Example usage for com.liferay.portal.kernel.servlet SessionErrors add

List of usage examples for com.liferay.portal.kernel.servlet SessionErrors add

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.servlet SessionErrors add.

Prototype

public static void add(PortletRequest portletRequest, String key) 

Source Link

Usage

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

License:Open Source License

public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    try {/*w ww .  jav  a 2s.  co  m*/
        ActionUtil.getFileEntry(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchFileEntryException || e instanceof PrincipalException) {

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

            return mapping.findForward("portlet.document_library.error");
        } else {
            throw e;
        }
    }

    String forward = "portlet.document_library.edit_file_entry";

    return mapping.findForward(getForward(renderRequest, forward));
}

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

License:Open Source License

public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    try {/*from  w w w.j  a  v a  2 s  .com*/
        String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

        String imageData = ParamUtil.getString(actionRequest, "imageData");
        String fileEntryId = ParamUtil.getString(actionRequest, "fileEntryId");

        if (cmd.equals(Constants.CHECKOUT)) {
            System.out.println("updating");
        }

        originalStrutsPortletAction.processAction(originalStrutsPortletAction, portletConfig, actionRequest,
                actionResponse);
    } catch (AntivirusScannerException ase) {
        SessionErrors.add(actionRequest, ase.getClass());
    }
}

From source file:com.liferay.portlet.documentlibrary.action.EditFileEntryTypeAction.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   ww  w  . jav  a  2s .  co  m
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateFileEntryType(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteFileEntryType(actionRequest, actionResponse);
        }

        if (SessionErrors.isEmpty(actionRequest)) {
            SessionMessages.add(actionRequest,
                    portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET,
                    PortletKeys.DOCUMENT_LIBRARY);
        }

        sendRedirect(actionRequest, actionResponse);
    } catch (Exception e) {
        if (e instanceof DuplicateFileEntryTypeException || e instanceof NoSuchMetadataSetException
                || e instanceof StructureDuplicateElementException) {

            SessionErrors.add(actionRequest, e.getClass().getName());
        } else if (e instanceof NoSuchFileEntryTypeException || e instanceof NoSuchStructureException
                || e instanceof PrincipalException) {

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

            setForward(actionRequest, "portlet.document_library.error");
        } else if (e instanceof RequiredStructureException) {
            SessionErrors.add(actionRequest, e.getClass().getName());

            sendRedirect(actionRequest, actionResponse);
        } else {
            throw e;
        }
    }
}

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

License:Open Source License

@Override
public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    DLFileEntryType fileEntryType = null;

    try {/*from  w  w w .  ja va  2s  .  com*/
        long fileEntryTypeId = ParamUtil.getLong(renderRequest, "fileEntryTypeId");

        if (fileEntryTypeId > 0) {
            fileEntryType = DLFileEntryTypeServiceUtil.getFileEntryType(fileEntryTypeId);

            renderRequest.setAttribute(WebKeys.DOCUMENT_LIBRARY_FILE_ENTRY_TYPE, fileEntryType);

            DDMStructure ddmStructure = DDMStructureLocalServiceUtil.fetchStructure(fileEntryType.getGroupId(),
                    "auto_" + fileEntryTypeId);

            renderRequest.setAttribute(WebKeys.DYNAMIC_DATA_MAPPING_STRUCTURE, ddmStructure);
        }
    } catch (Exception e) {
        if (e instanceof NoSuchFileEntryTypeException || e instanceof PrincipalException) {

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

            return mapping.findForward("portlet.document_library.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.document_library.edit_file_entry_type"));
}

From source file:com.liferay.portlet.documentlibrary.action.EditFileShortcutAction.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 {//ww  w  .  j  a  v a2 s .  c  om
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateFileShortcut(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteFileShortcut(actionRequest);
        }

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

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

            setForward(actionRequest, "portlet.document_library.error");
        } else if (e instanceof FileShortcutPermissionException || e instanceof NoSuchFileEntryException) {

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

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

License:Open Source License

@Override
public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    try {// w  ww  . ja  va  2 s.  c o  m
        ActionUtil.getFileShortcut(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchFileShortcutException || e instanceof PrincipalException) {

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

            return mapping.findForward("portlet.document_library.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.document_library.edit_file_shortcut"));
}

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 {/*  w  w w.jav  a  2 s  .  c  om*/
        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;
        }
    }
}

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

License:Open Source License

@Override
public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    try {//from   w ww  .ja v a2  s. c om
        ActionUtil.getFolder(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchFolderException || e instanceof PrincipalException) {

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

            return mapping.findForward("portlet.document_library.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.document_library.edit_folder"));
}

From source file:com.liferay.portlet.documentlibrary.action.EditRepositoryAction.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 . j av a2  s . c  o m*/
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateRepository(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            unmountRepository(actionRequest);
        }

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

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

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

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

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

License:Open Source License

@Override
public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    try {/*from   w w w.  j a va  2s .  com*/
        ActionUtil.getRepository(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchRepositoryException || e instanceof PrincipalException) {

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

            return mapping.findForward("portlet.document_library.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.document_library.edit_repository"));
}