Example usage for com.liferay.portal.kernel.util Constants SUBSCRIBE

List of usage examples for com.liferay.portal.kernel.util Constants SUBSCRIBE

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util Constants SUBSCRIBE.

Prototype

String SUBSCRIBE

To view the source code for com.liferay.portal.kernel.util Constants SUBSCRIBE.

Click Source Link

Usage

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

License:Open Source License

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

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {//ww  w  .ja  v a 2  s . c  o m
        BlogsEntry entry = null;
        List<BlogsEntryAttachmentFileEntryReference> blogsEntryAttachmentFileEntryReferences = null;

        UploadException uploadException = (UploadException) actionRequest
                .getAttribute(WebKeys.UPLOAD_EXCEPTION);

        if (uploadException != null) {
            Throwable cause = uploadException.getCause();

            if (uploadException.isExceededFileSizeLimit()) {
                throw new FileSizeException(cause);
            }

            if (uploadException.isExceededLiferayFileItemSizeLimit()) {
                throw new LiferayFileItemException(cause);
            }

            if (uploadException.isExceededUploadRequestSizeLimit()) {
                throw new UploadRequestSizeException(cause);
            }

            throw new PortalException(cause);
        } else if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {

            Callable<Object[]> updateEntryCallable = new UpdateEntryCallable(actionRequest);

            Object[] returnValue = TransactionInvokerUtil.invoke(_transactionConfig, updateEntryCallable);

            entry = (BlogsEntry) returnValue[0];
            blogsEntryAttachmentFileEntryReferences = (List<BlogsEntryAttachmentFileEntryReference>) returnValue[1];
        } else if (cmd.equals(Constants.DELETE)) {
            deleteEntries(actionRequest, false);
        } else if (cmd.equals(Constants.MOVE_TO_TRASH)) {
            deleteEntries(actionRequest, true);
        } else if (cmd.equals(Constants.RESTORE)) {
            restoreTrashEntries(actionRequest);
        } else if (cmd.equals(Constants.SUBSCRIBE)) {
            subscribe(actionRequest);
        } else if (cmd.equals(Constants.UNSUBSCRIBE)) {
            unsubscribe(actionRequest);
        }

        String redirect = ParamUtil.getString(actionRequest, "redirect");
        String portletId = HttpUtil.getParameter(redirect, "p_p_id", false);

        int workflowAction = ParamUtil.getInteger(actionRequest, "workflowAction",
                WorkflowConstants.ACTION_SAVE_DRAFT);

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

        if (ajax) {
            JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

            JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

            for (BlogsEntryAttachmentFileEntryReference blogsEntryAttachmentFileEntryReference : blogsEntryAttachmentFileEntryReferences) {

                JSONObject blogsEntryFileEntryReferencesJSONObject = JSONFactoryUtil.createJSONObject();

                blogsEntryFileEntryReferencesJSONObject.put("attributeDataImageId",
                        EditorConstants.ATTRIBUTE_DATA_IMAGE_ID);
                blogsEntryFileEntryReferencesJSONObject.put("fileEntryId", String.valueOf(
                        blogsEntryAttachmentFileEntryReference.getTempBlogsEntryAttachmentFileEntryId()));
                blogsEntryFileEntryReferencesJSONObject.put("fileEntryUrl",
                        PortletFileRepositoryUtil.getPortletFileEntryURL(null,
                                blogsEntryAttachmentFileEntryReference.getBlogsEntryAttachmentFileEntry(),
                                StringPool.BLANK));

                jsonArray.put(blogsEntryFileEntryReferencesJSONObject);
            }

            jsonObject.put("blogsEntryAttachmentReferences", jsonArray);
            jsonObject.put("coverImageFileEntryId", entry.getCoverImageFileEntryId());
            jsonObject.put("entryId", entry.getEntryId());
            jsonObject.put("redirect", redirect);

            JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject);

            return;
        }

        if ((entry != null) && (workflowAction == WorkflowConstants.ACTION_SAVE_DRAFT)) {

            redirect = getSaveAndContinueRedirect(actionRequest, entry, redirect);

            sendRedirect(actionRequest, actionResponse, redirect);
        } else {
            WindowState windowState = actionRequest.getWindowState();

            if (!windowState.equals(LiferayWindowState.POP_UP)) {
                sendRedirect(actionRequest, actionResponse, redirect);
            } else {
                redirect = PortalUtil.escapeRedirect(redirect);

                if (Validator.isNotNull(redirect)) {
                    if (cmd.equals(Constants.ADD) && (entry != null)) {
                        String namespace = PortalUtil.getPortletNamespace(portletId);

                        redirect = HttpUtil.addParameter(redirect, namespace + "className",
                                BlogsEntry.class.getName());
                        redirect = HttpUtil.addParameter(redirect, namespace + "classPK", entry.getEntryId());
                    }

                    actionRequest.setAttribute(WebKeys.REDIRECT, redirect);
                }
            }
        }
    } catch (AssetCategoryException | AssetTagException e) {
        SessionErrors.add(actionRequest, e.getClass(), e);

        actionResponse.setRenderParameter("mvcRenderCommandName", "/blogs/edit_entry");

        hideDefaultSuccessMessage(actionRequest);
    } catch (EntryContentException | EntryCoverImageCropException | EntryDescriptionException
            | EntryDisplayDateException | EntrySmallImageNameException | EntrySmallImageScaleException
            | EntryTitleException | EntryUrlTitleException | FileSizeException | LiferayFileItemException
            | SanitizerException | UploadRequestSizeException e) {

        SessionErrors.add(actionRequest, e.getClass());

        actionResponse.setRenderParameter("mvcRenderCommandName", "/blogs/edit_entry");

        hideDefaultSuccessMessage(actionRequest);
    } catch (NoSuchEntryException | PrincipalException e) {
        SessionErrors.add(actionRequest, e.getClass());

        actionResponse.setRenderParameter("mvcPath", "/blogs/error.jsp");

        hideDefaultSuccessMessage(actionRequest);
    } catch (Throwable t) {
        _log.error(t, t);

        actionResponse.setRenderParameter("mvcPath", "/blogs/error.jsp");

        hideDefaultSuccessMessage(actionRequest);
    }
}

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

License:Open Source License

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

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {// w  w w. jav a  2 s .co m
        BookmarksEntry entry = null;

        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            entry = updateEntry(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteEntry(actionRequest, false);
        } else if (cmd.equals(Constants.MOVE)) {
            moveEntries(actionRequest);
        } else if (cmd.equals(Constants.MOVE_TO_TRASH)) {
            deleteEntry(actionRequest, true);
        } else if (cmd.equals(Constants.RESTORE)) {
            restoreTrashEntries(actionRequest);
        } else if (cmd.equals(Constants.SUBSCRIBE)) {
            subscribeEntry(actionRequest);
        } else if (cmd.equals(Constants.UNSUBSCRIBE)) {
            unsubscribeEntry(actionRequest);
        }

        WindowState windowState = actionRequest.getWindowState();

        if (windowState.equals(LiferayWindowState.POP_UP)) {
            String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

            if (Validator.isNotNull(redirect)) {
                if (cmd.equals(Constants.ADD) && (entry != null)) {
                    String portletId = HttpUtil.getParameter(redirect, "p_p_id", false);

                    String namespace = PortalUtil.getPortletNamespace(portletId);

                    redirect = HttpUtil.addParameter(redirect, namespace + "className",
                            BookmarksEntry.class.getName());
                    redirect = HttpUtil.addParameter(redirect, namespace + "classPK", entry.getEntryId());
                }

                actionRequest.setAttribute(WebKeys.REDIRECT, redirect);
            }
        }
    } catch (Exception e) {
        if (e instanceof NoSuchEntryException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass());

            actionResponse.setRenderParameter("mvcPath", "/bookmarks/error.jsp");
        } else if (e instanceof EntryURLException || e instanceof NoSuchFolderException) {

            SessionErrors.add(actionRequest, e.getClass());
        } else if (e instanceof AssetCategoryException || e instanceof AssetTagException) {

            SessionErrors.add(actionRequest, e.getClass(), e);
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.bookmarks.web.internal.portlet.action.EditFolderMVCActionCommand.java

License:Open Source License

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

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {/*from   w  w  w.j  a  v a 2 s  . com*/
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateFolder(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteFolders(actionRequest, false);
        } else if (cmd.equals(Constants.MOVE_TO_TRASH)) {
            deleteFolders(actionRequest, true);
        } else if (cmd.equals(Constants.RESTORE)) {
            restoreTrashEntries(actionRequest);
        } else if (cmd.equals(Constants.SUBSCRIBE)) {
            subscribeFolder(actionRequest);
        } else if (cmd.equals(Constants.UNSUBSCRIBE)) {
            unsubscribeFolder(actionRequest);
        }
    } catch (Exception e) {
        if (e instanceof NoSuchFolderException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass());

            actionResponse.setRenderParameter("mvcPath", "/bookmarks/error.jsp");
        } else if (e instanceof FolderNameException) {
            SessionErrors.add(actionRequest, e.getClass());
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.document.library.web.internal.portlet.action.EditFileEntryTypeMVCActionCommand.java

License:Open Source License

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

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {/* ww w  . j av a2  s.  co  m*/
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateFileEntryType(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteFileEntryType(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.SUBSCRIBE)) {
            subscribeFileEntryType(actionRequest);
        } else if (cmd.equals(Constants.UNSUBSCRIBE)) {
            unsubscribeFileEntryType(actionRequest);
        }

        if (SessionErrors.isEmpty(actionRequest)) {
            SessionMessages.add(actionRequest,
                    _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET,
                    DLPortletKeys.DOCUMENT_LIBRARY);

            String redirect = _portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

            if (Validator.isNotNull(redirect)) {
                sendRedirect(actionRequest, actionResponse, redirect);
            }
        }
    } catch (DuplicateFileEntryTypeException | NoSuchMetadataSetException | RequiredStructureException
            | StructureDefinitionException | StructureDuplicateElementException | StructureNameException e) {

        SessionErrors.add(actionRequest, e.getClass());
    } catch (RequiredFileEntryTypeException rfete) {
        SessionErrors.add(actionRequest, rfete.getClass());

        actionResponse.setRenderParameter("mvcPath", "/document_library/view_file_entry_types.jsp");
    } catch (NoSuchFileEntryTypeException | NoSuchStructureException | PrincipalException e) {

        SessionErrors.add(actionRequest, e.getClass());

        actionResponse.setRenderParameter("mvcPath", "/document_library/error.jsp");
    }
}

From source file:com.liferay.document.library.web.internal.portlet.action.EditFolderMVCActionCommand.java

License:Open Source License

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

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {/*  w  w  w  . j  a  va 2  s .co  m*/
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateFolder(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteFolders(actionRequest, false);
        } else if (cmd.equals(Constants.MOVE_TO_TRASH)) {
            deleteFolders(actionRequest, true);
        } else if (cmd.equals(Constants.SUBSCRIBE)) {
            subscribeFolder(actionRequest);
        } else if (cmd.equals(Constants.UNSUBSCRIBE)) {
            unsubscribeFolder(actionRequest);
        } else if (cmd.equals("deleteExpiredTemporaryFileEntries")) {
            deleteExpiredTemporaryFileEntries(actionRequest);
        } else if (cmd.equals("updateWorkflowDefinitions")) {
            updateWorkflowDefinitions(actionRequest);
        }
    } catch (NoSuchFolderException | PrincipalException e) {
        SessionErrors.add(actionRequest, e.getClass());

        actionResponse.setRenderParameter("mvcPath", "/document_library/error.jsp");
    } catch (DuplicateFileEntryException | DuplicateFileException | DuplicateFolderNameException
            | FolderNameException | RequiredFileEntryTypeException e) {

        SessionErrors.add(actionRequest, e.getClass());
    } catch (Exception e) {
        throw new PortletException(e);
    }
}

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

License:Open Source License

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

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {/*w w  w.  j  av  a2  s.c  o m*/
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateCategory(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteCategories(actionRequest, false);
        } else if (cmd.equals(Constants.MOVE_TO_TRASH)) {
            deleteCategories(actionRequest, true);
        } else if (cmd.equals(Constants.RESTORE)) {
            restoreTrashEntries(actionRequest);
        } else if (cmd.equals(Constants.SUBSCRIBE)) {
            subscribeCategory(actionRequest);
        } else if (cmd.equals(Constants.UNSUBSCRIBE)) {
            unsubscribeCategory(actionRequest);
        }
    } catch (NoSuchCategoryException | PrincipalException e) {
        SessionErrors.add(actionRequest, e.getClass());

        actionResponse.setRenderParameter("mvcPath", "/message_boards/error.jsp");
    } catch (CaptchaConfigurationException | CaptchaTextException | CategoryNameException
            | MailingListEmailAddressException | MailingListInServerNameException
            | MailingListInUserNameException | MailingListOutEmailAddressException
            | MailingListOutServerNameException | MailingListOutUserNameException e) {

        SessionErrors.add(actionRequest, e.getClass());
    }
}

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

License:Open Source License

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

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    MBMessage message = null;/*from   w ww .j  av  a  2  s .c  om*/

    try {
        UploadException uploadException = (UploadException) actionRequest
                .getAttribute(WebKeys.UPLOAD_EXCEPTION);

        if (uploadException != null) {
            Throwable cause = uploadException.getCause();

            if (uploadException.isExceededFileSizeLimit()) {
                throw new FileSizeException(cause);
            }

            if (uploadException.isExceededLiferayFileItemSizeLimit()) {
                throw new LiferayFileItemException(cause);
            }

            if (uploadException.isExceededUploadRequestSizeLimit()) {
                throw new UploadRequestSizeException(cause);
            }

            throw new PortalException(cause);
        } else if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {

            message = updateMessage(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.ADD_ANSWER)) {
            addAnswer(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteMessage(actionRequest);
        } else if (cmd.equals(Constants.DELETE_ANSWER)) {
            deleteAnswer(actionRequest);
        } else if (cmd.equals(Constants.LOCK)) {
            lockThreads(actionRequest);
        } else if (cmd.equals(Constants.SUBSCRIBE)) {
            subscribeMessage(actionRequest);
        } else if (cmd.equals(Constants.UNLOCK)) {
            unlockThreads(actionRequest);
        } else if (cmd.equals(Constants.UNSUBSCRIBE)) {
            unsubscribeMessage(actionRequest);
        }

        if (Validator.isNotNull(cmd)) {
            WindowState windowState = actionRequest.getWindowState();

            if (!windowState.equals(LiferayWindowState.POP_UP)) {
                String redirect = getRedirect(actionRequest, actionResponse, message);

                sendRedirect(actionRequest, actionResponse, redirect);
            } else {
                String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

                if (Validator.isNotNull(redirect)) {
                    actionResponse.sendRedirect(redirect);
                }
            }
        }
    } catch (NoSuchMessageException | PrincipalException | RequiredMessageException e) {

        SessionErrors.add(actionRequest, e.getClass());

        actionResponse.setRenderParameter("mvcPath", "/message_boards/error.jsp");
    } catch (AntivirusScannerException | CaptchaConfigurationException | CaptchaTextException
            | DuplicateFileEntryException | FileExtensionException | FileNameException | FileSizeException
            | LiferayFileItemException | LockedThreadException | MessageBodyException | MessageSubjectException
            | SanitizerException | UploadRequestSizeException e) {

        if (e instanceof AntivirusScannerException) {
            SessionErrors.add(actionRequest, e.getClass(), e);
        } else {
            SessionErrors.add(actionRequest, e.getClass());
        }
    } catch (AssetCategoryException | AssetTagException e) {
        SessionErrors.add(actionRequest, e.getClass(), e);
    } catch (Exception e) {
        Throwable cause = e.getCause();

        if (cause instanceof SanitizerException) {
            SessionErrors.add(actionRequest, SanitizerException.class);
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.CategorySubscriptionPortletConfigurationIcon.java

License:Open Source License

@Override
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    PortletURL portletURL = PortalUtil.getControlPanelPortletURL(portletRequest,
            MBPortletKeys.MESSAGE_BOARDS_ADMIN, PortletRequest.ACTION_PHASE);

    portletURL.setParameter(ActionRequest.ACTION_NAME, "/message_boards/edit_category");

    MBCategory category = null;/*from w ww.  j a v  a 2s  . c  o  m*/

    try {
        category = ActionUtil.getCategory(portletRequest);
    } catch (Exception e) {
        return null;
    }

    if (_isSubscribed(portletRequest, category)) {
        portletURL.setParameter(Constants.CMD, Constants.UNSUBSCRIBE);
    } else {
        portletURL.setParameter(Constants.CMD, Constants.SUBSCRIBE);
    }

    portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest));
    portletURL.setParameter("mbCategoryId", String.valueOf(category.getCategoryId()));

    return portletURL.toString();
}

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.ThreadSubscriptionPortletConfigurationIcon.java

License:Open Source License

@Override
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    PortletURL portletURL = PortalUtil.getControlPanelPortletURL(portletRequest,
            MBPortletKeys.MESSAGE_BOARDS_ADMIN, PortletRequest.ACTION_PHASE);

    portletURL.setParameter(ActionRequest.ACTION_NAME, "/message_boards/edit_message");

    MBMessage message = null;/* w  w w .jav  a  2 s . co m*/

    try {
        message = ActionUtil.getMessage(portletRequest);
    } catch (Exception e) {
        return null;
    }

    if (_isSubscribed(portletRequest, message.getThreadId())) {
        portletURL.setParameter(Constants.CMD, Constants.UNSUBSCRIBE);
    } else {
        portletURL.setParameter(Constants.CMD, Constants.SUBSCRIBE);
    }

    portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest));
    portletURL.setParameter("messageId", String.valueOf(message.getMessageId()));

    return portletURL.toString();
}

From source file:com.liferay.portlet.messageboards.action.EditCategoryAction.java

License:Open Source License

@Override
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {//w  ww .  j  a v  a2s.  co m
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateCategory(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteCategories(actionRequest);
        } else if (cmd.equals(Constants.SUBSCRIBE)) {
            subscribeCategory(actionRequest);
        } else if (cmd.equals(Constants.UNSUBSCRIBE)) {
            unsubscribeCategory(actionRequest);
        }

        sendRedirect(actionRequest, actionResponse);
    } catch (Exception e) {
        if (e instanceof NoSuchCategoryException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass().getName());

            setForward(actionRequest, "portlet.message_boards.error");
        } else if (e instanceof CaptchaMaxChallengesException || e instanceof CaptchaTextException
                || e instanceof CategoryNameException || e instanceof MailingListEmailAddressException
                || e instanceof MailingListInServerNameException || e instanceof MailingListInUserNameException
                || e instanceof MailingListOutEmailAddressException
                || e instanceof MailingListOutServerNameException
                || e instanceof MailingListOutUserNameException) {

            SessionErrors.add(actionRequest, e.getClass().getName());
        } else {
            throw e;
        }
    }
}