List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml
public static String escapeHtml(String input)
From source file:hudson.plugins.ansicolor.AnsiColorNote.java
/** * Annotate output that contains ANSI codes and hide raw text. *//*from w w w . j a va2 s. c o m*/ @Override public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) { try { String colorizedData = colorize(StringEscapeUtils.escapeHtml(this.data), this.getColorMap()); if (!colorizedData.contentEquals(this.data)) { text.addMarkup(charPos, colorizedData); text.addMarkup(charPos, charPos + text.getText().length(), "<span style=\"display: none;\">", "</span>"); } } catch (Exception e) { LOG.log(Level.WARNING, "Failed to add markup to \"" + text + "\"", e); } return null; }
From source file:com.raptor.entities.task.TaskSenderBlogWordpress.java
/** * Execute the task and send the content to a blog site as a Post * @param filled a list of Article/*from w w w . j a va 2 s.co m*/ * @return true or false if it was executed */ @Override @SuppressWarnings("unchecked") public Object execute(Object filled) throws Exception { List<Article> articles = (List<Article>) filled; Log.getInstance().debug("Connect to wordpress blog " + this.blogLink, null); Boolean result = true; List<String> emails = new ArrayList<String>(); emails.add(this.blogEmail); for (Article article : articles) { String content = article.getContent(); //check if we have to add the source if (this.getAddSource()) content += " Source : " + this.findSource(); Wordpress wp = new Wordpress(this.blogLogin, this.blogPass, this.blogLink + "/xmlrpc.php"); Page post = new Page(); post.setDescription(StringEscapeUtils.escapeHtml(content)); post.setTitle(StringEscapeUtils.escapeHtml(article.getTitle())); wp.newPost(post, false); } if (result) Log.getInstance().info("All the articles was sent to wordpress"); return result; }
From source file:com.alibaba.jstorm.ui.controller.SupervisorController.java
@RequestMapping(value = "/supervisor", method = RequestMethod.GET) public String show(@RequestParam(value = "cluster", required = true) String clusterName, @RequestParam(value = "host", required = true) String host, @RequestParam(value = "win", required = false) String win, ModelMap model) { clusterName = StringEscapeUtils.escapeHtml(clusterName); long start = System.currentTimeMillis(); host = NetWorkUtils.host2Ip(host);//from w ww . j av a2 s .co m int window = UIUtils.parseWindow(win); UIUtils.addWindowAttribute(model, window); NimbusClient client = null; try { client = NimbusClientManager.getNimbusClient(clusterName); //get supervisor summary SupervisorWorkers supervisorWorkers = client.getClient().getSupervisorWorkers(host); model.addAttribute("supervisor", new SupervisorEntity(supervisorWorkers.get_supervisor())); //get worker summary List<WorkerSummary> workerSummaries = supervisorWorkers.get_workers(); model.addAttribute("workerSummary", UIUtils.getWorkerEntities(workerSummaries)); //get worker metrics Map<String, MetricInfo> workerMetricInfo = supervisorWorkers.get_workerMetric(); List<UIWorkerMetric> workerMetrics = UIMetricUtils.getWorkerMetrics(workerMetricInfo, workerSummaries, host, window); // System.out.println("workerMetricInfo:"+workerMetricInfo); model.addAttribute("workerMetrics", workerMetrics); model.addAttribute("workerHead", UIMetricUtils.sortHead(workerMetrics, UIWorkerMetric.HEAD)); } catch (Exception e) { NimbusClientManager.removeClient(clusterName); LOG.error(e.getMessage(), e); UIUtils.addErrorAttribute(model, e); } // page information model.addAttribute("clusterName", clusterName); model.addAttribute("host", host); model.addAttribute("page", "supervisor"); model.addAttribute("supervisorPort", UIUtils.getSupervisorPort(clusterName)); UIUtils.addTitleAttribute(model, "Supervisor Summary"); LOG.info("supervisor page show cost:{}ms", System.currentTimeMillis() - start); return "supervisor"; }
From source file:com.alibaba.jstorm.ui.controller.TaskController.java
@RequestMapping(value = "/task", 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 = "id", required = true) String task_id, @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;//from w w w. j a v a 2s .c o m try { client = NimbusClientManager.getNimbusClient(clusterName); //get task entity TopologyInfo topologyInfo = client.getClient().getTopologyInfo(topology_id); int id = JStormUtils.parseInt(task_id); TaskEntity task = UIUtils.getTaskEntity(topologyInfo.get_tasks(), id); task.setComponent(component); model.addAttribute("task", task); //get task metric List<MetricInfo> taskStreamMetrics = client.getClient().getTaskAndStreamMetrics(topology_id, id); // System.out.println("taskMetrics size:"+getSize(taskMetrics)); UITaskMetric taskMetric = UIMetricUtils.getTaskMetric(taskStreamMetrics, component, id, window); model.addAttribute("taskMetric", taskMetric); model.addAttribute("taskHead", UIMetricUtils.sortHead(taskMetric, UITaskMetric.HEAD)); //get stream metric List<UIStreamMetric> streamData = UIMetricUtils.getStreamMetrics(taskStreamMetrics, component, id, window); model.addAttribute("streamData", streamData); model.addAttribute("streamHead", UIMetricUtils.sortHead(streamData, UIStreamMetric.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); } model.addAttribute("clusterName", clusterName); model.addAttribute("topologyId", topology_id); model.addAttribute("compName", component); model.addAttribute("page", "task"); UIUtils.addTitleAttribute(model, "Task Summary"); LOG.info("task page show cost:{}ms", System.currentTimeMillis() - start); return "task"; }
From source file:com.fluidops.iwb.api.valueresolver.ValueResolverUtil.java
/** * Default handling for URIs and Literals. * /*from w w w .j av a2 s . c o m*/ * @param value * The value itself (URI/Literal) * @param def * The default text in case the value cannot be resolved * @return Returns a String (= Literal) or a link (= URI) */ public static String resolveDefault(Value value, String def) { if (value == null || value.stringValue().isEmpty()) return def; // default value if (value instanceof Literal) return StringEscapeUtils.escapeHtml(value.stringValue()); else return EndpointImpl.api().getRequestMapper().getAHrefFromValue(value); }
From source file:at.gv.egovernment.moa.id.auth.parser.StartAuthentificationParameterParser.java
public static void parse(AuthenticationSession moasession, String target, String oaURL, String bkuURL, String templateURL, String useMandate, String ccc, String module, String action, HttpServletRequest req) throws WrongParametersException, MOAIDException { String targetFriendlyName = null; // String sso = req.getParameter(PARAM_SSO); // escape parameter strings target = StringEscapeUtils.escapeHtml(target); //oaURL = StringEscapeUtils.escapeHtml(oaURL); bkuURL = StringEscapeUtils.escapeHtml(bkuURL); templateURL = StringEscapeUtils.escapeHtml(templateURL); useMandate = StringEscapeUtils.escapeHtml(useMandate); ccc = StringEscapeUtils.escapeHtml(ccc); // sso = StringEscapeUtils.escapeHtml(sso); // check parameter //pvp2.x can use general identifier (equals oaURL in SAML1) // if (!ParamValidatorUtils.isValidOA(oaURL)) // throw new WrongParametersException("StartAuthentication", PARAM_OA, "auth.12"); if (!ParamValidatorUtils.isValidUseMandate(useMandate)) throw new WrongParametersException("StartAuthentication", PARAM_USEMANDATE, "auth.12"); if (!ParamValidatorUtils.isValidCCC(ccc)) throw new WrongParametersException("StartAuthentication", PARAM_CCC, "auth.12"); // if (!ParamValidatorUtils.isValidUseMandate(sso)) // throw new WrongParametersException("StartAuthentication", PARAM_SSO, "auth.12"); //check UseMandate flag String useMandateString = null; boolean useMandateBoolean = false; if ((useMandate != null) && (useMandate.compareTo("") != 0)) { useMandateString = useMandate;/*from w w w.ja v a2s .c om*/ } else { useMandateString = "false"; } if (useMandateString.compareToIgnoreCase("true") == 0) useMandateBoolean = true; else useMandateBoolean = false; moasession.setUseMandate(useMandateString); //load OnlineApplication configuration OAAuthParameter oaParam; if (moasession.getPublicOAURLPrefix() != null) { Logger.debug("Loading OA parameters for PublicURLPrefix: " + moasession.getPublicOAURLPrefix()); oaParam = AuthConfigurationProvider.getInstance() .getOnlineApplicationParameter(moasession.getPublicOAURLPrefix()); if (oaParam == null) throw new AuthenticationException("auth.00", new Object[] { moasession.getPublicOAURLPrefix() }); } else { oaParam = AuthConfigurationProvider.getInstance().getOnlineApplicationParameter(oaURL); if (oaParam == null) throw new AuthenticationException("auth.00", new Object[] { oaURL }); // get target and target friendly name from config String targetConfig = oaParam.getTarget(); String targetFriendlyNameConfig = oaParam.getTargetFriendlyName(); if (StringUtils.isEmpty(targetConfig) || (module.equals(SAML1Protocol.PATH) && !StringUtils.isEmpty(target))) { //INFO: ONLY SAML1 legacy mode // if SAML1 is used and target attribute is given in request // use requested target // check target parameter if (!ParamValidatorUtils.isValidTarget(target)) { Logger.error("Selected target is invalid. Using target: " + target); throw new WrongParametersException("StartAuthentication", PARAM_TARGET, "auth.12"); } } else { // use target from config target = targetConfig; targetFriendlyName = targetFriendlyNameConfig; } // //check useSSO flag // String useSSOString = null; // boolean useSSOBoolean = false; // if ((sso != null) && (sso.compareTo("") != 0)) { // useSSOString = sso; // } else { // useSSOString = "false"; // } // // if (useSSOString.compareToIgnoreCase("true") == 0) // useSSOBoolean = true; // else // useSSOBoolean = false; //moasession.setSsoRequested(useSSOBoolean); moasession.setSsoRequested(true && oaParam.useSSO()); //make always SSO if OA requested it!!!! //Validate BKU URI List<String> allowedbkus = oaParam.getBKUURL(); allowedbkus.addAll(AuthConfigurationProvider.getInstance().getDefaultBKUURLs()); if (!ParamValidatorUtils.isValidBKUURI(bkuURL, allowedbkus)) throw new WrongParametersException("StartAuthentication", PARAM_BKU, "auth.12"); moasession.setBkuURL(bkuURL); if ((!oaParam.getBusinessService())) { if (isEmpty(target)) throw new WrongParametersException("StartAuthentication", PARAM_TARGET, "auth.05"); } else { if (useMandateBoolean) { Logger.error("Online-Mandate Mode for business application not supported."); throw new AuthenticationException("auth.17", null); } target = null; targetFriendlyName = null; } moasession.setPublicOAURLPrefix(oaParam.getPublicURLPrefix()); moasession.setTarget(target); moasession.setBusinessService(oaParam.getBusinessService()); //moasession.setStorkService(oaParam.getStorkService()); Logger.debug( "Business: " + moasession.getBusinessService() + " stork: " + moasession.getStorkService()); moasession.setTargetFriendlyName(targetFriendlyName); moasession.setDomainIdentifier(oaParam.getIdentityLinkDomainIdentifier()); } //check OnlineApplicationURL if (isEmpty(oaURL)) throw new WrongParametersException("StartAuthentication", PARAM_OA, "auth.05"); moasession.setOAURLRequested(oaURL); //check AuthURL String authURL = req.getScheme() + "://" + req.getServerName(); if ((req.getScheme().equalsIgnoreCase("https") && req.getServerPort() != 443) || (req.getScheme().equalsIgnoreCase("http") && req.getServerPort() != 80)) { authURL = authURL.concat(":" + req.getServerPort()); } authURL = authURL.concat(req.getContextPath() + "/"); if (!authURL.startsWith("https:")) throw new AuthenticationException("auth.07", new Object[] { authURL + "*" }); //set Auth URL from configuration moasession.setAuthURL(AuthConfigurationProvider.getInstance().getPublicURLPrefix() + "/"); //check and set SourceID if (oaParam.getSAML1Parameter() != null) { String sourceID = oaParam.getSAML1Parameter().getSourceID(); if (MiscUtil.isNotEmpty(sourceID)) moasession.setSourceID(sourceID); } if (MiscUtil.isEmpty(templateURL)) { List<TemplateType> templateURLList = oaParam.getTemplateURL(); List<String> defaulTemplateURLList = AuthConfigurationProvider.getInstance().getSLRequestTemplates(); if (templateURLList != null && templateURLList.size() > 0 && MiscUtil.isNotEmpty(templateURLList.get(0).getURL())) { templateURL = FileUtils.makeAbsoluteURL(oaParam.getTemplateURL().get(0).getURL(), AuthConfigurationProvider.getInstance().getRootConfigFileDir()); Logger.info("No SL-Template in request, load SL-Template from OA configuration (URL: " + templateURL + ")"); } else if ((defaulTemplateURLList.size() > 0) && MiscUtil.isNotEmpty(defaulTemplateURLList.get(0))) { templateURL = FileUtils.makeAbsoluteURL(defaulTemplateURLList.get(0), AuthConfigurationProvider.getInstance().getRootConfigFileDir()); Logger.info("No SL-Template in request, load SL-Template from general configuration (URL: " + templateURL + ")"); } else { Logger.error("NO SL-Tempalte found in OA config"); throw new WrongParametersException("StartAuthentication", PARAM_TEMPLATE, "auth.12"); } } if (!ParamValidatorUtils.isValidTemplate(req, templateURL, oaParam.getTemplateURL())) throw new WrongParametersException("StartAuthentication", PARAM_TEMPLATE, "auth.12"); moasession.setTemplateURL(templateURL); moasession.setCcc(ccc); }
From source file:ch.systemsx.cisd.openbis.generic.shared.translator.ExternalDataTranslator.java
public static ExternalData translate(ExternalDataPE externalDataPE, String defaultDataStoreBaseURL, String baseIndexURL, boolean loadSampleProperties, final LoadableFields... withExperimentFields) { SamplePE sampleOrNull = externalDataPE.tryGetSample(); ExperimentPE experiment = externalDataPE.getExperiment(); ExternalData externalData = new ExternalData(); externalData.setId(HibernateUtils.getId(externalDataPE)); externalData.setCode(StringEscapeUtils.escapeHtml(externalDataPE.getCode())); externalData.setComplete(BooleanOrUnknown.tryToResolve(externalDataPE.getComplete())); externalData.setDataProducerCode(StringEscapeUtils.escapeHtml(externalDataPE.getDataProducerCode())); externalData.setDataSetType(DataSetTypeTranslator.translate(externalDataPE.getDataSetType(), new HashMap<PropertyTypePE, PropertyType>())); externalData.setDerived(externalDataPE.isDerived()); externalData.setFileFormatType(TypeTranslator.translate(externalDataPE.getFileFormatType())); externalData.setInvalidation(tryToGetInvalidation(sampleOrNull, experiment)); externalData.setLocation(StringEscapeUtils.escapeHtml(externalDataPE.getLocation())); externalData.setLocatorType(TypeTranslator.translate(externalDataPE.getLocatorType())); final Collection<ExternalData> parents = new HashSet<ExternalData>(); externalData.setParents(parents);/*from w w w . j a v a 2 s.c o m*/ for (DataPE parentPE : externalDataPE.getParents()) { parents.add(fillExternalData(new ExternalData(), parentPE)); } setChildren(externalDataPE, externalData); externalData.setProductionDate(externalDataPE.getProductionDate()); externalData.setModificationDate(externalDataPE.getModificationDate()); externalData.setRegistrationDate(externalDataPE.getRegistrationDate()); externalData.setSample( sampleOrNull == null ? null : fillSample(new Sample(), sampleOrNull, loadSampleProperties)); externalData.setDataStore( DataStoreTranslator.translate(externalDataPE.getDataStore(), defaultDataStoreBaseURL)); externalData.setPermlink(PermlinkUtilities.createPermlinkURL(baseIndexURL, EntityKind.DATA_SET, externalData.getIdentifier())); setProperties(externalDataPE, externalData); externalData.setExperiment(ExperimentTranslator.translate(experiment, baseIndexURL, withExperimentFields)); return externalData; }
From source file:com.redhat.rhn.frontend.dto.MultiOrgAllUserOverview.java
/** * get the user's first name * @return the user's first name */ public String getUserFirstName() { return StringEscapeUtils.escapeHtml(userFirstName); }
From source file:com.igormaznitsa.mindmap.model.ModelUtils.java
@Nonnull public static String makePreBlock(@Nonnull final String text) { return "<pre>" + StringEscapeUtils.escapeHtml(text) + "</pre>"; //NOI18N }
From source file:ch.ksfx.web.pages.spidering.ViewResults.java
public String getFormattedData(Result result) { String data = ""; data += "<table><tr>"; for (ResultUnit resultUnit : result.getResultUnits()) { data += "<td valign='top'>" + StringEscapeUtils.escapeHtml(resultUnit.getValue()) + "</td>"; }/*from ww w . j av a 2 s . co m*/ data += "</tr></table>"; return data; }