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

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

Introduction

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

Prototype

boolean BLOGS_ENTRY_COMMENTS_ENABLED

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

Click Source Link

Usage

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

License:Open Source License

@Indexable(type = IndexableType.REINDEX)
@Override//  w ww  .j a  v  a2 s.co  m
public BlogsEntry updateStatus(long userId, long entryId, int status, ServiceContext serviceContext,
        Map<String, Serializable> workflowContext) throws PortalException {

    // Entry

    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();

    BlogsEntry entry = blogsEntryPersistence.findByPrimaryKey(entryId);

    int oldStatus = entry.getStatus();

    if ((status == WorkflowConstants.STATUS_APPROVED) && now.before(entry.getDisplayDate())) {

        status = WorkflowConstants.STATUS_SCHEDULED;
    }

    entry.setStatus(status);
    entry.setStatusByUserId(user.getUserId());
    entry.setStatusByUserName(user.getFullName());
    entry.setStatusDate(serviceContext.getModifiedDate(now));

    if ((status == WorkflowConstants.STATUS_APPROVED) && Validator.isNull(entry.getUrlTitle())) {

        entry.setUrlTitle(getUniqueUrlTitle(entryId, entry.getGroupId(), entry.getTitle()));
    }

    blogsEntryPersistence.update(entry);

    // Statistics

    blogsStatsUserLocalService.updateStatsUser(entry.getGroupId(), entry.getUserId(), entry.getDisplayDate());

    AssetEntry assetEntry = assetEntryLocalService.fetchEntry(BlogsEntry.class.getName(), entryId);

    if ((assetEntry == null) || (assetEntry.getPublishDate() == null)) {
        serviceContext.setCommand(Constants.ADD);
    }

    JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();

    extraDataJSONObject.put("title", entry.getTitle());

    if (status == WorkflowConstants.STATUS_APPROVED) {

        // Asset

        assetEntryLocalService.updateEntry(BlogsEntry.class.getName(), entryId, entry.getDisplayDate(), null,
                true, true);

        // Social

        if ((oldStatus != WorkflowConstants.STATUS_IN_TRASH)
                && (oldStatus != WorkflowConstants.STATUS_SCHEDULED)) {

            if (serviceContext.isCommandUpdate()) {
                SocialActivityManagerUtil.addActivity(user.getUserId(), entry, BlogsActivityKeys.UPDATE_ENTRY,
                        extraDataJSONObject.toString(), 0);
            } else {
                SocialActivityManagerUtil.addUniqueActivity(user.getUserId(), entry,
                        BlogsActivityKeys.ADD_ENTRY, extraDataJSONObject.toString(), 0);
            }
        }

        // Trash

        if (oldStatus == WorkflowConstants.STATUS_IN_TRASH) {
            if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) {
                CommentManagerUtil.restoreDiscussionFromTrash(BlogsEntry.class.getName(), entryId);
            }

            trashEntryLocalService.deleteEntry(BlogsEntry.class.getName(), entryId);
        }

        if (oldStatus != WorkflowConstants.STATUS_IN_TRASH) {

            // Subscriptions

            notifySubscribers(userId, entry, serviceContext, workflowContext);

            // Ping

            String[] trackbacks = (String[]) serviceContext.getAttribute("trackbacks");
            Boolean pingOldTrackbacks = ParamUtil.getBoolean(serviceContext, "pingOldTrackbacks");

            pingGoogle(entry, serviceContext);
            pingPingback(entry, serviceContext);
            pingTrackbacks(entry, trackbacks, pingOldTrackbacks, serviceContext);
        }
    } else {

        // Asset

        assetEntryLocalService.updateVisible(BlogsEntry.class.getName(), entryId, false);

        // Social

        if ((status == WorkflowConstants.STATUS_SCHEDULED)
                && (oldStatus != WorkflowConstants.STATUS_IN_TRASH)) {

            if (serviceContext.isCommandUpdate()) {
                SocialActivityManagerUtil.addActivity(user.getUserId(), entry, BlogsActivityKeys.UPDATE_ENTRY,
                        extraDataJSONObject.toString(), 0);
            } else {
                SocialActivityManagerUtil.addUniqueActivity(user.getUserId(), entry,
                        BlogsActivityKeys.ADD_ENTRY, extraDataJSONObject.toString(), 0);
            }
        }

        // Trash

        if (status == WorkflowConstants.STATUS_IN_TRASH) {
            if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) {
                CommentManagerUtil.moveDiscussionToTrash(BlogsEntry.class.getName(), entryId);
            }

            trashEntryLocalService.addTrashEntry(userId, entry.getGroupId(), BlogsEntry.class.getName(),
                    entry.getEntryId(), entry.getUuid(), null, oldStatus, null, null);
        } else if (oldStatus == WorkflowConstants.STATUS_IN_TRASH) {
            if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) {
                CommentManagerUtil.restoreDiscussionFromTrash(BlogsEntry.class.getName(), entryId);
            }

            trashEntryLocalService.deleteEntry(BlogsEntry.class.getName(), entryId);
        }
    }

    return entry;
}

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.  ja v a 2 s . c  o m
@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.blogs.web.asset.BlogsEntryAssetRenderer.java

License:Open Source License

@Override
public String getDiscussionPath() {
    if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) {
        return "edit_entry_discussion";
    } else {//from   w ww  .  j a v a2  s.  c o m
        return null;
    }
}

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

License:Open Source License

public BlogsEntry addEntry(long userId, String title, String description, String content, int displayDateMonth,
        int displayDateDay, int displayDateYear, int displayDateHour, int displayDateMinute,
        boolean allowPingbacks, boolean allowTrackbacks, String[] trackbacks, boolean smallImage,
        String smallImageURL, String smallImageFileName, InputStream smallImageInputStream,
        ServiceContext serviceContext) throws PortalException, SystemException {

    // Entry/*from w ww  . j  av a  2s .  c o m*/

    User user = userPersistence.findByPrimaryKey(userId);
    long groupId = serviceContext.getScopeGroupId();

    Date displayDate = PortalUtil.getDate(displayDateMonth, displayDateDay, displayDateYear, displayDateHour,
            displayDateMinute, user.getTimeZone(), new EntryDisplayDateException());

    byte[] smallImageBytes = null;

    try {
        if ((smallImageInputStream != null) && smallImage) {
            smallImageBytes = FileUtil.getBytes(smallImageInputStream);
        }
    } catch (IOException ioe) {
    }

    Date now = new Date();

    validate(title, content, smallImage, smallImageURL, smallImageFileName, smallImageBytes);

    long entryId = counterLocalService.increment();

    BlogsEntry entry = blogsEntryPersistence.create(entryId);

    entry.setUuid(serviceContext.getUuid());
    entry.setGroupId(groupId);
    entry.setCompanyId(user.getCompanyId());
    entry.setUserId(user.getUserId());
    entry.setUserName(user.getFullName());
    entry.setCreateDate(serviceContext.getCreateDate(now));
    entry.setModifiedDate(serviceContext.getModifiedDate(now));
    entry.setTitle(title);
    entry.setUrlTitle(getUniqueUrlTitle(entryId, groupId, title));
    entry.setDescription(description);
    entry.setContent(content);
    entry.setDisplayDate(displayDate);
    entry.setAllowPingbacks(allowPingbacks);
    entry.setAllowTrackbacks(allowTrackbacks);
    entry.setSmallImage(smallImage);
    entry.setSmallImageId(counterLocalService.increment());
    entry.setSmallImageURL(smallImageURL);
    entry.setStatus(WorkflowConstants.STATUS_DRAFT);
    entry.setStatusDate(serviceContext.getModifiedDate(now));
    entry.setExpandoBridgeAttributes(serviceContext);

    blogsEntryPersistence.update(entry, false);

    // Resources

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

        addEntryResources(entry, serviceContext.isAddGroupPermissions(),
                serviceContext.isAddGuestPermissions());
    } else {
        addEntryResources(entry, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions());
    }

    // Small image

    saveImages(smallImage, entry.getSmallImageId(), smallImageBytes);

    // Asset

    updateAsset(userId, entry, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(),
            serviceContext.getAssetLinkEntryIds());

    // Message boards

    if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) {
        mbMessageLocalService.addDiscussionMessage(userId, entry.getUserName(), groupId,
                BlogsEntry.class.getName(), entryId, WorkflowConstants.ACTION_PUBLISH);
    }

    // Workflow

    if ((trackbacks != null) && (trackbacks.length > 0)) {
        serviceContext.setAttribute("trackbacks", trackbacks);
    } else {
        serviceContext.setAttribute("trackbacks", null);
    }

    WorkflowHandlerRegistryUtil.startWorkflowInstance(user.getCompanyId(), groupId, userId,
            BlogsEntry.class.getName(), entry.getEntryId(), entry, serviceContext);

    return entry;
}