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

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

Introduction

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

Prototype

int STATUS_ANY

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

Click Source Link

Usage

From source file:com.liferay.message.boards.web.internal.display.context.DefaultMBListDisplayContext.java

License:Open Source License

@Override
public void populateResultsAndTotal(SearchContainer searchContainer) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    if (isShowSearch()) {
        long searchCategoryId = ParamUtil.getLong(_request, "searchCategoryId");

        long[] categoryIdsArray = null;

        List categoryIds = new ArrayList();

        categoryIds.add(Long.valueOf(searchCategoryId));

        MBCategoryServiceUtil.getSubcategoryIds(categoryIds, themeDisplay.getScopeGroupId(), searchCategoryId);

        categoryIdsArray = StringUtil.split(StringUtil.merge(categoryIds), 0L);

        Indexer indexer = IndexerRegistryUtil.getIndexer(MBMessage.class);

        SearchContext searchContext = SearchContextFactory.getInstance(_request);

        searchContext.setAttribute("paginationType", "more");
        searchContext.setCategoryIds(categoryIdsArray);
        searchContext.setEnd(searchContainer.getEnd());
        searchContext.setIncludeAttachments(true);

        String keywords = ParamUtil.getString(_request, "keywords");

        searchContext.setKeywords(keywords);

        searchContext.setStart(searchContainer.getStart());

        Hits hits = indexer.search(searchContext);

        searchContainer.setResults(SearchResultUtil.getSearchResults(hits, _request.getLocale()));

        searchContainer.setSearch(true);
        searchContainer.setTotal(hits.getLength());
    } else if (isShowRecentPosts()) {
        searchContainer.setEmptyResultsMessage("there-are-no-recent-posts");

        long groupThreadsUserId = ParamUtil.getLong(_request, "groupThreadsUserId");

        Calendar calendar = Calendar.getInstance();

        MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings
                .getInstance(themeDisplay.getSiteGroupId());

        int offset = GetterUtil.getInteger(mbGroupServiceSettings.getRecentPostsDateOffset());

        calendar.add(Calendar.DATE, -offset);

        searchContainer.setTotal(MBThreadServiceUtil.getGroupThreadsCount(themeDisplay.getScopeGroupId(),
                groupThreadsUserId, calendar.getTime(), WorkflowConstants.STATUS_APPROVED));
        searchContainer.setResults(MBThreadServiceUtil.getGroupThreads(themeDisplay.getScopeGroupId(),
                groupThreadsUserId, calendar.getTime(), WorkflowConstants.STATUS_APPROVED,
                searchContainer.getStart(), searchContainer.getEnd()));
    } else if (isShowMyPosts()) {
        long groupThreadsUserId = ParamUtil.getLong(_request, "groupThreadsUserId");

        if (themeDisplay.isSignedIn()) {
            groupThreadsUserId = themeDisplay.getUserId();
        }/*w  w  w  .  ja  v a  2 s .co  m*/

        int status = WorkflowConstants.STATUS_ANY;

        searchContainer.setTotal(MBThreadServiceUtil.getGroupThreadsCount(themeDisplay.getScopeGroupId(),
                groupThreadsUserId, status));
        searchContainer.setResults(MBThreadServiceUtil.getGroupThreads(themeDisplay.getScopeGroupId(),
                groupThreadsUserId, status, searchContainer.getStart(), searchContainer.getEnd()));
        searchContainer.setEmptyResultsMessage("you-do-not-have-any-posts");
    } else {
        int status = WorkflowConstants.STATUS_APPROVED;

        PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

        if (permissionChecker.isContentReviewer(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId())) {

            status = WorkflowConstants.STATUS_ANY;
        }

        searchContainer.setTotal(MBCategoryLocalServiceUtil
                .getCategoriesAndThreadsCount(themeDisplay.getScopeGroupId(), _categoryId, status));
        searchContainer.setResults(MBCategoryServiceUtil.getCategoriesAndThreads(themeDisplay.getScopeGroupId(),
                _categoryId, status, searchContainer.getStart(), searchContainer.getEnd()));
    }
}

From source file:com.liferay.message.boards.web.internal.portlet.action.ActionUtil.java

License:Open Source License

public static MBMessageDisplay getMessageDisplay(HttpServletRequest request) throws PortalException {

    long messageId = ParamUtil.getLong(request, "messageId");

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    int status = WorkflowConstants.STATUS_APPROVED;

    if (permissionChecker.isContentReviewer(themeDisplay.getUserId(), themeDisplay.getScopeGroupId())) {

        status = WorkflowConstants.STATUS_ANY;
    }/*ww w.  j  a  v a 2  s .c  o m*/

    MBMessageDisplay messageDisplay = MBMessageServiceUtil.getMessageDisplay(messageId, status);

    if (messageDisplay != null) {
        MBMessage message = messageDisplay.getMessage();

        if ((message != null) && message.isInTrash()) {
            throw new NoSuchMessageException("{messageId=" + messageId + "}");
        }
    }

    return messageDisplay;
}

From source file:com.liferay.message.boards.web.internal.security.permission.MBPermissionPropagatorImpl.java

License:Open Source License

protected void propagateCategoryRolePermissions(final ActionRequest actionRequest, final String className,
        String primKey, final long[] roleIds) throws PortalException {

    final long categoryId = GetterUtil.getLong(primKey);

    MBCategory category = _mbCategoryLocalService.getCategory(categoryId);

    List<Object> categoriesAndThreads = _mbCategoryLocalService.getCategoriesAndThreads(category.getGroupId(),
            categoryId);/*  www  .j  a v a  2 s .co  m*/

    for (Object categoryOrThread : categoriesAndThreads) {
        if (categoryOrThread instanceof MBThread) {
            MBThread thread = (MBThread) categoryOrThread;

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

            for (MBMessage message : messages) {
                propagateMessageRolePermissions(actionRequest, className, categoryId, message.getMessageId(),
                        roleIds);
            }
        } else {
            category = (MBCategory) categoryOrThread;

            List<Long> categoryIds = new ArrayList<>();

            categoryIds.add(category.getCategoryId());

            categoryIds = _mbCategoryLocalService.getSubcategoryIds(categoryIds, category.getGroupId(),
                    category.getCategoryId());

            for (final long addCategoryId : categoryIds) {
                propagateCategoryRolePermissions(actionRequest, className, categoryId, addCategoryId, roleIds);

                ActionableDynamicQuery actionableDynamicQuery = _mbMessageLocalService
                        .getActionableDynamicQuery();

                actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

                    @Override
                    public void addCriteria(DynamicQuery dynamicQuery) {
                        Property categoryIdProperty = PropertyFactoryUtil.forName("categoryId");

                        dynamicQuery.add(categoryIdProperty.eq(addCategoryId));
                    }

                });
                actionableDynamicQuery.setGroupId(category.getGroupId());
                actionableDynamicQuery
                        .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<MBMessage>() {

                            @Override
                            public void performAction(MBMessage message) throws PortalException {

                                propagateMessageRolePermissions(actionRequest, className, categoryId,
                                        message.getMessageId(), roleIds);
                            }

                        });

                actionableDynamicQuery.performActions();
            }
        }
    }
}

From source file:com.liferay.message.boards.web.internal.security.permission.MBPermissionPropagatorImpl.java

License:Open Source License

protected void propagateThreadRolePermissions(ActionRequest actionRequest, String className, long messageId,
        long threadId, long[] roleIds) throws PortalException {

    List<MBMessage> messages = _mbMessageLocalService.getThreadMessages(threadId, WorkflowConstants.STATUS_ANY);

    for (MBMessage message : messages) {
        propagateMessageRolePermissions(actionRequest, className, messageId, message.getMessageId(), roleIds);
    }/* w ww . ja v a  2s .co  m*/
}

From source file:com.liferay.message.boards.web.internal.trash.MBThreadTrashRenderer.java

License:Open Source License

@Override
public boolean include(HttpServletRequest request, HttpServletResponse response, String template)
        throws Exception {

    MBMessageDisplay messageDisplay = MBMessageServiceUtil.getMessageDisplay(_rootMessage.getMessageId(),
            WorkflowConstants.STATUS_ANY);

    request.setAttribute(WebKeys.MESSAGE_BOARDS_MESSAGE_DISPLAY, messageDisplay);

    MBTreeWalker treeWalker = messageDisplay.getTreeWalker();

    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER, treeWalker);

    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_CATEGORY, messageDisplay.getCategory());
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_CUR_MESSAGE, treeWalker.getRoot());
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_DEPTH, Integer.valueOf(0));
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_LAST_NODE, Boolean.FALSE);
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_SEL_MESSAGE, _rootMessage);
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_THREAD, messageDisplay.getThread());

    return super.include(request, response, template);
}

From source file:com.liferay.message.boards.web.trash.MBThreadTrashRenderer.java

License:Open Source License

@Override
public boolean include(HttpServletRequest request, HttpServletResponse response, String template)
        throws Exception {

    MBMessageDisplay messageDisplay = MBMessageServiceUtil.getMessageDisplay(_rootMessage.getMessageId(),
            WorkflowConstants.STATUS_ANY);

    request.setAttribute(WebKeys.MESSAGE_BOARDS_MESSAGE_DISPLAY, messageDisplay);

    MBTreeWalker treeWalker = messageDisplay.getTreeWalker();

    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER, treeWalker);
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_CATEGORY, messageDisplay.getCategory());
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_CUR_MESSAGE, treeWalker.getRoot());
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_DEPTH, Integer.valueOf(0));
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_LAST_NODE, Boolean.FALSE);
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_SEL_MESSAGE, _rootMessage);
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_THREAD, messageDisplay.getThread());

    return super.include(request, response, template);
}

From source file:com.liferay.portlet.asset.service.impl.AssetEntryLocalServiceImpl.java

License:Open Source License

/**
 * @deprecated As of 6.2.0, replaced by/*from   w  ww  .  j  a v a 2 s. c o  m*/
 *             {@link #search(long, long[], long, String, String, int, int, int)}
 */
@Override
public Hits search(long companyId, long[] groupIds, long userId, String className, String keywords, int start,
        int end) throws SystemException {
    return search(companyId, groupIds, userId, className, keywords, WorkflowConstants.STATUS_ANY, start, end);
}

From source file:com.liferay.portlet.asset.service.impl.AssetEntryLocalServiceImpl.java

License:Open Source License

/**
 * @deprecated As of 6.2.0, replaced by/*w w  w.  j av a2 s . c o m*/
 *             {@link #search(long, long[], long, String, String, String, String, String, String, int, boolean, int, int)}
 */
@Override
public Hits search(long companyId, long[] groupIds, long userId, String className, String userName,
        String title, String description, String assetCategoryIds, String assetTagNames, boolean andSearch,
        int start, int end) throws SystemException {
    return search(companyId, groupIds, userId, className, userName, title, description, assetCategoryIds,
            assetTagNames, WorkflowConstants.STATUS_ANY, andSearch, start, end);
}

From source file:com.liferay.portlet.asset.service.impl.AssetEntryLocalServiceImpl.java

License:Open Source License

/**
 * @deprecated As of 6.2.0, replaced by//  www  .j  a v  a  2 s.  com
 *             {@link #search(long, long[], long, String, String, int, int, int)}
 */
@Override
public Hits search(long companyId, long[] groupIds, String className, String keywords, int start, int end)
        throws SystemException {
    return search(companyId, groupIds, 0, className, keywords, WorkflowConstants.STATUS_ANY, start, end);
}

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

License:Open Source License

public List<BlogsEntry> getCompanyEntries(long companyId, Date displayDate, int status, int start, int end)
        throws SystemException {

    if (status == WorkflowConstants.STATUS_ANY) {
        return blogsEntryPersistence.findByC_LtD(companyId, displayDate, start, end);
    } else {//from  ww w.  j a v  a  2  s. co  m
        return blogsEntryPersistence.findByC_LtD_S(companyId, displayDate, status, start, end);
    }
}