List of usage examples for org.apache.wicket.util.string StringValue isNull
public boolean isNull()
From source file:cz.zcu.kiv.eegdatabase.wui.ui.search.SearchResultDataProvider.java
License:Apache License
public SearchResultDataProvider(StringValue searchString, ResultCategory category) { Injector.get().inject(this); System.out.println(searchString); if (searchString.isNull()) { this.searchQuery = ""; } else {//from w w w. j a v a 2 s .co m this.searchQuery = searchString.toString(); } this.category = category; }
From source file:de.alpharogroup.wicket.base.util.parameter.PageParametersExtensions.java
License:Apache License
/** * <p>//w w w .j a v a 2 s . c o m * Checks if the given StringValue is not null and the value of the given StringValue object is * not null and the value of the given StringValue object is not empty. * </p> * * @param stringValue * the StringValue to check, may be null * @return <code>true</code> if the StringValue is not null and the value of the given * StringValue object is not null and the value of the given StringValue object is not * empty otherwise false. */ public static final boolean isNotNullOrEmpty(final StringValue stringValue) { return (stringValue != null) && !stringValue.isNull() && !stringValue.isEmpty(); }
From source file:de.alpharogroup.wicket.base.util.parameter.PageParametersExtensions.java
License:Apache License
/** * <p>/*from w w w. ja v a2s .com*/ * Checks if the given StringValue is null or the value of the given StringValue object is null * or the value of the given StringValue object is empty. * </p> * * @param stringValue * the StringValue to check, may be null * @return <code>true</code> if the StringValue is null or the value of the given StringValue * object is null or the value of the given StringValue object is empty. */ public static final boolean isNullOrEmpty(final StringValue stringValue) { return (stringValue == null) || stringValue.isNull() || stringValue.isEmpty(); }
From source file:eu.esdihumboldt.hale.server.templates.war.pages.EditTemplatePage.java
License:Open Source License
@Override protected void addControls() { StringValue idParam = getPageParameters().get(0); if (!idParam.isNull() && !idParam.isEmpty()) { String templateId = idParam.toString(); OrientGraph graph = DatabaseHelper.getGraph(); try {//from w w w .j a v a 2 s . c o m Template template = null; try { template = Template.getByTemplateId(graph, templateId); } catch (NonUniqueResultException e) { log.error("Duplicate template representation: " + templateId, e); } if (template != null) { // get associated user Vertex v = template.getV(); Iterator<Vertex> owners = v.getVertices(Direction.OUT, "owner").iterator(); if (UserUtil.isAdmin() // user is admin // or user is owner || (owners.hasNext() && UserUtil.getLogin().equals(new User(owners.next(), graph).getLogin()))) { add(new TemplateForm("edit-form", false, templateId)); } else { throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_FORBIDDEN); } } else { throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND, "Template not found."); } } finally { graph.shutdown(); } } else throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_BAD_REQUEST, "Template identifier must be specified."); }
From source file:eu.esdihumboldt.hale.server.templates.war.pages.TemplatePage.java
License:Open Source License
@SuppressWarnings("serial") @Override//from w ww . ja v a2 s . co m protected void addControls(boolean loggedIn) { super.addControls(loggedIn); StringValue idParam = getPageParameters().get(0); if (!idParam.isNull() && !idParam.isEmpty()) { String templateId = idParam.toString(); OrientGraph graph = DatabaseHelper.getGraph(); try { Template template = null; try { template = Template.getByTemplateId(graph, templateId); } catch (NonUniqueResultException e) { log.error("Duplicate template representation: " + templateId, e); } if (template != null) { // name Label name = new Label("name", template.getName()); add(name); // download String href = TemplateLocations.getTemplateDownloadUrl(templateId); ExternalLink download = new ExternalLink("download", href); add(download); // project location WebMarkupContainer project = new WebMarkupContainer("project"); project.add(AttributeModifier.replace("value", TemplateLocations.getTemplateProjectUrl(scavenger, templateId))); add(project); // author Label author = new Label("author", template.getAuthor()); add(author); // edit-buttons container WebMarkupContainer editButtons = new WebMarkupContainer("edit-buttons"); editButtons.setVisible(false); add(editButtons); // deleteDialog container WebMarkupContainer deleteDialog = new WebMarkupContainer("deleteDialog"); deleteDialog.setVisible(false); add(deleteDialog); // user String userName; Vertex v = template.getV(); boolean showEditPart = UserUtil.isAdmin(); Iterator<Vertex> owners = v.getVertices(Direction.OUT, "owner").iterator(); if (owners.hasNext()) { User user = new User(owners.next(), graph); userName = UserUtil.getDisplayName(user); showEditPart = loggedIn && UserUtil.getLogin().equals(user.getLogin()); } else { userName = "Unregistered user"; } // edit buttons if (showEditPart) { editButtons.setVisible(true); deleteDialog.setVisible(true); // edit editButtons.add(new BookmarkablePageLink<>("edit", EditTemplatePage.class, new PageParameters().set(0, templateId))); // update editButtons.add(new BookmarkablePageLink<>("update", UpdateTemplatePage.class, new PageParameters().set(0, templateId))); // delete deleteDialog.add(new DeleteTemplateLink("delete", templateId)); } Label user = new Label("user", userName); add(user); // description String descr = template.getDescription(); String htmlDescr = null; if (descr == null || descr.isEmpty()) { descr = "No description for the project template available."; } else { // convert markdown to htmlDescr = new PegDownProcessor(Extensions.AUTOLINKS | Extensions.SUPPRESS_ALL_HTML | Extensions.HARDWRAPS | Extensions.SMARTYPANTS).markdownToHtml(descr); } // description in pre Label description = new Label("description", descr); description.setVisible(htmlDescr == null); add(description); // description in div Label htmlDescription = new Label("html-description", htmlDescr); htmlDescription.setVisible(htmlDescr != null); htmlDescription.setEscapeModelStrings(false); add(htmlDescription); // invalid WebMarkupContainer statusInvalid = new WebMarkupContainer("invalid"); statusInvalid.setVisible(!template.isValid()); add(statusInvalid); // resources ResourcesPanel resources = new ResourcesPanel("resources", templateId); add(resources); // project popover WebMarkupContainer projectPopover = new WebMarkupContainer("project-popover"); projectPopover.add(new HTMLPopoverBehavior(Model.of("Load template in HALE"), new PopoverConfig().withPlacement(Placement.bottom)) { @Override public Component newBodyComponent(String markupId) { return new ProjectURLPopover(markupId); } }); add(projectPopover); } else { throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND, "Template not found."); } } finally { graph.shutdown(); } } else throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_BAD_REQUEST, "Template identifier must be specified."); }
From source file:eu.esdihumboldt.hale.server.templates.war.pages.UpdateTemplatePage.java
License:Open Source License
@Override protected void addControls() { StringValue idParam = getPageParameters().get(0); if (!idParam.isNull() && !idParam.isEmpty()) { String templateId = idParam.toString(); OrientGraph graph = DatabaseHelper.getGraph(); try {//from w ww . ja va2 s . co m Template template = null; try { template = Template.getByTemplateId(graph, templateId); } catch (NonUniqueResultException e) { log.error("Duplicate template representation: " + templateId, e); } if (template != null) { // get associated user Vertex v = template.getV(); Iterator<Vertex> owners = v.getVertices(Direction.OUT, "owner").iterator(); if (UserUtil.isAdmin() // user is admin // or user is owner || (owners.hasNext() && UserUtil.getLogin().equals(new User(owners.next(), graph).getLogin()))) { // template name add(new Label("name", template.getName())); // upload form add(new TemplateUploadForm("upload-form", templateId)); } else { throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_FORBIDDEN); } } else { throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND, "Template not found."); } } finally { graph.shutdown(); } } else throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_BAD_REQUEST, "Template identifier must be specified."); }
From source file:fiftyfive.wicket.shiro.markup.LogoutPage.java
License:Apache License
/** * Called by {@link #onBeforeRender} after {@link #logout} to redirect to another page. * By default this is the application home page. However if a {@code "to"} page parameter * was provided, assume it is a URI and redirect to that URI instead. For security reasons, * full URLs (i.e. something starting with {@code http}) are ignored. * * @throws RedirectToUrlException to cause Wicket to perform a 302 redirect *///from w w w . j a va2 s. com protected void redirectAfterLogout() throws RedirectToUrlException { StringValue to = getPageParameters().get("to"); // If "to" param was not specified, or was erroneously set to // an absolute URL (i.e. containing a ":" like "http://blah"), then fall back // to the home page. if (null == to || to.isNull() || to.toString().indexOf(":") >= 0) { to = StringValue.valueOf(urlFor(getApplication().getHomePage(), null)); } throw new RedirectToUrlException(to.toString(), 302); }
From source file:nl.ru.cmbi.vase.web.page.AlignmentPage.java
License:Apache License
public AlignmentPage(final PageParameters parameters) { log.info("start AlignmentPage with parameters " + parameters.toString()); StringValue structureIDString = parameters.get(0), chainIDString = parameters.get(1); if (structureIDString == null || structureIDString.isNull() || structureIDString.isEmpty()) { throw new RestartResponseAtInterceptPageException(new ErrorPage("structure id missing")); } else {//from w w w.ja v a2s . com structureID = structureIDString.toString().toLowerCase(); if (chainIDString != null && !chainIDString.isNull() && !chainIDString.isEmpty()) { chainID = chainIDString.toChar(); } try { File xmlFile = new File(Config.getCacheDir(), structureID + ".xml"), gzXmlFile = new File(Config.getCacheDir(), structureID + ".xml.gz"); if (xmlFile.isFile()) { VASEDataObject data = VASEXMLParser.parse(new FileInputStream(xmlFile)); this.initPageWith(data); } else if (gzXmlFile.isFile()) { VASEDataObject data = VASEXMLParser.parse(new GZIPInputStream(new FileInputStream(xmlFile))); this.initPageWith(data); } else { if (Config.isXmlOnly()) { throw new RestartResponseAtInterceptPageException(new ErrorPage( "VASE is running in xml-only mode, so only xml-entries can be accessed. (see homepage)")); } InputStream pdbIn = Utils.getPdbInputStream(structureID); if (pdbIn == null) { throw new RestartResponseAtInterceptPageException( new ErrorPage("Unable to resolve PDB URL for: " + structureID)); } InputStream stockholmInputStream = Utils.getStockholmInputStream(structureID); if (stockholmInputStream == null) { throw new RestartResponseAtInterceptPageException( new ErrorPage("No alignment data for: " + structureID)); } Set<Character> stockholmChainIDs = StockholmParser.listChainsInStockholm(stockholmInputStream); if (chainID == null) { if (stockholmChainIDs.size() == 1) { // no chain id needs to be given, since there's only one chainID = stockholmChainIDs.iterator().next(); } else { // Redirect to a page with chain selection PageParameters params = new PageParameters(); params.add(SearchResultsPage.parameterName, structureID); this.setResponsePage(SearchResultsPage.class, params); return; } } else if (!stockholmChainIDs.contains(chainID)) { throw new RestartResponseAtInterceptPageException( new ErrorPage("No such chain in " + structureID + ": " + chainID)); } stockholmInputStream = Utils.getStockholmInputStream(structureID); VASEDataObject data = StockholmParser.parseStockHolm(stockholmInputStream, pdbIn, structureID, chainID); if (data == null) log.error("data is null"); this.initPageWith(data); } } catch (RestartResponseAtInterceptPageException e) { //just rethrow it throw e; } catch (Exception e) { // any other type of exception log.error("Error getting alignments for " + structureIDString + " : " + e.getMessage(), e); throw new RestartResponseAtInterceptPageException( new ErrorPage("Error getting alignments for " + structureIDString + " : " + e.toString())); } } }
From source file:nl.ru.cmbi.vase.web.page.ErrorPage.java
License:Apache License
public ErrorPage(PageParameters params) { String message = ""; StringValue messageValue = params.get("message"); if (messageValue != null && !messageValue.isNull()) { message = messageValue.toString(); message = org.apache.wicket.util.string.Strings.escapeMarkup(message).toString(); message = message.replaceAll("[\n\r]", "<br/>"); }/*w w w. j a v a 2 s . com*/ setPageTitle("ERROR"); add(new Label("message", message).setEscapeModelStrings(false)); add(new BookmarkablePageLink("home", this.getApplication().getHomePage())); }
From source file:org.antbear.jee.wicket.GeolocationAjaxBehavior.java
License:Apache License
@Override protected void respond(AjaxRequestTarget target) { log.debug("respond"); Request request = RequestCycle.get().getRequest(); IRequestParameters requestParameters = request.getRequestParameters(); StringValue svStatus = requestParameters.getParameterValue("status"); if (svStatus == null || svStatus.isNull() || svStatus.isEmpty()) throw new RuntimeException("Invariant violation: status is a required parameter"); Integer status = svStatus.toInteger(); if (status == 0) { StringValue svMessage = requestParameters.getParameterValue("msg"); if (svMessage == null || svMessage.isNull() || svMessage.isEmpty()) throw new RuntimeException("Invariant violation: message is a required parameter"); log.debug("Geolocation failed: " + svMessage.toString()); onError(target, svMessage.toString()); } else {//from w w w. j av a 2s . c o m StringValue svLatitude = requestParameters.getParameterValue("lat"); if (svLatitude == null || svLatitude.isNull() || svLatitude.isEmpty()) throw new RuntimeException("Invariant violation: message is a required parameter"); StringValue svLongitude = requestParameters.getParameterValue("lon"); if (svLongitude == null || svLongitude.isNull() || svLongitude.isEmpty()) throw new RuntimeException("Invariant violation: message is a required parameter"); log.debug("Geolocation received: lat " + svLatitude.toDouble() + ", lon " + svLongitude.toDouble()); onLocation(target, svLatitude.toDouble(), svLongitude.toDouble()); } }