diff --git a/config/alfresco/templates/webscripts/org/alfresco/cmis/atomentry.lib.atom.ftl b/config/alfresco/templates/webscripts/org/alfresco/cmis/atomentry.lib.atom.ftl index 991e7ba123..4412dde350 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/cmis/atomentry.lib.atom.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/atomentry.lib.atom.ftl @@ -93,7 +93,7 @@ ${node.properties.creator} [@contentstream node/] urn:uuid:${node.id} -[#assign pwcuri]/api/pwc/[@linksLib.noderef node/][/#assign] +[#assign pwcuri]/cmis/pwc/[@linksLib.noderef node/][/#assign] [@linksLib.linkself href="${pwcuri}"/] [@linksLib.linkstream node "enclosure"/] [@linksLib.linknodeedit node/] @@ -204,7 +204,7 @@ [/#macro] [#macro assocCMISLinks assoc] -[#-- TODO: --] +[#-- TODO: --] [@linksLib.linktype assoc/] [@linksLib.linktosource assoc.source/] [@linksLib.linktotarget assoc.target/] diff --git a/config/alfresco/templates/webscripts/org/alfresco/cmis/atomfeed.lib.atom.ftl b/config/alfresco/templates/webscripts/org/alfresco/cmis/atomfeed.lib.atom.ftl index 29a5854c76..772fb13772 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/cmis/atomfeed.lib.atom.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/atomfeed.lib.atom.ftl @@ -21,7 +21,7 @@ ${absurl(url.context)}/images/logo/AlfrescoLogo16.ico ${id} [#nested] [#-- NOTE: Custom links --] -${title} +${title?xml} ${xmldate(date)} [/#macro] @@ -36,6 +36,6 @@ ${absurl(url.context)}/images/logo/AlfrescoLogo16.ico urn:uuid:${node.id}[#if kind != ""]-${kind}[/#if] [#nested] [#-- NOTE: Custom links --] -${node.name}[#if kind != ""] ${kind?capitalize}[/#if] +${node.name?xml}[#if kind != ""] ${kind?capitalize}[/#if] ${xmldate(node.properties.modified)} [/#macro] diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/repository.get.atomsvc.ftl b/config/alfresco/templates/webscripts/org/alfresco/cmis/cmis.get.atomsvc.ftl similarity index 75% rename from config/alfresco/templates/webscripts/org/alfresco/repository/repository.get.atomsvc.ftl rename to config/alfresco/templates/webscripts/org/alfresco/cmis/cmis.get.atomsvc.ftl index 7ffbbeb2cb..1033af48ac 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/repository.get.atomsvc.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/cmis.get.atomsvc.ftl @@ -10,21 +10,21 @@ root collection root - + type collection types - + checkedout collection ${cmisconstants.MIMETYPE_ENTRY} checkedout - + unfiled collection ${cmisconstants.MIMETYPE_ENTRY} unfiled - + query collection ${cmisconstants.MIMETYPE_CMIS_QUERY} query @@ -32,7 +32,7 @@ - + ${server.id} @@ -70,22 +70,23 @@ - ${absurl(url.serviceContext)}/api/node/{id}?filter={filter}&includeAllowableActions={includeAllowableActions}&includePolicyIds={includePolicyIds}&includeRelationships={includeRelationships}&includeACL={includeACL}&renditionFilter={renditionFilter} + ${absurl(url.serviceContext)}/cmis/arg/n?noderef={id}&filter={filter}&includeAllowableActions={includeAllowableActions}&includePolicyIds={includePolicyIds}&includeRelationships={includeRelationships}&includeACL={includeACL}&renditionFilter={renditionFilter} ${cmisconstants.URI_OBJECT_BY_ID} ${cmisconstants.MIMETYPE_ENTRY} - ${absurl(url.serviceContext)}/api/path/{path}?filter={filter}&includeAllowableActions={includeAllowableActions}&includePolicyIds={includePolicyIds}&includeRelationships={includeRelationships}&includeACL={includeACL}&renditionFilter={renditionFilter} + [#-- NOTE: path provided as URL argument for safe handling by URI template generators --] + ${absurl(url.serviceContext)}/cmis/s/${defaultRootFolder.storeType}:${defaultRootFolder.storeId}/arg/p?path={path}&filter={filter}&includeAllowableActions={includeAllowableActions}&includePolicyIds={includePolicyIds}&includeRelationships={includeRelationships}&includeACL={includeACL}&renditionFilter={renditionFilter} ${cmisconstants.URI_OBJECT_BY_PATH} ${cmisconstants.MIMETYPE_ENTRY} - ${absurl(url.serviceContext)}/api/type/{id} + ${absurl(url.serviceContext)}/cmis/type/{id} ${cmisconstants.URI_TYPE_BY_ID} ${cmisconstants.MIMETYPE_ENTRY} - ${absurl(url.serviceContext)}/api/query?q={q}&searchAllVersions={searchAllVersions}&maxItems={maxItems}&skipCount={skipCount}&includeAllowableActions={includeAllowableActions}&includeRelationships={includeRelationships} + ${absurl(url.serviceContext)}/cmis/query?q={q}&searchAllVersions={searchAllVersions}&maxItems={maxItems}&skipCount={skipCount}&includeAllowableActions={includeAllowableActions}&includeRelationships={includeRelationships} ${cmisconstants.URI_QUERY} ${cmisconstants.MIMETYPE_FEED} diff --git a/config/alfresco/templates/webscripts/org/alfresco/cmis/cmis.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/cmis/cmis.get.desc.xml index fee4cd806e..3f4a12782e 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/cmis/cmis.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/cmis.get.desc.xml @@ -1,9 +1,11 @@ - CMIS Front Page + CMIS AtomPub Service Document + /cmis - + + none CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/cmis/cmis.get.js b/config/alfresco/templates/webscripts/org/alfresco/cmis/cmis.get.js index 38312d310a..b132a36176 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/cmis/cmis.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/cmis.get.js @@ -1,7 +1,6 @@ -var tckRunner = Packages.org.apache.chemistry.tck.atompub.tools.TCKRunner(); -model.tckTests = tckRunner.getTestNames(); -model.tckOptions = tckRunner.getOptions(); model.cmisVersion = cmis.version; +model.defaultRootFolder = cmis.defaultRootFolder; +model.defaultRootFolderPath = cmis.defaultRootFolderPath; model.querySupport = cmis.querySupport.label; model.joinSupport = cmis.joinSupport.label; model.pwcSearchable = cmis.pwcSearchable; diff --git a/config/alfresco/templates/webscripts/org/alfresco/cmis/index.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/cmis/index.get.desc.xml new file mode 100644 index 0000000000..1bf5a42d7e --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/index.get.desc.xml @@ -0,0 +1,12 @@ + + CMIS Index Page + + + + /cmis/index + /cmis/index.html + + + none + CMIS + diff --git a/config/alfresco/templates/webscripts/org/alfresco/cmis/index.get.html.ftl b/config/alfresco/templates/webscripts/org/alfresco/cmis/index.get.html.ftl new file mode 100644 index 0000000000..c0f8bd2f2c --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/index.get.html.ftl @@ -0,0 +1,153 @@ +[#ftl] +[#import "/org/alfresco/cmis/links.lib.atom.ftl" as linksLib/] + + + + + + Alfresco CMIS + + + + + + +
+ + +
+
+

Explore and Test CMIS

+

The CMIS (Content Management Interoperability Services) specification is now very close to Public Review.

+

This site hosts a CMIS Repository and CMIS AtomPub TCK to assist the development of the specification and promote interoperability between up-and-coming implementations. Feel free to use them for building and testing your own CMIS clients and servers.

+

Frequent updates are made to both the Repository and TCK as issues are resolved or new capabilities added. Currently, version ${cmisVersion} of the CMIS specification is supported.

+ + +

Alfresco CMIS Repository

+

Point your CMIS client to one of the following Alfresco CMIS bindings (with user=admin and password=admin).

+ + +

You can also browse this repository via the CMIS FileShare browser.

+ +
[+] CMIS Repository Information
+ + + + + + + + + + +
[+] CMIS Repository Capabilities
+ + + + + + + + + + + + + + + + + +

Note: The contents of this repository may be cleaned at any time.

+ + +

CMIS AtomPub TCK

+

Point the TCK (Test Compatibility Kit) at your CMIS Repository AtomPub Service Document. Provide credentials (or leave blank, if authentication not required) and adjust options as necessary. Hit the 'Start TCK' button for a test report.

+

Tip: Enable the 'Trace Reqs/Responses' option for examples of conversations with a CMIS Repository via AtomPub.

+

Note: This TCK is now contributed to Apache Chemistry.

+ +
+
+ CMIS Repository +

+

+

+
+
+ Options +

+

+

+

+

+ + + [#list tckTests as test][/#list] +

+
+

+
+
+ +
+

CMIS Resources

+ +

Alfresco Resources

+ +

Apache Chemistry

+
+

CMIS FileShare

+ +

Provide Feedback

+ +
+
+ + +
+ + + diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/repository.get.js b/config/alfresco/templates/webscripts/org/alfresco/cmis/index.get.js similarity index 57% rename from config/alfresco/templates/webscripts/org/alfresco/repository/repository.get.js rename to config/alfresco/templates/webscripts/org/alfresco/cmis/index.get.js index b132a36176..38312d310a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/repository.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/index.get.js @@ -1,6 +1,7 @@ +var tckRunner = Packages.org.apache.chemistry.tck.atompub.tools.TCKRunner(); +model.tckTests = tckRunner.getTestNames(); +model.tckOptions = tckRunner.getOptions(); model.cmisVersion = cmis.version; -model.defaultRootFolder = cmis.defaultRootFolder; -model.defaultRootFolderPath = cmis.defaultRootFolderPath; model.querySupport = cmis.querySupport.label; model.joinSupport = cmis.joinSupport.label; model.pwcSearchable = cmis.pwcSearchable; diff --git a/config/alfresco/templates/webscripts/org/alfresco/cmis/links.lib.atom.ftl b/config/alfresco/templates/webscripts/org/alfresco/cmis/links.lib.atom.ftl index a30a85e1cc..328d014edb 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/cmis/links.lib.atom.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/links.lib.atom.ftl @@ -6,7 +6,7 @@ [#-- Link to repository service document --] [#macro linkservice] - + [/#macro] [#-- Link to node allowable actions --] @@ -111,7 +111,7 @@ [/#macro] [#macro linkassocedit assoc] - + [/#macro] [#-- Link to via --] @@ -125,19 +125,22 @@ [#-- --] [#-- Helper to render Alfresco service document uri --] -[#macro serviceuri]${absurl(url.serviceContext)}/api/repository[/#macro] +[#macro serviceuri]${absurl(url.serviceContext)}/cmis[/#macro] [#-- Helper to render Alfresco content stream uri --] -[#macro contenturi node]${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/content[#if node.properties.name?? && node.properties.name?last_index_of(".") != -1]${encodeuri(node.properties.name?substring(node.properties.name?last_index_of(".")))}[/#if][/#macro] +[#macro contenturi node]${absurl(url.serviceContext)}/cmis/[@noderef node/]/content[#if node.properties.name?? && node.properties.name?last_index_of(".") != -1]${encodeuri(node.properties.name?substring(node.properties.name?last_index_of(".")))}[/#if][/#macro] + +[#-- Helper to render Store Ref --] +[#macro storeref store]s/${store.protocol}:${store.identifier}[/#macro] [#-- Helper to render Node Ref --] -[#macro noderef node]${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}[/#macro] +[#macro noderef node][@storeref node.nodeRef.storeRef/]/i/${node.nodeRef.id}[/#macro] [#-- Helper to render Alfresco Node uri --] -[#macro nodeuri node]/api/node/[@noderef node/][/#macro] +[#macro nodeuri node]/cmis/[@noderef node/][/#macro] [#-- Helper to render Alfresco Assoc uri --] -[#macro assocuri assoc]/api/rel/[@noderef assoc.source/]/type/${cmistype(assoc).typeId.id!"undefined"}/target/[@noderef assoc.target/][/#macro] +[#macro assocuri assoc]/cmis/rel/[@noderef assoc.source/]/type/${cmistype(assoc).typeId.id!"undefined"}/target/[@noderef assoc.target/][/#macro] [#-- Helper to render Alfresco Type uri --] -[#macro typeuri typedef]/api/type/${typedef.typeId.id}[/#macro] +[#macro typeuri typedef]/cmis/type/${typedef.typeId.id}[/#macro] diff --git a/config/alfresco/templates/webscripts/org/alfresco/cmis/atomentry.lib.js b/config/alfresco/templates/webscripts/org/alfresco/cmis/modify.lib.js similarity index 99% rename from config/alfresco/templates/webscripts/org/alfresco/cmis/atomentry.lib.js rename to config/alfresco/templates/webscripts/org/alfresco/cmis/modify.lib.js index f41497544e..c279058591 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/cmis/atomentry.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/modify.lib.js @@ -23,6 +23,7 @@ function createNode(parent, entry, slug) } // construct node of folder or file + var node = null; var name = (slug !== null) ? slug : entry.title; var baseType = type.typeId.baseTypeId; if (baseType == DOCUMENT_TYPE_ID) diff --git a/config/alfresco/templates/webscripts/org/alfresco/cmis/read.lib.js b/config/alfresco/templates/webscripts/org/alfresco/cmis/read.lib.js new file mode 100644 index 0000000000..c128208e88 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/read.lib.js @@ -0,0 +1,62 @@ +// +// Get Node from URL +// +// @return node (or null, if not found) +function getObjectFromUrl() +{ + var ret = new Object(); + ret.ref = cmis.createObjectReferenceFromUrl(args, url.templateArgs); + if (ret.ref == null) + { + status.setCode(400, "Cannot determine object reference from URL"); + return ret; + } + ret.node = cmis.getNode(ret.ref); + if (ret.node === null) + { + status.setCode(404, "Cannot find object for " + ret.ref.toString()); + } + return ret; +} + +// +// Get Node from Object Id +// +// @return node (or null, if not found) +function getObjectFromObjectId(objectId) +{ + var ret = new Object(); + ret.ref = cmis.createObjectIdReference(objectId); + if (ret.ref == null) + { + status.setCode(400, "Cannot create object id reference from " + objectId); + return ret; + } + ret.node = cmis.getNode(ret.ref); + if (ret.node === null) + { + status.setCode(404, "Cannot find object for " + ret.ref.toString()); + } + return ret; +} + +// +// Get Association from URL +// +// @return association (or null, if not found) +function getAssocFromUrl() +{ + var ret = new Object(); + ret.ref = cmis.createRelationshipReferenceFromUrl(args, url.templateArgs); + if (ret.ref == null) + { + status.setCode(400, "Cannot determine association reference from URL"); + return ret; + } + ret.assoc = cmis.getAssociation(ret.ref); + if (ret.assoc === null) + { + status.setCode(404, "Cannot find association for " + ret.ref.toString()); + } + return ret; +} diff --git a/config/alfresco/templates/webscripts/org/alfresco/cmis/test.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/cmis/test.post.desc.xml index a2c7c97215..28b979e254 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/cmis/test.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/test.post.desc.xml @@ -13,7 +13,7 @@ boolean trace: true => trace request and response bodies String tests: names of tests to execute (use * in test name to represent wildcard) (Default: *)
]]> - /api/cmis/test?url={serviceUrl}&user={user?}&validate={validate?}&trace={trace?}&tests={tests?} + /cmis/test?url={serviceUrl}&user={user?}&validate={validate?}&trace={trace?}&tests={tests?} none CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/repository.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/repository.get.desc.xml deleted file mode 100644 index 77a926685b..0000000000 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/repository.get.desc.xml +++ /dev/null @@ -1,39 +0,0 @@ - - Repository AtomPub Service Document (getRepositoryInfo) - - -
-Outputs:
-
-ID repositoryId: Repository Id (same as input)
-String repositoryName: Repository name
-URI repositoryURI: URI for this repository
-String repositoryDescription: Description of this repository
-ID rootFolderId: Root folder Id
-String vendorName: Repository vendor name
-String productName: Repository product name
-String productVersion: Product Version Information
-String cmisVersionsSupported: Version of CMIS standard supported.
-XML repositorySpecificInformation: Repository-specific information
-
-Capabilities:
-
-boolean capabilityMultifiling
-boolean capabilitiyUnfiling
-Boolean capabilityVersionSpecificFiling
-Boolean capabilityPWCUpdatable
-Boolean capabilityAllVersionsSearchable
-Boolean capabilityPWCSearchable
-Enum capabilityJoin: nojoin, inneronly, innerAndouter
-Enum capabilityFulltext: nofulltext, fulltextonly, fulltextandstructured
-<Array> relatedRepositories -]]> -
- /api/repository - /api/cmis - - user - CMIS -
\ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/search/queries.post.cmisquery.js b/config/alfresco/templates/webscripts/org/alfresco/repository/search/queries.post.cmisquery.js index 05654832aa..4791856426 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/search/queries.post.cmisquery.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/search/queries.post.cmisquery.js @@ -66,7 +66,7 @@ script: } // construct query uri - model.queryUri = "/api/query"; + model.queryUri = "/cmis/query"; model.queryArgs = cmis.ARG_QUERY_STATEMENT + "=" + model.statement; if (model.includeAllowableActions) model.queryArgs += "&" + cmis.ARG_INCLUDE_ALLOWABLE_ACTIONS + "=true"; model.queryArgs += "&" + cmis.ARG_SKIP_COUNT + "=" + page.number; diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/search/queries.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/search/queries.post.desc.xml index 5daab9e35e..babc656d91 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/search/queries.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/search/queries.post.desc.xml @@ -29,7 +29,7 @@ It is recommended that “includeAllowableActions” be used with query statemen "IncludeRelationships" indicates whether relationships are also returned for each returned object. If it is set to "source" or "target", relationships for which the returned object is a source, or respectively a target, will also be returned. If it is set to "both", relationships for which the returned object is either a source or a target will be returned. If it is set to "none", relationships are not returned.
]]> - /api/queries + /cmis/queries user diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/search/query.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/search/query.get.desc.xml index 7c313f8e13..e680414263 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/search/query.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/search/query.get.desc.xml @@ -29,7 +29,7 @@ It is recommended that “includeAllowableActions” be used with query statemen "IncludeRelationships" indicates whether relationships are also returned for each returned object. If it is set to "source" or "target", relationships for which the returned object is a source, or respectively a target, will also be returned. If it is set to "both", relationships for which the returned object is either a source or a target will be returned. If it is set to "none", relationships are not returned.
]]> - /api/query?q={q}&includeAllowableActions={includeAllowableActions?}&searchAllVersions={searchAllVersions?}&skipCount={skipCount?}&maxItems={maxItems?} + /cmis/query?q={q}&includeAllowableActions={includeAllowableActions?}&searchAllVersions={searchAllVersions?}&skipCount={skipCount?}&maxItems={maxItems?} user diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/allowableactions.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/allowableactions.get.desc.xml index a61cc79535..379c5c441c 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/allowableactions.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/allowableactions.get.desc.xml @@ -1,8 +1,15 @@ Retrieve Allowable Actions Retrieve Allowable Actions + + /cmis/i/{id}/allowableactions + /cmis/s/{store}/i/{id}/allowableactions + + /cmis/p{path}/allowableactions + /cmis/s/{store}/p{path}/allowableactions + /api/node/{store_type}/{store_id}/{id}/allowableactions - /api/path/{store_type}/{store_id}/{id}/allowableactions + /api/path/{store_type}/{store_id}/{path}/allowableactions guest argument diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/allowableactions.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/allowableactions.get.js index bcaf54e27b..bf701d4122 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/allowableactions.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/allowableactions.get.js @@ -1,17 +1,18 @@ + + 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) + var object = getObjectFromUrl(); + if (object.node == null) + { + break script + } + model.node = object.node; + if (model.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } - + // TODO: handle version?? } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.get.desc.xml index a0aa4362eb..5a594752c7 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.get.desc.xml @@ -28,7 +28,7 @@ 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.
]]> - /api/checkedout?folderId={folderId?}&includeDescendants={includeDescendants?}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} + /cmis/checkedout?folderId={folderId?}&includeDescendants={includeDescendants?}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} user diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.get.js index b3201609a7..16d34e283a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.get.js @@ -1,3 +1,5 @@ + + script: { // locate (optional) folder @@ -5,18 +7,16 @@ script: var folderId = args[cmis.ARG_FOLDER_ID]; if (folderId !== null) { - model.folder = cmis.findNode(folderId); - if (model.folder === null) + var folder = getObjectFromObjectId(folderId); + if (folder.node === null) { - status.code = 400; - status.message = "Folder " + folderId + " not found"; - status.redirect = true; break script; } + model.folder = folder.node; if (!model.folder.isContainer) { status.code = 400; - status.message = "Folder id " + folderId + " does not refer to a folder"; + status.message = "Folder id " + folder.ref + " does not refer to a folder"; status.redirect = true; break script; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.post.atomentry.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.post.atomentry.js index 6c703450c7..7ddc5d7573 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.post.atomentry.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.post.atomentry.js @@ -1,3 +1,5 @@ + + script: { // ensure atom entry is posted @@ -21,20 +23,18 @@ script: } // locate node - model.node = cmis.findNode(objectId); - if (model.node === null) + var object = getObjectFromObjectId(objectId); + if (object.node === null) { - status.code = 400; - status.message = "Repository node " + objectId + " not found"; - status.redirect = true; break script; } + model.node = object.node; // ensure node can be checked-out if (!model.node.isDocument) { status.code = 400; - status.message = "Cannot checkout node " + objectId + " as it is not a document"; + status.message = "Cannot checkout node " + object.ref + " as it is not a document"; status.redirect = true; break script; } @@ -43,7 +43,7 @@ script: if (model.node.isLocked || model.node.hasAspect("cm:workingCopy")) { status.code = 400; - status.message = "Cannot checkout node " + objectId + " as it is already checked-out"; + status.message = "Cannot checkout node " + object.ref + " as it is already checked-out"; status.redirect = true; break script; } @@ -61,6 +61,6 @@ script: // setup for 201 Created response // TODO: set Content-Location status.code = 201; - status.location = url.server + url.serviceContext + "/api/pwc/" + model.pwc.nodeRef.storeRef.protocol + "/" + model.pwc.nodeRef.storeRef.identifier + "/" + model.pwc.nodeRef.id; + status.location = url.server + url.serviceContext + "/cmis/pwc/s/" + model.pwc.nodeRef.storeRef.protocol + ":" + model.pwc.nodeRef.storeRef.identifier + "/i/" + model.pwc.nodeRef.id; status.redirect = true; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.post.desc.xml index b29b192672..ec2730c484 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/checkedout.post.desc.xml @@ -23,7 +23,7 @@ CheckOut() on a non-document object will throw OperationNotSupportedException. ]]> - /api/checkedout + /cmis/checkedout user CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.get.desc.xml index f94e72a592..8d654ccc85 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.get.desc.xml @@ -34,8 +34,17 @@ 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.
]]> + + + /cmis/i/{id}/children?types={types}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/i/{id}/children?types={types}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} + + /cmis/p{path}/children?types={types}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/p{path}/children?types={types}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} + /api/node/{store_type}/{store_id}/{id}/children?types={types}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} - /api/path/{store_type}/{store_id}/{id}/children?types={types}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} + /api/path/{store_type}/{store_id}/{path}/children?types={types}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} + guest argument diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.get.js index ffff83afd7..aa12c1ba90 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.get.js @@ -1,17 +1,15 @@ + + 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) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } - + model.node = object.node; + // handle filters model.types = args[cmis.ARG_TYPES] === null ? cmis.defaultTypesFilter : args[cmis.ARG_TYPES]; if (!cmis.isValidTypesFilter(model.types)) diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.post.atom.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.post.atom.js index e6c86f1808..c93357e5b8 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.post.atom.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.post.atom.js @@ -1,5 +1,6 @@ - + + script: { @@ -13,16 +14,12 @@ script: } // locate parent node - var pathSegments = url.match.split("/"); - var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/")); - model.parent = cmis.findNode(pathSegments[2], reference); - if (model.parent === null) + var parent = getObjectFromUrl(); + if (parent.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } + model.parent = parent.node; // is this a create or move? var object = entry.getExtension(atom.names.cmisra_object); @@ -41,40 +38,45 @@ script: } else { + // locate node and its source folder + var object = getObjectFromObjectId(objectId); + if (object.node == null) + { + break script; + } + node = object.node; + // move node var sourceFolderId = args[cmis.ARG_SOURCE_FOLDER_ID]; if (sourceFolderId == null) { status.code = 400; - status.message = "Move of object " + objectId + " requires sourceFolderId argument"; + status.message = "Move of object " + object.ref + " requires sourceFolderId argument"; status.redirect = true; break script; } - // locate node and its source folder - node = search.findNode(objectId); - if (node == null) + var sourceFolderObject = getObjectFromObjectId(sourceFolderId); + if (sourceFolderObject.node == null) { status.code = 400; - status.message = "Object " + objectId + " does not exist"; - status.redirect = true; - break script; - } - sourceFolder = search.findNode(sourceFolderId); - if (sourceFolder == null || !(sourceFolder.nodeRef.equals(node.parent.nodeRef))) - { - status.code = 400; - status.message = "Source Folder " + sourceFolderId + " is not valid for object " + objectId; + break script; + } + if (!sourceFolderObject.node.nodeRef.equals(node.parent.nodeRef)) + { + status.code = 400; + status.message = "Source Folder " + sourceFolderObject.ref + " is not parent of object " + object.ref; status.redirect = true; break script; } + var sourceFolder = sourceFolderObject.node; // perform move var success = node.move(model.parent); if (!success) { status.code = 500; - status.message = "Failed to move object " + objectId + " from folder " + sourceFolderId + " to folder " + model.parent.nodeRef; + status.message = "Failed to move object " + object.ref + " from folder " + sourceFolderObject.ref + " to folder " + parent.ref; status.redirect = true; break script; } @@ -85,6 +87,6 @@ script: model.node = node; // TODO: set Content-Location status.code = 201; - status.location = url.server + url.serviceContext + "/api/node/" + node.nodeRef.storeRef.protocol + "/" + node.nodeRef.storeRef.identifier + "/" + node.nodeRef.id; + status.location = url.server + url.serviceContext + "/cmis/s/" + node.nodeRef.storeRef.protocol + ":" + node.nodeRef.storeRef.identifier + "/i/" + node.nodeRef.id; status.redirect = true; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.post.desc.xml index a65414ce30..a3974c64db 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.post.desc.xml @@ -41,8 +41,16 @@ If the to-be-created Folder’s Object Type is not one of the “Allowed_Child_O Root folder can not be created using this service.
]]> + + /cmis/i/{id}/children?sourceFolderId={sourceFolderId} + /cmis/s/{store}/i/{id}/children?sourceFolderId={sourceFolderId} + + /cmis/p{path}/children?sourceFolderId={sourceFolderId} + /cmis/s/{store}/p{path}/children?sourceFolderId={sourceFolderId} + /api/node/{store_type}/{store_id}/{id}/children?sourceFolderId={sourceFolderId} - /api/path/{store_type}/{store_id}/{id}/children?sourceFolderId={sourceFolderId} + /api/path/{store_type}/{store_id}/{path}/children?sourceFolderId={sourceFolderId} + user CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.delete.desc.xml index d23b64788a..76ce58fb35 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.delete.desc.xml @@ -2,11 +2,20 @@ Content Delete (deleteContent) + + + /cmis/i/{id}/content{property} + /cmis/s/{store}/i/{id}/content{property} + + /cmis/p{path}/content{property} + /cmis/s/{store}/p{path}/content{property} + /api/node/content{property}/{store_type}/{store_id}/{id} /api/path/content{property}/{store_type}/{store_id}/{id} /api/avmpath/content{property}/{store_id}/{id} /api/node/{store_type}/{store_id}/{id}/content{property} /api/path/{store_type}/{store_id}/{id}/content{property} + guest argument CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.delete.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.delete.js index 49f3ccde1c..fb13208569 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.delete.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.delete.js @@ -1,16 +1,14 @@ + + script: { // locate node - var pathSegments = url.match.split("/"); - var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/")); - var node = cmis.findNode(pathSegments[2], reference); - if (node === null) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } + node = object.node; if (!node.hasPermission("Delete")) { diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.get.desc.xml index 281e93cacc..4e02128234 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.get.desc.xml @@ -20,11 +20,21 @@ Some CMIS protocol bindings MAY choose not to explicitly implement a “getConte Each CMIS protocol binding will provide a way for fetching a sub-range within a content stream, in a manner appropriate to that protocol.
]]> + + + /cmis/i/{id}/content{property}?a={attach?} + /cmis/s/{store}/i/{id}/content{property}?a={attach?} + + /cmis/p{path}/content{property}?a={attach?} + /cmis/s/{store}/p{path}/content{property}?a={attach?} + + /api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?} - /api/path/content{property}/{store_type}/{store_id}/{id}?a={attach?} - /api/avmpath/content{property}/{store_id}/{id}?a={attach?} + /api/path/content{property}/{store_type}/{store_id}/{path}?a={attach?} + /api/avmpath/content{property}/{store_id}/{avmpath}?a={attach?} /api/node/{store_type}/{store_id}/{id}/content{property}?a={attach?} - /api/path/{store_type}/{store_id}/{id}/content{property}?a={attach?} + /api/path/{store_type}/{store_id}/{path}/content{property}?a={attach?} + guest argument diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.put.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.put.desc.xml index d56ee9042b..856a364b3b 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.put.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/content.put.desc.xml @@ -1,11 +1,21 @@ Content Write (setContent) TODO + + + /cmis/i/{id}/content{property}?overwriteFlag={overwriteFlag?} + /cmis/s/{store}/i/{id}/content{property}?overwriteFlag={overwriteFlag?} + + /cmis/p{path}/content{property}?overwriteFlag={overwriteFlag?} + /cmis/s/{store}/p{path}/content{property}?overwriteFlag={overwriteFlag?} + + /api/node/content{property}/{store_type}/{store_id}/{id}?overwriteFlag={overwriteFlag?} /api/path/content{property}/{store_type}/{store_id}/{id}?overwriteFlag={overwriteFlag?} /api/avmpath/content{property}/{store_id}/{id}?overwriteFlag={overwriteFlag?} /api/node/{store_type}/{store_id}/{id}/content{property}?overwriteFlag={overwriteFlag?} /api/path/{store_type}/{store_id}/{id}/content{property}?overwriteFlag={overwriteFlag?} + guest argument CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.delete.desc.xml index 1846721082..433a70b275 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.delete.desc.xml @@ -29,8 +29,17 @@ Does not specify the order in which delete will happen
o However, any objects that are not deleted (e.g. because a previous object failed to delete), they MUST remain valid CMIS objects (including any applicable filing constraint for each object).
]]> + + + /cmis/i/{id}/descendants?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} + /cmis/s/{store}/i/{id}/descendants?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} + + /cmis/p{path}/descendants?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} + /cmis/s/{store}/p{path}/descendants?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} + /api/node/{store_type}/{store_id}/{id}/descendants?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} - /api/path/{store_type}/{store_id}/{id}/descendants?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} + /api/path/{store_type}/{store_id}/{path}/descendants?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} + user CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.delete.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.delete.js index 4422fb1862..319b02594a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.delete.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.delete.js @@ -1,16 +1,14 @@ + + script: { // locate node - var pathSegments = url.match.split("/"); - var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/")); - var node = cmis.findNode(pathSegments[2], reference); - if (node === null) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } + var node = object.node; // NOTE: Ignore continueOnDelete as complete tree is deleted in single transaction // TODO: Throw error on invalid unfileMultiFiledDocuments error @@ -28,7 +26,7 @@ script: if (!node.remove()) { status.code = 500; - status.message = "Failed to delete node " + pathSegments[2] + " " + reference.join("/"); + status.message = "Failed to delete object " + object.ref; status.redirect = true; break script; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.desc.xml index 20dad2939f..a1fa35571e 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.desc.xml @@ -32,8 +32,17 @@ When returning the results of a call where the caller specified “Any” type, If “includeAllowableActions” is TRUE, the repository will return the allowable actions for the current user for each descendant object as part of the output.
"IncludeRelationships" indicates whether relationships are also returned for each returned object. If it is set to "source" or "target", relationships for which the returned object is a source, or respectively a target, will also be returned. If it is set to "both", relationships for which the returned object is either a source or a target will be returned. If it is set to "none", relationships are not returned.]]> + + + /cmis/i/{id}/descendants?types={types}&filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/i/{id}/descendants?types={types}&filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} + + /cmis/p{path}/descendants?types={types}&filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/p{path}/descendants?types={types}&filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} + /api/node/{store_type}/{store_id}/{id}/descendants?types={types}&filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} - /api/path/{store_type}/{store_id}/{id}/descendants?types={types}&filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} + /api/path/{store_type}/{store_id}/{path}/descendants?types={types}&filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} + guest argument diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.js index 0bcd370577..48d5cb66d7 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.js @@ -1,17 +1,14 @@ + + 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) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } - + model.node = object.node; + // handle filters model.types = args[cmis.ARG_TYPES] === null ? cmis.defaultTypesFilter : args[ARG_TYPES]; if (!cmis.isValidTypesFilter(model.types)) diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.delete.desc.xml index 55c6561922..3237275238 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.delete.desc.xml @@ -17,8 +17,17 @@ This service deletes a specific version of a document object. To delete all ver Deletion of a private working copy (checked out version) is the same as to cancel checkout.
]]> + + + /cmis/i/{id}?includeChildren={includeChildren?} + /cmis/s/{store}/i/{id}?includeChildren={includeChildren?} + + /cmis/p{path}?includeChildren={includeChildren?} + /cmis/s/{store}/p{path}?includeChildren={includeChildren?} + /api/node/{store_type}/{store_id}/{id}?includeChildren={includeChildren?} - /api/path/{store_type}/{store_id}/{id}?includeChildren={includeChildren?} + /api/path/{store_type}/{store_id}/{path}?includeChildren={includeChildren?} + user CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.delete.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.delete.js index 49f3ccde1c..e6427fdcdf 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.delete.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.delete.js @@ -1,21 +1,19 @@ + + script: { // locate node - var pathSegments = url.match.split("/"); - var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/")); - var node = cmis.findNode(pathSegments[2], reference); - if (node === null) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } + var node = object.node; if (!node.hasPermission("Delete")) { status.code = 403; - status.message = "Permission to delete is denied"; + status.message = "Permission to delete object " + object.ref + " is denied"; status.redirect = true; break script; } @@ -28,7 +26,7 @@ script: if (node.children.length > 0 && !args.includeChildren) { status.code = 403; - status.message = "Cannot delete folder " + pathSegments[2] + " " + reference.join("/") + " as it's not empty"; + status.message = "Cannot delete folder " + object.ref + " as it's not empty"; status.redirect = true; break script; } @@ -38,7 +36,7 @@ script: if (!node.remove()) { status.code = 500; - status.message = "Failed to delete node " + pathSegments[2] + " " + reference.join("/"); + status.message = "Failed to delete object " + object.ref; status.redirect = true; break script; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.get.desc.xml index fa98fc1f00..9d028cf211 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.get.desc.xml @@ -26,9 +26,23 @@ PropertyCollection includes changeToken (if applicable to repository)
]]> + + + /cmis/i/{id}?filter={filter?}&returnVersion={returnVersion?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/i/{id}?filter={filter?}&returnVersion={returnVersion?}&includeAllowableActions={includeAllowableActions?} + + /cmis/p{path}?filter={filter?}&returnVersion={returnVersion?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/p{path}?filter={filter?}&returnVersion={returnVersion?}&includeAllowableActions={includeAllowableActions?} + + + /cmis/s/{store}/arg/i?id={id}&filter={filter?}&returnVersion={returnVersion?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/arg/p?path={path}&filter={filter?}&returnVersion={returnVersion?}&includeAllowableActions={includeAllowableActions?} + /cmis/arg/n?noderef={noderef}&filter={filter?}&returnVersion={returnVersion?}&includeAllowableActions={includeAllowableActions?} + + /api/node/{store_type}/{store_id}/{id}?filter={filter?}&returnVersion={returnVersion?}&includeAllowableActions={includeAllowableActions?} - /api/path/{store_type}/{store_id}/{id}?filter={filter?}&returnVersion={returnVersion?}&includeAllowableActions={includeAllowableActions?} - + /api/path/{store_type}/{store_id}/{path}?filter={filter?}&returnVersion={returnVersion?}&includeAllowableActions={includeAllowableActions?} + guest argument diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.get.js index 431a0e8d07..f841737245 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.get.js @@ -1,22 +1,19 @@ + + 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) + var object = getObjectFromUrl(); + if (object.node === null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } + model.node = object.node; // TODO: handle version?? // property filter model.filter = args[cmis.ARG_FILTER]; - if (model.filter === null) + if (model.filter === null || model.filter == "") { model.filter = "*"; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.patch.atom.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.patch.atom.js index 643d5f9c38..774cea49b1 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.patch.atom.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.patch.atom.js @@ -1,5 +1,6 @@ - + + script: { @@ -13,16 +14,12 @@ 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) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } + model.node = object.node; // update properties var updated = updateNode(model.node, entry, null, function(propDef) {return patchValidator(propDef, false);}); diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.patch.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.patch.desc.xml index 7a986afb29..391fa481a3 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.patch.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.patch.desc.xml @@ -27,8 +27,17 @@ If this is a private working copy, some repositories may not support updates.
]]> + + + /cmis/i/{id} + /cmis/s/{store}/i/{id} + + /cmis/p{path} + /cmis/s/{store}/p{path} + /api/node/{store_type}/{store_id}/{id} - /api/path/{store_type}/{store_id}/{id} + /api/path/{store_type}/{store_id}/{path} + user argument CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.atom.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.atom.js index aaecfcd3e3..903a7a7ed3 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.atom.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.atom.js @@ -1,5 +1,6 @@ - + + script: { @@ -13,16 +14,12 @@ 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) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } + model.node = object.node; // update properties var updated = updateNode(model.node, entry, null, function(propDef) {return putValidator(propDef, false);}); diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.desc.xml index 7a986afb29..f36beb2cef 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.desc.xml @@ -27,8 +27,17 @@ If this is a private working copy, some repositories may not support updates.
]]> + + + /cmis/i/{id} + /cmis/s/{store}/i/{id} + + /cmis/p{path} + /cmis/s/{store}/p{path} + /api/node/{store_type}/{store_id}/{id} - /api/path/{store_type}/{store_id}/{id} + /api/path/{store_type}/{store_id}/{path} + user argument CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/parent.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/parent.get.desc.xml index 3314a8ec81..76907692e0 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/parent.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/parent.get.desc.xml @@ -2,8 +2,17 @@ Retrieve Parent Folder (getFolderParent) + + + /cmis/i/{id}/parent?filter={filter?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/i/{id}/parent?filter={filter?}&includeAllowableActions={includeAllowableActions?} + + /cmis/p{path}/parent?filter={filter?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/p{path}/parent?filter={filter?}&includeAllowableActions={includeAllowableActions?} + /api/node/{store_type}/{store_id}/{id}/parent?filter={filter?}&includeAllowableActions={includeAllowableActions?} - /api/path/{store_type}/{store_id}/{id}/parent?filter={filter?}&includeAllowableActions={includeAllowableActions?} + /api/path/{store_type}/{store_id}/{path}/parent?filter={filter?}&includeAllowableActions={includeAllowableActions?} + guest argument diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/parent.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/parent.get.js index 4d3da3d26f..e359cff894 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/parent.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/parent.get.js @@ -1,22 +1,20 @@ + + script: { // locate node - var pathSegments = url.match.split("/"); - var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/")); - var node = cmis.findNode(pathSegments[2], reference); - if (node === null) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } - + var node = object.node; + // locate parent if (node.id == cmis.defaultRootFolder.id) { status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " parent not found"; + status.message = "Object " + object.ref + " parent not found"; status.redirect = true; break script; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/parents.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/parents.get.desc.xml index 6403c55b84..954dbc7a38 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/parents.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/parents.get.desc.xml @@ -23,8 +23,17 @@ If “includeAllowableActions” is TRUE, the repository will return the allowab "IncludeRelationships" indicates whether relationships are also returned for each returned object. If it is set to "source" or "target", relationships for which the returned object is a source, or respectively a target, will also be returned. If it is set to "both", relationships for which the returned object is either a source or a target will be returned. If it is set to "none", relationships are not returned.
]]> + + + /cmis/i/{id}/parents?filter={filter?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/i/{id}/parents?filter={filter?}&includeAllowableActions={includeAllowableActions?} + + /cmis/p{path}/parents?filter={filter?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/p{path}/parents?filter={filter?}&includeAllowableActions={includeAllowableActions?} + /api/node/{store_type}/{store_id}/{id}/parents?filter={filter?}&includeAllowableActions={includeAllowableActions?} - /api/path/{store_type}/{store_id}/{id}/parents?filter={filter?}&includeAllowableActions={includeAllowableActions?} + /api/path/{store_type}/{store_id}/{path}/parents?filter={filter?}&includeAllowableActions={includeAllowableActions?} + guest argument diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/parents.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/parents.get.js index d7375179b7..bba1975836 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/parents.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/parents.get.js @@ -1,20 +1,15 @@ + + script: { - // locate node - var pathSegments = url.match.split("/"); - var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/")); - var node = cmis.findNode(pathSegments[2], reference); - if (node === null) + // locate node and parent + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } - - // locate parent - model.node = node; - model.parent = node.parent; + model.node = object.node; + model.parent = model.node.parent; // property filter model.filter = args[cmis.ARG_FILTER]; diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.delete.desc.xml index cadcf45f63..a2cd3b47ea 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.delete.desc.xml @@ -14,7 +14,11 @@ It is repository specific on who can cancel a checkout (user, admin, larger grou Throws OperationNotSupportedException if the object is not checked out
]]> - /api/pwc/{store_type}/{store_id}/{id} + + + /cmis/pwc/i/{id} + /cmis/pwc/s/{store}/i/{id} + user CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.delete.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.delete.js index 10dbba3a6b..5a1d47cddf 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.delete.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.delete.js @@ -1,21 +1,18 @@ + + script: { - // locate node - var pathSegments = url.match.split("/"); - var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/")); - var node = cmis.findNode("node", reference); - if (node === null || !node.hasAspect("cm:workingcopy")) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Private working copy " + reference.join("/") + " not found"; - status.redirect = true; break script; } - + var node = object.node; + if (!node.hasPermission("CancelCheckOut")) { status.code = 403; - status.message = "Permission to cancel checkout is denied"; + status.message = "Permission to cancel checkout of " + object.ref + " is denied"; status.redirect = true; break script; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.get.desc.xml index 4f3b020b9d..d689f21453 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.get.desc.xml @@ -1,7 +1,10 @@ Retrieve properties of PWC Retrieves the properties of a private working copy - /api/pwc/{store_type}/{store_id}/{id}?filter={filter?} + + /cmis/pwc/i/{id}?filter={filter?} + /cmis/pwc/s/{store}/i/{id}?filter={filter?} + user argument diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.get.js index dcb7701863..2ced406914 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.get.js @@ -1,17 +1,15 @@ + + 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("node", reference); - if (model.node === null || !model.node.hasAspect("cm:workingcopy")) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Private working copy " + reference.join("/") + " not found"; - status.redirect = true; break script; } - + model.node = object.node; + // TODO: property filters } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.patch.atom.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.patch.atom.js index 85ed1908e4..23f2733ab3 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.patch.atom.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.patch.atom.js @@ -1,26 +1,23 @@ - + + 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("node", reference); - if (model.node === null || !model.node.hasAspect("cm:workingcopy")) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Private working copy " + reference.join("/") + " not found"; - status.redirect = true; break script; } - + model.node = object.node; + // check permissions model.checkin = args[cmis.ARG_CHECKIN] == "true" ? true : false; if (model.checkin && !model.node.hasPermission("CheckIn")) { status.code = 403; - status.message = "Permission to checkin is denied"; + status.message = "Permission to checkin " + object.ref + " is denied"; status.redirect = true; break script; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.patch.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.patch.desc.xml index 9e0543e198..bea40a5347 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.patch.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.patch.desc.xml @@ -25,7 +25,10 @@ If Document is not checked out, throw OperationNotSupportedException.
If the Document has “Content_Stream_Allowed” set to FALSE, and a call is made to checkIn that includes a content-stream, throw ConstraintViolationException.
]]> - /api/pwc/{store_type}/{store_id}/{id}?checkinComment={checkinComment?}&major={major?}&checkin={checkin?} + + /cmis/pwc/i/{id}?checkinComment={checkinComment?}&major={major?}&checkin={checkin?} + /cmis/pwc/s/{store}/i/{id}?checkinComment={checkinComment?}&major={major?}&checkin={checkin?} + user CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.put.atom.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.put.atom.js index 662d93288c..e78e724396 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.put.atom.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.put.atom.js @@ -1,20 +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("node", reference); - if (model.node === null || !model.node.hasAspect("cm:workingcopy")) + var object = getObjectFromUrl(); + if (object.node === null || !object.node.hasAspect("cm:workingcopy")) { - status.code = 404; - status.message = "Private working copy " + reference.join("/") + " not found"; - status.redirect = true; break script; } - + model.node = object.node; + // check permissions model.checkin = args[cmis.ARG_CHECKIN] == "true" ? true : false; if (model.checkin && !model.node.hasPermission("CheckIn")) diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.put.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.put.desc.xml index 9e0543e198..bea40a5347 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.put.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.put.desc.xml @@ -25,7 +25,10 @@ If Document is not checked out, throw OperationNotSupportedException.
If the Document has “Content_Stream_Allowed” set to FALSE, and a call is made to checkIn that includes a content-stream, throw ConstraintViolationException.
]]> - /api/pwc/{store_type}/{store_id}/{id}?checkinComment={checkinComment?}&major={major?}&checkin={checkin?} + + /cmis/pwc/i/{id}?checkinComment={checkinComment?}&major={major?}&checkin={checkin?} + /cmis/pwc/s/{store}/i/{id}?checkinComment={checkinComment?}&major={major?}&checkin={checkin?} + user CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.delete.desc.xml index 89aaafb0c7..9e134b11a5 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.delete.desc.xml @@ -2,7 +2,9 @@ Delete relationship (deleteRelationship) - /api/rel/{store_type}/{store_id}/{id}/type/{rel_type}/target/{target_store_type}/{target_store_id}/{target_id} + + /cmis/rel/s/{store}/i/{id}/type/{rel_type}/target/s/{target_store}/i/{target_id} + user CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.delete.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.delete.js index 978809783a..47a84080df 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.delete.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.delete.js @@ -1,32 +1,14 @@ + script: { - // relationship type - var relType = url.templateArgs.rel_type; - model.relTypeDef = cmis.queryType(relType); - if (model.relTypeDef === null) + var rel = getAssocFromUrl(); + if (rel.assoc == null) { - status.setCode(400, "Relationship type " + relType + " unknown"); - break script; - } - if (model.relTypeDef.baseType.typeId != RELATIONSHIP_TYPE_ID) - { - status.setCode(400, "Type + " + relType + " is not a relationship type"); - break script; - } - - // source and target - var source = [url.templateArgs.store_type, url.templateArgs.store_id, url.templateArgs.id]; - var target = [url.templateArgs.target_store_type, url.templateArgs.target_store_id, url.templateArgs.target_id]; - - // locate association - var assoc = cmis.findRelationship(model.relTypeDef, source, target); - if (assoc === null) - { - status.setCode(404, "Assoc " + source.join("/") + "/" + relType + "/" + target.join("/") + " not found"); break script; } + var assoc = rel.assoc; // TODO: check permission // if (!assoc.source.hasPermission("DeleteAssociations")) diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.get.desc.xml index 533e36b6c5..d4501f728b 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.get.desc.xml @@ -2,9 +2,11 @@ Retrieve relationship (getProperties) - /api/rel/{store_type}/{store_id}/{id}/type/{rel_type}/target/{target_store_type}/{target_store_id}/{target_id}?filter={filter?}&includeAllowableActions={includeAllowableActions?} + + /cmis/rel/s/{store}/i/{id}/type/{rel_type}/target/s/{target_store}/i/{target_id}?filter={filter?}&includeAllowableActions={includeAllowableActions?} + guest argument CMIS -
\ No newline at end of file +
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.get.js index ab2f8563e3..1c9a0b2dc3 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationship.get.js @@ -1,24 +1,15 @@ + script: { - // relationship type - var relType = url.templateArgs.rel_type; - model.relTypeDef = cmis.queryType(relType); - if (model.relTypeDef === null) + // locate association + var rel = getAssocFromUrl(); + if (rel.assoc == null) { - status.setCode(400, "Relationship type " + relType + " unknown"); break script; } - if (model.relTypeDef.baseType.typeId != RELATIONSHIP_TYPE_ID) - { - status.setCode(400, "Type + " + relType + " is not a relationship type"); - break script; - } - - // source and target - var source = [url.templateArgs.store_type, url.templateArgs.store_id, url.templateArgs.id]; - var target = [url.templateArgs.target_store_type, url.templateArgs.target_store_id, url.templateArgs.target_id]; + model.assoc = rel.assoc; // property filter model.filter = args[cmis.ARG_FILTER]; @@ -30,12 +21,4 @@ script: // include allowable actions var includeAllowableActions = args[cmis.ARG_INCLUDE_ALLOWABLE_ACTIONS]; model.includeAllowableActions = (includeAllowableActions == "true" ? true : false); - - // locate association - model.assoc = cmis.findRelationship(model.relTypeDef, source, target); - if (model.assoc === null) - { - status.setCode(404, "Assoc " + source.join("/") + "/" + relType + "/" + target.join("/") + " not found"); - break script; - } } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.get.desc.xml index 0c52275ea0..f55d6db4f0 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.get.desc.xml @@ -2,6 +2,15 @@ Retrieve list of relationships (getRelationships) + + + /cmis/i/{id}/rels?filter={filter?}&relationshipType={relationshipType?}&includeSubRelationshipTypes={includeSubRelationshipTypes?}&direction={direction?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/i/{id}/rels?filter={filter?}&relationshipType={relationshipType?}&includeSubRelationshipTypes={includeSubRelationshipTypes?}&direction={direction?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} + + /cmis/p{path}/rels?filter={filter?}&relationshipType={relationshipType?}&includeSubRelationshipTypes={includeSubRelationshipTypes?}&direction={direction?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/p{path}/rels?filter={filter?}&relationshipType={relationshipType?}&includeSubRelationshipTypes={includeSubRelationshipTypes?}&direction={direction?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} + + /api/node/{store_type}/{store_id}/{id}/rels?filter={filter?}&relationshipType={relationshipType?}&includeSubRelationshipTypes={includeSubRelationshipTypes?}&direction={direction?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} /api/path/{store_type}/{store_id}/{id}/rels?filter={filter?}&relationshipType={relationshipType?}&includeSubRelationshipTypes={includeSubRelationshipTypes?}&direction={direction?}&skipCount={skipCount?}&maxItems={maxItems?}&includeAllowableActions={includeAllowableActions?} guest diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.get.js index be27d6b317..a44ac901c8 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.get.js @@ -1,16 +1,15 @@ + 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) + var object = getObjectFromUrl(); + if (object.node == null) { - status.setCode(404, "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"); break script; } + model.node = object.node; // property filter model.filter = args[cmis.ARG_FILTER]; diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.post.atom.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.post.atom.js index 25cbf66108..4bd8a283b1 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.post.atom.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.post.atom.js @@ -1,5 +1,6 @@ - + + script: { @@ -13,16 +14,12 @@ script: } // locate source node - var pathSegments = url.match.split("/"); - var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/")); - model.source = cmis.findNode(pathSegments[2], reference); - if (model.source === null) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } + model.source = object.node; // create var assoc = createAssociation(model.source, entry); @@ -36,6 +33,6 @@ script: // TODO: set Content-Location status.code = 201; // TODO: complete url mapping - status.location = url.server + url.serviceContext + "/api/rel/" + model.source.nodeRef.storeRef.protocol + "/" + model.source.nodeRef.storeRef.identifier + "/" + model.source.nodeRef.id; + status.location = url.server + url.serviceContext + "/cmis/rel/" + model.source.nodeRef.storeRef.protocol + "/" + model.source.nodeRef.storeRef.identifier + "/" + model.source.nodeRef.id; status.redirect = true; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.post.desc.xml index a1181ff6a7..3c95808bea 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/relationships.post.desc.xml @@ -2,8 +2,18 @@ Create relationship (createRelationship) + + + /cmis/i/{id}/rels + /cmis/s/{store}/i/{id}/rels + + /cmis/p{path}/rels + /cmis/s/{store}/p{path}/rels + + /api/node/{store_type}/{store_id}/{id}/rels /api/path/{store_type}/{store_id}/{id}/rels + guest argument CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.delete.desc.xml index 21e41b0075..1d23eb01ea 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.delete.desc.xml @@ -2,8 +2,17 @@ Delete tree (deleteTree) + + + /cmis/i/{id}/tree?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} + /cmis/s/{store}/i/{id}/tree?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} + + /cmis/p{path}/tree?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} + /cmis/s/{store}/p{path}/tree?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} + /api/node/{store_type}/{store_id}/{id}/tree?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} - /api/path/{store_type}/{store_id}/{id}/tree?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} + /api/path/{store_type}/{store_id}/{path}/tree?continueOnFailure={continueOnFailure?}&unfileMultiFiledDocuments={unfileMultiFiledDocuments} + user CMIS diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.delete.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.delete.js index 4422fb1862..50159be558 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.delete.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.delete.js @@ -1,17 +1,15 @@ + + script: { // locate node - var pathSegments = url.match.split("/"); - var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/")); - var node = cmis.findNode(pathSegments[2], reference); - if (node === null) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } - + var node = object.node; + // NOTE: Ignore continueOnDelete as complete tree is deleted in single transaction // TODO: Throw error on invalid unfileMultiFiledDocuments error @@ -28,7 +26,7 @@ script: if (!node.remove()) { status.code = 500; - status.message = "Failed to delete node " + pathSegments[2] + " " + reference.join("/"); + status.message = "Failed to delete object " + object.ref; status.redirect = true; break script; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.get.desc.xml index 00a4d11f9c..c629f54d3b 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.get.desc.xml @@ -2,8 +2,17 @@ Retrieve folder tree (getFolderTree) + + + /cmis/i/{id}/tree?filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/i/{id}/tree?filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} + + /cmis/p{path}/tree?filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} + /cmis/s/{store}/p{path}/tree?filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} + /api/node/{store_type}/{store_id}/{id}/tree?filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} - /api/path/{store_type}/{store_id}/{id}/tree?filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} + /api/path/{store_type}/{store_id}/{path}/tree?filter={filter?}&depth={depth?}&includeAllowableActions={includeAllowableActions?} + guest argument diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.get.js index 1a4fa85236..d7fd3133e2 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/tree.get.js @@ -1,21 +1,19 @@ + + 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) + var object = getObjectFromUrl(); + if (object.node == null) { - status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; break script; } + model.node = object.node; if (model.node.isDocument) { status.code = 404; - status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not a folder"; + status.message = "Object " + object.ref + " is not a folder"; status.redirect = true; break script; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/type.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/type.get.desc.xml index e75fc801c1..b9e7cc2a03 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/type.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/type.get.desc.xml @@ -19,7 +19,7 @@ canCreateInstances if false, the user MUST NOT be able to create instances of th When includeInheritedProperties is true, the repository SHOULD return all properties defined for the Object Type, including any properties inherited from its parent. If false, only Properties defined on the Object Type (but not its parent) SHOULD be returned. ]]> - /api/type/{typeId}?includeInheritedProperties={includeInheritedProperties?} + /cmis/type/{typeId}?includeInheritedProperties={includeInheritedProperties?} user diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/typechildren.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/typechildren.get.desc.xml index 649111d86c..25639451dc 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/typechildren.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/typechildren.get.desc.xml @@ -1,8 +1,8 @@ Retrieve list of child Types Retrieve list of all child Types - /api/type/{typeId}/children?includePropertyDefinitions={includePropertyDefinitions?}&skipCount={skipCount?}&maxItems={maxItems?} - /api/types?typeId={typeId?}&includePropertyDefinitions={includePropertyDefinitions?}&skipCount={skipCount?}&maxItems={maxItems?} + /cmis/type/{typeId}/children?includePropertyDefinitions={includePropertyDefinitions?}&skipCount={skipCount?}&maxItems={maxItems?} + /cmis/types?typeId={typeId?}&includePropertyDefinitions={includePropertyDefinitions?}&skipCount={skipCount?}&maxItems={maxItems?} user diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/typedescendants.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/typedescendants.get.desc.xml index 69a73b881b..39ad975b91 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/typedescendants.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/typedescendants.get.desc.xml @@ -1,8 +1,8 @@ Retrieve list of descendant Types Retrieve list of all descendant Types - /api/type/{typeId}/descendants?includePropertyDefinitions={includePropertyDefinitions?}&depth={depth?} - /api/types/descendants?typeId={typeId?}&includePropertyDefinitions={includePropertyDefinitions?}&depth={depth?} + /cmis/type/{typeId}/descendants?includePropertyDefinitions={includePropertyDefinitions?}&depth={depth?} + /cmis/types/descendants?typeId={typeId?}&includePropertyDefinitions={includePropertyDefinitions?}&depth={depth?} user diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/unfiled.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/unfiled.get.desc.xml index 8f3237a878..49c68cec87 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/unfiled.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/unfiled.get.desc.xml @@ -1,7 +1,7 @@ Unfiled Documents Retrieve list of documents that are not in any folder - /api/unfiled + /cmis/unfiled guest diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/versions.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/versions.get.desc.xml index 82e489ff47..0625690f7e 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/versions.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/versions.get.desc.xml @@ -18,8 +18,17 @@ Notes:
Returns all versions the user can access including checked-out version and private working copy.
]]> + + + /cmis/i/{id}/versions?filter={filter?} + /cmis/s/{store}/i/{id}/versions?filter={filter?} + + /cmis/p{path}/versions?filter={filter?} + /cmis/s/{store}/p{path}/versions?filter={filter?} + /api/node/{store_type}/{store_id}/{id}/versions?filter={filter?} - /api/path/{store_type}/{store_id}/{id}/versions?filter={filter?} + /api/path/{store_type}/{store_id}/{path}/versions?filter={filter?} + user argument diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/versions.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/versions.get.js index 4a34ca839f..3ec1211e57 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/versions.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/versions.get.js @@ -1,17 +1,15 @@ + + script: { - // locate version series // NOTE: version series is identified by noderef (as this is constant during lifetime of 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 || !model.node.isVersioned) + var object = getObjectFromUrl(); + if (object.node == null || !object.node.isVersioned) { - status.code = 404; - status.message = "Versions series " + pathSegments[2] + " " + reference.join("/") + " not found"; - status.redirect = true; + status.message = "Versions series " + object.ref + " not found"; break script; } + model.node = object.node; // property filter model.filter = args[cmis.ARG_FILTER]; diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml index 527faf4519..166761a3ba 100644 --- a/config/alfresco/web-scripts-application-context.xml +++ b/config/alfresco/web-scripts-application-context.xml @@ -224,10 +224,10 @@ cmis - + @@ -292,7 +292,7 @@ - + @@ -309,12 +309,19 @@ - + + + + + + + + diff --git a/source/java/org/alfresco/repo/cmis/rest/CMISScript.java b/source/java/org/alfresco/repo/cmis/rest/CMISScript.java index e3cdd185ba..13382a3ac4 100644 --- a/source/java/org/alfresco/repo/cmis/rest/CMISScript.java +++ b/source/java/org/alfresco/repo/cmis/rest/CMISScript.java @@ -26,26 +26,29 @@ package org.alfresco.repo.cmis.rest; import java.util.Collection; import java.util.Iterator; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import java.util.Map; import org.alfresco.cmis.CMISDictionaryService; import org.alfresco.cmis.CMISJoinEnum; +import org.alfresco.cmis.CMISObjectReference; import org.alfresco.cmis.CMISPropertyDefinition; import org.alfresco.cmis.CMISQueryEnum; import org.alfresco.cmis.CMISQueryOptions; import org.alfresco.cmis.CMISQueryService; import org.alfresco.cmis.CMISRelationshipDirectionEnum; +import org.alfresco.cmis.CMISRelationshipReference; +import org.alfresco.cmis.CMISRepositoryReference; import org.alfresco.cmis.CMISResultSet; import org.alfresco.cmis.CMISServices; import org.alfresco.cmis.CMISTypeDefinition; import org.alfresco.cmis.CMISTypesFilterEnum; import org.alfresco.cmis.CMISQueryOptions.CMISQueryMode; +import org.alfresco.cmis.reference.NodeRefReference; +import org.alfresco.cmis.reference.ReferenceFactory; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.jscript.Association; import org.alfresco.repo.jscript.BaseScopableProcessorExtension; import org.alfresco.repo.jscript.ScriptNode; -import org.alfresco.repo.model.Repository; import org.alfresco.repo.web.util.paging.Cursor; import org.alfresco.repo.web.util.paging.Page; import org.alfresco.repo.web.util.paging.PagedResults; @@ -101,15 +104,11 @@ public class CMISScript extends BaseScopableProcessorExtension // service dependencies private ServiceRegistry services; - private Repository repository; private CMISServices cmisService; private CMISDictionaryService cmisDictionaryService; private CMISQueryService cmisQueryService; private Paging paging; - - // versioned objectId pattern - // TODO: encapsulate elsewhere - private static final Pattern versionedObjectIdPattern = Pattern.compile(".+://.+/.+/.+"); + private ReferenceFactory referenceFactory; /** @@ -122,16 +121,6 @@ public class CMISScript extends BaseScopableProcessorExtension this.services = services; } - /** - * Set the repository - * - * @param repository - */ - public void setRepository(Repository repository) - { - this.repository = repository; - } - /** * Set the paging helper * @@ -172,6 +161,16 @@ public class CMISScript extends BaseScopableProcessorExtension this.cmisQueryService = cmisQueryService; } + /** + * Set the CMIS Reference Factory + * + * @param referenceFactory + */ + public void setCMISReferenceFactory(ReferenceFactory referenceFactory) + { + this.referenceFactory = referenceFactory; + } + /** * Gets the supported CMIS Version * @@ -238,63 +237,83 @@ public class CMISScript extends BaseScopableProcessorExtension } /** - * Finds a Node given a repository reference + * Create CMIS Repository Reference from URL segments * - * @param referenceType node, path - * @param reference node => id, path => path - * @return node (or null, if not found) + * @param args url arguments + * @param templateArgs url template arguments + * @return Repository Reference (or null, in case of bad url) */ - public ScriptNode findNode(String referenceType, String[] reference) + public CMISRepositoryReference createRepoReferenceFromUrl(Map args, Map templateArgs) { - ScriptNode node = null; - NodeRef nodeRef = repository.findNodeRef(referenceType, reference); - if (nodeRef != null) - { - node = new ScriptNode(nodeRef, services, getScope()); - } - return node; + return referenceFactory.createRepoReferenceFromUrl(args, templateArgs); + } + + /** + * Create CMIS Object Reference from URL segments + * + * @param args url arguments + * @param templateArgs url template arguments + * @return Repository Reference (or null, in case of bad url) + */ + public CMISObjectReference createObjectReferenceFromUrl(Map args, Map templateArgs) + { + return referenceFactory.createObjectReferenceFromUrl(args, templateArgs); } /** - * Finds a Node given CMIS ObjectId + * Create CMIS Relationship Reference from URL segments * - * @param objectId - * @return node (or null, if not found) + * @param args url arguments + * @param templateArgs url template arguments + * @return Repository Reference (or null, in case of bad url) */ - public ScriptNode findNode(String objectId) + public CMISRelationshipReference createRelationshipReferenceFromUrl(Map args, Map templateArgs) { - NodeRef nodeRef; - Matcher matcher = versionedObjectIdPattern.matcher(objectId); - if (matcher.matches()) - { - // TODO: handle version id - nodeRef = new NodeRef(objectId.substring(0, objectId.lastIndexOf("/"))); - } - else - { - nodeRef = new NodeRef(objectId); - } - String[] reference = new String[] {nodeRef.getStoreRef().getProtocol(), nodeRef.getStoreRef().getIdentifier(), nodeRef.getId()}; - return findNode("node", reference); + return referenceFactory.createRelationshipReferenceFromUrl(args, templateArgs); } /** - * Finds an Association + * Create Object Reference * - * @param sourceType - * @param source - * @param relDef - * @param targetType - * @param target - * - * @return + * @param repo repository reference + * @param object id object id (NodeRef.toString() format) + * @return object id reference */ - public Association findRelationship(CMISTypeDefinition relDef, String[] sourceRef, String[] targetRef) + public CMISObjectReference createObjectIdReference(String objectId) { - NodeRef source = new NodeRef(sourceRef[0], sourceRef[1], sourceRef[2]); - NodeRef target = new NodeRef(targetRef[0], targetRef[1], targetRef[2]); - AssociationRef assocRef = cmisService.getRelationship(relDef, source, target); - return (assocRef == null) ? null : new Association(services, assocRef); + return new NodeRefReference(cmisService, objectId); + } + + /** + * Get Node from Object Reference + * + * @param ref object reference + * @return node + */ + public ScriptNode getNode(CMISObjectReference ref) + { + NodeRef nodeRef = ref.getNodeRef(); + if (nodeRef == null) + { + return null; + } + return new ScriptNode(nodeRef, services, getScope()); + } + + /** + * Get Association from Relationship Reference + * + * @param ref relationship reference + * @return association + */ + public Association getAssociation(CMISRelationshipReference ref) + { + AssociationRef assocRef = ref.getAssocRef(); + if (assocRef == null) + { + return null; + } + return new Association(services, assocRef); } /** @@ -424,35 +443,6 @@ public class CMISScript extends BaseScopableProcessorExtension return results; } - /** - * Query for all Type Definitions in a type hierarchy - * - * @param page - * @return paged result set of types - */ -// public PagedResults queryTypeHierarchy(CMISTypeDefinition typeDef, boolean descendants, Page page) -// { -// Collection subTypes = typeDef.getSubTypes(descendants); -// Cursor cursor = paging.createCursor(subTypes.size(), page); -// -// // skip -// Iterator iterSubTypes = subTypes.iterator(); -// for (int i = 0; i < cursor.getStartRow(); i++) -// { -// iterSubTypes.next(); -// } -// -// // get types for page -// CMISTypeDefinition[] types = new CMISTypeDefinition[cursor.getRowCount()]; -// for (int i = cursor.getStartRow(); i <= cursor.getEndRow(); i++) -// { -// types[i - cursor.getStartRow()] = iterSubTypes.next(); -// } -// -// PagedResults results = paging.createPagedResults(types, cursor); -// return results; -// } - /** * Query for a Type Definition given a CMIS Type Id * diff --git a/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java b/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java index 3ba1a2de7e..c2f628c570 100644 --- a/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java +++ b/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java @@ -782,8 +782,6 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten { try { - if (logger.isDebugEnabled()) - logger.debug("Writing Transactional response: size=" + outputStream.size()); if (outputWriter != null) { @@ -792,6 +790,9 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten } else if (outputStream != null) { + if (logger.isDebugEnabled()) + logger.debug("Writing Transactional response: size=" + outputStream.size()); + outputStream.flush(); outputStream.writeTo(res.getOutputStream()); } diff --git a/source/java/org/alfresco/repo/web/scripts/content/ContentDelete.java b/source/java/org/alfresco/repo/web/scripts/content/ContentDelete.java new file mode 100644 index 0000000000..e571e21311 --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/content/ContentDelete.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * 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. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.web.scripts.content; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import org.alfresco.cmis.CMISObjectReference; +import org.alfresco.cmis.reference.ReferenceFactory; +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.repository.ContentData; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.web.scripts.AbstractWebScript; +import org.alfresco.web.scripts.WebScriptException; +import org.alfresco.web.scripts.WebScriptRequest; +import org.alfresco.web.scripts.WebScriptResponse; + + +/** + * Content Delete Service + * + * Delete content stream from the Repository. + * + * @author davidc + */ +public class ContentDelete extends AbstractWebScript +{ + // Component dependencies + private ReferenceFactory referenceFactory; + private NamespaceService namespaceService; + private NodeService nodeService; + + /** + * @param reference factory + */ + public void setReferenceFactory(ReferenceFactory referenceFactory) + { + this.referenceFactory = referenceFactory; + } + + /** + * @param namespaceService + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + + /** + * @param nodeService + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + + /** + * @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse) + */ + public void execute(WebScriptRequest req, WebScriptResponse res) + throws IOException + { + // create map of args + String[] names = req.getParameterNames(); + Map args = new HashMap(names.length, 1.0f); + for (String name : names) + { + args.put(name, req.getParameter(name)); + } + + // create map of template vars + Map templateVars = req.getServiceMatch().getTemplateVars(); + + // create object reference from url + CMISObjectReference reference = referenceFactory.createObjectReferenceFromUrl(args, templateVars); + NodeRef nodeRef = reference.getNodeRef(); + if (nodeRef == null) + { + throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString()); + } + + // determine content property + QName propertyQName = ContentModel.PROP_CONTENT; + String contentPart = templateVars.get("property"); + if (contentPart.length() > 0 && contentPart.charAt(0) == ';') + { + if (contentPart.length() < 2) + { + throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Content property malformed"); + } + String propertyName = contentPart.substring(1); + if (propertyName.length() > 0) + { + propertyQName = QName.createQName(propertyName, namespaceService); + } + } + + // retrieve content property + ContentData contentData = (ContentData)nodeService.getProperty(nodeRef, propertyQName); + if (contentData != null) + { + contentData = new ContentData(null, null, 0, null); + nodeService.setProperty(nodeRef, propertyQName, contentData); + } + + // no content returned + res.setStatus(204); + } +} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/web/scripts/content/ContentGet.java b/source/java/org/alfresco/repo/web/scripts/content/ContentGet.java index 6bc14b72bb..f17b4b2390 100644 --- a/source/java/org/alfresco/repo/web/scripts/content/ContentGet.java +++ b/source/java/org/alfresco/repo/web/scripts/content/ContentGet.java @@ -25,13 +25,14 @@ package org.alfresco.repo.web.scripts.content; import java.io.IOException; -import java.util.Arrays; +import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletResponse; +import org.alfresco.cmis.CMISObjectReference; +import org.alfresco.cmis.reference.ReferenceFactory; import org.alfresco.model.ContentModel; -import org.alfresco.repo.model.Repository; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; @@ -56,15 +57,15 @@ public class ContentGet extends StreamContent private static final Log logger = LogFactory.getLog(ContentGet.class); // Component dependencies - private Repository repository; + private ReferenceFactory referenceFactory; private NamespaceService namespaceService; /** - * @param repository + * @param reference factory */ - public void setRepository(Repository repository) + public void setReferenceFactory(ReferenceFactory referenceFactory) { - this.repository = repository; + this.referenceFactory = referenceFactory; } /** @@ -80,20 +81,24 @@ public class ContentGet extends StreamContent */ public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException - { - // convert web script URL to node reference in Repository - String match = req.getServiceMatch().getPath(); - String[] matchParts = match.split("/"); + { + // create map of args + String[] names = req.getParameterNames(); + Map args = new HashMap(names.length, 1.0f); + for (String name : names) + { + args.put(name, req.getParameter(name)); + } + + // create map of template vars Map templateVars = req.getServiceMatch().getTemplateVars(); - String[] id = templateVars.get("id").split("/"); - String[] path = new String[id.length + 2]; - path[0] = templateVars.get("store_type"); - path[1] = templateVars.get("store_id"); - System.arraycopy(id, 0, path, 2, id.length); - NodeRef nodeRef = repository.findNodeRef(matchParts[2], path); + + // create object reference from url + CMISObjectReference reference = referenceFactory.createObjectReferenceFromUrl(args, templateVars); + NodeRef nodeRef = reference.getNodeRef(); if (nodeRef == null) { - throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + matchParts[2] + " reference " + Arrays.toString(path)); + throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString()); } // determine content property diff --git a/source/java/org/alfresco/repo/web/scripts/content/ContentSet.java b/source/java/org/alfresco/repo/web/scripts/content/ContentSet.java index 4cbb018d46..e63f84344a 100644 --- a/source/java/org/alfresco/repo/web/scripts/content/ContentSet.java +++ b/source/java/org/alfresco/repo/web/scripts/content/ContentSet.java @@ -28,14 +28,16 @@ import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.Charset; -import java.util.Arrays; +import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletResponse; +import org.alfresco.cmis.CMISObjectReference; +import org.alfresco.cmis.reference.ObjectPathReference; +import org.alfresco.cmis.reference.ReferenceFactory; import org.alfresco.model.ContentModel; import org.alfresco.repo.content.encoding.ContentCharsetFinder; -import org.alfresco.repo.model.Repository; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.PropertyDefinition; @@ -68,18 +70,18 @@ public class ContentSet extends AbstractWebScript private static final Log logger = LogFactory.getLog(ContentSet.class); // Component dependencies - private Repository repository; + private ReferenceFactory referenceFactory; private DictionaryService dictionaryService; private NamespaceService namespaceService; private ContentService contentService; private MimetypeService mimetypeService; /** - * @param repository + * @param reference factory */ - public void setRepository(Repository repository) + public void setReferenceFactory(ReferenceFactory referenceFactory) { - this.repository = repository; + this.referenceFactory = referenceFactory; } /** @@ -119,20 +121,24 @@ public class ContentSet extends AbstractWebScript */ public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException - { - // convert web script URL to node reference in Repository - String match = req.getServiceMatch().getPath(); - String[] matchParts = match.split("/"); + { + // create map of args + String[] names = req.getParameterNames(); + Map args = new HashMap(names.length, 1.0f); + for (String name : names) + { + args.put(name, req.getParameter(name)); + } + + // create map of template vars Map templateVars = req.getServiceMatch().getTemplateVars(); - String[] id = templateVars.get("id").split("/"); - String[] path = new String[id.length + 2]; - path[0] = templateVars.get("store_type"); - path[1] = templateVars.get("store_id"); - System.arraycopy(id, 0, path, 2, id.length); - NodeRef nodeRef = repository.findNodeRef(matchParts[2], path); + + // create object reference from url + CMISObjectReference reference = referenceFactory.createObjectReferenceFromUrl(args, templateVars); + NodeRef nodeRef = reference.getNodeRef(); if (nodeRef == null) { - throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + matchParts[2] + " reference " + Arrays.toString(path)); + throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString()); } // determine content property @@ -153,7 +159,7 @@ public class ContentSet extends AbstractWebScript PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName); if (propertyDef == null) { - throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + matchParts[2] + " reference " + Arrays.toString(path) + " content property " + propertyQName); + throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find content property " + propertyQName + " of " + reference.toString()); } if (!propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT)) { @@ -180,9 +186,9 @@ public class ContentSet extends AbstractWebScript String mimetype = req.getContentType(); if (mimetype == null) { - if (matchParts[2].equals("path") || matchParts[2].equals("avmpath")) + if (reference instanceof ObjectPathReference) { - mimetype = mimetypeService.guessMimetype(templateVars.get("id")); + mimetype = mimetypeService.guessMimetype(((ObjectPathReference)reference).getPath()); } } if (mimetype != null) diff --git a/source/test-resources/cmis/cmis-test-context.xml b/source/test-resources/cmis/cmis-test-context.xml deleted file mode 100644 index bfb3ede03e..0000000000 --- a/source/test-resources/cmis/cmis-test-context.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - cmis/cmisCustomModel.xml - - - - - \ No newline at end of file diff --git a/source/test-resources/cmis/cmisCustomModel.xml b/source/test-resources/cmis/cmisCustomModel.xml deleted file mode 100644 index ccfd2e7231..0000000000 --- a/source/test-resources/cmis/cmisCustomModel.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - CMIS Custom Model - Alfresco - 1.0 - - - - - - - - - - - - - - Custom Folder - cm:folder - - - Custom Folder Property (string) - d:text - - - - - - Custom Document - cm:content - - - Custom Document Property (string) - d:text - - - Custom Document Property (multi-valued boolean) - d:boolean - true - - - - - - false - false - - - cm:content - false - true - - - - - - - \ No newline at end of file