org.apache.wicket.WicketRuntimeException Java Examples
The following examples show how to use
org.apache.wicket.WicketRuntimeException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReportletWizardBuilder.java From syncope with Apache License 2.0 | 6 votes |
@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; }
Example #2
Source File: BootstrapDateTimePicker.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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; }
Example #3
Source File: PlantUmlService.java From Orienteer with Apache License 2.0 | 6 votes |
@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); } }
Example #4
Source File: MarkDownModel.java From Orienteer with Apache License 2.0 | 6 votes |
@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; }
Example #5
Source File: StringQueryManager.java From wicket-orientdb with Apache License 2.0 | 6 votes |
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(); }
Example #6
Source File: ConvertToODocumentFunction.java From wicket-orientdb with Apache License 2.0 | 6 votes |
@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"); } }
Example #7
Source File: DefaultWidgetTypesRegistry.java From Orienteer with Apache License 2.0 | 6 votes |
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; }
Example #8
Source File: SassResourceStream.java From webanno with Apache License 2.0 | 6 votes |
/** * 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); }
Example #9
Source File: Application.java From openmeetings with Apache License 2.0 | 6 votes |
@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); } }
Example #10
Source File: CollectionAdapterModel.java From wicket-orientdb with Apache License 2.0 | 6 votes |
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."); } } }
Example #11
Source File: SelectableRecorder.java From syncope with Apache License 2.0 | 6 votes |
/** * 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); }
Example #12
Source File: AbstractClassResolver.java From onedev with MIT License | 6 votes |
@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(); }
Example #13
Source File: AbstractAttrs.java From syncope with Apache License 2.0 | 6 votes |
@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; }
Example #14
Source File: ServletWebResponse.java From onedev with MIT License | 6 votes |
@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); } }
Example #15
Source File: EntityBrowserPanel.java From nextreports-server with Apache License 2.0 | 6 votes |
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; }
Example #16
Source File: AbstractAttrs.java From syncope with Apache License 2.0 | 6 votes |
@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; }
Example #17
Source File: AjaxWizard.java From syncope with Apache License 2.0 | 6 votes |
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); } }
Example #18
Source File: AuditHistoryDetails.java From syncope with Apache License 2.0 | 6 votes |
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); } }
Example #19
Source File: EntityTreeProvider.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override public boolean hasChildren(Entity entity) { // TODO performance wicket-6 try { return !getChildren(entity.getId()).isEmpty(); } catch (NotFoundException e) { throw new WicketRuntimeException(e); } }
Example #20
Source File: EntityBrowserPanel.java From nextreports-server with Apache License 2.0 | 5 votes |
private Entity getRoot() { try { return storageService.getEntity(getRootPath()); } catch (NotFoundException e) { throw new WicketRuntimeException(e); } }
Example #21
Source File: EntityTreeProvider.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override public Iterator<? extends Entity> getRoots() { List<Entity> roots = new ArrayList<Entity>(); try { roots.add(storageService.getEntity(rootPath)); } catch (NotFoundException e) { throw new WicketRuntimeException(e); } return roots.iterator(); }
Example #22
Source File: EntityBrowserPanel.java From nextreports-server with Apache License 2.0 | 5 votes |
private Entity getCurrentEntity() { String path = getCurrentPath(); try { return storageService.getEntity(path); } catch (NotFoundException e) { throw new WicketRuntimeException(e); } }
Example #23
Source File: SimpleVisualizer.java From Orienteer with Apache License 2.0 | 5 votes |
public <T> Component createComponent(String id, DisplayMode mode, IModel<T> model) { Class<? extends Component> componentClass = DisplayMode.EDIT.equals(mode)?editComponentClass:viewComponentClass; try { return componentClass.getConstructor(String.class, IModel.class).newInstance(id, model); } catch (Exception e) { throw new WicketRuntimeException("Can't create component", e); } }
Example #24
Source File: LoginPageTest.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
@Test public void testLoginAndLogout() { final LoginPage loginPage = new LoginPage(new PageParameters()); // start and render the test page tester.startPage(loginPage); // assert rendered page class tester.assertRenderedPage(LoginPage.class); // assert rendered label component tester.assertVisible("body:form:username"); FormTester form = tester.newFormTester("body:form"); form.setValue(findComponentByLabel(form, "username"), "demo"); form.setValue(findComponentByLabel(form,"password"), "wrong"); form.submit(KEY_LOGINPAGE_BUTTON_LOGIN); tester.assertRenderedPage(LoginPage.class); form = tester.newFormTester("body:form"); form.setValue(findComponentByLabel(form,"username"), TestBase.TEST_ADMIN_USER); form.setValue(findComponentByLabel(form,"password"), TestBase.TEST_ADMIN_USER_PASSWORD); form.submit(KEY_LOGINPAGE_BUTTON_LOGIN); tester.assertRenderedPage(CalendarPage.class); tester.startPage(AddressListPage.class); tester.assertRenderedPage(AddressListPage.class); loginTestAdmin(); // login should be ignored. tester.assertRenderedPage(WicketUtils.getDefaultPage()); logout(); try { tester.startPage(AddressListPage.class); Assert.fail("Page must not be available, user not logged-in."); } catch (final WicketRuntimeException ex) { // Everything fine. } }
Example #25
Source File: AbstractMetaPanel.java From Orienteer with Apache License 2.0 | 5 votes |
private void convertInput(FormComponent<V> formComponent) { try { Method convertInputMethod = FormComponent.class.getDeclaredMethod("convertInput"); convertInputMethod.setAccessible(true); convertInputMethod.invoke(formComponent); } catch (Exception e) { throw new WicketRuntimeException("Can't invoke 'convertInput' on component", e); } }
Example #26
Source File: BirtImage.java From Orienteer with Apache License 2.0 | 5 votes |
public IResource toResource() { try { if(source == IImage.URL_IMAGE) { return new ResourceStreamResource(new UrlResourceStream(new URL(getID()))); } else if (source == IImage.FILE_IMAGE) { return new FileSystemResource( Paths.get(FileUtil.getURI(getID()))); } else { return new ByteArrayResource(getMIMEType(), data); } } catch (MalformedURLException e) { throw new WicketRuntimeException("Can't transform to resource", e); } }
Example #27
Source File: AbstractInfinitePagingDataGridView.java From sakai with Educational Community License v2.0 | 5 votes |
/** * @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) )"); } } }
Example #28
Source File: StylableSelectOptions.java From sakai with Educational Community License v2.0 | 5 votes |
/** * @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)); } } } }
Example #29
Source File: BaseModal.java From syncope with Apache License 2.0 | 5 votes |
private BaseModal<T> setInternalContent(final Panel component) { if (!component.getId().equals(getContentId())) { throw new WicketRuntimeException("Modal content id is wrong. " + "Component ID: " + component.getId() + "; content ID: " + getContentId()); } content.replaceWith(component); content = component; return this; }
Example #30
Source File: PolicyRuleWizardBuilder.java From syncope with Apache License 2.0 | 5 votes |
@Override protected Serializable onApplyInternal(final PolicyRuleWrapper modelObject) { PolicyTO policyTO = PolicyRestClient.getPolicy(type, policy); ComposablePolicy composable; if (policyTO instanceof ComposablePolicy) { composable = (ComposablePolicy) policyTO; } else { throw new IllegalStateException("Non composable policy"); } if (modelObject.getImplementationEngine() == ImplementationEngine.JAVA) { ImplementationTO rule = ImplementationRestClient.read(implementationType, modelObject.getImplementationKey()); try { rule.setBody(MAPPER.writeValueAsString(modelObject.getConf())); ImplementationRestClient.update(rule); } catch (Exception e) { throw new WicketRuntimeException(e); } } if (modelObject.isNew()) { composable.getRules().add(modelObject.getImplementationKey()); } PolicyRestClient.updatePolicy(type, policyTO); return modelObject; }