mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
CMIS Allowable Actions REST binding (part 1)
- add getAllowableActions() - update getProperties(), getChildren() with includeAllowableActions flag - testAllowableActions() TODO: - add includeAllowableActions flag for all other required methods - Abdera extension to parse allowable actions git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13834 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
[#-- ATOM Entry for Document --]
|
||||
[#-- --]
|
||||
|
||||
[#macro document node propfilter="*" ns=""]
|
||||
[#macro document node propfilter="*" includeallowableactions=false includerelationships="none" ns=""]
|
||||
[@entry ns]
|
||||
<author><name>${node.properties.creator!""}</name></author>
|
||||
[@contentstream node/]
|
||||
@@ -31,6 +31,7 @@
|
||||
<updated>${xmldate(node.properties.modified)}</updated>
|
||||
<cmis:object>
|
||||
[@documentCMISProps node propfilter/]
|
||||
[#if includeallowableactions][@allowableactions node/][/#if]
|
||||
</cmis:object>
|
||||
<cmis:terminator/>
|
||||
<app:edited>${xmldate(node.properties.modified)}</app:edited>
|
||||
@@ -93,7 +94,7 @@
|
||||
[#-- ATOM Entry for Private Working Copy --]
|
||||
[#-- --]
|
||||
|
||||
[#macro pwc node propfilter="*" ns=""]
|
||||
[#macro pwc node propfilter="*" includeallowableactions=false includerelationships="none" ns=""]
|
||||
[@entry ns]
|
||||
<author><name>${node.properties.creator}</name></author>
|
||||
[@contentstream node/]
|
||||
@@ -123,7 +124,7 @@
|
||||
[#-- ATOM Entry for Folder --]
|
||||
[#-- --]
|
||||
|
||||
[#macro folder node propfilter="*" typesfilter="any" ns="" depth=1 maxdepth=1]
|
||||
[#macro folder node propfilter="*" typesfilter="any" includeallowableactions=false includerelationships="none" ns="" depth=1 maxdepth=1]
|
||||
[@entry ns]
|
||||
<author><name>${node.properties.creator}</name></author>
|
||||
<content>${node.id}</content> [#-- TODO --]
|
||||
@@ -138,14 +139,15 @@
|
||||
<cmis:object>
|
||||
[#-- recurse for depth greater than 1 --]
|
||||
[@folderCMISProps node propfilter/]
|
||||
[#if includeallowableactions][@allowableactions node/][/#if]
|
||||
</cmis:object>
|
||||
[#if depth < maxdepth || depth == -1]
|
||||
[#list cmischildren(node, typesfilter) as child]
|
||||
[#if child.isDocument]
|
||||
[@entryLib.document child propfilter/]
|
||||
[@entryLib.document child propfilter includeallowableactions includerelationships/]
|
||||
[#else]
|
||||
[@entryLib.folder child propfilter/]
|
||||
[@folder child propfilter typesfilter ns depth+1 maxdepth/]
|
||||
[@entryLib.folder child propfilter includeallowableactions includerelationships/]
|
||||
[@folder child propfilter typesfilter includeallowableactions includerelationships ns depth+1 maxdepth/]
|
||||
[/#if]
|
||||
[/#list]
|
||||
[/#if]
|
||||
@@ -304,6 +306,25 @@
|
||||
[#macro idvalue value]<cmis:value>${value}</cmis:value>[/#macro]
|
||||
|
||||
|
||||
[#-- --]
|
||||
[#-- CMIS Allowable Actions --]
|
||||
[#-- --]
|
||||
|
||||
[#macro allowableactions node ns=""]
|
||||
<cmis:allowableActions[#if ns != ""] ${ns}[/#if]>
|
||||
[#nested]
|
||||
[#assign typedef = cmistype(node)]
|
||||
[#list typedef.actionEvaluators?values as actionevaluator]
|
||||
[@allowableaction node actionevaluator/]
|
||||
[/#list]
|
||||
</cmis:allowableActions>
|
||||
[/#macro]
|
||||
|
||||
[#macro allowableaction node actionevaluator]
|
||||
<cmis:${actionevaluator.action.label}>${actionevaluator.isAllowed(node.nodeRef)?string}</cmis:${actionevaluator.action.label}>
|
||||
[/#macro]
|
||||
|
||||
|
||||
[#-- --]
|
||||
[#-- ATOM Entry for Type Definition --]
|
||||
[#-- --]
|
||||
|
@@ -6,4 +6,5 @@
|
||||
[#macro opensearchNS]http://a9.com/-/spec/opensearch/1.1/[/#macro]
|
||||
[#macro serviceNS]xmlns="[@appNS/]" xmlns:atom="[@atomNS/]" xmlns:cmis="[@cmisNS/]" xmlns:alf="[@alfNS/]"[/#macro]
|
||||
[#macro feedNS]xmlns="[@atomNS/]" xmlns:app="[@appNS/]" xmlns:cmis="[@cmisNS/]" xmlns:alf="[@alfNS/]" xmlns:opensearch="[@opensearchNS/]"[/#macro]
|
||||
[#macro entryNS]xmlns="[@atomNS/]" xmlns:app="[@appNS/]" xmlns:cmis="[@cmisNS/]" xmlns:alf="[@alfNS/]"[/#macro]
|
||||
[#macro entryNS]xmlns="[@atomNS/]" xmlns:app="[@appNS/]" xmlns:cmis="[@cmisNS/]" xmlns:alf="[@alfNS/]"[/#macro]
|
||||
[#macro allowableactionsNS]xmlns:cmis="[@cmisNS/]"[/#macro]
|
@@ -0,0 +1,13 @@
|
||||
[#ftl]
|
||||
[#import "/org/alfresco/cmis/ns.lib.atom.ftl" as nsLib/]
|
||||
[#import "/org/alfresco/cmis/atomentry.lib.atom.ftl" as entryLib/]
|
||||
[#compress]
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
[#assign namespace][@nsLib.allowableactionsNS/][/#assign]
|
||||
[@entryLib.allowableactions node=node ns=namespace]
|
||||
<cmis:parentId>${cmisproperty(node, "ObjectId")}</cmis:parentId>
|
||||
<cmis:parentUrl>${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}</cmis:parentUrl>
|
||||
[/@entryLib.allowableactions]
|
||||
|
||||
[/#compress]
|
@@ -0,0 +1,9 @@
|
||||
<webscript>
|
||||
<shortname>Retrieve Allowable Actions</shortname>
|
||||
<description>Retrieve Allowable Actions</description>
|
||||
<url>/api/node/{store_type}/{store_id}/{id}/permissions</url>
|
||||
<url>/api/path/{store_type}/{store_id}/{id}/permissions</url>
|
||||
<authentication>guest</authentication>
|
||||
<format default="atomentry">argument</format>
|
||||
<family>CMIS</family>
|
||||
</webscript>
|
@@ -0,0 +1,17 @@
|
||||
script:
|
||||
{
|
||||
// locate node
|
||||
var pathSegments = url.match.split("/");
|
||||
var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/"));
|
||||
model.node = cmis.findNode(pathSegments[2], reference);
|
||||
if (model.node === null)
|
||||
{
|
||||
status.code = 404;
|
||||
status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found";
|
||||
status.redirect = true;
|
||||
break script;
|
||||
}
|
||||
|
||||
// TODO: handle version??
|
||||
|
||||
}
|
@@ -14,7 +14,7 @@
|
||||
|
||||
[#list results as child]
|
||||
[#if child.isDocument]
|
||||
[@entryLib.pwc child filter/]
|
||||
[@entryLib.pwc node=child propfilter=filter includeallowableactions=false includerelationships="none"/]
|
||||
[/#if]
|
||||
[/#list]
|
||||
|
||||
|
@@ -5,6 +5,6 @@
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
[#assign namespace][@nsLib.entryNS/][/#assign]
|
||||
[@entryLib.pwc node=pwc ns=namespace/]
|
||||
[@entryLib.pwc node=pwc includeallowableactions=true includerelationships="none" ns=namespace/]
|
||||
|
||||
[/#compress]
|
@@ -14,9 +14,9 @@
|
||||
|
||||
[#list results as child]
|
||||
[#if child.isDocument]
|
||||
[@entryLib.document child filter/]
|
||||
[@entryLib.document node=child propfilter=filter includeallowableactions=includeAllowableActions/]
|
||||
[#else]
|
||||
[@entryLib.folder child filter/]
|
||||
[@entryLib.folder node=child propfilter=filter includeallowableactions=includeAllowableActions/]
|
||||
[/#if]
|
||||
[/#list]
|
||||
|
||||
|
@@ -34,8 +34,8 @@ If “includeAllowableActions” is TRUE, the repository will return the allowab
|
||||
If no “maxItems” value is provided, then the Repository will determine an appropriate number of items to return. How the Repository determines this value is repository-specific and opaque to CMIS.<br>
|
||||
]]>
|
||||
</description>
|
||||
<url>/api/node/{store_type}/{store_id}/{id}/children?types={types}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}</url>
|
||||
<url>/api/path/{store_type}/{store_id}/{id}/children?types={types}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}</url>
|
||||
<url>/api/node/{store_type}/{store_id}/{id}/children?types={types}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?}</url>
|
||||
<url>/api/path/{store_type}/{store_id}/{id}/children?types={types}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?}</url>
|
||||
<authentication>guest</authentication>
|
||||
<format default="atomfeed">argument</format>
|
||||
<family>CMIS</family>
|
||||
|
@@ -29,6 +29,10 @@ script:
|
||||
model.filter = "*";
|
||||
}
|
||||
|
||||
// include allowable actions
|
||||
var includeAllowableActions = cmis.findArg(args.includeAllowableActions, headers["CMIS-includeAllowableActions"]);
|
||||
model.includeAllowableActions = (includeAllowableActions == "true" ? true : false);
|
||||
|
||||
// retrieve children
|
||||
var page = paging.createPageOrWindow(args, headers);
|
||||
var paged = cmis.queryChildren(model.node, model.types, page);
|
||||
|
@@ -7,9 +7,9 @@
|
||||
[#assign namespace][@nsLib.entryNS/][/#assign]
|
||||
|
||||
[#if node.isDocument]
|
||||
[@entryLib.document node=node ns=namespace/]
|
||||
[@entryLib.document node=node propfilter="*" includeallowableactions=true includerelationships=true ns=namespace/]
|
||||
[#else]
|
||||
[@entryLib.folder node=node ns=namespace/]
|
||||
[@entryLib.folder node=node propfilter="*" includeallowableactions=true includerelationships=true ns=namespace/]
|
||||
[/#if]
|
||||
|
||||
[/#compress]
|
@@ -12,9 +12,9 @@
|
||||
[#if depth > 0 || depth == -1]
|
||||
[#list cmischildren(node, typesFilter) as child]
|
||||
[#if child.isDocument]
|
||||
[@entryLib.document node=child propfilter=propFilter/]
|
||||
[@entryLib.document node=child propfilter=propFilter includeallowableactions=false includerelationships=false/]
|
||||
[#else]
|
||||
[@entryLib.folder node=child propfilter=propFilter typesfilter=typeFilter depth=1 maxdepth=depth/]
|
||||
[@entryLib.folder node=child propfilter=propFilter typesfilter=typeFilter includeallowableactions=false includerelationships=false depth=1 maxdepth=depth/]
|
||||
[/#if]
|
||||
[/#list]
|
||||
[/#if]
|
||||
|
@@ -8,9 +8,9 @@
|
||||
[#assign namespace][@nsLib.entryNS/][/#assign]
|
||||
|
||||
[#if node.isDocument]
|
||||
[@entryLib.document node=node ns=namespace/]
|
||||
[@entryLib.document node=node propfilter="*" includeallowableactions=false includerelationships="none" ns=namespace/]
|
||||
[#else]
|
||||
[@entryLib.folder node=node ns=namespace/]
|
||||
[@entryLib.folder node=node propfilter="*" includeallowableactions=false includerelationships="none" ns=namespace/]
|
||||
[/#if]
|
||||
|
||||
[/#compress]
|
@@ -7,9 +7,9 @@
|
||||
[#assign namespace][@nsLib.entryNS/][/#assign]
|
||||
|
||||
[#if node.isDocument]
|
||||
[@entryLib.document node=node propfilter=filter ns=namespace/]
|
||||
[@entryLib.document node=node propfilter=filter includeallowableactions=includeAllowableActions includerelationships="none" ns=namespace/]
|
||||
[#else]
|
||||
[@entryLib.folder node=node propfilter=filter ns=namespace/]
|
||||
[@entryLib.folder node=node propfilter=filter includeallowableactions=includeAllowableActions includerelationships="none" ns=namespace/]
|
||||
[/#if]
|
||||
|
||||
[/#compress]
|
@@ -21,4 +21,7 @@ script:
|
||||
model.filter = "*";
|
||||
}
|
||||
|
||||
// include allowable actions
|
||||
var includeAllowableActions = cmis.findArg(args.includeAllowableActions, headers["CMIS-includeAllowableActions"]);
|
||||
model.includeAllowableActions = (includeAllowableActions == "true" ? true : false);
|
||||
}
|
||||
|
@@ -7,9 +7,9 @@
|
||||
[#assign namespace][@nsLib.entryNS/][/#assign]
|
||||
|
||||
[#if node.isDocument]
|
||||
[@entryLib.document node=node ns=namespace/]
|
||||
[@entryLib.document node=node includeallowableactions=true includerelationships="none" ns=namespace/]
|
||||
[#else]
|
||||
[@entryLib.folder node=node ns=namespace/]
|
||||
[@entryLib.folder node=node includeallowableactions=true includerelationships="none" ns=namespace/]
|
||||
[/#if]
|
||||
|
||||
[/#compress]
|
@@ -18,7 +18,7 @@
|
||||
|
||||
[#macro parent node recurse=false]
|
||||
[#if node?exists && node.isContainer]
|
||||
[@entryLib.folder node filter/]
|
||||
[@entryLib.folder node=node propfilter=filter includeallowableactions=false includerelationships="none"/]
|
||||
[#if recurse && node.id != rootNode.id]
|
||||
[@parent node.parent true/]
|
||||
[/#if]
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
[#macro parent node recurse=false]
|
||||
[#if node?exists && node.isContainer]
|
||||
[@entryLib.folder node filter/]
|
||||
[@entryLib.folder node=node propfilter=filter includeallowableactions=false includerelationships="none"/]
|
||||
[#if recurse && node.id != rootNode.id]
|
||||
[@parent node.parent true/]
|
||||
[/#if]
|
||||
|
@@ -6,6 +6,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
[#assign namespace][@nsLib.entryNS/][/#assign]
|
||||
|
||||
[@entryLib.pwc node=node ns=namespace/]
|
||||
[@entryLib.pwc node=node includeallowableactions=false includerelationships="none" ns=namespace/]
|
||||
|
||||
[/#compress]
|
||||
|
@@ -7,9 +7,9 @@
|
||||
[#assign namespace][@nsLib.entryNS/][/#assign]
|
||||
|
||||
[#if checkin]
|
||||
[@entryLib.document node=node ns=namespace/]
|
||||
[@entryLib.document node=node includeallowableactions=true includerelationships="none" ns=namespace/]
|
||||
[#else]
|
||||
[@entryLib.pwc node=node ns=namespace/]
|
||||
[@entryLib.pwc node=node includeallowableactions=true includerelationships="none" ns=namespace/]
|
||||
[/#if]
|
||||
|
||||
[/#compress]
|
@@ -34,5 +34,5 @@ script:
|
||||
// handle property definitions
|
||||
// TODO: spec issue 34
|
||||
var returnPropertyDefinitions = cmis.findArg(args.includePropertyDefinitions, headers["CMIS-includePropertyDefinitions"]);
|
||||
model.returnPropertyDefinitions = returnPropertyDefinitions == "true" ? true : false;
|
||||
model.returnPropertyDefinitions = (returnPropertyDefinitions == "true" ? true : false);
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
*
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
@@ -554,6 +554,62 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
assertEquals("updated content " + guid, contentRes.getContentAsString());
|
||||
}
|
||||
|
||||
public void testAllowableActions()
|
||||
throws Exception
|
||||
{
|
||||
// retrieve test folder for allowable actions
|
||||
Entry testFolder = createTestFolder("testAllowableActions");
|
||||
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
|
||||
assertNotNull(childrenLink);
|
||||
|
||||
// test allowable actions for folder
|
||||
{
|
||||
Entry child = createFolder(childrenLink.getHref(), "testFolderAllowableActions");
|
||||
assertNotNull(child);
|
||||
Link allowableActions = child.getLink(CMISConstants.REL_ALLOWABLEACTIONS);
|
||||
Response allowableActionsRes = sendRequest(new GetRequest(allowableActions.getHref().toString()), 200, getAtomValidator());
|
||||
assertNotNull(allowableActionsRes);
|
||||
// TODO: parse response with Abdera extension
|
||||
|
||||
// retrieve getProperties() with includeAllowableActions flag
|
||||
Map<String, String> args = new HashMap<String, String>();
|
||||
args.put("includeAllowableActions", "true");
|
||||
Response getPropertiesRes = sendRequest(new GetRequest(child.getSelfLink().getHref().toString()).setArgs(args), 200, getAtomValidator());
|
||||
assertNotNull(getPropertiesRes);
|
||||
// TODO: parse response with Abdera extension
|
||||
|
||||
// TODO: test equality between getAllowableActions and getProperties
|
||||
}
|
||||
|
||||
// test allowable actions for document
|
||||
{
|
||||
Entry child = createDocument(childrenLink.getHref(), "testDocumentAllowableActions");
|
||||
assertNotNull(child);
|
||||
Link allowableActions = child.getLink(CMISConstants.REL_ALLOWABLEACTIONS);
|
||||
Response allowableActionsRes = sendRequest(new GetRequest(allowableActions.getHref().toString()), 200, getAtomValidator());
|
||||
assertNotNull(allowableActionsRes);
|
||||
// TODO: parse response with Abdera extension
|
||||
|
||||
// retrieve getProperties() with includeAllowableActions flag
|
||||
Map<String, String> args = new HashMap<String, String>();
|
||||
args.put("includeAllowableActions", "true");
|
||||
Response getPropertiesRes = sendRequest(new GetRequest(child.getSelfLink().getHref().toString()).setArgs(args), 200, getAtomValidator());
|
||||
assertNotNull(getPropertiesRes);
|
||||
// TODO: parse response with Abdera extension
|
||||
|
||||
// TODO: test equality between getAllowableActions and getProperties
|
||||
}
|
||||
|
||||
// test allowable actions for children
|
||||
{
|
||||
Map<String, String> args = new HashMap<String, String>();
|
||||
args.put("includeAllowableActions", "true");
|
||||
Response allowableActionsRes = sendRequest(new GetRequest(childrenLink.getHref().toString()).setArgs(args), 200, getAtomValidator());
|
||||
assertNotNull(allowableActionsRes);
|
||||
// TODO: parse response with Abdera extension
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetCheckedOut()
|
||||
throws Exception
|
||||
{
|
||||
|
Reference in New Issue
Block a user