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:it.eng.spagobi.commons.presentation.tags.ListBIParametersTag.java

/**
 * Starting from the module <code>buttonsSB</code> object, 
 * creates all buttons for the jsp list. 
 * /*w  w w .  j a  v a 2 s  .  c  om*/
 * @throws JspException If any exception occurs.
 */

protected StringBuffer makeButton() throws JspException {

    StringBuffer htmlStream = new StringBuffer();
    SourceBean buttonsSB = (SourceBean) _layout.getAttribute("BUTTONS");
    List buttons = buttonsSB.getContainedSourceBeanAttributes();
    Iterator iter = buttons.listIterator();
    while (iter.hasNext()) {
        SourceBeanAttribute buttonSBA = (SourceBeanAttribute) iter.next();
        SourceBean buttonSB = (SourceBean) buttonSBA.getValue();
        List parameters = buttonSB.getAttributeAsList("PARAMETER");
        HashMap paramsMap = getParametersMap(parameters, null);
        String img = (String) buttonSB.getAttribute("image");
        String labelCode = (String) buttonSB.getAttribute("label");
        String label = msgBuilder.getMessage(labelCode, "messages", httpRequest);
        label = StringEscapeUtils.escapeHtml(label);
        htmlStream.append("<form action='" + urlBuilder.getUrl(httpRequest, new HashMap()) + "' id='form"
                + label + "'  method='POST' >\n");
        htmlStream.append("   <td class=\"header-button-column-portlet-section\">\n");
        Set paramsKeys = paramsMap.keySet();
        Iterator iterpar = paramsKeys.iterator();
        while (iterpar.hasNext()) {
            String paramKey = (String) iterpar.next();
            String paramValue = (String) paramsMap.get(paramKey);
            while (paramValue.indexOf("%20") != -1) {
                paramValue = paramValue.replaceAll("%20", " ");
            }
            htmlStream.append(
                    "     <input type='hidden' name='" + paramKey + "' value='" + paramValue + "' /> \n");
        }
        htmlStream.append("      <a href='javascript:document.getElementById(\"form" + label
                + "\").submit()'><img class=\"header-button-image-portlet-section\" title='" + label + "' alt='"
                + label + "' src='" + urlBuilder.getResourceLinkByTheme(httpRequest, img, currTheme)
                + "' /></a>\n");
        htmlStream.append("   </td>\n");
        htmlStream.append("</form>\n");
    }
    return htmlStream;
}

From source file:edu.jdomengine.core.attr.JDomPromptAttribute.java

@Override
public String getValue() {
    return StringEscapeUtils.escapeHtml(this.value);
}

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

public String getExtraURLParameters() {
    String extraURLParameters = (String) treeParams.get(EXTRA_URL_PARAMS);
    if (extraURLParameters == null || getTreeType().equals(DE_SEARCH_TREE)) {
        extraURLParameters = "&PageId=DataElementsGroup&NOT_FIRST_DISPLAY=1&performQuery=yes";
    }//from   w w  w  .  j  ava 2 s. co m

    if (getTreeType().equals(DE_SEARCH_TREE)) {
        String src = (String) treeParams.get("src");
        if (src != null) {
            String modIndex = (String) treeParams.get("moduleIndex");
            String quesIndex = (String) treeParams.get("questionIndex");
            extraURLParameters += "&src=" + src + "&moduleIndex=" + modIndex + "&questionIndex=" + quesIndex;
        }
    }

    // Add bread crumbs info
    if (extraURLParameters == null)
        extraURLParameters = TREE_BREADCRUMBS + "=" + TREE_BREADCRUMBS_HOLDER;
    else
        extraURLParameters = extraURLParameters + "&" + TREE_BREADCRUMBS + "=" + TREE_BREADCRUMBS_HOLDER;

    return StringEscapeUtils.escapeHtml(extraURLParameters);
}

From source file:ac.elements.parser.ExtendedFunctions.java

/**
 * The main method.//w  w  w  .ja  va2 s . c  o  m
 * 
 * @param args
 *            the arguments
 */
public static void main(String[] args) {

    java.math.BigInteger myInt = new java.math.BigInteger("1223");
    System.out.println(myInt);
    System.out.println(ExtendedFunctions.timePeriod(myInt));
    myInt = new java.math.BigInteger("59000");
    System.out.println(myInt);
    System.out.println(ExtendedFunctions.timePeriod(myInt));
    myInt = new java.math.BigInteger("59900");
    System.out.println(myInt);
    System.out.println(ExtendedFunctions.timePeriod(myInt));
    myInt = new java.math.BigInteger("5990000");
    System.out.println(myInt);
    System.out.println(ExtendedFunctions.timePeriod(myInt));
    myInt = new java.math.BigInteger("599000000");
    System.out.println(myInt);
    System.out.println(ExtendedFunctions.timePeriod(myInt));
    myInt = new java.math.BigInteger("59900000000");
    System.out.println(myInt);
    System.out.println(ExtendedFunctions.timePeriod(myInt));

    String sql = "select * from domain where `this`='test' and this2=\"test\"";

    System.out.println(ExtendedFunctions.escapeSql(sql));

    String unformattedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><QueryMessage\n"
            + "        xmlns=\"http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message\"\n"
            + "        xmlns:query=\"http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query\">\n"
            + "    <Query>\n" + "        <query:CategorySchemeWhere>\n"
            + "   \t\t\t\t\t         <query:AgencyID>ECB\n\n\n\n</query:AgencyID>\n"
            + "        </query:CategorySchemeWhere>\n" + "    </Query>\n\n\n\n\n" + "</QueryMessage>";

    System.out.println(ExtendedFunctions.formatXml(unformattedXml));

    String company = "international business MACHINES. iag is here.";
    System.out.println(ExtendedFunctions.capitalize(company));

    String url = "\u1087\u1088\u1077\u1076\u1089";

    System.out.println(url);
    System.out.println(ExtendedFunctions.escUniJs(url));
    System.out.println(ExtendedFunctions.toUnicodeHTML(url));
    ExtendedFunctions.trim(url);
    url = "http://news.google.com/news?hl=en&client=safari&rls=en-us&q=get%20part%20of%20paragraph%20words%20google%20algorithm&um=1&ie=UTF-8&sa=N&tab=wn";
    System.out.println(ExtendedFunctions.chopUrl(url, 30));
    url = "http://www.pcplus.co.uk/node/3061/";
    System.out.println(ExtendedFunctions.chopUrl(url, 30));
    url = "http://www.opent.net/forum/security-problem-with-ot-script-on-ssl-t159.html";
    System.out.println(ExtendedFunctions.chopUrl(url, 30));
    System.out.println(ExtendedFunctions.escapeJavaScript("escapeJavas'\"cript"));
    System.err.println(StringUtils.abbreviate("Take time off working", 0, 10));
    System.err.println(StringUtils.capitalize("how is vandersar doing?"));
    String unescapedJava = "Are you \" for real?";
    System.err.println(StringEscapeUtils.escapeJava(unescapedJava));

    String unescapedJavaScript = "What's in a name?";
    System.err.println(ExtendedFunctions.escapeJavaScript(unescapedJavaScript));

    String unescapedSql = "Mc'Williams";
    System.err.println(StringEscapeUtils.escapeSql(unescapedSql));

    String unescapedXML = "<data>";
    System.err.println(StringEscapeUtils.escapeXml(unescapedXML));

    String unescapedHTML = "the data is <data>";
    System.err.println(StringEscapeUtils.escapeHtml(unescapedHTML));
    System.err.println(WordUtils.capitalize(unescapedHTML));
    System.err.println(WordUtils.swapCase(unescapedHTML));
}

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

public int doEndTag() throws JspException {
    try {/*from w  w w .ja v  a  2s.c o m*/
        JspWriter out = pageContext.getOut();

        List optList = null;
        ListOrderedMap optGroups = null;

        try {
            optList = (List) getFormObject().getOptionLists().get(name);
            outputOptionsMarkup(optList, out);
        } catch (ClassCastException e) {
            // maybe it's a ListOrderedMap of optgroups
            optGroups = (ListOrderedMap) getFormObject().getOptionLists().get(name);
            OrderedMapIterator ogKey = optGroups.orderedMapIterator();
            while (ogKey.hasNext()) {
                String optGroupName = (String) ogKey.next();
                out.println("<optgroup label=\"" + StringEscapeUtils.escapeHtml(optGroupName) + "\">");
                outputOptionsMarkup((List) optGroups.get(optGroupName), out);
                out.println("</optgroup>");
            }
        } catch (NullPointerException npe) {
            System.out.println("OptionTag could not find option list for " + name);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new JspException(ex.getMessage());
    }
    return SKIP_BODY; // EVAL_PAGE; did colnames only //EVAL_PAGE in connection pooled version;
}

From source file:com.fluidops.iwb.widget.WidgetEmbeddingError.java

public static String getNoDataMessage(String configValue) {
    if (configValue == null) {
        return WidgetQueryConfig.DEFAULT_NO_DATA_MESSAGE;
    } else if (configValue.length() == 0) {
        return "&nbsp;";
    } else {//from w ww  .j  a va  2 s . co m
        return StringEscapeUtils.escapeHtml(configValue);
    }
}

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

@RequestMapping(value = "/topology", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String cluster,
        @RequestParam(value = "id") String id, @RequestParam(value = "win", required = false) String win,
        ModelMap model) {/*  w w w  .j a  v a2s  .c  o m*/
    cluster = StringEscapeUtils.escapeHtml(cluster);
    id = StringEscapeUtils.escapeHtml(id);
    long start = System.currentTimeMillis();
    LOG.info("request topology info for cluster name: " + cluster + " id:" + id);
    int window = UIUtils.parseWindow(win);
    UIUtils.addWindowAttribute(model, window);
    NimbusClient client = null;
    try {
        client = NimbusClientManager.getNimbusClient(cluster);
        TopologyInfo topologyInfo = client.getClient().getTopologyInfo(id);
        //            System.out.println("topologyinfo worker metric:" + topologyInfo.get_metrics().get_workerMetric());
        model.addAttribute("topology", JStormUtils.thriftToMap(topologyInfo.get_topology()));
        //            model.addAttribute("tasks", getTaskEntities(topologyInfo));       //remove tasks stat
        model.addAttribute("supervisorPort", UIUtils.getSupervisorPort(cluster));

        MetricInfo topologyMetrics = topologyInfo.get_metrics().get_topologyMetric();
        //            List<MetricInfo> topologyMetrics = client.getClient().getMetrics(id, MetaType.TOPOLOGY.getT());
        //            System.out.println("topologyMetrics:" + topologyMetrics);
        UISummaryMetric topologyData = UIMetricUtils.getSummaryMetrics(topologyMetrics, window);
        model.addAttribute("topologyData", topologyData);
        model.addAttribute("topologyHead", UIMetricUtils.sortHead(topologyData, UISummaryMetric.HEAD));

        MetricInfo componentMetrics = topologyInfo.get_metrics().get_componentMetric();
        //            List<MetricInfo> componentMetrics = client.getClient().getMetrics(id, MetaType.COMPONENT.getT());
        //            System.out.println("componentMetrics:" + componentMetrics);
        List<UIUserDefinedMetric> userDefinedMetrics = Lists.newArrayList();
        List<UIComponentMetric> componentData = UIMetricUtils.getComponentMetrics(componentMetrics, window,
                topologyInfo.get_components(), userDefinedMetrics);
        model.addAttribute("componentData", componentData);
        model.addAttribute("componentHead", UIMetricUtils.sortHead(componentData, UIComponentMetric.HEAD));
        model.addAttribute("userDefinedMetrics", userDefinedMetrics);
        //            System.out.println("componentHead:" + BasicMetric.sortHead(componentData));

        MetricInfo workerMetrics = topologyInfo.get_metrics().get_workerMetric();
        //            List<MetricInfo> workerMetrics = client.getClient().getMetrics(id, MetaType.WORKER.getT());
        //            System.out.println("workerMetrics:" + workerMetrics);
        List<UIWorkerMetric> workerData = UIMetricUtils.getWorkerMetrics(workerMetrics, id, window);
        model.addAttribute("workerData", workerData);
        model.addAttribute("workerHead", UIMetricUtils.sortHead(workerData, UIWorkerMetric.HEAD));

        List<TaskEntity> taskData = UIUtils.getTaskEntities(topologyInfo);
        model.addAttribute("taskData", taskData);

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

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

From source file:com.hp.alm.ali.idea.model.type.PlainTextType.java

@Override
public String translate(String value, ValueCallback callback) {
    try {//w w  w  .  j a  v a  2s .  c o  m
        final StringBuffer buf = new StringBuffer();
        new ParserDelegator().parse(new StringReader(value), new HTMLEditorKit.ParserCallback() {
            @Override
            public void handleText(char[] data, int pos) {
                if (buf.length() > 0 && !StringUtils.isWhitespace(buf.substring(buf.length() - 1))) {
                    buf.append(" ");
                }
                buf.append(data);
            }
        }, false);
        return buf.toString();
    } catch (IOException e) {
        return StringEscapeUtils.escapeHtml(value);
    }
}

From source file:edu.jdomengine.core.node.JDomText.java

@Override
public StringBuilder toHtml5(StringBuilder str) {
    return str.append(StringEscapeUtils.escapeHtml(getText()));
}

From source file:com.sap.dirigible.ide.bridge.ext.XSSRequestWrapper.java

private String stripXSS(String value) {
    if (value != null) {
        value = StringEscapeUtils.escapeHtml(value);
        value = StringEscapeUtils.escapeJavaScript(value);
        value = value.replaceAll("", ""); //$NON-NLS-1$ //$NON-NLS-2$
        value = Jsoup.clean(value, Whitelist.none());
    }//from   w w  w  .j  a  v a2s  . co m
    return value;
}