List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml
public static String escapeHtml(String input)
From source file:de.knowwe.visualization.util.Utils.java
public static String clean(String text, String lineBreak) { String cleanText = StringEscapeUtils.escapeHtml(text); cleanText = cleanText.replaceAll("\\r\\n|\\n", lineBreak); return cleanText.replaceAll("\"", "'"); }
From source file:com.reizes.shiva.utils.CommonUtil.java
/** * StringEscapeUtils.escapeHtml wrapping * @param str -/* w w w . j a v a 2s .c o m*/ * @return - */ public static String escapeHtml(String str) { if (str == null) { return null; } return StringUtils.replace(StringEscapeUtils.escapeHtml(str), "\n", "<br/>"); }
From source file:de.fhg.fokus.openride.services.rider.search.SearchService.java
@GET @Produces("text/json") @Path("{riderrouteid}/matches") public Response getMatches(@PathParam("riderrouteid") Integer riderrouteid) { List<MatchEntity> matches = (List<MatchEntity>) riderUndertakesRideControllerBean.getMatches(riderrouteid, true);/* www . j ava 2 s . com*/ MatchResponse m; List<MatchResponse> matchlist = new ArrayList<MatchResponse>(); CustomerEntity driver; RiderUndertakesRideEntity rideEntity = riderUndertakesRideControllerBean .getRideByRiderRouteId(riderrouteid); for (MatchEntity match : matches) { int rideid = match.getMatchEntityPK().getRideId(); DriverUndertakesRideEntity driveEntity = driverUndertakesRideControllerBean.getDriveByDriveId(rideid); driver = driveEntity.getCustId(); m = new MatchResponse(match.getDriverState(), match.getRiderState(), match.getMatchExpectedStartTime().getTime(), driveEntity.getRideId(), rideEntity.getRiderrouteId(), driver.getCustId(), driver.getCustNickname(), Math.round(riderUndertakesRideControllerBean.getRatingsRatioByCustomer(driver) * 100), match.getMatchPriceCents(), StringEscapeUtils.escapeHtml(rideEntity.getStartptAddress()), StringEscapeUtils.escapeHtml(rideEntity.getEndptAddress())); if (match.getDriverState() != null && match.getDriverState().equals(MatchEntity.ACCEPTED) && match.getRiderState() != null && match.getRiderState().equals(MatchEntity.ACCEPTED)) { m.setDriverMobilePhoneNo(StringEscapeUtils.escapeHtml(driver.getCustMobilephoneno())); CarDetailsEntity cd = carDetailsControllerBean.getCarDetails(driver); m.setDriverCarColour(cd.getCardetColour()); m.setDriverCarBrand(cd.getCardetBrand()); m.setDriverCarBuildYear(cd.getCardetBuildyear()); m.setDriverCarPlateNo(cd.getCardetPlateno()); } matchlist.add(m); } XStream x = Utils.getJasonXStreamer(matchlist); Response response = Response.ok(x.toXML(matchlist)).build(); return response; }
From source file:com.junichi11.netbeans.php.enhancements.ui.actions.ConvertToAction.java
private String convert(String selectedText) throws AssertionError { String convertedString;// www .ja va 2 s .c o m switch (getType()) { case STRING_2_NAME_ENTITIES: // escape (name entities) convertedString = StringEscapeUtils.escapeHtml(selectedText); break; case NAME_ENTITIES_2_STRING: convertedString = StringEscapeUtils.unescapeHtml(selectedText); break; default: throw new AssertionError(); } return convertedString; }
From source file:com.haulmont.cuba.web.log.LogWindow.java
private String writeLog() { StringBuilder sb = new StringBuilder(); List<LogItem> items = App.getInstance().getAppLog().getItems(); for (LogItem item : items) { sb.append("<b>"); sb.append(DateFormatUtils.format(item.getTimestamp(), DATE_FORMAT)); sb.append(" "); sb.append(item.getLevel().name()); sb.append("</b> "); sb.append(StringEscapeUtils.escapeHtml(item.getMessage())); if (item.getStacktrace() != null) { sb.append(" "); String htmlMessage = StringEscapeUtils.escapeHtml(item.getStacktrace()); htmlMessage = StringUtils.replace(htmlMessage, "\n", "<br/>"); htmlMessage = StringUtils.replace(htmlMessage, " ", " "); htmlMessage = StringUtils.replace(htmlMessage, "\t", " "); sb.append(htmlMessage);//w ww . j a v a 2 s . c om } sb.append("<br/>"); } return sb.toString(); }
From source file:com.hp.autonomy.searchcomponents.hod.view.HodViewServerService.java
private String escapeAndAddLineBreaks(final String input) { return input == null ? "" : StringEscapeUtils.escapeHtml(input).replace("\n", "<br>"); }
From source file:com.bstek.dorado.view.resolver.PageHeaderOutputter.java
public void output(Object object, OutputContext context) throws Exception { DoradoContext doradoContext = DoradoContext.getCurrent(); View view = (View) object; String skin = skinResolver.determineSkin(doradoContext, view); doradoContext.setAttribute("view.skin", skin); int currentClientType = VariantUtils.toInt(doradoContext.getAttribute(ClientType.CURRENT_CLIENT_TYPE_KEY)); if (currentClientType == 0) { currentClientType = ClientType.DESKTOP; }//from ww w. j av a 2s .c o m Writer writer = context.getWriter(); writer.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=") .append(Constants.DEFAULT_CHARSET).append("\" />\n"); if (StringUtils.isNotEmpty(view.getTitle())) { writer.append("<title>").append(StringEscapeUtils.escapeHtml(view.getTitle())).append("</title>\n"); } Locale locale = localeResolver.resolveLocale(); String contextPath = Configure.getString("web.contextPath"); if (StringUtils.isEmpty(contextPath)) { contextPath = DoradoContext.getAttachedRequest().getContextPath(); } writer.append("<script language=\"javascript\" type=\"text/javascript\" charset=\"UTF-8\" src=\"") .append(contextPath).append("/dorado/client/boot.dpkg?clientType=") .append(ClientType.toString(currentClientType)).append("&skin=").append(skin) .append("&cacheBuster=") .append(CacheBusterUtils.getCacheBuster((locale != null) ? locale.toString() : null)) .append("\"></script>\n").append("<script language=\"javascript\" type=\"text/javascript\">\n"); writer.append("window.$setting={\n"); for (ClientSettingsOutputter clientSettingsOutputter : clientSettingsOutputters) { clientSettingsOutputter.output(writer); } writer.append("\n};\n"); writer.append("$import(\"").append(getBasePackageNames(doradoContext, currentClientType, skin)) .append("\");\n</script>\n").append("<script language=\"javascript\" type=\"text/javascript\">\n"); topViewOutputter.output(view, context); writer.append("</script>\n"); Set<Object> javaScriptContents = context.getJavaScriptContents(); if (javaScriptContents != null && !javaScriptContents.isEmpty()) { writer.append("<script language=\"javascript\" type=\"text/javascript\">\n"); for (Object content : javaScriptContents) { if (content instanceof JavaScriptContent && !((JavaScriptContent) content).getIsController()) { javaScriptResourceManager.outputContent(context, content); } writer.append('\n'); } writer.append("</script>\n"); } Set<Object> styleSheetContents = context.getStyleSheetContents(); if (styleSheetContents != null && !styleSheetContents.isEmpty()) { writer.append("<style type=\"text/css\">\n"); for (Object content : styleSheetContents) { styleSheetResourceManager.outputContent(context, content); writer.append('\n'); } writer.append("</style>\n"); } }
From source file:com.sonymobile.backlogtool.Story.java
/** * @return the description */ public String getDescription() { return StringEscapeUtils.escapeHtml(description); }
From source file:at.gv.egovernment.moa.id.protocols.saml1.SAML1Protocol.java
public IRequest preProcess(HttpServletRequest request, HttpServletResponse response, String action) throws MOAIDException { SAML1RequestImpl config = new SAML1RequestImpl(); if (!AuthConfigurationProvider.getInstance().getAllowedProtocols().isSAML1Active()) { Logger.info("SAML1 is deaktivated!"); throw new ProtocolNotActiveException("auth.22", new Object[] { "SAML 1" }); }/*from w w w . j a v a 2 s . c o m*/ String oaURL = (String) request.getParameter(PARAM_OA); //oaURL = StringEscapeUtils.escapeHtml(oaURL); String target = (String) request.getParameter(PARAM_TARGET); target = StringEscapeUtils.escapeHtml(target); String sourceID = request.getParameter(PARAM_SOURCEID); sourceID = StringEscapeUtils.escapeHtml(sourceID); //the target parameter is used to define the OA in SAML1 standard if (target != null && target.startsWith("http")) { oaURL = target; target = null; } if (MiscUtil.isEmpty(oaURL)) { Logger.info("Receive SAML1 request with no OA parameter. Authentication STOPPED!"); throw new WrongParametersException("StartAuthentication", PARAM_OA, "auth.12"); } if (!ParamValidatorUtils.isValidOA(oaURL)) throw new WrongParametersException("StartAuthentication", PARAM_OA, "auth.12"); config.setOAURL(oaURL); Logger.info("Dispatch SAML1 Request: OAURL=" + oaURL); if (!ParamValidatorUtils.isValidSourceID(sourceID)) throw new WrongParametersException("StartAuthentication", PARAM_SOURCEID, "auth.12"); //load Target only from OA config OAAuthParameter oaParam = AuthConfigurationProvider.getInstance().getOnlineApplicationParameter(oaURL); if (oaParam == null) throw new InvalidProtocolRequestException("auth.00", new Object[] { null }); OASAML1 saml1 = oaParam.getSAML1Parameter(); if (saml1 == null || !(saml1.isIsActive() != null && saml1.isIsActive())) { Logger.info("Online-Application " + oaURL + " can not use SAML1 for authentication."); throw new InvalidProtocolRequestException("auth.00", new Object[] { null }); } config.setSourceID(sourceID); if (MiscUtil.isNotEmpty(target)) config.setTarget(target); else config.setTarget(oaParam.getTarget()); return config; }
From source file:com.edgenius.wiki.render.handler.AttachmentHandler.java
public List<RenderPiece> handle(RenderContext renderContext, Map<String, String> values) { List<RenderPiece> pieces = new ArrayList<RenderPiece>(); List<FileNode> files = new ArrayList<FileNode>(); if (atts != null) { files = getFileList(values != null ? values.get("filter") : null, renderContext.getPageVisibleAttachments()); }//from ww w .jav a2 s . co m List<String> urls = new ArrayList<String>(); //try to find the image from repository for (FileNode node : files) { //found attachment urls.add(renderContext.buildDownloadURL(node.getFilename(), node.getNodeUuid(), true)); } int id = renderContext.createIncremetalKey(); StringBuffer attachBuf = new StringBuffer("<div aid=\"attachments\" id=\"attachment-").append(id) .append("\" class=\"").append(WikiConstants.mceNonEditable).append("\" "); if (values != null && values.size() > 0) { attachBuf.append("wajax=\"") .append(RichTagUtil.buildWajaxAttributeString(this.getClass().getName(), values)).append("\" "); } attachBuf.append(">"); attachBuf.append("<table name=\"attachments\" class=\"macroAttachment\">"); //TODO: i18n, header attachBuf.append("<tr><th>File</th><th>Author</th><th>Size</th><th>Date</th><th>Comment</th></tr>"); int sum = urls.size(); if (sum > 0) { for (int idx = 0; idx < sum; idx++) { FileNode node = files.get(idx); attachBuf.append("<tr>"); //filename attachBuf.append("<td class='column2'><a href=\""); attachBuf.append(urls.get(idx)); attachBuf.append("\" title=\"Download file\">"); attachBuf.append(node.getFilename()); attachBuf.append("</a></td>"); //author attachBuf.append("<td class='column2'>").append(StringEscapeUtils.escapeHtml(node.getCreateor())) .append("</td>"); //size attachBuf.append("<td class='column3'>").append(GwtUtils.convertHumanSize(node.getSize())) .append("</td>"); //date attachBuf.append("<td class='column4'>").append( DateUtil.toDisplayDate(WikiUtil.getUser(), new Date(node.getDate()), messageService)) .append("</td>"); //comment attachBuf.append("<td>").append(StringEscapeUtils.escapeHtml(node.getComment())).append("</td>"); attachBuf.append("</tr>"); } } else { //TODO: i18n attachBuf.append("<tr><td colspan='5'>").append("No matched files").append("</td></tr>"); } attachBuf.append("</table></div>"); pieces.add(new TextModel(attachBuf.toString())); return pieces; }