List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml
public static String escapeHtml(String input)
From source file:com.crawljax.plugins.adi.Report.java
/** * Taken from ErrorReport./*w ww.j ava2 s . c o m*/ */ private String replaceMarkers(String dom) { for (int i = 0; i < failures.size(); i++) { String[] failure = failures.get(i); String regexSearch = "\\s*" + "###BEGINMARKER" + i + "###"; String replace = "<div class=\"difference\" title=\"" + StringEscapeUtils.escapeHtml(failure[2]) + "\" style=\"background: " + COLORS[i % COLORS.length] + ";\">"; dom = dom.replaceAll(regexSearch, replace); } dom = dom.replaceAll("(\\s)*###ENDMARKER###", "</div>"); return dom; }
From source file:com.redhat.rhn.domain.action.ActionFormatter.java
/** * @param server on which action has been executed * @return returns localized formatted string to be used on system event details page *//*from w ww. j ava 2s .co m*/ public String getDetails(Server server) { LocalizationService ls = LocalizationService.getInstance(); StringBuilder retval = new StringBuilder(); retval.append(ls.getMessage("system.event.details.execute", getEarliestDate())); retval.append("</br>"); ServerAction sa = ActionFactory.getServerActionForServerAndAction(server, action); retval.append(ls.getMessage("system.event.details.status", ls.getMessage("system.event.details.status" + sa.getStatus().getName()))); retval.append("</br>"); if (sa.getPickupTime() != null) { retval.append(ls.getMessage("system.event.details.pickup", sa.getPickupTime())); } else { retval.append(ls.getMessage("system.event.details.notPickedUp")); retval.append(action.getHistoryDetails(server)); return retval.toString(); } retval.append("</br>"); if (sa.getCompletionTime() != null) { retval.append(ls.getMessage("system.event.details.completed", sa.getCompletionTime())); } else { retval.append(ls.getMessage("system.event.details.notCompleted")); retval.append(action.getHistoryDetails(server)); return retval.toString(); } retval.append("</br>"); retval.append(ls.getMessage("system.event.details.returned", StringEscapeUtils.escapeHtml(sa.getResultMsg()), sa.getResultCode())); retval.append(action.getHistoryDetails(server)); return retval.toString(); }
From source file:de.unisb.cs.st.javalanche.mutation.analyze.html.HtmlReport.java
public void addSummary(String heading, String content) { StringBuilder sb = new StringBuilder(); sb.append("<h3>"); sb.append(StringEscapeUtils.escapeHtml(heading)); sb.append("</h3>"); sb.append("<p>"); content = StringEscapeUtils.escapeHtml(content); content = content.replace("\n", "<br /> \n"); sb.append(content);/*from ww w . ja v a2s . c o m*/ sb.append("</p>"); summary.add(sb.toString()); }
From source file:com.igormaznitsa.mindmap.plugins.exporters.FreeMindExporter.java
private static void writeTopicRecursively(@Nonnull final Topic topic, @Nonnull final MindMapPanelConfig cfg, int shift, @Nonnull final State state) { final String mainShiftStr = generateString(' ', shift); final Color edge = cfg.getConnectorColor(); String position = topic.getTopicLevel() == 1 ? (AbstractCollapsableElement.isLeftSidedTopic(topic) ? "left" : "right") : ""; //NOI18N state.append(mainShiftStr).append("<node CREATED=\"") //NOI18N .append(System.currentTimeMillis()) //NOI18N .append("\" MODIFIED=\"") //NOI18N .append(System.currentTimeMillis()) //NOI18N .append("\" COLOR=\"") //NOI18N .append(assertNotNull(Utils.color2html(MindMapUtils.getTextColor(cfg, topic), false))) //NOI18N .append("\" BACKGROUND_COLOR=\"") //NOI18N .append(assertNotNull(Utils.color2html(MindMapUtils.getBackgroundColor(cfg, topic), false))) //NOI18N .append("\" ") //NOI18N .append(position.isEmpty() ? " " : String.format("POSITION=\"%s\"", position)) //NOI18N .append(" ID=\"") //NOI18N .append(makeUID(topic)) //NOI18N .append("\" ") //NOI18N .append("TEXT=\"") //NOI18N .append(escapeXML(topic.getText())).append("\" "); //NOI18N final ExtraFile file = (ExtraFile) topic.getExtras().get(Extra.ExtraType.FILE); final ExtraLink link = (ExtraLink) topic.getExtras().get(Extra.ExtraType.LINK); final ExtraTopic transition = (ExtraTopic) topic.getExtras().get(Extra.ExtraType.TOPIC); final String thelink; final List<Extra<?>> extrasToSaveInText = new ArrayList<Extra<?>>(); // make some prioritization for only attribute if (transition != null) { thelink = '#' + makeUID(assertNotNull(topic.getMap().findTopicForLink(transition)));//NOI18N if (file != null) { extrasToSaveInText.add(file); }// w ww .j a v a 2 s .co m if (link != null) { extrasToSaveInText.add(link); } } else if (file != null) { thelink = file.getValue().toString(); if (link != null) { extrasToSaveInText.add(link); } } else if (link != null) { thelink = link.getValue().toString(); } else { thelink = "";//NOI18N } if (!thelink.isEmpty()) { state.append(" LINK=\"").append(escapeXML(thelink)).append("\"");//NOI18N } state.append(">").nextLine();//NOI18N shift++; final String childShift = generateString(' ', shift);//NOI18N state.append(childShift).append("<edge COLOR=\"").append(assertNotNull(Utils.color2html(edge, false))) .append("\"/>").nextLine();//NOI18N final ExtraNote note = (ExtraNote) topic.getExtras().get(Extra.ExtraType.NOTE); final StringBuilder htmlTextForNode = new StringBuilder(); if (!extrasToSaveInText.isEmpty()) { htmlTextForNode.append("<ul>"); //NOI18N for (final Extra<?> e : extrasToSaveInText) { htmlTextForNode.append("<li>"); //NOI18N if (e instanceof ExtraLinkable) { final String linkAsText = ((ExtraLinkable) e).getAsURI().asString(true, e.getType() != Extra.ExtraType.FILE); htmlTextForNode.append("<b>").append(StringEscapeUtils.escapeHtml(e.getType().name())) .append(": </b>").append("<a href=\"").append(linkAsText).append("\">") .append(linkAsText).append("</a>"); //NOI18N } else { htmlTextForNode.append("<b>").append(StringEscapeUtils.escapeHtml(e.getType().name())) .append(": </b>").append(StringEscapeUtils.escapeHtml(e.getAsString())); //NOI18N } htmlTextForNode.append("</li>"); //NOI18N } htmlTextForNode.append("</ul>"); //NOI18N } if (note != null) { htmlTextForNode.append("<p><pre>").append(StringEscapeUtils.escapeHtml(note.getValue())) .append("</pre></p>"); //NOI18N } if (htmlTextForNode.length() > 0) { state.append(childShift).append("<richcontent TYPE=\"NOTE\">") .append("<html><head></head><body>" + htmlTextForNode.toString() + "</body></html>") .append("</richcontent>").nextLine();//NOI18N //NOI18N } for (final Topic ch : topic.getChildren()) { writeTopicRecursively(ch, cfg, shift, state); } state.append(mainShiftStr).append("</node>").nextLine();//NOI18N }
From source file:ch.systemsx.cisd.openbis.generic.shared.translator.ExternalDataTranslator.java
private static Sample fillSample(Sample sample, SamplePE samplePE, boolean loadSampleProperties) { sample.setId(HibernateUtils.getId(samplePE)); SampleTranslator.setCodes(sample, samplePE); sample.setInvalidation(translateInvalidation(samplePE.getInvalidation())); sample.setSampleType(TypeTranslator.translate(samplePE.getSampleType())); sample.setIdentifier(StringEscapeUtils.escapeHtml(samplePE.getSampleIdentifier().toString())); if (loadSampleProperties) { sample.setProperties(EntityPropertyTranslator.translate(samplePE.getProperties(), new HashMap<PropertyTypePE, PropertyType>())); }// www . j av a 2 s. c o m return sample; }
From source file:com.epam.cme.storefront.util.PageTitleResolver.java
/** * creates page title for given code/*from w ww .j a v a 2 s. com*/ */ 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(SEPARATOR).append(pathElement.getName()); } if (currentSite != null) { builder.append(SEPARATOR).append(currentSite.getName()); } return StringEscapeUtils.escapeHtml(builder.toString()); }
From source file:au.org.ala.delta.model.format.Formatter.java
public String defaultFormat(String text, CommentStrippingMode commentStrippingMode, AngleBracketHandlingMode angleBracketHandlingMode, boolean stripFormatting, boolean capitaliseFirstWord, boolean newLinesToSpace, boolean rtfToHtml) { if (StringUtils.isEmpty(text)) { return ""; }//from w w w.java 2 s .co m if (_despaceRtf) { text = Utils.despaceRtf(text, false); } if (stripFormatting) { text = RTFUtils.stripFormatting(text, newLinesToSpace); } text = stripComments(text, commentStrippingMode); if (commentStrippingMode != CommentStrippingMode.STRIP_ALL) { text = handleAngleBrackets(text, angleBracketHandlingMode); } // Stripping formatting can leave extra whitespace lying around // sometimes. text = text.replaceAll(" +", " "); if (capitaliseFirstWord) { text = Utils.capitaliseFirstWord(text); } if (rtfToHtml) { text = StringEscapeUtils.escapeHtml(text); text = replaceDash(text); text = RTFUtils.rtfToHtml(text); } else { text = replaceDash(text); } return text.trim(); }
From source file:edu.harvard.iq.dataverse.DataCitation.java
private String formatString(String value, boolean escapeHtml, String wrapper) { if (!StringUtils.isEmpty(value)) { return new StringBuilder(wrapper).append(escapeHtml ? StringEscapeUtils.escapeHtml(value) : value) .append(wrapper).toString(); }// w w w. j a v a2s . c o m return null; }
From source file:at.gv.egovernment.moa.id.auth.servlet.VerifyCertificateServlet.java
/** * Gets the signer certificate from the InfoboxReadRequest and * responds with a new //w w w .j av a 2 s. c o m * <code>CreateXMLSignatureRequest</code>. * <br> * Request parameters: * <ul> * <li>MOASessionID: ID of associated authentication session</li> * <li>XMLResponse: <code><InfoboxReadResponse></code></li> * </ul> * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest, HttpServletResponse) */ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Logger.debug("POST VerifyCertificateServlet"); Logger.warn(getClass().getName() + " is deprecated and should not be used any more."); 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); String pendingRequestID = null; Map<String, String> parameters; try { parameters = getParameters(req); } catch (FileUploadException 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); AuthenticationSession session = null; try { // check parameter if (!ParamValidatorUtils.isValidSessionID(sessionID)) throw new WrongParametersException("VerifyCertificate", PARAM_SESSIONID, "auth.12"); session = AuthenticationServer.getSession(sessionID); //change MOASessionID sessionID = AuthenticationSessionStoreage.changeSessionID(session); X509Certificate cert = AuthenticationServer.getInstance().getCertificate(sessionID, parameters); if (cert == null) { Logger.error("Certificate could not be read."); throw new AuthenticationException("auth.14", null); } boolean useMandate = session.getUseMandate(); if (useMandate) { // verify certificate for OrganWalter String createXMLSignatureRequestOrRedirect = AuthenticationServer.getInstance() .verifyCertificate(session, cert); try { AuthenticationSessionStoreage.storeSession(session); } catch (MOADatabaseException e) { throw new MOAIDException("session store error", null); } ServletUtils.writeCreateXMLSignatureRequestOrRedirect(resp, session, createXMLSignatureRequestOrRedirect, AuthenticationServer.REQ_PROCESS_VALIDATOR_INPUT, "VerifyCertificate"); } else { String countrycode = CertificateUtils.getIssuerCountry(cert); if (countrycode != null) { if (countrycode.compareToIgnoreCase("AT") == 0) { Logger.error( "Certificate issuer country code is \"AT\". Login not support in foreign identities mode."); throw new AuthenticationException("auth.22", null); } } // Foreign Identities Modus String createXMLSignatureRequest = AuthenticationServer.getInstance() .createXMLSignatureRequestForeignID(session, cert); // build dataurl (to the GetForeignIDSerlvet) String dataurl = new DataURLBuilder().buildDataURL(session.getAuthURL(), REQ_GET_FOREIGN_ID, session.getSessionID()); try { AuthenticationSessionStoreage.storeSession(session); } catch (MOADatabaseException e) { throw new MOAIDException("session store error", null); } ServletUtils.writeCreateXMLSignatureRequest(resp, createXMLSignatureRequest, AuthenticationServer.REQ_PROCESS_VALIDATOR_INPUT, "GetForeignID", dataurl); Logger.debug("Send CreateXMLSignatureRequest to BKU"); } } catch (MOAIDException ex) { handleError(null, ex, req, resp, pendingRequestID); } catch (Exception e) { Logger.error("CertificateValidation has an interal Error.", e); } finally { ConfigurationDBUtils.closeSession(); } }
From source file:com.redhat.rhn.frontend.struts.RhnAction.java
/** * Add a success message to the request with any parameters. * * @param req to add the message to//from w w w . j a va 2 s. com * @param msgKey resource key to lookup * @param params String values to fill in */ protected void createMessage(HttpServletRequest req, String msgKey, String[] params) { ActionMessages msg = new ActionMessages(); for (int i = 0; i < params.length; i++) { params[i] = StringEscapeUtils.escapeHtml(params[i]); } msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(msgKey, params)); saveMessages(req, msg); }