Java Code Examples for org.apache.commons.lang.StringUtils#replace()

The following examples show how to use org.apache.commons.lang.StringUtils#replace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnifiedUserMngImpl.java    From Lottery with GNU General Public License v2.0 6 votes vote down vote up
private void senderEmail(final String username, final String to,
		final String activationCode, final EmailSender email,
		final MessageTemplate tpl) throws UnsupportedEncodingException, MessagingException {
	/*
	 * JavaMailSenderImpl sender = new JavaMailSenderImpl();
	 * sender.setHost(email.getHost());
	 * sender.setUsername(email.getUsername());
	 * sender.setPassword(email.getPassword()); sender.send(new
	 * MimeMessagePreparator() { public void prepare(MimeMessage
	 * mimeMessage) throws MessagingException, UnsupportedEncodingException
	 * { MimeMessageHelper msg; msg = new MimeMessageHelper(mimeMessage,
	 * false, email.getEncoding());
	 * msg.setSubject(tpl.getRegisterSubject()); msg.setTo(to);
	 * msg.setFrom(email.getUsername(), email.getPersonal()); String text =
	 * tpl.getRegisterText(); text = StringUtils.replace(text,
	 * "${username}", username); text = StringUtils.replace(text,
	 * "${activationCode}", activationCode); msg.setText(text); } });
	 */
	String text = tpl.getRegisterText();
	text = StringUtils.replace(text, "${username}", username);
	text = StringUtils.replace(text, "${activationCode}", activationCode);
	EmailSendTool sendEmail = new EmailSendTool(email.getHost(), email
			.getUsername(), email.getPassword(), to, tpl
			.getRegisterSubject(), text, email.getPersonal(), "", "");
	sendEmail.send();
}
 
Example 2
Source File: LWC.java    From Modern-LWC with MIT License 6 votes vote down vote up
/**
 * Normalize a name to a more readable & usable form.
 * <p/>
 * E.g sign_post/wall_sign = Sign, furnace/burning_furnace = Furnace,
 * iron_door_block = iron_door
 *
 * @param material
 * @return
 */
public static String normalizeMaterialName(Material material) {
    String name = StringUtils.replace(material.toString().toLowerCase(), "block", "");

    // some name normalizations
    if (name.contains("sign")) {
        name = "Sign";
    }

    if (name.contains("furnace")) {
        name = "furnace";
    }

    if (name.endsWith("_")) {
        name = name.substring(0, name.length() - 1);
    }

    return name.toLowerCase();
}
 
Example 3
Source File: KualiAction.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * Retrieves the value of a parameter to be passed into the lookup or inquiry frameworks.  The default implementation of this method will attempt to look
 * in the request to determine wheter the appropriate value exists as a request parameter.  If not, it will attempt to look through the form object to find
 * the property.
 * 
 * @param boClass a class implementing boClass, representing the BO that will be looked up
 * @param parameterName the name of the parameter
 * @param parameterValuePropertyName the property (relative to the form object) where the value to be passed into the lookup/inquiry may be found
 * @param form
 * @param request
 * @return
 */
protected String retrieveLookupParameterValue(Class<? extends BusinessObject> boClass, String parameterName, String parameterValuePropertyName, ActionForm form, HttpServletRequest request) throws Exception {
    String value;
    if (StringUtils.contains(parameterValuePropertyName, "'")) {
        value = StringUtils.replace(parameterValuePropertyName, "'", "");
    } else if (request.getParameterMap().containsKey(parameterValuePropertyName)) {
        value = request.getParameter(parameterValuePropertyName);
    } else if (request.getParameterMap().containsKey(KewApiConstants.DOCUMENT_ATTRIBUTE_FIELD_PREFIX + parameterValuePropertyName)) {
        value = request.getParameter(KewApiConstants.DOCUMENT_ATTRIBUTE_FIELD_PREFIX + parameterValuePropertyName);
    } else {
        if (form instanceof KualiForm) {
            value = ((KualiForm) form).retrieveFormValueForLookupInquiryParameters(parameterName, parameterValuePropertyName);
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unable to retrieve lookup/inquiry parameter value for parameter name " + parameterName + " parameter value property " + parameterValuePropertyName);
            }
            value = null;
        }
    }
    
    if (value != null && boClass != null && getBusinessObjectAuthorizationService().attributeValueNeedsToBeEncryptedOnFormsAndLinks(boClass, parameterName)) {
        LOG.warn("field name " + parameterName + " is a secure value and not returned in parameter result value");
        value = null;
    }
    return value;
}
 
Example 4
Source File: STSServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private String processHolderOfKeyCredentials(Credential hokCred, String request) throws TechnicalConnectorException, CertificateEncodingException {
   if (hokCred != null && hokCred.getCertificate() != null) {
      request = StringUtils.replace(request, "${holder.of.key}", new String(Base64.encode(hokCred.getCertificate().getEncoded())));
      PublicKey publicKey = hokCred.getCertificate().getPublicKey();
      if (publicKey instanceof RSAPublicKey) {
         RSAPublicKey rsaPublicKey = (RSAPublicKey)publicKey;
         request = StringUtils.replace(request, "${publickey.rsa.modulus}", new String(Base64.encode(convertTo(rsaPublicKey.getModulus()))));
         request = StringUtils.replace(request, "${publickey.rsa.exponent}", new String(Base64.encode(convertTo(rsaPublicKey.getPublicExponent()))));
         request = StringUtils.replace(request, "<ds:DSAKeyValue><ds:G>${publickey.dsa.g}<ds:G><ds:P>${publickey.dsa.p}</ds:P><ds:Q>${publickey.dsa.q}</ds:Q></ds:DSAKeyValue>", "");
      } else if (publicKey instanceof DSAPublicKey) {
         DSAPublicKey dsaPublicKey = (DSAPublicKey)publicKey;
         request = StringUtils.replace(request, "${publickey.dsa.g}", new String(Base64.encode(convertTo(dsaPublicKey.getParams().getG()))));
         request = StringUtils.replace(request, "${publickey.dsa.p}", new String(Base64.encode(convertTo(dsaPublicKey.getParams().getP()))));
         request = StringUtils.replace(request, "${publickey.dsa.q}", new String(Base64.encode(convertTo(dsaPublicKey.getParams().getQ()))));
         request = StringUtils.replace(request, "<ds:RSAKeyValue><ds:Modulus>${publickey.rsa.modulus}</ds:Modulus><ds:Exponent>${publickey.rsa.exponent}</ds:Exponent></ds:RSAKeyValue>", "");
      } else {
         LOG.info("Unsupported public key: [" + publicKey.getClass().getName() + "+]");
      }
   }

   return request;
}
 
Example 5
Source File: ResourceBundleUtil.java    From tddl5 with Apache License 2.0 6 votes vote down vote up
/**
 * <pre>
 * 从资源文件中,根据key,得到详细描述信息
 * 资源文件中,key对应的message允许占位符,根据params组成动态的描述信息
 * 
 * 如果key为null,则返回null
 * 如果key对应的message为null,则返回null
 * </pre>
 * 
 * @param key 详细描述对应的关键词
 * @param params 占位符对应的内容
 * @return 详细描述信息
 */
public String getMessage(String key, int code, String type, String... params) {
    // 参数校验
    if (key == null) {
        return null;
    }
    // 得到message内容
    String msg = bundle.getString(key);
    msg = parseStringValue(msg, bundle, new HashSet<String>());
    msg = StringUtils.replace(msg, "{code}", String.valueOf(code));
    msg = StringUtils.replace(msg, "{type}", String.valueOf(type));
    // 如果不存在动态内容,则直接返回msg
    if (params == null || params.length == 0) {
        return msg;
    }
    // 存在动态内容,渲染后返回新的message
    if (StringUtils.isBlank(msg)) {
        // 如果得到的msg为null或者空字符串,则直接返回msg本身
        return msg;
    }
    return MessageFormat.format(msg, (Object[]) params);
}
 
Example 6
Source File: CustomerInvoiceDocumentServiceImpl.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @see org.kuali.kfs.module.ar.document.service.CustomerInvoiceDocumentService#getOpenInvoiceDocumentsByCustomerNameByCustomerType(java.lang.String,
 *      java.lang.String)
 */
@Override
public Collection<CustomerInvoiceDocument> getOpenInvoiceDocumentsByCustomerNameByCustomerType(String customerName, String customerTypeCode) {
    Collection<CustomerInvoiceDocument> invoices = new ArrayList<CustomerInvoiceDocument>();

    // trim and force-caps the customer name
    customerName = StringUtils.replace(customerName, KFSConstants.WILDCARD_CHARACTER, KFSConstants.PERCENTAGE_SIGN);
    customerName = customerName.trim();
    if (customerName.indexOf("%") < 0) {
        customerName += "%";
    }

    // trim and force-caps
    customerTypeCode = customerTypeCode.trim().toUpperCase();

    invoices.addAll(customerInvoiceDocumentDao.getOpenByCustomerNameByCustomerType(customerName, customerTypeCode));
    return invoices;
}
 
Example 7
Source File: STSServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
private Document generateToken(String requestTemplate, boolean sign, Credential headerCred, Credential hokCred, SAMLNameIdentifier nameIdentifier, String authmethod, List<SAMLAttribute> attributes, List<SAMLAttributeDesignator> designators, int validity) throws TechnicalConnectorException {
   try {
      String request = ConnectorXmlUtils.flatten(requestTemplate);
      request = this.processDefaultFields(request, validity, nameIdentifier);
      request = this.processHolderOfKeyCredentials(hokCred, request);
      request = StringUtils.replace(request, "${authenticationMethod}", authmethod);
      Element payload = ConnectorXmlUtils.toElement(request.getBytes());
      Document doc = payload.getOwnerDocument();
      this.addDesignators(designators, doc);
      this.processAttributes(attributes, doc);
      boolean alwaysSign = Boolean.parseBoolean(ConfigFactory.getConfigValidator().getProperty("be.ehealth.technicalconnector.service.sts.always.sign.inner.request"));
      if (sign && (!headerCred.getCertificate().equals(hokCred.getCertificate()) || alwaysSign)) {
         try {
            String keyinfoType = ConfigFactory.getConfigValidator().getProperty("be.ehealth.technicalconnector.service.sts.keyinfo", "x509");
            if ("publickey".equalsIgnoreCase(keyinfoType)) {
               this.signRequest(doc.getDocumentElement(), hokCred.getPrivateKey(), hokCred.getPublicKey());
            } else {
               this.signRequest(doc.getDocumentElement(), hokCred.getPrivateKey(), hokCred.getCertificate());
            }
         } catch (Exception var15) {
            throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_SIGNATURE, new Object[]{"XML signature error: " + var15.getMessage(), var15});
         }
      }

      return doc;
   } catch (CertificateEncodingException var16) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_CRYPTO, var16, new Object[]{var16.getMessage()});
   }
}
 
Example 8
Source File: ConfigFactory.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void setConfigLocation(String configLocation) throws TechnicalConnectorException {
   String locationToSet = configLocation;
   if (configLocation == null) {
      if (ConfigUtil.isNet()) {
         locationToSet = StringUtils.replace("/be.ehealth.technicalconnector.properties", "/", ".\\");
      } else {
         locationToSet = "/be.ehealth.technicalconnector.properties";
      }
   }

   ConnectorIOUtils.getResourceFilePath(locationToSet);
   configLocation = locationToSet;
   ConfigurationImpl.reset();
   invalidate();
}
 
Example 9
Source File: Javadoc8Style.java    From javadoc.chm with Apache License 2.0 5 votes vote down vote up
@Override
public String getMethodFullName(String url) {
    String name = StringUtils.substringAfter(url, "#");
    int count = StringUtils.countMatches(name, "-");
    name = StringUtils.replaceOnce(name, "-", "(");
    for (int i = 0; i < count - 2; i++) {
        name = StringUtils.replaceOnce(name, "-", ", ");
    }
    name = StringUtils.replaceOnce(name, "-", ")");
    name = StringUtils.replace(name, ":A", "[]");
    return name;
}
 
Example 10
Source File: SwitchRenderer.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private void buildButton(Switch w, String lab, String cmd, int maxLabelSize, boolean severalButtons, Item item,
        State state, StringBuilder buttons) throws RenderException {
    String button = getSnippet("button");

    String command = cmd;
    String label = lab;

    if (item instanceof NumberItem && ((NumberItem) item).getDimension() != null) {
        String unit = getUnitForWidget(w);
        command = StringUtils.replace(command, UnitUtils.UNIT_PLACEHOLDER, unit);
        label = StringUtils.replace(label, UnitUtils.UNIT_PLACEHOLDER, unit);
    }

    if (label != null && maxLabelSize >= 1 && label.length() > maxLabelSize) {
        label = label.substring(0, maxLabelSize - 1) + ELLIPSIS;
    }

    button = StringUtils.replace(button, "%item%", w.getItem());
    button = StringUtils.replace(button, "%cmd%", escapeHtml(command));
    button = StringUtils.replace(button, "%label%", label != null ? escapeHtml(label) : "");

    String buttonClass;
    State compareMappingState = state;
    if (state instanceof QuantityType) { // convert the item state to the command value for proper
                                         // comparison and buttonClass calculation
        compareMappingState = convertStateToLabelUnit((QuantityType<?>) state, command);
    }

    if (severalButtons && compareMappingState.toString().equals(command)) {
        buttonClass = "mdl-button--accent";
    } else {
        buttonClass = "mdl-button";
    }
    button = StringUtils.replace(button, "%class%", buttonClass);

    buttons.append(button);
}
 
Example 11
Source File: CustomerInvoiceDocumentServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @see org.kuali.kfs.module.ar.document.service.CustomerInvoiceDocumentService#getOpenInvoiceDocumentsByCustomerName(java.lang.String)
 */
@Override
public Collection<CustomerInvoiceDocument> getOpenInvoiceDocumentsByCustomerName(String customerName) {
    Collection<CustomerInvoiceDocument> invoices = new ArrayList<CustomerInvoiceDocument>();

    // trim and force-caps the customer name
    customerName = StringUtils.replace(customerName, KFSConstants.WILDCARD_CHARACTER, KFSConstants.PERCENTAGE_SIGN);
    customerName = customerName.trim();
    if (customerName.indexOf("%") < 0) {
        customerName += "%";
    }

    invoices.addAll(customerInvoiceDocumentDao.getOpenByCustomerName(customerName));
    return invoices;
}
 
Example 12
Source File: EmailAnalysisBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void generateCommentEntry(StringBuilder htmlText, StyledCriteriaRatingDTO dto, boolean showCommentTitle) {

	int rowCount = 1;
	String escapedTitle = HtmlUtils.htmlEscape(dto.getRatingCriteria().getTitle());
	if (dto.getRatingCriteria().isCommentRating() || dto.getRatingCriteria().isCommentsEnabled()) {
	    if (dto.getRatingDtos().size() < 1) {
		htmlText.append("<tr><td style=\"width:25%\"><span style=\"").append(bold).append("\">")
			.append(escapedTitle).append("</span></td><td>")
			.append(getLocalisedMessage("event.sent.results.no.results")).append("</td></tr>");
	    } else {
		for (StyledRatingDTO ratingDto : dto.getRatingDtos()) {
		    if (ratingDto.getComment() != null) {
			String escapedComment = HtmlUtils.htmlEscape(ratingDto.getComment());
			escapedComment = StringUtils.replace(escapedComment, "&lt;BR&gt;", "<BR>");
			htmlText.append("<tr>");
			if (showCommentTitle) {
			    htmlText.append("<td style=\"width:25%;vertical-align:top;\">");
			    if (rowCount == 1) {
				htmlText.append("<span style=\"").append(bold).append("\">").append(escapedTitle)
					.append("</span>");
			    }
			    htmlText.append("</td>");
			}
			htmlText.append("<td style=\"").append(borderBelow).append("\">").append(escapedComment)
				.append("</td></tr>\n");
			rowCount++;
		    }
		}
	    }
	}
    }
 
Example 13
Source File: UpdateSqlLogParser.java    From sofa-acts with Apache License 2.0 5 votes vote down vote up
/**
 * generate select-sql
 * @param sql
 * @param paramValue
 * @return
 */
public String genSql(String sql, List<String> paramValue, List<String> paramType) {
    //parse field in set, where
    String setFieldStr = sql.substring(sql.indexOf(" set ") + 5, sql.indexOf(" where "));
    String[] setFields = setFieldStr.trim().split(",");
    if (null == setFields || setFields.length == 0) {
        return null;
    }

    String condtionPart = sql.substring(sql.indexOf(" where ")).trim();

    int needUpdateFieldNum = 0;
    for (String field : setFields) {
        if (StringUtils.contains(field, "?")) {
            needUpdateFieldNum++;
        }
    }
    while (condtionPart.contains("?")) {
        condtionPart = StringUtils.replace(condtionPart, "?",
            "'" + paramValue.get(needUpdateFieldNum) + "'", 1);
        ++needUpdateFieldNum;
    }

    String tableName = parseTableName(sql);
    StringBuffer querySql = new StringBuffer("select * from ");
    querySql.append(tableName);
    querySql.append(" " + condtionPart);
    querySql.append("\r\n");
    return querySql.toString();
}
 
Example 14
Source File: DbTplDaoImpl.java    From Lottery with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public List<DbTpl> getStartWith(String prefix) {
	StringUtils.replace(prefix, "_", "\\_");
	prefix = prefix + "%";
	String hql = "from DbTpl bean where bean.id like ? order by bean.id";
	return find(hql, prefix);
}
 
Example 15
Source File: FreeMarkerRenderer.java    From opoopress with Apache License 2.0 5 votes vote down vote up
@Override
protected String buildTemplateContent(String layout, File layoutFile, String content) {
    //String layoutFilename = getLayoutFilename(layout);
    //File layoutFile = new File(templateDir, layoutFilename);
    try {
        String template = FileUtils.readFileToString(layoutFile, "UTF-8");
        return StringUtils.replace(template, "${content}", content);
    } catch (Exception e) {
        throw new RuntimeException("Read layout file error: " + layoutFile, e);
    }
}
 
Example 16
Source File: PathUtils.java    From oodt with Apache License 2.0 5 votes vote down vote up
public static String doDynamicDateFormatReplacement(String string,
        Metadata metadata) throws ParseException, CasMetadataException, CommonsException {
    Pattern dateFormatPattern = Pattern
            .compile("\\[\\s*FORMAT\\s*\\(.{1,}?,.{1,}?,.{1,}?\\)\\s*\\]");
    Matcher dateFormatMatcher = dateFormatPattern.matcher(string);
    while (dateFormatMatcher.find()) {
        String dateFormatString = string.substring(dateFormatMatcher
                .start(), dateFormatMatcher.end());

        // get arguments
        Matcher argMatcher = Pattern.compile("\\(.*\\)").matcher(
                dateFormatString);
        argMatcher.find();
        String argsString = dateFormatString.substring(argMatcher.start() + 1,
                argMatcher.end() - 1); 
        argsString = doDynamicReplacement(argsString, metadata);
        String[] args = argsString.split(",");
        String curFormat = args[0].trim();
        String dateString = args[1].trim();
        String newFormat = args[2].trim();

        // reformat date
        Date date = new SimpleDateFormat(curFormat).parse(dateString);
        String newDateString = new SimpleDateFormat(newFormat).format(date);

        // swap in date string
        string = StringUtils.replace(string, dateFormatString,
                newDateString);
        dateFormatMatcher = dateFormatPattern.matcher(string);
    }

    return string;
}
 
Example 17
Source File: KickstartFactory.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Save a KickstartData to the DB and associate
 * the storage with the KickstartSession passed in.  This is
 * used if you want to save the KickstartData and associate the
 *
 * @param ksdataIn Kickstart Data to be stored in db
 * @param ksession KickstartSession to associate with this save.
 */
public static void saveKickstartData(KickstartData ksdataIn,
        KickstartSession ksession) {
    log.debug("saveKickstartData: " + ksdataIn.getLabel());
    singleton.saveObject(ksdataIn);
    String fileData = null;
    if (ksdataIn.isRawData()) {
        log.debug("saveKickstartData is raw, use file");
        KickstartRawData rawData = (KickstartRawData) ksdataIn;
        fileData = rawData.getData();
    }
    else {
        log.debug("saveKickstartData wizard.  use object");
        KickstartFormatter formatter = new KickstartFormatter(
                KickstartUrlHelper.COBBLER_SERVER_VARIABLE, ksdataIn, ksession);
        fileData = formatter.getFileData();
    }
    Profile p = Profile.lookupById(CobblerXMLRPCHelper.getAutomatedConnection(),
            ksdataIn.getCobblerId());
    if (p != null && p.getKsMeta() != null) {
        Map ksmeta = p.getKsMeta();
        Iterator i = ksmeta.keySet().iterator();
        while (i.hasNext()) {
            String name = (String) i.next();
            log.debug("fixing ksmeta: " + name);
            fileData = StringUtils.replace(fileData, "\\$" + name, "$" + name);
        }
    }
    else {
        log.debug("No ks meta for this profile.");
    }
    String path = ksdataIn.buildCobblerFileName();
    log.debug("writing ks file to : " + path);
    FileUtils.writeStringToFile(fileData, path);
}
 
Example 18
Source File: LikeUtil.java    From yugong with GNU General Public License v2.0 4 votes vote down vote up
private static String convertWildcard(String toConvert) {
    toConvert = StringUtils.replace(toConvert, "_", "(.)");
    toConvert = StringUtils.replace(toConvert, "%", "(.*)");
    return toConvert;
}
 
Example 19
Source File: StringUtil.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public static String replace(String src, String target, String rWith, int maxCount) {
	return StringUtils.replace(src, target, rWith, maxCount);
}
 
Example 20
Source File: ChartRenderer.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderException {
    Chart chart = (Chart) w;

    try {
        String itemParam = null;
        Item item = itemUIRegistry.getItem(chart.getItem());
        if (item instanceof GroupItem) {
            itemParam = "groups=" + chart.getItem();
        } else {
            itemParam = "items=" + chart.getItem();
        }

        String chartUrl = "/chart?" + itemParam + "&period=" + chart.getPeriod();
        if (chart.getService() != null) {
            chartUrl += "&service=" + chart.getService();
        }
        // if legend parameter is given, add corresponding GET parameter
        if (chart.getLegend() != null) {
            if (chart.getLegend()) {
                chartUrl += "&legend=true";
            } else {
                chartUrl += "&legend=false";
            }
        }
        // add theme GET parameter
        String chartTheme = null;
        switch (config.getTheme()) {
            case WebAppConfig.THEME_NAME_DEFAULT:
                chartTheme = "bright";
                break;
            case WebAppConfig.THEME_NAME_DARK:
                chartTheme = "dark";
                break;
        }
        if (chartTheme != null) {
            chartUrl += "&theme=" + chartTheme;
        }
        String url;
        boolean ignoreRefresh;
        if (!itemUIRegistry.getVisiblity(w)) {
            url = URL_NONE_ICON;
            ignoreRefresh = true;
        } else {
            // add timestamp to circumvent browser cache
            url = chartUrl + "&t=" + (new Date()).getTime();
            ignoreRefresh = false;
        }

        String snippet = getSnippet("chart");
        snippet = preprocessSnippet(snippet, w);

        if (chart.getRefresh() > 0) {
            snippet = StringUtils.replace(snippet, "%update_interval%", Integer.toString(chart.getRefresh()));
        } else {
            snippet = StringUtils.replace(snippet, "%update_interval%", "0");
        }

        snippet = StringUtils.replace(snippet, "%id%", itemUIRegistry.getWidgetId(w));
        snippet = StringUtils.replace(snippet, "%proxied_url%", chartUrl);
        snippet = StringUtils.replace(snippet, "%valid_url%", "true");
        snippet = StringUtils.replace(snippet, "%ignore_refresh%", ignoreRefresh ? "true" : "false");
        snippet = StringUtils.replace(snippet, "%url%", url);

        sb.append(snippet);
    } catch (ItemNotFoundException e) {
        logger.warn("Chart cannot be rendered as item '{}' does not exist.", chart.getItem());
    }
    return null;
}