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

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

Introduction

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

Prototype

String MOVE

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

Click Source Link

Usage

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 {//from w  ww.  j  av a2 s . c  om
        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.document.library.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.  j  a  va 2s.  c  o m
        if (cmd.equals(Constants.CANCEL_CHECKOUT)) {
            cancelCheckedOutEntries(actionRequest);
        } else if (cmd.equals(Constants.CHECKIN)) {
            checkInEntries(actionRequest);
        } else if (cmd.equals(Constants.CHECKOUT)) {
            checkOutEntries(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteEntries(actionRequest, false);
        } else if (cmd.equals(Constants.MOVE)) {
            moveEntries(actionRequest);
        } else if (cmd.equals(Constants.MOVE_TO_TRASH)) {
            deleteEntries(actionRequest, true);
        } else if (cmd.equals(Constants.RESTORE)) {
            restoreTrashEntries(actionRequest);
        }

        WindowState windowState = actionRequest.getWindowState();

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

            if (Validator.isNotNull(redirect)) {
                sendRedirect(actionRequest, actionResponse, redirect);
            }
        }
    } catch (DuplicateLockException | NoSuchFileEntryException | NoSuchFolderException | PrincipalException e) {

        if (e instanceof DuplicateLockException) {
            DuplicateLockException dle = (DuplicateLockException) e;

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

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

        if (e instanceof DuplicateFileEntryException) {
            HttpServletResponse response = _portal.getHttpServletResponse(actionResponse);

            response.setStatus(ServletResponseConstants.SC_DUPLICATE_FILE_EXCEPTION);
        }

        SessionErrors.add(actionRequest, e.getClass());
    } catch (AssetCategoryException | AssetTagException | InvalidFolderException e) {

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

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

License:Open Source License

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

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

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

    try {//from w  w w  .j a  v  a2s. c om
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            jsonObject = updateCategory(actionRequest);
        } else if (cmd.equals(Constants.MOVE)) {
            jsonObject = moveCategory(actionRequest);
        }
    } catch (Exception e) {
        jsonObject.putException(e);
    }

    writeJSON(actionRequest, actionResponse, jsonObject);
}

From source file:com.liferay.portlet.documentlibrary.action.EditEntryAction.java

License:Open Source License

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

    HttpServletResponse Response = PortalUtil.getHttpServletResponse(actionResponse);

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

    try {/*w  w w.  ja v  a2s  . c o m*/
        if (cmd.equals(Constants.DELETE)) {
            deleteEntries(actionRequest);
        } else if (cmd.equals(Constants.CANCEL_CHECKOUT)) {
            cancelCheckedOutEntries(actionRequest);
        } else if (cmd.equals(Constants.CHECKIN)) {
            checkInEntries(actionRequest);
        } else if (cmd.equals(Constants.CHECKOUT)) {
            checkOutEntries(actionRequest);
        } else if (cmd.equals(Constants.MOVE)) {
            moveEntries(actionRequest);
        }

        WindowState windowState = actionRequest.getWindowState();

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

            if (Validator.isNotNull(redirect)) {
                actionResponse.sendRedirect(redirect);
            }
        }
    } catch (Exception e) {
        if (e instanceof DuplicateLockException || e instanceof NoSuchFileEntryException
                || e instanceof NoSuchFolderException || e instanceof PrincipalException) {

            if (e instanceof DuplicateLockException) {
                DuplicateLockException dle = (DuplicateLockException) e;

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

            setForward(actionRequest, "portlet.document_library.error");
        } else if (e instanceof DuplicateFileException || e instanceof DuplicateFolderNameException
                || e instanceof NoSuchFolderException || e instanceof SourceFileNameException) {

            if (e instanceof DuplicateFileException) {
                HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);

                response.setStatus(ServletResponseConstants.SC_DUPLICATE_FILE_EXCEPTION);
            }

            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.portlet.documentlibrary.action.EditFolderAction.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 {/*from w  w w .  ja v  a  2s.  com*/
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateFolder(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteFolders(actionRequest);
        } else if (cmd.equals(Constants.MOVE)) {
            moveFolders(actionRequest);
        } else if (cmd.equals("updateWorkflowDefinitions")) {
            updateWorkflowDefinitions(actionRequest);
        }

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

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

            setForward(actionRequest, "portlet.document_library.error");
        } else if (e instanceof DuplicateFileException || e instanceof DuplicateFolderNameException
                || e instanceof FolderNameException) {

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