mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
DocLib simple metadata editing and tag support.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10047 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
<webscript>
|
||||||
|
<shortname>Node Metadata Storage Service</shortname>
|
||||||
|
<description>Node Metadata Storage Service</description>
|
||||||
|
<url>/api/metadata/node/{store_type}/{store_id}/{id}</url>
|
||||||
|
<format default="json" />
|
||||||
|
<authentication>user</authentication>
|
||||||
|
</webscript>
|
@@ -0,0 +1,69 @@
|
|||||||
|
main();
|
||||||
|
|
||||||
|
function main()
|
||||||
|
{
|
||||||
|
if (url.templateArgs.store_type === null)
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_BAD_REQUEST, "NodeRef missing");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// nodeRef input
|
||||||
|
var storeType = url.templateArgs.store_type;
|
||||||
|
var storeId = url.templateArgs.store_id;
|
||||||
|
var id = url.templateArgs.id;
|
||||||
|
var nodeRef = storeType + "://" + storeId + "/" + id;
|
||||||
|
var node = search.findNode(nodeRef);
|
||||||
|
if (node === null)
|
||||||
|
{
|
||||||
|
status.setCode(status.STATUS_NOT_FOUND, "Not a valid nodeRef: '" + nodeRef + "'");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set passed-in properties
|
||||||
|
if (json.has("properties"))
|
||||||
|
{
|
||||||
|
var properties = jsonToObject("properties");
|
||||||
|
for (property in properties)
|
||||||
|
{
|
||||||
|
node.properties[property] = properties[property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set passed-in tags
|
||||||
|
if (json.has("tags"))
|
||||||
|
{
|
||||||
|
var tags = String(json.get("tags"));
|
||||||
|
if (tags !== "")
|
||||||
|
{
|
||||||
|
var tagsArray = tags.split(" ");
|
||||||
|
node.tags = tagsArray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
function jsonToObject(p_name)
|
||||||
|
{
|
||||||
|
var object = {};
|
||||||
|
var jsonObj = json.get(p_name);
|
||||||
|
var names = jsonObj.names();
|
||||||
|
var name;
|
||||||
|
for (var i = 0, j = names.length(); i < j; i++)
|
||||||
|
{
|
||||||
|
name = names.get(i);
|
||||||
|
object[name] = jsonObj.get(name);
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
function jsonToArray(p_name)
|
||||||
|
{
|
||||||
|
var array = [];
|
||||||
|
var jsonArray = json.get(p_name);
|
||||||
|
for (var i = 0, j = jsonArray.length(); i < j; i++)
|
||||||
|
{
|
||||||
|
array.push(jsonArray.get(i));
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"success": true
|
||||||
|
}
|
@@ -3,7 +3,7 @@ function getActionSet(asset, obj)
|
|||||||
var actionSet = "empty";
|
var actionSet = "empty";
|
||||||
var itemStatus = obj.itemStatus.toString();
|
var itemStatus = obj.itemStatus.toString();
|
||||||
var isItemOwner = null;
|
var isItemOwner = null;
|
||||||
isItemOwner == (obj.itemOwner && obj.itemOwner.properties.userName == person.properties.userName);
|
isItemOwner = (obj.itemOwner && obj.itemOwner.properties.userName == person.properties.userName);
|
||||||
|
|
||||||
// Only 1 action set for folders
|
// Only 1 action set for folders
|
||||||
if (asset.isContainer)
|
if (asset.isContainer)
|
||||||
|
@@ -32,6 +32,14 @@ function getDocList(filter)
|
|||||||
// Default to all children of parentNode
|
// Default to all children of parentNode
|
||||||
assets = parsedArgs.parentNode.children;
|
assets = parsedArgs.parentNode.children;
|
||||||
}
|
}
|
||||||
|
else if (filterQuery == "node")
|
||||||
|
{
|
||||||
|
assets = [parsedArgs.rootNode];
|
||||||
|
}
|
||||||
|
else if (filterQuery == "tag")
|
||||||
|
{
|
||||||
|
assets = parsedArgs.rootNode.childrenByTags(args["filterData"]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Run the query returned from the filter
|
// Run the query returned from the filter
|
||||||
@@ -105,7 +113,8 @@ function getDocList(filter)
|
|||||||
owner: itemOwner,
|
owner: itemOwner,
|
||||||
createdBy: createdBy,
|
createdBy: createdBy,
|
||||||
modifiedBy: modifiedBy,
|
modifiedBy: modifiedBy,
|
||||||
actionSet: actionSet
|
actionSet: actionSet,
|
||||||
|
tags: asset.tags
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
<#else>
|
<#else>
|
||||||
<#assign modifiedBy="" modifiedByUser="">
|
<#assign modifiedBy="" modifiedByUser="">
|
||||||
</#if>
|
</#if>
|
||||||
|
<#assign tags><#list item.tags as tag>"${tag}"<#if tag_has_next>,</#if></#list></#assign>
|
||||||
{
|
{
|
||||||
"index": ${item_index},
|
"index": ${item_index},
|
||||||
"nodeRef": "${d.nodeRef}",
|
"nodeRef": "${d.nodeRef}",
|
||||||
@@ -49,7 +50,8 @@
|
|||||||
"size": "${d.size}",
|
"size": "${d.size}",
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
"contentUrl": "api/node/content/${d.storeType}/${d.storeId}/${d.id}/${d.name?url}",
|
"contentUrl": "api/node/content/${d.storeType}/${d.storeId}/${d.id}/${d.name?url}",
|
||||||
"actionSet": "${item.actionSet}"
|
"actionSet": "${item.actionSet}",
|
||||||
|
"tags": [${tags}]
|
||||||
}<#if item_has_next>,</#if>
|
}<#if item_has_next>,</#if>
|
||||||
</#list>
|
</#list>
|
||||||
]
|
]
|
||||||
|
@@ -4,6 +4,14 @@ function getFilterQuery(filter, obj)
|
|||||||
|
|
||||||
switch (String(filter))
|
switch (String(filter))
|
||||||
{
|
{
|
||||||
|
case "node":
|
||||||
|
filterQuery = "node";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "tag":
|
||||||
|
filterQuery = "tag";
|
||||||
|
break;
|
||||||
|
|
||||||
case "recentlyModified":
|
case "recentlyModified":
|
||||||
var usingModified = true;
|
var usingModified = true;
|
||||||
// fall through...
|
// fall through...
|
||||||
|
Reference in New Issue
Block a user