Example usage for com.liferay.portal.kernel.security.permission ActionKeys SUBSCRIBE

List of usage examples for com.liferay.portal.kernel.security.permission ActionKeys SUBSCRIBE

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.security.permission ActionKeys SUBSCRIBE.

Prototype

String SUBSCRIBE

To view the source code for com.liferay.portal.kernel.security.permission ActionKeys SUBSCRIBE.

Click Source Link

Usage

From source file:com.liferay.bookmarks.service.impl.BookmarksEntryServiceImpl.java

License:Open Source License

@Override
public void subscribeEntry(long entryId) throws PortalException {
    BookmarksEntryPermissionChecker.check(getPermissionChecker(), entryId, ActionKeys.SUBSCRIBE);

    bookmarksEntryLocalService.subscribeEntry(getUserId(), entryId);
}

From source file:com.liferay.bookmarks.service.impl.BookmarksEntryServiceImpl.java

License:Open Source License

@Override
public void unsubscribeEntry(long entryId) throws PortalException {
    BookmarksEntryPermissionChecker.check(getPermissionChecker(), entryId, ActionKeys.SUBSCRIBE);

    bookmarksEntryLocalService.unsubscribeEntry(getUserId(), entryId);
}

From source file:com.liferay.bookmarks.service.impl.BookmarksFolderServiceImpl.java

License:Open Source License

@Override
public void subscribeFolder(long groupId, long folderId) throws PortalException {

    BookmarksFolderPermissionChecker.check(getPermissionChecker(), groupId, folderId, ActionKeys.SUBSCRIBE);

    bookmarksFolderLocalService.subscribeFolder(getUserId(), groupId, folderId);
}

From source file:com.liferay.bookmarks.service.impl.BookmarksFolderServiceImpl.java

License:Open Source License

@Override
public void unsubscribeFolder(long groupId, long folderId) throws PortalException {

    BookmarksFolderPermissionChecker.check(getPermissionChecker(), groupId, folderId, ActionKeys.SUBSCRIBE);

    bookmarksFolderLocalService.unsubscribeFolder(getUserId(), groupId, folderId);
}

From source file:com.liferay.journal.service.impl.JournalArticleServiceImpl.java

License:Open Source License

/**
 * Subscribes the user to changes in elements that belong to the web content
 * article's DDM structure./*from  w ww  .j av a2s.c  o  m*/
 *
 * @param groupId the primary key of the folder's group
 * @param userId the primary key of the user to be subscribed
 * @param ddmStructureId the primary key of the structure to subscribe to
 */
@Override
public void subscribeStructure(long groupId, long userId, long ddmStructureId) throws PortalException {

    JournalPermission.check(getPermissionChecker(), groupId, ActionKeys.SUBSCRIBE);

    journalArticleLocalService.subscribeStructure(groupId, userId, ddmStructureId);
}

From source file:com.liferay.journal.service.impl.JournalArticleServiceImpl.java

License:Open Source License

/**
 * Unsubscribes the user from changes in elements that belong to the web
 * content article's DDM structure.//from  w  w w .j a v  a2s  .c  o  m
 *
 * @param groupId the primary key of the folder's group
 * @param userId the primary key of the user to be subscribed
 * @param ddmStructureId the primary key of the structure to subscribe to
 */
@Override
public void unsubscribeStructure(long groupId, long userId, long ddmStructureId) throws PortalException {

    JournalPermission.check(getPermissionChecker(), groupId, ActionKeys.SUBSCRIBE);

    journalArticleLocalService.unsubscribeStructure(groupId, userId, ddmStructureId);
}

From source file:com.liferay.journal.service.impl.JournalFolderServiceImpl.java

License:Open Source License

@Override
public void subscribe(long groupId, long folderId) throws PortalException {
    JournalFolderPermission.check(getPermissionChecker(), groupId, folderId, ActionKeys.SUBSCRIBE);

    journalFolderLocalService.subscribe(getUserId(), groupId, folderId);
}

From source file:com.liferay.journal.service.impl.JournalFolderServiceImpl.java

License:Open Source License

@Override
public void unsubscribe(long groupId, long folderId) throws PortalException {

    JournalFolderPermission.check(getPermissionChecker(), groupId, folderId, ActionKeys.SUBSCRIBE);

    journalFolderLocalService.unsubscribe(getUserId(), groupId, folderId);
}

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

License:Open Source License

@Override
public boolean hasSubscribePermission(long companyId, long groupId, String className, long classPK)
        throws PortalException {

    return MBDiscussionPermission.contains(_permissionChecker, companyId, groupId, className, classPK,
            ActionKeys.SUBSCRIBE);
}

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   www . jav  a  2  s  .  com*/
        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);
        }
    }
}