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.thoughtworks.go.server.view.Escaper.java

public String escape(String value) {
    return StringEscapeUtils.escapeHtml(value);
}

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

public static MaterialType translate(MaterialTypePE entityTypeOrNull, boolean withProperties,
        Map<PropertyTypePE, PropertyType> cacheOrNull) {
    if (entityTypeOrNull == null) {
        return null;
    }//w ww .  j  a  va  2s.c  om
    final MaterialType result = new MaterialType();
    result.setCode(StringEscapeUtils.escapeHtml(entityTypeOrNull.getCode()));
    result.setDescription(StringEscapeUtils.escapeHtml(entityTypeOrNull.getDescription()));
    result.setDatabaseInstance(DatabaseInstanceTranslator.translate(entityTypeOrNull.getDatabaseInstance()));
    if (withProperties == false) {
        unsetMaterialTypes(entityTypeOrNull.getMaterialTypePropertyTypes());
    }
    result.setMaterialTypePropertyTypes(MaterialTypePropertyTypeTranslator
            .translate(entityTypeOrNull.getMaterialTypePropertyTypes(), result, cacheOrNull));
    return result;
}

From source file:gov.nih.nci.ncicb.cadsr.contexttree.BaseTreeNode.java

public String getTreeType() {
    String treeType = (String) treeParams.get(TREE_TYPE_URL_PARAM);
    if (treeType == null)
        treeType = DE_SEARCH_TREE;/*w w  w .  j  av  a  2s.co  m*/
    return StringEscapeUtils.escapeHtml(treeType);
}

From source file:ch.systemsx.cisd.openbis.generic.client.web.server.translator.UserFailureExceptionTranslator.java

/**
 * Converts any {@link ch.systemsx.cisd.common.exceptions.UserFailureException} or subclass of
 * it to a <i>GWT</i> {@link UserFailureException} (or subclass of it if this one could be
 * found in the same package)./*w  w w. j a va2 s.c  om*/
 */
public static UserFailureException translate(
        ch.systemsx.cisd.common.exceptions.UserFailureException exception) {
    final String className = WEB_CLIENT_EXCEPTIONS_PACKAGE + "." + exception.getClass().getSimpleName();
    String message = StringEscapeUtils.escapeHtml(exception.getMessage());
    try {
        return ClassUtils.create(UserFailureException.class, className, message);
    } catch (final CheckedExceptionTunnel e) {
        return new UserFailureException(message);
    }

}

From source file:jp.sourceforge.tmdmaker.generate.internal.EscapeTool.java

/**
 * html//w w  w  . jav a2s.c om
 * 
 * @param string
 * @return 
 */
public String html(Object string) {
    if (string == null) {
        return null;
    }
    return StringEscapeUtils.escapeHtml(String.valueOf(string));
}

From source file:edu.cornell.mannlib.vedit.tags.ErrorTag.java

public int doEndTag() throws JspException {
    try {//from  w  ww  .  j a v a  2  s  . co m
        JspWriter out = pageContext.getOut();

        String errors = null;
        try {
            errors = (String) getFormObject().getErrorMap().get(name);
        } catch (Exception e) {
            System.out.println("Could not get the form object from which to extract validation error message.");
        }

        if (errors != null) {
            out.print(StringEscapeUtils.escapeHtml((String) errors));
        }

    } catch (Exception ex) {
        throw new JspException(ex.getMessage());
    }
    return SKIP_BODY;
}

From source file:edu.cornell.mannlib.vedit.tags.OptionTag.java

private void outputOptionsMarkup(List optList, JspWriter out) throws IOException {
    Iterator it = optList.iterator();
    while (it.hasNext()) {
        Option opt = (Option) it.next();
        if (opt.getValue() == null)
            opt.setValue("");
        if (opt.getBody() == null)
            opt.setBody("");
        out.print("<option value=\"" + StringEscapeUtils.escapeHtml(opt.getValue()) + "\"");
        if (opt.getSelected())
            out.print(" selected=\"selected\"");
        out.print(">");
        out.print(StringEscapeUtils.escapeHtml(opt.getBody()));
        out.print("</option>\n");
    }// w w w .j ava  2 s.co  m
}

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

public final static Project translate(final ProjectPE project) {
    if (project == null) {
        return null;
    }/*from   www.j av a2 s. co m*/
    final Project result = new Project();
    result.setId(HibernateUtils.getId(project));
    result.setModificationDate(project.getModificationDate());
    result.setCode(StringEscapeUtils.escapeHtml(project.getCode()));
    result.setDescription(StringEscapeUtils.escapeHtml(project.getDescription()));
    result.setGroup(GroupTranslator.translate(project.getGroup()));
    result.setProjectLeader(PersonTranslator.translate(project.getProjectLeader()));
    result.setRegistrator(PersonTranslator.translate(project.getRegistrator()));
    result.setRegistrationDate(project.getRegistrationDate());
    result.setIdentifier(
            StringEscapeUtils.escapeHtml(IdentifierHelper.createProjectIdentifier(project).toString()));
    List<Attachment> attachments;
    if (project.attachmentsInitialized() == false) {
        attachments = DtoConverters.createUnmodifiableEmptyList();
    } else {
        attachments = AttachmentTranslator.translate(project.getAttachments());
    }
    result.setAttachments(attachments);
    return result;
}

From source file:com.inet.web.service.mail.utils.MailHeaderHelper.java

/**
 * convert to JSON from given Mail Header
 * @param header MailHeader/*w  w  w  .  jav  a  2  s. c om*/
 * @return JSON
 */
public static JSONObject convertMailHeader2JSON(MailHeader header, boolean isFetch) {
    JSONObject json = new JSONObject();
    json.accumulate(MailConstants.HEADER_ID, header.getId())
            .accumulate(MailConstants.MAIL_PRIORITY, header.getPriority().toString())
            .accumulate(MailConstants.SENDER,
                    StringEscapeUtils.escapeHtml(StringService.hasLength(header.getSender())
                            ? header.getSender().replace("\"", StringService.EMPTY_STRING)
                            : StringService.EMPTY_STRING))
            .accumulate(MailConstants.RECIPIENT,
                    StringService.hasLength(header.getRecipients()) ? header.getRecipients()
                            : StringService.EMPTY_STRING)
            .accumulate(MailConstants.SUBJECT, StringEscapeUtils.escapeHtml(header.getSubject()))
            .accumulate(MailConstants.ATTACHED, header.getAttached() == CommonService.YES ? true : false)
            .accumulate(MailConstants.SIZE, MailService.getByteSize(header.getSize()))
            .accumulate(MailConstants.READ,
                    header.getRead() == CommonService.YES ? MailConstants.READ_YES : MailConstants.READ_NO)
            .accumulate(MailConstants.RECEIVED_DATE,
                    header.getReceived() != null ? header.getReceived().getTime()
                            : header.getCreated().getTime())
            .accumulate(MailConstants.SENT_DATE,
                    header.getSent() != null ? header.getSent().getTime() : header.getCreated().getTime())
            .accumulate(MailConstants.FLAG, String.valueOf(header.getFlag()))
            .accumulate(MailConstants.TYPE, header.getType().toString())
            .accumulate(MailConstants.CONTENT_ID, header.getComposeID());

    if (isFetch)
        json.accumulate(MailConstants.FOLDER, header.getFolder().getId());

    return json;
}

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

public final static Filter translate(final FilterPE filter) {
    if (filter == null) {
        return null;
    }/*  www  .j  ava2 s.c o m*/
    final Filter result = new Filter();
    result.setId(HibernateUtils.getId(filter));
    result.setExpression(filter.getExpression());
    result.setModificationDate(filter.getModificationDate());
    result.setName(StringEscapeUtils.escapeHtml(filter.getName()));
    result.setDescription(StringEscapeUtils.escapeHtml(filter.getDescription()));
    result.setRegistrator(PersonTranslator.translate(filter.getRegistrator()));
    result.setRegistrationDate(filter.getRegistrationDate());
    result.setDatabaseInstance(DatabaseInstanceTranslator.translate(filter.getDatabaseInstance()));
    result.setPublic(filter.isPublic());
    result.setParameters(extractParameters(filter.getExpression()));
    result.setColumns(extractColumns(filter.getExpression()));
    return result;
}