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:eu.arthepsy.sonar.plugins.rebrand.ImageSettings.java

private String escape(String value) {
    if (StringUtils.isEmpty(value)) {
        return "";
    } else {/*from  www .j  av a2  s .c om*/
        return StringEscapeUtils.escapeHtml(value.replaceAll("'", "#&39;"));
    }
}

From source file:ch.entwine.weblounge.test.site.GreeterTag.java

/**
 * {@inheritDoc}//from w w  w .j av a  2  s  .c  om
 * 
 * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
 */
public int doStartTag() throws JspException {
    try {
        Map<String, String> greetings = TestSiteUtils.loadGreetings();
        String greeting = null;
        if (language != null) {
            greeting = greetings.get(language);
            if (greeting == null)
                greeting = "Excuse me?";
        } else {
            String[] languages = greetings.keySet().toArray(new String[greetings.size()]);
            language = languages[(int) Math.random() * languages.length];
            greeting = greetings.get(language);
        }
        String encodedGreeting = StringEscapeUtils.escapeHtml(greeting);
        pageContext.getOut().print("<div id=\"greeting\">");
        pageContext.getOut().print(encodedGreeting);
        pageContext.getOut().println("</div>");
        pageContext.getOut().flush();
    } catch (IOException ioe) {
        throw new JspException("IOException while writing to client" + ioe.getMessage());
    }
    return SKIP_BODY;
}

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

/**
 * Extracts "sub" code from {@link SamplePE} that is in exactly the same as the one kept in DB
 * (so the same one that is mapped with {@link SamplePE#getCode()}).
 *//* www .jav  a  2  s . c o  m*/
public final static String extractSubCode(SamplePE samplePE) {
    return StringEscapeUtils.escapeHtml(samplePE.getCode());
}

From source file:com.sonymobile.backlogtool.Attribute.java

public String getName() {
    return StringEscapeUtils.escapeHtml(name);
}

From source file:com.alibaba.jstorm.ui.controller.ComponentController.java

@RequestMapping(value = "/component", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String clusterName,
        @RequestParam(value = "topology", required = true) String topology_id,
        @RequestParam(value = "component", required = true) String component,
        @RequestParam(value = "win", required = false) String win, ModelMap model) {
    clusterName = StringEscapeUtils.escapeHtml(clusterName);
    topology_id = StringEscapeUtils.escapeHtml(topology_id);
    long start = System.currentTimeMillis();
    int window = UIUtils.parseWindow(win);
    UIUtils.addWindowAttribute(model, window);
    NimbusClient client = null;/*  w  w w  . j  a  v  a  2  s. c o  m*/
    try {
        client = NimbusClientManager.getNimbusClient(clusterName);

        //get Component Metric
        TopologyInfo topologyInfo = client.getClient().getTopologyInfo(topology_id);
        MetricInfo componentMetrics = topologyInfo.get_metrics().get_componentMetric();
        //            List<MetricInfo> componentMetrics = client.getClient().getMetrics(topology_id, MetaType.COMPONENT.getT());
        UIComponentMetric componentMetric = UIMetricUtils.getComponentMetric(componentMetrics, window,
                component, topologyInfo.get_components());
        model.addAttribute("comp", componentMetric);
        model.addAttribute("compHead", UIMetricUtils.sortHead(componentMetric, UIComponentMetric.HEAD));

        //get Task Stat
        model.addAttribute("tasks", UIUtils.getTaskEntities(topologyInfo, component));

        //get Task metrics
        //            MetricInfo taskMetrics = topologyInfo.get_metrics().get_taskMetric();
        MetricInfo taskMetrics = client.getClient().getTaskMetrics(topology_id, component);
        //            System.out.println("taskMetrics:" + taskMetrics);
        List<UITaskMetric> taskData = UIMetricUtils.getTaskMetrics(taskMetrics, component, window);
        model.addAttribute("taskData", taskData);
        model.addAttribute("taskHead", UIMetricUtils.sortHead(taskData, UITaskMetric.HEAD));

    } catch (NotAliveException nae) {
        model.addAttribute("flush", String.format("The topology: %s is dead.", topology_id));
    } catch (Exception e) {
        NimbusClientManager.removeClient(clusterName);
        LOG.error(e.getMessage(), e);
        UIUtils.addErrorAttribute(model, e);
    }

    // page information
    model.addAttribute("clusterName", clusterName);
    model.addAttribute("topologyId", topology_id);
    model.addAttribute("compName", component);
    model.addAttribute("page", "component");
    model.addAttribute("supervisorPort", UIUtils.getSupervisorPort(clusterName));
    UIUtils.addTitleAttribute(model, "Component Summary");
    try {
        String topologyName = Common.topologyIdToName(topology_id);
        model.addAttribute("topologyName", topologyName);
    } catch (InvalidTopologyException e) {
        e.printStackTrace();
    }

    LOG.info("component page show cost:{}ms", System.currentTimeMillis() - start);
    return "component";
}

From source file:com.naryx.tagfusion.expression.function.string.encodeForHtmlAttribute.java

public cfData execute(cfSession _session, cfArgStructData argStruct) throws cfmRunTimeException {
    String htmlAtt = StringEscapeUtils.escapeHtml(getNamedStringParam(argStruct, "string", ""));
    htmlAtt = StringUtil.tokenReplace(htmlAtt, new String[] { "'" }, new String[] { "&#39;" });
    return new cfStringData(htmlAtt);
}

From source file:info.magnolia.jcr.wrapper.HTMLEscapingContentDecorator.java

public String decorate(String raw) {
    final String str = StringEscapeUtils.escapeHtml(raw);
    if (transformLineBreaks) {
        return StringUtils.replace(str, "\n", "<br/>");
    }//from   w w w.  ja  v  a 2s.com
    return str;

}

From source file:com.redhat.rhn.frontend.action.rhnpackage.PackageDependenciesAction.java

private List<String> createDependenciesStrings(DataResult dr) {

    if (dr == null || dr.isEmpty()) {
        return null;
    }//  w w  w  . ja  v  a  2s .c  o m

    List<String> lines = new ArrayList<String>();

    // Loop through all items in data result
    for (Iterator resultItr = dr.iterator(); resultItr.hasNext();) {
        Map item = (Map) resultItr.next();

        String name = (String) item.get("name");
        String version = (String) item.get("version");
        Long sense = (Long) item.get("sense");

        String line = name;
        if (version != null) {
            line += " ";
            line += PackageManager.getDependencyModifier(sense, version);
        }

        lines.add(StringEscapeUtils.escapeHtml(line));
    }

    return lines;
}

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

private final static Sample translate(final SamplePE samplePE, String baseIndexURL, final int containerDep,
        final int generatedFromDep, final boolean withDetails) {
    final Sample result = new Sample();
    setCodes(result, samplePE);/* w w  w .jav a2s. c o m*/
    result.setPermId(StringEscapeUtils.escapeHtml(samplePE.getPermId()));
    result.setPermlink(
            PermlinkUtilities.createPermlinkURL(baseIndexURL, EntityKind.SAMPLE, samplePE.getPermId()));
    result.setModificationDate(samplePE.getModificationDate());
    // NOTE: we should always translate Id in this way
    // because getId() on HibernateProxy object always returns null
    result.setId(HibernateUtils.getId(samplePE));
    result.setIdentifier(StringEscapeUtils.escapeHtml(samplePE.getIdentifier()));
    result.setSampleType(SampleTypeTranslator.translate(samplePE.getSampleType(),
            new HashMap<PropertyTypePE, PropertyType>()));
    if (withDetails) {
        result.setGroup(GroupTranslator.translate(samplePE.getGroup()));
        result.setDatabaseInstance(DatabaseInstanceTranslator.translate(samplePE.getDatabaseInstance()));
        result.setRegistrator(PersonTranslator.translate(samplePE.getRegistrator()));
        result.setRegistrationDate(samplePE.getRegistrationDate());
        setProperties(result, samplePE);
        result.setExperiment(ExperimentTranslator.translate(samplePE.getExperiment(), baseIndexURL,
                LoadableFields.PROPERTIES));
        List<Attachment> attachments;
        if (samplePE.attachmentsInitialized() == false) {
            attachments = DtoConverters.createUnmodifiableEmptyList();
        } else {
            attachments = AttachmentTranslator.translate(samplePE.getAttachments());
        }
        result.setAttachments(attachments);
    }
    if (containerDep > 0 && samplePE.getContainer() != null) {
        if (HibernateUtils.isInitialized(samplePE.getContainer())) {
            result.setContainer(SampleTranslator.translate(samplePE.getContainer(), baseIndexURL,
                    containerDep - 1, 0, false));
        }
    }
    if (generatedFromDep > 0 && samplePE.getGeneratedFrom() != null) {
        if (HibernateUtils.isInitialized(samplePE.getGeneratedFrom())) {
            result.setGeneratedFrom(SampleTranslator.translate(samplePE.getGeneratedFrom(), baseIndexURL, 0,
                    generatedFromDep - 1, false));
        }
    }
    result.setInvalidation(InvalidationTranslator.translate(samplePE.getInvalidation()));
    return result;
}

From source file:eionet.cr.web.util.columns.HarvestSourcesColumn.java

@Override
public String format(Object object) {
    if (object instanceof HarvestSourceDTO) {
        if (dateFormat) {
            Date date = ((HarvestSourceDTO) object).getLastHarvest();
            return date != null ? SIMPLE_DATE_FORMAT.format(date) : "";
        } else {/*from ww  w. j av  a 2s  .  co m*/
            String factsheetUrlBinding = HarvestSourceActionBean.class.getAnnotation(UrlBinding.class).value();
            int i = factsheetUrlBinding.lastIndexOf("/");
            String hrefName = ((HarvestSourceDTO) object).getUrl();

            StringBuffer href = new StringBuffer(
                    i >= 0 ? factsheetUrlBinding.substring(i + 1) : factsheetUrlBinding)
                            .append("?view=&amp;harvestSource.url=").append(Util.urlEncode(hrefName));

            return new StringBuffer("<a href=\"").append(href).append("\">")
                    .append(StringEscapeUtils.escapeHtml(hrefName)).append("</a>").toString();
        }
    }
    return "";
}