List of usage examples for com.liferay.portal.kernel.servlet SessionMessages add
public static void add(PortletRequest portletRequest, String key)
From source file:com.liferay.portlet.plugininstaller.action.InstallPluginAction.java
License:Open Source License
protected void uninstall(ActionRequest actionRequest) throws Exception { String appServerType = ServerDetector.getServerId(); String deploymentContext = ParamUtil.getString(actionRequest, "deploymentContext"); if (appServerType.startsWith(ServerDetector.JBOSS_ID)) { deploymentContext += ".war"; }//from w w w. j a v a2 s.c om File deployDir = new File(DeployUtil.getAutoDeployDestDir() + "/" + deploymentContext); DeployUtil.undeploy(appServerType, deployDir); SessionMessages.add(actionRequest, "triggeredPortletUndeploy"); }
From source file:com.liferay.portlet.rolesadmin.action.EditRolePermissionsAction.java
License:Open Source License
protected void deletePermission(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long roleId = ParamUtil.getLong(actionRequest, "roleId"); long permissionId = ParamUtil.getLong(actionRequest, "permissionId"); String name = ParamUtil.getString(actionRequest, "name"); int scope = ParamUtil.getInteger(actionRequest, "scope"); String primKey = ParamUtil.getString(actionRequest, "primKey"); String actionId = ParamUtil.getString(actionRequest, "actionId"); Role role = RoleLocalServiceUtil.getRole(roleId); String roleName = role.getName(); if (roleName.equals(RoleConstants.ADMINISTRATOR) || roleName.equals(RoleConstants.ORGANIZATION_ADMINISTRATOR) || roleName.equals(RoleConstants.ORGANIZATION_OWNER) || roleName.equals(RoleConstants.OWNER) || roleName.equals(RoleConstants.SITE_ADMINISTRATOR) || roleName.equals(RoleConstants.SITE_OWNER)) { throw new RolePermissionsException(roleName); }//from ww w. j av a 2s . c om if (PropsValues.PERMISSIONS_USER_CHECK_ALGORITHM == 6) { if (ResourceBlockLocalServiceUtil.isSupported(name)) { if (scope == ResourceConstants.SCOPE_GROUP) { ResourceBlockServiceUtil.removeGroupScopePermission(themeDisplay.getScopeGroupId(), themeDisplay.getCompanyId(), GetterUtil.getLong(primKey), name, roleId, actionId); } else { ResourceBlockServiceUtil.removeCompanyScopePermission(themeDisplay.getScopeGroupId(), themeDisplay.getCompanyId(), name, roleId, actionId); } } else { ResourcePermissionServiceUtil.removeResourcePermission(themeDisplay.getScopeGroupId(), themeDisplay.getCompanyId(), name, scope, primKey, roleId, actionId); } } else { PermissionServiceUtil.unsetRolePermission(roleId, themeDisplay.getScopeGroupId(), permissionId); } // Send redirect SessionMessages.add(actionRequest, "permissionDeleted"); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } }
From source file:com.liferay.portlet.rolesadmin.action.EditRolePermissionsAction.java
License:Open Source License
protected void updateActions(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long roleId = ParamUtil.getLong(actionRequest, "roleId"); Role role = RoleLocalServiceUtil.getRole(roleId); String roleName = role.getName(); if (roleName.equals(RoleConstants.ADMINISTRATOR) || roleName.equals(RoleConstants.ORGANIZATION_ADMINISTRATOR) || roleName.equals(RoleConstants.ORGANIZATION_OWNER) || roleName.equals(RoleConstants.OWNER) || roleName.equals(RoleConstants.SITE_ADMINISTRATOR) || roleName.equals(RoleConstants.SITE_OWNER)) { throw new RolePermissionsException(roleName); }// w ww . ja v a 2 s .c o m String portletResource = ParamUtil.getString(actionRequest, "portletResource"); String[] modelResources = StringUtil.split(ParamUtil.getString(actionRequest, "modelResources")); boolean showModelResources = ParamUtil.getBoolean(actionRequest, "showModelResources"); Map<String, List<String>> resourceActionsMap = new HashMap<String, List<String>>(); if (showModelResources) { for (String modelResource : modelResources) { resourceActionsMap.put(modelResource, ResourceActionsUtil.getResourceActions(null, modelResource)); } } else if (Validator.isNotNull(portletResource)) { resourceActionsMap.put(portletResource, ResourceActionsUtil.getResourceActions(portletResource, null)); } String[] selectedTargets = StringUtil.split(ParamUtil.getString(actionRequest, "selectedTargets")); for (Map.Entry<String, List<String>> entry : resourceActionsMap.entrySet()) { String selResource = entry.getKey(); List<String> actions = entry.getValue(); actions = ListUtil.sort(actions, new ActionComparator(themeDisplay.getLocale())); for (String actionId : actions) { String target = selResource + actionId; boolean selected = ArrayUtil.contains(selectedTargets, target); String[] groupIds = StringUtil.split(ParamUtil.getString(actionRequest, "groupIds" + target)); groupIds = ArrayUtil.distinct(groupIds); int scope = ResourceConstants.SCOPE_COMPANY; if ((role.getType() == RoleConstants.TYPE_ORGANIZATION) || (role.getType() == RoleConstants.TYPE_PROVIDER) || (role.getType() == RoleConstants.TYPE_SITE)) { scope = ResourceConstants.SCOPE_GROUP_TEMPLATE; } else { if (groupIds.length > 0) { scope = ResourceConstants.SCOPE_GROUP; } } if (PropsValues.PERMISSIONS_USER_CHECK_ALGORITHM == 6) { if (ResourceBlockLocalServiceUtil.isSupported(selResource)) { updateActions_6Blocks(role, themeDisplay.getScopeGroupId(), selResource, actionId, selected, scope, groupIds); } else { updateAction_6(role, themeDisplay.getScopeGroupId(), selResource, actionId, selected, scope, groupIds); } } else { updateAction_1to5(role, themeDisplay.getScopeGroupId(), selResource, actionId, selected, scope, groupIds); } } } // Send redirect SessionMessages.add(actionRequest, "permissionsUpdated"); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { redirect = redirect + "&" + Constants.CMD + "=" + Constants.VIEW; actionResponse.sendRedirect(redirect); } }
From source file:com.liferay.portlet.sample.WCSearchPortlet.java
License:Open Source License
@Override public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { try {//from www .jav a2s.com String cmd = ParamUtil.getString(actionRequest, Constants.CMD); if (Validator.isNotNull(cmd)) { if (SessionErrors.isEmpty(actionRequest)) { SessionMessages.add(actionRequest, "requestProcessed"); } String redirect = ParamUtil.getString(actionRequest, "redirect"); actionResponse.sendRedirect(redirect); } } catch (Exception e) { throw new PortletException(e); } }
From source file:com.liferay.portlet.sites.action.PostMembershipRequestAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try {//from w w w .j a v a2 s . co m long groupId = ParamUtil.getLong(actionRequest, "groupId"); String comments = ParamUtil.getString(actionRequest, "comments"); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); MembershipRequestServiceUtil.addMembershipRequest(groupId, comments, serviceContext); SessionMessages.add(actionRequest, "membership_request_sent"); sendRedirect(actionRequest, actionResponse); } catch (Exception e) { if (e instanceof NoSuchGroupException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.sites_admin.error"); } else if (e instanceof MembershipRequestCommentsException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.sites_admin.post_membership_request"); } else { throw e; } } }
From source file:com.liferay.portlet.sites.action.ReplyMembershipRequestAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try {//from ww w . j a v a2 s .c o m ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long membershipRequestId = ParamUtil.getLong(actionRequest, "membershipRequestId"); int statusId = ParamUtil.getInteger(actionRequest, "statusId"); String replyComments = ParamUtil.getString(actionRequest, "replyComments"); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); MembershipRequestServiceUtil.updateStatus(membershipRequestId, replyComments, statusId, serviceContext); if (statusId == MembershipRequestConstants.STATUS_APPROVED) { MembershipRequest membershipRequest = MembershipRequestServiceUtil .getMembershipRequest(membershipRequestId); LiveUsers.joinGroup(themeDisplay.getCompanyId(), membershipRequest.getGroupId(), new long[] { membershipRequest.getUserId() }); } SessionMessages.add(actionRequest, "membership_reply_sent"); sendRedirect(actionRequest, actionResponse); } catch (Exception e) { if (e instanceof NoSuchGroupException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.sites_admin.error"); } else if (e instanceof MembershipRequestCommentsException) { SessionErrors.add(actionRequest, e.getClass().getName()); setForward(actionRequest, "portlet.sites_admin.reply_membership_request"); } else { throw e; } } }
From source file:com.liferay.portlet.stagingbar.action.EditLayoutBranchAction.java
License:Open Source License
protected void deleteLayoutBranch(ActionRequest actionRequest, PortletConfig portletConfig) throws Exception { long layoutBranchId = ParamUtil.getLong(actionRequest, "layoutBranchId"); long currentLayoutBranchId = ParamUtil.getLong(actionRequest, "currentLayoutBranchId"); LayoutBranchServiceUtil.deleteLayoutBranch(layoutBranchId); SessionMessages.add(actionRequest, "pageVariationDeleted"); if (layoutBranchId == currentLayoutBranchId) { SessionMessages.add(actionRequest, portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_PORTLET_NOT_AJAXABLE); }//from w w w . ja v a2 s . c o m }
From source file:com.liferay.portlet.stagingbar.action.EditLayoutBranchAction.java
License:Open Source License
protected void updateLayoutBranch(ActionRequest actionRequest) throws Exception { long layoutBranchId = ParamUtil.getLong(actionRequest, "layoutBranchId"); long layoutRevisionId = ParamUtil.getLong(actionRequest, "copyLayoutRevisionId"); String name = ParamUtil.getString(actionRequest, "name"); String description = ParamUtil.getString(actionRequest, "description"); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); if (layoutBranchId <= 0) { LayoutBranchServiceUtil.addLayoutBranch(layoutRevisionId, name, description, false, serviceContext); SessionMessages.add(actionRequest, "pageVariationAdded"); } else {//from w w w . j ava 2 s . c o m LayoutBranchServiceUtil.updateLayoutBranch(layoutBranchId, name, description, serviceContext); SessionMessages.add(actionRequest, "pageVariationUpdated"); } }
From source file:com.liferay.portlet.stagingbar.action.EditLayoutSetBranchAction.java
License:Open Source License
protected void deleteLayoutSetBranch(ActionRequest actionRequest, PortletConfig portletConfig) throws Exception { long layoutSetBranchId = ParamUtil.getLong(actionRequest, "layoutSetBranchId"); long currentLayoutBranchId = ParamUtil.getLong(actionRequest, "currentLayoutBranchId"); if (layoutSetBranchId == currentLayoutBranchId) { SessionMessages.add(actionRequest, portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_PORTLET_NOT_AJAXABLE); }//from w ww . ja v a 2 s. c om LayoutSetBranchServiceUtil.deleteLayoutSetBranch(layoutSetBranchId); SessionMessages.add(actionRequest, "sitePageVariationDeleted"); }
From source file:com.liferay.portlet.stagingbar.action.EditLayoutSetBranchAction.java
License:Open Source License
protected void mergeLayoutSetBranch(ActionRequest actionRequest) throws Exception { long layoutSetBranchId = ParamUtil.getLong(actionRequest, "layoutSetBranchId"); long mergeLayoutSetBranchId = ParamUtil.getLong(actionRequest, "mergeLayoutSetBranchId"); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); LayoutSetBranchServiceUtil.mergeLayoutSetBranch(layoutSetBranchId, mergeLayoutSetBranchId, serviceContext); SessionMessages.add(actionRequest, "sitePageVariationMerged"); }