From 0df277628ffde71659f7ceb36fd56ace9223ff3a Mon Sep 17 00:00:00 2001 From: Mike Hatfield Date: Thu, 24 Jul 2008 13:28:56 +0000 Subject: [PATCH] DocLib single and multi-asset Copy To action. DocLib RSS Feed link. Various bug fixes and CSS tweaks to DocLib components and data webscripts. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10005 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../slingshot/docsummary/docsummary.get.js | 3 +- .../documentlibrary/action-sets.lib.js | 3 +- .../documentlibrary/action/action.lib.ftl | 1 + .../documentlibrary/action/action.lib.js | 190 ++++++++---------- .../action/cancel-checkout.post.js | 8 +- .../documentlibrary/action/checkin.post.js | 8 +- .../documentlibrary/action/checkout.post.js | 8 +- .../action/copy-to.post.desc.xml | 11 + .../documentlibrary/action/copy-to.post.js | 77 +++++++ .../action/copy-to.post.json.ftl | 2 + .../documentlibrary/action/file.delete.js | 4 +- .../documentlibrary/action/folder.post.js | 2 +- .../action/move-to.post.desc.xml | 4 +- .../documentlibrary/action/move-to.post.js | 4 +- .../slingshot/documentlibrary/doclist.get.js | 18 +- .../documentlibrary/doclist.get.json.ftl | 27 ++- .../documentlibrary/doclist.get.rss.ftl | 6 +- .../documentlibrary/parse-args.lib.js | 24 ++- 18 files changed, 253 insertions(+), 147 deletions(-) create mode 100644 config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.desc.xml create mode 100644 config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.js create mode 100644 config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.json.ftl diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/docsummary/docsummary.get.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/docsummary/docsummary.get.js index f12a96f157..ac369e5046 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/docsummary/docsummary.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/docsummary/docsummary.get.js @@ -42,7 +42,8 @@ function getDocs(siteId, filter) var query = "+TYPE:\"{http://www.alfresco.org/model/content/1.0}content\" +PATH:\"" + path + "\" +@cm\\:modified:[" + fromQuery + "T00\\:00\\:00 TO " + - toQuery + "T23\\:59\\:59]"; + toQuery + "T23\\:59\\:59]" + + "-TYPE:\"{http://www.alfresco.org/model/content/1.0}thumbnail\""; if (logger.isLoggingEnabled()) logger.log("docsummary query = " + query); diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action-sets.lib.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action-sets.lib.js index 7fd72c20f1..577dd677e9 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action-sets.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action-sets.lib.js @@ -2,7 +2,8 @@ function getActionSet(asset, obj) { var actionSet = "empty"; var itemStatus = obj.itemStatus.toString(); - var isItemOwner = (obj.itemOwner == person.properties.userName); + var isItemOwner = null; + isItemOwner == (obj.itemOwner && obj.itemOwner.properties.userName == person.properties.userName); // Only 1 action set for folders if (asset.isContainer) diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.ftl index 1b16bb56bf..eacb060e3b 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.ftl @@ -1,6 +1,7 @@ <#macro resultsJSON results> { "totalResults": ${results?size}, + "overallSuccess": ${overallSuccess?string}, "results": [ <#list results as r> diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js index 309595c72c..ceff7a25f3 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js @@ -1,11 +1,13 @@ /** * Document List Component: action * - * Parameters are either supplied as JSON object literal in content body, - * or on request URI (e.g. HTTP DELETE methods must use URI) + * For a single-asset action, template paramters address the asset. + * For multi-asset actions, template parameters address the source or destination node, + * and a JSON body addresses the assets involved in the action. + * (note: HTTP DELETE methods must use URI) * - * @param uri {string} /{siteId}/{containerId}/{filepath} : full path to file or folder name involved in the action - * @param content {json} /{siteId}/{containerId}/{filepath} : full path to file or folder name involved in the action + * @param uri {string} site/{siteId}/{containerId}/{filepath} : full path to file or folder name involved in the action + * @param uri {string} node/{store_type}/{store_id}/{id}/{filepath} : full path to file or folder name involved in the action */ /* Bootstrap action script */ @@ -36,17 +38,29 @@ function main() return; } - // Try to get the root node if templateArg parameters passed-in - if (params.hasRootNode) + // Resolve path if available + var path = url.templateArgs.path; + // Path might be null for the root folder + if (!path) + { + path = ""; + } + // Remove any leading or trailing "/" from the path + // Fix-up parent path to have no leading or trailing slashes + if (path.length > 0) { - rootNode = getRootNode(params); - if (typeof node == "string") + var aPaths = path.split("/"); + while (aPaths[0] === "") { - status.setCode(status.STATUS_NOT_FOUND, node); - return; + aPaths.shift(); } - params.rootNode = rootNode; + while (aPaths[aPaths.length-1] === "") + { + aPaths.pop(); + } + path = aPaths.join("/"); } + params.path = path; // Multiple input files in the JSON body? files = getMultipleInputFiles(); @@ -81,6 +95,19 @@ function main() } else { + /** + * NOTE: Webscripts run within one transaction only. + * If a single operation fails, the transaction is marked for rollback and all + * previous (successful) operations are also therefore rolled back. + * We therefore need to scan the results for a failed operation and mark the entire + * set of operations as failed. + */ + var overallSuccess = true; + for (var i = 0, j = results.length; i < j; i++) + { + overallSuccess = overallSuccess && results[i].success; + } + model.overallSuccess = overallSuccess; model.results = results; } } @@ -103,48 +130,44 @@ function getSiteInputParams() // First try to get the parameters from the URI var siteId = url.templateArgs.site; var containerId = url.templateArgs.container; - var filePath = url.templateArgs.path; + // SiteId if ((siteId === null) || (siteId.length === 0)) { return "'site' parameter is missing."; } - // containerId + // Find the site + var siteNode = siteService.getSite(siteId); + if (siteNode === null) + { + return "Site '" + siteId + "' not found."; + } + + // ContainerId if ((containerId === null) || (containerId.length === 0)) { return "'container' parameter is missing."; } - - // filePath might be null for the root folder - if (filePath === null) - { - filePath = ""; - } - // Remove any leading or trailing "/" from the path - // Fix-up parent path to have no leading or trailing slashes - if (filePath.length > 0) - { - var aPaths = filePath.split("/"); - while (aPaths[0] === "") - { - aPaths.shift(); - } - while (aPaths[aPaths.length-1] === "") - { - aPaths.pop(); - } - filePath = aPaths.join("/"); - } + // Find the component container + var rootNode = siteNode.getContainer(containerId); + if (rootNode === null) + { + rootNode = siteNode.createContainer(containerId); + if (rootNode === null) + { + return "Component container '" + containerId + "' not found in '" + siteId + "'."; + } + } + // Populate the return object params = { - containerId: containerId, - siteId: siteId, - filePath: filePath, usingNodeRef: false, - hasRootNode: true + siteId: siteId, + containerId: containerId, + rootNode: rootNode } } catch(e) @@ -174,39 +197,33 @@ function getNodeRefInputParams() var storeId = url.templateArgs.store_id; var id = url.templateArgs.id; - // Was a JSON parameter list supplied? - // TODO: Also handle multiple files - if (typeof json == "object") - { - if (!json.isNull("store_type")) - { - storeType = json.get("store_type"); - } - if (!json.isNull("store_id")) - { - storeId = json.get("store_id"); - } - if (!json.isNull("id")) - { - id = json.get("id"); - } - } - var nodeRef = storeType + "://" + storeId + "/" + id; - var node = search.findNode(nodeRef); + var rootNode = null; - if (node === null) - { - return "'" + nodeRef + "' is not valid."; + if (nodeRef == "alfresco://company/home") + { + rootNode = companyhome; + } + else if (nodeRef == "alfresco://user/home") + { + rootNode = userhome; + } + else + { + rootNode = search.findNode(nodeRef); + + if (rootNode === null) + { + return "'" + nodeRef + "' is not a valid nodeRef."; + } } // Populate the return object params = { - nodeRef: nodeRef, - node: node, usingNodeRef: true, - hasRootNode: true + nodeRef: nodeRef, + rootNode: rootNode } } catch(e) @@ -255,53 +272,6 @@ function getMultipleInputFiles() } -/** - * Obtain the root node for the given site and component - * - * @method getRootNode - * @param p_params {object} Object literal containing mandatory parameters - * @return {object|string} valid repository node or string error - */ -function getRootNode(p_params) -{ - var rootNode = null; - var error = null; - - if (p_params.usingNodeRef) - { - return p_params.node; - } - - try - { - // Find the site - var siteNode = siteService.getSite(p_params.siteId); - if (siteNode === null) - { - return "Site '" + p_params.siteId + "' not found."; - } - - // Find the component container - rootNode = siteNode.getContainer(p_params.containerId); - if (rootNode === null) - { - rootNode = siteNode.createContainer(p_params.containerId); - if (rootNode === null) - { - return "Component container '" + p_params.containerId + "' not found in '" + p_params.siteId + "'."; - } - } - } - catch(e) - { - error = e.toString(); - } - - // Return the node object, or the error string if it was set - return (error !== null ? error : rootNode); -} - - /** * Obtain the asset node for the given rootNode and filepath * diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/cancel-checkout.post.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/cancel-checkout.post.js index 0137e5f0e2..57217f0395 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/cancel-checkout.post.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/cancel-checkout.post.js @@ -10,7 +10,7 @@ * Entrypoint required by action.lib.js * * @method runAction - * @param p_params {object} standard action parameters: nodeRef, siteId, containerId, filePath + * @param p_params {object} standard action parameters: nodeRef, siteId, containerId, path * @return {object|null} object representation of action result */ function runAction(p_params) @@ -19,12 +19,12 @@ function runAction(p_params) try { - var assetNode = getAssetNode(p_params.rootNode, p_params.filePath); + var assetNode = getAssetNode(p_params.rootNode, p_params.path); // Must have assetNode by this point if (typeof assetNode == "string") { - status.setCode(status.STATUS_NOT_FOUND, "Not found: " + p_params.filePath); + status.setCode(status.STATUS_NOT_FOUND, "Not found: " + p_params.path); return; } @@ -32,7 +32,7 @@ function runAction(p_params) var originalDoc = assetNode.cancelCheckout(); if (originalDoc === null) { - status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, "Could not cancel checkout: " + p_params.filePath); + status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, "Could not cancel checkout: " + p_params.path); return; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkin.post.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkin.post.js index 408146b578..4d2b729fe6 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkin.post.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkin.post.js @@ -10,7 +10,7 @@ * Entrypoint required by action.lib.js * * @method runAction - * @param p_params {object} standard action parameters: nodeRef, siteId, containerId, filePath + * @param p_params {object} standard action parameters: nodeRef, siteId, containerId, path * @return {object|null} object representation of action result */ function runAction(p_params) @@ -19,12 +19,12 @@ function runAction(p_params) try { - var assetNode = p_params.node || getAssetNode(p_params.rootNode, p_params.filePath); + var assetNode = p_params.node || getAssetNode(p_params.rootNode, p_params.path); // Must have assetNode by this point if (typeof assetNode == "string") { - status.setCode(status.STATUS_NOT_FOUND, "Not found: " + p_params.filePath); + status.setCode(status.STATUS_NOT_FOUND, "Not found: " + p_params.path); return; } @@ -32,7 +32,7 @@ function runAction(p_params) var originalDoc = assetNode.checkin(); if (originalDoc === null) { - status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, "Could not checkin: " + p_params.filePath); + status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, "Could not checkin: " + p_params.path); return; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkout.post.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkout.post.js index db44b32f17..df89bc2d1d 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkout.post.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkout.post.js @@ -11,7 +11,7 @@ * Entrypoint required by action.lib.js * * @method runAction - * @param p_params {object} standard action parameters: nodeRef, siteId, containerId, filePath + * @param p_params {object} standard action parameters: nodeRef, siteId, containerId, path * @return {object|null} object representation of action result */ function runAction(p_params) @@ -20,12 +20,12 @@ function runAction(p_params) try { - var assetNode = p_params.node || getAssetNode(p_params.rootNode, p_params.filePath); + var assetNode = p_params.node || getAssetNode(p_params.rootNode, p_params.path); // Must have assetNode by this point if (typeof assetNode == "string") { - status.setCode(status.STATUS_NOT_FOUND, "Not found: " + p_params.filePath); + status.setCode(status.STATUS_NOT_FOUND, "Not found: " + p_params.path); return; } @@ -33,7 +33,7 @@ function runAction(p_params) var workingCopy = assetNode.checkout(); if (workingCopy === null) { - status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, "Could not checkout: " + p_params.filePath); + status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, "Could not checkout: " + p_params.path); return; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.desc.xml new file mode 100644 index 0000000000..6ffecc34b6 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.desc.xml @@ -0,0 +1,11 @@ + + copy-to + Document List Action - Copy multiple files + /slingshot/doclib/action/copy-to/site/{site}/{container}/{path} + /slingshot/doclib/action/copy-to/site/{site}/{container} + /slingshot/doclib/action/copy-to/node/{store_type}/{store_id}/{id}/{path} + /slingshot/doclib/action/copy-to/node/{store_type}/{store_id}/{id} + argument + user + required + diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.js new file mode 100644 index 0000000000..a1937dfd7a --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.js @@ -0,0 +1,77 @@ + + +/** + * Copy multiple files action + * @method POST + */ + +/** + * Entrypoint required by action.lib.js + * + * @method runAction + * @param p_params {object} Object literal containing files array + * @return {object|null} object representation of action results + */ +function runAction(p_params) +{ + var results = []; + var files = p_params.files; + var file, fileNode, result, nodeRef; + + // Find destination node + var destNode = p_params.node || getAssetNode(p_params.rootNode, p_params.path); + + // Must have destNode by this point + if (typeof assetNode == "string") + { + status.setCode(status.STATUS_NOT_FOUND, "Not found: " + p_params.path); + return; + } + + // Must have array of files + if (!files || files.length == 0) + { + status.setCode(status.STATUS_BAD_REQUEST, "No files."); + return; + } + + for (file in files) + { + nodeRef = files[file]; + result = + { + nodeRef: nodeRef, + action: "copyFile", + success: false + } + + try + { + fileNode = search.findNode(nodeRef); + if (fileNode === null) + { + result.id = file; + result.nodeRef = nodeRef; + result.success = false; + } + else + { + result.id = fileNode.name; + result.type = fileNode.isContainer ? "folder" : "document"; + // copy the node (deep copy) + result.nodeRef = fileNode.copy(destNode, true); + result.success = (result.nodeRef !== null); + } + } + catch (e) + { + result.id = file; + result.nodeRef = nodeRef; + result.success = false; + } + + results.push(result); + } + + return results; +} diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.json.ftl new file mode 100644 index 0000000000..e2f0e9da9f --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.json.ftl @@ -0,0 +1,2 @@ +<#import "action.lib.ftl" as actionLib /> +<@actionLib.resultsJSON results=results /> \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/file.delete.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/file.delete.js index d03ffd8be2..34f3cbdf1e 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/file.delete.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/file.delete.js @@ -10,7 +10,7 @@ * Entrypoint required by action.lib.js * * @method runAction - * @param p_params {object} standard action parameters: nodeRef, siteId, containerId, filePath + * @param p_params {object} standard action parameters: nodeRef, siteId, containerId, path * @return {object|null} object representation of action result */ function runAction(p_params) @@ -19,7 +19,7 @@ function runAction(p_params) try { - var assetNode = p_params.node || getAssetNode(p_params.rootNode, p_params.filePath); + var assetNode = p_params.node || getAssetNode(p_params.rootNode, p_params.path); // Must have assetNode by this point if (typeof assetNode == "string") diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/folder.post.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/folder.post.js index 5162b37663..e69511ba4e 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/folder.post.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/folder.post.js @@ -30,7 +30,7 @@ function runAction(p_params) } var folderName = json.get("name"); - var parentPath = p_params.filePath; + var parentPath = p_params.path; var folderPath = parentPath + "/" + folderName; // Check folder doesn't already exist diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.desc.xml index aee02252c2..42b2ff668d 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.desc.xml @@ -1,7 +1,9 @@ - files + move-to Document List Action - Move multiple files /slingshot/doclib/action/move-to/site/{site}/{container}/{path} + /slingshot/doclib/action/move-to/site/{site}/{container} + /slingshot/doclib/action/move-to/node/{store_type}/{store_id}/{id}/{path} /slingshot/doclib/action/move-to/node/{store_type}/{store_id}/{id} argument user diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.js index 6ce797a5f5..e302ad6280 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.js @@ -19,12 +19,12 @@ function runAction(p_params) var file, fileNode, result, nodeRef; // Find destination node - var destNode = p_params.node || getAssetNode(p_params.rootNode, p_params.filePath); + var destNode = p_params.node || getAssetNode(p_params.rootNode, p_params.path); // Must have destNode by this point if (typeof assetNode == "string") { - status.setCode(status.STATUS_NOT_FOUND, "Not found: " + p_params.filePath); + status.setCode(status.STATUS_NOT_FOUND, "Not found: " + p_params.path); return; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js index 327f683873..1c2808dff1 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js @@ -49,27 +49,29 @@ function getDocList(filter) } // Locked/working copy status defines action set - var itemStatus, itemOwner, actionSet, thumbnail; + var itemStatus, itemOwner, actionSet, thumbnail, createdBy, modifiedBy; for each(asset in assets) { itemStatus = []; - itemOwner = ""; + itemOwner = null; + createdBy = null; + modifiedBy = null; if ((asset.isContainer && showFolders) || (asset.isDocument && showDocs)) { if (asset.isLocked) { itemStatus.push("locked"); - itemOwner = asset.properties["cm:lockOwner"]; + itemOwner = people.getPerson(asset.properties["cm:lockOwner"]); } if (asset.hasAspect("cm:workingcopy")) { itemStatus.push("workingCopy"); - itemOwner = asset.properties["cm:workingCopyOwner"]; + itemOwner = people.getPerson(asset.properties["cm:workingCopyOwner"]); } // Is this user the item owner? - if (itemOwner == person.properties.userName) + if (itemOwner && (itemOwner.properties.userName == person.properties.userName)) { itemStatus.push("lockedBySelf"); } @@ -85,6 +87,10 @@ function getDocList(filter) } } + // Get users + createdBy = people.getPerson(asset.properties["cm:creator"]); + modifiedBy = people.getPerson(asset.properties["cm:modifier"]); + // Get relevant actions set actionSet = getActionSet(asset, { @@ -97,6 +103,8 @@ function getDocList(filter) asset: asset, status: itemStatus, owner: itemOwner, + createdBy: createdBy, + modifiedBy: modifiedBy, actionSet: actionSet }); } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.json.ftl index efcf323ff4..6f2f9159e1 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.json.ftl @@ -9,6 +9,24 @@ <#assign d = item.asset> <#assign version = "1.0"> <#if d.hasAspect("cm:versionable")><#assign version = d.versionHistory?sort_by("versionLabel")?reverse[0].versionLabel> + <#if item.owner?exists> + <#assign lockedBy = (item.owner.properties.firstName + " " + item.owner.properties.lastName)?trim> + <#assign lockedByUser = item.owner.properties.userName> + <#else> + <#assign lockedBy="" lockedByUser=""> + + <#if item.createdBy?exists> + <#assign createdBy = (item.createdBy.properties.firstName + " " + item.createdBy.properties.lastName)?trim> + <#assign createdByUser = item.createdBy.properties.userName> + <#else> + <#assign createdBy="" createdByUser=""> + + <#if item.modifiedBy?exists> + <#assign modifiedBy = (item.modifiedBy.properties.firstName + " " + item.modifiedBy.properties.lastName)?trim> + <#assign modifiedByUser = item.modifiedBy.properties.userName> + <#else> + <#assign modifiedBy="" modifiedByUser=""> + { "index": ${item_index}, "nodeRef": "${d.nodeRef}", @@ -18,13 +36,16 @@ "fileName": "${d.name?html}", "displayName": "${d.name?replace(workingCopyLabel, "")?html}", "status": "<#list item.status as s>${s}<#if s_has_next>,", - "lockedBy": "${item.owner}", + "lockedBy": "${lockedBy}", + "lockedByUser": "${lockedByUser}", "title": "${(d.properties.title!"")?html}", "description": "${(d.properties.description!"")?html}", "createdOn": "${d.properties.created?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", - "createdBy": "${d.properties.creator}", + "createdBy": "${createdBy}", + "createdByUser": "${createdByUser}", "modifiedOn": "${d.properties.modified?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", - "modifiedBy": "${d.properties.modifier}", + "modifiedBy": "${modifiedBy}", + "modifiedByUser": "${modifiedByUser}", "size": "${d.size}", "version": "${version}", "contentUrl": "api/node/content/${d.storeType}/${d.storeId}/${d.id}/${d.name?url}", diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.rss.ftl b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.rss.ftl index 7bd8d48bc3..9e13b1c8b9 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.rss.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.rss.ftl @@ -9,7 +9,7 @@ Alfresco ${server.edition} v${server.version} Alfresco - My Documents - ${absurl(url.context)?replace("alfresco", "slingshot/proxy/alfresco")}/images/logo/AlfrescoLogo200.png + ${absurl(url.context)?replace("alfresco", "share/proxy/alfresco")}/images/logo/AlfrescoLogo200.png <#list doclist.items as item> <#assign d = item.asset> @@ -19,12 +19,12 @@ ${d.name?html} <#assign navurl='/navigate/showDocDetails/' + d.nodeRef.storeRef.protocol + '/' + d.nodeRef.storeRef.identifier + '/' + d.nodeRef.id> - ${absurl(url.context)?replace("alfresco", "slingshot/proxy/alfresco")}/api/node/content/${d.storeType}/${d.storeId}/${d.id}/${d.name?url} + ${absurl(url.context)?replace("alfresco", "share/proxy/alfresco")}/api/node/content/${d.storeType}/${d.storeId}/${d.id}/${d.name?url} <#if isMP3> - <#if isImage || true><img src="${absurl(url.context)?replace("alfresco", "slingshot/proxy/alfresco")}/api/node/content/${d.storeType}/${d.storeId}/${d.id}/${d.name?url}"><br/> + <#if isImage || true><img src="${absurl(url.context)?replace("alfresco", "share/proxy/alfresco")}/api/node/content/${d.storeType}/${d.storeId}/${d.id}/${d.name?url}"><br/> <#if d.properties.description?exists>${d.properties.description?html} ${xmldate(d.properties.modified)} diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/parse-args.lib.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/parse-args.lib.js index 01ccf0bf82..fdf9810272 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/parse-args.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/parse-args.lib.js @@ -10,12 +10,24 @@ function getParsedArgs() var storeId = url.templateArgs.store_id; var id = url.templateArgs.id; var nodeRef = storeType + "://" + storeId + "/" + id; - rootNode = search.findNode(nodeRef); - if (rootNode === null) - { - status.setCode(status.STATUS_NOT_FOUND, "Not a valid nodeRef: '" + nodeRef + "'"); - return null; - } + + if (nodeRef == "alfresco://company/home") + { + rootNode = companyhome; + } + else if (nodeRef == "alfresco://user/home") + { + rootNode = userhome; + } + else + { + rootNode = search.findNode(nodeRef); + if (rootNode === null) + { + status.setCode(status.STATUS_NOT_FOUND, "Not a valid nodeRef: '" + nodeRef + "'"); + return null; + } + } } else {