Example usage for com.liferay.portal.kernel.theme ThemeDisplay translate

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay translate

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay translate.

Prototype

public String translate(String key) 

Source Link

Usage

From source file:com.liferay.login.web.internal.portlet.action.CreateAnonymousAccountMVCRenderCommand.java

License:Open Source License

@Override
public String render(RenderRequest renderRequest, RenderResponse renderResponse) {

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

    PortletConfig portletConfig = (PortletConfig) renderRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

    String portletName = portletConfig.getPortletName();

    if (!portletName.equals(LoginPortletKeys.FAST_LOGIN)) {
        return "/login.jsp";
    }//from   ww w.j a  v a  2 s .co  m

    renderResponse.setTitle(themeDisplay.translate("anonymous-account"));

    return "/create_anonymous_account.jsp";
}

From source file:com.liferay.login.web.internal.portlet.action.ForgotPasswordMVCRenderCommand.java

License:Apache License

@Override
public String render(RenderRequest renderRequest, RenderResponse renderResponse) {

    System.out.println("In " + getClass().getName() + " render");

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

    Company company = themeDisplay.getCompany();

    if (!company.isSendPassword() && !company.isSendPasswordResetLink()) {
        return "/login.jsp";
    }//from  w  w w .  j  av  a  2  s .com

    renderResponse.setTitle(themeDisplay.translate("forgot-password"));

    return "/forgot_password.jsp";
}

From source file:com.liferay.message.boards.web.internal.util.MBBreadcrumbUtil.java

License:Open Source License

public static void addPortletBreadcrumbEntries(MBCategory category, HttpServletRequest request,
        RenderResponse renderResponse) throws Exception {

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

    String mvcRenderCommandName = ParamUtil.getString(request, "mvcRenderCommandName");

    PortletURL portletURL = renderResponse.createRenderURL();

    if (mvcRenderCommandName.equals("/message_boards/select_category")) {
        portletURL.setParameter("mvcRenderCommandName", "/message_boards/select_category");
        portletURL.setWindowState(LiferayWindowState.POP_UP);

        PortalUtil.addPortletBreadcrumbEntry(request, themeDisplay.translate("categories"),
                portletURL.toString());/*from  w  w w.  j a  v a 2 s  .  c  o m*/
    } else {
        portletURL.setParameter("mvcRenderCommandName", "/message_boards/view");
    }

    PortalUtil.addPortletBreadcrumbEntry(request, themeDisplay.translate("home"), portletURL.toString());

    if (category == null) {
        return;
    }

    if (!mvcRenderCommandName.equals("/message_boards/select_category")) {
        portletURL.setParameter("mvcRenderCommandName", "/message_boards/view_category");
    }

    List<MBCategory> ancestorCategories = category.getAncestors();

    Collections.reverse(ancestorCategories);

    for (MBCategory curCategory : ancestorCategories) {
        portletURL.setParameter("mbCategoryId", String.valueOf(curCategory.getCategoryId()));

        PortalUtil.addPortletBreadcrumbEntry(request, curCategory.getName(), portletURL.toString());
    }

    portletURL.setParameter("mbCategoryId", String.valueOf(category.getCategoryId()));

    PortalUtil.addPortletBreadcrumbEntry(request, category.getName(), portletURL.toString());
}

From source file:com.liferay.polls.web.internal.portlet.action.ViewChartMVCResourceCommand.java

License:Open Source License

@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
        throws Exception {

    try {//from w  w  w.jav  a 2s .  c o m
        ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);

        long questionId = ParamUtil.getLong(resourceRequest, "questionId");

        String chartType = ParamUtil.getString(resourceRequest, "chartType", "pie");
        String chartName = themeDisplay.translate("vote-results");
        String xName = themeDisplay.translate("choice");
        String yName = themeDisplay.translate("votes");

        CategoryDataset categoryDataset = PollsUtil.getVotesDataset(questionId);

        JFreeChart jFreeChat = null;

        if (chartType.equals("area")) {
            jFreeChat = ChartFactory.createAreaChart(chartName, xName, yName, categoryDataset,
                    PlotOrientation.VERTICAL, true, false, false);
        } else if (chartType.equals("horizontal_bar")) {
            jFreeChat = ChartFactory.createBarChart(chartName, xName, yName, categoryDataset,
                    PlotOrientation.HORIZONTAL, true, false, false);
        } else if (chartType.equals("line")) {
            jFreeChat = ChartFactory.createLineChart(chartName, xName, yName, categoryDataset,
                    PlotOrientation.VERTICAL, true, false, false);
        } else if (chartType.equals("vertical_bar")) {
            jFreeChat = ChartFactory.createBarChart(chartName, xName, yName, categoryDataset,
                    PlotOrientation.VERTICAL, true, false, false);
        } else {
            PieDataset pieDataset = DatasetUtilities.createPieDatasetForRow(categoryDataset, 0);

            jFreeChat = ChartFactory.createPieChart(chartName, pieDataset, true, false, false);
        }

        resourceResponse.setContentType(ContentTypes.IMAGE_JPEG);

        OutputStream outputStream = resourceResponse.getPortletOutputStream();

        ChartUtilities.writeChartAsJPEG(outputStream, jFreeChat, 400, 400);
    } catch (Exception e) {
        PortletSession portletSession = resourceRequest.getPortletSession();

        PortletContext portletContext = portletSession.getPortletContext();

        PortletRequestDispatcher requestDispatcher = portletContext.getRequestDispatcher("/polls/error.jsp");

        requestDispatcher.forward(resourceRequest, resourceResponse);
    }
}

From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java

License:Open Source License

protected Tuple getNewScope(ActionRequest actionRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Layout layout = themeDisplay.getLayout();

    String[] scopes = StringUtil.split(ParamUtil.getString(actionRequest, "scope"));

    String scopeType = scopes[0];

    long scopeGroupId = 0;
    String scopeName = null;/*  w  w  w .j  a va2s. com*/

    if (Validator.isNull(scopeType)) {
        scopeGroupId = layout.getGroupId();
    } else if (scopeType.equals("company")) {
        scopeGroupId = themeDisplay.getCompanyGroupId();
        scopeName = themeDisplay.translate("global");
    } else if (scopeType.equals("layout")) {
        String scopeLayoutUuid = scopes[1];

        Layout scopeLayout = _layoutLocalService.getLayoutByUuidAndGroupId(scopeLayoutUuid, layout.getGroupId(),
                layout.isPrivateLayout());

        if (!scopeLayout.hasScopeGroup()) {
            Map<Locale, String> nameMap = new HashMap<>();

            String name = String.valueOf(scopeLayout.getPlid());

            nameMap.put(LocaleUtil.getDefault(), name);

            _groupLocalService.addGroup(themeDisplay.getUserId(), GroupConstants.DEFAULT_PARENT_GROUP_ID,
                    Layout.class.getName(), scopeLayout.getPlid(), GroupConstants.DEFAULT_LIVE_GROUP_ID,
                    nameMap, null, 0, true, GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION, null, false, true,
                    null);
        }

        scopeGroupId = scopeLayout.getGroupId();
        scopeName = scopeLayout.getName(themeDisplay.getLocale());
    } else {
        throw new IllegalArgumentException("Scope type " + scopeType + " is invalid");
    }

    return new Tuple(scopeGroupId, scopeName);
}

From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java

License:Open Source License

protected String getOldScopeName(ActionRequest actionRequest, Portlet portlet) throws Exception {

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

    Layout layout = themeDisplay.getLayout();

    PortletPreferences portletPreferences = actionRequest.getPreferences();

    String scopeType = GetterUtil.getString(portletPreferences.getValue("lfrScopeType", null));

    if (Validator.isNull(scopeType)) {
        return null;
    }/*w ww  .j  a  v  a  2 s .  c  om*/

    String scopeName = null;

    if (scopeType.equals("company")) {
        scopeName = themeDisplay.translate("global");
    } else if (scopeType.equals("layout")) {
        String scopeLayoutUuid = GetterUtil.getString(portletPreferences.getValue("lfrScopeLayoutUuid", null));

        Layout scopeLayout = _layoutLocalService.fetchLayoutByUuidAndGroupId(scopeLayoutUuid,
                layout.getGroupId(), layout.isPrivateLayout());

        if (scopeLayout != null) {
            scopeName = scopeLayout.getName(themeDisplay.getLocale());
        }
    } else {
        throw new IllegalArgumentException("Scope type " + scopeType + " is invalid");
    }

    return scopeName;
}

From source file:com.liferay.server.admin.web.internal.portlet.action.ViewChartMVCResourceCommand.java

License:Open Source License

protected MeterPlot getMeterPlot(ThemeDisplay themeDisplay, ValueDataset valueDataset) {

    MeterPlot meterPlot = new MeterPlot(valueDataset);

    meterPlot.addInterval(new MeterInterval(themeDisplay.translate("normal"), new Range(0.0D, 75D),
            Color.lightGray, new BasicStroke(2.0F), new Color(0, 255, 0, 64)));

    meterPlot.addInterval(new MeterInterval(themeDisplay.translate("warning"), new Range(75D, 90D),
            Color.lightGray, new BasicStroke(2.0F), new Color(255, 255, 0, 64)));

    meterPlot.addInterval(new MeterInterval(themeDisplay.translate("critical"), new Range(90D, 100D),
            Color.lightGray, new BasicStroke(2.0F), new Color(255, 0, 0, 128)));

    meterPlot.setDialBackgroundPaint(Color.white);
    meterPlot.setDialShape(DialShape.PIE);
    meterPlot.setDialOutlinePaint(Color.gray);
    meterPlot.setTickLabelFont(new Font(null, Font.PLAIN, 10));
    meterPlot.setTickLabelPaint(Color.darkGray);
    meterPlot.setTickLabelsVisible(true);
    meterPlot.setTickPaint(Color.lightGray);
    meterPlot.setTickSize(5D);/*from   w  w w. j  av a2s.  c o m*/
    meterPlot.setMeterAngle(180);
    meterPlot.setNeedlePaint(Color.darkGray);
    meterPlot.setRange(new Range(0.0D, 100D));
    meterPlot.setValueFont(new Font(null, Font.PLAIN, 10));
    meterPlot.setValuePaint(Color.black);
    meterPlot.setUnits("%");

    return meterPlot;
}

From source file:com.liferay.site.admin.web.internal.portlet.SiteAdminPortlet.java

License:Open Source License

protected Group updateGroup(ActionRequest actionRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long userId = portal.getUserId(actionRequest);

    long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");

    long parentGroupId = ParamUtil.getLong(actionRequest, "parentGroupSearchContainerPrimaryKeys",
            GroupConstants.DEFAULT_PARENT_GROUP_ID);
    Map<Locale, String> nameMap = null;
    Map<Locale, String> descriptionMap = null;
    int type = 0;
    String friendlyURL = null;//from   w  w  w. ja va 2 s.co  m
    boolean inheritContent = false;
    boolean active = false;
    boolean manualMembership = true;

    int membershipRestriction = GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION;

    boolean actionRequestMembershipRestriction = ParamUtil.getBoolean(actionRequest, "membershipRestriction");

    if (actionRequestMembershipRestriction && (parentGroupId != GroupConstants.DEFAULT_PARENT_GROUP_ID)) {

        membershipRestriction = GroupConstants.MEMBERSHIP_RESTRICTION_TO_PARENT_SITE_MEMBERS;
    }

    ServiceContext serviceContext = ServiceContextFactory.getInstance(Group.class.getName(), actionRequest);

    ServiceContextThreadLocal.pushServiceContext(serviceContext);

    Group liveGroup = null;

    if (liveGroupId <= 0) {

        // Add group

        nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name");
        descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description");
        type = ParamUtil.getInteger(actionRequest, "type");
        friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL");
        manualMembership = ParamUtil.getBoolean(actionRequest, "manualMembership");
        inheritContent = ParamUtil.getBoolean(actionRequest, "inheritContent");
        active = ParamUtil.getBoolean(actionRequest, "active");

        liveGroup = groupService.addGroup(parentGroupId, GroupConstants.DEFAULT_LIVE_GROUP_ID, nameMap,
                descriptionMap, type, manualMembership, membershipRestriction, friendlyURL, true,
                inheritContent, active, serviceContext);

        LiveUsers.joinGroup(themeDisplay.getCompanyId(), liveGroup.getGroupId(), userId);
    } else {

        // Update group

        liveGroup = groupLocalService.getGroup(liveGroupId);

        nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name", liveGroup.getNameMap());
        descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description",
                liveGroup.getDescriptionMap());
        type = ParamUtil.getInteger(actionRequest, "type", liveGroup.getType());
        manualMembership = ParamUtil.getBoolean(actionRequest, "manualMembership",
                liveGroup.isManualMembership());
        friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL", liveGroup.getFriendlyURL());
        inheritContent = ParamUtil.getBoolean(actionRequest, "inheritContent", liveGroup.getInheritContent());
        active = ParamUtil.getBoolean(actionRequest, "active", liveGroup.getActive());

        liveGroup = groupService.updateGroup(liveGroupId, parentGroupId, nameMap, descriptionMap, type,
                manualMembership, membershipRestriction, friendlyURL, inheritContent, active, serviceContext);

        if (type == GroupConstants.TYPE_SITE_OPEN) {
            List<MembershipRequest> membershipRequests = membershipRequestLocalService.search(liveGroupId,
                    MembershipRequestConstants.STATUS_PENDING, QueryUtil.ALL_POS, QueryUtil.ALL_POS);

            for (MembershipRequest membershipRequest : membershipRequests) {
                membershipRequestService.updateStatus(membershipRequest.getMembershipRequestId(),
                        themeDisplay.translate("your-membership-has-been-approved"),
                        MembershipRequestConstants.STATUS_APPROVED, serviceContext);

                LiveUsers.joinGroup(themeDisplay.getCompanyId(), membershipRequest.getGroupId(),
                        new long[] { membershipRequest.getUserId() });
            }
        }
    }

    // Settings

    UnicodeProperties typeSettingsProperties = liveGroup.getTypeSettingsProperties();

    String customJspServletContextName = ParamUtil.getString(actionRequest, "customJspServletContextName",
            typeSettingsProperties.getProperty("customJspServletContextName"));

    typeSettingsProperties.setProperty("customJspServletContextName", customJspServletContextName);

    typeSettingsProperties.setProperty("defaultSiteRoleIds",
            ListUtil.toString(getRoles(actionRequest), Role.ROLE_ID_ACCESSOR, StringPool.COMMA));
    typeSettingsProperties.setProperty("defaultTeamIds",
            ListUtil.toString(getTeams(actionRequest), Team.TEAM_ID_ACCESSOR, StringPool.COMMA));

    String[] analyticsTypes = PrefsPropsUtil.getStringArray(themeDisplay.getCompanyId(),
            PropsKeys.ADMIN_ANALYTICS_TYPES, StringPool.NEW_LINE);

    for (String analyticsType : analyticsTypes) {
        if (StringUtil.equalsIgnoreCase(analyticsType, "google")) {
            String googleAnalyticsId = ParamUtil.getString(actionRequest, "googleAnalyticsId",
                    typeSettingsProperties.getProperty("googleAnalyticsId"));

            typeSettingsProperties.setProperty("googleAnalyticsId", googleAnalyticsId);
        } else {
            String analyticsScript = ParamUtil.getString(actionRequest, Sites.ANALYTICS_PREFIX + analyticsType,
                    typeSettingsProperties.getProperty(analyticsType));

            typeSettingsProperties.setProperty(Sites.ANALYTICS_PREFIX + analyticsType, analyticsScript);
        }
    }

    boolean trashEnabled = ParamUtil.getBoolean(actionRequest, "trashEnabled",
            GetterUtil.getBoolean(typeSettingsProperties.getProperty("trashEnabled"), true));

    typeSettingsProperties.setProperty("trashEnabled", String.valueOf(trashEnabled));

    int trashEntriesMaxAgeCompany = PrefsPropsUtil.getInteger(themeDisplay.getCompanyId(),
            PropsKeys.TRASH_ENTRIES_MAX_AGE);

    int trashEntriesMaxAgeGroup = ParamUtil.getInteger(actionRequest, "trashEntriesMaxAge");

    if (trashEntriesMaxAgeGroup <= 0) {
        trashEntriesMaxAgeGroup = GetterUtil.getInteger(
                typeSettingsProperties.getProperty("trashEntriesMaxAge"), trashEntriesMaxAgeCompany);
    }

    if (trashEntriesMaxAgeGroup != trashEntriesMaxAgeCompany) {
        typeSettingsProperties.setProperty("trashEntriesMaxAge",
                String.valueOf(GetterUtil.getInteger(trashEntriesMaxAgeGroup)));
    } else {
        typeSettingsProperties.remove("trashEntriesMaxAge");
    }

    int contentSharingWithChildrenEnabled = ParamUtil.getInteger(actionRequest,
            "contentSharingWithChildrenEnabled",
            GetterUtil.getInteger(typeSettingsProperties.getProperty("contentSharingWithChildrenEnabled"),
                    Sites.CONTENT_SHARING_WITH_CHILDREN_DEFAULT_VALUE));

    typeSettingsProperties.setProperty("contentSharingWithChildrenEnabled",
            String.valueOf(contentSharingWithChildrenEnabled));

    UnicodeProperties formTypeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest,
            "TypeSettingsProperties--");

    typeSettingsProperties.putAll(formTypeSettingsProperties);

    // Virtual hosts

    LayoutSet publicLayoutSet = liveGroup.getPublicLayoutSet();

    String publicVirtualHost = ParamUtil.getString(actionRequest, "publicVirtualHost",
            publicLayoutSet.getVirtualHostname());

    layoutSetService.updateVirtualHost(liveGroup.getGroupId(), false, publicVirtualHost);

    LayoutSet privateLayoutSet = liveGroup.getPrivateLayoutSet();

    String privateVirtualHost = ParamUtil.getString(actionRequest, "privateVirtualHost",
            privateLayoutSet.getVirtualHostname());

    layoutSetService.updateVirtualHost(liveGroup.getGroupId(), true, privateVirtualHost);

    // Staging

    if (liveGroup.hasStagingGroup()) {
        Group stagingGroup = liveGroup.getStagingGroup();

        friendlyURL = ParamUtil.getString(actionRequest, "stagingFriendlyURL", stagingGroup.getFriendlyURL());

        groupService.updateFriendlyURL(stagingGroup.getGroupId(), friendlyURL);

        LayoutSet stagingPublicLayoutSet = stagingGroup.getPublicLayoutSet();

        publicVirtualHost = ParamUtil.getString(actionRequest, "stagingPublicVirtualHost",
                stagingPublicLayoutSet.getVirtualHostname());

        layoutSetService.updateVirtualHost(stagingGroup.getGroupId(), false, publicVirtualHost);

        LayoutSet stagingPrivateLayoutSet = stagingGroup.getPrivateLayoutSet();

        privateVirtualHost = ParamUtil.getString(actionRequest, "stagingPrivateVirtualHost",
                stagingPrivateLayoutSet.getVirtualHostname());

        layoutSetService.updateVirtualHost(stagingGroup.getGroupId(), true, privateVirtualHost);

        UnicodeProperties stagedGroupTypeSettingsProperties = stagingGroup.getTypeSettingsProperties();

        stagedGroupTypeSettingsProperties.putAll(formTypeSettingsProperties);

        groupService.updateGroup(stagingGroup.getGroupId(), stagedGroupTypeSettingsProperties.toString());
    }

    liveGroup = groupService.updateGroup(liveGroup.getGroupId(), typeSettingsProperties.toString());

    // Layout set prototypes

    long privateLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "privateLayoutSetPrototypeId");
    long publicLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "publicLayoutSetPrototypeId");

    boolean privateLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest,
            "privateLayoutSetPrototypeLinkEnabled", privateLayoutSet.isLayoutSetPrototypeLinkEnabled());
    boolean publicLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest,
            "publicLayoutSetPrototypeLinkEnabled", publicLayoutSet.isLayoutSetPrototypeLinkEnabled());

    if ((privateLayoutSetPrototypeId == 0) && (publicLayoutSetPrototypeId == 0)
            && !privateLayoutSetPrototypeLinkEnabled && !publicLayoutSetPrototypeLinkEnabled) {

        long layoutSetPrototypeId = ParamUtil.getLong(actionRequest, "layoutSetPrototypeId");
        int layoutSetVisibility = ParamUtil.getInteger(actionRequest, "layoutSetVisibility");
        boolean layoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest,
                "layoutSetPrototypeLinkEnabled", layoutSetPrototypeId > 0);

        if (layoutSetVisibility == _LAYOUT_SET_VISIBILITY_PRIVATE) {
            privateLayoutSetPrototypeId = layoutSetPrototypeId;

            privateLayoutSetPrototypeLinkEnabled = layoutSetPrototypeLinkEnabled;
        } else {
            publicLayoutSetPrototypeId = layoutSetPrototypeId;

            publicLayoutSetPrototypeLinkEnabled = layoutSetPrototypeLinkEnabled;
        }
    }

    if (!liveGroup.isStaged() || liveGroup.isStagedRemotely()) {
        SitesUtil.updateLayoutSetPrototypesLinks(liveGroup, publicLayoutSetPrototypeId,
                privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled,
                privateLayoutSetPrototypeLinkEnabled);
    } else {
        SitesUtil.updateLayoutSetPrototypesLinks(liveGroup.getStagingGroup(), publicLayoutSetPrototypeId,
                privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled,
                privateLayoutSetPrototypeLinkEnabled);
    }

    themeDisplay.setSiteGroupId(liveGroup.getGroupId());

    return liveGroup;
}

From source file:com.liferay.wiki.trash.WikiNodeTrashHandler.java

License:Open Source License

@Override
public String getRestoreMessage(PortletRequest portletRequest, long classPK) {

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

    return themeDisplay.translate("wiki");
}

From source file:com.liferay.wiki.web.internal.portlet.action.EditPageAttachmentsMVCActionCommand.java

License:Open Source License

/**
 * TODO: Remove. This should extend from EditFileEntryAction once it is
 * modularized.//from   w w  w.j a va 2  s. co  m
 */
protected void handleUploadException(PortletConfig portletConfig, ActionRequest actionRequest,
        ActionResponse actionResponse, String cmd, Exception e) throws Exception {

    if (e instanceof AssetCategoryException || e instanceof AssetTagException) {

        SessionErrors.add(actionRequest, e.getClass(), e);
    } else if (e instanceof AntivirusScannerException || e instanceof DuplicateFileEntryException
            || e instanceof DuplicateFolderNameException || e instanceof FileExtensionException
            || e instanceof FileMimeTypeException || e instanceof FileNameException
            || e instanceof FileSizeException || e instanceof LiferayFileItemException
            || e instanceof NoSuchFolderException || e instanceof SourceFileNameException
            || e instanceof StorageFieldRequiredException || e instanceof UploadRequestSizeException) {

        if (!cmd.equals(Constants.ADD_DYNAMIC) && !cmd.equals(Constants.ADD_MULTIPLE)
                && !cmd.equals(Constants.ADD_TEMP)) {

            if (e instanceof AntivirusScannerException) {
                SessionErrors.add(actionRequest, e.getClass(), e);
            } else {
                SessionErrors.add(actionRequest, e.getClass());
            }

            return;
        } else if (cmd.equals(Constants.ADD_TEMP)) {
            hideDefaultErrorMessage(actionRequest);
        }

        if (e instanceof AntivirusScannerException || e instanceof DuplicateFileEntryException
                || e instanceof FileExtensionException || e instanceof FileNameException
                || e instanceof FileSizeException || e instanceof UploadRequestSizeException) {

            HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);

            response.setContentType(ContentTypes.TEXT_HTML);
            response.setStatus(HttpServletResponse.SC_OK);

            String errorMessage = StringPool.BLANK;
            int errorType = 0;

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

            if (e instanceof AntivirusScannerException) {
                AntivirusScannerException ase = (AntivirusScannerException) e;

                errorMessage = themeDisplay.translate(ase.getMessageKey());
                errorType = ServletResponseConstants.SC_FILE_ANTIVIRUS_EXCEPTION;
            }

            if (e instanceof DuplicateFileEntryException) {
                errorMessage = themeDisplay.translate("please-enter-a-unique-document-name");
                errorType = ServletResponseConstants.SC_DUPLICATE_FILE_EXCEPTION;
            } else if (e instanceof FileExtensionException) {
                errorMessage = themeDisplay.translate("please-enter-a-file-with-a-valid-extension-x", StringUtil
                        .merge(getAllowedFileExtensions(portletConfig, actionRequest, actionResponse)));
                errorType = ServletResponseConstants.SC_FILE_EXTENSION_EXCEPTION;
            } else if (e instanceof FileNameException) {
                errorMessage = themeDisplay.translate("please-enter-a-file-with-a-valid-file-name");
                errorType = ServletResponseConstants.SC_FILE_NAME_EXCEPTION;
            } else if (e instanceof FileSizeException) {
                long fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE);

                if (fileMaxSize == 0) {
                    fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.UPLOAD_SERVLET_REQUEST_IMPL_MAX_SIZE);
                }

                errorMessage = themeDisplay.translate(
                        "please-enter-a-file-with-a-valid-file-size-no-larger" + "-than-x",
                        TextFormatter.formatStorageSize(fileMaxSize, themeDisplay.getLocale()));

                errorType = ServletResponseConstants.SC_FILE_SIZE_EXCEPTION;
            }

            JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

            jsonObject.put("message", errorMessage);
            jsonObject.put("status", errorType);

            JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject);
        }

        if (e instanceof AntivirusScannerException) {
            SessionErrors.add(actionRequest, e.getClass(), e);
        } else {
            SessionErrors.add(actionRequest, e.getClass());
        }
    } else if (e instanceof DuplicateLockException || e instanceof InvalidFileVersionException
            || e instanceof NoSuchFileEntryException || e instanceof PrincipalException) {

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

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

        actionResponse.setRenderParameter("mvcPath", "/html/porltet/document_library/error.jsp");
    } else {
        Throwable cause = e.getCause();

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