List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml
public static String escapeHtml(String input)
From source file:de.unidue.inf.is.ezdl.gframedl.converter.HTMLConversionStrategy.java
private String escape(String string) { return StringEscapeUtils.escapeHtml(string); }
From source file:com.igormaznitsa.mindmap.exporters.FreeMindExporter.java
private static void writeTopicRecursively(final Topic topic, final MindMapPanelConfig cfg, int shift, final State state) { final String mainShiftStr = generateString(' ', shift); final Color edge = cfg.getConnectorColor(); final Color color; final Color backcolor; 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(Utils.color2html(getTextColor(cfg, topic), false)) //NOI18N .append("\" BACKGROUND_COLOR=\"") //NOI18N .append(Utils.color2html(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(topic.getMap().findTopicForLink(transition));//NOI18N if (file != null) { extrasToSaveInText.add(file); }/* w w w . j a v a 2 s. c o 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(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:com.igormaznitsa.mindmap.exporters.MDExporter.java
private static void writeTopic(final Topic topic, final String listPosition, final State state) throws IOException { final int level = topic.getTopicLevel(); String prefix = "";//NOI18N final String topicUid = getTopicUid(topic); if (topicUid != null) { state.append("<a name=\"").append(topicUid).append("\">").nextLine();//NOI18N }// ww w . j a v a 2s. c om if (level < STARTING_INDEX_FOR_NUMERATION) { final String headerPrefix = generateString('#', topic.getTopicLevel() + 1);//NOI18N state.append(headerPrefix).append(' ').append(ModelUtils.escapeMarkdownStr(topic.getText())).nextLine(); } else { final String headerPrefix = generateString('#', STARTING_INDEX_FOR_NUMERATION + 1);//NOI18N state.append(prefix).append(headerPrefix).append(' ').append(listPosition).append(' ') .append(ModelUtils.escapeMarkdownStr(topic.getText())).nextLine(); } final ExtraFile file = (ExtraFile) topic.getExtras().get(Extra.ExtraType.FILE); final ExtraLink link = (ExtraLink) topic.getExtras().get(Extra.ExtraType.LINK); final ExtraNote note = (ExtraNote) topic.getExtras().get(Extra.ExtraType.NOTE); final ExtraTopic transition = (ExtraTopic) topic.getExtras().get(Extra.ExtraType.TOPIC); boolean extrasPrinted = false; if (transition != null) { final Topic linkedTopic = topic.getMap().findTopicForLink(transition); if (linkedTopic != null) { state.append(prefix).append("*Related to: ")//NOI18N .append('[')//NOI18N .append(ModelUtils.escapeMarkdownStr(makeLineFromString(linkedTopic.getText()))) .append("](")//NOI18N .append("#")//NOI18N .append(getTopicUid(linkedTopic)).append(")*")//NOI18N .nextStringMarker().nextLine(); extrasPrinted = true; if (file != null || link != null || note != null) { state.nextStringMarker().nextLine(); } } } if (file != null) { final MMapURI fileURI = file.getValue(); state.append(prefix).append("> File: ")//NOI18N .append(ModelUtils.escapeMarkdownStr( fileURI.isAbsolute() ? fileURI.asFile(null).getAbsolutePath() : fileURI.toString())) .nextStringMarker().nextLine(); extrasPrinted = true; } if (link != null) { final String url = link.getValue().toString(); final String ascurl = link.getValue().asString(true, true); state.append(prefix).append("> Url: ")//NOI18N .append('[')//NOI18N .append(ModelUtils.escapeMarkdownStr(url)).append("](")//NOI18N .append(ascurl).append(')')//NOI18N .nextStringMarker().nextLine(); extrasPrinted = true; } if (note != null) { if (extrasPrinted) { state.nextLine(); } state.append(prefix).append("<pre>")//NOI18N .append(StringEscapeUtils.escapeHtml(note.getValue())).append("</pre>")//NOI18N .nextLine(); } }
From source file:com.fluidops.iwb.util.UIUtil.java
/** * Returns the HTML link to this value with the help of * {@link RequestMapper#getAHref(Value, String, String)}. * The tooltip is built combining the given comment if available * and the value representation with {@link #createKeyValueTooltip(Value)} * The method escapes HTML in the tooltip. * and the label is retrieved from the datamanager. * //w ww . j av a 2 s . c o m * This method replaces linebreaks in the label with a * HTML br. * * @param value * @param comment * @return */ public static String getAHrefWithTooltip(Value value, String comment) { String tooltip = createKeyValueTooltip(value); if (StringUtil.isNotNullNorEmpty(comment)) tooltip = comment + "\n\n" + tooltip; String label = EndpointImpl.api().getDataManager().getLabelHTMLEncoded(value); label = label.replace("\n", "<br/>"); return EndpointImpl.api().getRequestMapper().getAHrefEncoded(value, label, StringEscapeUtils.escapeHtml(tooltip)); }
From source file:de.fhg.fokus.openride.services.driver.offer.OfferService.java
@GET @Produces("text/json") @Path("inactive") public Response getInactiveOffers(@PathParam("username") String username, @PathParam("rideId") String rideId, @Context ServletContext context) { System.out.println("getOffer start"); List<DriverUndertakesRideEntity> drives = driverUndertakesRideControllerBean.getInactiveDrives(username); ArrayList<Offer> offers = new ArrayList<Offer>(); Offer offer = null;//from w w w . j ava 2 s . c o m for (DriverUndertakesRideEntity drive : drives) { //FIXME: check attributes! System.out.println("OfferService: Drive -> " + drive.toString()); // only get the already inactive drives double startptLat = drive.getRideStartpt() != null ? drive.getRideStartpt().getY() : -1.0; double startptLon = drive.getRideStartpt() != null ? drive.getRideStartpt().getX() : -1.0; double endptLat = drive.getRideEndpt() != null ? drive.getRideEndpt().getY() : -1.0; double endptLon = drive.getRideEndpt() != null ? drive.getRideEndpt().getX() : -1.0; long starttime = drive.getRideStarttime() != null ? drive.getRideStarttime().getTime() : new Long("1").MIN_VALUE; //FIXME: was maxWaitTime, but should be rideprice?? double rideprice = -1.0; String rideComment = drive.getRideComment(); int acceptableDetourInMin = -1;//FIXME: (pab) what is different from the above Calling this: drive.getRideAcceptableDetourInMin(); int acceptableDetourInKm = -1; //drive.getRideAcceptableDetourInKm(); int acceptableDetourInPercent = -1; //drive.getRideAcceptableDetourInPercent();//drive.getRideAcceptableDetourInMin(); int offeredseats = drive.getRideOfferedseatsNo(); String offeredCurrency = drive.getRideOfferedCurrency(); String startptAddress = drive.getStartptAddress(); String endptAddress = drive.getEndptAddress(); offer = new Offer(drive.getRideId(), startptLat, startptLon, endptLat, endptLon, starttime, rideprice, StringEscapeUtils.escapeHtml(rideComment), acceptableDetourInMin, acceptableDetourInKm, acceptableDetourInPercent, offeredseats, StringEscapeUtils.escapeHtml(offeredCurrency), StringEscapeUtils.escapeHtml(startptAddress), StringEscapeUtils.escapeHtml(endptAddress), null); offer.setUpdated(driverUndertakesRideControllerBean.isDriveUpdated(drive.getRideId())); offers.add(offer); } ArrayList list = new ArrayList(); list.add(new Offer()); XStream x = Utils.getJasonXStreamer(list); Response response = Response.ok(x.toXML(offers)).build(); return response; }
From source file:com.silverpeas.tags.navigation.PageListeTag.java
/** * Construction de la liste./*from w w w . j av a 2 s . c om*/ * @param out * @param rootTopic */ private void browse(JspWriter out, NodeDetail rootTopic) { try { Collection pubs = themetracker.getPublicationsByTopic(idTopicRoot + ",order,asc"); Iterator iPubs = pubs.iterator(); print(out, "<ul id='" + id + "'>", true); StringBuffer html = new StringBuffer(); int number = 1; while (iPubs.hasNext()) { PublicationDetail pub = (PublicationDetail) iPubs.next(); html.setLength(0); html.append("<li id='"); html.append(buildId(TOPIC_ID_PREFIX, rootTopic, number)); html.append("' class='"); html.append(getClassNameByPublication(pub, number)); html.append("'"); html.append(">"); html.append("<a href='"); html.append(generateFullSemanticPath(rootTopic, pub, number)); html.append("' title='"); html.append(StringEscapeUtils.escapeHtml(rootTopic.getDescription())); html.append("'><span>"); html.append(pub.getName()); html.append("</span></a>"); print(out, html.toString(), true); number++; } print(out, "</ul>", true); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.activecq.api.helpers.DesignHelper.java
/** * * SRC Method **// w w w .j a v a2s. com */ protected static String designSrc(Page page, String pathPrefix, String path) { if (page == null || StringUtils.isBlank(path)) { return ""; } ResourceResolver resourceResolver = page.adaptTo(Resource.class).getResourceResolver(); Designer designer = resourceResolver.adaptTo(Designer.class); if (designer == null) { return ""; } final Design design = designer.getDesign(page); if (design == null) { return ""; } final Resource designResource = resourceResolver.getResource(design.getPath()); String src = makePath(designResource, pathPrefix, path); if (!exists(resourceResolver, src)) { // Search up the tree src = searchUp(designResource, pathPrefix, path); } return StringUtils.isBlank(src) ? "" : StringEscapeUtils.escapeHtml(src); }
From source file:com.sun.socialsite.util.UtilitiesModel.java
public static String escapeHTML(String str) { return StringEscapeUtils.escapeHtml(str); }
From source file:net.i2cat.csade.life2.backoffice.bl.PlatformUserManager.java
public JSONObject getPlatformUsersJSON(JQueryDataTableParamModel param) throws RemoteException, ServiceException { JSONObject jsonResponse = new JSONObject(); UserProfile[] result = null;//from w ww . ja v a 2s. c o m String filter = ""; if (param == null) throw new ServiceException("Invalid Session!"); if (param.sSearch != null && !"".equals(param.sSearch)) { filter = "Name like '%" + param.sSearch + "%' or Login like '%" + param.sSearch + "%' "; } if (param.iCallerRole != 6) { if (!"".equals(filter)) { filter += " AND "; } filter += "Role<>6 AND Role <" + param.iCallerRole; } if (param.iRole >= 0) { if (!"".equals(filter)) { filter += " AND "; } filter += "Role=" + param.iRole; } if (param.sLng != null && !"".equals(param.sLng)) { if (!"".equals(filter)) { filter += " AND "; } filter += "Language like '" + param.sLng + "'"; } if (param.iCallerRole == 5) { if (!"".equals(filter)) { filter += " AND "; } filter += " isInRegion(region,'&','" + param.sRegion + "')=1 "; } if (param.iCallerRole == 7) { if (!"".equals(filter)) { filter += " AND "; } filter += " cisInSupraRegion(region,'&','" + param.sRegion + "')=1 "; } if (param.iCallerRole == 8) { if (!"".equals(filter)) { filter += " AND "; } filter += " isInCtryCode(region,'&','" + param.sRegion + "')=1 "; } int total = userDAO.countPlatformUsersFiltered(filter); result = userDAO.getPlatformUsersFiltered(filter, param.iDisplayStart, param.iDisplayLength); if (result != null) { try { jsonResponse.put("iTotalRecords", total); //El total despues de filtrar jsonResponse.put("iTotalDisplayRecords", total); JSONArray data = new JSONArray(); for (UserProfile u : result) { JSONArray row = new JSONArray(); row.add("<a href=\"#\" onclick=\"showFormPlatform('" + u.getLogin() + "'," + u.getUser_id() + ");\">" + u.getUser_id() + "</a>"); row.add(StringEscapeUtils.escapeHtml(u.getLogin())); row.add(StringEscapeUtils.escapeHtml(u.getName())); row.add(PlatformUser.roleNames[u.getRole()]); //row.add(u.getName().replaceAll("", "á").replaceAll("", "é").replaceAll("", "í").replaceAll("", "ó").replaceAll("", "ú").replaceAll("", "ñ")); row.add(u.getLast_location_timestamp()); row.add(u.getEmail()); data.add(row); } jsonResponse.put("sEcho", param.sEcho); jsonResponse.put("aaData", data); } catch (JSONException e) { } } else { jsonResponse.put("aaData", "[]"); } return jsonResponse; }
From source file:net.intelliant.util.UtilCommon.java
/** * 1. Compressed JPEG images./*from ww w . j a v a2 s . c o m*/ * 2. Prefixes (if required) image server URL to image src locations. * * @return a <code>String</code> value */ public static String parseHtmlAndGenerateCompressedImages(String html) throws IOException { if (UtilValidate.isEmpty(html)) { return html; } org.jsoup.nodes.Document doc = Jsoup.parse(html); Elements images = doc.select("img[src~=(?i)\\.(jpg|jpeg|png|gif)]"); if (images != null && images.size() > 0) { Set<String> imageLocations = new HashSet<String>(); for (Element image : images) { String srcAttributeValue = image.attr("src"); if (!(imageLocations.contains(srcAttributeValue))) { if (Debug.infoOn()) { Debug.logInfo( "[parseHtmlAndGenerateCompressedImages] originalSource >> " + srcAttributeValue, module); } if (!UtilValidate.isUrl(srcAttributeValue)) { int separatorIndex = srcAttributeValue.lastIndexOf("/"); if (separatorIndex == -1) { separatorIndex = srcAttributeValue .lastIndexOf("\\"); /** just in case some one plays with html source. */ } if (separatorIndex != -1) { String originalFileName = srcAttributeValue.substring(separatorIndex + 1); /* Handling spaces in file-name to make url friendly. */ String outputFileName = StringEscapeUtils.escapeHtml(originalFileName); /** Compression works for jpeg's only. if (originalFileName.endsWith("jpg") || originalFileName.endsWith("jpeg")) { try { outputFileName = generateCompressedImageForInputFile(imageUploadLocation, originalFileName); } catch (NoSuchAlgorithmException e) { Debug.logError(e, module); return html; } } */ StringBuilder finalLocation = new StringBuilder(campaignBaseURL); finalLocation.append(imageUploadWebApp).append(outputFileName); html = StringUtil.replaceString(html, srcAttributeValue, finalLocation.toString()); imageLocations.add(srcAttributeValue); } } else { Debug.logWarning("[parseHtmlAndGenerateCompressedImages] ignoring encountered HTML URL..", module); } } } } else { if (Debug.infoOn()) { Debug.logInfo("[parseHtmlAndGenerateCompressedImages] No jpeg images, doing nothing..", module); } } if (Debug.infoOn()) { Debug.logInfo("[parseHtmlAndGenerateCompressedImages] returning html >> " + html, module); } return html; }