Example usage for com.liferay.portal.kernel.util DateUtil newDate

List of usage examples for com.liferay.portal.kernel.util DateUtil newDate

Introduction

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

Prototype

public static Date newDate(long date) 

Source Link

Usage

From source file:com.liferay.social.activity.customizer.interpreter.CustomWikiActivityInterpreter.java

License:Open Source License

@Override
protected String getBody(SocialActivity activity, ServiceContext serviceContext) throws Exception {

    // Date//from www  .j ava2  s .  co m

    Date createDate = DateUtil.newDate(activity.getCreateDate());

    // View count

    WikiPageResource pageResource = _wikiPageResourceLocalService.getWikiPageResource(activity.getClassPK());

    AssetEntry assetEntry = _assetEntryLocalService.fetchEntry(WikiPage.class.getName(),
            pageResource.getPrimaryKey());

    int viewCount = assetEntry.getViewCount();

    // Excerpt

    String summary = StringPool.BLANK;

    try {
        AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil
                .getAssetRendererFactoryByClassName(WikiPage.class.getName());

        AssetRenderer<?> assetRenderer = assetRendererFactory.getAssetRenderer(activity.getClassPK());

        summary = assetRenderer.getSearchSummary(serviceContext.getLocale());
    } catch (Exception e) {
        _log.error("Cannot create summary", e);
    }

    // Tags

    List<AssetTag> tags = assetEntry.getTags();

    return _getFormattedBody(createDate, viewCount, summary, tags, serviceContext);
}