List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml
public static String escapeHtml(String input)
From source file:ch.systemsx.cisd.openbis.generic.server.business.bo.common.EntityPropertiesEnricher.java
private Long2ObjectMap<MaterialType> getMaterialTypes() { final CodeRecord[] typeCodes = query.getMaterialTypes(); final Long2ObjectOpenHashMap<MaterialType> materialTypeMap = new Long2ObjectOpenHashMap<MaterialType>( typeCodes.length);// w ww . j a v a 2s.c o m for (CodeRecord t : typeCodes) { final MaterialType type = new MaterialType(); type.setCode(StringEscapeUtils.escapeHtml(t.code)); materialTypeMap.put(t.id, type); } materialTypeMap.trim(); return materialTypeMap; }
From source file:at.gv.egovernment.moa.id.auth.servlet.VerifyIdentityLinkServlet.java
/** * Verifies the identity link and responds with a new * <code>CreateXMLSignatureRequest</code> or a new <code> * InfoboxReadRequest</code> (in case of a foreign eID card). * <br>//from ww w. jav a 2 s. c o m * Request parameters: * <ul> * <li>MOASessionID: ID of associated authentication session</li> * <li>XMLResponse: <code><InfoboxReadResponse></code></li> * </ul> * Response: * <ul> * <li>Content type: <code>"text/xml"</code></li> * <li>Content: see return value of {@link AuthenticationServer#verifyIdentityLink}</li> * <li>Error status: <code>500</code> * </ul> * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest, HttpServletResponse) */ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Logger.debug("POST VerifyIdentityLink"); Logger.warn(getClass().getName() + " is deprecated and should not be used any more."); Map<String, String> parameters; String pendingRequestID = null; try { parameters = getParameters(req); } catch (Exception e) { Logger.error("Parsing mulitpart/form-data request parameters failed: " + e.getMessage()); throw new IOException(e.getMessage()); } String sessionID = req.getParameter(PARAM_SESSIONID); // escape parameter strings sessionID = StringEscapeUtils.escapeHtml(sessionID); pendingRequestID = AuthenticationSessionStoreage.getPendingRequestID(sessionID); resp.setHeader(MOAIDAuthConstants.HEADER_EXPIRES, MOAIDAuthConstants.HEADER_VALUE_EXPIRES); resp.setHeader(MOAIDAuthConstants.HEADER_PRAGMA, MOAIDAuthConstants.HEADER_VALUE_PRAGMA); resp.setHeader(MOAIDAuthConstants.HEADER_CACHE_CONTROL, MOAIDAuthConstants.HEADER_VALUE_CACHE_CONTROL); resp.addHeader(MOAIDAuthConstants.HEADER_CACHE_CONTROL, MOAIDAuthConstants.HEADER_VALUE_CACHE_CONTROL_IE); try { // check parameter if (!ParamValidatorUtils.isValidSessionID(sessionID)) throw new WrongParametersException("VerifyIdentityLink", PARAM_SESSIONID, "auth.12"); AuthenticationSession session = AuthenticationServer.getSession(sessionID); //change MOASessionID sessionID = AuthenticationSessionStoreage.changeSessionID(session); String createXMLSignatureRequestOrRedirect = AuthenticationServer.getInstance() .verifyIdentityLink(session, parameters); Logger.debug(createXMLSignatureRequestOrRedirect); if (createXMLSignatureRequestOrRedirect == null) { // no identity link found boolean useMandate = session.getUseMandate(); if (useMandate) { Logger.error("Online-Mandate Mode for foreign citizencs not supported."); throw new AuthenticationException("auth.13", null); } try { Logger.info("Send InfoboxReadRequest to BKU to get signer certificate."); // create the InfoboxReadRequest to get the certificate String infoboxReadRequest = new InfoboxReadRequestBuilderCertificate().build(true); // build dataurl (to the VerifyCertificateSerlvet) String dataurl = new DataURLBuilder().buildDataURL(session.getAuthURL(), REQ_VERIFY_CERTIFICATE, session.getSessionID()); ServletUtils.writeCreateXMLSignatureRequest(resp, infoboxReadRequest, AuthenticationServer.REQ_PROCESS_VALIDATOR_INPUT, "VerifyIdentityLink", dataurl); } catch (Exception e) { handleError(null, e, req, resp, pendingRequestID); } } else { boolean useMandate = session.getUseMandate(); if (useMandate) { // Mandate modus // read certificate and set dataurl to Logger.debug("Send InfoboxReadRequest to BKU to get signer certificate."); String infoboxReadRequest = new InfoboxReadRequestBuilderCertificate().build(true); // build dataurl (to the GetForeignIDSerlvet) String dataurl = new DataURLBuilder().buildDataURL(session.getAuthURL(), REQ_VERIFY_CERTIFICATE, session.getSessionID()); //Logger.debug("ContentType set to: application/x-www-form-urlencoded (ServletUtils)"); //ServletUtils.writeCreateXMLSignatureRequestURLEncoded(resp, session, infoboxReadRequest, AuthenticationServer.REQ_PROCESS_VALIDATOR_INPUT, "VerifyIdentityLink", dataurl); Logger.debug("ContentType set to: text/xml;charset=UTF-8 (ServletUtils)"); ServletUtils.writeCreateXMLSignatureRequest(resp, infoboxReadRequest, AuthenticationServer.REQ_PROCESS_VALIDATOR_INPUT, "VerifyIdentityLink", dataurl); } else { Logger.info("Normal"); OAAuthParameter oaParam = AuthConfigurationProvider.getInstance() .getOnlineApplicationParameter(session.getPublicOAURLPrefix()); AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance(); createXMLSignatureRequestOrRedirect = AuthenticationServer.getInstance() .getCreateXMLSignatureRequestAuthBlockOrRedirect(session, authConf, oaParam); ServletUtils.writeCreateXMLSignatureRequestOrRedirect(resp, session, createXMLSignatureRequestOrRedirect, AuthenticationServer.REQ_PROCESS_VALIDATOR_INPUT, "VerifyIdentityLink"); } } try { AuthenticationSessionStoreage.storeSession(session); } catch (MOADatabaseException e) { Logger.info("No valid MOA session found. Authentification process is abourted."); throw new AuthenticationException("auth.20", null); } } catch (ParseException ex) { handleError(null, ex, req, resp, pendingRequestID); } catch (MOAIDException ex) { handleError(null, ex, req, resp, pendingRequestID); } catch (Exception e) { Logger.error("IdentityLinkValidation has an interal Error.", e); } finally { ConfigurationDBUtils.closeSession(); } }
From source file:de.hybris.platform.acceleratorservices.storefront.util.PageTitleResolver.java
/** * creates page title for given code/*from w w w. j a v a 2 s . c o m*/ */ public String resolveProductPageTitle(final ProductModel product) { // Lookup categories final List<CategoryModel> path = getCategoryPath(product); // Lookup site (or store) final CMSSiteModel currentSite = getCmsSiteService().getCurrentSite(); // Construct page title final String identifier = product.getName(); final String articleNumber = product.getCode(); final String productName = StringUtils.isEmpty(identifier) ? articleNumber : identifier; final StringBuilder builder = new StringBuilder(productName); for (final CategoryModel pathElement : path) { builder.append(TITLE_WORD_SEPARATOR).append(pathElement.getName()); } if (currentSite != null) { builder.append(TITLE_WORD_SEPARATOR).append(currentSite.getName()); } return StringEscapeUtils.escapeHtml(builder.toString()); }
From source file:io.github.tavernaextras.biocatalogue.ui.filtertree.FilterTreePane.java
/** * This method loads filter data from API and populates the view. */// w w w . j a v a 2s . co m private void loadFiltersAndBuildTheTree() { SwingUtilities.invokeLater(new Runnable() { public void run() { resetTreeActionToolbar(); jpFilters.removeAll(); jpFilters.setLayout(new BorderLayout()); jpFilters.add(new JLabel(" Loading filters..."), BorderLayout.NORTH); jpFilters.add(new JLabel(ResourceManager.getImageIcon(ResourceManager.BAR_LOADER_ORANGE)), BorderLayout.CENTER); thisPanel.validate(); thisPanel.repaint(); // validate and repaint this component to make sure that // scroll bar around the filter tree placeholder panel disappears } }); new Thread("Load filters") { public void run() { try { // load filter data filtersRoot = client.getBioCatalogueFilters(filtersURL); // Create root of the filter tree component FilterTreeNode root = new FilterTreeNode("root"); // populate the tree via its root element for (FilterGroup fgroup : filtersRoot.getGroupList()) { // attach filter group directly to the root node FilterTreeNode fgroupNode = new FilterTreeNode( "<html><span style=\"color: black; font-weight: bold;\">" + StringEscapeUtils.escapeHtml(fgroup.getName().toString()) + "</span></html>"); root.add(fgroupNode); // go through all filter types in this group and add them to the tree for (FilterType ftype : fgroup.getTypeList()) { // if there's more than one filter type in the group, add the type node as another level of nesting // (otherwise, attach filters inside the single type directly to the group node) FilterTreeNode filterTypeNode = fgroupNode; if (fgroup.getTypeList().size() > 1) { filterTypeNode = new FilterTreeNode( "<html><span style=\"color: black; font-weight: bold;\">" + StringEscapeUtils.escapeHtml(ftype.getName().toString()) + "</span></html>"); fgroupNode.add(filterTypeNode); } // For some reason sorting the list of filters before inserting into tree // messes up the tree nodes // Collections.sort(ftype.getFilterList(), new Comparator<Filter>(){ // @Override // public int compare(Filter f1, Filter f2) { // return (f1.getName().compareToIgnoreCase(f2.getName())); // } // }); addFilterChildren(filterTypeNode, ftype.getUrlKey().toString(), ftype.getFilterList()); } } // Create the tree view with the populated root filterTree = new JFilterTree(root); filterTree.setRootVisible(false); // don't want the root to be visible; not a standard thing, so not implemented within JTriStateTree filterTree.setLargeModel(true); // potentially can have many filters! filterTree.addCheckingListener(thisPanel); // insert the created tree view into the filters panel jpFilters.removeAll(); jpFilters.setLayout(new GridLayout(0, 1)); jpFilters.add(filterTree); jpFilters.validate(); // add actions from the contextual menu of the filter tree into the toolbar // that replicates those plus adds additional ones in this panel tbFilterTreeToolbar.removeAll(); for (Action a : filterTree.getContextualMenuActions()) { tbFilterTreeToolbar.add(a); } // enable all actions filterTree.enableAllContextualMenuAction(true); } catch (Exception e) { logger.error("Failed to load filter tree from the following URL: " + filtersURL, e); } } /** * Recursive method to populate a node of the filter tree with all * sub-filters. * * Ontological terms will be underlined. * * @param root Tree node to add children to. * @param filterList A list of Filters to add to "root" as children. */ private void addFilterChildren(FilterTreeNode root, String filterCategory, List<Filter> filterList) { for (Filter f : filterList) { // Is this an ontological term? String ontology = null; if (FilterTreeNode.isTagWithNamespaceNode(filterCategory, f.getUrlValue())) { String nameAndNamespace = f.getUrlValue().substring(1, f.getUrlValue().length() - 1); String[] namePlusNamespace = nameAndNamespace.split("#"); ontology = JFilterTree.getOntologyFromNamespace(namePlusNamespace[0]); } FilterTreeNode fNode = new FilterTreeNode("<html><span color=\"black\"" /*(FilterTreeNode.isTagWithNamespaceNode(filterCategory, f.getUrlValue()) ? " style=\"text-decoration: underline;\"" : "") */ + ">" + StringEscapeUtils.escapeHtml(f.getName()) + " (" + f.getCount() + ")" + "</span>" + /*(FilterTreeNode.isTagWithNamespaceNode(filterCategory, f.getUrlValue()) ? "<span color=\"gray\"> ("+f.getCount().intValue()+")</span></html>" : "</html>"),*/ (ontology != null ? "<span color=\"#3090C7\"> <" + ontology + "></span></html>" : "</html>"), filterCategory, f.getUrlValue()); addFilterChildren(fNode, filterCategory, f.getFilterList()); // Insert the node into the (alphabetically) sorted children nodes List<FilterTreeNode> children = Collections.list(root.children()); // Search for the index the new node should be inserted at int index = Collections.binarySearch(children, fNode, new Comparator<FilterTreeNode>() { @Override public int compare(FilterTreeNode o1, FilterTreeNode o2) { String str1 = ((String) o1.getUserObject()).toString(); String str2 = ((String) o2.getUserObject()).toString(); return (str1.compareToIgnoreCase(str2)); } }); if (index < 0) { // not found - index will be equal to -insertion-point -1 index = -index - 1; } // else node with the same name found in the array - insert it at that position root.insert(fNode, index); //root.add(fNode); } } }.start(); }
From source file:gov.medicaid.binders.BaseFormBinder.java
/** * Sets the given indexed value to the model. * * @param mv the model and view to add to * @param key the attribute key (this will prepend the namespace) * @param idx the index//from w w w . j a va 2 s . c om * @param value the value to be set */ protected void attr(Map<String, Object> mv, String key, int idx, String value) { mv.put(name(key, idx), StringEscapeUtils.escapeHtml(value)); }
From source file:com.silverpeas.tags.navigation.FilArianeTag.java
/** * Gnration du lien html./* w w w . j a v a 2 s . c o m*/ * @param node * @param path * @param level * @throws RemoteException */ private void writeLink(NodeDetail node, StringBuffer path, int level) throws RemoteException { path.append("<a href='"); path.append(generateFullSemanticPath(node)); path.append("' title='"); path.append(StringEscapeUtils.escapeHtml(node.getDescription())); path.append("' class='"); path.append(getCssClass(level)); path.append("'>"); path.append(transformLabel(node.getName())); path.append("</a>"); }
From source file:com.jigsforjava.string.StringUtils.java
/** * <p>Utilizes the Jakarta Commons Lang library to escape the characters * in a String using HTML entities.</p> * * <p>/*from w w w .j a v a 2 s. co m*/ * For example: * </p> * <p><code>"bread" & "butter"</code></p> * becomes: * <p> * <code>&quot;bread&quot; &amp; &quot;butter&quot;</code>. * </p> * * @param string is the string to encode. * @see StringEscapeUtils */ public static String htmlEncode(String string) { return StringEscapeUtils.escapeHtml(string); }
From source file:com.fluidops.iwb.util.UIUtil.java
/** * Create the tooltip for a given {@link Value}. Depicts additional * available information (e.g. datatype or language of a literal) * // w ww.ja v a2s . c o m * @param val * @return */ public static String createKeyValueTooltip(Value val) { if (val == null) return ""; StringBuilder tooltipBuilder = new StringBuilder(); if (val instanceof Literal) { Literal lit = (Literal) val; if (lit.getDatatype() == null) { tooltipBuilder.append("Untyped"); } else { tooltipBuilder.append(Datatype.getLabel(lit.getDatatype())); } tooltipBuilder.append(" literal value \n\"").append(lit.stringValue()).append("\""); if (lit.getLanguage() != null) { tooltipBuilder.append("\n(Language: ").append(lit.getLanguage()).append(")"); } } else { String valueType = (val instanceof URI) ? "URI" : "Blank Node"; tooltipBuilder.append(valueType).append(" <").append(StringEscapeUtils.escapeHtml(val.stringValue())) .append(">"); } return tooltipBuilder.toString(); }
From source file:com.igormaznitsa.mindmap.plugins.exporters.MindmupExporter.java
@Nullable private static String makeHtmlFromExtras(@Nonnull final Topic topic) { final ExtraFile file = (ExtraFile) topic.getExtras().get(Extra.ExtraType.FILE); final ExtraNote note = (ExtraNote) topic.getExtras().get(Extra.ExtraType.NOTE); final ExtraLink link = (ExtraLink) topic.getExtras().get(Extra.ExtraType.LINK); if (file == null && link == null && note == null) { return null; }//from w w w . j a va 2s.co m final StringBuilder result = new StringBuilder(); if (file != null) { final String uri = file.getValue().asString(true, false); result.append("FILE: <a href=\"").append(uri).append("\">").append(uri).append("</a><br>"); //NOI18N } if (link != null) { final String uri = link.getValue().asString(true, true); result.append("LINK: <a href=\"").append(uri).append("\">").append(uri).append("</a><br>"); //NOI18N } if (note != null) { if (file != null || link != null) { result.append("<br>"); //NOI18N } result.append("<pre>").append(StringEscapeUtils.escapeHtml(note.getValue())).append("</pre>"); //NOI18N } return result.toString(); }
From source file:com.scaleunlimited.cascading.FlowMonitor.java
@SuppressWarnings("rawtypes") public boolean run(Enum... counters) throws Throwable { if (_htmlDir == null) { _htmlDir = getDefaultLogDir(_flow.getConfig()); }/*from w w w . j a v a 2s .co m*/ _flowException = null; FlowListener catchExceptions = new FlowListener() { @Override public void onCompleted(Flow flow) { } @Override public void onStarting(Flow flow) { } @Override public void onStopping(Flow flow) { } @Override public boolean onThrowable(Flow flow, Throwable t) { _flowException = t; return true; } }; _flow.addListener(catchExceptions); _flow.start(); FlowStats stats; Set<String> loggingStatus = new HashSet<String>(); loggingStatus.add(Status.RUNNING.name()); loggingStatus.add(Status.SUCCESSFUL.name()); loggingStatus.add(Status.STOPPED.name()); loggingStatus.add(Status.FAILED.name()); do { stats = _flow.getFlowStats(); List<FlowStepStats> stepStats = stats.getFlowStepStats(); for (FlowStepStats stepStat : stepStats) { String stepId = stepStat.getID(); StepEntry stepEntry = findStepById(stepId); Status oldStatus = stepEntry.getStatus(); Status newStatus = stepStat.getStatus(); if (oldStatus != newStatus) { stepEntry.setStartTime(stepStat.getStartTime()); stepEntry.setStatus(stepStat.getStatus()); } if (loggingStatus.contains(newStatus.name())) { if (stepStat.isFinished()) { stepEntry.setDuration(stepStat.getDuration()); } else if (stepStat.isRunning()) { stepEntry.setDuration(System.currentTimeMillis() - stepEntry.getStartTime()); } else { // Duration isn't known stepEntry.setDuration(0); } stepEntry.addTimeEntry(makeTimeEntry(stepEntry, stepStat, counters), _timeEntriesPerStep); } } // Now we can build our resulting table StringBuilder topTemplate = new StringBuilder(_htmlTopTemplate); replace(topTemplate, "%flowname%", StringEscapeUtils.escapeHtml(_flow.getName())); for (StepEntry stepEntry : _stepEntries) { StringBuilder stepTemplate = new StringBuilder(_htmlStepTemplate); replaceHtml(stepTemplate, "%stepname%", stepEntry.getName()); replaceHtml(stepTemplate, "%stepstatus%", "" + stepEntry.getStatus()); replaceHtml(stepTemplate, "%stepstart%", new Date(stepEntry.getStartTime()).toString()); replaceHtml(stepTemplate, "%stepduration%", "" + (stepEntry.getDuration() / 1000)); replace(stepTemplate, "%counternames%", getTableHeader(stepEntry.getStep(), counters)); // Now we need to build rows of data, for steps that are running or have finished. if (stepEntry.getStatus() != Status.PENDING) { for (TimeEntry row : stepEntry.getTimerEntries()) { StringBuilder rowTemplate = new StringBuilder(_htmlRowTemplate); replaceHtml(rowTemplate, "%timeoffset%", "" + (row.getTimeDelta() / 1000)); replace(rowTemplate, "%countervalues%", getCounterValues(row.getCounterValues())); insert(stepTemplate, "%steprows%", rowTemplate.toString()); } } // Get rid of position marker we used during inserts. replace(stepTemplate, "%steprows%", ""); insert(topTemplate, "%steps%", stepTemplate.toString()); } // Get rid of position marker we used during inserts. replace(topTemplate, "%steps%", ""); // We've got the template ready to go, create the file. File htmlFile = new File(_htmlDir, FILENAME); FileWriterWithEncoding fw = new FileWriterWithEncoding(htmlFile, "UTF-8"); IOUtils.write(topTemplate.toString(), fw); fw.close(); Thread.sleep(_updateInterval); } while (!stats.isFinished()); // Create a copy of the file as an archive, once we're done. File htmlFile = new File(_htmlDir, FILENAME); File archiveFile = new File(_htmlDir, String.format("%s-%s", _flow.getName(), FILENAME)); archiveFile.delete(); if (!htmlFile.exists() || archiveFile.exists()) { LOGGER.warn("Unable to create archive of file " + htmlFile.getAbsolutePath()); } else { try { String content = IOUtils.toString(new FileReader(htmlFile)); FileWriterWithEncoding fw = new FileWriterWithEncoding(archiveFile, "UTF-8"); IOUtils.write(content, fw); fw.close(); } catch (Exception e) { LOGGER.warn("Unable to create archive of file " + htmlFile.getAbsolutePath(), e); } } if (stats.isFailed() && (_flowException != null)) { throw _flowException; } return stats.isSuccessful(); }