Example usage for com.liferay.portal.kernel.comment CommentManagerUtil addDiscussion

List of usage examples for com.liferay.portal.kernel.comment CommentManagerUtil addDiscussion

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.comment CommentManagerUtil addDiscussion.

Prototype

public static void addDiscussion(long userId, long groupId, String className, long classPK, String userName)
            throws PortalException 

Source Link

Usage

From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java

License:Open Source License

/**
 * @deprecated As of 7.0.0, with no direct replacement
 *//*from w  ww  . j  a  v  a2  s  .c  om*/
@Deprecated
protected void addDiscussion(BlogsEntry entry, long userId, long groupId) throws PortalException {

    if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) {
        CommentManagerUtil.addDiscussion(userId, groupId, BlogsEntry.class.getName(), entry.getEntryId(),
                entry.getUserName());
    }
}

From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java

License:Open Source License

@Override
public WikiPage addPage(long userId, long nodeId, String title, double version, String content, String summary,
        boolean minorEdit, String format, boolean head, String parentTitle, String redirectTitle,
        ServiceContext serviceContext) throws PortalException {

    // Page/*from  ww  w.  j a  v  a  2  s .co m*/

    User user = userPersistence.findByPrimaryKey(userId);
    WikiNode node = wikiNodePersistence.findByPrimaryKey(nodeId);
    Date now = new Date();

    long pageId = counterLocalService.increment();

    content = SanitizerUtil.sanitize(user.getCompanyId(), node.getGroupId(), userId, WikiPage.class.getName(),
            pageId, "text/" + format, content);

    validate(title, nodeId, content, format);

    long resourcePrimKey = wikiPageResourceLocalService.getPageResourcePrimKey(node.getGroupId(), nodeId,
            title);

    WikiPage page = wikiPagePersistence.create(pageId);

    page.setUuid(serviceContext.getUuid());
    page.setResourcePrimKey(resourcePrimKey);
    page.setGroupId(node.getGroupId());
    page.setCompanyId(user.getCompanyId());
    page.setUserId(user.getUserId());
    page.setUserName(user.getFullName());
    page.setNodeId(nodeId);
    page.setTitle(title);
    page.setVersion(version);
    page.setMinorEdit(minorEdit);
    page.setContent(content);
    page.setSummary(summary);
    page.setFormat(format);
    page.setHead(head);
    page.setParentTitle(parentTitle);
    page.setRedirectTitle(redirectTitle);
    page.setStatus(WorkflowConstants.STATUS_DRAFT);
    page.setStatusByUserId(userId);
    page.setStatusDate(serviceContext.getModifiedDate(now));
    page.setExpandoBridgeAttributes(serviceContext);

    wikiPagePersistence.update(page);

    // Resources

    if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {

        addPageResources(page, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions());
    } else {
        addPageResources(page, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions());
    }

    // Node

    node.setLastPostDate(serviceContext.getModifiedDate(now));

    wikiNodePersistence.update(node);

    // Asset

    updateAsset(userId, page, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(),
            serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority());

    // Message boards

    WikiGroupServiceOverriddenConfiguration wikiGroupServiceOverriddenConfiguration = configurationProvider
            .getConfiguration(WikiGroupServiceOverriddenConfiguration.class,
                    new GroupServiceSettingsLocator(node.getGroupId(), WikiConstants.SERVICE_NAME));

    if (wikiGroupServiceOverriddenConfiguration.pageCommentsEnabled()) {
        CommentManagerUtil.addDiscussion(userId, page.getGroupId(), WikiPage.class.getName(), resourcePrimKey,
                page.getUserName());
    }

    // Workflow

    page = startWorkflowInstance(userId, page, serviceContext);

    return page;
}

From source file:net.indaba.lostandfound.service.impl.ItemLocalServiceImpl.java

License:Open Source License

public Item addOrUpdateItem(Item item, ServiceContext serviceContext) throws PortalException {
    _log.debug("addOrUpdateItem");

    if (item.isNew()) {
        _log.debug("is a new item");
        item.setItemId(CounterLocalServiceUtil.increment());
        item.setCreateDate(new Date());
        item = super.addItem(item);
        CommentManagerUtil.addDiscussion(serviceContext.getUserId(), serviceContext.getScopeGroupId(),
                Item.class.getName(), item.getPrimaryKey(), null);
    } else {//  w w w  .ja va  2 s.  co m
        _log.debug("updating item");
        item = super.updateItem(item);
    }

    /* UserId needs to be set on REST API calls */
    AssetEntry assetEntry = updateAsset(serviceContext.getUserId(), item, serviceContext.getAssetCategoryIds(),
            serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext);
    if (updateFirebase(item, serviceContext)) {
        try {
            Future<String> firebaseKey = getFbService().addOrUpdate(item, null);
            List<AssetCategory> categories = AssetCategoryLocalServiceUtil
                    .getAssetEntryAssetCategories(assetEntry.getEntryId());
            AssetCategory category = null;
            if (!categories.isEmpty())
                category = categories.get(0);
            FirebaseService<AssetCategory> fbCatService = FirebaseSynchronizer.getInstance()
                    .getService(AssetCategory.class);
            getFbService().setRelationManyToOne(item, category, fbCatService, firebaseKey);
        } catch (Exception e) {
            _log.error("Error updating item " + item.getItemId(), e);
        }
    }

    Indexer<Item> indexer = IndexerRegistryUtil.nullSafeGetIndexer(Item.class);
    indexer.reindex(item);

    return item;
}