Example usage for org.apache.commons.lang StringUtils replace

List of usage examples for org.apache.commons.lang StringUtils replace

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils replace.

Prototype

public static String replace(String text, String searchString, String replacement) 

Source Link

Document

Replaces all occurrences of a String within another String.

Usage

From source file:com.vmware.bdd.utils.ScriptForUpdatingEtcHostsGenerator.java

public String getContentForUpdatingEtcHosts(String hostsContent) {
    load();//from w w w  .  j a  v a 2 s.  c  o m

    String scriptContent = new String(getTemplateContent());

    ArrayList<String[]> replacementList = new ArrayList<>();

    replacementList.add(new String[] { "ETC_HOSTS_CONTENT", hostsContent });

    for (String[] replacement : replacementList) {
        scriptContent = StringUtils.replace(scriptContent, replacement[0], replacement[1]);
    }

    return scriptContent;
}

From source file:com.liferay.sync.engine.service.persistence.SyncFilePersistence.java

public SyncFile fetchByPF_S_First(String parentFilePathName, int state) throws SQLException {

    QueryBuilder<SyncFile, Long> queryBuilder = queryBuilder();

    queryBuilder.limit(1L);//ww w  .  ja  va  2s.c o  m

    Where<SyncFile, Long> where = queryBuilder.where();

    FileSystem fileSystem = FileSystems.getDefault();

    parentFilePathName = StringUtils.replace(parentFilePathName + fileSystem.getSeparator(), "\\", "\\\\");

    where.like("filePathName", new SelectArg(parentFilePathName + "%"));

    where.eq("state", state);
    where.ne("uiEvent", SyncFile.UI_EVENT_DELETED_LOCAL);
    where.ne("uiEvent", SyncFile.UI_EVENT_DELETED_REMOTE);
    where.ne("uiEvent", SyncFile.UI_EVENT_TRASHED_LOCAL);
    where.ne("uiEvent", SyncFile.UI_EVENT_TRASHED_REMOTE);

    where.and(6);

    return where.queryForFirst();
}

From source file:edu.cornell.med.icb.util.ICBStringUtils.java

/**
 * Fix the incoming string to be safe for HTML &lt;input&gt;, etc..
 * @param inval The incoming String to be fixed. Passing
 * in a null or an empty string will return an empty string.
 * @return String that is safe to use for Javascript strings
 *///from  w w w  . j ava2s  .c  o m
public static String htmlFix(final String inval) {
    if (StringUtils.isEmpty(inval)) {
        return "";
    }

    String outval = StringUtils.replace(inval, "&", HTML_AMP);
    outval = StringUtils.replace(outval, "'", HTML_SINGLE_QUOTE);
    outval = StringUtils.replace(outval, "\"", HTML_DOUBLE_QUOTE);
    outval = StringUtils.replace(outval, "<", HTML_LESS_THAN);
    outval = StringUtils.replace(outval, ">", HTML_GREATER_THAN);
    return outval;
}

From source file:edu.ku.brc.specify.tasks.subpane.security.UserAgentVSQBldr.java

/**
 * @param dataMap//from   ww w.ja  va 2s  .co  m
 * @param fieldNames
 * @return
 */
@Override
public String buildSQL(final Map<String, Object> dataMap, final List<String> fieldNames) {
    Vector<Object> disciplineIds = BasicSQLUtils
            .querySingleCol("SELECT DisciplineID FROM discipline ORDER BY Name");
    if (disciplineIds.size() > 1) {
        Vector<Object> divisionNames = BasicSQLUtils
                .querySingleCol("SELECT Name FROM discipline ORDER BY Name");
        ToggleButtonChooserDlg<Object> divDlg = new ToggleButtonChooserDlg<Object>((Dialog) null,
                UIRegistry.getResourceString("SEC_PK_SRCH"), divisionNames,
                ToggleButtonChooserPanel.Type.RadioButton);
        divDlg.setUseScrollPane(true);
        divDlg.createUI();
        divDlg.getCancelBtn().setVisible(false);

        divDlg.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        UIHelper.centerAndShow(divDlg);
        int inx = divisionNames.indexOf(divDlg.getSelectedObject());
        disciplineID = (Integer) disciplineIds.get(inx);

    } else {
        disciplineID = (Integer) disciplineIds.get(0);
    }

    String searchName = cbx.getSearchName();
    if (searchName != null) {
        esTblInfo = ExpressSearchConfigCache.getTableInfoByName(searchName);
        if (esTblInfo != null) {
            String sqlStr = esTblInfo.getViewSql();
            return buildSearchString(dataMap, fieldNames,
                    StringUtils.replace(sqlStr, "DSPLNID", disciplineID.toString()));
        }
    }
    return null;
}

From source file:gemlite.core.webapp.tools.IndexController.java

@SuppressWarnings("unchecked")
    @RequestMapping(value = "/index/describe/{indexName}", method = RequestMethod.GET)
    @ResponseBody//from   ww  w.j a  va 2s .  c o m
    public List<HashMap<String, Object>> describeIndex(@PathVariable String indexName) {
        //
        indexName = StringUtils.replace(indexName, "(Hash Index)", "");
        //indexpn
        ic.describeIndex(true, indexName);
        List<HashMap<String, Object>> list = (List<HashMap<String, Object>>) ic.get(CommandMeta.DESCRIBE_INDEX);
        return list;
    }

From source file:dpfmanager.conformancechecker.tiff.reporting.HtmlReport.java

/**
 * Parse an individual report to HTML./* ww w  . j a v a2 s  .  c om*/
 *
 * @param ir   the individual report.
 * @param mode the mode (1, 2).
 */
public String parseIndividual(IndividualReport ir, int mode, int id) {
    String templatePath = "templates/individual.html";

    String htmlBody = readFilefromResources(templatePath);

    // Image
    String fileName = getReportName("", ir.getFilePath(), id);
    String imgPath = "img/" + fileName + ".jpg";
    BufferedImage thumb = tiff2Jpg(ir.getFilePath());
    if (thumb == null) {
        imgPath = "img/noise.jpg";
    }
    htmlBody = StringUtils.replace(htmlBody, "##IMG_PATH##", encodeUrl(imgPath));

    /**
     * Basic info / divs conforms
     */
    htmlBody = StringUtils.replace(htmlBody, "##IMG_NAME##", ir.getFileName());
    htmlBody = StringUtils.replace(htmlBody, "##IMG_FILEPATH##", ir.getFilePath());
    String divs = "";
    for (String iso : ir.getCheckedIsos()) {
        if (ir.hasValidation(iso) || ir.getErrors(iso).isEmpty()) {
            divs += makeConformsText(ir, iso);
        }
    }
    htmlBody = StringUtils.replace(htmlBody, "##DIVS_CONFORMS##", divs);

    if (mode == 1) {
        htmlBody = StringUtils.replace(htmlBody, "##CL_LINKR2##", "show");
        htmlBody = StringUtils.replace(htmlBody, "##LINK2##",
                encodeUrl(new File(fileName).getName() + "_fixed.html"));
    }
    if (mode == 2) {
        htmlBody = StringUtils.replace(htmlBody, "##CL_LINKR1##", "show");
        htmlBody = StringUtils.replace(htmlBody, "##LINK1##",
                encodeUrl(new File(fileName).getName() + ".html"));
    }

    /**
     * Table errors / warnings count
     */
    String rowTmpl = "<tr>\n" + "    <td>##TITLE##</td>\n" + "    <td class=\"##ERR_CLASS##\">##ERR##</td>\n"
            + "    <td class=\"##WAR_CLASS##\">##WAR##</td>\n" + "    </tr>";
    String rows = "";
    for (String iso : ir.getIsosCheck()) {
        if (ir.hasValidation(iso)) {
            String name = ImplementationCheckerLoader.getIsoName(iso);
            String row = rowTmpl;
            int errorsCount = ir.getNErrors(iso);
            int warningsCount = ir.getNWarnings(iso);
            row = StringUtils.replace(row, "##TITLE##", name);
            String difErr = ir.getCompareReport() != null
                    ? getDif(ir.getCompareReport().getNErrors(iso), ir.getNErrors(iso))
                    : "";
            String difWar = ir.getCompareReport() != null
                    ? getDif(ir.getCompareReport().getNWarnings(iso), ir.getNWarnings(iso))
                    : "";
            row = StringUtils.replace(row, "##ERR##", "" + errorsCount + difErr);
            row = StringUtils.replace(row, "##WAR##", "" + warningsCount + difWar);
            row = StringUtils.replace(row, "##ERR_CLASS##", errorsCount > 0 ? "error" : "info");
            row = StringUtils.replace(row, "##WAR_CLASS##", warningsCount > 0 ? "warning" : "info");
            rows += row;
        }
    }
    htmlBody = StringUtils.replace(htmlBody, "##TABLE_RESUME_ERRORS##", rows);

    /**
     * Errors / Warnings resume
     */

    String fullTmpl = "<div class=\"row bot20 fullw\">\n" + "\t\t\t\t##CHECK##\n" + "\t\t\t\t<div>\n"
            + "\t\t\t\t\t<h5 class=\"bold left15\"><i class=\"fa ##ICON##\"></i>  ##TITLE##</h4>\n"
            + "\t\t\t\t\t##CONTENT##\n" + "\t\t\t\t</div>\n" + "\t\t\t</div>";
    String checkInfos = "<div class=\"clexpert\"><input type=\"checkbox\" id=\"checkInfo##COUNT##\" onchange=\"onChangeInfo(##COUNT##)\"><label for=\"checkInfo##COUNT##\"><span></span> Show infos</label></div>";
    String errorsTmpl = "<table class=\"CustomTable3 left15\">\n" + "\t\t\t\t        <tr>\n"
            + "\t\t\t\t            <th class=\"bold tcenter\" style='width: 50px;'>Type</th>\n"
            + "\t\t\t\t            <th class=\"bold\" style='width: 120px;'>ID</th>\n"
            + "\t\t\t\t            <th class=\"bold\" style='width: 80px;'>Location</th>\n"
            + "\t\t\t\t            <th class=\"bold\">Description</th>\n" + "\t\t\t\t        </tr>\n"
            + "\t\t\t\t        ##ROWS##\n" + "\t\t\t\t\t</table>";
    String policyTmpl = "<table class=\"CustomTable3 left15\">\n" + "\t\t\t\t        <tr>\n"
            + "\t\t\t\t            <th class=\"bold tcenter\" style='width: 50px;'>Type</th>\n"
            + "\t\t\t\t            <th class=\"bold\">Rule</th>\n"
            + "\t\t\t\t            <th class=\"bold\">Description</th>\n" + "\t\t\t\t        </tr>\n"
            + "\t\t\t\t        ##ROWS##\n" + "\t\t\t\t\t</table>";
    String tdTmpl = "<tr ##CLASS## ##DISPLAY## ##POPOVER##><td class=\"bold tcenter\"><i style=\"font-size: 18px;\" class=\"fa fa-##FA_CLASS##-circle iconStyle\"/></td><td>##ID##</td><td>##LOC##</td><td>##DESC##</td></tr>";
    String pcTmpl = "<tr ##CLASS## ##DISPLAY## ##POPOVER##><td class=\"bold tcenter\"><i style=\"font-size: 18px;\" class=\"fa fa-##FA_CLASS##-circle iconStyle\"/><td>##LOC##</td><td>##DESC##</td></tr>";
    rows = "";
    int count = 0;
    for (String iso : ir.getIsosCheck()) {
        if (ir.hasValidation(iso)) {
            String name = ImplementationCheckerLoader.getIsoName(iso);
            String row = fullTmpl, icon = "exclamation";
            int errorsCount = ir.getNErrors(iso);
            int warningsCount = ir.getNWarnings(iso);
            int infosCount = ir.getNInfos(iso);
            int addedRows = 0, addedInfos = 0;
            if (errorsCount > 0) {
                icon = "fa-times-circle";
            } else if (warningsCount > 0) {
                icon = "fa-exclamation-circle";
            } else {
                icon = "fa-check-circle";
            }
            String content = "";
            if (errorsCount + warningsCount + infosCount > 0) {
                if (iso.equals(TiffConformanceChecker.POLICY_ISO)) {
                    content += policyTmpl;
                } else {
                    content += errorsTmpl;
                }
                String allRows = "";
                // Errors, Warnings and Infos
                for (RuleResult val : ir.getAllRuleResults(iso)) {
                    String tdRow, display = "", clasz = "", location = "";
                    if (val.getRule() == null) {
                        // Policy value
                        tdRow = pcTmpl;
                        if (!val.ok() && !val.getWarning()) {
                            tdRow = tdRow.replace("##FA_CLASS##", "times");
                        } else if (!val.ok()) {
                            tdRow = tdRow.replace("##FA_CLASS##", "exclamation");
                        }
                        location = val.getRuleDescription();
                    } else {
                        // Rule value
                        tdRow = tdTmpl;
                        if (val.getRule().isError() || val.getRule().isCritical()) {
                            tdRow = tdRow.replace("##FA_CLASS##", "times");
                        } else if (val.getRule().isWarning()) {
                            tdRow = tdRow.replace("##FA_CLASS##", "exclamation");
                        } else if (val.getRule().isInfo()) {
                            tdRow = tdRow.replace("##FA_CLASS##", "info");
                            display = "style='display: none;'";
                            clasz = "class='info##COUNT##'";
                            addedInfos++;
                        }
                        location = val.getLocation();
                    }
                    tdRow = tdRow.replace("##ID##", val.getRule() != null ? val.getRule().getId() : "");
                    tdRow = tdRow.replace("##LOC##", location);
                    tdRow = tdRow.replace("##DESC##", val.getDescription());
                    tdRow = tdRow.replace("##POPOVER##", makePopoverAttributes(val));
                    tdRow = tdRow.replace("##DISPLAY##", display);
                    tdRow = tdRow.replace("##CLASS##", clasz);
                    addedRows++;
                    allRows += tdRow;
                }
                content = StringUtils.replace(content, "##ROWS##", allRows);
            }
            if (addedRows == 0) {
                content = "";
            }
            if (addedInfos == 0) {
                row = StringUtils.replace(row, "##CHECK##", "");
            }
            row = StringUtils.replace(row, "##CHECK##", checkInfos);
            row = StringUtils.replace(row, "##CONTENT##", content);
            row = StringUtils.replace(row, "##COUNT##", (++count) + "");
            row = StringUtils.replace(row, "##TITLE##", name);
            row = StringUtils.replace(row, "##ICON##", icon);
            rows += row;
        }
    }
    htmlBody = StringUtils.replace(htmlBody, "##DIVS_ERRORS##", rows);

    /**
     * Tags divs
     */
    htmlBody = StringUtils.replace(htmlBody, "##TAGS_DIVS##", generateTagsDivs(ir));

    /**
     * File Structure
     */
    String ul = "<ul id='structure'>";
    int index = 0;
    TiffDocument td = ir.getTiffModel();
    IFD ifd = td.getFirstIFD();
    boolean hasIFDList = false;
    if (ifd != null && ifd.hasNextIFD()) {
        hasIFDList = ifd.hasNextIFD();
    }
    while (ifd != null) {
        String typ = " - Main image";
        if (ifd.hasSubIFD() && ifd.getImageSize() < ifd.getsubIFD().getImageSize()) {
            typ = " - Thumbnail";
        }
        String aIni = "";
        String aBody = " " + ifd.toString() + typ;
        String aEnd = "";
        String bold = "";
        if (index == 0) {
            bold = "bold";
        }
        aIni = "<a id='liifd" + index + "' href='javascript:void(0)' onclick=\"showTagsDiv('ifd" + index
                + "')\" class='" + bold + "'>";
        aEnd = "</a>";
        ul += "<li><i class=\"fa fa-file-image-o\"></i>" + aIni + aBody + aEnd;
        if (ifd.getsubIFD() != null) {
            typ = "";
            if (ifd.getImageSize() < ifd.getsubIFD().getImageSize())
                typ = " - Main image";
            else
                typ = " - Thumbnail";
            ul += "<ul><li><i class=\"fa fa-file-o\"></i> <a href='javascript:void(0)' onclick=\"showTagsDiv('sub"
                    + index + "')\" id='lisub" + index + "'>SubIFD" + typ + "</a></li></ul>";
        }
        if (ifd.containsTagId(34665)) {
            ul += "<ul><li><i class=\"fa fa-file-o\"></i> <a href='javascript:void(0)' onclick=\"showTagsDiv('exi"
                    + index + "')\" id='liexi" + index + "'>EXIF</a></li></ul>";
        }
        if (ifd.containsTagId(700)) {
            ul += "<ul><li><i class=\"fa fa-file-o\"></i> <a href='javascript:void(0)' onclick=\"showTagsDiv('xmp"
                    + index + "')\" id='lixmp" + index + "'>XMP</a></li></ul>";
        }
        if (ifd.containsTagId(33723)) {
            ul += "<ul><li><i class=\"fa fa-file-o\"></i> <a href='javascript:void(0)' onclick=\"showTagsDiv('ipt"
                    + index + "')\" id='liipt" + index + "'>IPTC</a></li></ul>";
        }
        if (index == 0) {
            if (ir.getTiffModel().getIccProfile() != null) {
                String creat = "";
                if (ir.getTiffModel().getIccProfile().getCreator() != null) {
                    creat = "<li>Creator: " + ir.getTiffModel().getIccProfile().getCreator().getCreator()
                            + "</li>";
                }
                ul += "<ul><li><i class=\"fa fa-file-o\"></i> ICC<ul>" + "<li>Description: "
                        + ir.getTiffModel().getIccProfile().getDescription() + "</li>" + creat + "<li>Version: "
                        + ir.getTiffModel().getIccProfile().getVersion() + "</li>" + "<li>Class: "
                        + ir.getTiffModel().getIccProfile().getProfileClass().toString() + "</li></ul>"
                        + "</li></ul>";
            }
        }
        ul += "</li>";
        index++;
        ifd = ifd.getNextIFD();
    }
    ul += "</ul>";
    htmlBody = StringUtils.replace(htmlBody, "##UL##", ul);

    /**
     * Metadata incoherencies
     */
    IFD tdifd = td.getFirstIFD();
    int nifd = 1;
    rows = "";
    while (tdifd != null) {
        XMP xmp = null;
        IPTC iptc = null;
        if (tdifd.containsTagId(TiffTags.getTagId("XMP"))) {
            try {
                xmp = (XMP) tdifd.getTag("XMP").getValue().get(0);
            } catch (Exception ex) {
                xmp = null;
            }
        }
        if (tdifd.containsTagId(TiffTags.getTagId("IPTC"))) {
            try {
                iptc = (IPTC) tdifd.getTag("IPTC").getValue().get(0);
            } catch (Exception ex) {
                iptc = null;
            }
        }

        // Author
        String authorTag = null;
        if (tdifd.containsTagId(TiffTags.getTagId("Artist")))
            authorTag = tdifd.getTag("Artist").toString();
        String authorIptc = null;
        if (iptc != null)
            authorIptc = iptc.getCreator();
        String authorXmp = null;
        if (xmp != null)
            authorXmp = xmp.getCreator();
        rows += detectIncoherency(authorTag, authorIptc, authorXmp, "Author", nifd);

        tdifd = tdifd.getNextIFD();
        nifd++;
    }
    if (rows.isEmpty()) {
        rows = "<tr><td class='tcenter'><i style='font-size: 18px;' class=\"fa fa-check-circle\"></i></td><td>No metadata incoherencies found</td></tr>";
    }
    htmlBody = StringUtils.replace(htmlBody, "##META_ROWS##", rows);

    /**
     * Finish, write to html file
     */
    htmlBody = StringUtils.replace(htmlBody, "\\.\\./html/", "");
    return htmlBody;
}

From source file:com.painiu.webapp.util.PhotoUtils.java

public static String toApiURL(String url) {
    return StringUtils.replace(url, "http://photo.", "http://photo0.");
}

From source file:com.tesora.dve.db.NativeType.java

/**
 * This method is to make sure that when mapping a string to a type (through, say, enum.valueOf), the format is always
 * the same. Inherited classes should use this to set up their own enum's of valid types.
 * //from   w w w.j  a  v a 2  s  .  c om
 * Does the 'opposite' of fixName.
 * 
 * @param name
 * @return
 */
public static String fixNameForType(String name) {
    if (StringUtils.startsWith(StringUtils.lowerCase(name, Locale.ENGLISH), "enum")) {
        return "ENUM";
    }

    return name == null ? null : StringUtils.replace(name.toUpperCase(Locale.ENGLISH), " ", "_");
}

From source file:net.sf.zekr.engine.search.tanzil.ZeroHighlighter.java

@SuppressWarnings({ "unchecked", "rawtypes" })
protected SearchResultModel doSearch(String rawQuery) throws SearchException {
    try {/*from  ww w  .java2  s  .c  om*/
        logger.debug("Searching for query: " + rawQuery);
        rawQuery = rawQuery.replaceAll("\\-", "!");

        boolean thisIsQuran = !quranText.isTranslation();
        PatternEnricher enricher = PatternEnricherFactory.getEnricher(quranText.getLanguage(), thisIsQuran);
        if (thisIsQuran) { // it's translation
            enricher.setParameter(QuranPatternEnricher.IGNORE_HARAKA, Boolean.FALSE);
        }
        String pattern = enricher.enrich(rawQuery);

        String highlightPattern = pattern.replaceAll("[+!]", "|");
        highlightPattern = highlightPattern.replaceAll("^[|]+", "").replaceAll("!", ""); // remove leading '|'s
        logger.debug("Rewritten query: " + pattern);

        pattern = StringUtils.replace(pattern, "!", "+!");
        if (pattern.startsWith("+")) {
            pattern = pattern.substring(1);
        }
        String[] patterns = pattern.split("\\+");
        Set<String> clauses = new LinkedHashSet<String>();
        List intermediateResult = locations;
        for (int i = 0; i < patterns.length; i++) {
            // TODO: for queries with patterns.length > 1, first search for larger (more filtering) patterns[i]
            String p = patterns[i];
            boolean exclude;
            if (exclude = p.charAt(0) == '!') {
                p = p.substring(1);
            }
            intermediateResult = filterBucket(intermediateResult, p, exclude, i == 0, enricher);
        }

        // extract matched parts and clauses
        int total = 0;
        List resultItems = intermediateResult;
        for (int i = 0; i < patterns.length; i++) {
            if (patterns[i].charAt(0) == '!') {
                continue;
            }
            Pattern regex = Pattern.compile(patterns[i], Pattern.CASE_INSENSITIVE);
            for (int j = 0; j < resultItems.size(); j++) {
                SearchResultItem sri = (SearchResultItem) resultItems.get(j);
                Matcher matcher = regex.matcher(sri.text);
                while (matcher.find()) {
                    total++;
                    sri.matchedParts.add(new String(matcher.group()));
                    clauses.add(getClause(sri.text, matcher));
                }
            }
        }

        // score and highlight results
        logger.debug("Score and highlight search results.");
        scoreSearchResult(resultItems, highlightPattern, patterns.length);

        return new SearchResultModel(quranText, resultItems, StringUtils.join(clauses, " "), rawQuery, total,
                searchResultComparator, ascending);
    } catch (SearchException se) {
        throw se;
    } catch (Exception e) {
        throw new SearchException(e);
    }
}

From source file:com.pearson.openideas.cq5.components.newsletter.NewArticlesList.java

/**
 * {@inheritDoc}/*ww  w  .j a v a2  s .c o  m*/
 */
public void init() {

    TagManager tagManager = getResourceResolver().adaptTo(TagManager.class);

    List<String> paths;

    Map<String, String> queryParamMap = new HashMap<String, String>();
    queryParamMap.put("path", "/content/plc/prkc/uk/open-ideas");
    queryParamMap.put("type", "cq:Page");
    queryParamMap.put("1_property", "jcr:content/cq:template");
    queryParamMap.put("1_property.value", "/apps/plc/prkc/uk/open-ideas/templates/openIdeasArticleTemplate");
    queryParamMap.put("2_property", "jcr:content/cq:lastReplicationAction");
    queryParamMap.put("2_property.value", "Activate");
    queryParamMap.put("orderBy", "@jcr:content/jcr:created");
    queryParamMap.put("orderBy.sort", "desc");

    ArticleQueryService queryService = getSlingScriptHelper().getService(ArticleQueryService.class);
    PropertiesService propertiesService = getSlingScriptHelper().getService(PropertiesService.class);

    // get a list of paths returned from our query
    paths = queryService.getArticles(queryParamMap);

    // hash map used to separate articles into different lists by theme
    articlesByTheme = new HashMap<String, List<Article>>();

    // loop through paths, create articles and decide whether or not they should be in our email
    for (String path : paths) {
        Resource resource = getResourceResolver().getResource(path + "/jcr:content");
        Article article = new Article();
        try {
            article = ArticleUtils.createArticleObject(resource, article, tagManager);
        } catch (Exception e) {
            log.error("Error creating this article", e);
        }
        log.debug("Suitable for email? " + article.getSuitableForEmail());

        // add article to hash map, check will be true if it has been published in the last week
        if (article.getSuitableForEmail()) {
            log.debug("Article path: " + article.getUrl());
            article.setUrl(propertiesService.getPublishUrl() + article.getUrl() + ".html");
            log.debug("article full published URL: " + article.getUrl());
            log.debug("image path? " + article.getImage().getFileNodePath());
            String imagePath = article.getThumbnail().getFileNodePath();
            imagePath = StringUtils.replace(imagePath, "image/file", "image.img.jpg");
            imagePath = StringUtils.replace(imagePath, "jcr:content", "_jcr_content");
            imagePath = propertiesService.getPublishUrl() + imagePath;
            log.debug("image path NOW: " + imagePath);
            article.setNewsletterImageUrl(imagePath);
            List<Article> articleList = articlesByTheme.get(article.getTheme());
            if (articleList == null) {
                articleList = new ArrayList<Article>();
            }
            articleList.add(article);
            articlesByTheme.put(article.getTheme(), articleList);

        }
    }

}