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:com.comcast.cns.io.CNSAttributePopulator.java

public static String getGetTopicAttributesResponse(CNSTopicAttributes attr) {

    StringBuffer out = new StringBuffer("<GetTopicAttributesResponse>\n");

    out.append("\t<GetTopicAttributesResult>\n");
    out.append("\t\t<Attributes>\n");
    out.append("\t\t\t<entry>\n");
    out.append("\t\t\t\t<key>EffectiveDeliveryPolicy</key>\n");
    out.append("\t\t\t\t<value>").append(attr.getEffectiveDeliveryPolicy().toString()).append("</value>\n");
    out.append("\t\t\t</entry>\n");
    out.append("\t\t\t<entry>\n");
    out.append("\t\t\t\t<key>Owner</key>\n");
    out.append("\t\t\t\t<value>").append(attr.getUserId()).append("</value>\n");
    out.append("\t\t\t</entry>\n");
    out.append("\t\t\t<entry>\n");
    out.append("\t\t\t\t<key>Policy</key>\n");
    out.append("\t\t\t\t<value>").append(attr.getPolicy()).append("</value>\n");
    out.append("\t\t\t</entry>\n");
    out.append("\t\t\t<entry>\n");
    out.append("\t\t\t\t<key>SubscriptionsPending</key>\n");
    out.append("\t\t\t\t<value>").append(attr.getSubscriptionsPending()).append("</value>\n");
    out.append("\t\t\t</entry>\n");
    out.append("\t\t\t<entry>\n");
    out.append("\t\t\t\t<key>SubscriptionsConfirmed</key>\n");
    out.append("\t\t\t\t<value>").append(attr.getSubscriptionsConfirmed()).append("</value>\n");
    out.append("\t\t\t</entry>\n");
    out.append("\t\t\t<entry>\n");
    out.append("\t\t\t\t<key>SubscriptionsDeleted</key>\n");
    out.append("\t\t\t\t<value>").append(attr.getSubscriptionsDeleted()).append("</value>\n");
    out.append("\t\t\t</entry>\n");

    if (attr.getDisplayName() != null && !attr.getDisplayName().isEmpty()) {
        out.append("\t\t\t<entry>\n");
        out.append("\t\t\t\t<key>DisplayName</key>\n");
        out.append("\t\t\t\t<value>").append(StringEscapeUtils.escapeHtml(attr.getDisplayName()))
                .append("</value>\n");
        out.append("\t\t\t</entry>\n");
    }// w w  w  . ja  v  a2s.  c  o  m

    out.append("\t\t\t<entry>\n");
    out.append("\t\t\t\t<key>DeliveryPolicy</key>\n");
    out.append("\t\t\t\t<value>" + attr.getEffectiveDeliveryPolicy().toString() + "</value>\n");
    out.append("\t\t\t</entry>\n");
    out.append("\t\t\t<entry>\n");
    out.append("\t\t\t\t<key>TopicArn</key>\n");
    out.append("\t\t\t\t<value>").append(attr.getTopicArn()).append("</value>\n");
    out.append("\t\t\t</entry>\n");
    out.append("\t\t</Attributes>\n");
    out.append("\t</GetTopicAttributesResult>\n");
    out.append(CNSPopulator.getResponseMetadata());
    out.append("</GetTopicAttributesResponse>");

    return out.toString();
}

From source file:com.silverpeas.importExport.report.HtmlExportPublicationGenerator.java

public HtmlExportPublicationGenerator(PublicationType publicationType, ModelDetail modelDetail,
        String wysiwygText, String urlPub, int nbThemes) {
    this.publicationDetail = publicationType.getPublicationDetail();
    if (publicationType.getPublicationContentType() != null) {
        this.dbModelContent = publicationType.getPublicationContentType().getDBModelContentType();
        this.xmlModelContent = publicationType.getPublicationContentType().getXMLModelContentType();
    }// w  w  w  .j  a  v a  2  s .co m
    this.nbThemes = nbThemes + 2;
    if (publicationType.getAttachmentsType() != null) {
        this.listAttDetail = publicationType.getAttachmentsType().getListAttachmentDetail();
    }
    this.modelDetail = modelDetail;
    this.wysiwygText = wysiwygText;
    this.urlPub = StringEscapeUtils.escapeHtml(urlPub).replaceAll("#", "%23");
}

From source file:gov.nih.nci.ncicb.cadsr.cdebrowser.process.GetClassificationsLOV.java

/**
 * persist: called by start to do all persisting work for this process.  If
 * this method throws an exception, then the condition returned by the
 * <code>getPersistFailureCondition()</code> is set.  Otherwise, the
 * condition returned by <code>getPersistSuccessCondition()</code> is set.
 *//*  w  ww .ja v a 2  s.co m*/
public void persist() throws Exception {
    HttpServletRequest myRequest = null;
    TabInfoBean tib = null;
    String[] searchParam = null;
    ClassificationsLOVBean cslb = null;
    String performQuery = null;
    DBUtil dbUtil = null;
    String dsName = null;

    try {
        if (getStringInfo("INITIALIZED") == null) {
            CDEBrowserParams params = CDEBrowserParams.getInstance();
            //dsName = params.getSbrDSN();
            dbUtil = new DBUtil();
        } else {
            dbUtil = (DBUtil) getInfoObject("dbUtil");
            //dsName = getStringInfo("SBR_DSN");
        }

        tib = new TabInfoBean("cdebrowser_lov_tabs");
        myRequest = (HttpServletRequest) getInfoObject("HTTPRequest");
        tib.processRequest(myRequest);

        if (tib.getMainTabNum() != 0) {
            tib.setMainTabNum(0);
        }

        searchParam = getInfoStringArray("SEARCH");

        if (searchParam != null) {
            int numberOfSearchFields = searchParam.length;
        }

        performQuery = StringEscapeUtils.escapeHtml(getStringInfo("performQuery"));

        if (performQuery == null) {
            //dbUtil = (DBUtil) getInfoObject("dbUtil");
            //dsName = getStringInfo("SBR_DSN");
            dbUtil.getConnectionFromContainer();

            String contextIdSeq = StringEscapeUtils.escapeHtml(getStringInfo("P_CONTE_IDSEQ"));

            if (contextIdSeq != null) {

                if (!AppScanValidator.validateElementIdSequence(contextIdSeq))
                    throw new Exception("Invalidate ID sequence");
            }
            String chk = StringEscapeUtils.escapeHtml(getStringInfo("chkContext"));

            String[] contexts = null;

            if ((chk != null) && chk.equals("always")) {
                Collection coll = (Collection) myRequest.getSession().getAttribute("userContexts");
                contexts = new String[coll.size()];
                int i = 0;
                for (Iterator it = coll.iterator(); it.hasNext(); i++)
                    contexts[i] = ((Context) it.next()).getConteIdseq();
                myRequest.setAttribute("chkContext", chk);
            } else {
                if ((contextIdSeq != null) && (contextIdSeq.length() > 0)) {
                    contexts = new String[1];
                    contexts[0] = contextIdSeq;
                } else
                    contexts = new String[0];
            }

            // build additional query filters
            String additionalWhere = "";
            if (contexts.length > 0)
                additionalWhere += " and (upper(nvl(cs_conte.conte_idseq,'%')) like upper ( '%" + contexts[0]
                        + "%') ";

            for (int i = 1; i < contexts.length; i++) {
                additionalWhere += " or upper(nvl(cs_conte.conte_idseq,'%')) like upper ( '%" + contexts[i]
                        + "%') ";
            }
            if (contexts.length > 0)
                additionalWhere += ")";

            //         String additionalWhere =
            //           " and upper(nvl(cs_conte.conte_idseq,'%')) like upper ( '%" +
            //           conteIdseq + "%') ";

            cslb = new ClassificationsLOVBean(myRequest, dbUtil, additionalWhere);
            dbUtil.returnConnection();
        } else {
            cslb = (ClassificationsLOVBean) getInfoObject(ProcessConstants.CS_LOV);
            cslb.getCommonLOVBean().resetRequest(myRequest);
        }

        setResult(ProcessConstants.CS_LOV, cslb);
        setResult("tib", tib);
        setResult("performQuery", null);
        setCondition(SUCCESS);
    } catch (Exception ex) {
        try {
            setCondition(FAILURE);
            //dbUtil.returnConnection();
        } catch (TransitionConditionException tce) {
            reportException(tce, DEBUG);
        } catch (Exception e) {
            reportException(e, DEBUG);
        }

        reportException(ex, DEBUG);
    } finally {
        if (dbUtil != null) {
            dbUtil.returnConnection();
        }
    }
}

From source file:com.epam.cme.storefront.util.PageTitleResolver.java

public String resolveCategoryPageTitle(final CategoryModel category) {
    final StringBuilder sb = new StringBuilder();
    final List<CategoryModel> categories = this.getCategoryPath(category);
    for (final CategoryModel c : categories) {
        sb.append(c.getName()).append(SEPARATOR);
    }//  w ww  .  ja  va2 s. co m

    final CMSSiteModel currentSite = getCmsSiteService().getCurrentSite();
    if (currentSite != null) {
        sb.append(currentSite.getName());
    }

    return StringEscapeUtils.escapeHtml(sb.toString());
}

From source file:com.redhat.rhn.frontend.nav.NavNode.java

/**
 * Gets the current value of name/*from  w w  w  . java  2 s.com*/
 * @return String the current value
 */
public String getName() {
    //Return the translated and escaped name
    String unescapedName = LocalizationService.getInstance().getMessage(this.name);
    return StringEscapeUtils.escapeHtml(unescapedName);
}

From source file:edu.usc.goffish.gofs.formats.gml.KeyValuePair.java

@Override
public final void write(Writer output) throws IOException {
    output.write(Key());//w  ww . jav  a 2 s. co  m
    output.write(" \"");
    output.write(StringEscapeUtils.escapeHtml(_value));
    output.write("\"");
}

From source file:de.fhg.fokus.openride.services.profile.ProfileService.java

@GET
@Produces("text/json")
public Response getProfile(@Context HttpServletRequest con, @PathParam("username") String username) {

    System.out.println("getProfile start");

    // check if remote user == {username} in path param
    if (!username.equals(con.getRemoteUser())) {
        //  return Response.status(Response.Status.FORBIDDEN).build();
    }// w w  w  .ja v  a2  s .c om

    CustomerEntity c = customerControllerBean.getCustomerByNickname(username);
    CarDetailsEntity cd = carDetailsControllerBean.getCarDetails(c);

    // build a List of Objects that shall be available in the JSON context.
    ArrayList list = new ArrayList();
    list.add(new ProfileResponse());

    XStream x = Utils.getJasonXStreamer(list);

    Long dateOfBirth = null;
    if (c.getCustDateofbirth() != null) {
        dateOfBirth = c.getCustDateofbirth().getTime();
    }
    Short licenseDate = null;
    if (c.getCustLicensedate() != null) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(c.getCustLicensedate());
        licenseDate = (short) cal.get(Calendar.YEAR);
    }

    ProfileResponse profile = new ProfileResponse(StringEscapeUtils.escapeHtml(c.getCustFirstname()),
            StringEscapeUtils.escapeHtml(c.getCustLastname()), c.getCustGender(), dateOfBirth,
            StringEscapeUtils.escapeHtml(c.getCustEmail()),
            StringEscapeUtils.escapeHtml(c.getCustMobilephoneno()),
            StringEscapeUtils.escapeHtml(c.getCustFixedphoneno()),
            StringEscapeUtils.escapeHtml(c.getCustAddrStreet()), c.getCustAddrZipcode(),
            StringEscapeUtils.escapeHtml(c.getCustAddrCity()), getCustIssmokerChar(c.getCustIssmoker()),
            licenseDate, (cd != null) ? cd.getCardetColour() : null, (cd != null) ? cd.getCardetBrand() : null,
            (cd != null) ? cd.getCardetBuildyear() : null, (cd != null) ? cd.getCardetPlateno() : null);

    return Response.ok(x.toXML(profile)).build();

}

From source file:com.careerly.common.support.resolver.ControllerExceptionResolver.java

/**
 * @param request/*from   w  ww  . j av  a  2 s  .c o  m*/
 * @param response
 * @param handler
 * @return
 */
private void resolveDataException(HttpServletRequest request, HttpServletResponse response, Object handler,
        StandardJsonObject errorJsonObject) {
    try {
        String data = null;
        String callbackValue = request.getParameter("callback");
        if (StringUtils.isNotBlank(callbackValue)) {
            StringBuilder builder = new StringBuilder();
            builder.append(StringEscapeUtils.escapeHtml(callbackValue)).append("(");
            builder.append(JsonUtils.marshalToString(errorJsonObject));
            builder.append(")");
            data = builder.toString();
        } else {
            data = JsonUtils.marshalToString(errorJsonObject);
        }

        response.setContentType("application/json;charset=UTF-8");
        Writer writer = response.getWriter();
        writer.write(data);
        writer.close();
    } catch (IOException e) {
        ControllerExceptionResolver.logger.error("ERROR ## write message happened error, the trace ", e);
    }
}

From source file:com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckFile.java

public String getVerboseHtml() {
    return StringEscapeUtils.escapeHtml(verbose);
}

From source file:de.hybris.platform.acceleratorservices.storefront.util.PageTitleResolver.java

public String resolveCategoryPageTitle(final CategoryModel category) {
    final StringBuilder stringBuilder = new StringBuilder();
    final List<CategoryModel> categories = this.getCategoryPath(category);
    for (final CategoryModel c : categories) {
        stringBuilder.append(c.getName()).append(TITLE_WORD_SEPARATOR);
    }//w  w w  . ja  v a2s. c  o m

    final CMSSiteModel currentSite = getCmsSiteService().getCurrentSite();
    if (currentSite != null) {
        stringBuilder.append(currentSite.getName());
    }

    return StringEscapeUtils.escapeHtml(stringBuilder.toString());
}