org.apache.commons.io.monitor.FileAlterationListenerAdaptor#org.apache.wicket.WicketRuntimeException源码实例Demo

下面列出了org.apache.commons.io.monitor.FileAlterationListenerAdaptor#org.apache.wicket.WicketRuntimeException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: onedev   文件: ServletWebResponse.java
@Override
public void sendError(int sc, String msg)
{
	try
	{
		if (msg == null)
		{
			httpServletResponse.sendError(sc);
		}
		else
		{
			httpServletResponse.sendError(sc, msg);
		}
	}
	catch (IOException e)
	{
		throw new WicketRuntimeException(e);
	}
}
 
源代码2 项目: onedev   文件: AbstractClassResolver.java
@Override
public Iterator<URL> getResources(final String name)
{
	Set<URL> resultSet = new TreeSet<>(new UrlExternalFormComparator());

	try
	{
		// Try the classloader for the wicket jar/bundle
		Enumeration<URL> resources = Application.class.getClassLoader().getResources(name);
		loadResources(resources, resultSet);

		// Try the classloader for the user's application jar/bundle
		resources = Application.get().getClass().getClassLoader().getResources(name);
		loadResources(resources, resultSet);

		// Try the context class loader
		resources = getClassLoader().getResources(name);
		loadResources(resources, resultSet);
	}
	catch (Exception e)
	{
		throw new WicketRuntimeException(e);
	}

	return resultSet.iterator();
}
 
源代码3 项目: openmeetings   文件: Application.java
@Override
public void updateJpaAddresses() {
	StringBuilder sb = new StringBuilder();
	String delim = "";
	for (Member m : hazelcast.getCluster().getMembers()) {
		sb.append(delim).append(m.getAddress().getHost());
		delim = ";";
	}
	if (Strings.isEmpty(delim)) {
		sb.append("localhost");
	}
	try {
		cfgDao.updateClusterAddresses(sb.toString());
	} catch (UnknownHostException e) {
		log.error("Uexpected exception while updating JPA addresses", e);
		throw new WicketRuntimeException(e);
	}
}
 
源代码4 项目: webanno   文件: SassResourceStream.java
/**
 * Constructor.
 *
 * @param sassStream
 *            The resource stream that loads the Sass content. Only UrlResourceStream is
 *            supported at the moment!
 * @param scopeClass
 *            The name of the class used as a scope to resolve "package!" dependencies/imports
 */
public SassResourceStream(IResourceStream sassStream, String scopeClass)
{
    Args.notNull(sassStream, "sassStream");

    while (sassStream instanceof ResourceStreamWrapper) {
        ResourceStreamWrapper wrapper = (ResourceStreamWrapper) sassStream;
        try {
            sassStream = wrapper.getDelegate();
        }
        catch (Exception x) {
            throw new WicketRuntimeException(x);
        }
    }

    if (!(sassStream instanceof UrlResourceStream)) {
        throw new IllegalArgumentException(String.format("%s can work only with %s",
                SassResourceStream.class.getSimpleName(), UrlResourceStream.class.getName()));
    }

    URL sassUrl = ((UrlResourceStream) sassStream).getURL();

    SassCacheManager cacheManager = SassCacheManager.get();

    this.sassSource = cacheManager.getSassContext(sassUrl, scopeClass);
}
 
源代码5 项目: pm-wicket-utils   文件: BootstrapDateTimePicker.java
/**
 * Gets the DateTextField inside this datepicker wrapper.
 *
 * @return the date field
 */
public DateTextField getDateTextField()
{
	DateTextField component = visitChildren(DateTextField.class, new IVisitor<DateTextField, DateTextField>() {
		@Override
		public void component(DateTextField arg0, IVisit<DateTextField> arg1) {
			arg1.stop(arg0);
		}
	});

	if (component == null) {
		
		throw new WicketRuntimeException("BootstrapDateTimepicker didn't have any DateTextField child!");
	}
	
	return component;
}
 
源代码6 项目: wicket-orientdb   文件: StringQueryManager.java
public StringQueryManager(String sql) {
   	this.sql = sql;
   	Matcher matcher = PROJECTION_PATTERN.matcher(sql);
       if(matcher.find()) {
       	projection = matcher.group(1).trim();
       	Matcher expandMatcher = EXPAND_PATTERN.matcher(projection);
       	containExpand = expandMatcher.find();
       	if(containExpand) {
			countSql = matcher.replaceFirst("select sum("+expandMatcher.group(1)+".size()) as count from");
       	}
       	else {
       		countSql = matcher.replaceFirst("select count(*) from"); 
       	}
       }
       else {
           throw new WicketRuntimeException("Can't find 'object(<.>)' part in your request: "+sql);
       }
       hasOrderBy = ORDER_CHECK_PATTERN.matcher(sql).find();
       managers = Maps.newHashMap();
}
 
@Override
public ODocument apply(F input) {
	if(input==null)
	{
		return null;
	}
	else if(input instanceof ODocument)
	{
		return (ODocument)input;
	}
	else if(input instanceof ORID)
	{
		return ((ORID)input).getRecord();
	}
	else if(input instanceof CharSequence)
	{
		return new ORecordId(input.toString()).getRecord();
	}
	else
	{
		throw new WicketRuntimeException("Object '"+input+"' of type '"+input.getClass()+"' can't be converted to ODocument");
	}
}
 
源代码8 项目: wicket-orientdb   文件: CollectionAdapterModel.java
protected void setCollection(List<T> object)
{
	if(object==null) model.setObject(null);
	else 
	{
		M collection = model.getObject();
		if(collection!=null)
		{
			collection.clear();
			collection.addAll(object);
		}
		else
		{
			throw new WicketRuntimeException("Creation of collection is not supported. Please override this method of you need support.");
		}
	}
}
 
源代码9 项目: syncope   文件: AbstractAttrs.java
@SuppressWarnings({ "unchecked" })
private List<MembershipTO> loadMembershipAttrs() {
    List<MembershipTO> memberships = new ArrayList<>();
    try {
        membershipSchemas.clear();

        for (MembershipTO membership : (List<MembershipTO>) PropertyResolver.getPropertyField(
                "memberships", anyTO).get(anyTO)) {
            setSchemas(Pair.of(membership.getGroupKey(), membership.getGroupName()), getMembershipAuxClasses(
                    membership, anyTO.getType()));
            setAttrs(membership);

            if (AbstractAttrs.this instanceof PlainAttrs && !membership.getPlainAttrs().isEmpty()) {
                memberships.add(membership);
            } else if (AbstractAttrs.this instanceof DerAttrs && !membership.getDerAttrs().isEmpty()) {
                memberships.add(membership);
            } else if (AbstractAttrs.this instanceof VirAttrs && !membership.getVirAttrs().isEmpty()) {
                memberships.add(membership);
            }
        }
    } catch (WicketRuntimeException | IllegalArgumentException | IllegalAccessException ex) {
        // ignore
    }

    return memberships;
}
 
源代码10 项目: syncope   文件: AjaxWizard.java
private Serializable onApply(final AjaxRequestTarget target) throws TimeoutException {
    try {
        Future<Pair<Serializable, Serializable>> executor = execute(new ApplyFuture(target));

        Pair<Serializable, Serializable> res =
                executor.get(getMaxWaitTimeInSeconds(), TimeUnit.SECONDS);

        if (res.getLeft() != null) {
            send(pageRef.getPage(), Broadcast.BUBBLE, res.getLeft());
        }

        return res.getRight();
    } catch (InterruptedException | ExecutionException e) {
        if (e.getCause() instanceof CaptchaNotMatchingException) {
            throw (CaptchaNotMatchingException) e.getCause();
        }
        throw new WicketRuntimeException(e);
    }
}
 
源代码11 项目: syncope   文件: AuditHistoryDetails.java
private Model<String> toJSON(final AuditEntry auditEntry, final Class<T> reference) {
    try {
        String content = auditEntry.getBefore() == null
                ? MAPPER.readTree(auditEntry.getOutput()).get("entity").toPrettyString()
                : auditEntry.getBefore();

        T entity = MAPPER.readValue(content, reference);
        if (entity instanceof UserTO) {
            UserTO userTO = (UserTO) entity;
            userTO.setPassword(null);
            userTO.setSecurityAnswer(null);
        }

        return Model.of(MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(entity));
    } catch (Exception e) {
        LOG.error("While (de)serializing entity {}", auditEntry, e);
        throw new WicketRuntimeException(e);
    }
}
 
源代码12 项目: syncope   文件: ReportletWizardBuilder.java
@Override
protected Serializable onApplyInternal(final ReportletWrapper modelObject) {
    if (modelObject.getImplementationEngine() == ImplementationEngine.JAVA) {
        BeanWrapper confWrapper = PropertyAccessorFactory.forBeanPropertyAccess(modelObject.getConf());
        modelObject.getSCondWrapper().forEach((fieldName, pair) -> {
            confWrapper.setPropertyValue(fieldName, SearchUtils.buildFIQL(pair.getRight(), pair.getLeft()));
        });
        ImplementationTO reportlet = ImplementationRestClient.read(
                IdRepoImplementationType.REPORTLET, modelObject.getImplementationKey());
        try {
            reportlet.setBody(MAPPER.writeValueAsString(modelObject.getConf()));
            ImplementationRestClient.update(reportlet);
        } catch (Exception e) {
            throw new WicketRuntimeException(e);
        }
    }

    ReportTO reportTO = ReportRestClient.read(report);
    if (modelObject.isNew()) {
        reportTO.getReportlets().add(modelObject.getImplementationKey());
    }

    ReportRestClient.update(reportTO);
    return modelObject;
}
 
源代码13 项目: syncope   文件: AbstractAttrs.java
@SuppressWarnings("unchecked")
private List<MembershipTO> loadMemberships() {
    membershipSchemas.clear();

    List<MembershipTO> membs = new ArrayList<>();
    try {
        ((List<MembershipTO>) PropertyResolver.getPropertyField("memberships", anyTO).get(anyTO)).forEach(memb -> {
            setSchemas(memb.getGroupKey(),
                    anyTypeClassRestClient.list(getMembershipAuxClasses(memb, anyTO.getType())).
                            stream().map(EntityTO::getKey).collect(Collectors.toList()));
            setAttrs(memb);

            if (this instanceof PlainAttrs && !memb.getPlainAttrs().isEmpty()) {
                membs.add(memb);
            } else if (this instanceof DerAttrs && !memb.getDerAttrs().isEmpty()) {
                membs.add(memb);
            } else if (this instanceof VirAttrs && !memb.getVirAttrs().isEmpty()) {
                membs.add(memb);
            }
        });
    } catch (WicketRuntimeException | IllegalArgumentException | IllegalAccessException ex) {
        // ignore
    }

    return membs;
}
 
源代码14 项目: syncope   文件: SelectableRecorder.java
/**
 * Synchronize ids collection from the palette's model
 */
private void initIds() {
    // construct the model string based on selection collection
    IChoiceRenderer<? super T> renderer = getPalette().getChoiceRenderer();
    StringBuilder modelStringBuffer = new StringBuilder();
    Collection<T> modelCollection = getPalette().getModelCollection();
    if (modelCollection == null) {
        throw new WicketRuntimeException("Expected getPalette().getModelCollection() to return a non-null value."
                + " Please make sure you have model object assigned to the palette");
    }
    Iterator<T> selection = modelCollection.iterator();

    int i = 0;
    while (selection.hasNext()) {
        modelStringBuffer.append(renderer.getIdValue(selection.next(), i++));
        if (selection.hasNext()) {
            modelStringBuffer.append(',');
        }
    }

    // set model and update ids array
    String modelString = modelStringBuffer.toString();
    setDefaultModel(new Model<>(modelString));
    updateIds(modelString);
}
 
源代码15 项目: Orienteer   文件: MarkDownModel.java
@Override
protected String load() {
    String markDownValue = markDawnModel.getObject();
    if (Strings.isEmpty(markDownValue)) {
        return "";
    }
    try {
        MutableDataSet options = new MutableDataSet();
        options.set(Parser.EXTENSIONS, createExtensions());
        Parser parser = Parser.builder(options).build();
        HtmlRenderer renderer = HtmlRenderer.builder(options).build();

        Node node = parser.parse(markDawnModel.getObject());
        markDownValue = renderer.render(node);
    } catch (Exception e) {
        throw new WicketRuntimeException("Can't use flexmark-java for markups", e);
    }
    return markDownValue;
}
 
源代码16 项目: Orienteer   文件: PlantUmlService.java
@Override
public String asImage(String content)
{
	ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
	DeflaterOutputStream dos = new DeflaterOutputStream(baos, new Deflater(9, true));
	try
	{
		dos.write(content.getBytes());
		dos.flush();
		dos.close();
		//return urlPrefix+URLEncoder.encode(Base64.encodeBase64String(baos.toByteArray()), "UTF-8");
		return urlPrefix+AsciiEncoder.INSTANCE.encode(baos.toByteArray());
	} catch (IOException e)
	{
		throw new WicketRuntimeException("Can't encrypt content for '"+PlantUmlService.class.getSimpleName()+"'", e);
	}
}
 
源代码17 项目: Orienteer   文件: DefaultWidgetTypesRegistry.java
public IWidgetTypesRegistry register(String packageName, ClassLoader classLoader) {
	ClassPath classPath;
	try {
		classPath = ClassPath.from(classLoader);
	} catch (IOException e) {
		throw new WicketRuntimeException("Can't scan classpath", e);
	}
	ImmutableSet<ClassInfo> classesInPackage = classPath.getTopLevelClassesRecursive(packageName);
	for (ClassInfo classInfo : classesInPackage) {
		Class<?> clazz = classInfo.load();
		Widget widgetDescription = clazz.getAnnotation(Widget.class);
		if (widgetDescription != null) {
			if (!AbstractWidget.class.isAssignableFrom(clazz))
				throw new WicketRuntimeException("@" + Widget.class.getSimpleName() + " should be only on widgets");
			Class<? extends AbstractWidget<Object>> widgetClass = (Class<? extends AbstractWidget<Object>>) clazz;
			register(widgetClass);
		}
	}
	return this;
}
 
源代码18 项目: nextreports-server   文件: EntityBrowserPanel.java
private Entity getChild(Entity node, String name) {
Entity[] children;
try {
	children = storageService.getEntityChildren(node.getPath());
} catch (NotFoundException e) {
	throw new WicketRuntimeException(e);
}

         for (Entity tmp : children) {
             if (name.equals(tmp.getName())) {
                 return tmp;
             }
         }

         return null;
     }
 
源代码19 项目: jasypt   文件: JasyptCrypt.java
/**
 * <p>
 * Decrypts a string using URL and filename safe Base64 decoding.
 * </p>
 * 
 * @param text the text to be decrypted.
 * @return the decrypted string.
 */
public String decryptUrlSafe(final String text) {
    
    try {
        final byte[] base64EncryptedBytes = text.getBytes();
        final byte[] encryptedBytes = 
            Base64.decodeBase64(base64EncryptedBytes);
        return new String(
                this.encryptor.decrypt(encryptedBytes), CHARACTER_ENCODING);
    } catch (Exception e) {
        throw new WicketRuntimeException(e);
    }
    
}
 
源代码20 项目: jasypt   文件: JasyptCrypt.java
/**
 * <p>
 * Encrypts a string using URL and filename safe Base64 encoding.
 * </p>
 * 
 * @param plainText the text to be encrypted.
 * @return encrypted string.
 */
public String encryptUrlSafe(final String plainText) {
    
    try {
        final byte[] plainBytes = plainText.getBytes(CHARACTER_ENCODING); 
        final byte[] encryptedBytes = this.encryptor.encrypt(plainBytes);
        return new String(Base64.encodeBase64(encryptedBytes));
    } catch (Exception e) {
        throw new WicketRuntimeException(e);
    }
    
}
 
源代码21 项目: jasypt   文件: JasyptCrypt.java
/**
 * <p>
 * Decrypts a string using URL and filename safe Base64 decoding.
 * </p>
 * 
 * @param text the text to be decrypted.
 * @return the decrypted string.
 */
public String decryptUrlSafe(final String text) {
    
    try {
        final byte[] base64EncryptedBytes = text.getBytes();
        final byte[] encryptedBytes = 
            Base64UrlSafe.decodeBase64(base64EncryptedBytes);
        return new String(
                this.encryptor.decrypt(encryptedBytes), CHARACTER_ENCODING);
    } catch (Exception e) {
        throw new WicketRuntimeException(e);
    }
    
}
 
源代码22 项目: jasypt   文件: JasyptCrypt.java
/**
 * <p>
 * Encrypts a string using URL and filename safe Base64 encoding.
 * </p>
 * 
 * @param plainText the text to be encrypted.
 * @return encrypted string.
 */
public String encryptUrlSafe(final String plainText) {
    
    try {
        final byte[] plainBytes = plainText.getBytes(CHARACTER_ENCODING); 
        final byte[] encryptedBytes = this.encryptor.encrypt(plainBytes);
        return new String(Base64UrlSafe.encodeBase64(encryptedBytes));
    } catch (Exception e) {
        throw new WicketRuntimeException(e);
    }
    
}
 
源代码23 项目: jasypt   文件: JasyptCrypt.java
/**
 * <p>
 * Decrypts a string using URL and filename safe Base64 decoding.
 * </p>
 * 
 * @param text the text to be decrypted.
 * @return the decrypted string.
 */
public String decryptUrlSafe(final String text) {
    
    try {
        final byte[] base64EncryptedBytes = text.getBytes();
        final byte[] encryptedBytes = 
            Base64UrlSafe.decodeBase64(base64EncryptedBytes);
        return new String(
                this.encryptor.decrypt(encryptedBytes), CHARACTER_ENCODING);
    } catch (Exception e) {
        throw new WicketRuntimeException(e);
    }
    
}
 
源代码24 项目: jasypt   文件: JasyptCrypt.java
/**
 * <p>
 * Encrypts a string using URL and filename safe Base64 encoding.
 * </p>
 * 
 * @param plainText the text to be encrypted.
 * @return encrypted string.
 */
public String encryptUrlSafe(final String plainText) {
    
    try {
        final byte[] plainBytes = plainText.getBytes(CHARACTER_ENCODING); 
        final byte[] encryptedBytes = this.encryptor.encrypt(plainBytes);
        return new String(Base64UrlSafe.encodeBase64(encryptedBytes));
    } catch (Exception e) {
        throw new WicketRuntimeException(e);
    }
    
}
 
private File getGazeteerFile(Gazeteer aGazeteer)
{
    try {
        return gazeteerService.getGazeteerFile(aGazeteer);
    }
    catch (IOException e) {
        throw new WicketRuntimeException(e);
    }
}
 
源代码26 项目: onedev   文件: FormComponent.java
/**
 * @return The parent form for this form component
 */
public Form<?> getForm()
{
	Form<?> form = Form.findForm(this);
	if (form == null)
	{
		throw new WicketRuntimeException("Could not find Form parent for " + this);
	}
	return form;
}
 
源代码27 项目: onedev   文件: FormComponent.java
/**
 * Sets the required flag
 * 
 * @param required
 * @return this for chaining
 */
public final FormComponent<T> setRequired(final boolean required)
{
	if (!required && getType() != null && getType().isPrimitive())
	{
		throw new WicketRuntimeException(
				"FormComponent has to be required when the type is primitive class: " + this);
	}
	if (required != isRequired())
	{
		addStateChange();
	}
	setFlag(FLAG_REQUIRED, required);
	return this;
}
 
源代码28 项目: webanno   文件: UrlImporter.java
private String read(URL url)
{
    try {
        return IOUtils.toString(url.openStream(), StandardCharsets.UTF_8.name());
    }
    catch (IOException ex) {
        throw new WicketRuntimeException(ex);
    }
}
 
源代码29 项目: sakai   文件: StylableSelectOptions.java
/**
 * @see org.apache.wicket.Component#onBeforeRender()
 */
protected final void onPopulate() {
	if(size() == 0 || recreateChoices){
		// populate this repeating view with SelectOption components
		removeAll();

		Object modelObject = getDefaultModelObject();

		if(modelObject != null){
			if(!(modelObject instanceof Collection)){
				throw new WicketRuntimeException("Model object " + modelObject + " not a collection");
			}

			// iterator over model objects for SelectOption components
			Iterator it = ((Collection) modelObject).iterator();

			while (it.hasNext()){
				// we need a container to represent a row in repeater
				WebMarkupContainer row = new WebMarkupContainer(newChildId());
				row.setRenderBodyOnly(true);
				add(row);

				// we add our actual SelectOption component to the row
				Object value = it.next();
				String text = renderer.getDisplayValue(value);
				IModel model = renderer.getModel(value);
				String style = renderer.getStyle(value);
				row.add(newOption(text, model, style));
			}
		}
	}
}
 
源代码30 项目: sakai   文件: AbstractInfinitePagingDataGridView.java
/**
 * @param item
 * @see org.apache.wicket.markup.repeater.RefreshingView#populateItem(org.apache.wicket.markup.repeater.Item)
 */
@Override
protected final void populateItem(final Item<T> item)
{
	RepeatingView cells = new RepeatingView(CELL_REPEATER_ID);
	item.add(cells);

	int populatorsNumber = populators.size();
	for (int i = 0; i < populatorsNumber; i++)
	{
		ICellPopulator<T> populator = populators.get(i);
		IModel<ICellPopulator<T>> populatorModel = new Model<>(populator);
		Item<ICellPopulator<T>> cellItem = newCellItem(cells.newChildId(), i, populatorModel);
		cells.add(cellItem);

		populator.populateItem(cellItem, CELL_ITEM_ID, item.getModel());

		if (cellItem.get("cell") == null)
		{
			throw new WicketRuntimeException(
				populator.getClass().getName() +
					".populateItem() failed to add a component with id [" +
					CELL_ITEM_ID +
					"] to the provided [cellItem] object. Make sure you call add() on cellItem and make sure you gave the added component passed in 'componentId' id. ( *cellItem*.add(new MyComponent(*componentId*, rowModel) )");
		}
	}
}