Example usage for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay getScopeGroupId.

Prototype

public long getScopeGroupId() 

Source Link

Document

Returns the ID of the scoped or sub-scoped active group (e.g.

Usage

From source file:com.liferay.meeting.portlet.action.AddWebExAccountMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    long webExSiteId = ParamUtil.getLong(actionRequest, "webExSiteId");
    String login = ParamUtil.getString(actionRequest, "login");
    String password = ParamUtil.getString(actionRequest, "password");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(WebExAccount.class.getName(),
            actionRequest);/*from ww  w .j  av  a 2 s.co  m*/

    WebExAccountServiceUtil.addWebExAccount(themeDisplay.getScopeGroupId(), webExSiteId, login, password,
            serviceContext);
}

From source file:com.liferay.meeting.portlet.action.AddWebExSiteMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    String name = ParamUtil.getString(actionRequest, "name");
    String apiURL = ParamUtil.getString(actionRequest, "apiURL");
    String login = ParamUtil.getString(actionRequest, "login");
    String password = ParamUtil.getString(actionRequest, "password");
    String partnerKey = ParamUtil.getString(actionRequest, "partnerKey");
    long siteKey = ParamUtil.getLong(actionRequest, "siteKey");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(WebExSite.class.getName(), actionRequest);

    WebExSiteServiceUtil.addWebExSite(themeDisplay.getScopeGroupId(), name, apiURL, login, password, partnerKey,
            siteKey, serviceContext);//ww w. j  a va  2 s  .  co m
}

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();
        }/*from   w  ww.j  ava2 s .c  o 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 MBCategory getCategory(HttpServletRequest request) throws Exception {

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

    String mvcRenderCommandName = ParamUtil.getString(request, "mvcRenderCommandName");

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (mvcRenderCommandName.equals("/message_boards/view_banned_users")
            && !MBPermission.contains(permissionChecker, themeDisplay.getScopeGroupId(), ActionKeys.BAN_USER)) {

        throw new PrincipalException.MustHavePermission(permissionChecker, ActionKeys.BAN_USER);
    }/*from  w  w  w  .  j a v  a 2 s  . co m*/

    MBBanLocalServiceUtil.checkBan(themeDisplay.getScopeGroupId(), themeDisplay.getUserId());

    long categoryId = ParamUtil.getLong(request, "mbCategoryId");

    MBCategory category = null;

    if (categoryId > 0) {
        category = MBCategoryServiceUtil.getCategory(categoryId);
    } else {
        MBPermission.check(permissionChecker, themeDisplay.getScopeGroupId(), ActionKeys.VIEW);
    }

    return category;
}

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;
    }//from w  w  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.portlet.action.EditCategoryMVCActionCommand.java

License:Open Source License

protected void deleteCategories(ActionRequest actionRequest, boolean moveToTrash) throws Exception {

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

    long[] deleteCategoryIds = null;

    long categoryId = ParamUtil.getLong(actionRequest, "mbCategoryId");

    if (categoryId > 0) {
        deleteCategoryIds = new long[] { categoryId };
    } else {/*  ww  w  . ja va 2s  .  c  o  m*/
        deleteCategoryIds = StringUtil.split(ParamUtil.getString(actionRequest, "deleteCategoryIds"), 0L);
    }

    List<TrashedModel> trashedModels = new ArrayList<>();

    for (long deleteCategoryId : deleteCategoryIds) {
        if (moveToTrash) {
            MBCategory category = _mbCategoryService.moveCategoryToTrash(deleteCategoryId);

            trashedModels.add(category);
        } else {
            _mbCategoryService.deleteCategory(themeDisplay.getScopeGroupId(), deleteCategoryId);
        }
    }

    if (moveToTrash && !trashedModels.isEmpty()) {
        TrashUtil.addTrashSessionMessages(actionRequest, trashedModels);

        hideDefaultSuccessMessage(actionRequest);
    }
}

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

License:Open Source License

protected void subscribeCategory(ActionRequest actionRequest) throws Exception {

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

    long categoryId = ParamUtil.getLong(actionRequest, "mbCategoryId");

    _mbCategoryService.subscribeCategory(themeDisplay.getScopeGroupId(), categoryId);
}

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

License:Open Source License

protected void unsubscribeCategory(ActionRequest actionRequest) throws Exception {

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

    long categoryId = ParamUtil.getLong(actionRequest, "mbCategoryId");

    _mbCategoryService.unsubscribeCategory(themeDisplay.getScopeGroupId(), categoryId);
}

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

License:Open Source License

protected void deleteEntries(ActionRequest actionRequest, boolean moveToTrash) throws Exception {

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

    long[] threadIds = ParamUtil.getLongValues(actionRequest, "rowIdsMBThread");

    List<TrashedModel> trashedModels = new ArrayList<>();

    for (long threadId : threadIds) {
        if (moveToTrash) {
            MBThread thread = _mbThreadService.moveThreadToTrash(threadId);

            trashedModels.add(thread);// w ww.  j a v  a2 s. com
        } else {
            _mbThreadService.deleteThread(threadId);
        }
    }

    long[] categoryIds = ParamUtil.getLongValues(actionRequest, "rowIdsMBCategory");

    for (long categoryId : categoryIds) {
        if (moveToTrash) {
            MBCategory category = _mbCategoryService.moveCategoryToTrash(categoryId);

            trashedModels.add(category);
        } else {
            _mbCategoryService.deleteCategory(themeDisplay.getScopeGroupId(), categoryId);
        }
    }

    if (moveToTrash && !trashedModels.isEmpty()) {
        TrashUtil.addTrashSessionMessages(actionRequest, trashedModels);

        hideDefaultSuccessMessage(actionRequest);
    }
}

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

License:Open Source License

protected MBMessage updateMessage(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

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

    long groupId = themeDisplay.getScopeGroupId();
    long categoryId = ParamUtil.getLong(actionRequest, "mbCategoryId");
    long threadId = ParamUtil.getLong(actionRequest, "threadId");
    long parentMessageId = ParamUtil.getLong(actionRequest, "parentMessageId");
    String subject = ParamUtil.getString(actionRequest, "subject");
    String body = ParamUtil.getString(actionRequest, "body");

    MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings.getInstance(groupId);

    List<ObjectValuePair<String, InputStream>> inputStreamOVPs = new ArrayList<>(5);

    try {/*from   w w w.jav a2s  . c  o  m*/
        UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);

        for (int i = 1; i <= 5; i++) {
            String fileName = uploadPortletRequest.getFileName("msgFile" + i);
            InputStream inputStream = uploadPortletRequest.getFileAsStream("msgFile" + i);

            if ((inputStream == null) || Validator.isNull(fileName)) {
                continue;
            }

            ObjectValuePair<String, InputStream> inputStreamOVP = new ObjectValuePair<>(fileName, inputStream);

            inputStreamOVPs.add(inputStreamOVP);
        }

        boolean question = ParamUtil.getBoolean(actionRequest, "question");
        boolean anonymous = ParamUtil.getBoolean(actionRequest, "anonymous");
        double priority = ParamUtil.getDouble(actionRequest, "priority");
        boolean allowPingbacks = ParamUtil.getBoolean(actionRequest, "allowPingbacks");

        ServiceContext serviceContext = ServiceContextFactory.getInstance(MBMessage.class.getName(),
                actionRequest);

        boolean preview = ParamUtil.getBoolean(actionRequest, "preview");

        serviceContext.setAttribute("preview", preview);

        MBMessage message = null;

        if (messageId <= 0) {
            if (PropsValues.CAPTCHA_CHECK_PORTLET_MESSAGE_BOARDS_EDIT_MESSAGE) {

                CaptchaUtil.check(actionRequest);
            }

            if (threadId <= 0) {

                // Post new thread

                message = _mbMessageService.addMessage(groupId, categoryId, subject, body,
                        mbGroupServiceSettings.getMessageFormat(), inputStreamOVPs, anonymous, priority,
                        allowPingbacks, serviceContext);

                if (question) {
                    _mbThreadLocalService.updateQuestion(message.getThreadId(), true);
                }
            } else {

                // Post reply

                message = _mbMessageService.addMessage(parentMessageId, subject, body,
                        mbGroupServiceSettings.getMessageFormat(), inputStreamOVPs, anonymous, priority,
                        allowPingbacks, serviceContext);
            }
        } else {
            List<String> existingFiles = new ArrayList<>();

            for (int i = 1; i <= 5; i++) {
                String path = ParamUtil.getString(actionRequest, "existingPath" + i);

                if (Validator.isNotNull(path)) {
                    existingFiles.add(path);
                }
            }

            // Update message

            message = _mbMessageService.updateMessage(messageId, subject, body, inputStreamOVPs, existingFiles,
                    priority, allowPingbacks, serviceContext);

            if (message.isRoot()) {
                _mbThreadLocalService.updateQuestion(message.getThreadId(), question);
            }
        }

        PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

        boolean subscribe = ParamUtil.getBoolean(actionRequest, "subscribe");

        if (!preview && subscribe
                && MBMessagePermission.contains(permissionChecker, message, ActionKeys.SUBSCRIBE)) {

            _mbMessageService.subscribeMessage(message.getMessageId());
        }

        return message;
    } finally {
        for (ObjectValuePair<String, InputStream> inputStreamOVP : inputStreamOVPs) {

            InputStream inputStream = inputStreamOVP.getValue();

            StreamUtil.cleanUp(inputStream);
        }
    }
}