Example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED.

Prototype

int STATUS_APPROVED

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED.

Click Source Link

Usage

From source file:com.liferay.mentions.internal.service.MentionsBlogsEntryServiceWrapper.java

License:Open Source License

@Override
public BlogsEntry updateStatus(long userId, long entryId, int status, ServiceContext serviceContext,
        Map<String, Serializable> workflowContext) throws PortalException {

    BlogsEntry entry = _blogsEntryLocalService.getEntry(entryId);

    int oldStatus = entry.getStatus();

    entry = super.updateStatus(userId, entryId, status, serviceContext, workflowContext);

    if ((status != WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_IN_TRASH)) {

        return entry;
    }/*from w  w w. j av  a  2  s  .  co m*/

    long siteGroupId = _portal.getSiteGroupId(entry.getGroupId());

    if (!MentionsUtil.isMentionsEnabled(siteGroupId)) {
        return entry;
    }

    String contentURL = (String) serviceContext.getAttribute("contentURL");

    if (Validator.isNull(contentURL)) {
        serviceContext.setAttribute("contentURL", workflowContext.get("url"));
    }

    MentionsGroupServiceConfiguration mentionsGroupServiceConfiguration = _configurationProvider
            .getCompanyConfiguration(MentionsGroupServiceConfiguration.class, entry.getCompanyId());

    _mentionsNotifier.notify(userId, entry.getGroupId(), entry.getTitle(), entry.getContent(),
            BlogsEntry.class.getName(), entry.getEntryId(),
            mentionsGroupServiceConfiguration.assetEntryMentionEmailSubject(),
            mentionsGroupServiceConfiguration.assetEntryMentionEmailBody(), serviceContext);

    return entry;
}

From source file:com.liferay.mentions.internal.service.MentionsMessageServiceWrapper.java

License:Open Source License

@Override
public MBMessage updateStatus(long userId, long messageId, int status, ServiceContext serviceContext,
        Map<String, Serializable> workflowContext) throws PortalException {

    MBMessage message = _mbMessageLocalService.getMessage(messageId);

    int oldStatus = message.getStatus();

    message = super.updateStatus(userId, messageId, status, serviceContext, workflowContext);

    if ((status != WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_IN_TRASH)) {

        return message;
    }// www. jav  a 2 s.co m

    long siteGroupId = _portal.getSiteGroupId(message.getGroupId());

    if (!MentionsUtil.isMentionsEnabled(siteGroupId)) {
        return message;
    }

    String content = message.getBody();

    if (message.isFormatBBCode()) {
        content = BBCodeTranslatorUtil.getHTML(content);
    }

    String title = message.getSubject();

    if (message.isDiscussion()) {
        title = StringUtil.shorten(HtmlUtil.extractText(content), 100);
    }

    MentionsGroupServiceConfiguration mentionsGroupServiceConfiguration = _configurationProvider
            .getCompanyConfiguration(MentionsGroupServiceConfiguration.class, message.getCompanyId());

    LocalizedValuesMap subjectLocalizedValuesMap = mentionsGroupServiceConfiguration
            .commentMentionEmailSubject();
    LocalizedValuesMap bodyLocalizedValuesMap = mentionsGroupServiceConfiguration.commentMentionEmailBody();

    if (!message.isDiscussion()) {
        subjectLocalizedValuesMap = mentionsGroupServiceConfiguration.assetEntryMentionEmailSubject();
        bodyLocalizedValuesMap = mentionsGroupServiceConfiguration.assetEntryMentionEmailBody();
    }

    String contentURL = (String) serviceContext.getAttribute("contentURL");

    if (Validator.isNull(contentURL)) {
        serviceContext.setAttribute("contentURL", workflowContext.get("url"));
    }

    _mentionsNotifier.notify(userId, message.getGroupId(), title, content, message.getModelClassName(),
            message.getMessageId(), subjectLocalizedValuesMap, bodyLocalizedValuesMap, serviceContext);

    return message;
}

From source file:com.liferay.mentions.internal.service.MentionsWikiPageServiceWrapper.java

License:Open Source License

@Override
public WikiPage updateStatus(long userId, WikiPage page, int status, ServiceContext serviceContext,
        Map<String, Serializable> workflowContext) throws PortalException {

    int oldStatus = page.getStatus();

    page = super.updateStatus(userId, page, status, serviceContext, workflowContext);

    WikiGroupServiceOverriddenConfiguration wikiGroupServiceOverriddenConfiguration = _configurationProvider
            .getConfiguration(WikiGroupServiceOverriddenConfiguration.class,
                    new GroupServiceSettingsLocator(page.getGroupId(), WikiConstants.SERVICE_NAME));

    // Subscriptions

    if (status == WorkflowConstants.STATUS_APPROVED) {
        if (NotificationThreadLocal.isEnabled()
                && (!page.isMinorEdit() || wikiGroupServiceOverriddenConfiguration.pageMinorEditSendEmail())) {

            notifySubscribers(userId, page, (String) workflowContext.get(WorkflowConstants.CONTEXT_URL),
                    serviceContext);/*from   w ww .  ja  v  a2 s.  co  m*/
        }
    }

    if ((status != WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_IN_TRASH)) {

        return page;
    }

    long siteGroupId = PortalUtil.getSiteGroupId(page.getGroupId());

    if (!MentionsUtil.isMentionsEnabled(siteGroupId)) {
        return page;
    }

    String contentURL = (String) serviceContext.getAttribute("contentURL");

    if (Validator.isNull(contentURL)) {
        serviceContext.setAttribute("contentURL", workflowContext.get("url"));
    }

    String portalURL = serviceContext.getPortalURL();

    String attachmentURLPrefix = WikiUtil.getAttachmentURLPrefix(serviceContext.getPathMain(),
            serviceContext.getPlid(), page.getNodeId(), page.getTitle());

    attachmentURLPrefix = portalURL + attachmentURLPrefix;

    String pageContent = _wikiEngineRenderer.convert(page, null, null, attachmentURLPrefix);

    MentionsGroupServiceConfiguration mentionsGroupServiceConfiguration = _configurationProvider
            .getCompanyConfiguration(MentionsGroupServiceConfiguration.class, page.getCompanyId());

    _mentionsNotifier.notify(page.getUserId(), page.getGroupId(), page.getTitle(), pageContent,
            WikiPage.class.getName(), page.getPageId(),
            mentionsGroupServiceConfiguration.assetEntryMentionEmailSubject(),
            mentionsGroupServiceConfiguration.assetEntryMentionEmailBody(), serviceContext);

    return page;
}

From source file:com.liferay.mentions.internal.util.DefaultMentionsUserFinder.java

License:Open Source License

@Override
public List<User> getUsers(long companyId, long userId, String query,
        SocialInteractionsConfiguration socialInteractionsConfiguration) throws PortalException {

    if (socialInteractionsConfiguration.isSocialInteractionsAnyUserEnabled()) {

        LinkedHashMap<String, Object> params = new LinkedHashMap<>();

        params.put("wildcardMode", WildcardMode.TRAILING);

        return _userLocalService.search(companyId, query, WorkflowConstants.STATUS_APPROVED, params, 0,
                _MAX_USERS, new UserScreenNameComparator());
    }//from  ww  w  . j a  v a2 s  . c om

    User user = _userLocalService.getUser(userId);

    int[] types = { SocialRelationConstants.TYPE_BI_FRIEND };

    if (socialInteractionsConfiguration.isSocialInteractionsFriendsEnabled()
            && socialInteractionsConfiguration.isSocialInteractionsSitesEnabled()) {

        return _userLocalService.searchSocial(user.getGroupIds(), userId, types, query, 0, _MAX_USERS);
    }

    if (socialInteractionsConfiguration.isSocialInteractionsSitesEnabled()) {

        return _userLocalService.searchSocial(companyId, user.getGroupIds(), query, 0, _MAX_USERS);
    }

    if (socialInteractionsConfiguration.isSocialInteractionsFriendsEnabled()) {

        return _userLocalService.searchSocial(userId, types, query, 0, _MAX_USERS);
    }

    return Collections.emptyList();
}

From source file:com.liferay.mentions.util.DefaultMentionsUserFinderImpl.java

License:Open Source License

@Override
public List<User> getUsers(long companyId, long userId, String query,
        SocialInteractionsConfiguration socialInteractionsConfiguration) throws PortalException {

    if (socialInteractionsConfiguration.isSocialInteractionsAnyUserEnabled()) {

        LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>();

        params.put("wildcardMode", WildcardMode.TRAILING);

        return UserLocalServiceUtil.search(companyId, query, WorkflowConstants.STATUS_APPROVED, params, 0,
                _MAX_USERS, new UserScreenNameComparator());
    }//from  www . j a v a2 s  .co m

    User user = UserLocalServiceUtil.getUser(userId);

    int[] types = socialInteractionsConfiguration.getSocialInteractionsSocialRelationTypesArray();

    if (socialInteractionsConfiguration.isSocialInteractionsSocialRelationTypesEnabled()
            && socialInteractionsConfiguration.isSocialInteractionsSitesEnabled()) {

        return UserLocalServiceUtil.searchSocial(user.getGroupIds(), userId, types, query, QueryUtil.ALL_POS,
                QueryUtil.ALL_POS);
    }

    if (socialInteractionsConfiguration.isSocialInteractionsSitesEnabled()) {

        return UserLocalServiceUtil.searchSocial(companyId, user.getGroupIds(), query, QueryUtil.ALL_POS,
                QueryUtil.ALL_POS);
    }

    if (socialInteractionsConfiguration.isSocialInteractionsSocialRelationTypesEnabled()) {

        return UserLocalServiceUtil.searchSocial(userId, types, query, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
    }

    return Collections.emptyList();
}

From source file:com.liferay.message.boards.comment.internal.MBCommentManagerImpl.java

License:Open Source License

@Override
public long addComment(long userId, long groupId, String className, long classPK, String body,
        Function<String, ServiceContext> serviceContextFunction) throws PortalException {

    MBMessageDisplay messageDisplay = _mbMessageLocalService.getDiscussionMessageDisplay(userId, groupId,
            className, classPK, WorkflowConstants.STATUS_APPROVED);

    MBThread thread = messageDisplay.getThread();

    List<MBMessage> messages = _mbMessageLocalService.getThreadMessages(thread.getThreadId(),
            WorkflowConstants.STATUS_APPROVED);

    for (MBMessage message : messages) {
        String messageBody = message.getBody();

        if (messageBody.equals(body)) {
            throw new DuplicateCommentException(body);
        }//from w  w  w .j av  a 2 s.  c  o  m
    }

    ServiceContext serviceContext = serviceContextFunction.apply(MBMessage.class.getName());

    MBMessage mbMessage = _mbMessageLocalService.addDiscussionMessage(userId, StringPool.BLANK, groupId,
            className, classPK, thread.getThreadId(), thread.getRootMessageId(), StringPool.BLANK, body,
            serviceContext);

    return mbMessage.getMessageId();
}

From source file:com.liferay.message.boards.comment.internal.MBCommentManagerImpl.java

License:Open Source License

@Override
public long addComment(long userId, long groupId, String className, long classPK, String userName,
        String subject, String body, Function<String, ServiceContext> serviceContextFunction)
        throws PortalException {

    MBMessageDisplay mbMessageDisplay = _mbMessageLocalService.getDiscussionMessageDisplay(userId, groupId,
            className, classPK, WorkflowConstants.STATUS_APPROVED);

    MBThread mbThread = mbMessageDisplay.getThread();

    ServiceContext serviceContext = serviceContextFunction.apply(MBMessage.class.getName());

    MBMessage mbMessage = _mbMessageLocalService.addDiscussionMessage(userId, userName, groupId, className,
            classPK, mbThread.getThreadId(), mbThread.getRootMessageId(), subject, body, serviceContext);

    return mbMessage.getMessageId();
}

From source file:com.liferay.message.boards.comment.internal.MBCommentManagerImpl.java

License:Open Source License

@Override
public int getCommentsCount(String className, long classPK) {
    long classNameId = PortalUtil.getClassNameId(className);

    return _mbMessageLocalService.getDiscussionMessagesCount(classNameId, classPK,
            WorkflowConstants.STATUS_APPROVED);
}

From source file:com.liferay.message.boards.comment.internal.MBCommentManagerImpl.java

License:Open Source License

@Override
public void moveDiscussionToTrash(String className, long classPK) {
    List<MBMessage> messages = _mbMessageLocalService.getMessages(className, classPK,
            WorkflowConstants.STATUS_APPROVED);

    for (MBMessage message : messages) {
        message.setStatus(WorkflowConstants.STATUS_IN_TRASH);

        _mbMessageLocalService.updateMBMessage(message);
    }/*  w w  w .  j a v  a 2s  . c  om*/
}

From source file:com.liferay.message.boards.comment.internal.MBCommentManagerImpl.java

License:Open Source License

@Override
public void restoreDiscussionFromTrash(String className, long classPK) {
    List<MBMessage> messages = _mbMessageLocalService.getMessages(className, classPK,
            WorkflowConstants.STATUS_IN_TRASH);

    for (MBMessage message : messages) {
        message.setStatus(WorkflowConstants.STATUS_APPROVED);

        _mbMessageLocalService.updateMBMessage(message);
    }//w w w .ja  va2  s . c om
}