From dd4b136d350a5e3c31acf0b73dd80bbe4e6a0a23 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Sun, 10 Mar 2013 17:49:16 +0000 Subject: [PATCH] RM-622 ("Manage Permissions" for "File Plan" influence "Manage Permissions" for "Unfiled Records") git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@47840 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../documentlibrary-v2/rm-doclist.get.js | 1 + .../documentlibrary-v2/rm-parse-args.lib.js | 142 ++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-parse-args.lib.js diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-doclist.get.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-doclist.get.js index ac91752be0..c57fd90d21 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-doclist.get.js +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-doclist.get.js @@ -2,6 +2,7 @@ + /** diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-parse-args.lib.js b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-parse-args.lib.js new file mode 100644 index 0000000000..dd9a034aa4 --- /dev/null +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/rm-parse-args.lib.js @@ -0,0 +1,142 @@ +/** + * Get and parse arguments + * + * @method getParsedArgs + * @return {array|null} Array containing the validated input parameters + */ +ParseArgs.getParsedArgs = function RecordsManagementFilter_getParsedArgs(containerType) +{ + var type = url.templateArgs.type, + libraryRoot = args.libraryRoot, + rootNode = null, + pathNode = null, + nodeRef = null, + path = "", + location = null; + + // Is this library rooted from a non-site nodeRef? + if (libraryRoot !== null) + { + libraryRoot = ParseArgs.resolveNode(libraryRoot); + } + + + if (url.templateArgs.store_type !== null) + { + /** + * nodeRef input: store_type, store_id and id + */ + var storeType = url.templateArgs.store_type, + storeId = url.templateArgs.store_id, + id = url.templateArgs.id; + + nodeRef = storeType + "://" + storeId + "/" + id; + rootNode = libraryRoot || ParseArgs.resolveNode(nodeRef); + if (rootNode == null) + { + status.setCode(status.STATUS_NOT_FOUND, "Not a valid nodeRef: '" + nodeRef + "'"); + return null; + } + + // Special case: make sure filter picks up correct mode + if (type == null && args.filter == null) + { + args.filter = "node"; + } + } + else + { + /** + * Site and container input + */ + var siteId = url.templateArgs.site, + containerId = url.templateArgs.container, + siteNode = siteService.getSite(siteId); + + if (siteNode === null) + { + status.setCode(status.STATUS_GONE, "Site not found: '" + siteId + "'"); + return null; + } + + rootNode = siteNode.getContainer(containerId); + if (rootNode === null) + { + rootNode = siteNode.createContainer(containerId, containerType || "cm:folder"); + if (rootNode === null) + { + status.setCode(status.STATUS_GONE, "Document Library container '" + containerId + "' not found in '" + siteId + "'. (No permission?)"); + return null; + } + + rootNode.properties["cm:description"] = "Document Library"; + + /** + * MOB-593: Add email alias on documentLibrary container creation + * + rootNode.addAspect("emailserver:aliasable"); + var emailAlias = siteId; + if (containerId != "documentLibrary") + { + emailAlias += "-" + containerId; + } + rootNode.properties["emailserver:alias"] = emailAlias; + */ + rootNode.save(); + } + } + + if (args.filter == "unfiledRecords") + { + var unfiledRecordContainer = rootNode.childrenByXPath("rma:Unfiled_x0020_Records"); + pathNode = unfiledRecordContainer.length > 0 ? unfiledRecordContainer[0] : rootNode; + } + else + { + // Path input? + path = url.templateArgs.path || ""; + pathNode = path.length > 0 ? rootNode.childByNamePath(path) : (pathNode || rootNode); + } + + if (pathNode === null) + { + status.setCode(status.STATUS_NOT_FOUND, "Path not found: '" + path + "'"); + return null; + } + + // Parent location parameter adjustment + location = Common.getLocation(pathNode, libraryRoot); + if (location === null) + { + status.setCode(status.STATUS_GONE, "Location is 'null'. (No permission?)"); + return null; + } + if (path !== "") + { + location.path = ParseArgs.combinePaths(location.path, location.file); + } + if (args.filter !== "node" && !pathNode.isContainer) + { + location.file = ""; + } + + var objRet = + { + rootNode: rootNode, + pathNode: pathNode, + libraryRoot: libraryRoot, + location: location, + path: path, + nodeRef: nodeRef, + type: type + }; + + // Multiple input files in the JSON body? + var files = ParseArgs.getMultipleInputValues("nodeRefs"); + if (typeof files != "string") + { + objRet.files = files; + } + + return objRet; +}; \ No newline at end of file