diff --git a/config/alfresco/cmis-ws-context.xml b/config/alfresco/cmis-ws-context.xml index b532ca7787..318b9b2207 100644 --- a/config/alfresco/cmis-ws-context.xml +++ b/config/alfresco/cmis-ws-context.xml @@ -18,12 +18,12 @@ - + - + @@ -44,12 +44,12 @@ - + - + @@ -70,12 +70,12 @@ - + - + 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 6f912a7c5a..48c62ee1c4 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 @@ -4,14 +4,21 @@ [#-- ATOM Entry for Document --] [#-- --] + +[#macro contentLink node] + +${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/content.${node.properties.name} + +[/#macro] + [#macro document node propfilter="*"] ${node.properties.creator!""} - + urn:uuid:${node.id} - + - + [@documentCMISLinks node=node/] ${xmldate(node.properties.created)} ${node.properties.description!node.properties.title!cropContent(node, 50)} @@ -27,7 +34,7 @@ - + [/#macro] @@ -54,7 +61,7 @@ [@filter propfilter "VERSION_LABEL"][@prop "versionLabel" cmisproperty(node, "VERSION_LABEL")!"" "String"/][/@filter] [@filter propfilter "VERSION_SERIES_CHECKED_OUT_BY"][@prop "versionSeriesCheckedOutBy" cmisproperty(node, "VERSION_SERIES_CHECKED_OUT_BY")!"" "String"/][/@filter] [@filter propfilter "CHECKIN_COMMENT"][@prop "checkinComment" cmisproperty(node, "CHECKIN_COMMENT")!"" "String"/][/@filter] - [@filter propfilter "CONTENT_STREAM_URI"][@prop "contentStreamURI" absurl(url.serviceContext) + "/api/node/" + node.nodeRef.storeRef.protocol + "/" + node.nodeRef.storeRef.identifier + "/" + node.nodeRef.id + "/content" "String"/][/@filter] + [@filter propfilter "CONTENT_STREAM_URI"][@prop "contentStreamURI" absurl(url.serviceContext) + "/api/node/" + node.nodeRef.storeRef.protocol + "/" + node.nodeRef.storeRef.identifier + "/" + node.nodeRef.id + "/content." + node.properties.name "String"/][/@filter] [/#macro] @@ -65,10 +72,10 @@ [#macro version node version propfilter="*"] ${node.properties.creator} - + urn:uuid:${node.id} - + [@documentCMISLinks node=node/] ${xmldate(node.properties.created)} ${node.properties.description!node.properties.title!cropContent(node.properties.content, 50)} @@ -86,12 +93,12 @@ [#macro pwc node propfilter="*"] ${node.properties.creator} - + urn:uuid:${node.id} - + - + [@documentCMISLinks node=node/] ${xmldate(node.properties.created)} ${node.properties.description!node.properties.title!cropContent(node.properties.content, 50)} @@ -160,21 +167,33 @@ [#if row.nodes??] [#assign node = row.nodes?first] ${node.properties.creator!""} - + urn:uuid:${node.id} ${node.name} ${xmldate(node.properties.modified)} [/#if] -[#assign values = row.values] -[#if values?size > 0] + +[#-- TODO: spec issue: baseType to become formal property --] +[#if node??] + [#if node.isDocument] + [@prop "baseType" "document" "String"/] + [#else] + [@prop "baseType" "folder" "String"/] + [/#if] +[/#if] + +[#assign values = row.values] [#list values?keys as colname] [#assign coltype = row.getColumnType(colname)] + [#if values[colname]??] [@prop colname values[colname] coltype/] + [#else] + [@propnull colname coltype/] + [/#if] [/#list] -[/#if] [#-- TODO: custom ns ${absurl(url.context)}${node.icon16} --] [/#macro] @@ -235,7 +254,7 @@ [#macro propdefCMISProps propdef] - ${propdef.propertyName} + ${propdef.propertyNameREST} ${propdef.propertyId} [#if propdef.displayName??]${propdef.displayName?xml}[/#if] [#if propdef.description??]${propdef.description?xml}[/#if] @@ -283,6 +302,24 @@ [/#if] [/#macro] +[#macro propnull name type] +[#if type == "String"] + +[#elseif type == "Integer"] + +[#elseif type == "Decimal"] + +[#elseif type == "Boolean"] + +[#elseif type == "DateTime"] + +[#elseif type == "URI"] + +[#elseif type == "ID"] + +[#-- TODO: remaining property types --] +[/#if] +[/#macro] [#-- TODO: spec issue 40 --] [#macro cmisBaseType rootType] diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/search/query.post.cmissqlquery.js b/config/alfresco/templates/webscripts/org/alfresco/repository/search/query.post.cmissqlquery.js index 41e8244f51..3c0bc8717e 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/search/query.post.cmissqlquery.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/search/query.post.cmissqlquery.js @@ -3,17 +3,30 @@ script: // process query statement // // - // object_id1 + // SELECT name FROM DOCUMENT_OBJECT_TYPE // false // 0 // 0 // false // + // XML parsing need to be moved to Java + + function ltrim(str){ + return str.replace(/^\s+/, ''); + } + default xml namespace = 'http://www.cmis.org/2008/05'; - var cmisQuery = new XML(query); + // regex to match an XML declaration + var xmlDeclaration = /^<\?xml version[^>]+?>/; + // remove xml declaration and leading whitespace + query = ltrim(query.replace(xmlDeclaration, '')); + + // need to move the XML declaration if it exists + var cmisQuery = new XML(query); + // extract query statement model.statement = cmisQuery.statement.toString(); if (model.statement == null || model.statement.length == 0) 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 new file mode 100644 index 0000000000..b336cafc2d --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.post.atom.js @@ -0,0 +1,89 @@ +script: +{ + // ensure atom entry is posted + if (entry === null) + { + status.code = 400; + status.message = "Expected atom entry"; + status.redirect = true; + break 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) + { + status.code = 404; + status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; + status.redirect = true; + break script; + } + + // pull apart atom entry + // TODO: creation of file/folder sub-types + // TODO: cmis properties + + var id = entry.id; + var name = (slug !== null) ? slug : entry.title; + var title = entry.title; + var description = entry.summary; + var updated = entry.updated; + var author = (entry.author !== null) ? entry.author.name : null; + var cmisProperties = entry.getExtension(atom.names.cmis_properties); + var objectType = (cmisProperties !== null) ? cmisProperties.objectType : null; + + // create the item + // TODO: author/updated/id + + if (objectType === null || objectType.toLowerCase() == "document") + { + // TODO: objectTypeId to Alfresco content type + var node = model.parent.createFile(name); + node.properties.title = title; + node.properties.description = description; + + // write entry content + if (entry.content != null) + { + if (entry.contentType !== null && entry.contentType == "MEDIA") + { + node.properties.content.write(entry.contentStream); + } + else + { + node.content = entry.content; + } + node.properties.content.encoding = "UTF-8"; + node.properties.content.mimetype = atom.toMimeType(entry); + } + + node.save(); + model.node = node; + + // TODO: versioningState argument (CheckedOut/CheckedInMinor/CheckedInMajor) + } + else if (objectType.toLowerCase() == "folder") + { + // TODO: objectTypeId to Alfresco content type + var node = model.parent.createFolder(name); + node.properties.title = title; + node.properties.description = description; + node.save(); + model.node = node; + } + else + { + status.code = 400; + status.message = "CMIS object type " + objectType + " not understood"; + status.redirect = true; + break script; + } + + // setup for 201 Created response + // 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.redirect = true; +} diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.atomfeed.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.atomfeed.ftl new file mode 100644 index 0000000000..61e8df147c --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.atomfeed.ftl @@ -0,0 +1,30 @@ +[#ftl] +[#import "/org/alfresco/cmis/ns.lib.atom.ftl" as nsLib/] +[#import "/org/alfresco/cmis/atomfeed.lib.atom.ftl" as feedLib/] +[#import "/org/alfresco/cmis/atomentry.lib.atom.ftl" as entryLib/] +[#import "/org/alfresco/paging.lib.atom.ftl" as pagingLib/] +[#compress] + + + + +[@feedLib.node node] + [@pagingLib.links cursor/] +[/@feedLib.node] + +[#list results as child] + + [#if child.isDocument] + [@entryLib.document child filter/] + [#else] + [@entryLib.folder child filter/] + [/#if] + +[/#list] + +[@feedLib.hasMore cursor/] +[@pagingLib.opensearch cursor/] + + + +[/#compress] \ No newline at end of file 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 new file mode 100644 index 0000000000..6cf84d3f43 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.desc.xml @@ -0,0 +1,9 @@ + + Retrieve tree of descendants + Retrieve descendants + /api/node/{store_type}/{store_id}/{id}/descendants?types={types}&filter={filter?}&depth={depth?} + /api/path/{store_type}/{store_id}/{id}/descendants?types={types}&filter={filter?}&depth={depth?} + guest + argument + CMIS + \ No newline at end of file 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 new file mode 100644 index 0000000000..b1f34af635 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.get.js @@ -0,0 +1,37 @@ +script: +{ + // locate node + var pathSegments = url.match.split("/"); + var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/")); + model.node = cmis.findNode(pathSegments[2], reference); + if (model.node === null) + { + status.code = 404; + status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; + status.redirect = true; + break script; + } + + // handle filters + model.types = cmis.findArg(args.types, headers["CMIS-types"]) === null ? cmis.defaultTypesFilter : cmis.findArg(args.types, headers["CMIS-types"]); + if (!cmis.isValidTypesFilter(model.types)) + { + status.code = 400; + status.message = "Types filter '" + model.types + "' unknown"; + status.redirect = true; + break script; + } + // property filter + model.filter = cmis.findArg(args.filter, headers["CMIS-filter"]); + if (model.filter === null) + { + model.filter = "*"; + } + + // TODO: retrieve descendants instead + // retrieve children + var page = paging.createPageOrWindow(args, headers); + var paged = cmis.queryChildren(model.node, model.types, page); + model.results = paged.results; + model.cursor = paged.cursor; +} diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.atom.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.atom.js new file mode 100644 index 0000000000..f745b7d27d --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.atom.js @@ -0,0 +1,91 @@ +// TODO: consolidate with children.post.atomentry.js + +script: +{ + // ensure atom entry is posted + if (entry === null) + { + status.code = 400; + status.message = "Expected atom entry"; + status.redirect = true; + break 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) + { + status.code = 404; + status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found"; + status.redirect = true; + break script; + } + + // pull apart atom entry + // TODO: creation of file/folder sub-types + // TODO: cmis properties + + var id = entry.id; + var name = (slug !== null) ? slug : entry.title; + var title = entry.title; + var description = entry.summary; + var updated = entry.updated; + var author = (entry.author !== null) ? entry.author.name : null; + var cmisProperties = entry.getExtension(atom.names.cmis_properties); + var objectType = (cmisProperties !== null) ? cmisProperties.objectType : null; + + // create the item + // TODO: author/updated/id + + if (objectType === null || objectType.toLowerCase() == "document") + { + // TODO: objectTypeId to Alfresco content type + var node = model.parent.createFile(name); + node.properties.title = title; + node.properties.description = description; + + // write entry content + if (entry.content != null) + { + if (entry.contentType !== null && entry.contentType == "MEDIA") + { + node.properties.content.write(entry.contentStream); + } + else + { + node.content = entry.content; + } + node.properties.content.encoding = "UTF-8"; + node.properties.content.mimetype = atom.toMimeType(entry); + } + + node.save(); + model.node = node; + + // TODO: versioningState argument (CheckedOut/CheckedInMinor/CheckedInMajor) + } + else if (objectType.toLowerCase() == "folder") + { + // TODO: objectTypeId to Alfresco content type + var node = model.parent.createFolder(name); + node.properties.title = title; + node.properties.description = description; + node.save(); + model.node = node; + } + else + { + status.code = 400; + status.message = "CMIS object type " + objectType + " not understood"; + status.redirect = true; + break script; + } + + // setup for 201 Created response + // 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.redirect = true; +} diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.atomentry.201.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.atomentry.201.ftl new file mode 100644 index 0000000000..84a13506f1 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.atomentry.201.ftl @@ -0,0 +1,16 @@ +[#ftl] +[#import "/org/alfresco/cmis/ns.lib.atom.ftl" as nsLib/] +[#import "/org/alfresco/cmis/atomentry.lib.atom.ftl" as entryLib/] +[#compress] + + + + + [#if node.isDocument] + [@entryLib.document node=node/] + [#else] + [@entryLib.folder node=node/] + [/#if] + + +[/#compress] \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.post.atomentry.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.atomentry.js similarity index 98% rename from config/alfresco/templates/webscripts/org/alfresco/repository/store/children.post.atomentry.js rename to config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.atomentry.js index 7276dd16b3..80feb7998a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/children.post.atomentry.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.atomentry.js @@ -1,3 +1,5 @@ +// TODO: consolidate with children.post.atomentry.js + script: { // ensure atom entry is posted diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.desc.xml new file mode 100644 index 0000000000..2ff04a7acf --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.desc.xml @@ -0,0 +1,9 @@ + + Create folder or document + + /api/node/{store_type}/{store_id}/{id}/descendants + /api/path/{store_type}/{store_id}/{id}/descendants + user + + CMIS + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.js new file mode 100644 index 0000000000..1527e32831 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/descendants.post.js @@ -0,0 +1,9 @@ +script: +{ + // TODO: Handle direct posting of media + + status.code = 400; + status.message = "Posting of media resource not supported"; + status.redirect = true; + break script; +} diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.atomentry.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.atom.js similarity index 77% rename from config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.atomentry.js rename to config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.atom.js index c86f26b3e2..121dcc3398 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.atomentry.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/store/item.put.atom.js @@ -46,18 +46,13 @@ script: var content = entry.content; if (content !== null) { - if (!model.node.isDocument) + if (model.node.isDocument) { - status.code = 400; - status.message = "Cannot update content on folder " + pathSegments[2] + " " + reference.join("/"); - status.redirect = true; - break script; + model.node.content = content; + model.node.properties.content.encoding = "UTF-8"; + model.node.properties.content.mimetype = atom.toMimeType(entry); + updated = true; } - - model.node.content = content; - model.node.properties.content.encoding = "UTF-8"; - model.node.properties.content.mimetype = atom.toMimeType(entry); - updated = true; } // only save if an update actually occurred diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.put.atomentry.js b/config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.put.atom.js similarity index 100% rename from config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.put.atomentry.js rename to config/alfresco/templates/webscripts/org/alfresco/repository/store/pwc.put.atom.js diff --git a/source/java/org/alfresco/repo/cmis/rest/BaseCMISWebScriptTest.java b/source/java/org/alfresco/repo/cmis/rest/BaseCMISWebScriptTest.java index 66093c7bc7..3edecf2866 100644 --- a/source/java/org/alfresco/repo/cmis/rest/BaseCMISWebScriptTest.java +++ b/source/java/org/alfresco/repo/cmis/rest/BaseCMISWebScriptTest.java @@ -55,6 +55,7 @@ public class BaseCMISWebScriptTest extends BaseWebScriptTest { private CMISValidator cmisValidator = new CMISValidator(); private boolean argsAsHeaders = false; + private boolean validateResponse = true; /** * Pass URL arguments as headers @@ -65,7 +66,17 @@ public class BaseCMISWebScriptTest extends BaseWebScriptTest { this.argsAsHeaders = argsAsHeaders; } - + + /** + * Validate Response + * + * @param validateResponse + */ + protected void setValidateResponse(boolean validateResponse) + { + this.validateResponse = validateResponse; + } + /** * Determines if URL arguments are passed as headers * @@ -125,14 +136,17 @@ public class BaseCMISWebScriptTest extends BaseWebScriptTest protected void assertValidXML(String xml, Validator validator) throws IOException, ParserConfigurationException { - try + if (validateResponse) { - Document document = cmisValidator.getDocumentBuilder().parse(new InputSource(new StringReader(xml))); - validator.validate(new DOMSource(document)); - } - catch (SAXException e) - { - fail(cmisValidator.toString(e, xml)); + try + { + Document document = cmisValidator.getDocumentBuilder().parse(new InputSource(new StringReader(xml))); + validator.validate(new DOMSource(document)); + } + catch (SAXException e) + { + fail(cmisValidator.toString(e, xml)); + } } } diff --git a/source/java/org/alfresco/repo/cmis/rest/CMISTest.java b/source/java/org/alfresco/repo/cmis/rest/CMISTest.java index 11fb7d6b73..1d3d682e68 100644 --- a/source/java/org/alfresco/repo/cmis/rest/CMISTest.java +++ b/source/java/org/alfresco/repo/cmis/rest/CMISTest.java @@ -27,6 +27,7 @@ package org.alfresco.repo.cmis.rest; import java.io.StringReader; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -63,31 +64,27 @@ import org.apache.commons.logging.LogFactory; */ public class CMISTest extends BaseCMISWebScriptTest { + // test context + protected static boolean remote = false; + + // Alfresco + protected static String repositoryUrl = "http://localhost:8080/alfresco/service/api/repository"; + protected static boolean validateResponse = true; + protected static String username = "admin"; + protected static String password = "admin"; + protected static boolean argsAsHeaders = false; + // Logger private static final Log logger = LogFactory.getLog(CMISTest.class); - - private AbderaService abdera; - - // test context - private String repositoryUrl = "http://localhost:8080/alfresco/service/api/repository"; - + // cached responses + private AbderaService abdera; private static Service service = null; private static String fulltextCapability = null; private static Entry testsFolder = null; private static Entry testRunFolder = null; - - /** - * Sets the Repository "service" URL - * - * @param repositoryUrl repository service url - */ - public void setRepositoryUrl(String repositoryUrl) - { - this.repositoryUrl = repositoryUrl; - } - + @Override protected void setUp() @@ -99,8 +96,21 @@ public class CMISTest extends BaseCMISWebScriptTest abderaImpl.registerExtensionFactory(new CMISExtensionFactory()); abdera = abderaImpl; - // setup user - setDefaultRunAs("admin"); + if (remote) + { + RemoteServer server = new RemoteServer(); + server.username = username; + server.password = password; + setRemoteServer(server); + } + else + { + // setup user + setDefaultRunAs("admin"); + } + + setArgsAsHeaders(argsAsHeaders); + setValidateResponse(validateResponse); super.setUp(); @@ -120,7 +130,7 @@ public class CMISTest extends BaseCMISWebScriptTest service = abdera.parseService(new StringReader(xml), null); assertNotNull(service); - Workspace workspace = service.getWorkspaces().get(0); + Workspace workspace = getWorkspace(service); CMISRepositoryInfo repoInfo = workspace.getExtension(CMISConstants.REPOSITORY_INFO); assertNotNull(repoInfo); CMISCapabilities capabilities = repoInfo.getCapabilities(); @@ -131,36 +141,55 @@ public class CMISTest extends BaseCMISWebScriptTest return service; } - private IRI getRootCollection(Service service) + private Workspace getWorkspace(Service service) { - Collection root = service.getCollection("Main Repository", "root collection"); + return service.getWorkspaces().get(0); + } + + private Collection getCMISCollection(Workspace workspace, String collectionId) + { + List collections = workspace.getCollections(); + for (Collection collection : collections) + { + String id = collection.getAttributeValue(CMISConstants.COLLECTION_TYPE); + if (id != null && id.equals(collectionId)) + { + return collection; + } + } + return null; + } + + private IRI getRootCollection(Workspace workspace) + { + Collection root = getCMISCollection(workspace, "root"); assertNotNull(root); IRI rootHREF = root.getHref(); assertNotNull(rootHREF); return rootHREF; } - private IRI getCheckedOutCollection(Service service) + private IRI getCheckedOutCollection(Workspace workspace) { - Collection root = service.getCollection("Main Repository", "checkedout collection"); + Collection root = getCMISCollection(workspace, "checkedout"); assertNotNull(root); IRI rootHREF = root.getHref(); assertNotNull(rootHREF); return rootHREF; } - private IRI getTypesCollection(Service service) + private IRI getTypesCollection(Workspace workspace) { - Collection root = service.getCollection("Main Repository", "type collection"); + Collection root = getCMISCollection(workspace, "types"); assertNotNull(root); IRI rootHREF = root.getHref(); assertNotNull(rootHREF); return rootHREF; } - private IRI getQueryCollection(Service service) + private IRI getQueryCollection(Workspace workspace) { - Collection root = service.getCollection("Main Repository", "query collection"); + Collection root = getCMISCollection(workspace, "query"); assertNotNull(root); IRI rootHREF = root.getHref(); assertNotNull(rootHREF); @@ -241,7 +270,7 @@ public class CMISTest extends BaseCMISWebScriptTest if (testRunFolder == null) { Service service = getRepository(); - IRI rootFolderHREF = getRootCollection(service); + IRI rootFolderHREF = getRootCollection(getWorkspace(service)); testsFolder = createTestsFolder(rootFolderHREF); Link testsChildrenLink = testsFolder.getLink(CMISConstants.REL_CHILDREN); testRunFolder = createFolder(testsChildrenLink.getHref(), "Test Run " + System.currentTimeMillis()); @@ -293,7 +322,7 @@ public class CMISTest extends BaseCMISWebScriptTest public void testRepository() throws Exception { - IRI rootHREF = getRootCollection(getRepository()); + IRI rootHREF = getRootCollection(getWorkspace(getRepository())); sendRequest(new GetRequest(rootHREF.toString()), 200, getAtomValidator()); } @@ -316,7 +345,22 @@ public class CMISTest extends BaseCMISWebScriptTest Entry entry = feedFolderAfter.getEntry(document.getId().toString()); assertNotNull(entry); } - + + public void testCreateDocument2() + throws Exception + { + Entry testFolder = createTestFolder("testCreateDocument2"); + Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN); + assertNotNull(childrenLink); + String createFile = loadString("/cmis/rest/createdocument2.atomentry.xml"); + Response res = sendRequest(new PostRequest(childrenLink.getHref().toString(), createFile, Format.ATOM.mimetype()), 201, getAtomValidator()); + String xml = res.getContentAsString(); + Entry entry = abdera.parseEntry(new StringReader(xml), null); + Response documentContentRes = sendRequest(new GetRequest(entry.getContentSrc().toString()), 200); + String resContent = documentContentRes.getContentAsString(); + assertEquals("1", resContent); + } + public void testCreateDocumentBase64() throws Exception { @@ -400,7 +444,7 @@ public class CMISTest extends BaseCMISWebScriptTest assertNotNull(documentRes); String documentXML = documentRes.getContentAsString(); assertNotNull(documentXML); - IRI checkedoutHREF = getCheckedOutCollection(getRepository()); + IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository())); Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201, getAtomValidator()); assertNotNull(pwcRes); Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null); @@ -529,7 +573,7 @@ public class CMISTest extends BaseCMISWebScriptTest assertNotNull(parentsToRoot.getEntries().get(1).getLink(CMISConstants.REL_PARENT)); assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId()); assertNotNull(parentsToRoot.getEntries().get(2).getLink(CMISConstants.REL_PARENT)); - Feed root = getFeed(getRootCollection(getRepository())); + Feed root = getFeed(getRootCollection(getWorkspace(getRepository()))); assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId()); assertNull(parentsToRoot.getEntries().get(3).getLink(CMISConstants.REL_PARENT)); } @@ -563,7 +607,7 @@ public class CMISTest extends BaseCMISWebScriptTest assertNotNull(parentsToRoot.getEntries().get(1).getLink(CMISConstants.REL_PARENT)); assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId()); assertNotNull(parentsToRoot.getEntries().get(2).getLink(CMISConstants.REL_PARENT)); - Feed root = getFeed(getRootCollection(getRepository())); + Feed root = getFeed(getRootCollection(getWorkspace(getRepository()))); assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId()); assertNull(parentsToRoot.getEntries().get(3).getLink(CMISConstants.REL_PARENT)); } @@ -640,7 +684,7 @@ public class CMISTest extends BaseCMISWebScriptTest // retrieve checkouts within scope of test checkout folder Service repository = getRepository(); assertNotNull(repository); - IRI checkedoutHREF = getCheckedOutCollection(getRepository()); + IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository())); Map args = new HashMap(); args.put("folderId", scopeId); Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args); @@ -664,7 +708,7 @@ public class CMISTest extends BaseCMISWebScriptTest assertNotNull(documentXML); // checkout - IRI checkedoutHREF = getCheckedOutCollection(getRepository()); + IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository())); Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201, getAtomValidator()); assertNotNull(pwcRes); String pwcXml = pwcRes.getContentAsString(); @@ -703,7 +747,7 @@ public class CMISTest extends BaseCMISWebScriptTest assertNotNull(xml); // checkout - IRI checkedoutHREF = getCheckedOutCollection(getRepository()); + IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository())); Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator()); assertNotNull(pwcRes); String pwcXml = pwcRes.getContentAsString(); @@ -748,7 +792,7 @@ public class CMISTest extends BaseCMISWebScriptTest assertNotNull(xml); // checkout - IRI checkedoutHREF = getCheckedOutCollection(getRepository()); + IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository())); Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator()); assertNotNull(pwcRes); Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null); @@ -841,7 +885,7 @@ public class CMISTest extends BaseCMISWebScriptTest assertNotNull(xml); // checkout - IRI checkedoutHREF = getCheckedOutCollection(getRepository()); + IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository())); Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator()); assertNotNull(pwcRes); Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null); @@ -903,7 +947,7 @@ public class CMISTest extends BaseCMISWebScriptTest String xml = documentRes.getContentAsString(); assertNotNull(xml); - IRI checkedoutHREF = getCheckedOutCollection(getRepository()); + IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository())); for (int i = 0; i < NUMBER_OF_VERSIONS; i++) { // checkout @@ -948,7 +992,7 @@ public class CMISTest extends BaseCMISWebScriptTest public void testGetAllTypeDefinitions() throws Exception { - IRI typesHREF = getTypesCollection(getRepository()); + IRI typesHREF = getTypesCollection(getWorkspace(getRepository())); Feed types = getFeed(typesHREF); assertNotNull(types); Feed typesWithProps = getFeed(typesHREF); @@ -966,7 +1010,7 @@ public class CMISTest extends BaseCMISWebScriptTest public void testGetHierarchyTypeDefinitions() throws Exception { - IRI typesHREF = getTypesCollection(getRepository()); + IRI typesHREF = getTypesCollection(getWorkspace(getRepository())); Map args = new HashMap(); args.put("type", "FOLDER_OBJECT_TYPE"); args.put("includePropertyDefinitions", "true"); @@ -1027,14 +1071,14 @@ public class CMISTest extends BaseCMISWebScriptTest throws Exception { // retrieve query collection - IRI queryHREF = getQueryCollection(getRepository()); + IRI queryHREF = getQueryCollection(getWorkspace(getRepository())); // retrieve test folder for query Entry testFolder = createTestFolder("testQuery"); CMISProperties testFolderProps = testFolder.getExtension(CMISConstants.PROPERTIES); Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN); - // create documents query + // create documents to query Entry document1 = createDocument(childrenLink.getHref(), "apple1"); assertNotNull(document1); CMISProperties document1Props = document1.getExtension(CMISConstants.PROPERTIES); @@ -1046,20 +1090,22 @@ public class CMISTest extends BaseCMISWebScriptTest assertNotNull(document2Props); Entry document3 = createDocument(childrenLink.getHref(), "banana1"); assertNotNull(document3); - - // TODO: query based on query capabilities + + // retrieve query request document String queryDoc = loadString("/cmis/rest/query.cmissqlquery.xml"); + // TODO: Enable XSD Validation when cmis:propertyXXX mapping is sorted in spec + { // construct structured query - String query = "SELECT OBJECT_ID, OBJECT_TYPE_ID, NAME FROM DOCUMENT_OBJECT_TYPE " + + String query = "SELECT * FROM DOCUMENT_OBJECT_TYPE " + "WHERE IN_FOLDER('" + testFolderProps.getObjectId() + "') " + "AND NAME = 'apple1'"; String queryReq = queryDoc.replace("${STATEMENT}", query); queryReq = queryReq.replace("${PAGESIZE}", "5"); // issue structured query - Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), "application/cmisrequest+xml;type=query"), 200, getAtomValidator()); + Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), "application/cmisrequest+xml;type=query"), 200); assertNotNull(queryRes); Feed queryFeed = abdera.parseFeed(new StringReader(queryRes.getContentAsString()), null); assertNotNull(queryFeed); @@ -1080,7 +1126,7 @@ public class CMISTest extends BaseCMISWebScriptTest queryReq = queryReq.replace("${PAGESIZE}", "5"); // issue fulltext query - Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), "application/cmisrequest+xml;type=query"), 200, getAtomValidator()); + Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), "application/cmisrequest+xml;type=query"), 200); assertNotNull(queryRes); Feed queryFeed = abdera.parseFeed(new StringReader(queryRes.getContentAsString()), null); assertNotNull(queryFeed); @@ -1097,13 +1143,13 @@ public class CMISTest extends BaseCMISWebScriptTest // construct fulltext and structured query String query = "SELECT OBJECT_ID, OBJECT_TYPE_ID, NAME FROM DOCUMENT_OBJECT_TYPE " + "WHERE IN_FOLDER('" + testFolderProps.getObjectId() + "') " + - "AND NAME = 'apple1'" + + "AND NAME = 'apple1' " + "AND CONTAINS('test content')"; String queryReq = queryDoc.replace("${STATEMENT}", query); queryReq = queryReq.replace("${PAGESIZE}", "5"); // issue structured query - Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), "application/cmisrequest+xml;type=query"), 200, getAtomValidator()); + Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), "application/cmisrequest+xml;type=query"), 200); assertNotNull(queryRes); Feed queryFeed = abdera.parseFeed(new StringReader(queryRes.getContentAsString()), null); assertNotNull(queryFeed); diff --git a/source/java/org/alfresco/repo/cmis/rest/TestRemoteCMIS.java b/source/java/org/alfresco/repo/cmis/rest/TestRemoteCMIS.java index 082255a9f2..2a6a2c8273 100644 --- a/source/java/org/alfresco/repo/cmis/rest/TestRemoteCMIS.java +++ b/source/java/org/alfresco/repo/cmis/rest/TestRemoteCMIS.java @@ -35,29 +35,6 @@ import junit.textui.TestRunner; */ public class TestRemoteCMIS extends CMISTest { - // remote CMIS server - private static String repositoryUrl = "http://localhost:8080/alfresco/service/api/repository"; - private static String username = "admin"; - private static String password = "admin"; - private static boolean argsAsHeaders = false; - - - @Override - protected void setUp() throws Exception - { - if (repositoryUrl != null) - { - setRepositoryUrl(repositoryUrl); - RemoteServer server = new RemoteServer(); - server.username = username; - server.password = password; - setRemoteServer(server); - } - - setArgsAsHeaders(argsAsHeaders); - - super.setUp(); - } /** * Execute Unit Tests as client to remote CMIS Server @@ -70,6 +47,8 @@ public class TestRemoteCMIS extends CMISTest */ public static void main(String[] args) { + remote = true; + if (args.length > 0) { repositoryUrl = args[0]; @@ -88,7 +67,7 @@ public class TestRemoteCMIS extends CMISTest String params = "both"; if (args.length > 2) { - String[] paramSegment = args[1].split("="); + String[] paramSegment = args[2].split("="); if (paramSegment[0].equalsIgnoreCase("params")) { params = paramSegment[1].toLowerCase(); diff --git a/source/java/org/alfresco/repo/cmis/ws/CMISPropNamesMapping.java b/source/java/org/alfresco/repo/cmis/ws/CMISPropNamesMapping.java deleted file mode 100755 index db5d2af59d..0000000000 --- a/source/java/org/alfresco/repo/cmis/ws/CMISPropNamesMapping.java +++ /dev/null @@ -1,57 +0,0 @@ - -package org.alfresco.repo.cmis.ws; - -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.cmis.dictionary.CMISMapping; - -/** - * Mappings of CMIS properties to names in response - * - * @author Dmitry Lazurkin - * - */ -public class CMISPropNamesMapping -{ - private static Map cmisPropertiesNamesMapping = new HashMap(); - - static - { - cmisPropertiesNamesMapping.put(CMISMapping.PROP_IS_IMMUTABLE, "isImmutable"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_IS_LATEST_VERSION, "isLatestVersion"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_IS_MAJOR_VERSION, "isMajorVersion"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_IS_LATEST_MAJOR_VERSION, "isLatestMajorVersion"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_SERIES_IS_CHECKED_OUT, "versionSeriesIsCheckedOut"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_CREATION_DATE, "creationDate"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_LAST_MODIFICATION_DATE, "lastModificationDate"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_OBJECT_ID, "objectID"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_SERIES_ID, "versionSeriesID"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_ID, "versionSeriesCheckedOutID"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_LENGTH, "contentStreamLength"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_NAME, "name"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_OBJECT_TYPE_ID, "objectTypeID"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_CREATED_BY, "createdBy"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_LAST_MODIFIED_BY, "lastModifiedBy"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_MIME_TYPE, "contentStreamMimeType"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_FILENAME, "contentStreamFileName"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_LABEL, "versionLabel"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_BY, "versionSeriesCheckedOutBy"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_CHECKIN_COMMENT, "checkinComment"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_URI, "contentStreamURI"); - cmisPropertiesNamesMapping.put(CMISMapping.PROP_PARENT, "parent"); - } - - /** - * Get property name in response - * - * @param internalName internal property name - * @return property name in response - */ - public static String getResponsePropertyName(String internalName) - { - //return cmisPropertiesNamesMapping.get(internalName); - return internalName; - } - -} diff --git a/source/java/org/alfresco/repo/cmis/ws/DMAbstractServicePort.java b/source/java/org/alfresco/repo/cmis/ws/DMAbstractServicePort.java index e4957ae887..8c652624e4 100644 --- a/source/java/org/alfresco/repo/cmis/ws/DMAbstractServicePort.java +++ b/source/java/org/alfresco/repo/cmis/ws/DMAbstractServicePort.java @@ -36,6 +36,7 @@ import javax.xml.datatype.XMLGregorianCalendar; import org.alfresco.cmis.CMISService; import org.alfresco.cmis.dictionary.CMISDictionaryService; import org.alfresco.cmis.dictionary.CMISMapping; +import org.alfresco.cmis.property.CMISPropertyNameMapping; import org.alfresco.cmis.property.CMISPropertyService; import org.alfresco.cmis.search.CMISQueryService; import org.alfresco.error.AlfrescoRuntimeException; @@ -107,7 +108,7 @@ public class DMAbstractServicePort if (filter.allow(name) && value != null) { PropertyBooleanType propBoolean = new PropertyBooleanType(); - propBoolean.setName(CMISPropNamesMapping.getResponsePropertyName(name)); + propBoolean.setName(CMISPropertyNameMapping.getWebServiceName(name)); propBoolean.setValue((Boolean) value); properties.getPropertyBoolean().add(propBoolean); } @@ -119,7 +120,7 @@ public class DMAbstractServicePort if (filter.allow(name) && value != null) { PropertyDateTimeType propDateTime = new PropertyDateTimeType(); - propDateTime.setName(CMISPropNamesMapping.getResponsePropertyName(name)); + propDateTime.setName(CMISPropertyNameMapping.getWebServiceName(name)); propDateTime.setValue(convert((Date) value)); properties.getPropertyDateTime().add(propDateTime); } @@ -131,7 +132,7 @@ public class DMAbstractServicePort if (filter.allow(name) && value != null) { PropertyIDType propID = new PropertyIDType(); - propID.setName(CMISPropNamesMapping.getResponsePropertyName(name)); + propID.setName(CMISPropertyNameMapping.getWebServiceName(name)); propID.setValue(value.toString()); properties.getPropertyID().add(propID); } @@ -143,7 +144,7 @@ public class DMAbstractServicePort if (filter.allow(name) && value != null) { PropertyIntegerType propInteger = new PropertyIntegerType(); - propInteger.setName(CMISPropNamesMapping.getResponsePropertyName(name)); + propInteger.setName(CMISPropertyNameMapping.getWebServiceName(name)); propInteger.setValue(BigInteger.valueOf((Long) value)); properties.getPropertyInteger().add(propInteger); } @@ -155,7 +156,7 @@ public class DMAbstractServicePort if (filter.allow(name) && value != null) { PropertyStringType propString = new PropertyStringType(); - propString.setName(CMISPropNamesMapping.getResponsePropertyName(name)); + propString.setName(CMISPropertyNameMapping.getWebServiceName(name)); propString.setValue(value.toString()); properties.getPropertyString().add(propString); } @@ -178,7 +179,7 @@ public class DMAbstractServicePort if (filter.allow(name) && value != null) { PropertyURIType propString = new PropertyURIType(); - propString.setName(CMISPropNamesMapping.getResponsePropertyName(name)); + propString.setName(CMISPropertyNameMapping.getWebServiceName(name)); propString.setValue(value.toString()); properties.getPropertyURI().add(propString); } diff --git a/source/java/org/alfresco/repo/cmis/ws/DMRepositoryServicePort.java b/source/java/org/alfresco/repo/cmis/ws/DMRepositoryServicePort.java index 5fc172fa1d..e49f3a213a 100644 --- a/source/java/org/alfresco/repo/cmis/ws/DMRepositoryServicePort.java +++ b/source/java/org/alfresco/repo/cmis/ws/DMRepositoryServicePort.java @@ -205,7 +205,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re objectTypeDefinitionType.setObjectTypeID(typeDefinition.getObjectTypeId().getTypeId()); objectTypeDefinitionType.setObjectTypeQueryName(typeDefinition.getObjectTypeQueryName()); objectTypeDefinitionType.setObjectTypeDisplayName(typeDefinition.getObjectTypeDisplayName()); - objectTypeDefinitionType.setParentTypeID(typeDefinition.getParentTypeId().getTypeId()); + objectTypeDefinitionType.setParentTypeID(typeDefinition.getParentTypeId() == null ? null : typeDefinition.getParentTypeId().getTypeId()); objectTypeDefinitionType.setRootTypeQueryName(typeDefinition.getRootTypeQueryName()); objectTypeDefinitionType.setDescription(typeDefinition.getDescription()); objectTypeDefinitionType.setCreatable(typeDefinition.isCreatable()); diff --git a/source/java/org/apache/abdera/ext/cmis/CMISConstants.java b/source/java/org/apache/abdera/ext/cmis/CMISConstants.java index 49d1fceefa..88c9189d63 100644 --- a/source/java/org/apache/abdera/ext/cmis/CMISConstants.java +++ b/source/java/org/apache/abdera/ext/cmis/CMISConstants.java @@ -43,6 +43,9 @@ public interface CMISConstants { public static final String CMIS_200805_NS = "http://www.cmis.org/2008/05"; + // CMIS Service Document + public static final QName COLLECTION_TYPE = new QName(CMIS_200805_NS, "collectionType"); + // CMIS Repository Info public static final QName REPOSITORY_INFO = new QName(CMIS_200805_NS, "repositoryInfo"); public static final QName REPOSITORY_ID = new QName(CMIS_200805_NS, "repositoryId"); diff --git a/source/test-resources/cmis/rest/createdocument.atomentry.xml b/source/test-resources/cmis/rest/createdocument.atomentry.xml index 09b8183126..2549bf844a 100644 --- a/source/test-resources/cmis/rest/createdocument.atomentry.xml +++ b/source/test-resources/cmis/rest/createdocument.atomentry.xml @@ -4,6 +4,6 @@ ${NAME} (summary) test content ${NAME} - document + document diff --git a/source/test-resources/cmis/rest/createdocument2.atomentry.xml b/source/test-resources/cmis/rest/createdocument2.atomentry.xml new file mode 100644 index 0000000000..73f3396ac4 --- /dev/null +++ b/source/test-resources/cmis/rest/createdocument2.atomentry.xml @@ -0,0 +1,8 @@ + + onesentence.txt + MQ== + + Document + onesentence.txt + + \ No newline at end of file diff --git a/source/test-resources/cmis/rest/createdocumentBase64.atomentry.xml b/source/test-resources/cmis/rest/createdocumentBase64.atomentry.xml index 8d0aaca162..b2d3120053 100644 --- a/source/test-resources/cmis/rest/createdocumentBase64.atomentry.xml +++ b/source/test-resources/cmis/rest/createdocumentBase64.atomentry.xml @@ -14,6 +14,6 @@ aXQgc2hvdWxkIGJlIGJhc2U2NCBlbmNvZGVkIGluIHRoZSBhdG9tIGVudHJ5Lg== - document + document diff --git a/source/test-resources/cmis/rest/createfolder.atomentry.xml b/source/test-resources/cmis/rest/createfolder.atomentry.xml index 014d4c1fff..e0384743da 100644 --- a/source/test-resources/cmis/rest/createfolder.atomentry.xml +++ b/source/test-resources/cmis/rest/createfolder.atomentry.xml @@ -3,6 +3,6 @@ ${NAME} ${NAME} (summary) - folder + folder diff --git a/source/test/java/org/alfresco/repo/cmis/ws/BaseServicePortTest.java b/source/test/java/org/alfresco/repo/cmis/ws/BaseServicePortTest.java index 8658562eff..d9c5ebef7f 100644 --- a/source/test/java/org/alfresco/repo/cmis/ws/BaseServicePortTest.java +++ b/source/test/java/org/alfresco/repo/cmis/ws/BaseServicePortTest.java @@ -28,6 +28,7 @@ import javax.transaction.UserTransaction; import org.alfresco.cmis.CMISService; import org.alfresco.cmis.dictionary.CMISMapping; +import org.alfresco.cmis.property.CMISPropertyNameMapping; import org.alfresco.model.ContentModel; import org.alfresco.repo.node.integrity.IntegrityChecker; import org.alfresco.repo.security.authentication.AuthenticationComponent; @@ -115,13 +116,13 @@ public class BaseServicePortTest extends AbstractDependencyInjectionSpringContex @Override protected String[] getConfigLocations() { - return new String[] { "classpath:alfresco/application-context.xml", "classpath:alfresco/test-cmis-context.xml" }; + return new String[] { "classpath:alfresco/application-context.xml", "classpath:test-cmis-context.xml" }; } protected String getPropertyIDValue(PropertiesType properties, String propertyName) { String result = null; - String realPropertyName = CMISPropNamesMapping.getResponsePropertyName(propertyName); + String realPropertyName = CMISPropertyNameMapping.getWebServiceName(propertyName); for (PropertyIDType property : properties.getPropertyID()) { @@ -138,7 +139,7 @@ public class BaseServicePortTest extends AbstractDependencyInjectionSpringContex protected String getPropertyStringValue(PropertiesType properties, String propertyName) { String result = null; - String realPropertyName = CMISPropNamesMapping.getResponsePropertyName(propertyName); + String realPropertyName = CMISPropertyNameMapping.getWebServiceName(propertyName); for (PropertyStringType property : properties.getPropertyString()) { @@ -155,7 +156,7 @@ public class BaseServicePortTest extends AbstractDependencyInjectionSpringContex protected boolean getPropertyBooleanValue(PropertiesType properties, String propertyName) { boolean result = false; - String realPropertyName = CMISPropNamesMapping.getResponsePropertyName(propertyName); + String realPropertyName = CMISPropertyNameMapping.getWebServiceName(propertyName); for (PropertyBooleanType property : properties.getPropertyBoolean()) { diff --git a/source/test/java/org/alfresco/repo/cmis/ws/DMRepositoryServicePortTest.java b/source/test/java/org/alfresco/repo/cmis/ws/DMRepositoryServicePortTest.java index 20939b3a89..89f7decac4 100644 --- a/source/test/java/org/alfresco/repo/cmis/ws/DMRepositoryServicePortTest.java +++ b/source/test/java/org/alfresco/repo/cmis/ws/DMRepositoryServicePortTest.java @@ -68,4 +68,11 @@ public class DMRepositoryServicePortTest extends BaseServicePortTest assertTrue(capabilities.isCapabilityMultifiling() && capabilities.isCapabilityPWCUpdatable()); assertFalse(capabilities.isCapabilityUnfiling() && capabilities.isCapabilityVersionSpecificFiling()); } + + public void testGetTypeDefinition() throws Exception + { + List repositories = repositoryServicePort.getRepositories(); + repositoryServicePort.getTypeDefinition(repositories.get(0).getRepositoryID(), "DOCUMENT_OBJECT_TYPE"); + } + }