List of usage examples for com.liferay.portal.kernel.model RoleConstants OWNER
String OWNER
To view the source code for com.liferay.portal.kernel.model RoleConstants OWNER.
Click Source Link
From source file:com.liferay.dynamic.data.mapping.internal.upgrade.v1_0_0.UpgradeDynamicDataMapping.java
License:Open Source License
public UpgradeDynamicDataMapping(AssetEntryLocalService assetEntryLocalService, DDM ddm, DDMFormJSONDeserializer ddmFormJSONDeserializer, DDMFormJSONSerializer ddmFormJSONSerializer, DDMFormLayoutJSONSerializer ddmFormLayoutJSONSerializer, DDMFormValuesJSONDeserializer ddmFormValuesJSONDeserializer, DDMFormValuesJSONSerializer ddmFormValuesJSONSerializer, DDMFormXSDDeserializer ddmFormXSDDeserializer, DLFileEntryLocalService dlFileEntryLocalService, DLFileVersionLocalService dlFileVersionLocalService, DLFolderLocalService dlFolderLocalService, ExpandoRowLocalService expandoRowLocalService, ExpandoTableLocalService expandoTableLocalService, ExpandoValueLocalService expandoValueLocalService, ResourceActions resourceActions, ResourceLocalService resourceLocalService, ResourcePermissionLocalService resourcePermissionLocalService) { _assetEntryLocalService = assetEntryLocalService; _ddm = ddm;// w ww.ja v a 2 s . c o m _ddmFormJSONDeserializer = ddmFormJSONDeserializer; _ddmFormJSONSerializer = ddmFormJSONSerializer; _ddmFormLayoutJSONSerializer = ddmFormLayoutJSONSerializer; _ddmFormValuesJSONDeserializer = ddmFormValuesJSONDeserializer; _ddmFormValuesJSONSerializer = ddmFormValuesJSONSerializer; _ddmFormXSDDeserializer = ddmFormXSDDeserializer; _dlFileEntryLocalService = dlFileEntryLocalService; _dlFileVersionLocalService = dlFileVersionLocalService; _dlFolderLocalService = dlFolderLocalService; _expandoRowLocalService = expandoRowLocalService; _expandoTableLocalService = expandoTableLocalService; _expandoValueLocalService = expandoValueLocalService; _resourceLocalService = resourceLocalService; _resourcePermissionLocalService = resourcePermissionLocalService; _dlFolderModelPermissions = ModelPermissionsFactory.create(_DLFOLDER_GROUP_PERMISSIONS, _DLFOLDER_GUEST_PERMISSIONS); _dlFolderModelPermissions.addRolePermissions(RoleConstants.OWNER, _DLFOLDER_OWNER_PERMISSIONS); _initModelResourceNames(resourceActions); }
From source file:com.liferay.roles.admin.web.internal.portlet.configuration.icon.PermissionsPortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { try {//w w w .j a v a 2 s. c o m ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); long roleId = _getRoleId(portletRequest); Role role = _roleService.fetchRole(roleId); String roleName = role.getName(); if (!roleName.equals(RoleConstants.OWNER) && RolePermissionUtil .contains(themeDisplay.getPermissionChecker(), roleId, ActionKeys.PERMISSIONS)) { return true; } return false; } catch (Exception e) { } return false; }
From source file:com.liferay.roles.admin.web.internal.portlet.RolesAdminPortlet.java
License:Open Source License
public void deletePermission(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long roleId = ParamUtil.getLong(actionRequest, "roleId"); 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 = _roleLocalService.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 w w w . jav a2 s. c o m*/ _resourcePermissionService.removeResourcePermission(themeDisplay.getScopeGroupId(), themeDisplay.getCompanyId(), name, scope, primKey, roleId, actionId); // Send redirect SessionMessages.add(actionRequest, "permissionDeleted"); String redirect = _portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } }
From source file:com.liferay.roles.admin.web.internal.portlet.RolesAdminPortlet.java
License:Open Source License
public void editRoleAssignments(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { long roleId = ParamUtil.getLong(actionRequest, "roleId"); Role role = _roleLocalService.getRole(roleId); String roleName = role.getName(); if (roleName.equals(RoleConstants.OWNER)) { throw new RoleAssignmentException(roleName); }/*from ww w.java 2 s. com*/ long[] addUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "addUserIds"), 0L); long[] removeUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "removeUserIds"), 0L); if (!ArrayUtil.isEmpty(addUserIds) || !ArrayUtil.isEmpty(removeUserIds)) { try (ProxyModeThreadLocalCloseable proxyModeThreadLocalCloseable = new ProxyModeThreadLocalCloseable()) { ProxyModeThreadLocal.setForceSync(true); _userService.addRoleUsers(roleId, addUserIds); _userService.unsetRoleUsers(roleId, removeUserIds); } } long[] addGroupIds = StringUtil.split(ParamUtil.getString(actionRequest, "addGroupIds"), 0L); long[] removeGroupIds = StringUtil.split(ParamUtil.getString(actionRequest, "removeGroupIds"), 0L); if (!ArrayUtil.isEmpty(addGroupIds) || !ArrayUtil.isEmpty(removeGroupIds)) { _groupService.addRoleGroups(roleId, addGroupIds); _groupService.unsetRoleGroups(roleId, removeGroupIds); } }
From source file:com.liferay.roles.admin.web.internal.portlet.RolesAdminPortlet.java
License:Open Source License
public void updateActions(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long roleId = ParamUtil.getLong(actionRequest, "roleId"); Role role = _roleLocalService.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 w w w . j av a 2 s . co m*/ String portletResource = ParamUtil.getString(actionRequest, "portletResource"); String[] relatedPortletResources = StringUtil .split(ParamUtil.getString(actionRequest, "relatedPortletResources")); String[] modelResources = StringUtil.split(ParamUtil.getString(actionRequest, "modelResources")); Map<String, List<String>> resourceActionsMap = new HashMap<>(); if (Validator.isNotNull(portletResource)) { resourceActionsMap.put(portletResource, ResourceActionsUtil.getResourceActions(portletResource, null)); } for (String relatedPortletResource : relatedPortletResources) { resourceActionsMap.put(relatedPortletResource, ResourceActionsUtil.getResourceActions(relatedPortletResource, null)); } for (String modelResource : modelResources) { resourceActionsMap.put(modelResource, ResourceActionsUtil.getResourceActions(null, modelResource)); } int rootResourceScope = ResourceConstants.SCOPE_COMPANY; String[] rootResourceGroupIds = null; String[] selectedTargets = StringUtil.split(ParamUtil.getString(actionRequest, "selectedTargets")); String[] unselectedTargets = StringUtil.split(ParamUtil.getString(actionRequest, "unselectedTargets")); 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); if (!selected && !ArrayUtil.contains(unselectedTargets, target)) { continue; } 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; } } updateAction(role, themeDisplay.getScopeGroupId(), selResource, actionId, selected, scope, groupIds); if (selected && actionId.equals(ActionKeys.ACCESS_IN_CONTROL_PANEL)) { updateViewControlPanelPermission(role, themeDisplay.getScopeGroupId(), selResource, scope, groupIds); rootResourceScope = scope; rootResourceGroupIds = groupIds; } } } // LPS-38031 if (rootResourceGroupIds != null) { updateViewRootResourcePermission(role, themeDisplay.getScopeGroupId(), portletResource, rootResourceScope, rootResourceGroupIds); } // Send redirect SessionMessages.add(actionRequest, "permissionsUpdated"); String redirect = _portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test(expected = NoSuchResourcePermissionException.class) public void testDeleteGroupWithStagingGroupRemovesStagingResource() throws Exception { Group group = GroupTestUtil.addGroup(); GroupTestUtil.enableLocalStaging(group); Assert.assertTrue(group.hasStagingGroup()); Group stagingGroup = group.getStagingGroup(); GroupServiceUtil.deleteGroup(group.getGroupId()); Role role = RoleLocalServiceUtil.getRole(stagingGroup.getCompanyId(), RoleConstants.OWNER); ResourcePermissionLocalServiceUtil.getResourcePermission(stagingGroup.getCompanyId(), Group.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(stagingGroup.getGroupId()), role.getRoleId()); }