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:edu.cornell.mannlib.vitro.webapp.web.jsptags.OptionsForPropertyTag.java

public int doStartTag() {
    try {//from   w  ww.j  a  v a2  s  . co m
        VitroRequest vreq = new VitroRequest((HttpServletRequest) pageContext.getRequest());
        WebappDaoFactory wdf = vreq.getWebappDaoFactory();
        if (wdf == null)
            throw new Exception("could not get WebappDaoFactory from request.");

        Individual subject = wdf.getIndividualDao().getIndividualByURI(getSubjectUri());
        if (subject == null)
            throw new Exception("could not get individual for subject uri " + getSubjectUri());

        ObjectProperty objProp = wdf.getObjectPropertyDao().getObjectPropertyByURI(getPredicateUri());
        if (objProp == null)
            throw new Exception("could not get object property for predicate " + getPredicateUri());

        List<VClass> vclasses = new ArrayList<VClass>();
        vclasses = wdf.getVClassDao().getVClassesForProperty(getPredicateUri(), true);

        HashMap<String, Individual> indMap = new HashMap<String, Individual>();
        for (VClass vclass : vclasses) {
            for (Individual ind : wdf.getIndividualDao().getIndividualsByVClassURI(vclass.getURI(), -1, -1))
                if (!indMap.containsKey(ind.getURI()))
                    indMap.put(ind.getURI(), ind);
        }

        List<Individual> individuals = new ArrayList(indMap.values());

        List<ObjectPropertyStatement> stmts = subject.getObjectPropertyStatements();
        if (stmts == null)
            throw new Exception("object properties for subject were null");

        individuals = removeIndividualsAlreadyInRange(individuals, stmts);
        Collections.sort(individuals, new compareEnts());

        JspWriter out = pageContext.getOut();

        int optionsCount = 0;
        for (Individual ind : individuals) {
            String uri = ind.getURI();
            if (uri != null) {
                out.print("<option value=\"" + StringEscapeUtils.escapeHtml(uri) + '"');
                if (uri.equals(getSelectedUri()))
                    out.print(" selected=\"selected\"");
                out.print('>');
                out.print(StringEscapeUtils.escapeHtml(ind.getName()));
                out.println("</option>");
                ++optionsCount;
            }

        }
        log.trace("added " + optionsCount + " options for object property \"" + getPredicateUri()
                + "\" in OptionsForPropertyTag.doStartTag()");
    } catch (Exception ex) {
        throw new Error("Error in doStartTag: " + ex.getMessage());
    }
    return SKIP_BODY;
}

From source file:de.skuzzle.polly.http.internal.HttpEventImpl.java

@Override
public String postEscaped(String key) {
    return StringEscapeUtils.escapeHtml(this.post.get(key));
}

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

public <STATE> String resolveSearchPageTitle(final String searchText,
        final List<BreadcrumbData<STATE>> appliedFacets) {
    final CMSSiteModel currentSite = getCmsSiteService().getCurrentSite();

    final StringBuilder builder = new StringBuilder();
    if (!StringUtils.isEmpty(searchText)) {
        builder.append(searchText).append(TITLE_WORD_SEPARATOR);
    }/* www. j  av a2  s  .  c o m*/
    for (final BreadcrumbData pathElement : appliedFacets) {
        builder.append(pathElement.getFacetValueName()).append(TITLE_WORD_SEPARATOR);
    }
    builder.append(currentSite.getName());
    return StringEscapeUtils.escapeHtml(builder.toString());
}

From source file:com.htmlhifive.tools.codeassist.core.proposal.wrapper.ProposalWrapperFactory.java

/**
 * ?StringBuilder??.//  www .j  av a2s  . c o m
 * 
 * @param sb ?StringBuilder
 * @param returnType 
 * @param description ?
 */
private static void addReturnType(StringBuilder sb, String returnType, String description) {

    sb.append("<dt>");
    sb.append(Messages.DES0002.getText());
    sb.append("</dt><dd>{");
    sb.append(returnType);
    sb.append("} ");
    String returnDescription = StringEscapeUtils.escapeHtml(description);
    sb.append(returnDescription == null ? "" : returnDescription);
    sb.append("</dd>");
}

From source file:io.github.tavernaextras.biocatalogue.ui.search_results.SOAPOperationListCellRenderer.java

/**
 * This entry can be in one of two states:
 * -- containing only the name of the resource and NOT loading further details;
 * -- containing only the name of the resource and LOADING further details.
 * /*from   ww  w  . ja va2s .  c  om*/
 * @param itemToRender
 * @return
 */
protected GridBagConstraints prepareInitiallyLoadingEntry(Object itemToRender) {
    LoadingResource resource = (LoadingResource) itemToRender;

    jlTypeIcon.setIcon(resourceType.getIcon());
    jlItemStatus.setIcon(ResourceManager.getImageIcon(ResourceManager.SERVICE_STATUS_UNCHECKED_ICON_LARGE));

    jlItemTitle.setText("<html>" + StringEscapeUtils.escapeHtml(Resource.getDisplayNameForResource(resource))
            + "<font color=\"gray\"><i>- fetching more information</i></font></html>");

    jlPartOf.setText(" ");
    jlWsdlLocation.setText(" ");
    jtDescription.setText("");
    jlSoapInputs.setText(" ");
    jlSoapOutputs.setText(" ");

    return (arrangeLayout());
}

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

public String getMessageHtml() {
    return StringEscapeUtils.escapeHtml(message);
}

From source file:com.redhat.rhn.manager.kickstart.KickstartUrlHelper.java

/**
 * The definitive method for getting the URL to a given
 * Kickstart profile on the Spacewalk server.  If your Kickstart
 * profile is named 'rhel5-Server-i386' the url would be:
 *
 * http://spacewalk.example.com/kickstart/ks/org/1/label/rhel5-Server-i386
 *
 * @return String url to kickstart file//w ww .jav a  2s .  c o m
 */
public String getKickstartFileUrl() {

    StringBuilder urlBuf = new StringBuilder();
    urlBuf.append("/label/");
    urlBuf.append(StringEscapeUtils.escapeHtml(ksData.getLabel()));

    return getKickstartFileUrlBase() + urlBuf.toString();
}

From source file:de.unisb.cs.st.javalanche.mutation.analyze.html.ClassReport.java

private String getSourceHtml() {
    StringBuilder sb = new StringBuilder();
    sb.append("<pre class=\"prettyprint\" style=\"border: 1px solid #888;padding: 2px\">");
    int linecount = 1;
    for (String line : content) {
        sb.append(/*  ww w  .  ja va 2s  .  co m*/
                String.format("<span class=\"nocode\"><a name=\"%d\">%3d: </a></span>", linecount, linecount));
        linecount++;
        sb.append(StringEscapeUtils.escapeHtml(line));
        sb.append("\n");
    }
    sb.append("</pre>");
    return sb.toString();
}

From source file:de.arago.rike.zombie.ZombieHelper.java

static String toPrettyJSON(List ticks) {
    List<OverdueMilestone> milestones = getOverdueMilestones(true);
    Collections.sort(milestones, new DoneSorter());
    final List data = new ArrayList();
    final Map open = new HashMap();
    final Map in_progress = new HashMap();
    final Map done = new HashMap();

    data.add(open);/*from w w  w .  j  ava2  s  .  co  m*/
    data.add(in_progress);
    data.add(done);

    open.put("Label", "open");
    open.put("color", "red");
    in_progress.put("Label", "in_progress");
    in_progress.put("color", "yellow");
    done.put("Label", "done");
    done.put("color", "green");

    List openData = new ArrayList();
    List in_progressData = new ArrayList();
    List doneData = new ArrayList();

    open.put("data", openData);
    in_progress.put("data", in_progressData);
    done.put("data", doneData);
    long now = new Date().getTime();

    int i = 1;

    for (OverdueMilestone o : milestones) {
        Milestone stone = o.getMilestone();

        ticks.add("<a href='/web/guest/rike/-/show/milestone/" + stone.getId() + "'>"
                + StringEscapeUtils.escapeHtml(stone.getTitle()) + "</a>");

        GregorianCalendar c = new GregorianCalendar();
        c.setTime(stone.getDueDate());
        c.add(Calendar.HOUR_OF_DAY,
                -((o.getWorkLeftInHours() - o.getWorkInProgressInHours()) * 7 * 24) / stone.getPerformance());
        long time1 = c.getTimeInMillis();
        c.add(Calendar.HOUR_OF_DAY, -(o.getWorkInProgressInHours() * 7 * 24) / stone.getPerformance());
        long time2 = c.getTimeInMillis();
        c.add(Calendar.HOUR_OF_DAY, -(o.getWorkDoneInHours() * 7 * 24) / stone.getPerformance());
        long time3 = c.getTimeInMillis();

        List item = new ArrayList();
        item.add(time1);
        item.add(i);
        item.add(stone.getDueDate().getTime());
        item.add("");
        openData.add(item);

        item = new ArrayList();
        item.add(time2);
        item.add(i);
        item.add(time1);
        item.add("");
        in_progressData.add(item);

        item = new ArrayList();
        item.add(time3);
        item.add(i);
        item.add(time2);
        item.add("");
        doneData.add(item);

        ++i;
    }

    return JSONArray.toJSONString(data);
}

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

private void renderNode(StringBuffer sb, NavNode node, NavTreeIndex treeIndex, Map parameters,
        String cssClass) {/*  ww w  .j  a v  a  2s .c om*/
    HtmlTag li = new HtmlTag("li");

    if (!cssClass.equals("")) {
        li.setAttribute("class", cssClass);
    }

    String href = node.getPrimaryURL();
    String allowedFormVars = treeIndex.getTree().getFormvar();
    if (allowedFormVars != null) {
        StringBuilder formVars;
        if (href.indexOf('?') == -1) {
            formVars = new StringBuilder("?");
        } else {
            formVars = new StringBuilder("&");
        }

        StringTokenizer st = new StringTokenizer(allowedFormVars);
        while (st.hasMoreTokens()) {
            if (formVars.length() > 1) {
                formVars.append("&amp;");
            }
            String currentVar = st.nextToken();
            String[] values = (String[]) parameters.get(currentVar);

            // if currentVar is null, values will be null too, so we can
            // just check values.
            if (values != null) {
                formVars.append(currentVar + "=" + StringEscapeUtils.escapeHtml(values[0]));
            }
        }
        href += formVars.toString();
    }

    li.addBody(aHref(href, node.getName(), node.getTarget()));
    sb.append(li.render());
    sb.append("\n");
}