Example usage for org.apache.commons.lang StringEscapeUtils escapeHtml

List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml

Introduction

In this page you can find the example usage for org.apache.commons.lang StringEscapeUtils escapeHtml.

Prototype

public static String escapeHtml(String input) 

Source Link

Usage

From source file:hudson.plugins.emailext.plugins.content.BuildLogRegexContent.java

private void appendMatchedLine(StringBuffer buffer, String line, boolean escapeHtml, String style,
        boolean addNewline) {
    if (escapeHtml) {
        line = StringEscapeUtils.escapeHtml(line);
    }// w  w  w  .  jav a 2s.  co m
    if (style != null) {
        buffer.append("<b");
        if (style.length() > 0) {
            buffer.append(" style=\"");
            buffer.append(style);
            buffer.append("\"");
        }
        buffer.append(">");
    }
    buffer.append(line);
    if (style != null) {
        buffer.append("</b>");
    }

    if (addNewline) {
        buffer.append('\n');
    }
}

From source file:it.eng.spagobi.commons.presentation.tags.ErrorTag.java

/**
 * Do start tag.//  www .j a  va2s.co m
 * 
 * @return the int
 * 
 * @throws JspException the jsp exception
 * 
 * @see it.eng.spagobi.commons.presentation.tags.ListTag#doStartTag()
 */
public int doStartTag() throws JspException {
    TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.DEBUG, "ErrorTag::doStartTag:: invoked");
    if (pageContext == null) {
        TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.CRITICAL,
                "ErrorTag::doStartTag:: pageContext null");
        throw new JspException("pageContext nullo");
    } // if (_httpRequest == null)
    HttpServletRequest httpRequest = null;
    try {
        httpRequest = (HttpServletRequest) pageContext.getRequest();
    } // try
    catch (Exception ex) {
        TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.CRITICAL, "ErrorTag::doStartTag::",
                ex);
        throw new JspException(ex.getMessage());
    } // catch (Exception ex)
    if (httpRequest == null) {
        TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.CRITICAL,
                "ErrorTag::doStartTag:: httpRequest null");
        throw new JspException("httpRequest nullo");
    } // if (_httpRequest == null)
      //ResponseContainer responseContainer = ResponseContainerPortletAccess.getResponseContainer(httpRequest);
    ResponseContainer responseContainer = ChannelUtilities.getResponseContainer(httpRequest);
    if (responseContainer == null) {
        TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.CRITICAL,
                "ErrorTag::doStartTag:: responseContainer null");
        throw new JspException("responseContainer null");
    } // if (responseContainer == null)
    StringBuffer output = new StringBuffer();
    EMFErrorHandler engErrorHandler = responseContainer.getErrorHandler();

    Collection errors = engErrorHandler.getErrors();

    if (!errors.isEmpty()) {
        output.append("<div class='errors-object-details-div'>\n");
        output.append("   <div class='div_detail_errors'>\n");
        output.append("      <div class='portlet-section-header'>\n");
        output.append("         ERRORS:\n");
        output.append("      </div>\n");
        output.append("      <div class='portlet-msg-error'>\n");
        output.append("         <ul class='ul_detail_error'>\n");
        EMFAbstractError error = null;
        String description = "";
        Iterator iter = errors.iterator();
        while (iter.hasNext()) {
            error = (EMFAbstractError) iter.next();
            description = error.getDescription();
            description = StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(description));
            output.append("         <li>" + description + "</li>\n");
        }
        output.append("         </ul>\n");
        output.append("      </div>\n");
        output.append("   </div>\n");
        output.append("</div>\n");
    }

    try {
        pageContext.getOut().print(output.toString());
    } // try
    catch (Exception ex) {
        TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.CRITICAL, "ErrorTag::doStartTag::",
                ex);
        throw new JspException(ex.getMessage());
    } // catch (Exception ex)
    return SKIP_BODY;
}

From source file:ch.systemsx.cisd.openbis.generic.shared.dto.identifier.IdentifierHelper.java

/**
 * Converts "full" sample code from the <var>sampleCode</var> and
 * <var>containerCodeOrNull</var>. For contained samples (i.e.
 * <code>containerCodeOrNull != null</code>) has a prefix consisting of container sample DB code
 * and a colon, otherwise it is just sample DB code, where by "sample DB code" is the code kept
 * in the DB./*w ww.  j  a va2 s . c  om*/
 */
public final static String convertCode(String sampleCode, String containerCodeOrNull) {
    final String subCode = convertSubCode(sampleCode);

    final String code;
    if (containerCodeOrNull != null) {
        final String containerCode = StringEscapeUtils.escapeHtml(containerCodeOrNull);
        code = containerCode + ":" + subCode;
    } else {
        code = subCode;
    }
    return code;
}

From source file:hello.jaxrs.GreetingsResource.java

private void printErrorMessage(final PrintWriter writer, final String message) {
    writer.println("<p><strong>");
    writer.println(StringEscapeUtils.escapeHtml(message));
    writer.println("</strong></p>");
}

From source file:com.crawljax.plugins.adi.Report.java

private String addFailuresToDom(Document dom) {

    /* TOOD: this modifies the DOM, it should create a copy */

    for (int i = 0; i < failures.size(); i++) {
        String[] failure = failures.get(i);
        if (failure[1] != null) {
            dom = addMarker("" + i, dom, failure[1]);
        }/*from   ww w. ja  va  2 s .  c o m*/
        dom = addMarker("" + i, dom, failure[0]);
    }
    String formattedDom = Helper.getDocumentToString(dom);
    formattedDom = PrettyHTML.prettyHTML(formattedDom, "  ");
    formattedDom = StringEscapeUtils.escapeHtml(formattedDom);
    formattedDom = replaceMarkers(formattedDom);

    return formattedDom;
}

From source file:ch.systemsx.cisd.openbis.generic.shared.translator.ExperimentTranslator.java

public final static ExperimentTypePE translate(final ExperimentType experimentType) {
    final ExperimentTypePE result = new ExperimentTypePE();
    result.setCode(StringEscapeUtils.escapeHtml(experimentType.getCode()));
    result.setDescription(StringEscapeUtils.escapeHtml(experimentType.getDescription()));
    result.setDatabaseInstance(DatabaseInstanceTranslator.translate(experimentType.getDatabaseInstance()));
    return result;
}

From source file:gov.nih.nci.ncicb.cadsr.common.lov.ProtocolsLOVBean.java

public ProtocolsLOVBean(HttpServletRequest request, DBUtil dbUtil, String additionalWhere) {

    try {/*ww w .j  av a2s  . com*/
        searchStr = request.getParameter("SEARCH");
        if (searchStr == null)
            searchStr = "";
        String searchWhere = "";
        String newSearchStr = "";
        if (!searchStr.equals("")) {
            newSearchStr = StringReplace.strReplace(searchStr, "*", "%");
            newSearchStr = StringReplace.strReplace(newSearchStr, "'", "''");
            searchWhere = " and   (upper (proto.long_name) like upper ( '" + newSearchStr + "') "
                    + " OR upper (proto.preferred_name) like upper ( '" + newSearchStr + "')) ";
        }
        if (request.getParameter("chkContext") == null) {
            whereClause = searchWhere;
        } else {
            whereClause = searchWhere + additionalWhere;
            isContextSpecific = true;
        }
        if (isEscape) {
            whereClause = whereClause + "ESCAPE '\\'";
        }
        // pass the following parameters to CommonListCntrlBean
        String[] searchParm = { "proto.long_name", "Keyword" };
        String[] jspLinkParm = { "proto.proto_idseq", "P_ID" };
        String[] displayParm = { "proto.long_name", "Long Name", "proto.protocol_id", "Protocol ID",
                "proto.preferred_name", "Short Name", "proto_conte.name", "Context", "proto.asl_name",
                "Workflow Status", "proto.preferred_definition", "Definition", "proto.lead_org",
                "Lead Organization" };
        String[] sqlStmtParm = new String[2];
        sqlStmtParm[0] = " from sbrext.protocols_view_ext proto, sbr.contexts_view proto_conte "
                + " where proto.conte_idseq = proto_conte.conte_idseq "
                + " and proto.latest_version_ind = 'Yes' " +
                //" and proto.deleted_ind = 'No' "  this is done in the view
                //" and proto.asl_name not in ('RETIRED PHASED OUT','RETIRED DELETED') ";
                whereClause;
        sqlStmtParm[1] = " order by proto.preferred_name ";
        int[] lovPassbackCols = { 0 };

        clb = new CommonLOVBean(request, dbUtil, searchParm, jspLinkParm, displayParm, sqlStmtParm, false,
                lovPassbackCols);

        clb.setCompressFlag(false); // set compress flag
        clb.setLinkCol(0); // set detail page link column, 0-> first; 1->second
        clb.setDetailReq_Type("protocols_ext"); //set req_type for detail page
        clb.setShowRowNum(40);
        clb.setJsId(StringEscapeUtils.escapeHtml(request.getParameter("idVar")));
        //System.out.println(">> ProtocolLOVBean: idVar="+request.getParameter("idVar"));
        clb.setJsName(StringEscapeUtils.escapeHtml(request.getParameter("nameVar")));
        //System.out.println(">> ProtocolLOVBean: nameVar="+request.getParameter("nameVar"));
        if (isContextSpecific)
            clb.setExtraURLInfo("&performQuery=false&ckhContext=yes");
        else
            clb.setExtraURLInfo("&performQuery=false");

    } catch (SQLException e) {
        log.error("Exception: ", e);
    }
}

From source file:com.predic8.membrane.core.interceptor.acl.AccessControlInterceptor.java

@Override
public String getShortDescription() {
    return "Authenticates incoming requests based on the file " + StringEscapeUtils.escapeHtml(file) + " .";
}

From source file:com.redhat.rhn.domain.action.config.ConfigActionFormatter.java

/**
 * {@inheritDoc}//from w  w w  .  j a v a2 s .c o  m
 */
@Override
public String getRelatedObjectDescription() {
    Set<ConfigRevisionAction> revisionActions = ((ConfigAction) getAction()).getConfigRevisionActions();
    List<String> result = new LinkedList<String>();
    if (revisionActions != null) {
        for (ConfigRevisionAction revisionAction : revisionActions) {
            ConfigRevision revision = revisionAction.getConfigRevision();
            if (revision != null) {
                ConfigFile configFile = revision.getConfigFile();
                if (configFile != null) {
                    ConfigFileName configFileName = configFile.getConfigFileName();
                    if (configFileName != null) {
                        result.add("<a href=\"/rhn/configuration/file/FileDetails.do?crid="
                                + revision.getId().toString() + "\">"
                                + StringEscapeUtils.escapeHtml(configFileName.getPath()) + "</a>");
                    }
                }
            }
        }
    }
    return StringUtil.join(", ", result);
}

From source file:de.tor.tribes.util.html.FightReportHTMLToolTipGenerator.java

public static String buildToolTip(FightReport pReport) {
    String res = pTemplateData;//w w  w  . j a  v  a  2 s.co  m
    String[] tables = buildUnitTables(pReport);
    SimpleDateFormat f = new SimpleDateFormat("dd.MM.yy HH:mm:ss");
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMinimumFractionDigits(0);
    nf.setMaximumFractionDigits(0);
    res = res.replaceAll(WINNER_STRING,
            ((pReport.isWon() ? "Der Angreifer hat gewonnen" : "Der Verteidiger hat gewonnen")));
    res = res.replaceAll(SEND_TIME, f.format(new Date(pReport.getTimestamp())));
    res = res.replaceAll(ATTACKER_TABLE, tables[0]);
    res = res.replaceAll(DEFENDER_TABLE, tables[1]);
    res = res.replaceAll(MISC_TABLES, buildMiscTables(pReport));
    res = res.replaceAll(LUCK_STRING, "Gl&uuml;ck (aus Sicht des Angreifers)");
    res = res.replaceAll(LUCK_BAR, buildLuckBar(pReport.getLuck()));
    res = res.replaceAll(MORAL, nf.format(pReport.getMoral()) + "%");
    nf.setMinimumFractionDigits(1);
    nf.setMaximumFractionDigits(1);
    res = res.replaceAll(LUCK_NEG,
            ((pReport.getLuck() < 0) ? "<b>" + nf.format(pReport.getLuck()) + "%</b>" : ""));
    res = res.replaceAll(LUCK_POS,
            ((pReport.getLuck() >= 0) ? "<b>" + nf.format(pReport.getLuck()) + "%</b>" : ""));
    res = res.replaceAll(LUCK_ICON1, "<img src=\""
            + ((pReport.getLuck() <= 0) ? FightReportHTMLToolTipGenerator.class.getResource("/res/rabe.png")
                    : FightReportHTMLToolTipGenerator.class.getResource("/res/rabe_grau.png"))
            + "\"/>");
    res = res.replaceAll(LUCK_ICON2, "<img src=\""
            + ((pReport.getLuck() >= 0) ? FightReportHTMLToolTipGenerator.class.getResource("/res/klee.png")
                    : FightReportHTMLToolTipGenerator.class.getResource("/res/klee_grau.png"))
            + "\"/>");
    res = res.replaceAll(ATTACKER, StringEscapeUtils.escapeHtml(pReport.getAttacker().getName()));
    res = res.replaceAll(SOURCE, StringEscapeUtils.escapeHtml(pReport.getSourceVillage().getFullName()));
    res = res.replaceAll(DEFENDER, StringEscapeUtils.escapeHtml(pReport.getDefender().getName()));
    res = res.replaceAll(TARGET, StringEscapeUtils.escapeHtml(pReport.getTargetVillage().getFullName()));
    res = res.replaceAll(RAM_DAMAGE,
            ((pReport.wasWallDamaged())
                    ? "Wall besch&auml;digt von Level <b>" + pReport.getWallBefore() + "</b> auf Level <b>"
                            + pReport.getWallAfter() + "</b>"
                    : ""));
    res = res.replaceAll(CATA_DAMAGE,
            ((pReport.wasBuildingDamaged()) ? pReport.getAimedBuilding() + " besch&auml;digt von Level <b>"
                    + pReport.getBuildingBefore() + "</b> auf Level <b>" + pReport.getBuildingAfter() + "</b>"
                    : ""));
    res = res.replaceAll(SNOB_INFLUENCE,
            ((pReport.wasSnobAttack())
                    ? "Zustimmung gesunken von <b>" + pReport.getAcceptanceBefore() + "</b> auf <b>"
                            + pReport.getAcceptanceAfter() + "</b>"
                    : ""));

    return res;
}