Story: RM-1206 (As a records user I want to be able to add records to a hold(s) I have permission to see so that I can freeze a record)

Sub-task: RM-1321 (Implement UI for adding records/folders to hold(s))

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@64360 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-03-14 17:49:34 +00:00
parent 73c3477e72
commit 5d295a5382
11 changed files with 93 additions and 45 deletions

View File

@@ -36,15 +36,17 @@ public interface HoldService
* @param filePlan The {@link NodeRef} of the file plan
* @return List of hold node references
*/
List<NodeRef> getHoldsInFilePlan(NodeRef filePlan);
List<NodeRef> getHolds(NodeRef filePlan);
/**
* Gets the list of all the holds within the holds container for the given node reference
*
* @param nodeRef The {@link NodeRef} of the record / record folder which will be in the retrieved list of hold(s)
* @return List of hold node references which has the node reference of the given record / record folder in it
* @param nodeRef The {@link NodeRef} of the record / record folder
* @param includedInHold <code>true</code> to retrieve the list of hold node references which will include the node reference
* <code>false</code> to get a list of node references which will not have the given node reference
* @return List of hold node references
*/
List<NodeRef> getHoldsForItem(NodeRef nodeRef);
List<NodeRef> getHolds(NodeRef nodeRef, boolean includedInHold);
/**
* Adds the record to the given hold

View File

@@ -38,6 +38,7 @@ import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.ParameterCheck;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -105,10 +106,10 @@ public class HoldServiceImpl implements HoldService, RecordsManagementModel
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService#getHoldsInFilePlan(org.alfresco.service.cmr.repository.NodeRef)
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService#getHolds(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public List<NodeRef> getHoldsInFilePlan(NodeRef filePlan)
public List<NodeRef> getHolds(NodeRef filePlan)
{
ParameterCheck.mandatory("filePlan", filePlan);
@@ -124,21 +125,34 @@ public class HoldServiceImpl implements HoldService, RecordsManagementModel
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService#getHoldsForItem(org.alfresco.service.cmr.repository.NodeRef)
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService#getHolds(org.alfresco.service.cmr.repository.NodeRef, boolean)
*/
@Override
public List<NodeRef> getHoldsForItem(NodeRef nodeRef)
public List<NodeRef> getHolds(NodeRef nodeRef, boolean includedInHold)
{
ParameterCheck.mandatory("nodeRef", nodeRef);
List<NodeRef> result = new ArrayList<NodeRef>();
List<ChildAssociationRef> holdsAssocs = nodeService.getParentAssocs(nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS);
List<NodeRef> holds = new ArrayList<NodeRef>(holdsAssocs.size());
List<NodeRef> holdsNotIncludingNodeRef = new ArrayList<NodeRef>(holdsAssocs.size());
for (ChildAssociationRef holdAssoc : holdsAssocs)
{
holds.add(holdAssoc.getParentRef());
holdsNotIncludingNodeRef.add(holdAssoc.getParentRef());
}
result.addAll(holdsNotIncludingNodeRef);
if (!includedInHold)
{
NodeRef filePlan = filePlanService.getFilePlan(nodeRef);
List<NodeRef> allHolds = getHolds(filePlan);
@SuppressWarnings("unchecked")
List<NodeRef> holdsIncludingNodeRef = ListUtils.subtract(allHolds, holdsNotIncludingNodeRef);
result.clear();
result.addAll(holdsIncludingNodeRef);
}
return holds;
return result;
}
/**
@@ -169,18 +183,23 @@ public class HoldServiceImpl implements HoldService, RecordsManagementModel
// Link the record to the hold
nodeService.addChild(hold, nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS);
// Apply the freeze aspect
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2);
// Apply the freeze aspect
props.put(PROP_FROZEN_AT, new Date());
props.put(PROP_FROZEN_BY, AuthenticationUtil.getFullyAuthenticatedUser());
nodeService.addAspect(nodeRef, ASPECT_FROZEN, props);
boolean hasFrozenAspect = nodeService.hasAspect(nodeRef, ASPECT_FROZEN);
// Log a message about applying the the frozen aspect
if (logger.isDebugEnabled())
if (!hasFrozenAspect)
{
StringBuilder msg = new StringBuilder();
msg.append("Frozen aspect applied to '").append(nodeRef).append("'.");
logger.debug(msg.toString());
nodeService.addAspect(nodeRef, ASPECT_FROZEN, props);
if (logger.isDebugEnabled())
{
StringBuilder msg = new StringBuilder();
msg.append("Frozen aspect applied to '").append(nodeRef).append("'.");
logger.debug(msg.toString());
}
}
// Mark all the folders contents as frozen
@@ -190,7 +209,7 @@ public class HoldServiceImpl implements HoldService, RecordsManagementModel
for (NodeRef record : records)
{
// no need to freeze if already frozen!
if (nodeService.hasAspect(record, ASPECT_FROZEN) == false)
if (!hasFrozenAspect)
{
nodeService.addAspect(record, ASPECT_FROZEN, props);
@@ -233,5 +252,11 @@ public class HoldServiceImpl implements HoldService, RecordsManagementModel
{
nodeService.removeChild(hold, nodeRef);
}
List<NodeRef> holdList = getHolds(nodeRef, true);
if (holdList.size() == 0)
{
nodeService.removeAspect(nodeRef, ASPECT_FROZEN);
}
}
}

View File

@@ -149,7 +149,7 @@ public interface FreezeService
* @param filePlan file plan for which the hold nodes will be retrieved
* @return Set<NodeRef> hold node references
*
* @deprecated as of 2.2, use {@link HoldService#getHoldsInFilePlan(NodeRef)} instead
* @deprecated as of 2.2, use {@link HoldService#getHolds(NodeRef)} instead
*/
@Deprecated
Set<NodeRef> getHolds(NodeRef filePlan);

View File

@@ -381,7 +381,7 @@ public class FreezeServiceImpl extends ServiceBaseImpl
{
ParameterCheck.mandatory("filePlan", filePlan);
return new HashSet<NodeRef>(holdService.getHoldsInFilePlan(filePlan));
return new HashSet<NodeRef>(holdService.getHolds(filePlan));
}
/**

View File

@@ -91,17 +91,18 @@ public class HoldsGet extends DeclarativeWebScript
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
NodeRef filePlan = getFilePlan(req);
NodeRef itemNodeRef = getItemNodeRef(req);
List<NodeRef> holds = new ArrayList<NodeRef>();
if (itemNodeRef == null)
{
holds.addAll(holdService.getHoldsInFilePlan(filePlan));
NodeRef filePlan = getFilePlan(req);
holds.addAll(holdService.getHolds(filePlan));
}
else
{
holds.addAll(holdService.getHoldsForItem(itemNodeRef));
boolean includedInHold = getIncludedInHold(req);
holds.addAll(holdService.getHolds(itemNodeRef, includedInHold));
}
List<Hold> holdObjects = new ArrayList<Hold>(holds.size());
@@ -119,7 +120,7 @@ public class HoldsGet extends DeclarativeWebScript
}
/**
* Helper method to get the file plan
* Helper method to get the file plan from the request
*
* @param req The webscript request
* @return The {@link NodeRef} of the file plan
@@ -150,7 +151,7 @@ public class HoldsGet extends DeclarativeWebScript
}
/**
* Helper method to get the item node reference
* Helper method to get the item node reference from the request
*
* @param req The webscript request
* @return The {@link NodeRef} of the item (record / record folder) or null if the parameter has not been passed
@@ -166,6 +167,23 @@ public class HoldsGet extends DeclarativeWebScript
return itemNodeRef;
}
/**
* Helper method to get the includeInHold parameter value from the request
*
* @param req The webscript request
* @return The value of the includeInHold parameter
*/
private boolean getIncludedInHold(WebScriptRequest req)
{
boolean result = true;
String includedInHold = req.getParameter("includedInHold");
if (StringUtils.isNotBlank(includedInHold))
{
result = Boolean.valueOf(includedInHold).booleanValue();
}
return result;
}
/**
* Helper method to sort the holds by their names
*