mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-1330 (Implement REST API for getting the hold(s) for a given node)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63826 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1669,7 +1669,8 @@
|
||||
<property name="objectDefinitionSource">
|
||||
<value>
|
||||
<![CDATA[
|
||||
org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService.getHolds=RM_ALLOW
|
||||
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.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
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Get the list of holds</shortname>
|
||||
<description>WebScript to get the list of available holds in the holds container</description>
|
||||
<url>/api/rma/{store_type}/{store_id}/{id}/holds</url>
|
||||
<url>/api/rma/holds</url>
|
||||
<url>/api/rma/{store_type}/{store_id}/{id}/holds?itemNodeRef={itemNodeRef?}</url>
|
||||
<url>/api/rma/holds?itemNodeRef={itemNodeRef?}</url>
|
||||
<format default="json">argument</format>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
|
@@ -31,12 +31,20 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
public interface HoldService
|
||||
{
|
||||
/**
|
||||
* Gets the list of the holds within the holds container for the given file plan
|
||||
* Gets the list of all the holds within the holds container in the given file plan
|
||||
*
|
||||
* @param filePlan The {@link NodeRef} of the file plan
|
||||
* @return List of hold node references
|
||||
*/
|
||||
List<NodeRef> getHolds(NodeRef filePlan);
|
||||
List<NodeRef> getHoldsInFilePlan(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
|
||||
*/
|
||||
List<NodeRef> getHoldsForItem(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Adds the record to the given hold
|
||||
|
@@ -105,22 +105,37 @@ public class HoldServiceImpl implements HoldService, RecordsManagementModel
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService#getHolds(org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService#getHoldsInFilePlan(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public List<NodeRef> getHolds(NodeRef filePlan)
|
||||
public List<NodeRef> getHoldsInFilePlan(NodeRef filePlan)
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
|
||||
NodeRef holdContainer = filePlanService.getHoldContainer(filePlan);
|
||||
List<ChildAssociationRef> holdsAssocs = nodeService.getChildAssocs(holdContainer, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
|
||||
List<NodeRef> holds = new ArrayList<NodeRef>(holdsAssocs.size());
|
||||
if (holdsAssocs != null && !holdsAssocs.isEmpty())
|
||||
{
|
||||
for (ChildAssociationRef holdAssoc : holdsAssocs)
|
||||
{
|
||||
holds.add(holdAssoc.getChildRef());
|
||||
}
|
||||
|
||||
return holds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService#getHoldsForItem(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public List<NodeRef> getHoldsForItem(NodeRef nodeRef)
|
||||
{
|
||||
ParameterCheck.mandatory("nodeRef", nodeRef);
|
||||
|
||||
List<ChildAssociationRef> holdsAssocs = nodeService.getParentAssocs(nodeRef, ASSOC_FROZEN_RECORDS, ASSOC_FROZEN_RECORDS);
|
||||
List<NodeRef> holds = new ArrayList<NodeRef>(holdsAssocs.size());
|
||||
for (ChildAssociationRef holdAssoc : holdsAssocs)
|
||||
{
|
||||
holds.add(holdAssoc.getParentRef());
|
||||
}
|
||||
|
||||
return holds;
|
||||
|
@@ -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#getHolds(NodeRef)} instead
|
||||
* @deprecated as of 2.2, use {@link HoldService#getHoldsInFilePlan(NodeRef)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
Set<NodeRef> getHolds(NodeRef filePlan);
|
||||
|
@@ -381,7 +381,7 @@ public class FreezeServiceImpl extends ServiceBaseImpl
|
||||
{
|
||||
ParameterCheck.mandatory("filePlan", filePlan);
|
||||
|
||||
return new HashSet<NodeRef>(holdService.getHolds(filePlan));
|
||||
return new HashSet<NodeRef>(holdService.getHoldsInFilePlan(filePlan));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -92,7 +92,18 @@ public class HoldsGet extends DeclarativeWebScript
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
NodeRef filePlan = getFilePlan(req);
|
||||
List<NodeRef> holds = holdService.getHolds(filePlan);
|
||||
NodeRef itemNodeRef = getItemNodeRef(req);
|
||||
List<NodeRef> holds = new ArrayList<NodeRef>();
|
||||
|
||||
if (itemNodeRef == null)
|
||||
{
|
||||
holds.addAll(holdService.getHoldsInFilePlan(filePlan));
|
||||
}
|
||||
else
|
||||
{
|
||||
holds.addAll(holdService.getHoldsForItem(itemNodeRef));
|
||||
}
|
||||
|
||||
List<String> holdNames = new ArrayList<String>(holds.size());
|
||||
for (NodeRef hold : holds)
|
||||
{
|
||||
@@ -138,6 +149,23 @@ public class HoldsGet extends DeclarativeWebScript
|
||||
return filePlan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the item node reference
|
||||
*
|
||||
* @param req The webscript request
|
||||
* @return The {@link NodeRef} of the item (record / record folder) or null if the parameter has not been passed
|
||||
*/
|
||||
private NodeRef getItemNodeRef(WebScriptRequest req)
|
||||
{
|
||||
String nodeRef = req.getParameter("itemNodeRef");
|
||||
NodeRef itemNodeRef = null;
|
||||
if (StringUtils.isNotBlank(nodeRef))
|
||||
{
|
||||
itemNodeRef = new NodeRef(nodeRef);
|
||||
}
|
||||
return itemNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to sort the holds by their names
|
||||
*
|
||||
|
@@ -127,7 +127,7 @@ public class RM1008Test extends BaseRMTestCase
|
||||
{
|
||||
// create hold object
|
||||
freezeService.freeze("test", rmFolder);
|
||||
List<NodeRef> holds = holdService.getHolds(filePlan);
|
||||
List<NodeRef> holds = holdService.getHoldsInFilePlan(filePlan);
|
||||
return holds.iterator().next();
|
||||
}
|
||||
}, rmAdminName);
|
||||
|
@@ -46,7 +46,7 @@ public class RM1030Test extends BaseRMTestCase
|
||||
public NodeRef run()
|
||||
{
|
||||
// show there are no holds when we start
|
||||
List<NodeRef> holds = holdService.getHolds(filePlan);
|
||||
List<NodeRef> holds = holdService.getHoldsInFilePlan(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.getHolds(filePlan);
|
||||
List<NodeRef> holds = holdService.getHoldsInFilePlan(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.getHolds(filePlan);
|
||||
List<NodeRef> holds = holdService.getHoldsInFilePlan(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.getHolds(filePlan);
|
||||
List<NodeRef> holds = holdService.getHoldsInFilePlan(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.getHolds(filePlan);
|
||||
List<NodeRef> holds = holdService.getHoldsInFilePlan(filePlan);
|
||||
assertNotNull(holds);
|
||||
assertEquals(0, holds.size());
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ public class FreezeServiceImplTest extends BaseRMTestCase
|
||||
assertTrue(freezeService.hasFrozenChildren(rmFolder));
|
||||
|
||||
// Check the hold exists
|
||||
List<NodeRef> holdAssocs = holdService.getHolds(filePlan);
|
||||
List<NodeRef> holdAssocs = holdService.getHoldsInFilePlan(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.getHolds(filePlan);
|
||||
holdAssocs = holdService.getHoldsInFilePlan(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.getHolds(filePlan);
|
||||
holdAssocs = holdService.getHoldsInFilePlan(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.getHolds(filePlan);
|
||||
holdAssocs = holdService.getHoldsInFilePlan(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.getHolds(filePlan);
|
||||
holdAssocs = holdService.getHoldsInFilePlan(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.getHolds(filePlan);
|
||||
holdAssocs = holdService.getHoldsInFilePlan(filePlan);
|
||||
assertNotNull(holdAssocs);
|
||||
assertEquals(1, holdAssocs.size());
|
||||
|
||||
|
@@ -433,7 +433,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
{
|
||||
if (filePlan != null && nodeService.exists(filePlan) == true)
|
||||
{
|
||||
List<NodeRef> holds = holdService.getHolds(filePlan);
|
||||
List<NodeRef> holds = holdService.getHoldsInFilePlan(filePlan);
|
||||
for (NodeRef hold : holds)
|
||||
{
|
||||
freezeService.relinquish(hold);
|
||||
|
Reference in New Issue
Block a user