mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Story: RM-1212 (As a records user I want to perform a records search, select multiple records/record folders from the results and add them all to a hold(s) I have permission to see so that I can easily discover and freeze relevant records)
Sub-tasks: * RM-1400 (Change the service so that all holds will be retrieved when adding multiple records/folders) * RM-1402 (Change the REST API so that all holds will be retrieved when adding multiple records/folders) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@65918 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -38,7 +38,7 @@ public interface HoldService
|
||||
* @return boolean true if hold, false otherwise
|
||||
*/
|
||||
boolean isHold(NodeRef nodeRef);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of all the holds within the holds container in the given file plan
|
||||
*
|
||||
@@ -48,9 +48,10 @@ public interface HoldService
|
||||
List<NodeRef> getHolds(NodeRef filePlan);
|
||||
|
||||
/**
|
||||
* Gets the node reference for the hold with the given name in the given file plan
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
* @param name {@link String} The name of the hold
|
||||
* @return {@link NodeRef} of the hold with the given name
|
||||
*/
|
||||
NodeRef getHold(NodeRef filePlan, String name);
|
||||
|
||||
@@ -63,44 +64,49 @@ public interface HoldService
|
||||
* @return List of hold node references
|
||||
*/
|
||||
List<NodeRef> heldBy(NodeRef nodeRef, boolean includedInHold);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of item node references which are in the given hold
|
||||
*
|
||||
* @param ndoeRef
|
||||
* @return
|
||||
* @param ndoeRef {@link NodeRef} of the hold
|
||||
* @return Lost of item {@link NodeRef}s which are in the given hold
|
||||
*/
|
||||
List<NodeRef> getHeld(NodeRef hold);
|
||||
|
||||
|
||||
/**
|
||||
* Creates a hold with the given name, reason and description for the given file plan
|
||||
*
|
||||
* @param filePlan
|
||||
* @param name
|
||||
* @param reason
|
||||
* @param description
|
||||
* @return
|
||||
* @param filePlan The {@link NodeRef} of the file plan
|
||||
* @param name {@link String} The name of the hold
|
||||
* @param reason {@link String} The reason of the hold
|
||||
* @param description {@link String} The description of the hold
|
||||
* @return The {@link NodeRef} of the created hold
|
||||
*/
|
||||
NodeRef createHold(NodeRef filePlan, String name, String reason, String description);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the hold reason for the given hold node reference
|
||||
*
|
||||
* @param hold
|
||||
* @return
|
||||
* @param hold The {@link NodeRef} of the hold
|
||||
* @return {@link String} The reason of the hold
|
||||
*/
|
||||
String getHoldReason(NodeRef hold);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the hold reason
|
||||
*
|
||||
* @param hold
|
||||
* @param reason
|
||||
* @param hold The {@link NodeRef} of the hold
|
||||
* @param reason {@link String} The reason for the hold
|
||||
*/
|
||||
void setHoldReason(NodeRef hold, String reason);
|
||||
|
||||
|
||||
/**
|
||||
* Deletes the hold
|
||||
*
|
||||
* @param hold
|
||||
* @param hold The {@link NodeRef} of the hold
|
||||
*/
|
||||
void deleteHold(NodeRef hold);
|
||||
|
||||
|
||||
/**
|
||||
* Adds the record to the given hold
|
||||
*
|
||||
@@ -108,11 +114,12 @@ public interface HoldService
|
||||
* @param nodeRef The {@link NodeRef} of the record / record folder which will be added to the given hold
|
||||
*/
|
||||
void addToHold(NodeRef hold, NodeRef nodeRef);
|
||||
|
||||
|
||||
/**
|
||||
* Adds the items to the the given hold
|
||||
*
|
||||
* @param hold
|
||||
* @param nodeRefs
|
||||
* @param hold The {@link NodeRef} of the hold to which the items will be added
|
||||
* @param nodeRefs The item {@link NodeRef}s which will be added to the hold
|
||||
*/
|
||||
void addToHold(NodeRef hold, List<NodeRef> nodeRefs);
|
||||
|
||||
@@ -124,6 +131,14 @@ public interface HoldService
|
||||
*/
|
||||
void addToHolds(List<NodeRef> holds, NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Adds the given items to the given list of holds
|
||||
*
|
||||
* @param holds List of holds to which the given items will be added
|
||||
* @param nodeRefs The list of items which will be added to the given holds
|
||||
*/
|
||||
void addToHolds(List<NodeRef> holds, List<NodeRef> nodeRefs);
|
||||
|
||||
/**
|
||||
* Removes the record from the given hold
|
||||
*
|
||||
@@ -131,31 +146,42 @@ public interface HoldService
|
||||
* @param nodeRef The {@link NodeRef} of the record / record folder which will be removed from the given hold
|
||||
*/
|
||||
void removeFromHold(NodeRef hold, NodeRef nodeRef);
|
||||
|
||||
|
||||
/**
|
||||
* Removes the given items from the given hold
|
||||
*
|
||||
* @param hold
|
||||
* @param nodeRefs
|
||||
* @param hold The hold {@link NodeRef} from which the given items will be removed
|
||||
* @param nodeRefs The list of items which will be removed from the given holds
|
||||
*/
|
||||
void removeFromHold(NodeRef hold, List<NodeRef> nodeRefs);
|
||||
|
||||
/**
|
||||
* Removes the record from the given list of hold
|
||||
* Removes the item from the given list of hold
|
||||
*
|
||||
* @param holds The list {@link NodeRef}s of the holds
|
||||
* @param nodeRef The {@link NodeRef} of the record / record folder which will be removed from the given holds
|
||||
*/
|
||||
void removeFromHolds(List<NodeRef> holds, NodeRef nodeRef);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nodeRef
|
||||
* Removes the items from the given holds
|
||||
*
|
||||
* @param holds List of hold {@link NodeRef}s from which the items will be removed
|
||||
* @param nodeRefs List of item {@link NodeRef}s which will be removed from the given holds
|
||||
*/
|
||||
void removeFromHolds(List<NodeRef> holds, List<NodeRef> nodeRefs);
|
||||
|
||||
/**
|
||||
* Removes the given {@link NodeRef} from all the holds
|
||||
*
|
||||
* @param nodeRef The {@link NodeRef} of item which will be removed from all the holds
|
||||
*/
|
||||
void removeFromAllHolds(NodeRef nodeRef);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nodeRefs
|
||||
* Removes the given list of {@link NodeRef}s from all the holds
|
||||
*
|
||||
* @param nodeRefs The list of item {@link NodeRef}s which will be removed from all the holds
|
||||
*/
|
||||
void removeFromAllHolds(List<NodeRef> nodeRefs);
|
||||
}
|
||||
|
@@ -497,6 +497,21 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#addToHolds(java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void addToHolds(List<NodeRef> holds, List<NodeRef> nodeRefs)
|
||||
{
|
||||
ParameterCheck.mandatoryCollection("holds", holds);
|
||||
ParameterCheck.mandatoryCollection("nodeRefs", nodeRefs);
|
||||
|
||||
for (NodeRef nodeRef : nodeRefs)
|
||||
{
|
||||
addToHolds(holds, nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromHold(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@@ -564,6 +579,21 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromHolds(java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void removeFromHolds(List<NodeRef> holds, List<NodeRef> nodeRefs)
|
||||
{
|
||||
ParameterCheck.mandatoryCollection("holds", holds);
|
||||
ParameterCheck.mandatoryCollection("nodeRefs", nodeRefs);
|
||||
|
||||
for (NodeRef nodeRef : nodeRefs)
|
||||
{
|
||||
removeFromHolds(holds, nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.hold.HoldService#removeFromAllHolds(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
|
@@ -49,13 +49,13 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
{
|
||||
/** Hold Service */
|
||||
private HoldService holdService;
|
||||
|
||||
|
||||
/** record service */
|
||||
private RecordService recordService;
|
||||
|
||||
|
||||
/** record folder service */
|
||||
private RecordFolderService recordFolderService;
|
||||
|
||||
|
||||
/** node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
{
|
||||
this.holdService = holdService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param recordFolderService record folder service
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
{
|
||||
this.recordFolderService = recordFolderService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param recordService record service
|
||||
*/
|
||||
@@ -84,7 +84,7 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
@@ -111,19 +111,19 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
{
|
||||
JSONObject json = getJSONFromContent(req);
|
||||
List<NodeRef> holds = getHolds(json);
|
||||
NodeRef nodeRef = getItemNodeRef(json);
|
||||
doAction(holds, nodeRef);
|
||||
List<NodeRef> nodeRefs = getItemNodeRefs(json);
|
||||
doAction(holds, nodeRefs);
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract method which will be implemented in the subclasses.
|
||||
* It will either add the item to the hold(s) or remove it from the hold(s)
|
||||
* It will either add the item(s) to the hold(s) or remove it/them from the hold(s)
|
||||
*
|
||||
* @param holds List of hold {@link NodeRef}(s)
|
||||
* @param nodeRef {@link NodeRef} of an item (record / record folder) which will be either added to the hold(s) or removed from the hol(s)
|
||||
* @param nodeRefs List of item {@link NodeRef}(s) (record(s) / record folder(s)) which will be either added to the hold(s) or removed from the hold(s)
|
||||
*/
|
||||
abstract void doAction(List<NodeRef> holds, NodeRef nodeRef);
|
||||
abstract void doAction(List<NodeRef> holds, List<NodeRef> nodeRefs);
|
||||
|
||||
/**
|
||||
* Helper method the get the json object from the request
|
||||
@@ -154,40 +154,51 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get the {@link NodeRef} for the item (record / record folder) which will be added to the hold(s)
|
||||
* Helper method to get the {@link NodeRef}s for the items(s) (record(s) / record folder(s)) which will be added to the hold(s)
|
||||
*
|
||||
* @param json The request content as JSON object
|
||||
* @return The {@link NodeRef} of the item which will be added to the hold(s)
|
||||
* @return List of item {@link NodeRef}s which will be added to the hold(s)
|
||||
*/
|
||||
protected NodeRef getItemNodeRef(JSONObject json)
|
||||
protected List<NodeRef> getItemNodeRefs(JSONObject json)
|
||||
{
|
||||
String nodeRefString = null;
|
||||
List<NodeRef> nodeRefs = new ArrayList<NodeRef>();
|
||||
try
|
||||
{
|
||||
nodeRefString = json.getString("nodeRef");
|
||||
JSONArray nodeRefsArray = json.getJSONArray("nodeRefs");
|
||||
for (int i = 0; i < nodeRefsArray.length(); i++)
|
||||
{
|
||||
NodeRef nodeReference = new NodeRef(nodeRefsArray.getString(i));
|
||||
checkItemNodeRef(nodeReference);
|
||||
nodeRefs.add(nodeReference);
|
||||
}
|
||||
}
|
||||
catch (JSONException je)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
||||
"Could not get the nodeRef from the json object.", je);
|
||||
"Could not get information from the json array.", je);
|
||||
}
|
||||
|
||||
NodeRef nodeRef = new NodeRef(nodeRefString);
|
||||
|
||||
return nodeRefs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for checking the node reference for an item
|
||||
*
|
||||
* @param nodeRef The {@link NodeRef} of an item (record / record folder)
|
||||
*/
|
||||
private void checkItemNodeRef(NodeRef nodeRef)
|
||||
{
|
||||
// ensure that the node exists
|
||||
if (!nodeService.exists(nodeRef))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Item being added to hold does not exist.");
|
||||
}
|
||||
|
||||
// ensure that the node we are adding to the hold is a record or
|
||||
// record folder
|
||||
|
||||
// ensure that the node we are adding to the hold is a record or record folder
|
||||
if (!recordService.isRecord(nodeRef) && !recordFolderService.isRecordFolder(nodeRef))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Items added to a hold must be either a record or record folder.");
|
||||
}
|
||||
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,27 +216,36 @@ public abstract class BaseHold extends DeclarativeWebScript
|
||||
for (int i = 0; i < holdsArray.length(); i++)
|
||||
{
|
||||
NodeRef nodeRef = new NodeRef(holdsArray.getString(i));
|
||||
|
||||
// check the hold exists
|
||||
if (!nodeService.exists(nodeRef))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The hold does not exist.");
|
||||
}
|
||||
|
||||
// check the noderef is actually a hold
|
||||
if (!holdService.isHold(nodeRef))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Items are being added to a node that isn't a hold.");
|
||||
}
|
||||
|
||||
checkHoldNodeRef(nodeRef);
|
||||
holds.add(nodeRef);
|
||||
}
|
||||
}
|
||||
catch (JSONException je)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
|
||||
"Could not get information from json array.", je);
|
||||
"Could not get information from the json array.", je);
|
||||
}
|
||||
|
||||
return holds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for checking the node reference for a hold
|
||||
*
|
||||
* @param nodeRef The {@link NodeRef} of a hold
|
||||
*/
|
||||
private void checkHoldNodeRef(NodeRef nodeRef)
|
||||
{
|
||||
// check the hold exists
|
||||
if (!nodeService.exists(nodeRef))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The hold does not exist.");
|
||||
}
|
||||
|
||||
// check the noderef is actually a hold
|
||||
if (!holdService.isHold(nodeRef))
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Items are being added to a node that isn't a hold.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,11 +31,11 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
public class HoldPost extends BaseHold
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.script.hold.BaseHold#doAction(java.util.List, org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.script.hold.BaseHold#doAction(java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
void doAction(List<NodeRef> holds, NodeRef nodeRef)
|
||||
void doAction(List<NodeRef> holds, List<NodeRef> nodeRefs)
|
||||
{
|
||||
getHoldService().addToHolds(holds, nodeRef);
|
||||
getHoldService().addToHolds(holds, nodeRefs);
|
||||
}
|
||||
}
|
||||
|
@@ -31,11 +31,11 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
public class HoldPut extends BaseHold
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.script.hold.BaseHold#doAction(java.util.List, org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.script.hold.BaseHold#doAction(java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
void doAction(List<NodeRef> holds, NodeRef nodeRef)
|
||||
void doAction(List<NodeRef> holds, List<NodeRef> nodeRefs)
|
||||
{
|
||||
getHoldService().removeFromHolds(holds, nodeRef);
|
||||
getHoldService().removeFromHolds(holds, nodeRefs);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user