Example usage for com.liferay.portal.kernel.util FriendlyURLNormalizerUtil normalizeWithPeriodsAndSlashes

List of usage examples for com.liferay.portal.kernel.util FriendlyURLNormalizerUtil normalizeWithPeriodsAndSlashes

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util FriendlyURLNormalizerUtil normalizeWithPeriodsAndSlashes.

Prototype

public static String normalizeWithPeriodsAndSlashes(String friendlyURL) 

Source Link

Usage

From source file:com.liferay.blogs.util.BlogsUtil.java

License:Open Source License

public static String getUrlTitle(long entryId, String title) {
    if (title == null) {
        return String.valueOf(entryId);
    }/*from  w  w w  .  j  a  v a 2 s.c o  m*/

    title = StringUtil.toLowerCase(title.trim());

    if (Validator.isNull(title) || Validator.isNumber(title) || title.equals("rss")) {

        title = String.valueOf(entryId);
    } else {
        title = FriendlyURLNormalizerUtil.normalizeWithPeriodsAndSlashes(title);
    }

    return ModelHintsUtil.trimString(BlogsEntry.class.getName(), "urlTitle", title);
}

From source file:com.liferay.journal.util.impl.JournalUtil.java

License:Open Source License

public static String getUrlTitle(long id, String title) {
    if (title == null) {
        return String.valueOf(id);
    }// w w  w  .ja v  a 2s .c o  m

    title = StringUtil.toLowerCase(title.trim());

    if (Validator.isNull(title) || Validator.isNumber(title) || title.equals("rss")) {

        title = String.valueOf(id);
    } else {
        title = FriendlyURLNormalizerUtil.normalizeWithPeriodsAndSlashes(title);
    }

    return ModelHintsUtil.trimString(JournalArticle.class.getName(), "urlTitle", title);
}

From source file:com.liferay.journal.verify.JournalServiceVerifyProcess.java

License:Open Source License

protected void verifyURLTitle() throws Exception {
    try (LoggingTimer loggingTimer = new LoggingTimer();
            PreparedStatement ps1 = connection
                    .prepareStatement("select distinct groupId, articleId, urlTitle from " + "JournalArticle");
            ResultSet rs = ps1.executeQuery()) {

        try (PreparedStatement ps2 = AutoBatchPreparedStatementUtil.autoBatch(connection
                .prepareStatement("update JournalArticle set urlTitle = ? where " + "urlTitle = ?"))) {

            while (rs.next()) {
                long groupId = rs.getLong("groupId");
                String articleId = rs.getString("articleId");
                String urlTitle = GetterUtil.getString(rs.getString("urlTitle"));

                String normalizedURLTitle = FriendlyURLNormalizerUtil.normalizeWithPeriodsAndSlashes(urlTitle);

                if (urlTitle.equals(normalizedURLTitle)) {
                    return;
                }/* w w w.  j  av a2s  .  c  o m*/

                normalizedURLTitle = _journalArticleLocalService.getUniqueUrlTitle(groupId, articleId,
                        normalizedURLTitle);

                ps2.setString(1, normalizedURLTitle);

                ps2.setString(2, urlTitle);

                ps2.addBatch();
            }

            ps2.executeBatch();
        }
    }
}