Example usage for com.liferay.portal.kernel.diff CompareVersionsException CompareVersionsException

List of usage examples for com.liferay.portal.kernel.diff CompareVersionsException CompareVersionsException

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.diff CompareVersionsException CompareVersionsException.

Prototype

public CompareVersionsException(Throwable cause) 

Source Link

Usage

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

License:Open Source License

public static String diffHtml(long groupId, String articleId, double sourceVersion, double targetVersion,
        String languageId, PortletRequestModel portletRequestModel, ThemeDisplay themeDisplay)
        throws Exception {

    JournalArticle sourceArticle = JournalArticleLocalServiceUtil.getArticle(groupId, articleId, sourceVersion);

    if (!JournalArticleLocalServiceUtil.isRenderable(sourceArticle, portletRequestModel, themeDisplay)) {

        throw new CompareVersionsException(sourceVersion);
    }/*from   www . j  av  a2s. c om*/

    JournalArticleDisplay sourceArticleDisplay = JournalArticleLocalServiceUtil.getArticleDisplay(sourceArticle,
            null, Constants.VIEW, languageId, 1, portletRequestModel, themeDisplay);

    JournalArticle targetArticle = JournalArticleLocalServiceUtil.getArticle(groupId, articleId, targetVersion);

    if (!JournalArticleLocalServiceUtil.isRenderable(targetArticle, portletRequestModel, themeDisplay)) {

        throw new CompareVersionsException(targetVersion);
    }

    JournalArticleDisplay targetArticleDisplay = JournalArticleLocalServiceUtil.getArticleDisplay(targetArticle,
            null, Constants.VIEW, languageId, 1, portletRequestModel, themeDisplay);

    return DiffHtmlUtil.diff(new UnsyncStringReader(sourceArticleDisplay.getContent()),
            new UnsyncStringReader(targetArticleDisplay.getContent()));
}