diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml index e87e5d81d2..0935b01903 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml @@ -103,7 +103,7 @@ Hold Container - rma:recordsManagementContainer + rma:hold rma:countable @@ -111,7 +111,7 @@ Hold Container Child - rma:recordsManagementContainer + rma:hold diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml index 7aa50dea2d..a7f7d52564 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml @@ -592,4 +592,11 @@ + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.post.desc.xml new file mode 100644 index 0000000000..8fa9a57492 --- /dev/null +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.post.desc.xml @@ -0,0 +1,17 @@ + + Adds an item to the hold(s) + + The body of the post should be in the form
+ {
+    "nodeRef" : nodeRef of the item (record / record folder),
+    "holds" : array of nodeRef for the hold(s)
+ }
+ ]]> +
+ /api/rma/holds + argument + user + required + internal +
\ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.post.json.ftl new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/hold.post.json.ftl @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java index cad28b48fa..1c05f217ed 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java @@ -214,10 +214,6 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { result = FilePlanComponentKind.RECORD; } - else if (getFreezeService().isHold(nodeRef) == true) - { - result = FilePlanComponentKind.HOLD; - } else if (instanceOf(nodeRef, TYPE_HOLD_CONTAINER)) { result = FilePlanComponentKind.HOLD_CONTAINER; @@ -226,6 +222,10 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { result = FilePlanComponentKind.HOLD_CONTAINER_CHILD; } + else if (getFreezeService().isHold(nodeRef) == true) + { + result = FilePlanComponentKind.HOLD; + } else if (getTransferService().isTransfer(nodeRef) == true) { result = FilePlanComponentKind.TRANSFER; diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPost.java new file mode 100644 index 0000000000..be34665558 --- /dev/null +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/HoldPost.java @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.hold; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.hold.HoldService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to add an item to the given hold in the hold container. + * + * @author Tuna Aksoy + * @since 2.2 + */ +public class HoldPost extends DeclarativeWebScript +{ + /** Hold Service */ + private HoldService holdService; + + /** + * Set the hold service + * + * @param holdService the hold service + */ + public void setHoldService(HoldService holdService) + { + this.holdService = holdService; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + NodeRef nodeRef = null; + List holds = new ArrayList(); + try + { + String content = req.getContent().getContent(); + JSONObject json = new JSONObject(new JSONTokener(content)); + nodeRef = getItemNodeRef(json); + holds.addAll(getHolds(json)); + } + catch (IOException iox) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not read content from req.", iox); + } + catch (JSONException je) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Could not parse JSON from req.", je); + } + + holdService.addToHoldContainers(holds, nodeRef); + + return new HashMap(); + } + + /** + * Helper method to get the {@link NodeRef} for the item (record / record folder) 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) + * @throws JSONException If there is no string value for the key + */ + private NodeRef getItemNodeRef(JSONObject json) throws JSONException + { + String nodeRef = json.getString("nodeRef"); + return new NodeRef(nodeRef); + } + + /** + * Helper method to get the list of {@link NodeRef}(s) for the hold(s) which will contain the item (record / record folder) + * + * @param json The request content as JSON object + * @return List of {@link NodeRef}(s) of the hold(s) + * @throws JSONException If there is no string value for the key + */ + private List getHolds(JSONObject json) throws JSONException + { + JSONArray holdsArray = json.getJSONArray("holds"); + List holds = new ArrayList(); + for (int i = 0; i < holdsArray.length(); i++) + { + String nodeRef = holdsArray.getString(i); + holds.add(new NodeRef(nodeRef)); + } + return holds; + } +}