List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml
public static String escapeHtml(String input)
From source file:com.igormaznitsa.sciareto.ui.tabs.TabTitle.java
private void updateView() { Utils.safeSwingCall(new Runnable() { @Override// ww w.jav a 2s.c o m public void run() { titleLabel.setText("<html>" + (changed ? "<b>*<u>" : "") + StringEscapeUtils.escapeHtml(makeName()) + (changed ? "</u></b>" : "") + "</html>"); revalidate(); } }); }
From source file:com.thalesgroup.hudson.plugins.cppcheck.CppcheckSource.java
/** * Writes the message to the output stream (with escaped HTML). * * @param output the output to write to * @param message the message to write//from w w w . j a v a2 s . c o m */ private void outputEscaped(final StringBuilder output, final String message) { output.append(StringEscapeUtils.escapeHtml(message)); }
From source file:com.manydesigns.elements.fields.TextField.java
public String getDisplayValue() { String escapedText;//w w w . j a va 2s . c om if (richText) { escapedText = stringValue; } else { escapedText = StringEscapeUtils.escapeHtml(stringValue); if (href == null && highlightLinks) { escapedText = highlightLinks(escapedText); } escapedText = adjustText(escapedText); } return escapedText; }
From source file:com.fluidops.iwb.util.UIUtil.java
/** * Returns the <img> HTML element with the given source relative * to the webapplication and the current context path. * //w w w .jav a2 s . c om * Example: * * <img src="%CP%/images/image.png"></img> * * @param relativeImgSrc * @param the optional title * @return */ public static String getImageHTMLRelative(String relativeImgSrc, String title) { StringBuilder sb = new StringBuilder(); sb.append("<img src=\""); sb.append(EndpointImpl.api().getRequestMapper().getContextPath()); sb.append(StringEscapeUtils.escapeHtml(relativeImgSrc)).append("\" "); if (!StringUtil.isNullOrEmpty(title)) sb.append("title=\"").append(title).append("\" "); sb.append("/>"); return sb.toString(); }
From source file:au.edu.anu.portal.portlets.sakaiconnector.PortletDispatcher.java
/** * Helper to process EDIT mode actions/*w w w .j a va 2s . co m*/ * @param request * @param response */ private void processEditAction(ActionRequest request, ActionResponse response) { log.debug("processEditAction()"); replayForm = false; isValid = false; //get prefs and submitted values PortletPreferences prefs = request.getPreferences(); String portletHeight = request.getParameter("portletHeight"); String portletTitle = StringEscapeUtils.escapeHtml(StringUtils.trim(request.getParameter("portletTitle"))); String remoteSiteId = request.getParameter("remoteSiteId"); String remoteToolId = request.getParameter("remoteToolId"); //catch a blank remoteSiteId and replay form if (StringUtils.isBlank(remoteSiteId)) { replayForm = true; response.setRenderParameter("portletTitle", portletTitle); response.setRenderParameter("portletHeight", portletHeight); return; } //catch a blank remoteToolId and replay form if (StringUtils.isBlank(remoteToolId)) { replayForm = true; response.setRenderParameter("portletTitle", portletTitle); response.setRenderParameter("portletHeight", portletHeight); response.setRenderParameter("remoteSiteId", remoteSiteId); return; } //portlet title could be blank, set to default //if(StringUtils.isBlank(portletTitle)){ // portletTitle=Constants.PORTLET_TITLE_DEFAULT; //} //form ok so validate try { prefs.setValue("portletHeight", portletHeight); //only set title if it is not blank if (StringUtils.isNotBlank(portletTitle)) { prefs.setValue("portletTitle", portletTitle); } prefs.setValue("remoteSiteId", remoteSiteId); prefs.setValue("remoteToolId", remoteToolId); } catch (ReadOnlyException e) { replayForm = true; response.setRenderParameter("errorMessage", Messages.getString("error.form.readonly.error")); log.error(e); return; } //save them try { prefs.store(); isValid = true; } catch (ValidatorException e) { replayForm = true; response.setRenderParameter("errorMessage", e.getMessage()); log.error(e); return; } catch (IOException e) { replayForm = true; response.setRenderParameter("errorMessage", Messages.getString("error.form.save.error")); log.error(e); return; } //if ok, invalidate cache and return to view if (isValid) { try { response.setPortletMode(PortletMode.VIEW); } catch (PortletModeException e) { e.printStackTrace(); } } }
From source file:ch.systemsx.cisd.openbis.generic.shared.translator.ExternalDataTranslator.java
/** * Fills <var>externalData</var> from <var>data</vra> with all data needed by * {@link IEntityInformationHolder}./*from ww w . j a va 2s. c o m*/ */ private static ExternalData fillExternalData(ExternalData externalData, DataPE dataPE) { externalData.setId(HibernateUtils.getId(dataPE)); externalData.setCode(StringEscapeUtils.escapeHtml(dataPE.getCode())); externalData.setDataSetType(DataSetTypeTranslator.translate(dataPE.getDataSetType(), new HashMap<PropertyTypePE, PropertyType>())); return externalData; }
From source file:com.ucap.uccc.cmis.impl.webservices.CmisWebServicesServlet.java
private void printPage(HttpServletRequest request, HttpServletResponse response, UrlBuilder baseUrl) throws ServletException, IOException { response.setStatus(HttpServletResponse.SC_OK); response.setContentType("text/html"); response.setCharacterEncoding(IOUtils.UTF8); String urlEscaped = StringEscapeUtils .escapeHtml((new UrlBuilder(baseUrl)).addPath("cmis").addParameter("wsdl").toString()); PrintWriter pw = response.getWriter(); pw.print("<html><head><title>Apache Chemistry OpenCMIS - CMIS " + cmisVersion.value() + " Web Services</title>" + "<style><!--H1 {font-size:24px;line-height:normal;font-weight:bold;background-color:#f0f0f0;color:#003366;border-bottom:1px solid #3c78b5;padding:2px;} " + "BODY {font-family:Verdana,arial,sans-serif;color:black;font-size:14px;} " + "HR {color:#3c78b5;height:1px;}--></style></head><body>"); pw.print("<h1>CMIS " + cmisVersion.value() + " Web Services</h1>"); pw.print("<p>CMIS WSDL for all services: <a href=\"" + urlEscaped + "\">" + urlEscaped + "</a></p>"); pw.print("</html></body>"); pw.flush();//from w ww . j a v a 2s.co m }
From source file:it.eng.spagobi.commons.presentation.tags.QueryWizardTag.java
public int doStartTag() throws JspException { logger.debug("QueryWizardTag::doStartTag:: invoked"); httpRequest = (HttpServletRequest) pageContext.getRequest(); requestContainer = ChannelUtilities.getRequestContainer(httpRequest); responseContainer = ChannelUtilities.getResponseContainer(httpRequest); urlBuilder = UrlBuilderFactory.getUrlBuilder(); msgBuilder = MessageBuilderFactory.getMessageBuilder(); String dsLabelField = msgBuilder.getMessage("SBIDev.queryWiz.dsLabelField", "messages", httpRequest); String queryDefField = msgBuilder.getMessage("SBIDev.queryWiz.queryDefField", "messages", httpRequest); currTheme = ThemesManager.getCurrentTheme(requestContainer); if (currTheme == null) currTheme = ThemesManager.getDefaultTheme(); RequestContainer aRequestContainer = RequestContainer.getRequestContainer(); SessionContainer aSessionContainer = aRequestContainer.getSessionContainer(); SessionContainer permanentSession = aSessionContainer.getPermanentContainer(); IEngUserProfile userProfile = (IEngUserProfile) permanentSession .getAttribute(IEngUserProfile.ENG_USER_PROFILE); boolean isable = false; try {//from w ww . jav a2 s. co m isable = userProfile.isAbleToExecuteAction(SpagoBIConstants.LOVS_MANAGEMENT); } catch (EMFInternalError e) { // TODO Auto-generated catch block e.printStackTrace(); } if (isable) { isreadonly = false; readonly = ""; disabled = ""; } List lstDs = new ArrayList(); try { lstDs = DAOFactory.getDataSourceDAO().loadAllDataSources(); } catch (EMFUserError emf) { emf.printStackTrace(); } Iterator itDs = lstDs.iterator(); StringBuffer output = new StringBuffer(); output.append("<table width='100%' cellspacing='0' border='0'>\n"); output.append(" <tr>\n"); output.append(" <td class='titlebar_level_2_text_section' style='vertical-align:middle;'>\n"); output.append(" " + msgBuilder.getMessage("SBIDev.queryWiz.wizardTitle", "messages", httpRequest) + "\n"); output.append(" </td>\n"); output.append(" <td class='titlebar_level_2_empty_section'> </td>\n"); output.append(" <td class='titlebar_level_2_button_section'>\n"); output.append(" <a style='text-decoration:none;' href='javascript:opencloseQueryWizardInfo()'> \n"); output.append(" <img width='22px' height='22px'\n"); output.append(" src='" + urlBuilder.getResourceLinkByTheme(httpRequest, "/img/info22.jpg", currTheme) + "'\n"); output.append(" name='info'\n"); output.append(" alt='" + msgBuilder.getMessage("SBIDev.queryWiz.showSintax", "messages", httpRequest) + "'\n"); output.append(" title='" + msgBuilder.getMessage("SBIDev.queryWiz.showSintax", "messages", httpRequest) + "'/>\n"); output.append(" </a>\n"); output.append(" </td>\n"); String urlImgProfAttr = urlBuilder.getResourceLinkByTheme(httpRequest, "/img/profileAttributes22.jpg", currTheme); output.append(generateProfAttrTitleSection(urlImgProfAttr)); output.append(" </tr>\n"); output.append("</table>\n"); output.append("<br/>\n"); output.append("<div class='div_detail_area_forms_lov'>\n"); output.append(" <div class='div_detail_label_lov'>\n"); output.append(" <span class='portlet-form-field-label'>\n"); output.append(dsLabelField); output.append(" </span>\n"); output.append(" </div>\n"); output.append(" <div class='div_detail_form'>\n"); output.append( " <select onchange='setLovProviderModified(true);' style='width:180px;' class='portlet-form-input-field' name='datasource' id='datasource' >\n"); while (itDs.hasNext()) { IDataSource ds = (IDataSource) itDs.next(); String dataSource = String.valueOf(ds.getLabel()); String dataSourceDescription = ds.getDescr(); dataSource = StringEscapeUtils.escapeHtml(dataSource); dataSourceDescription = StringEscapeUtils.escapeHtml(dataSourceDescription); String dsLabeleSelected = ""; if (dataSourceLabel.equals(dataSource)) dsLabeleSelected = "selected=\"selected\""; output.append(" <option " + disabled + " value='" + dataSource + "' " + dsLabeleSelected + ">" + dataSourceDescription + "</option>\n"); } output.append(" </select>\n"); output.append(" </div>\n"); output.append(" <div class='div_detail_label_lov'>\n"); output.append(" <span class='portlet-form-field-label'>\n"); output.append(queryDefField); output.append(" </span>\n"); output.append(" </div>\n"); output.append(" <div style='height:110px;' class='div_detail_form'>\n"); output.append(" <textarea style='height:100px;' " + disabled + " class='portlet-text-area-field' name='queryDef' onchange='setLovProviderModified(true);' cols='50'>" + queryDef + "</textarea>\n"); output.append(" </div>\n"); output.append(" <div class='div_detail_label_lov'>\n"); output.append(" \n"); output.append(" </div>\n"); output.append("</div>\n"); output.append("<script>\n"); output.append(" var infowizardqueryopen = false;\n"); output.append(" var winQWT = null;\n"); output.append(" function opencloseQueryWizardInfo() {\n"); output.append(" if(!infowizardqueryopen){\n"); output.append(" infowizardqueryopen = true;"); output.append(" openQueryWizardInfo();\n"); output.append(" }\n"); output.append(" }\n"); output.append(" function openQueryWizardInfo(){\n"); output.append(" if(winQWT==null) {\n"); output.append(" winQWT = new Window('winQWTInfo', {className: \"alphacube\", title:\"" + msgBuilder.getMessage("SBIDev.queryWiz.showSintax", "messages", httpRequest) + "\", width:680, height:150, destroyOnClose: false});\n"); output.append(" winQWT.setContent('querywizardinfodiv', false, false);\n"); output.append(" winQWT.showCenter(false);\n"); output.append(" } else {\n"); output.append(" winQWT.showCenter(false);\n"); output.append(" }\n"); output.append(" }\n"); output.append(" observerQWT = { onClose: function(eventName, win) {\n"); output.append(" if (win == winQWT) {\n"); output.append(" infowizardqueryopen = false;"); output.append(" }\n"); output.append(" }\n"); output.append(" }\n"); output.append(" Windows.addObserver(observerQWT);\n"); output.append("</script>\n"); output.append("<div id='querywizardinfodiv' style='display:none;'>\n"); output.append(msgBuilder.getMessageTextFromResource( "it/eng/spagobi/commons/presentation/tags/info/querywizardinfo", httpRequest)); output.append("</div>\n"); try { pageContext.getOut().print(output.toString()); } catch (Exception ex) { logger.error(ex); throw new JspException(ex.getMessage()); } return SKIP_BODY; }
From source file:com.appeligo.channelfeed.work.FileWriter.java
private synchronized void closeDoc() { if (body == null) { return;/*from ww w . j a v a 2 s.c om*/ } try { doc = new PrintStream(new GZIPOutputStream(new FileOutputStream(filenamePrefix + ".html.gz"))); writeHead(); } catch (IOException e) { log.error("Can't create .html.gz file.", e); return; } try { String programTitle = program.getProgramTitle(); doc.println("<!-- WARNING, XDS IS INFORMATIONAL ONLY AND CAN BE VERY UNRELIABLE -->"); if (xdsData.getCallLettersAndNativeChannel() != null) { doc.println( "<meta name=\"XDSCallLettersAndNativeChannel\" content=\"" + StringEscapeUtils.escapeHtml( xdsData.getCallLettersAndNativeChannel().replaceAll("[\\p{Cntrl}]", "")) + "\"/>"); } if (xdsData.getNetworkName() != null) { doc.println("<meta name=\"XDSNetworkName\" content=\"" + StringEscapeUtils.escapeHtml(xdsData.getNetworkName().replaceAll("[\\p{Cntrl}]", "")) + "\"/>"); } if (xdsData.getProgramName() != null) { doc.println("<meta name=\"XDSProgramName\" content=\"" + StringEscapeUtils.escapeHtml(xdsData.getProgramName().replaceAll("[\\p{Cntrl}]", "")) + "\"/>"); if (programTitle == null) { programTitle = xdsData.getProgramName(); } } try { if (xdsData.getProgramType() != null) { doc.println("<meta name=\"XDSProgramType\" content=\"" + XDSData.convertProgramType(xdsData.getProgramType()) + "\"/>"); } if (xdsData.getProgramStartTimeID() != null) { long startTimestamp = XDSData.convertProgramStartTimeID(xdsData.getProgramStartTimeID()); doc.println("<meta name=\"XDSProgramStartTimeID\" content=\"" + startTimestamp + "\"/>"); Date date = new Date(startTimestamp); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG); df.setTimeZone(TimeZone.getTimeZone("GMT")); doc.println("<meta name=\"XDSProgramStartTime\" content=\"" + df.format(date) + "\"/>"); if (XDSData.convertProgramTapeDelayed(xdsData.getProgramStartTimeID())) { doc.println("<meta name=\"XDSProgramTapeDelayed\" content=\"true\"/>"); } } if (xdsData.getProgramLength() != null) { doc.println("<meta name=\"XDSProgramLength\" content=\"" + XDSData.convertProgramLength(xdsData.getProgramLength()) + "\"/>"); } } catch (Exception e) { //ignore program type errors... probably bad data... such is XDS } if (program != null) { doc.println("<meta name=\"ProgramID\" content=\"" + program.getProgramId() + "\"/>"); doc.println("<meta name=\"ScheduleID\" content=\"" + program.getScheduleId() + "\"/>"); doc.println("<meta name=\"EpisodeTitle\" content=\"" + StringEscapeUtils.escapeHtml(program.getEpisodeTitle()) + "\"/>"); doc.println("<meta name=\"StartTime\" content=\"" + program.getStartTime().getTime() + "\"/>"); doc.println("<meta name=\"EndTime\" content=\"" + program.getEndTime().getTime() + "\"/>"); doc.println("<meta name=\"TVRating\" content=\"" + StringEscapeUtils.escapeHtml(program.getTvRating()) + "\"/>"); if (programTitle == null) { programTitle = Long.toString(program.getStartTime().getTime()); } } doc.println("<title>" + StringEscapeUtils.escapeHtml(programTitle) + "</title>"); doc.println("</head>"); doc.println("<body>"); doc.println("<h1>" + StringEscapeUtils.escapeHtml(programTitle) + "</h1>"); body.close(); body = null; InputStream readBody = new BufferedInputStream(new FileInputStream(filenamePrefix + ".body")); int b = readBody.read(); while (b >= 0) { doc.write(b); b = readBody.read(); } readBody.close(); File f = new File(filenamePrefix + ".body"); f.delete(); writeFoot(); doc.close(); doc = null; } catch (FileNotFoundException e) { log.error("Lost .body file!", e); } catch (IOException e) { log.error("Error copying .body to .html.gz", e); } doc = null; }
From source file:com.redhat.rhn.frontend.struts.RhnAction.java
/** * Add an error message to the request with 1 parameter: * * Your System55 has NOT been updated//from www . j a v a 2 s . com * * where System55 is the value placed in param. * * @param req to add the message to * @param beanKey resource key to lookup * @param param String value to fill in for the first parameter. * (param is HTML escaped as well) */ protected void createErrorMessage(HttpServletRequest req, String beanKey, String param) { ActionErrors errs = new ActionErrors(); String escParam = StringEscapeUtils.escapeHtml(param); errs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(beanKey, escParam)); saveMessages(req, errs); }