(1);
+
+ /**
+ * @param voter RM entry voter
+ */
+ public void setVoter(RMEntryVoter voter)
+ {
+ this.voter = voter;
+ }
+
+ /**
+ * @param capabilityService capability service
+ */
+ public void setCapabilityService(CapabilityService capabilityService)
+ {
+ this.capabilityService = capabilityService;
+ }
+
+ /**
+ * Init method
+ */
+ public void init()
+ {
+ capabilityService.registerCapability(this);
+ }
+
+ /**
+ * Registers an action
+ *
+ * @param action
+ */
+ public void registerAction(RecordsManagementAction action)
+ {
+ this.actions.add(action);
+ this.actionNames.add(action.getName());
+ voter.addProtectedAspects(action.getProtectedAspects());
+ voter.addProtectedProperties(action.getProtectedProperties());
+ }
+
+ /**
+ * @param name capability name
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getName()
+ */
+ @Override
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * @param title capability title
+ */
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getTitle()
+ */
+ @Override
+ public String getTitle()
+ {
+ String title = this.title;
+ if (StringUtils.isBlank(title))
+ {
+ title = I18NUtil.getMessage("capability." + getName() + ".title");
+ }
+ return title;
+ }
+
+ /**
+ * @param description capability description
+ */
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ /**
+ * @param descriptionId message id
+ */
+ public void setDescriptionId(String descriptionId)
+ {
+ this.description = I18NUtil.getMessage(descriptionId);
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getDescription()
+ */
+ @Override
+ public String getDescription()
+ {
+ return description;
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#isPrivate()
+ */
+ public boolean isPrivate()
+ {
+ return isPrivate;
+ }
+
+ /**
+ * @param isPrivate indicates whether the capability is private or not
+ */
+ public void setPrivate(boolean isPrivate)
+ {
+ this.isPrivate = isPrivate;
+ }
+
+ /**
+ * Translates the vote to an AccessStatus
+ *
+ * @param vote
+ * @return
+ */
+ private AccessStatus translate(int vote)
+ {
+ switch (vote)
+ {
+ case AccessDecisionVoter.ACCESS_ABSTAIN:
return AccessStatus.UNDETERMINED;
- case AccessDecisionVoter.ACCESS_GRANTED:
+ case AccessDecisionVoter.ACCESS_GRANTED:
return AccessStatus.ALLOWED;
- case AccessDecisionVoter.ACCESS_DENIED:
+ case AccessDecisionVoter.ACCESS_DENIED:
return AccessStatus.DENIED;
- default:
+ default:
return AccessStatus.UNDETERMINED;
- }
- }
+ }
+ }
- /**
- *
- * @param nodeRef
- * @return
- */
- public int checkActionConditionsIfPresent(NodeRef nodeRef)
- {
- String prefix = "checkActionConditionsIfPresent" + getName();
- int result = getTransactionCache(prefix, nodeRef);
- if (result != NOSET_VALUE)
- {
- return result;
- }
-
- if (actions.size() > 0)
- {
- for (RecordsManagementAction action : actions)
+ /**
+ *
+ * @param nodeRef
+ * @return
+ */
+ public int checkActionConditionsIfPresent(NodeRef nodeRef)
+ {
+ String prefix = "checkActionConditionsIfPresent" + getName();
+ int result = getTransactionCache(prefix, nodeRef);
+ if (result != NOSET_VALUE)
+ {
+ return result;
+ }
+
+ if (actions.size() > 0)
+ {
+ for (RecordsManagementAction action : actions)
+ {
+ if (action.isExecutable(nodeRef, null))
{
- if (action.isExecutable(nodeRef, null))
- {
- return setTransactionCache(prefix, nodeRef, AccessDecisionVoter.ACCESS_GRANTED);
- }
+ return setTransactionCache(prefix, nodeRef, AccessDecisionVoter.ACCESS_GRANTED);
}
- return setTransactionCache(prefix, nodeRef, AccessDecisionVoter.ACCESS_DENIED);
- }
- else
- {
- return setTransactionCache(prefix, nodeRef, AccessDecisionVoter.ACCESS_GRANTED);
- }
- }
+ }
+ return setTransactionCache(prefix, nodeRef, AccessDecisionVoter.ACCESS_DENIED);
+ }
+ else
+ {
+ return setTransactionCache(prefix, nodeRef, AccessDecisionVoter.ACCESS_GRANTED);
+ }
+ }
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#hasPermission(org.alfresco.service.cmr.repository.NodeRef)
- */
- public AccessStatus hasPermission(NodeRef nodeRef)
- {
- return translate(hasPermissionRaw(nodeRef));
- }
-
- /**
- * Determines whether the current user has permission on this capability.
- *
- * Returns the raw permission value.
- *
- * @param nodeRef node reference
- * @return raw permission value
- */
- public int hasPermissionRaw(NodeRef nodeRef)
- {
- String prefix = "hasPermissionRaw" + getName();
- int result = getTransactionCache(prefix, nodeRef);
- if (result != NOSET_VALUE)
- {
- return result;
- }
-
- if (checkRmRead(nodeRef) == AccessDecisionVoter.ACCESS_DENIED)
- {
- result = AccessDecisionVoter.ACCESS_DENIED;
- }
- else if (checkActionConditionsIfPresent(nodeRef) == AccessDecisionVoter.ACCESS_DENIED)
- {
- result = AccessDecisionVoter.ACCESS_DENIED;
- }
- else
- {
- result = hasPermissionImpl(nodeRef);
- }
-
- return setTransactionCache(prefix, nodeRef, result);
- }
-
- /**
- * Default implementation. Override if different behaviour required.
- *
- * @param nodeRef
- * @return
- */
- protected int hasPermissionImpl(NodeRef nodeRef)
- {
- return evaluate(nodeRef);
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#evaluate(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
- */
- public int evaluate(NodeRef source, NodeRef target)
- {
- return AccessDecisionVoter.ACCESS_ABSTAIN;
- }
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#hasPermission(org.alfresco.service.cmr.repository.NodeRef)
+ */
+ public AccessStatus hasPermission(NodeRef nodeRef)
+ {
+ return translate(hasPermissionRaw(nodeRef));
+ }
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getActionNames()
- */
- public List getActionNames()
- {
- return actionNames;
- }
+ /**
+ * Determines whether the current user has permission on this capability.
+ *
+ * Returns the raw permission value.
+ *
+ * @param nodeRef node reference
+ * @return raw permission value
+ */
+ public int hasPermissionRaw(NodeRef nodeRef)
+ {
+ String prefix = "hasPermissionRaw" + getName();
+ int result = getTransactionCache(prefix, nodeRef);
+ if (result != NOSET_VALUE)
+ {
+ return result;
+ }
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getActions()
- */
- public List getActions()
- {
- return actions;
- }
+ if (checkRmRead(nodeRef) == AccessDecisionVoter.ACCESS_DENIED)
+ {
+ result = AccessDecisionVoter.ACCESS_DENIED;
+ }
+ else if (checkActionConditionsIfPresent(nodeRef) == AccessDecisionVoter.ACCESS_DENIED)
+ {
+ result = AccessDecisionVoter.ACCESS_DENIED;
+ }
+ else
+ {
+ result = hasPermissionImpl(nodeRef);
+ }
- /**
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
- return result;
- }
+ return setTransactionCache(prefix, nodeRef, result);
+ }
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
+ /**
+ * Default implementation. Override if different behaviour required.
+ *
+ * @param nodeRef
+ * @return
+ */
+ protected int hasPermissionImpl(NodeRef nodeRef)
+ {
+ return evaluate(nodeRef);
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#evaluate(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
+ */
+ public int evaluate(NodeRef source, NodeRef target)
+ {
+ return AccessDecisionVoter.ACCESS_ABSTAIN;
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getActionNames()
+ */
+ public List getActionNames()
+ {
+ return actionNames;
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getActions()
+ */
+ public List getActions()
+ {
+ return actions;
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getGroupId()
+ */
+ public String getGroupId()
+ {
+ return this.groupId;
+ }
+
+ public void setGroupId(String groupId)
+ {
+ this.groupId = groupId;
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getGroupTitle()
+ */
+ public String getGroupTitle()
+ {
+ String groupTitle = this.groupTitle;
+ if (StringUtils.isBlank(groupTitle))
+ {
+ groupTitle = I18NUtil.getMessage("capability.group." + getGroupId() + ".title");
+ }
+ return groupTitle;
+ }
+
+ public void setGroupTitle(String groupTitle)
+ {
+ this.groupTitle = groupTitle;
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final AbstractCapability other = (AbstractCapability) obj;
+ if (getName() == null)
+ {
+ if (other.getName() != null)
return false;
- if (getClass() != obj.getClass())
- return false;
- final AbstractCapability other = (AbstractCapability) obj;
- if (getName() == null)
- {
- if (other.getName() != null)
- return false;
- }
- else if (!getName().equals(other.getName()))
- return false;
- return true;
- }
+ }
+ else if (!getName().equals(other.getName()))
+ return false;
+ return true;
+ }
}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/Capability.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/Capability.java
index 4510a2eca1..ec3addc916 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/Capability.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/Capability.java
@@ -32,75 +32,89 @@ import org.alfresco.service.cmr.security.AccessStatus;
*/
public interface Capability
{
- /**
- * Does this capability apply to this nodeRef?
- * @param nodeRef
- * @return
- */
- AccessStatus hasPermission(NodeRef nodeRef);
-
- /**
- *
- * @param nodeRef
- * @return
- */
- int hasPermissionRaw(NodeRef nodeRef);
+ /**
+ * Does this capability apply to this nodeRef?
+ * @param nodeRef
+ * @return
+ */
+ AccessStatus hasPermission(NodeRef nodeRef);
- /**
- * Evaluates the capability.
- *
- * @param nodeRef
- * @return
- */
- int evaluate(NodeRef nodeRef);
-
- /**
- * Evaluates the capability, taking into account a target.
- *
- * @param source source node reference
- * @param target target node reference
- * @return int permission value
- */
- int evaluate(NodeRef source, NodeRef target);
-
- /**
- * Indicates whether this is a private capability or not. Private capabilities are used internally, otherwise
- * they are made available to the user to assign to roles.
- *
- * @return boolean true if private, false otherwise
- */
- boolean isPrivate();
-
- /**
- * Get the name of the capability
- *
- * @return String capability name
- */
- String getName();
-
- /**
- * Get the title of the capability
- *
- * @return String capability title
- */
- String getTitle();
+ /**
+ *
+ * @param nodeRef
+ * @return
+ */
+ int hasPermissionRaw(NodeRef nodeRef);
- /**
- * Get the description of the capability
- *
- * @return String capability description
- */
- String getDescription();
-
- /**
- * Get the name of optional actions tied to this capability
- * @return
- */
- List getActionNames();
+ /**
+ * Evaluates the capability.
+ *
+ * @param nodeRef
+ * @return
+ */
+ int evaluate(NodeRef nodeRef);
- /**
- *
- * @return
- */
- List getActions();
+ /**
+ * Evaluates the capability, taking into account a target.
+ *
+ * @param source source node reference
+ * @param target target node reference
+ * @return int permission value
+ */
+ int evaluate(NodeRef source, NodeRef target);
+
+ /**
+ * Indicates whether this is a private capability or not. Private capabilities are used internally, otherwise
+ * they are made available to the user to assign to roles.
+ *
+ * @return boolean true if private, false otherwise
+ */
+ boolean isPrivate();
+
+ /**
+ * Get the name of the capability
+ *
+ * @return String capability name
+ */
+ String getName();
+
+ /**
+ * Get the title of the capability
+ *
+ * @return String capability title
+ */
+ String getTitle();
+
+ /**
+ * Get the description of the capability
+ *
+ * @return String capability description
+ */
+ String getDescription();
+
+ /**
+ * Get the name of optional actions tied to this capability
+ * @return
+ */
+ List getActionNames();
+
+ /**
+ *
+ * @return
+ */
+ List getActions();
+
+ /**
+ * Gets the group id of a capability
+ *
+ * @return String capability group id
+ */
+ String getGroupId();
+
+ /**
+ * Gets the group title of a capability
+ *
+ * @return String capability group title
+ */
+ String getGroupTitle();
}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityService.java
index f1e5f2dcaf..7906e3f111 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityService.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityService.java
@@ -33,66 +33,74 @@ import org.alfresco.service.cmr.security.AccessStatus;
*/
public interface CapabilityService
{
- /**
- * Register a capability
- *
- * @param capability capability
- */
- void registerCapability(Capability capability);
-
- /**
- * Get a named capability.
- *
- * @param name capability name
- * @return {@link Capability} capability or null if not found
- */
- Capability getCapability(String name);
-
- /**
- * Get a list of all the assignable capabilities.
- *
- * @return {@link Set}<{@link Capability}> set of all the assignable capabilities
- */
- Set getCapabilities();
-
- /**
- * Get a list of all the capabilities, optionally including those that are non-assignable.
- *
- * @param includePrivate indicates that the private, or non-assignable capabilities are included in the result
- * @return {@link Set}<{@link Capability}> set of capabilities
- */
- Set getCapabilities(boolean includePrivate);
-
- /**
- * Get all the capabilities access state based on the current user for the assignable capabilities.
- *
- * @param nodeRef node reference
- * @return
- */
- Map getCapabilitiesAccessState(NodeRef nodeRef);
-
- /**
- * Get all the capabilities access state based on the current user.
- *
- * @param nodeRef node reference
- * @return
- */
- Map getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate);
-
- /**
- *
- * @param nodeRef
- * @param capabilityNames
- * @return
- */
- Map getCapabilitiesAccessState(NodeRef nodeRef, List capabilityNames);
-
- /**
- * Helper method to get the access state for a single capability.
- *
- * @param nodeRef
- * @param capabilityName
- * @return
- */
- AccessStatus getCapabilityAccessState(NodeRef nodeRef, String capabilityName);
+ /**
+ * Register a capability
+ *
+ * @param capability capability
+ */
+ void registerCapability(Capability capability);
+
+ /**
+ * Get a named capability.
+ *
+ * @param name capability name
+ * @return {@link Capability} capability or null if not found
+ */
+ Capability getCapability(String name);
+
+ /**
+ * Get a list of all the assignable capabilities.
+ *
+ * @return {@link Set}<{@link Capability}> set of all the assignable capabilities
+ */
+ Set getCapabilities();
+
+ /**
+ * Get a list of all the capabilities, optionally including those that are non-assignable.
+ *
+ * @param includePrivate indicates that the private, or non-assignable capabilities are included in the result
+ * @return {@link Set}<{@link Capability}> set of capabilities
+ */
+ Set getCapabilities(boolean includePrivate);
+
+ /**
+ * Get all the capabilities access state based on the current user for the assignable capabilities.
+ *
+ * @param nodeRef node reference
+ * @return
+ */
+ Map getCapabilitiesAccessState(NodeRef nodeRef);
+
+ /**
+ * Get all the capabilities access state based on the current user.
+ *
+ * @param nodeRef node reference
+ * @return
+ */
+ Map getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate);
+
+ /**
+ *
+ * @param nodeRef
+ * @param capabilityNames
+ * @return
+ */
+ Map getCapabilitiesAccessState(NodeRef nodeRef, List capabilityNames);
+
+ /**
+ * Helper method to get the access state for a single capability.
+ *
+ * @param nodeRef
+ * @param capabilityName
+ * @return
+ */
+ AccessStatus getCapabilityAccessState(NodeRef nodeRef, String capabilityName);
+
+ /**
+ * Gets all the capabilities grouped by their ids. The map key is the group id of a capability and the
+ * value is another map with the key being the capability name and the value being the capability title
+ *
+ * @return Map of capabilities grouped by their ids
+ */
+ Map> getGroupedCapabilities();
}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityServiceImpl.java
index 3ab90eb468..2a31a808ef 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityServiceImpl.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/capability/CapabilityServiceImpl.java
@@ -27,6 +27,8 @@ import java.util.Set;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AccessStatus;
+import org.alfresco.util.ParameterCheck;
+import org.apache.commons.lang.StringUtils;
/**
* @author Roy Wetherall
@@ -34,125 +36,169 @@ import org.alfresco.service.cmr.security.AccessStatus;
*/
public class CapabilityServiceImpl implements CapabilityService
{
- /** Capabilities */
- private Map capabilities = new HashMap(57);
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapability(java.lang.String)
- */
- @Override
- public Capability getCapability(String name)
- {
- return capabilities.get(name);
- }
+ /** Capabilities */
+ private Map capabilities = new HashMap(57);
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#registerCapability(org.alfresco.module.org_alfresco_module_rm.capability.Capability)
- */
- @Override
- public void registerCapability(Capability capability)
- {
- capabilities.put(capability.getName(), capability);
- }
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapability(java.lang.String)
+ */
+ @Override
+ public Capability getCapability(String name)
+ {
+ ParameterCheck.mandatoryString("name", name);
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities()
- */
- @Override
- public Set getCapabilities()
- {
- return getCapabilities(true);
- }
+ return capabilities.get(name);
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#registerCapability(org.alfresco.module.org_alfresco_module_rm.capability.Capability)
+ */
+ @Override
+ public void registerCapability(Capability capability)
+ {
+ ParameterCheck.mandatory("capability", capability);
+
+ capabilities.put(capability.getName(), capability);
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities()
+ */
+ @Override
+ public Set getCapabilities()
+ {
+ return getCapabilities(true);
+ }
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities(boolean)
- */
- @Override
- public Set getCapabilities(boolean includePrivate)
- {
- Set result = null;
- if (includePrivate == true)
- {
- result = new HashSet(capabilities.values());
- }
- else
- {
- result = new HashSet(capabilities.size());
- for (Capability capability : capabilities.values())
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities(boolean)
+ */
+ @Override
+ public Set getCapabilities(boolean includePrivate)
+ {
+ Set result = null;
+ if (includePrivate == true)
+ {
+ result = new HashSet(capabilities.values());
+ }
+ else
+ {
+ result = new HashSet(capabilities.size());
+ for (Capability capability : capabilities.values())
+ {
+ if (capability.isPrivate() == false)
{
- if (capability.isPrivate() == false)
- {
- result.add(capability);
- }
+ result.add(capability);
}
- }
-
- return result;
- }
+ }
+ }
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef)
- */
- public Map getCapabilitiesAccessState(NodeRef nodeRef)
- {
- return getCapabilitiesAccessState(nodeRef, false);
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef, boolean)
- */
- @Override
- public Map getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate)
- {
- Set listOfCapabilites = getCapabilities(includePrivate);
- HashMap answer = new HashMap();
- for (Capability capability : listOfCapabilites)
- {
+ return result;
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef)
+ */
+ public Map getCapabilitiesAccessState(NodeRef nodeRef)
+ {
+ ParameterCheck.mandatory("nodeRef", nodeRef);
+
+ return getCapabilitiesAccessState(nodeRef, false);
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef, boolean)
+ */
+ @Override
+ public Map getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate)
+ {
+ ParameterCheck.mandatory("nodeRef", nodeRef);
+
+ Set listOfCapabilites = getCapabilities(includePrivate);
+ HashMap answer = new HashMap();
+ for (Capability capability : listOfCapabilites)
+ {
+ AccessStatus status = capability.hasPermission(nodeRef);
+ if (answer.put(capability, status) != null)
+ {
+ throw new IllegalStateException();
+ }
+ }
+ return answer;
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef, java.util.List)
+ */
+ public Map getCapabilitiesAccessState(NodeRef nodeRef, List capabilityNames)
+ {
+ ParameterCheck.mandatory("nodeRef", nodeRef);
+ ParameterCheck.mandatory("capabilityNames", capabilityNames);
+
+ HashMap answer = new HashMap();
+ for (String capabilityName : capabilityNames)
+ {
+ Capability capability = capabilities.get(capabilityName);
+ if (capability != null)
+ {
AccessStatus status = capability.hasPermission(nodeRef);
if (answer.put(capability, status) != null)
{
- throw new IllegalStateException();
+ throw new IllegalStateException();
}
- }
- return answer;
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilitiesAccessState(org.alfresco.service.cmr.repository.NodeRef, java.util.List)
- */
- public Map getCapabilitiesAccessState(NodeRef nodeRef, List capabilityNames)
- {
- HashMap answer = new HashMap();
- for (String capabilityName : capabilityNames)
- {
- Capability capability = capabilities.get(capabilityName);
- if (capability != null)
- {
- AccessStatus status = capability.hasPermission(nodeRef);
- if (answer.put(capability, status) != null)
- {
- throw new IllegalStateException();
- }
- }
- }
- return answer;
- }
-
- /**
- * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilityAccessState(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
- */
- @Override
- public AccessStatus getCapabilityAccessState(NodeRef nodeRef, String capabilityName)
- {
- AccessStatus result = AccessStatus.UNDETERMINED;
- Capability capability = getCapability(capabilityName);
- if (capability != null)
- {
- List list = Collections.singletonList(capabilityName);
- Map map = getCapabilitiesAccessState(nodeRef, list);
- result = map.get(capability);
- }
- return result;
- }
+ }
+ }
+ return answer;
+ }
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilityAccessState(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
+ */
+ @Override
+ public AccessStatus getCapabilityAccessState(NodeRef nodeRef, String capabilityName)
+ {
+ ParameterCheck.mandatory("nodeRef", nodeRef);
+ ParameterCheck.mandatory("capabilityName", capabilityName);
+
+ AccessStatus result = AccessStatus.UNDETERMINED;
+ Capability capability = getCapability(capabilityName);
+ if (capability != null)
+ {
+ List list = Collections.singletonList(capabilityName);
+ Map map = getCapabilitiesAccessState(nodeRef, list);
+ result = map.get(capability);
+ }
+ return result;
+ }
+
+ /**
+ * @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getGroupedCapabilities()
+ */
+ @Override
+ public Map> getGroupedCapabilities()
+ {
+ Map> groupedCapabilities = new HashMap>(capabilities.size());
+ for (Capability capability : getCapabilities(true))
+ {
+ String groupTitle = capability.getGroupTitle();
+ if (StringUtils.isNotBlank(groupTitle))
+ {
+ String capabilityName = capability.getName();
+ String capabilityTitle = capability.getTitle();
+
+ if (groupedCapabilities.containsKey(groupTitle))
+ {
+ groupedCapabilities.get(groupTitle).put(capabilityName, capabilityTitle);
+ }
+ else
+ {
+ Map capabilityList = new HashMap(13);
+ capabilityList.put(capabilityName, capabilityTitle);
+ groupedCapabilities.put(groupTitle, capabilityList);
+ }
+ }
+ }
+
+ return groupedCapabilities;
+ }
}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesGet.java
index 1255120eb3..3e920deae0 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesGet.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmRolesGet.java
@@ -37,57 +37,57 @@ import org.apache.commons.logging.LogFactory;
/**
* Get information about record management roles
- *
+ *
* @author Roy Wetherall
*/
public class RmRolesGet extends DeclarativeWebScript
{
- @SuppressWarnings("unused")
- private static Log logger = LogFactory.getLog(RmRolesGet.class);
-
- private RecordsManagementService rmService;
- private RecordsManagementSecurityService rmSecurityService;
-
- public void setRecordsManagementSecurityService(RecordsManagementSecurityService rmSecurityService)
- {
- this.rmSecurityService = rmSecurityService;
- }
-
- public void setRecordsManagementService(RecordsManagementService rmService)
- {
- this.rmService = rmService;
- }
+ @SuppressWarnings("unused")
+ private static Log logger = LogFactory.getLog(RmRolesGet.class);
- @Override
- public Map executeImpl(WebScriptRequest req, Status status, Cache cache)
- {
- Map model = new HashMap();
- Set roles = null;
-
- // TODO should be passed
- List roots = rmService.getFilePlans();
- if (roots != null && roots.size() > 0)
- {
- NodeRef root = roots.get(0);
-
- // Get the user filter
- String user = req.getParameter("user");
- if (user != null && user.length() != 0)
- {
- roles = rmSecurityService.getRolesByUser(root, user);
- }
- else
- {
- roles = rmSecurityService.getRoles(root);
- }
- }
- else
- {
- roles = new HashSet(1);
- }
+ private RecordsManagementService rmService;
+ private RecordsManagementSecurityService rmSecurityService;
- model.put("roles", roles);
-
- return model;
+ public void setRecordsManagementSecurityService(RecordsManagementSecurityService rmSecurityService)
+ {
+ this.rmSecurityService = rmSecurityService;
+ }
+
+ public void setRecordsManagementService(RecordsManagementService rmService)
+ {
+ this.rmService = rmService;
+ }
+
+ @Override
+ public Map executeImpl(WebScriptRequest req, Status status, Cache cache)
+ {
+ Map model = new HashMap();
+ Set roles = null;
+
+ // TODO should be passed
+ List roots = rmService.getFilePlans();
+ if (roots != null && roots.size() > 0)
+ {
+ NodeRef root = roots.get(0);
+
+ // Get the user filter
+ String user = req.getParameter("user");
+ if (user != null && user.length() != 0)
+ {
+ roles = rmSecurityService.getRolesByUser(root, user);
+ }
+ else
+ {
+ roles = rmSecurityService.getRoles(root);
+ }
+ }
+ else
+ {
+ roles = new HashSet(1);
+ }
+
+ model.put("roles", roles);
+
+ return model;
}
}
\ No newline at end of file
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/capability/CapabilitiesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/capability/CapabilitiesGet.java
index 86612fb061..8144f15ca6 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/capability/CapabilitiesGet.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/capability/CapabilitiesGet.java
@@ -31,6 +31,7 @@ import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.security.AccessStatus;
+import org.apache.commons.lang.StringUtils;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
@@ -39,73 +40,87 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
public class CapabilitiesGet extends DeclarativeWebScript
{
- private RecordsManagementService recordsManagementService;
-
- private CapabilityService capabilityService;
-
- public void setRecordsManagementService(RecordsManagementService recordsManagementService)
- {
- this.recordsManagementService = recordsManagementService;
- }
-
- public void setCapabilityService(CapabilityService capabilityService)
- {
- this.capabilityService = capabilityService;
- }
-
- /**
- * @see org.alfresco.repo.web.scripts.content.StreamContent#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
- */
- @Override
- protected Map executeImpl(WebScriptRequest req, Status status, Cache cache)
- {
- Map templateVars = req.getServiceMatch().getTemplateVars();
- String storeType = templateVars.get("store_type");
- String storeId = templateVars.get("store_id");
- String nodeId = templateVars.get("id");
-
- boolean includePrivate = false;
- String includePrivateString = req.getParameter("includeAll");
- if (includePrivateString != null)
- {
+ private RecordsManagementService recordsManagementService;
+
+ private CapabilityService capabilityService;
+
+ public void setRecordsManagementService(RecordsManagementService recordsManagementService)
+ {
+ this.recordsManagementService = recordsManagementService;
+ }
+
+ public void setCapabilityService(CapabilityService capabilityService)
+ {
+ this.capabilityService = capabilityService;
+ }
+
+ /**
+ * @see org.alfresco.repo.web.scripts.content.StreamContent#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
+ */
+ @Override
+ protected Map executeImpl(WebScriptRequest req, Status status, Cache cache)
+ {
+ Map templateVars = req.getServiceMatch().getTemplateVars();
+ String storeType = templateVars.get("store_type");
+ String storeId = templateVars.get("store_id");
+ String nodeId = templateVars.get("id");
+
+ NodeRef nodeRef = null;
+ if (StringUtils.isNotBlank(storeType) && StringUtils.isNotBlank(storeId) && StringUtils.isNotBlank(nodeId))
+ {
+ nodeRef = new NodeRef(new StoreRef(storeType, storeId), nodeId);
+ }
+ else
+ {
+ // we are talking about the file plan node
+ // TODO we are making the assumption there is only one file plan here!
+ List filePlans = recordsManagementService.getFilePlans();
+ if (filePlans.isEmpty() == true)
+ {
+ throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No file plan node has been found.");
+ }
+ else if (filePlans.size() != 1)
+ {
+ throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "More than one file plan has been found.");
+ }
+ nodeRef = filePlans.get(0);
+ }
+
+ boolean grouped = false;
+ String groupedString = req.getParameter("grouped");
+ if (StringUtils.isNotBlank(groupedString))
+ {
+ grouped = Boolean.parseBoolean(groupedString);
+ }
+
+ Map model = new HashMap(1);
+ if (grouped == true)
+ {
+ model.put("groupedCapabilities", capabilityService.getGroupedCapabilities());
+ }
+ else
+ {
+ boolean includePrivate = false;
+ String includePrivateString = req.getParameter("includeAll");
+ if (StringUtils.isNotBlank(includePrivateString))
+ {
includePrivate = Boolean.parseBoolean(includePrivateString);
- }
-
- NodeRef nodeRef = null;
- if (storeType != null && storeId != null && nodeId != null)
- {
- nodeRef = new NodeRef(new StoreRef(storeType, storeId), nodeId);
- }
- else
- {
- // we are talking about the file plan node
- // TODO we are making the assumption there is only one file plan here!
- List filePlans = recordsManagementService.getFilePlans();
- if (filePlans.isEmpty() == true)
- {
- throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No file plan node has been found.");
- }
- else if (filePlans.size() != 1)
- {
- throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "More than one file plan has been found.");
- }
- nodeRef = filePlans.get(0);
- }
-
- Map map = capabilityService.getCapabilitiesAccessState(nodeRef, includePrivate);
- List list = new ArrayList(map.size());
- for (Map.Entry entry : map.entrySet())
- {
+ }
+
+ Map map = capabilityService.getCapabilitiesAccessState(nodeRef, includePrivate);
+ List list = new ArrayList(map.size());
+ for (Map.Entry entry : map.entrySet())
+ {
AccessStatus accessStatus = entry.getValue();
if (AccessStatus.DENIED.equals(accessStatus) == false)
{
- Capability capability = entry.getKey();
- list.add(capability.getName());
- }
- }
-
- Map model = new HashMap(1);
- model.put("capabilities", list);
- return model;
- }
+ Capability capability = entry.getKey();
+ list.add(capability.getName());
+ }
+ }
+ model.put("capabilities", list);
+ }
+
+ return model;
+ }
}
\ No newline at end of file