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

@@ -1669,8 +1669,7 @@
<property name="objectDefinitionSource">
<value>
<![CDATA[
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.getHoldsInFilePlan=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.getHoldsForItem=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.getHolds=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.addToHoldContainer=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.addToHoldContainers=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.removeFromHoldContainer=RM_ALLOW

View File

@@ -2,12 +2,16 @@
<shortname>Gets the list of the hold(s)</shortname>
<description><![CDATA[
WebScript to get the list of the available holds in the holds container.
If an item node reference has been specified only those holds will be
retrieved which have the item node references, otherwise all hold node
references will be retrieved.
If an item node reference has not been specified all the hold node
references will be retrieved. If an item node reference has been specified
the list of the retrieved hold node references depends on the value of the
includeInHold parameter. If this is set to true a list of hold node
references will be retrieved which have the item node reference in it
(this is the default) otherwise a list of hold node references will be
retrieved which do not include the given node reference.
]]>
</description>
<url>/api/rma/{store_type}/{store_id}/{id}/holds?itemNodeRef={itemNodeRef?}</url>
<url>/api/rma/{store_type}/{store_id}/{id}/holds?itemNodeRef={itemNodeRef?}&amp;includedInHold={includedInHold?}</url>
<url>/api/rma/holds?itemNodeRef={itemNodeRef?}</url>
<format default="json">argument</format>
<authentication>user</authentication>

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,19 +183,24 @@ 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());
boolean hasFrozenAspect = nodeService.hasAspect(nodeRef, ASPECT_FROZEN);
if (!hasFrozenAspect)
{
nodeService.addAspect(nodeRef, ASPECT_FROZEN, props);
// Log a message about applying the the frozen aspect
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
if (recordFolderService.isRecordFolder(nodeRef))
@@ -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
*

View File

@@ -127,7 +127,7 @@ public class RM1008Test extends BaseRMTestCase
{
// create hold object
freezeService.freeze("test", rmFolder);
List<NodeRef> holds = holdService.getHoldsInFilePlan(filePlan);
List<NodeRef> holds = holdService.getHolds(filePlan);
return holds.iterator().next();
}
}, rmAdminName);

View File

@@ -46,7 +46,7 @@ public class RM1030Test extends BaseRMTestCase
public NodeRef run()
{
// show there are no holds when we start
List<NodeRef> holds = holdService.getHoldsInFilePlan(filePlan);
List<NodeRef> holds = holdService.getHolds(filePlan);
assertNotNull(holds);
assertEquals(0, holds.size());
@@ -64,7 +64,7 @@ public class RM1030Test extends BaseRMTestCase
assertTrue(freezeService.isFrozen(recordOne));
// count the number of holds
List<NodeRef> holds = holdService.getHoldsInFilePlan(filePlan);
List<NodeRef> holds = holdService.getHolds(filePlan);
assertNotNull(holds);
assertEquals(1, holds.size());
}
@@ -91,7 +91,7 @@ public class RM1030Test extends BaseRMTestCase
assertTrue(freezeService.isFrozen(rmFolder));
// count the number of holds
List<NodeRef> holds = holdService.getHoldsInFilePlan(filePlan);
List<NodeRef> holds = holdService.getHolds(filePlan);
assertNotNull(holds);
assertEquals(2, holds.size());
}
@@ -113,7 +113,7 @@ public class RM1030Test extends BaseRMTestCase
assertTrue(freezeService.isFrozen(recordOne));
assertFalse(freezeService.isFrozen(rmFolder));
List<NodeRef> holds = holdService.getHoldsInFilePlan(filePlan);
List<NodeRef> holds = holdService.getHolds(filePlan);
assertNotNull(holds);
assertEquals(1, holds.size());
}
@@ -135,7 +135,7 @@ public class RM1030Test extends BaseRMTestCase
assertFalse(freezeService.isFrozen(recordOne));
assertFalse(freezeService.isFrozen(rmFolder));
List<NodeRef> holds = holdService.getHoldsInFilePlan(filePlan);
List<NodeRef> holds = holdService.getHolds(filePlan);
assertNotNull(holds);
assertEquals(0, holds.size());
}

View File

@@ -65,7 +65,7 @@ public class FreezeServiceImplTest extends BaseRMTestCase
assertTrue(freezeService.hasFrozenChildren(rmFolder));
// Check the hold exists
List<NodeRef> holdAssocs = holdService.getHoldsInFilePlan(filePlan);
List<NodeRef> holdAssocs = holdService.getHolds(filePlan);
assertNotNull(holdAssocs);
assertEquals(1, holdAssocs.size());
NodeRef holdNodeRef = holdAssocs.iterator().next();
@@ -98,7 +98,7 @@ public class FreezeServiceImplTest extends BaseRMTestCase
assertTrue(freezeService.isHold(newHold));
// Check the holds exist
holdAssocs = holdService.getHoldsInFilePlan(filePlan);
holdAssocs = holdService.getHolds(filePlan);
assertNotNull(holdAssocs);
assertEquals(2, holdAssocs.size());
for (NodeRef hold : holdAssocs)
@@ -136,7 +136,7 @@ public class FreezeServiceImplTest extends BaseRMTestCase
freezeService.unFreeze(recordThree);
// Check the holds
holdAssocs = holdService.getHoldsInFilePlan(filePlan);
holdAssocs = holdService.getHolds(filePlan);
assertNotNull(holdAssocs);
assertEquals(2, holdAssocs.size());
for (NodeRef hold : holdAssocs)
@@ -175,7 +175,7 @@ public class FreezeServiceImplTest extends BaseRMTestCase
freezeService.relinquish(holdNodeRef);
// Check the existing hold
holdAssocs = holdService.getHoldsInFilePlan(filePlan);
holdAssocs = holdService.getHolds(filePlan);
assertNotNull(holdAssocs);
assertEquals(1, holdAssocs.size());
@@ -184,7 +184,7 @@ public class FreezeServiceImplTest extends BaseRMTestCase
freezeService.unFreeze(freezeService.getFrozen(holdNodeRef));
// All holds should be deleted
holdAssocs = holdService.getHoldsInFilePlan(filePlan);
holdAssocs = holdService.getHolds(filePlan);
assertEquals(0, holdAssocs.size());
// Check the nodes are unfrozen
@@ -204,7 +204,7 @@ public class FreezeServiceImplTest extends BaseRMTestCase
assertTrue(freezeService.hasFrozenChildren(rmFolder));
// Check the hold
holdAssocs = holdService.getHoldsInFilePlan(filePlan);
holdAssocs = holdService.getHolds(filePlan);
assertNotNull(holdAssocs);
assertEquals(1, holdAssocs.size());

View File

@@ -433,7 +433,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
{
if (filePlan != null && nodeService.exists(filePlan))
{
List<NodeRef> holds = holdService.getHoldsInFilePlan(filePlan);
List<NodeRef> holds = holdService.getHolds(filePlan);
for (NodeRef hold : holds)
{
freezeService.relinquish(hold);