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

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

Introduction

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

Prototype

String CANCEL_CHECKOUT

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

Click Source Link

Usage

From source file:com.liferay.document.library.web.internal.display.context.logic.UIItemsBuilder.java

License:Open Source License

public void addCancelCheckoutMenuItem(List<MenuItem> menuItems) throws PortalException {

    if (!_fileEntryDisplayContextHelper.isCancelCheckoutDocumentActionAvailable()) {

        return;//from  w ww.  j  a  v a  2 s  .c  o m
    }

    PortletURL portletURL = _getActionURL("/document_library/edit_file_entry", Constants.CANCEL_CHECKOUT);

    portletURL.setParameter("fileEntryId", String.valueOf(_fileEntry.getFileEntryId()));

    _addURLUIItem(new URLMenuItem(), menuItems, DLUIItemKeys.CANCEL_CHECKOUT, "cancel-checkout[document]",
            portletURL.toString());
}

From source file:com.liferay.document.library.web.internal.display.context.logic.UIItemsBuilder.java

License:Open Source License

public void addCancelCheckoutToolbarItem(List<ToolbarItem> toolbarItems) throws PortalException {

    if (!_fileEntryDisplayContextHelper.isCancelCheckoutDocumentActionAvailable()) {

        return;/*from  w  ww  . j  ava2  s  .  c  o  m*/
    }

    _addJavaScriptUIItem(new JavaScriptToolbarItem(), toolbarItems, DLUIItemKeys.CANCEL_CHECKOUT,
            LanguageUtil.get(_resourceBundle, "cancel-checkout[document]"),
            getSubmitFormJavaScript(Constants.CANCEL_CHECKOUT, null));
}

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 {/* www  .  j  av  a  2 s.  com*/
        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.document.library.web.internal.portlet.action.EditFileEntryMVCActionCommand.java

License:Open Source License

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

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

    FileEntry fileEntry = null;/*from   ww  w .j  a v  a2 s.  co m*/

    PortletConfig portletConfig = getPortletConfig(actionRequest);

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

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

            if (cmd.equals(Constants.ADD_TEMP)) {
                if (cause instanceof FileUploadBase.IOFileUploadException) {
                    if (_log.isInfoEnabled()) {
                        _log.info("Temporary upload was cancelled");
                    }
                }
            } else {
                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.ADD_DYNAMIC)
                || cmd.equals(Constants.UPDATE) || cmd.equals(Constants.UPDATE_AND_CHECKIN)) {

            fileEntry = updateFileEntry(portletConfig, actionRequest, actionResponse);
        } else if (cmd.equals(Constants.ADD_MULTIPLE)) {
            addMultipleFileEntries(portletConfig, actionRequest, actionResponse);

            hideDefaultSuccessMessage(actionRequest);
        } else if (cmd.equals(Constants.ADD_TEMP)) {
            addTempFileEntry(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteFileEntry(actionRequest, false);
        } else if (cmd.equals(Constants.DELETE_TEMP)) {
            deleteTempFileEntry(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.CANCEL_CHECKOUT)) {
            cancelFileEntriesCheckOut(actionRequest);
        } else if (cmd.equals(Constants.CHECKIN)) {
            checkInFileEntries(actionRequest);
        } else if (cmd.equals(Constants.CHECKOUT)) {
            checkOutFileEntries(actionRequest);
        } else if (cmd.equals(Constants.MOVE_TO_TRASH)) {
            deleteFileEntry(actionRequest, true);
        } else if (cmd.equals(Constants.RESTORE)) {
            restoreTrashEntries(actionRequest);
        } else if (cmd.equals(Constants.REVERT)) {
            revertFileEntry(actionRequest);
        }

        WindowState windowState = actionRequest.getWindowState();

        if (cmd.equals(Constants.ADD_TEMP) || cmd.equals(Constants.DELETE_TEMP)) {

            actionResponse.setRenderParameter("mvcPath", "/null.jsp");
        } else if (cmd.equals(Constants.PREVIEW)) {
            SessionMessages.add(actionRequest,
                    _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_FORCE_SEND_REDIRECT);

            hideDefaultSuccessMessage(actionRequest);

            actionResponse.setRenderParameter("mvcRenderCommandName", "/document_library/edit_file_entry");
        } else if (!windowState.equals(LiferayWindowState.POP_UP)) {
        } else {
            String redirect = ParamUtil.getString(actionRequest, "redirect");
            int workflowAction = ParamUtil.getInteger(actionRequest, "workflowAction",
                    WorkflowConstants.ACTION_SAVE_DRAFT);

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

                redirect = getSaveAndContinueRedirect(portletConfig, actionRequest, fileEntry, redirect);

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

                    if (Validator.isNotNull(redirect)) {
                        if (cmd.equals(Constants.ADD) && (fileEntry != null)) {

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

                            String namespace = _portal.getPortletNamespace(portletId);

                            redirect = HttpUtil.addParameter(redirect, namespace + "className",
                                    DLFileEntry.class.getName());
                            redirect = HttpUtil.addParameter(redirect, namespace + "classPK",
                                    fileEntry.getFileEntryId());
                        }

                        actionRequest.setAttribute(WebKeys.REDIRECT, redirect);
                    }
                }
            }
        }
    } catch (Exception e) {
        handleUploadException(portletConfig, actionRequest, actionResponse, cmd, e);
    }
}

From source file:com.liferay.document.library.web.internal.portlet.configuration.icon.CancelCheckoutFileEntryPortletConfigurationIcon.java

License:Open Source License

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

    PortletURL portletURL = _portal.getControlPanelPortletURL(portletRequest,
            DLPortletKeys.DOCUMENT_LIBRARY_ADMIN, PortletRequest.ACTION_PHASE);

    portletURL.setParameter(ActionRequest.ACTION_NAME, "/document_library/edit_file_entry");
    portletURL.setParameter(Constants.CMD, Constants.CANCEL_CHECKOUT);

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

    portletURL.setParameter("redirect", themeDisplay.getURLCurrent());

    try {//from w  w w.j ava2  s  . c  om
        FileEntry fileEntry = ActionUtil.getFileEntry(portletRequest);

        portletURL.setParameter("fileEntryId", String.valueOf(fileEntry.getFileEntryId()));
    } catch (Exception e) {
    }

    return portletURL.toString();
}

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 {//from  www  .j a  v  a  2 s .com
        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;
        }
    }
}