List of usage examples for com.liferay.portal.kernel.model Portlet getPermissionPropagatorInstance
public com.liferay.portal.kernel.security.permission.propagator.PermissionPropagator getPermissionPropagatorInstance();
From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java
License:Open Source License
public void updateRolePermissions(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); String modelResource = ParamUtil.getString(actionRequest, "modelResource"); long[] roleIds = StringUtil.split(ParamUtil.getString(actionRequest, "rolesSearchContainerPrimaryKeys"), 0L);//ww w. j a v a2 s.c om String selResource = PortletConstants.getRootPortletId(portletResource); if (Validator.isNotNull(modelResource)) { selResource = modelResource; } long resourceGroupId = ParamUtil.getLong(actionRequest, "resourceGroupId", themeDisplay.getScopeGroupId()); String resourcePrimKey = ParamUtil.getString(actionRequest, "resourcePrimKey"); Map<Long, String[]> roleIdsToActionIds = new HashMap<>(); if (_resourceBlockLocalService.isSupported(selResource)) { for (long roleId : roleIds) { List<String> actionIds = getActionIdsList(actionRequest, roleId, true); roleIdsToActionIds.put(roleId, actionIds.toArray(new String[actionIds.size()])); } _resourceBlockService.setIndividualScopePermissions(themeDisplay.getCompanyId(), resourceGroupId, selResource, GetterUtil.getLong(resourcePrimKey), roleIdsToActionIds); } else { for (long roleId : roleIds) { String[] actionIds = getActionIds(actionRequest, roleId, false); roleIdsToActionIds.put(roleId, actionIds); } _resourcePermissionService.setIndividualResourcePermissions(resourceGroupId, themeDisplay.getCompanyId(), selResource, resourcePrimKey, roleIdsToActionIds); } if (PropsValues.PERMISSIONS_PROPAGATION_ENABLED) { Portlet portlet = _portletLocalService.getPortletById(themeDisplay.getCompanyId(), portletResource); PermissionPropagator permissionPropagator = portlet.getPermissionPropagatorInstance(); if (permissionPropagator != null) { permissionPropagator.propagateRolePermissions(actionRequest, modelResource, resourcePrimKey, roleIds); } } if (Validator.isNull(modelResource)) { // Force update of layout modified date. See LPS-59246. Portlet portlet = ActionUtil.getPortlet(actionRequest); PortletPreferences portletPreferences = ActionUtil.getLayoutPortletSetup(actionRequest, portlet); portletPreferences.store(); } }