Example usage for com.liferay.portal.util PropsValues LAYOUT_COMMENTS_ENABLED

List of usage examples for com.liferay.portal.util PropsValues LAYOUT_COMMENTS_ENABLED

Introduction

In this page you can find the example usage for com.liferay.portal.util PropsValues LAYOUT_COMMENTS_ENABLED.

Prototype

boolean LAYOUT_COMMENTS_ENABLED

To view the source code for com.liferay.portal.util PropsValues LAYOUT_COMMENTS_ENABLED.

Click Source Link

Usage

From source file:com.liferay.message.boards.internal.exportimport.data.handler.MBDiscussionStagedModelDataHandler.java

License:Open Source License

@Override
protected void doImportStagedModel(PortletDataContext portletDataContext, MBDiscussion discussion)
        throws Exception {

    long userId = portletDataContext.getUserId(discussion.getUserUuid());

    String className = discussion.getClassName();

    Map<Long, Long> relatedClassPKs = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(className);

    long newClassPK = MapUtil.getLong(relatedClassPKs, discussion.getClassPK(), discussion.getClassPK());

    MBDiscussion existingDiscussion = _mbDiscussionLocalService.fetchDiscussion(discussion.getClassName(),
            newClassPK);//w ww.  jav a 2s .c o m

    if (existingDiscussion == null) {
        if (className.equals(Layout.class.getName()) && PropsValues.LAYOUT_COMMENTS_ENABLED) {

            MBMessage rootMessage = _mbMessageLocalService.addDiscussionMessage(userId,
                    discussion.getUserName(), portletDataContext.getScopeGroupId(), className, newClassPK,
                    WorkflowConstants.ACTION_PUBLISH);

            existingDiscussion = _mbDiscussionLocalService.getThreadDiscussion(rootMessage.getThreadId());
        } else {
            StringBundler sb = new StringBundler(4);

            sb.append("No discussion exists for class name ");
            sb.append(discussion.getClassName());
            sb.append(" and class PK ");
            sb.append(newClassPK);

            throw new NoSuchDiscussionException(sb.toString());
        }
    }

    Map<Long, Long> discussionIds = (Map<Long, Long>) portletDataContext
            .getNewPrimaryKeysMap(MBDiscussion.class);

    discussionIds.put(discussion.getDiscussionId(), existingDiscussion.getDiscussionId());

    Map<Long, Long> threadIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(MBThread.class);

    threadIds.put(discussion.getThreadId(), existingDiscussion.getThreadId());
}