mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-563 (Add group id and title to Capability API and definitions)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@43933 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,6 +27,7 @@ import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
@@ -40,313 +41,345 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
public abstract class AbstractCapability extends RMSecurityCommon
|
||||
implements Capability, RecordsManagementModel, RMPermissionModel
|
||||
{
|
||||
/** Logger */
|
||||
@SuppressWarnings("unused")
|
||||
private static Log logger = LogFactory.getLog(AbstractCapability.class);
|
||||
/** Logger */
|
||||
@SuppressWarnings("unused")
|
||||
private static Log logger = LogFactory.getLog(AbstractCapability.class);
|
||||
|
||||
/** RM entry voter */
|
||||
protected RMEntryVoter voter;
|
||||
|
||||
/** Capability service */
|
||||
protected CapabilityService capabilityService;
|
||||
|
||||
/** Capability name */
|
||||
protected String name;
|
||||
|
||||
/** Capability title and description */
|
||||
protected String title;
|
||||
protected String description;
|
||||
|
||||
/** Indicates whether this is a private capability or not */
|
||||
protected boolean isPrivate = false;
|
||||
/** RM entry voter */
|
||||
protected RMEntryVoter voter;
|
||||
|
||||
/** List of actions */
|
||||
protected List<RecordsManagementAction> actions = new ArrayList<RecordsManagementAction>(1);
|
||||
/** Capability service */
|
||||
protected CapabilityService capabilityService;
|
||||
|
||||
/** Action names */
|
||||
protected List<String> actionNames = new ArrayList<String>(1);
|
||||
/** Capability name */
|
||||
protected String name;
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
/** Capability title and description */
|
||||
protected String title;
|
||||
protected String description;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/** Capability group id and title*/
|
||||
protected String groupId;
|
||||
protected String groupTitle;
|
||||
|
||||
/**
|
||||
* @param titleId message id
|
||||
*/
|
||||
public void setTitleId(String titleId)
|
||||
{
|
||||
this.title = I18NUtil.getMessage(titleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getTitle()
|
||||
*/
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
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;
|
||||
}
|
||||
/** Indicates whether this is a private capability or not */
|
||||
protected boolean isPrivate = false;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#isPrivate()
|
||||
*/
|
||||
public boolean isPrivate()
|
||||
{
|
||||
return isPrivate;
|
||||
}
|
||||
/** List of actions */
|
||||
protected List<RecordsManagementAction> actions = new ArrayList<RecordsManagementAction>(1);
|
||||
|
||||
/**
|
||||
* @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:
|
||||
/** Action names */
|
||||
protected List<String> actionNames = new ArrayList<String>(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.
|
||||
* <p>
|
||||
* 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<String> getActionNames()
|
||||
{
|
||||
return actionNames;
|
||||
}
|
||||
/**
|
||||
* Determines whether the current user has permission on this capability.
|
||||
* <p>
|
||||
* 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<RecordsManagementAction> 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<String> getActionNames()
|
||||
{
|
||||
return actionNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.Capability#getActions()
|
||||
*/
|
||||
public List<RecordsManagementAction> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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<String> getActionNames();
|
||||
/**
|
||||
* Evaluates the capability.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
int evaluate(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<RecordsManagementAction> 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<String> getActionNames();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<RecordsManagementAction> 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();
|
||||
}
|
||||
|
@@ -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<Capability> 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<Capability> getCapabilities(boolean includePrivate);
|
||||
|
||||
/**
|
||||
* Get all the capabilities access state based on the current user for the assignable capabilities.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return
|
||||
*/
|
||||
Map<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Get all the capabilities access state based on the current user.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return
|
||||
*/
|
||||
Map<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nodeRef
|
||||
* @param capabilityNames
|
||||
* @return
|
||||
*/
|
||||
Map<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef, List<String> 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<Capability> 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<Capability> getCapabilities(boolean includePrivate);
|
||||
|
||||
/**
|
||||
* Get all the capabilities access state based on the current user for the assignable capabilities.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return
|
||||
*/
|
||||
Map<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Get all the capabilities access state based on the current user.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return
|
||||
*/
|
||||
Map<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nodeRef
|
||||
* @param capabilityNames
|
||||
* @return
|
||||
*/
|
||||
Map<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef, List<String> 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<String, Map<String, String>> getGroupedCapabilities();
|
||||
}
|
||||
|
@@ -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<String, Capability> capabilities = new HashMap<String, Capability>(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<String, Capability> capabilities = new HashMap<String, Capability>(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<Capability> 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<Capability> getCapabilities()
|
||||
{
|
||||
return getCapabilities(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities(boolean)
|
||||
*/
|
||||
@Override
|
||||
public Set<Capability> getCapabilities(boolean includePrivate)
|
||||
{
|
||||
Set<Capability> result = null;
|
||||
if (includePrivate == true)
|
||||
{
|
||||
result = new HashSet<Capability>(capabilities.values());
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new HashSet<Capability>(capabilities.size());
|
||||
for (Capability capability : capabilities.values())
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getCapabilities(boolean)
|
||||
*/
|
||||
@Override
|
||||
public Set<Capability> getCapabilities(boolean includePrivate)
|
||||
{
|
||||
Set<Capability> result = null;
|
||||
if (includePrivate == true)
|
||||
{
|
||||
result = new HashSet<Capability>(capabilities.values());
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new HashSet<Capability>(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<Capability, AccessStatus> 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<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate)
|
||||
{
|
||||
Set<Capability> listOfCapabilites = getCapabilities(includePrivate);
|
||||
HashMap<Capability, AccessStatus> answer = new HashMap<Capability, AccessStatus>();
|
||||
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<Capability, AccessStatus> 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<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef, boolean includePrivate)
|
||||
{
|
||||
ParameterCheck.mandatory("nodeRef", nodeRef);
|
||||
|
||||
Set<Capability> listOfCapabilites = getCapabilities(includePrivate);
|
||||
HashMap<Capability, AccessStatus> answer = new HashMap<Capability, AccessStatus>();
|
||||
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<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef, List<String> capabilityNames)
|
||||
{
|
||||
ParameterCheck.mandatory("nodeRef", nodeRef);
|
||||
ParameterCheck.mandatory("capabilityNames", capabilityNames);
|
||||
|
||||
HashMap<Capability, AccessStatus> answer = new HashMap<Capability, AccessStatus>();
|
||||
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<Capability, AccessStatus> getCapabilitiesAccessState(NodeRef nodeRef, List<String> capabilityNames)
|
||||
{
|
||||
HashMap<Capability, AccessStatus> answer = new HashMap<Capability, AccessStatus>();
|
||||
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<String> list = Collections.singletonList(capabilityName);
|
||||
Map<Capability, AccessStatus> 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<String> list = Collections.singletonList(capabilityName);
|
||||
Map<Capability, AccessStatus> map = getCapabilitiesAccessState(nodeRef, list);
|
||||
result = map.get(capability);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService#getGroupedCapabilities()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Map<String, String>> getGroupedCapabilities()
|
||||
{
|
||||
Map<String, Map<String, String>> groupedCapabilities = new HashMap<String, Map<String, String>>(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<String, String> capabilityList = new HashMap<String, String>(13);
|
||||
capabilityList.put(capabilityName, capabilityTitle);
|
||||
groupedCapabilities.put(groupTitle, capabilityList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return groupedCapabilities;
|
||||
}
|
||||
}
|
||||
|
@@ -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<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
Set<Role> roles = null;
|
||||
|
||||
// TODO should be passed
|
||||
List<NodeRef> 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<Role>(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<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
Set<Role> roles = null;
|
||||
|
||||
// TODO should be passed
|
||||
List<NodeRef> 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<Role>(1);
|
||||
}
|
||||
|
||||
model.put("roles", roles);
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
@@ -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<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
Map<String, String> 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<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
Map<String, String> 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<NodeRef> 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<String, Object> model = new HashMap<String, Object>(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<NodeRef> 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<Capability, AccessStatus> map = capabilityService.getCapabilitiesAccessState(nodeRef, includePrivate);
|
||||
List<String> list = new ArrayList<String>(map.size());
|
||||
for (Map.Entry<Capability, AccessStatus> entry : map.entrySet())
|
||||
{
|
||||
}
|
||||
|
||||
Map<Capability, AccessStatus> map = capabilityService.getCapabilitiesAccessState(nodeRef, includePrivate);
|
||||
List<String> list = new ArrayList<String>(map.size());
|
||||
for (Map.Entry<Capability, AccessStatus> entry : map.entrySet())
|
||||
{
|
||||
AccessStatus accessStatus = entry.getValue();
|
||||
if (AccessStatus.DENIED.equals(accessStatus) == false)
|
||||
{
|
||||
Capability capability = entry.getKey();
|
||||
list.add(capability.getName());
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||
model.put("capabilities", list);
|
||||
return model;
|
||||
}
|
||||
Capability capability = entry.getKey();
|
||||
list.add(capability.getName());
|
||||
}
|
||||
}
|
||||
model.put("capabilities", list);
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user