From: <dcr...@hy...> - 2010-02-15 07:17:15
|
Author: dcrutchf Date: 2010-02-14 23:17:06 -0800 (Sun, 14 Feb 2010) New Revision: 14291 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14291 Modified: trunk/src/org/hyperic/hq/authz/server/session/RoleManagerEJBImpl.java trunk/src/org/hyperic/hq/authz/shared/PermissionManager.java trunk/src/org/hyperic/hq/authz/shared/PermissionManagerImpl.java trunk/src/org/hyperic/hq/authz/shared/ResourceOperationsHelper.java trunk/web/WEB-INF/classes/ApplicationResources.properties trunk/web/css/HQ_40.css Log: Changed the role permission view to make it simpler and hopefully more usable. Modified: trunk/src/org/hyperic/hq/authz/server/session/RoleManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/authz/server/session/RoleManagerEJBImpl.java 2010-02-14 09:26:41 UTC (rev 14290) +++ trunk/src/org/hyperic/hq/authz/server/session/RoleManagerEJBImpl.java 2010-02-15 07:17:06 UTC (rev 14291) @@ -593,41 +593,20 @@ } /** - * Get role permission Map + * Get operations * For a given role id, find the resource types and permissions * which are supported by it * @param subject * @param roleId - * @return map - keys are resource type names, values are lists of operation - * values which are supported on the resouce type. + * @return list - values are lists of operation * @ejb:interface-method */ - public Map getRoleOperationMap(AuthzSubject subject, Integer roleId) + public List getRoleOperations(AuthzSubject subject, Integer roleId) throws PermissionException { - Map theMap = new HashMap(); // find the role by id Role role = getRoleDAO().findById(roleId); // now get the operations - Collection operations = role.getOperations(); - // now for each operation, get the supported resource type - Iterator operationIt = operations.iterator(); - while (operationIt.hasNext()) { - Operation anOp = (Operation) operationIt.next(); - // now get the resource Type for the op - ResourceType resType = anOp.getResourceType(); - // check if there's a key for this entry - if (theMap.containsKey(resType.getName())) { - // looks like this res type is accounted for - // add the operation to the list - ((List) theMap.get(resType.getName())).add(anOp); - } else { - // key's not there, add it - List opList = new ArrayList(); - opList.add(anOp); - theMap.put(resType.getName(), opList); - } - } - return theMap; + return new ArrayList(role.getOperations()); } /** Modified: trunk/src/org/hyperic/hq/authz/shared/PermissionManager.java =================================================================== --- trunk/src/org/hyperic/hq/authz/shared/PermissionManager.java 2010-02-14 09:26:41 UTC (rev 14290) +++ trunk/src/org/hyperic/hq/authz/shared/PermissionManager.java 2010-02-15 07:17:06 UTC (rev 14291) @@ -25,8 +25,12 @@ package org.hyperic.hq.authz.shared; +import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; import javax.ejb.FinderException; @@ -34,6 +38,7 @@ import org.hyperic.hq.appdef.shared.CloningBossInterface; import org.hyperic.hq.authz.server.session.AuthzSession; import org.hyperic.hq.authz.server.session.AuthzSubject; +import org.hyperic.hq.authz.server.session.Operation; import org.hyperic.hq.authz.server.session.PagerProcessor_operation; import org.hyperic.hq.authz.server.session.Resource; import org.hyperic.hq.authz.server.session.ResourceType; @@ -188,7 +193,7 @@ public abstract List getAllOperations(AuthzSubject subject, PageControl pc) throws PermissionException, FinderException; - + public abstract String getResourceTypeSQL(String instanceId, Integer subjectId, String resType, Modified: trunk/src/org/hyperic/hq/authz/shared/PermissionManagerImpl.java =================================================================== --- trunk/src/org/hyperic/hq/authz/shared/PermissionManagerImpl.java 2010-02-14 09:26:41 UTC (rev 14290) +++ trunk/src/org/hyperic/hq/authz/shared/PermissionManagerImpl.java 2010-02-15 07:17:06 UTC (rev 14291) @@ -31,8 +31,11 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import javax.ejb.FinderException; @@ -357,7 +360,7 @@ } return operationPager.seek(ops, pc.getPagenum(), pc.getPagesize()); } - + public Collection getGroupResources(Integer subjectId, Integer groupId, Boolean fsystem) { return getResourceDAO().findInGroup_orderName(groupId, fsystem); Modified: trunk/src/org/hyperic/hq/authz/shared/ResourceOperationsHelper.java =================================================================== --- trunk/src/org/hyperic/hq/authz/shared/ResourceOperationsHelper.java 2010-02-14 09:26:41 UTC (rev 14290) +++ trunk/src/org/hyperic/hq/authz/shared/ResourceOperationsHelper.java 2010-02-15 07:17:06 UTC (rev 14291) @@ -1,47 +1,100 @@ package org.hyperic.hq.authz.shared; +import java.util.ArrayList; +import java.util.List; + import org.hyperic.hq.appdef.shared.AppdefEntityConstants; import org.hyperic.hq.authz.server.session.Resource; public class ResourceOperationsHelper { + // This number should be equal to the max number of operation codes per resource + private final static int MULTIPLIER = 6; + // Resource type codes... - private final static int PLATFORM = 0; - private final static int SERVER = 5; - private final static int SERVICE = 10; - private final static int GROUP = 15; + public final static int PLATFORM = 0; + public final static int SERVER = 1 * MULTIPLIER; + public final static int SERVICE = 2 * MULTIPLIER; + public final static int GROUP = 3 * MULTIPLIER; + public final static int APPLICATION = 4 * MULTIPLIER; + public final static int USER = 5 * MULTIPLIER; + public final static int ROLE = 6 * MULTIPLIER; + public final static int ESCALATION = 7 * MULTIPLIER; // Operation codes...these are added to the resource type code to get the actual operation - private final static int CREATE = 0; - private final static int READ = 1; - private final static int UPDATE = 2; - private final static int DELETE = 3; - private final static int MANAGE_ALERTS = 4; + public final static int CREATE = 0; + public final static int READ = 1; + public final static int UPDATE = 2; + public final static int DELETE = 3; + public final static int MANAGE_ALERTS = 4; + public final static int MANAGE_CONTROLS = 5; - // Array containing all the operations for each resource type... - // ORDER IS IMPORTANT! - private final static String[] operationsArray = { - AuthzConstants.platformOpCreatePlatform, - AuthzConstants.platformOpViewPlatform, - AuthzConstants.platformOpModifyPlatform, - AuthzConstants.platformOpRemovePlatform, - AuthzConstants.platformOpManageAlerts, - AuthzConstants.serverOpCreateServer, - AuthzConstants.serverOpViewServer, - AuthzConstants.serverOpModifyServer, - AuthzConstants.serverOpRemoveServer, - AuthzConstants.serverOpManageAlerts, - AuthzConstants.serviceOpCreateService, - AuthzConstants.serviceOpViewService, - AuthzConstants.serviceOpModifyService, - AuthzConstants.serviceOpRemoveService, - AuthzConstants.serviceOpManageAlerts, - AuthzConstants.groupOpCreateResourceGroup, - AuthzConstants.groupOpViewResourceGroup, - AuthzConstants.groupOpModifyResourceGroup, - AuthzConstants.groupOpRemoveResourceGroup, - AuthzConstants.groupOpManageAlerts - }; + // Permission Levels... + public final static int NO_PERMISSIONS = 0; + public final static int READ_ONLY_PERMISSION = 1; + public final static int READ_WRITE_PERMISSIONS = 2; + public final static int FULL_PERMISSIONS = 3; + + private static List operationsList; + + public ResourceOperationsHelper() { + // ArrayList containing all the operations for each resource type... + // ORDER IS IMPORTANT! + operationsList = new ArrayList(48); + + operationsList.add(AuthzConstants.platformOpCreatePlatform); + operationsList.add(AuthzConstants.platformOpViewPlatform); + operationsList.add(AuthzConstants.platformOpModifyPlatform); + operationsList.add(AuthzConstants.platformOpRemovePlatform); + operationsList.add(AuthzConstants.platformOpManageAlerts); + operationsList.add(AuthzConstants.platformOpControlPlatform); + operationsList.add(AuthzConstants.serverOpCreateServer); + operationsList.add(AuthzConstants.serverOpViewServer); + operationsList.add(AuthzConstants.serverOpModifyServer); + operationsList.add(AuthzConstants.serverOpRemoveServer); + operationsList.add(AuthzConstants.serverOpManageAlerts); + operationsList.add(AuthzConstants.serverOpControlServer); + operationsList.add(AuthzConstants.serviceOpCreateService); + operationsList.add(AuthzConstants.serviceOpViewService); + operationsList.add(AuthzConstants.serviceOpModifyService); + operationsList.add(AuthzConstants.serviceOpRemoveService); + operationsList.add(AuthzConstants.serviceOpManageAlerts); + operationsList.add(AuthzConstants.serviceOpControlService); + operationsList.add(AuthzConstants.groupOpCreateResourceGroup); + operationsList.add(AuthzConstants.groupOpViewResourceGroup); + operationsList.add(AuthzConstants.groupOpModifyResourceGroup); + operationsList.add(AuthzConstants.groupOpRemoveResourceGroup); + operationsList.add(AuthzConstants.groupOpManageAlerts); + operationsList.add(null); + operationsList.add(AuthzConstants.appOpCreateApplication); + operationsList.add(AuthzConstants.appOpViewApplication); + operationsList.add(AuthzConstants.appOpModifyApplication); + operationsList.add(AuthzConstants.appOpRemoveApplication); + operationsList.add(null); + operationsList.add(AuthzConstants.appOpControlApplication); + operationsList.add(AuthzConstants.subjectOpCreateSubject); + operationsList.add(AuthzConstants.subjectOpViewSubject); + operationsList.add(AuthzConstants.subjectOpModifySubject); + operationsList.add(AuthzConstants.subjectOpRemoveSubject); + operationsList.add(null); + operationsList.add(null); + operationsList.add(AuthzConstants.roleOpCreateRole); + operationsList.add(AuthzConstants.roleOpViewRole); + operationsList.add(AuthzConstants.roleOpModifyRole); + operationsList.add(AuthzConstants.roleOpRemoveRole); + operationsList.add(null); + operationsList.add(null); + operationsList.add(AuthzConstants.escOpCreateEscalation); + operationsList.add(AuthzConstants.escOpViewEscalation); + operationsList.add(AuthzConstants.escOpModifyEscalation); + operationsList.add(AuthzConstants.escOpRemoveEscalation); + operationsList.add(null); + operationsList.add(null); + } + public String getOperationName(int resourceTypeCode, int operationCode) { + return (String) operationsList.get(resourceTypeCode + operationCode); + } + public String getCreateOperation(Resource resource) throws IllegalArgumentException { return getOperation(resource, CREATE); @@ -66,6 +119,11 @@ throws IllegalArgumentException { return getOperation(resource, MANAGE_ALERTS); } + + public String getManageControlOperation(Resource resource) + throws IllegalArgumentException { + return getOperation(resource, MANAGE_CONTROLS); + } public String getCreateOperation(int resourceTypeId) throws IllegalArgumentException { @@ -91,7 +149,12 @@ throws IllegalArgumentException { return getOperation(resourceTypeId, MANAGE_ALERTS); } - + + public String getManageControlOperation(int resourceTypeId) + throws IllegalArgumentException { + return getOperation(resourceTypeId, MANAGE_CONTROLS); + } + public String getResourceType(Resource resource) throws IllegalArgumentException, UnsupportedOperationException { if (resource == null || resource.getResourceType() == null) { @@ -151,6 +214,40 @@ throw new IllegalArgumentException("resourceType must be a platform, server, service or group resource type."); } - return operationsArray[resourceTypeCode + operationCode]; + return getOperationName(resourceTypeCode, operationCode); } + + public CodePair getResourceTypeOperationCodePair(String operationName) { + int index = operationsList.indexOf(operationName); + int resourceTypeCode = ((index < MULTIPLIER) ? 0 : index/MULTIPLIER) * MULTIPLIER; + int operationCode = index - resourceTypeCode; + + return new CodePair(resourceTypeCode, operationCode); + } + + public class CodePair { + int resourceTypeCode; + int operationCode; + + public CodePair(int resourceTypeCode, int operationCode) { + this.resourceTypeCode = resourceTypeCode; + this.operationCode = operationCode; + } + + public int getResourceTypeCode() { + return resourceTypeCode; + } + + public void setResourceTypeCode(int resourceTypeCode) { + this.resourceTypeCode = resourceTypeCode; + } + + public int getOperationCode() { + return operationCode; + } + + public void setOperationCode(int operationCode) { + this.operationCode = operationCode; + } + } } Modified: trunk/web/WEB-INF/classes/ApplicationResources.properties =================================================================== --- trunk/web/WEB-INF/classes/ApplicationResources.properties 2010-02-14 09:26:41 UTC (rev 14290) +++ trunk/web/WEB-INF/classes/ApplicationResources.properties 2010-02-15 07:17:06 UTC (rev 14291) @@ -315,7 +315,7 @@ # admin.role.view.ReturnToRoles=<< Return to Roles # -admin.role.props.PropertiesAndPermissionsTab=Properties & Permissions +admin.role.props.PropertiesTab=Properties admin.role.props.GeneralPropertiesTab=General Properties admin.role.props.AlertCalendarTab=Alert Calendar admin.role.props.OwnerLabel=Owner: @@ -324,26 +324,26 @@ admin.role.props.administer.yes=YES admin.role.props.administer.no=NO admin.role.props.100=Please limit the description to 100 characters -# + admin.role.perms.PermissionsTab=Permissions admin.role.perms.ResourceTypeTH=Resource Type -admin.role.perms.type.covalentAuthzSubject=Users -admin.role.perms.type.covalentAuthzRole=Roles -admin.role.perms.type.covalentAuthzResourceGroup=Groups -admin.role.perms.type.covalentEAMPlatform=Platforms -admin.role.perms.type.covalentEAMServer=Servers -admin.role.perms.type.covalentEAMService=Services -admin.role.perms.type.covalentEAMApplication=Applications -admin.role.perms.type.EscalationScheme=Escalations -admin.role.perms.perm.view=View -admin.role.perms.perm.create=Create -admin.role.perms.perm.modify=Modify -admin.role.perms.perm.delete=Delete -admin.role.perms.perm.monitor=Monitor -admin.role.perms.perm.control=Control -admin.role.perms.perm.alert=Alerting -admin.role.perms.perm.CheckAll=Check All -# +admin.role.perms.type.users=Users +admin.role.perms.type.roles=Roles +admin.role.perms.type.groups=Groups +admin.role.perms.type.platforms=Platforms +admin.role.perms.type.servers=Servers +admin.role.perms.type.services=Services +admin.role.perms.type.applications=Applications +admin.role.perms.type.escalations=Escalations +admin.role.permissions.header=Permissions +admin.role.permissions.readOnly=Read Only +admin.role.permissions.readWrite=Read / Write +admin.role.permissions.full=Full +admin.role.permissions.none=None +admin.role.capabilities.header=Capabilities +admin.role.capabilities.alert=Can Fix/Ack Alerts? +admin.role.capabilities.control=Can Control? + admin.role.alert.AlertNotificationTab=Alert Notification Time Range admin.role.alert.ActiveLabel=Active: admin.role.alert.always=Always Modified: trunk/web/css/HQ_40.css =================================================================== --- trunk/web/css/HQ_40.css 2010-02-14 09:26:41 UTC (rev 14290) +++ trunk/web/css/HQ_40.css 2010-02-15 07:17:06 UTC (rev 14291) @@ -2606,4 +2606,30 @@ margin-top:15px; text-align:center; width:100%; +} + +.resourceTypeColumn { + padding: 8px 3px; + text-align: right; + width: 20%; +} + +.permissionColumn { + padding-left: 15px; +} + +.capabilitiesColumn { + padding-left: 5px; + width: 60%; +} + +.alertCapability { + width: 10%; +} + +.controlCapability { + width: 50%; +} +.bottomBorder { + border-bottom: 1px solid #eee; } \ No newline at end of file |