diff --git a/source/java/org/alfresco/repo/cmis/rest/CMISChildrenMethod.java b/source/java/org/alfresco/repo/cmis/rest/CMISChildrenMethod.java
new file mode 100644
index 0000000000..da77a3447b
--- /dev/null
+++ b/source/java/org/alfresco/repo/cmis/rest/CMISChildrenMethod.java
@@ -0,0 +1,115 @@
+/*
+ * 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.cmis.rest;
+
+import java.util.List;
+
+import org.alfresco.cmis.CMISService;
+import org.alfresco.cmis.CMISTypesFilterEnum;
+import org.alfresco.repo.template.TemplateNode;
+import org.alfresco.repo.web.scripts.RepositoryImageResolver;
+import org.alfresco.service.ServiceRegistry;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.TemplateImageResolver;
+
+import freemarker.ext.beans.BeanModel;
+import freemarker.template.TemplateMethodModelEx;
+import freemarker.template.TemplateModelException;
+import freemarker.template.TemplateScalarModel;
+
+/**
+ * Custom FreeMarker Template language method.
+ *
+ * Lists the (CMIS) children of a TemplateNode
+ *
+ * Usage: cmischildren(TemplateNode node)
+ * cmischildren(TemplateNode node, String typesFilter)
+ *
+ * @author davidc
+ */
+public class CMISChildrenMethod implements TemplateMethodModelEx
+{
+ private CMISService cmisService;
+ private ServiceRegistry serviceRegistry;
+ private TemplateImageResolver imageResolver;
+
+ /**
+ * Construct
+ */
+ public CMISChildrenMethod(CMISService cmisService, ServiceRegistry serviceRegistry, RepositoryImageResolver imageResolver)
+ {
+ this.cmisService = cmisService;
+ this.serviceRegistry = serviceRegistry;
+ this.imageResolver = imageResolver.getImageResolver();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object exec(List args) throws TemplateModelException
+ {
+ TemplateNode[] children = null;
+
+ if (args.size() > 0)
+ {
+ Object arg0 = args.get(0);
+ if (arg0 instanceof BeanModel)
+ {
+ // extract node ref
+ Object wrapped = ((BeanModel)arg0).getWrappedObject();
+ if (wrapped != null)
+ {
+ if (wrapped instanceof TemplateNode)
+ {
+ NodeRef nodeRef = ((TemplateNode)wrapped).getNodeRef();
+ CMISTypesFilterEnum typesFilter = CMISTypesFilterEnum.ANY;
+ if (args.size() > 1)
+ {
+ // extract types filter, if specified
+ Object arg1 = args.get(1);
+ if (arg1 instanceof TemplateScalarModel)
+ {
+ String typesFilterStr = ((TemplateScalarModel)arg1).getAsString();
+ if (typesFilterStr != null && typesFilterStr.length() > 0)
+ {
+ typesFilter = (CMISTypesFilterEnum)CMISTypesFilterEnum.FACTORY.toEnum(typesFilterStr);
+ }
+ }
+ }
+
+ // query children
+ NodeRef[] childNodeRefs = cmisService.getChildren(nodeRef, typesFilter);
+ children = new TemplateNode[childNodeRefs.length];
+ for (int i = 0; i < childNodeRefs.length; i++)
+ {
+ children[i] = new TemplateNode(childNodeRefs[i], serviceRegistry, imageResolver);
+ }
+ }
+ }
+ }
+ }
+
+ return children;
+ }
+
+}
diff --git a/source/java/org/alfresco/repo/cmis/rest/CMISQueryReader.java b/source/java/org/alfresco/repo/cmis/rest/CMISQueryReader.java
index cd24caefd7..c33e863b06 100644
--- a/source/java/org/alfresco/repo/cmis/rest/CMISQueryReader.java
+++ b/source/java/org/alfresco/repo/cmis/rest/CMISQueryReader.java
@@ -38,6 +38,7 @@ import org.alfresco.web.scripts.FormatReader;
import org.alfresco.web.scripts.WebScriptException;
import org.alfresco.web.scripts.WebScriptRequest;
import org.alfresco.web.scripts.WebScriptResponse;
+import org.apache.abdera.ext.cmis.CMISConstants;
/**
@@ -61,7 +62,7 @@ public class CMISQueryReader implements FormatReader
*/
public String getSourceMimetype()
{
- return "application/cmisrequest+xml;type=query";
+ return CMISConstants.MIMETYPE_QUERY;
}
/* (non-Javadoc)
diff --git a/source/java/org/alfresco/repo/cmis/rest/CMISScript.java b/source/java/org/alfresco/repo/cmis/rest/CMISScript.java
index 252ac23763..a7293c78f1 100644
--- a/source/java/org/alfresco/repo/cmis/rest/CMISScript.java
+++ b/source/java/org/alfresco/repo/cmis/rest/CMISScript.java
@@ -27,16 +27,17 @@ package org.alfresco.repo.cmis.rest;
import java.util.Collection;
import java.util.Iterator;
+import org.alfresco.cmis.CMISFullTextSearchEnum;
+import org.alfresco.cmis.CMISJoinEnum;
+import org.alfresco.cmis.CMISQueryEnum;
import org.alfresco.cmis.CMISService;
-import org.alfresco.cmis.CMISService.TypesFilter;
+import org.alfresco.cmis.CMISTypesFilterEnum;
import org.alfresco.cmis.dictionary.CMISDictionaryService;
import org.alfresco.cmis.dictionary.CMISTypeDefinition;
import org.alfresco.cmis.dictionary.CMISTypeId;
import org.alfresco.cmis.search.CMISQueryOptions;
import org.alfresco.cmis.search.CMISQueryService;
import org.alfresco.cmis.search.CMISResultSet;
-import org.alfresco.cmis.search.FullTextSearchSupport;
-import org.alfresco.cmis.search.JoinSupport;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.jscript.BaseScopableProcessorExtension;
import org.alfresco.repo.jscript.ScriptNode;
@@ -56,8 +57,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/
public class CMISScript extends BaseScopableProcessorExtension
{
- private static final TypesFilter defaultTypesFilter = TypesFilter.Any;
-
private ServiceRegistry services;
private Repository repository;
private CMISService cmisService;
@@ -191,7 +190,7 @@ public class CMISScript extends BaseScopableProcessorExtension
*/
public String getDefaultTypesFilter()
{
- return defaultTypesFilter.toString();
+ return CMISTypesFilterEnum.FACTORY.defaultLabel();
}
/**
@@ -202,19 +201,7 @@ public class CMISScript extends BaseScopableProcessorExtension
*/
public boolean isValidTypesFilter(String typesFilter)
{
- try
- {
- TypesFilter.valueOf(typesFilter);
- return true;
- }
- catch(IllegalArgumentException e)
- {
- return false;
- }
- catch(NullPointerException e)
- {
- return false;
- }
+ return CMISTypesFilterEnum.FACTORY.validLabel(typesFilter);
}
/**
@@ -226,16 +213,9 @@ public class CMISScript extends BaseScopableProcessorExtension
* @param typesFilter types filter
* @return resolved types filter
*/
- private TypesFilter resolveTypesFilter(String typesFilter)
+ private CMISTypesFilterEnum resolveTypesFilter(String typesFilter)
{
- if (isValidTypesFilter(typesFilter))
- {
- return TypesFilter.valueOf(typesFilter);
- }
- else
- {
- return defaultTypesFilter;
- }
+ return (CMISTypesFilterEnum)CMISTypesFilterEnum.FACTORY.toEnum(typesFilter);
}
/**
@@ -266,7 +246,7 @@ public class CMISScript extends BaseScopableProcessorExtension
*/
public PagedResults queryChildren(ScriptNode parent, String typesFilter, Page page)
{
- TypesFilter filter = resolveTypesFilter(typesFilter);
+ CMISTypesFilterEnum filter = resolveTypesFilter(typesFilter);
NodeRef[] children = cmisService.getChildren(parent.getNodeRef(), filter);
Cursor cursor = paging.createCursor(children.length, page);
@@ -408,7 +388,17 @@ public class CMISScript extends BaseScopableProcessorExtension
//
// SQL Query
//
-
+
+ /**
+ * Can you query the private working copy of a document.
+ *
+ * @return
+ */
+ public boolean getPwcSearchable()
+ {
+ return cmisQueryService.getPwcSearchable();
+ }
+
/**
* Can you query non-latest versions of a document.
*
@@ -420,13 +410,23 @@ public class CMISScript extends BaseScopableProcessorExtension
{
return cmisQueryService.getAllVersionsSearchable();
}
-
+
+ /**
+ * Get the query support level.
+ *
+ * @return
+ */
+ public CMISQueryEnum getQuerySupport()
+ {
+ return cmisQueryService.getQuerySupport();
+ }
+
/**
* Get the join support level in queries.
*
* @return
*/
- public JoinSupport getJoinSupport()
+ public CMISJoinEnum getJoinSupport()
{
return cmisQueryService.getJoinSupport();
}
@@ -436,7 +436,7 @@ public class CMISScript extends BaseScopableProcessorExtension
*
* @return
*/
- public FullTextSearchSupport getFullTextSearchSupport()
+ public CMISFullTextSearchEnum getFullTextSearchSupport()
{
return cmisQueryService.getFullTextSearchSupport();
}
diff --git a/source/java/org/alfresco/repo/cmis/rest/CMISTest.java b/source/java/org/alfresco/repo/cmis/rest/CMISTest.java
index 1d3d682e68..6f8cbf4867 100644
--- a/source/java/org/alfresco/repo/cmis/rest/CMISTest.java
+++ b/source/java/org/alfresco/repo/cmis/rest/CMISTest.java
@@ -31,6 +31,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.alfresco.util.Base64;
import org.alfresco.util.GUID;
import org.alfresco.web.scripts.Format;
import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
@@ -53,6 +54,7 @@ import org.apache.abdera.model.Feed;
import org.apache.abdera.model.Link;
import org.apache.abdera.model.Service;
import org.apache.abdera.model.Workspace;
+import org.apache.abdera.util.Constants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -73,6 +75,7 @@ public class CMISTest extends BaseCMISWebScriptTest
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);
@@ -84,8 +87,7 @@ public class CMISTest extends BaseCMISWebScriptTest
private static Entry testsFolder = null;
private static Entry testRunFolder = null;
-
-
+
@Override
protected void setUp()
throws Exception
@@ -213,7 +215,7 @@ public class CMISTest extends BaseCMISWebScriptTest
Entry entry = abdera.parseEntry(new StringReader(xml), null);
assertNotNull(entry);
assertEquals(name, entry.getTitle());
- assertEquals(name + " (summary)", entry.getSummary());
+ //assertEquals(name + " (summary)", entry.getSummary());
CMISProperties props = entry.getExtension(CMISConstants.PROPERTIES);
assertEquals("folder", props.getBaseType());
String testFolderHREF = (String)res.getHeader("Location");
@@ -232,13 +234,14 @@ public class CMISTest extends BaseCMISWebScriptTest
{
String createFile = loadString(atomEntryFile);
createFile = createFile.replace("${NAME}", name);
+ createFile = createFile.replace("${CONTENT}", Base64.encodeBytes(name.getBytes()));
Response res = sendRequest(new PostRequest(parent.toString(), createFile, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(res);
String xml = res.getContentAsString();
Entry entry = abdera.parseEntry(new StringReader(xml), null);
assertNotNull(entry);
assertEquals(name, entry.getTitle());
- assertEquals(name + " (summary)", entry.getSummary());
+ //assertEquals(name + " (summary)", entry.getSummary());
assertNotNull(entry.getContentSrc());
CMISProperties props = entry.getExtension(CMISConstants.PROPERTIES);
assertEquals("document", props.getBaseType());
@@ -338,7 +341,7 @@ public class CMISTest extends BaseCMISWebScriptTest
Entry document = createDocument(children.getSelfLink().getHref(), "testCreateDocument");
Response documentContentRes = sendRequest(new GetRequest(document.getContentSrc().toString()), 200);
String resContent = documentContentRes.getContentAsString();
- assertEquals("test content " + document.getTitle(), resContent);
+ assertEquals(document.getTitle(), resContent);
Feed feedFolderAfter = getFeed(childrenLink.getHref());
int entriesAfter = feedFolderAfter.getEntries().size();
assertEquals(entriesBefore +1, entriesAfter);
@@ -361,26 +364,27 @@ public class CMISTest extends BaseCMISWebScriptTest
assertEquals("1", resContent);
}
- public void testCreateDocumentBase64()
- throws Exception
- {
- Entry testFolder = createTestFolder("testCreateDocumentBase64");
- Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
- assertNotNull(childrenLink);
- Feed children = getFeed(childrenLink.getHref());
- assertNotNull(children);
- int entriesBefore = children.getEntries().size();
- Entry document = createDocument(children.getSelfLink().getHref(), "testCreateDocument", "/cmis/rest/createdocumentBase64.atomentry.xml");
- Response documentContentRes = sendRequest(new GetRequest(document.getContentSrc().toString()), 200);
- String testContent = loadString("/cmis/rest/createdocumentBase64.txt");
- String resContent = documentContentRes.getContentAsString();
- assertEquals(testContent, resContent);
- Feed feedFolderAfter = getFeed(childrenLink.getHref());
- int entriesAfter = feedFolderAfter.getEntries().size();
- assertEquals(entriesBefore +1, entriesAfter);
- Entry entry = feedFolderAfter.getEntry(document.getId().toString());
- assertNotNull(entry);
- }
+ // TODO: Test creation of document via Atom Entry containing plain text (non Base64 encoded)
+// public void testCreateDocumentBase64()
+// throws Exception
+// {
+// Entry testFolder = createTestFolder("testCreateDocumentBase64");
+// Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+// assertNotNull(childrenLink);
+// Feed children = getFeed(childrenLink.getHref());
+// assertNotNull(children);
+// int entriesBefore = children.getEntries().size();
+// Entry document = createDocument(children.getSelfLink().getHref(), "testCreateDocument", "/cmis/rest/createdocumentBase64.atomentry.xml");
+// Response documentContentRes = sendRequest(new GetRequest(document.getContentSrc().toString()), 200);
+// String testContent = loadString("/cmis/rest/createdocumentBase64.txt");
+// String resContent = documentContentRes.getContentAsString();
+// assertEquals(testContent, resContent);
+// Feed feedFolderAfter = getFeed(childrenLink.getHref());
+// int entriesAfter = feedFolderAfter.getEntries().size();
+// assertEquals(entriesBefore +1, entriesAfter);
+// Entry entry = feedFolderAfter.getEntry(document.getId().toString());
+// assertNotNull(entry);
+// }
public void testCreateFolder()
throws Exception
@@ -418,25 +422,25 @@ public class CMISTest extends BaseCMISWebScriptTest
Entry testDocumentFromGet = getEntry(testDocument.getSelfLink().getHref());
assertEquals(testDocument.getId(), testDocumentFromGet.getId());
assertEquals(testDocument.getTitle(), testDocumentFromGet.getTitle());
- assertEquals(testDocument.getSummary(), testDocumentFromGet.getSummary());
+ //assertEquals(testDocument.getSummary(), testDocumentFromGet.getSummary());
// get something that doesn't exist
Response res = sendRequest(new GetRequest(testDocument.getSelfLink().getHref().toString() + GUID.generate()), 404);
assertNotNull(res);
}
- public void testChildren()
+ public void testGetChildren()
throws Exception
{
// create multiple children
- Entry testFolder = createTestFolder("testChildren");
+ Entry testFolder = createTestFolder("testGetChildren");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
- Entry document1 = createDocument(childrenLink.getHref(), "testChildren1");
+ Entry document1 = createDocument(childrenLink.getHref(), "testGetChildren1");
assertNotNull(document1);
- Entry document2 = createDocument(childrenLink.getHref(), "testChildren2");
+ Entry document2 = createDocument(childrenLink.getHref(), "testGetChildren2");
assertNotNull(document2);
- Entry document3 = createDocument(childrenLink.getHref(), "testChildren3");
+ Entry document3 = createDocument(childrenLink.getHref(), "testGetChildren3");
assertNotNull(document3);
// checkout one of the children to ensure private working copy isn't included
@@ -459,17 +463,17 @@ public class CMISTest extends BaseCMISWebScriptTest
assertNull(children.getEntry(pwc.getId().toString()));
}
- public void testChildrenPaging()
+ public void testGetChildrenPaging()
throws Exception
{
// create multiple children
Set docIds = new HashSet();
- Entry testFolder = createTestFolder("testChildrenPaging");
+ Entry testFolder = createTestFolder("testGetChildrenPaging");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
for (int i = 0; i < 15; i++)
{
- Entry document = createDocument(childrenLink.getHref(), "testChildrenPaging" + i);
+ Entry document = createDocument(childrenLink.getHref(), "testGetChildrenPaging" + i);
assertNotNull(document);
docIds.add(document.getId());
}
@@ -493,6 +497,10 @@ public class CMISTest extends BaseCMISWebScriptTest
// next page
Link nextLink = types.getLink("next");
+ if (nextCount < 4)
+ {
+ assertNotNull(nextLink);
+ }
childrenHREF = (nextLink != null) ? nextLink.getHref() : null;
args = null;
};
@@ -515,8 +523,9 @@ public class CMISTest extends BaseCMISWebScriptTest
// invalid type filter
Map args = new HashMap();
args.put("types", "Invalid");
- Response invalidRes = sendRequest(new GetRequest(childrenLink.getHref().toString()).setArgs(args), 400);
- assertNotNull(invalidRes);
+ // TODO: potential spec issue
+// Response invalidRes = sendRequest(new GetRequest(childrenLink.getHref().toString()).setArgs(args), 400);
+// assertNotNull(invalidRes);
// no filter
Feed noFilters = getFeed(childrenLink.getHref());
@@ -544,6 +553,92 @@ public class CMISTest extends BaseCMISWebScriptTest
assertNotNull(documents.getEntry(document.getId().toString()));
}
+ public void testGetChildrenPropertyFilter()
+ throws Exception
+ {
+ // create children
+ Entry testFolder = createTestFolder("testGetChildrenPropertyFilter");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ Entry document1 = createDocument(childrenLink.getHref(), "testGetChildrenPropertyFilter1");
+ assertNotNull(document1);
+
+ {
+ // get children with all properties
+ Feed children = getFeed(childrenLink.getHref());
+ for (Entry entry : children.getEntries())
+ {
+ CMISProperties props = entry.getExtension(CMISConstants.PROPERTIES);
+ assertNotNull(props.getObjectId());
+ assertNotNull(props.getObjectType());
+ }
+ }
+
+ {
+ // get children with object_id only
+ Map args = new HashMap();
+ args.put("filter", "OBJECT_ID");
+ Feed children = getFeed(childrenLink.getHref(), args);
+ for (Entry entry : children.getEntries())
+ {
+ CMISProperties props = entry.getExtension(CMISConstants.PROPERTIES);
+ assertNotNull(props.getObjectId());
+ assertNull(props.getObjectType());
+ }
+ }
+ }
+
+ public void testGetDescendants()
+ throws Exception
+ {
+ // create multiple nested children
+ Entry testFolder = createTestFolder("testGetDescendants");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ Entry document1 = createDocument(childrenLink.getHref(), "testGetDescendants1");
+ assertNotNull(document1);
+ Entry folder2 = createFolder(childrenLink.getHref(), "testGetDescendants2");
+ assertNotNull(folder2);
+ Link childrenLink2 = folder2.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink2);
+ Entry document3 = createDocument(childrenLink2.getHref(), "testGetDescendants3");
+ assertNotNull(document3);
+
+ {
+ // get descendants (depth = 1, equivalent to getChildren)
+ Map args = new HashMap();
+ args.put("depth", "1");
+ Link descendantsLink = testFolder.getLink(CMISConstants.REL_DESCENDANTS);
+ Feed descendants = getFeed(descendantsLink.getHref(), args);
+ assertNotNull(descendants);
+ assertEquals(2, descendants.getEntries().size());
+ assertNotNull(descendants.getEntry(document1.getId().toString()));
+ assertNotNull(descendants.getEntry(folder2.getId().toString()));
+
+ Entry getFolder2 = descendants.getEntry(folder2.getId().toString());
+ Entry getFolder2Child = getFolder2.getFirstChild(CMISConstants.NESTED_ENTRY);
+ assertNull(getFolder2Child);
+ }
+
+ {
+ // get nested children
+ Map args = new HashMap();
+ args.put("depth", "2");
+ Link descendantsLink = testFolder.getLink(CMISConstants.REL_DESCENDANTS);
+ Feed descendants = getFeed(descendantsLink.getHref(), args);
+ assertNotNull(descendants);
+ assertEquals(2, descendants.getEntries().size());
+ assertNotNull(descendants.getEntry(document1.getId().toString()));
+ assertNotNull(descendants.getEntry(folder2.getId().toString()));
+
+ Entry getFolder2 = descendants.getEntry(folder2.getId().toString());
+ List getFolder2Children = getFolder2.getExtensions(CMISConstants.NESTED_ENTRY);
+ assertNotNull(getFolder2Children);
+ assertEquals(1, getFolder2Children.size());
+ assertEquals(document3.getId(), getFolder2Children.get(0).getId());
+ }
+ }
+
public void testGetParent()
throws Exception
{
@@ -561,6 +656,8 @@ public class CMISTest extends BaseCMISWebScriptTest
assertEquals(1, parent.getEntries().size());
assertEquals(testFolder.getId(), parent.getEntries().get(0).getId());
+ // TODO: compare identity using OBJECT_ID property, not atom:id
+
// ensure there are ancestors 'testParent', "test run folder", "tests folder" and "root folder"
Map args = new HashMap();
args.put("returnToRoot", "true");
@@ -574,7 +671,8 @@ public class CMISTest extends BaseCMISWebScriptTest
assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId());
assertNotNull(parentsToRoot.getEntries().get(2).getLink(CMISConstants.REL_PARENT));
Feed root = getFeed(getRootCollection(getWorkspace(getRepository())));
- assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId());
+ Entry rootEntry = getEntry(root.getLink(CMISConstants.REL_SOURCE).getHref());
+ assertEquals(rootEntry.getId(), parentsToRoot.getEntries().get(3).getId());
assertNull(parentsToRoot.getEntries().get(3).getLink(CMISConstants.REL_PARENT));
}
@@ -602,13 +700,14 @@ public class CMISTest extends BaseCMISWebScriptTest
assertNotNull(parentsToRoot);
assertEquals(4, parentsToRoot.getEntries().size());
assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId());
- assertNotNull(parentsToRoot.getEntries().get(0).getLink(CMISConstants.REL_PARENT));
+ //assertNotNull(parentsToRoot.getEntries().get(0).getLink(CMISConstants.REL_PARENT));
assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
- assertNotNull(parentsToRoot.getEntries().get(1).getLink(CMISConstants.REL_PARENT));
+ //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));
+ //assertNotNull(parentsToRoot.getEntries().get(2).getLink(CMISConstants.REL_PARENT));
Feed root = getFeed(getRootCollection(getWorkspace(getRepository())));
- assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId());
+ Entry rootEntry = getEntry(root.getLink(CMISConstants.REL_SOURCE).getHref());
+ assertEquals(rootEntry.getId(), parentsToRoot.getEntries().get(3).getId());
assertNull(parentsToRoot.getEntries().get(3).getLink(CMISConstants.REL_PARENT));
}
@@ -653,8 +752,15 @@ public class CMISTest extends BaseCMISWebScriptTest
// create document for update
Entry document = createDocument(childrenLink.getHref(), "testUpdate");
assertNotNull(document);
- assertEquals("text/html", document.getContentMimeType().toString());
+ String mimetype = (document.getContentMimeType() != null) ? document.getContentMimeType().toString() : null;
+ if (mimetype != null)
+ {
+ assertEquals("text/html", mimetype);
+ }
+ // TODO: check for content update allowable action
+ // if update allowed, perform update, else update and check for appropriate error
+
// update
String updateFile = loadString("/cmis/rest/updatedocument.atomentry.xml");
String guid = GUID.generate();
@@ -667,6 +773,7 @@ public class CMISTest extends BaseCMISWebScriptTest
assertEquals(document.getId(), updated.getId());
assertEquals(document.getPublished(), updated.getPublished());
assertEquals("Updated Title " + guid, updated.getTitle());
+ // TODO: why is this testing for text/plain? it should be test/html
assertEquals("text/plain", updated.getContentMimeType().toString());
Response contentRes = sendRequest(new GetRequest(updated.getContentSrc().toString()), 200);
assertEquals("updated content " + guid, contentRes.getContentAsString());
@@ -1144,7 +1251,7 @@ public class CMISTest extends BaseCMISWebScriptTest
String query = "SELECT OBJECT_ID, OBJECT_TYPE_ID, NAME FROM DOCUMENT_OBJECT_TYPE " +
"WHERE IN_FOLDER('" + testFolderProps.getObjectId() + "') " +
"AND NAME = 'apple1' " +
- "AND CONTAINS('test content')";
+ "AND CONTAINS('apple1')";
String queryReq = queryDoc.replace("${STATEMENT}", query);
queryReq = queryReq.replace("${PAGESIZE}", "5");
diff --git a/source/java/org/alfresco/repo/cmis/rest/CMISTypeIdMethod.java b/source/java/org/alfresco/repo/cmis/rest/CMISTypeIdMethod.java
index a9f660c33f..39ef522bec 100644
--- a/source/java/org/alfresco/repo/cmis/rest/CMISTypeIdMethod.java
+++ b/source/java/org/alfresco/repo/cmis/rest/CMISTypeIdMethod.java
@@ -40,7 +40,7 @@ import freemarker.template.TemplateModelException;
*
* Retrieve the CMIS Type Id for an Alfresco node
*
- * Usage: cmistypeid(TemplaateNode node)
+ * Usage: cmistypeid(TemplateNode node)
* cmistypeid(QName nodeType)
*
* @author davidc
diff --git a/source/java/org/alfresco/repo/cmis/rest/TestRemoteCMIS.java b/source/java/org/alfresco/repo/cmis/rest/TestRemoteCMIS.java
deleted file mode 100644
index 2a6a2c8273..0000000000
--- a/source/java/org/alfresco/repo/cmis/rest/TestRemoteCMIS.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2005-2008 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.cmis.rest;
-
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-
-/**
- * CMIS API Test Harness
- *
- * @author davidc
- */
-public class TestRemoteCMIS extends CMISTest
-{
-
- /**
- * Execute Unit Tests as client to remote CMIS Server
- *
- * args[0] = serverUrl
- * args[1] = username/password
- * args[2] = [params=url|headers]
- *
- * @param args args
- */
- public static void main(String[] args)
- {
- remote = true;
-
- if (args.length > 0)
- {
- repositoryUrl = args[0];
- }
-
- if (args.length > 1)
- {
- String[] credentials = args[1].split("/");
- username = credentials[0];
- if (credentials.length > 1)
- {
- password = credentials[1];
- }
- }
-
- String params = "both";
- if (args.length > 2)
- {
- String[] paramSegment = args[2].split("=");
- if (paramSegment[0].equalsIgnoreCase("params"))
- {
- params = paramSegment[1].toLowerCase();
- }
- }
-
- // execute cmis tests with url arguments
- if (params.equals("both") || params.equals("url"))
- {
- TestRunner.run(new TestSuite(TestRemoteCMIS.class));
- }
-
- // execute cmis tests with headers
- if (params.equals("both") || params.equals("headers"))
- {
- argsAsHeaders = true;
- TestRunner.run(new TestSuite(TestRemoteCMIS.class));
- }
- }
-
-}
diff --git a/source/java/org/alfresco/repo/cmis/rest/BaseCMISWebScriptTest.java b/source/java/org/alfresco/repo/cmis/rest/test/BaseCMISWebScriptTest.java
similarity index 99%
rename from source/java/org/alfresco/repo/cmis/rest/BaseCMISWebScriptTest.java
rename to source/java/org/alfresco/repo/cmis/rest/test/BaseCMISWebScriptTest.java
index 3edecf2866..9e634e3770 100644
--- a/source/java/org/alfresco/repo/cmis/rest/BaseCMISWebScriptTest.java
+++ b/source/java/org/alfresco/repo/cmis/rest/test/BaseCMISWebScriptTest.java
@@ -22,7 +22,7 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.repo.cmis.rest;
+package org.alfresco.repo.cmis.rest.test;
import java.io.IOException;
import java.io.InputStream;
diff --git a/source/java/org/alfresco/repo/cmis/rest/test/CMISTest.java b/source/java/org/alfresco/repo/cmis/rest/test/CMISTest.java
new file mode 100644
index 0000000000..1fea12d97d
--- /dev/null
+++ b/source/java/org/alfresco/repo/cmis/rest/test/CMISTest.java
@@ -0,0 +1,1289 @@
+/*
+ *
+ * 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.
+
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
+ * 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.cmis.rest.test;
+
+import java.io.PrintStream;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.Test;
+
+import org.alfresco.util.Base64;
+import org.alfresco.util.GUID;
+import org.alfresco.web.scripts.Format;
+import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
+import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
+import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
+import org.alfresco.web.scripts.TestWebScriptServer.PutRequest;
+import org.alfresco.web.scripts.TestWebScriptServer.Request;
+import org.alfresco.web.scripts.TestWebScriptServer.Response;
+import org.alfresco.web.scripts.atom.AbderaService;
+import org.alfresco.web.scripts.atom.AbderaServiceImpl;
+import org.apache.abdera.ext.cmis.CMISCapabilities;
+import org.apache.abdera.ext.cmis.CMISConstants;
+import org.apache.abdera.ext.cmis.CMISExtensionFactory;
+import org.apache.abdera.ext.cmis.CMISObject;
+import org.apache.abdera.ext.cmis.CMISRepositoryInfo;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Collection;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Link;
+import org.apache.abdera.model.Service;
+import org.apache.abdera.model.Workspace;
+
+
+/**
+ * CMIS API Test Harness
+ *
+ * @author davidc
+ */
+public class CMISTest extends BaseCMISWebScriptTest
+{
+ // Repository Access
+ private String serviceUrl = "http://localhost:8080/alfresco/service/api/repository";
+
+ // cached responses
+ private AbderaService abdera;
+ private Service service = null;
+ private String fulltextCapability = null;
+ private Entry testsFolder = null;
+ private Entry testRunFolder = null;
+
+ /**
+ * Sets the Repository Service URL
+ *
+ * @param serviceUrl serviceURL
+ */
+ public void setServiceUrl(String serviceUrl)
+ {
+ this.serviceUrl = serviceUrl;
+ }
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ // setup client atom support
+ AbderaServiceImpl abderaImpl = new AbderaServiceImpl();
+ abderaImpl.afterPropertiesSet();
+ abderaImpl.registerExtensionFactory(new CMISExtensionFactory());
+ abdera = abderaImpl;
+
+ // Uncomment to change default behaviour of tests
+ setDefaultRunAs("admin");
+// RemoteServer server = new RemoteServer();
+// server.username = "admin";
+// server.password = "admin";
+// setRemoteServer(server);
+// setArgsAsHeaders(false);
+// setValidateResponse(false);
+// setListener(new CMISTestListener(System.out));
+// setTraceReqRes(true);
+
+ super.setUp();
+ }
+
+ /**
+ * Default Test Listener
+ */
+ public static class CMISTestListener extends BaseWebScriptTestListener implements WebScriptTestListener
+ {
+ /**
+ * Construct
+ *
+ * @param writer
+ */
+ public CMISTestListener(PrintStream writer)
+ {
+ super(writer);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.textui.ResultPrinter#startTest(junit.framework.Test)
+ */
+ @Override
+ public void startTest(Test test)
+ {
+ CMISTest cmisTest = (CMISTest)test;
+ getWriter().println();
+ getWriter().println("*** Test started: " + cmisTest.getName() + " (remote: " + (cmisTest.getRemoteServer() != null) + ", headers: " + cmisTest.getArgsAsHeaders() + ")");
+ }
+ }
+
+ private Service getRepository()
+ throws Exception
+ {
+ if (service == null)
+ {
+ Response res = sendRequest(new GetRequest(serviceUrl), 200, getAppValidator());
+ String xml = res.getContentAsString();
+ assertNotNull(xml);
+ assertTrue(xml.length() > 0);
+
+ service = abdera.parseService(new StringReader(xml), null);
+ assertNotNull(service);
+ Workspace workspace = getWorkspace(service);
+ CMISRepositoryInfo repoInfo = workspace.getExtension(CMISConstants.REPOSITORY_INFO);
+ assertNotNull(repoInfo);
+ CMISCapabilities capabilities = repoInfo.getCapabilities();
+ assertNotNull(repoInfo);
+ fulltextCapability = capabilities.getFullText();
+ assertNotNull(fulltextCapability);
+ }
+ return service;
+ }
+
+ private Workspace getWorkspace(Service service)
+ {
+ 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 getRootChildrenCollection(Workspace workspace)
+ {
+ Collection root = getCMISCollection(workspace, CMISConstants.COLLECTION_ROOT_CHILDREN);
+ assertNotNull(root);
+ IRI rootHREF = root.getHref();
+ assertNotNull(rootHREF);
+ return rootHREF;
+ }
+
+ private IRI getCheckedOutCollection(Workspace workspace)
+ {
+ Collection root = getCMISCollection(workspace, CMISConstants.COLLECTION_CHECKEDOUT);
+ assertNotNull(root);
+ IRI rootHREF = root.getHref();
+ assertNotNull(rootHREF);
+ return rootHREF;
+ }
+
+ private IRI getTypesChildrenCollection(Workspace workspace)
+ {
+ Collection root = getCMISCollection(workspace, CMISConstants.COLLECTION_TYPES_CHILDREN);
+ assertNotNull(root);
+ IRI rootHREF = root.getHref();
+ assertNotNull(rootHREF);
+ return rootHREF;
+ }
+
+ private IRI getQueryCollection(Workspace workspace)
+ {
+ Collection root = getCMISCollection(workspace, CMISConstants.COLLECTION_QUERY);
+ assertNotNull(root);
+ IRI rootHREF = root.getHref();
+ assertNotNull(rootHREF);
+ return rootHREF;
+ }
+
+ private Entry createFolder(IRI parent, String name)
+ throws Exception
+ {
+ return createFolder(parent, name, "/org/alfresco/repo/cmis/rest/test/createfolder.atomentry.xml");
+ }
+
+ private Entry createFolder(IRI parent, String name, String atomEntryFile)
+ throws Exception
+ {
+ String createFolder = loadString(atomEntryFile);
+ createFolder = createFolder.replace("${NAME}", name);
+ Response res = sendRequest(new PostRequest(parent.toString(), createFolder, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
+ assertNotNull(res);
+ String xml = res.getContentAsString();
+ Entry entry = abdera.parseEntry(new StringReader(xml), null);
+ assertNotNull(entry);
+ assertEquals(name, entry.getTitle());
+ //assertEquals(name + " (summary)", entry.getSummary());
+ CMISObject object = entry.getExtension(CMISConstants.OBJECT);
+ assertEquals("folder", object.getBaseType().getValue());
+ String testFolderHREF = (String)res.getHeader("Location");
+ assertNotNull(testFolderHREF);
+ return entry;
+ }
+
+ private Entry createDocument(IRI parent, String name)
+ throws Exception
+ {
+ return createDocument(parent, name, "/org/alfresco/repo/cmis/rest/test/createdocument.atomentry.xml");
+ }
+
+ private Entry createDocument(IRI parent, String name, String atomEntryFile)
+ throws Exception
+ {
+ String createFile = loadString(atomEntryFile);
+ createFile = createFile.replace("${NAME}", name);
+ createFile = createFile.replace("${CONTENT}", Base64.encodeBytes(name.getBytes()));
+ Response res = sendRequest(new PostRequest(parent.toString(), createFile, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
+ assertNotNull(res);
+ String xml = res.getContentAsString();
+ Entry entry = abdera.parseEntry(new StringReader(xml), null);
+ assertNotNull(entry);
+ assertEquals(name, entry.getTitle());
+ //assertEquals(name + " (summary)", entry.getSummary());
+ assertNotNull(entry.getContentSrc());
+ CMISObject object = entry.getExtension(CMISConstants.OBJECT);
+ assertEquals("document", object.getBaseType().getValue());
+ String testFileHREF = (String)res.getHeader("Location");
+ assertNotNull(testFileHREF);
+ return entry;
+ }
+
+ private Entry createTestsFolder(IRI rootFolder)
+ throws Exception
+ {
+ // TODO: Convert to query
+ Feed children = getFeed(rootFolder);
+ for (Entry child : children.getEntries())
+ {
+ if (child.getTitle().equals("CMIS Tests"))
+ {
+ return child;
+ }
+ }
+
+ // not found, create it
+ return createFolder(rootFolder, "CMIS Tests");
+ }
+
+ private Entry createTestFolder(String name)
+ throws Exception
+ {
+ if (testRunFolder == null)
+ {
+ Service service = getRepository();
+ IRI rootFolderHREF = getRootChildrenCollection(getWorkspace(service));
+ testsFolder = createTestsFolder(rootFolderHREF);
+ Link testsChildrenLink = testsFolder.getLink(CMISConstants.REL_CHILDREN);
+ testRunFolder = createFolder(testsChildrenLink.getHref(), "Test Run " + System.currentTimeMillis());
+ }
+ Link childrenLink = testRunFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ Entry testFolder = createFolder(childrenLink.getHref(), name + " " + System.currentTimeMillis());
+ return testFolder;
+ }
+
+ private Entry getEntry(IRI href)
+ throws Exception
+ {
+ return getEntry(href, null);
+ }
+
+ private Entry getEntry(IRI href, Map args)
+ throws Exception
+ {
+ Request get = new GetRequest(href.toString()).setArgs(args);
+ Response res = sendRequest(get, 200, getAtomValidator());
+ assertNotNull(res);
+ String xml = res.getContentAsString();
+ Entry entry = abdera.parseEntry(new StringReader(xml), null);
+ assertNotNull(entry);
+ assertEquals(getArgsAsHeaders() ? get.getUri() : get.getFullUri(), entry.getSelfLink().getHref().toString());
+ return entry;
+ }
+
+ private Feed getFeed(IRI href)
+ throws Exception
+ {
+ return getFeed(href, null);
+ }
+
+ private Feed getFeed(IRI href, Map args)
+ throws Exception
+ {
+ Request get = new GetRequest(href.toString()).setArgs(args);
+ Response res = sendRequest(get, 200, getAtomValidator());
+ assertNotNull(res);
+ String xml = res.getContentAsString();
+ Feed feed = abdera.parseFeed(new StringReader(xml), null);
+ assertNotNull(feed);
+ assertEquals(getArgsAsHeaders() ? get.getUri() : get.getFullUri(), feed.getSelfLink().getHref().toString());
+ return feed;
+ }
+
+ public void testRepository()
+ throws Exception
+ {
+ IRI rootHREF = getRootChildrenCollection(getWorkspace(getRepository()));
+ sendRequest(new GetRequest(rootHREF.toString()), 200, getAtomValidator());
+ }
+
+ public void testCreateDocument()
+ throws Exception
+ {
+ Entry testFolder = createTestFolder("testCreateDocument");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ Feed children = getFeed(childrenLink.getHref());
+ assertNotNull(children);
+ int entriesBefore = children.getEntries().size();
+ Entry document = createDocument(children.getSelfLink().getHref(), "testCreateDocument");
+ Response documentContentRes = sendRequest(new GetRequest(document.getContentSrc().toString()), 200);
+ String resContent = documentContentRes.getContentAsString();
+ assertEquals(document.getTitle(), resContent);
+ Feed feedFolderAfter = getFeed(childrenLink.getHref());
+ int entriesAfter = feedFolderAfter.getEntries().size();
+ assertEquals(entriesBefore +1, entriesAfter);
+ 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("/org/alfresco/repo/cmis/rest/test/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);
+ }
+
+ // TODO: Test creation of document via Atom Entry containing plain text (non Base64 encoded)
+// public void testCreateDocumentBase64()
+// throws Exception
+// {
+// Entry testFolder = createTestFolder("testCreateDocumentBase64");
+// Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+// assertNotNull(childrenLink);
+// Feed children = getFeed(childrenLink.getHref());
+// assertNotNull(children);
+// int entriesBefore = children.getEntries().size();
+// Entry document = createDocument(children.getSelfLink().getHref(), "testCreateDocument", "/org/alfresco/repo/cmis/rest/test/createdocumentBase64.atomentry.xml");
+// Response documentContentRes = sendRequest(new GetRequest(document.getContentSrc().toString()), 200);
+// String testContent = loadString("/org/alfresco/repo/cmis/rest/test/createdocumentBase64.txt");
+// String resContent = documentContentRes.getContentAsString();
+// assertEquals(testContent, resContent);
+// Feed feedFolderAfter = getFeed(childrenLink.getHref());
+// int entriesAfter = feedFolderAfter.getEntries().size();
+// assertEquals(entriesBefore +1, entriesAfter);
+// Entry entry = feedFolderAfter.getEntry(document.getId().toString());
+// assertNotNull(entry);
+// }
+
+ public void testCreateFolder()
+ throws Exception
+ {
+ Entry testFolder = createTestFolder("testCreateFolder");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ Feed children = getFeed(childrenLink.getHref());
+ assertNotNull(children);
+ int entriesBefore = children.getEntries().size();
+ Entry folder = createFolder(children.getSelfLink().getHref(), "testCreateFolder");
+ Feed feedFolderAfter = getFeed(childrenLink.getHref());
+ int entriesAfter = feedFolderAfter.getEntries().size();
+ assertEquals(entriesBefore +1, entriesAfter);
+ Entry entry = feedFolderAfter.getEntry(folder.getId().toString());
+ assertNotNull(entry);
+ }
+
+ public void testGet()
+ throws Exception
+ {
+ // get folder
+ Entry testFolder = createTestFolder("testGet");
+ assertNotNull(testFolder);
+ Entry testFolderFromGet = getEntry(testFolder.getSelfLink().getHref());
+ assertEquals(testFolder.getId(), testFolderFromGet.getId());
+ assertEquals(testFolder.getTitle(), testFolderFromGet.getTitle());
+ assertEquals(testFolder.getSummary(), testFolderFromGet.getSummary());
+
+ // get document
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ Entry testDocument = createDocument(childrenLink.getHref(), "testGet");
+ assertNotNull(testDocument);
+ Entry testDocumentFromGet = getEntry(testDocument.getSelfLink().getHref());
+ assertEquals(testDocument.getId(), testDocumentFromGet.getId());
+ assertEquals(testDocument.getTitle(), testDocumentFromGet.getTitle());
+ //assertEquals(testDocument.getSummary(), testDocumentFromGet.getSummary());
+
+ // get something that doesn't exist
+ Response res = sendRequest(new GetRequest(testDocument.getSelfLink().getHref().toString() + GUID.generate()), 404);
+ assertNotNull(res);
+ }
+
+ public void testGetChildren()
+ throws Exception
+ {
+ // create multiple children
+ Entry testFolder = createTestFolder("testGetChildren");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ Entry document1 = createDocument(childrenLink.getHref(), "testGetChildren1");
+ assertNotNull(document1);
+ Entry document2 = createDocument(childrenLink.getHref(), "testGetChildren2");
+ assertNotNull(document2);
+ Entry document3 = createDocument(childrenLink.getHref(), "testGetChildren3");
+ assertNotNull(document3);
+
+ // checkout one of the children to ensure private working copy isn't included
+ Response documentRes = sendRequest(new GetRequest(document2.getSelfLink().getHref().toString()), 200, getAtomValidator());
+ assertNotNull(documentRes);
+ String documentXML = documentRes.getContentAsString();
+ assertNotNull(documentXML);
+ 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);
+
+ // get children, ensure they exist (but not private working copy)
+ Feed children = getFeed(childrenLink.getHref());
+ assertNotNull(children);
+ assertEquals(3, children.getEntries().size());
+ assertNotNull(children.getEntry(document1.getId().toString()));
+ assertNotNull(children.getEntry(document2.getId().toString()));
+ assertNotNull(children.getEntry(document3.getId().toString()));
+ assertNull(children.getEntry(pwc.getId().toString()));
+ }
+
+ public void testGetChildrenPaging()
+ throws Exception
+ {
+ // create multiple children
+ Set docIds = new HashSet();
+ Entry testFolder = createTestFolder("testGetChildrenPaging");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ for (int i = 0; i < 15; i++)
+ {
+ Entry document = createDocument(childrenLink.getHref(), "testGetChildrenPaging" + i);
+ assertNotNull(document);
+ docIds.add(document.getId());
+ }
+ assertEquals(15, docIds.size());
+
+ // get children, ensure they exist (but not private working copy)
+ int nextCount = 0;
+ Map args = new HashMap();
+ args.put("maxItems", "4");
+ IRI childrenHREF = childrenLink.getHref();
+ while (childrenHREF != null)
+ {
+ nextCount++;
+ Feed types = getFeed(childrenHREF, args);
+ assertNotNull(types);
+ assertEquals(nextCount < 4 ? 4 : 3, types.getEntries().size());
+ for (Entry entry : types.getEntries())
+ {
+ docIds.remove(entry.getId());
+ }
+
+ // next page
+ Link nextLink = types.getLink("next");
+ if (nextCount < 4)
+ {
+ assertNotNull(nextLink);
+ }
+ childrenHREF = (nextLink != null) ? nextLink.getHref() : null;
+ args = null;
+ };
+ assertEquals(4, nextCount);
+ assertEquals(0, docIds.size());
+ }
+
+ public void testGetChildrenTypeFilter()
+ throws Exception
+ {
+ // create multiple children
+ Entry testFolder = createTestFolder("testChildrenTypeFilter");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ Entry document = createDocument(childrenLink.getHref(), "testChildren1");
+ assertNotNull(document);
+ Entry folder = createFolder(childrenLink.getHref(), "testChildren2");
+ assertNotNull(folder);
+
+ // invalid type filter
+ Map args = new HashMap();
+ args.put("types", "Invalid");
+ // TODO: potential spec issue
+// Response invalidRes = sendRequest(new GetRequest(childrenLink.getHref().toString()).setArgs(args), 400);
+// assertNotNull(invalidRes);
+
+ // no filter
+ Feed noFilters = getFeed(childrenLink.getHref());
+ assertNotNull(noFilters);
+ assertEquals(2, noFilters.getEntries().size());
+
+ // any filter
+ args.put("types", "Any");
+ Feed any = getFeed(childrenLink.getHref(), args);
+ assertNotNull(any);
+ assertEquals(2, any.getEntries().size());
+
+ // folders filter
+ args.put("types", "Folders");
+ Feed folders = getFeed(childrenLink.getHref(), args);
+ assertNotNull(folders);
+ assertEquals(1, folders.getEntries().size());
+ assertNotNull(folders.getEntry(folder.getId().toString()));
+
+ // documents filter
+ args.put("types", "Documents");
+ Feed documents = getFeed(childrenLink.getHref(), args);
+ assertNotNull(documents);
+ assertEquals(1, documents.getEntries().size());
+ assertNotNull(documents.getEntry(document.getId().toString()));
+ }
+
+ public void testGetChildrenPropertyFilter()
+ throws Exception
+ {
+ // create children
+ Entry testFolder = createTestFolder("testGetChildrenPropertyFilter");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ Entry document1 = createDocument(childrenLink.getHref(), "testGetChildrenPropertyFilter1");
+ assertNotNull(document1);
+
+ {
+ // get children with all properties
+ Feed children = getFeed(childrenLink.getHref());
+ for (Entry entry : children.getEntries())
+ {
+ CMISObject object = entry.getExtension(CMISConstants.OBJECT);
+ assertNotNull(object.getObjectId().getValue());
+ assertNotNull(object.getObjectTypeId().getValue());
+ }
+ }
+
+ {
+ // get children with object_id only
+ Map args = new HashMap();
+ args.put("filter", "ObjectId");
+ Feed children = getFeed(childrenLink.getHref(), args);
+ for (Entry entry : children.getEntries())
+ {
+ CMISObject object = entry.getExtension(CMISConstants.OBJECT);
+ assertNotNull(object.getObjectId().getValue());
+ assertNull(object.getObjectTypeId());
+ }
+ }
+ }
+
+ public void testGetDescendants()
+ throws Exception
+ {
+ // create multiple nested children
+ Entry testFolder = createTestFolder("testGetDescendants");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ Entry document1 = createDocument(childrenLink.getHref(), "testGetDescendants1");
+ assertNotNull(document1);
+ Entry folder2 = createFolder(childrenLink.getHref(), "testGetDescendants2");
+ assertNotNull(folder2);
+ Link childrenLink2 = folder2.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink2);
+ Entry document3 = createDocument(childrenLink2.getHref(), "testGetDescendants3");
+ assertNotNull(document3);
+
+ {
+ // get descendants (depth = 1, equivalent to getChildren)
+ Map args = new HashMap();
+ args.put("depth", "1");
+ Link descendantsLink = testFolder.getLink(CMISConstants.REL_DESCENDANTS);
+ Feed descendants = getFeed(descendantsLink.getHref(), args);
+ assertNotNull(descendants);
+ assertEquals(2, descendants.getEntries().size());
+ assertNotNull(descendants.getEntry(document1.getId().toString()));
+ assertNotNull(descendants.getEntry(folder2.getId().toString()));
+
+ Entry getFolder2 = descendants.getEntry(folder2.getId().toString());
+ Entry getFolder2Child = getFolder2.getFirstChild(CMISConstants.NESTED_ENTRY);
+ assertNull(getFolder2Child);
+ }
+
+ {
+ // get nested children
+ Map args = new HashMap();
+ args.put("depth", "2");
+ Link descendantsLink = testFolder.getLink(CMISConstants.REL_DESCENDANTS);
+ Feed descendants = getFeed(descendantsLink.getHref(), args);
+ assertNotNull(descendants);
+ assertEquals(2, descendants.getEntries().size());
+ assertNotNull(descendants.getEntry(document1.getId().toString()));
+ assertNotNull(descendants.getEntry(folder2.getId().toString()));
+
+ Entry getFolder2 = descendants.getEntry(folder2.getId().toString());
+ List getFolder2Children = getFolder2.getExtensions(CMISConstants.NESTED_ENTRY);
+ assertNotNull(getFolder2Children);
+ assertEquals(1, getFolder2Children.size());
+ Entry getFolder2Child = getFolder2Children.get(0);
+ assertEquals(document3.getId(), getFolder2Child.getId());
+ assertEquals(document3.getEditLink().getHref().toString(), getFolder2Child.getEditLink().getHref().toString());
+ }
+ }
+
+ public void testGetParent()
+ throws Exception
+ {
+ Entry testFolder = createTestFolder("testParent");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ Entry childFolder = createFolder(childrenLink.getHref(), "testParentChild");
+ assertNotNull(childFolder);
+ Link parentLink = childFolder.getLink(CMISConstants.REL_FOLDERPARENT);
+ assertNotNull(parentLink);
+
+ // ensure there is parent 'testParent'
+ Feed parent = getFeed(parentLink.getHref());
+ assertNotNull(parent);
+ assertEquals(1, parent.getEntries().size());
+ assertEquals(testFolder.getId(), parent.getEntries().get(0).getId());
+
+ // TODO: compare identity using OBJECT_ID property, not atom:id
+
+ // ensure there are ancestors 'testParent', "test run folder", "tests folder" and "root folder"
+ Map args = new HashMap();
+ args.put("returnToRoot", "true");
+ Feed parentsToRoot = getFeed(new IRI(parentLink.getHref().toString()), args);
+ assertNotNull(parentsToRoot);
+ assertEquals(4, parentsToRoot.getEntries().size());
+ assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId());
+ assertNotNull(parentsToRoot.getEntries().get(0).getLink(CMISConstants.REL_PARENT));
+ assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
+ 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(getRootChildrenCollection(getWorkspace(getRepository())));
+ Entry rootEntry = getEntry(root.getLink(CMISConstants.REL_SOURCE).getHref());
+ assertEquals(rootEntry.getId(), parentsToRoot.getEntries().get(3).getId());
+ assertNull(parentsToRoot.getEntries().get(3).getLink(CMISConstants.REL_PARENT));
+ }
+
+ public void testGetParents()
+ throws Exception
+ {
+ Entry testFolder = createTestFolder("testParents");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ assertNotNull(childrenLink);
+ Entry childDocs = createDocument(childrenLink.getHref(), "testParentsChild");
+ assertNotNull(childDocs);
+ Link parentLink = childDocs.getLink(CMISConstants.REL_PARENTS);
+ assertNotNull(parentLink);
+
+ // ensure there is parent 'testParent'
+ Feed parent = getFeed(parentLink.getHref());
+ assertNotNull(parent);
+ assertEquals(1, parent.getEntries().size());
+ assertEquals(testFolder.getId(), parent.getEntries().get(0).getId());
+
+ // ensure there are ancestors 'testParent', "test run folder" and "root folder"
+ Map args = new HashMap();
+ args.put("returnToRoot", "true");
+ Feed parentsToRoot = getFeed(new IRI(parentLink.getHref().toString()), args);
+ assertNotNull(parentsToRoot);
+ assertEquals(4, parentsToRoot.getEntries().size());
+ assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId());
+ //assertNotNull(parentsToRoot.getEntries().get(0).getLink(CMISConstants.REL_PARENT));
+ assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
+ //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(getRootChildrenCollection(getWorkspace(getRepository())));
+ Entry rootEntry = getEntry(root.getLink(CMISConstants.REL_SOURCE).getHref());
+ assertEquals(rootEntry.getId(), parentsToRoot.getEntries().get(3).getId());
+ assertNull(parentsToRoot.getEntries().get(3).getLink(CMISConstants.REL_PARENT));
+ }
+
+ public void testDelete()
+ throws Exception
+ {
+ // retrieve test folder for deletes
+ Entry testFolder = createTestFolder("testDelete");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+ Feed children = getFeed(childrenLink.getHref());
+ int entriesBefore = children.getEntries().size();
+
+ // create document for delete
+ Entry document = createDocument(childrenLink.getHref(), "testDelete");
+ Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
+ assertNotNull(documentRes);
+
+ // ensure document has been created
+ Feed children2 = getFeed(childrenLink.getHref());
+ assertNotNull(children2);
+ int entriesAfterCreate = children2.getEntries().size();
+ assertEquals(entriesAfterCreate, entriesBefore +1);
+
+ // delete
+ Response deleteRes = sendRequest(new DeleteRequest(document.getSelfLink().getHref().toString()), 204);
+ assertNotNull(deleteRes);
+
+ // ensure document has been deleted
+ Feed children3 = getFeed(childrenLink.getHref());
+ assertNotNull(children3);
+ int entriesAfterDelete = children3.getEntries().size();
+ assertEquals(entriesBefore, entriesAfterDelete);
+ }
+
+ public void testUpdate()
+ throws Exception
+ {
+ // retrieve test folder for update
+ Entry testFolder = createTestFolder("testUpdate");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+
+ // create document for update
+ Entry document = createDocument(childrenLink.getHref(), "testUpdate");
+ assertNotNull(document);
+ String mimetype = (document.getContentMimeType() != null) ? document.getContentMimeType().toString() : null;
+ if (mimetype != null)
+ {
+ assertEquals("text/html", mimetype);
+ }
+
+ // TODO: check for content update allowable action
+ // if update allowed, perform update, else update and check for appropriate error
+
+ // update
+ String updateFile = loadString("/org/alfresco/repo/cmis/rest/test/updatedocument.atomentry.xml");
+ String guid = GUID.generate();
+ updateFile = updateFile.replace("${NAME}", guid);
+ Response res = sendRequest(new PutRequest(document.getSelfLink().getHref().toString(), updateFile, Format.ATOMENTRY.mimetype()), 200, getAtomValidator());
+ assertNotNull(res);
+ Entry updated = abdera.parseEntry(new StringReader(res.getContentAsString()), null);
+
+ // ensure update occurred
+ assertEquals(document.getId(), updated.getId());
+ assertEquals(document.getPublished(), updated.getPublished());
+ assertEquals("Updated Title " + guid, updated.getTitle());
+ // TODO: why is this testing for text/plain? it should be test/html
+ assertEquals("text/plain", updated.getContentMimeType().toString());
+ Response contentRes = sendRequest(new GetRequest(updated.getContentSrc().toString()), 200);
+ assertEquals("updated content " + guid, contentRes.getContentAsString());
+ }
+
+ public void testGetCheckedOut()
+ throws Exception
+ {
+ // retrieve test folder for checkouts
+ Entry testFolder = createTestFolder("testGetCheckedOut");
+ CMISObject object = testFolder.getExtension(CMISConstants.OBJECT);
+ String scopeId = object.getObjectId().getValue();
+ assertNotNull(scopeId);
+
+ // retrieve checkouts within scope of test checkout folder
+ Service repository = getRepository();
+ assertNotNull(repository);
+ IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository()));
+ Map args = new HashMap();
+ args.put("folderId", scopeId);
+ Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
+ assertNotNull(checkedout);
+ assertEquals(0, checkedout.getEntries().size());
+ }
+
+ public void testCheckout()
+ throws Exception
+ {
+ // retrieve test folder for checkouts
+ Entry testFolder = createTestFolder("testCheckout");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+
+ // create document for checkout
+ Entry document = createDocument(childrenLink.getHref(), "testCheckout");
+ CMISObject docObject = document.getExtension(CMISConstants.OBJECT);
+ Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
+ assertNotNull(documentRes);
+ String documentXML = documentRes.getContentAsString();
+ assertNotNull(documentXML);
+
+ // checkout
+ IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository()));
+ Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
+ assertNotNull(pwcRes);
+ String pwcXml = pwcRes.getContentAsString();
+ assertNotNull(pwcXml);
+ Entry pwc = abdera.parseEntry(new StringReader(pwcXml), null);
+ assertNotNull(pwc);
+ CMISObject pwcObject = pwc.getExtension(CMISConstants.OBJECT);
+ assertNotNull(pwcObject);
+ assertTrue(pwcObject.isVersionSeriesCheckedOut().getBooleanValue());
+ assertEquals(docObject.getObjectId().getValue(), pwcObject.getVersionSeriesId().getValue());
+ assertEquals(pwcObject.getObjectId().getValue(), pwcObject.getVersionSeriesCheckedOutId().getValue());
+ assertNotNull(pwcObject.getVersionSeriesCheckedOutBy().getValue());
+
+ // test getCheckedOut is updated
+ CMISObject object = testFolder.getExtension(CMISConstants.OBJECT);
+ String scopeId = object.getObjectId().getValue();
+ Map args = new HashMap();
+ args.put("folderId", scopeId);
+ Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
+ assertNotNull(checkedout);
+ assertEquals(1, checkedout.getEntries().size());
+ }
+
+ public void testCancelCheckout()
+ throws Exception
+ {
+ // retrieve test folder for checkouts
+ Entry testFolder = createTestFolder("testCancelCheckout");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+
+ // create document for checkout
+ Entry document = createDocument(childrenLink.getHref(), "testCancelCheckout");
+ Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
+ assertNotNull(documentRes);
+ String xml = documentRes.getContentAsString();
+ assertNotNull(xml);
+
+ // checkout
+ IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository()));
+ Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
+ assertNotNull(pwcRes);
+ String pwcXml = pwcRes.getContentAsString();
+
+ // test getCheckedOut is updated
+ CMISObject object = testFolder.getExtension(CMISConstants.OBJECT);
+ String scopeId = object.getObjectId().getValue();
+ Map args = new HashMap();
+ args.put("folderId", scopeId);
+ Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
+ assertNotNull(checkedout);
+ assertEquals(1, checkedout.getEntries().size());
+
+ // cancel checkout
+ Entry pwc = abdera.parseEntry(new StringReader(pwcXml), null);
+ assertNotNull(pwc);
+ Response cancelRes = sendRequest(new DeleteRequest(pwc.getSelfLink().getHref().toString()), 204);
+ assertNotNull(cancelRes);
+
+ // test getCheckedOut is updated
+ CMISObject object2 = testFolder.getExtension(CMISConstants.OBJECT);
+ String scopeId2 = object2.getObjectId().getValue();
+ Map args2 = new HashMap();
+ args2.put("folderId", scopeId2);
+ Feed checkedout2 = getFeed(new IRI(checkedoutHREF.toString()), args2);
+ assertNotNull(checkedout2);
+ assertEquals(0, checkedout2.getEntries().size());
+ }
+
+ public void testCheckIn()
+ throws Exception
+ {
+ // retrieve test folder for checkins
+ Entry testFolder = createTestFolder("testCheckIn");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+
+ // create document for checkout
+ Entry document = createDocument(childrenLink.getHref(), "testCheckin");
+ Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
+ assertNotNull(documentRes);
+ String xml = documentRes.getContentAsString();
+ assertNotNull(xml);
+
+ // checkout
+ 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);
+ assertNotNull(pwc);
+
+ // test getCheckedOut is updated
+ CMISObject object = testFolder.getExtension(CMISConstants.OBJECT);
+ String scopeId = object.getObjectId().getValue();
+ Map args = new HashMap();
+ args.put("folderId", scopeId);
+ Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
+ assertNotNull(checkedout);
+ assertEquals(1, checkedout.getEntries().size());
+
+ // test version properties of checked-out item
+ // test checked-in version properties
+ Entry checkedoutdoc = getEntry(document.getSelfLink().getHref());
+ CMISObject checkedoutdocObject = checkedoutdoc.getExtension(CMISConstants.OBJECT);
+ assertNotNull(checkedoutdocObject);
+ assertTrue(checkedoutdocObject.isVersionSeriesCheckedOut().getBooleanValue());
+ //assertEquals(checkedoutdocObject.getObjectId().getValue(), checkedoutdocObject.getVersionSeriesId().getValue());
+ assertNotNull(checkedoutdocObject.getVersionSeriesCheckedOutId().getValue());
+ assertNotNull(checkedoutdocObject.getVersionSeriesCheckedOutBy().getValue());
+
+ // test update of private working copy
+ String updateFile = loadString("/org/alfresco/repo/cmis/rest/test/updatedocument.atomentry.xml");
+ String guid = GUID.generate();
+ updateFile = updateFile.replace("${NAME}", guid);
+ Response pwcUpdatedres = sendRequest(new PutRequest(pwc.getEditLink().getHref().toString(), updateFile, Format.ATOMENTRY.mimetype()), 200, getAtomValidator());
+ assertNotNull(pwcUpdatedres);
+ Entry updated = abdera.parseEntry(new StringReader(pwcUpdatedres.getContentAsString()), null);
+ // ensure update occurred
+ assertEquals(pwc.getId(), updated.getId());
+ assertEquals(pwc.getPublished(), updated.getPublished());
+ assertEquals("Updated Title " + guid, updated.getTitle());
+ assertEquals("text/plain", updated.getContentMimeType().toString());
+ Response pwcContentRes = sendRequest(new GetRequest(pwc.getContentSrc().toString()), 200);
+ assertEquals("updated content " + guid, pwcContentRes.getContentAsString());
+
+ // checkin
+ String checkinFile = loadString("/org/alfresco/repo/cmis/rest/test/checkindocument.atomentry.xml");
+ String checkinUrl = pwc.getSelfLink().getHref().toString();
+ Map args2 = new HashMap();
+ args2.put("checkinComment", guid);
+ args2.put("checkin", "true");
+ Response checkinRes = sendRequest(new PutRequest(checkinUrl, checkinFile, Format.ATOMENTRY.mimetype()).setArgs(args2), 200, getAtomValidator());
+ assertNotNull(checkinRes);
+ String checkinResXML = checkinRes.getContentAsString();
+
+ // test getCheckedOut is updated
+ CMISObject object2 = testFolder.getExtension(CMISConstants.OBJECT);
+ String scopeId2 = object2.getObjectId().getValue();
+ Map args3 = new HashMap();
+ args3.put("folderId", scopeId2);
+ Feed checkedout2 = getFeed(new IRI(checkedoutHREF.toString()), args3);
+ assertNotNull(checkedout2);
+ assertEquals(0, checkedout2.getEntries().size());
+
+ // test checked-in doc has new updates
+ Entry checkedIn = abdera.parseEntry(new StringReader(checkinResXML), null);
+ Entry updatedDoc = getEntry(checkedIn.getSelfLink().getHref());
+ // TODO: issue with updating name on PWC and it not reflecting on checked-in document
+ //assertEquals("Updated Title " + guid, updatedDoc.getTitle());
+ assertEquals("text/plain", updatedDoc.getContentMimeType().toString());
+ Response updatedContentRes = sendRequest(new GetRequest(updatedDoc.getContentSrc().toString()), 200);
+ assertEquals("updated content " + guid, updatedContentRes.getContentAsString());
+
+ // test checked-in version properties
+ CMISObject updatedObject = updatedDoc.getExtension(CMISConstants.OBJECT);
+ assertNotNull(updatedObject);
+ assertFalse(updatedObject.isVersionSeriesCheckedOut().getBooleanValue());
+ //assertEquals(updatedObject.getObjectId().getValue(), updatedObject.getVersionSeriesId().getValue());
+ assertNull(updatedObject.getVersionSeriesCheckedOutId().getValue());
+ assertNull(updatedObject.getVersionSeriesCheckedOutBy().getValue());
+ assertEquals(guid, updatedObject.getCheckinComment().getValue());
+ }
+
+ public void testUpdateOnCheckIn()
+ throws Exception
+ {
+ // retrieve test folder for checkins
+ Entry testFolder = createTestFolder("testUpdateOnCheckIn");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+
+ // create document for checkout
+ Entry document = createDocument(childrenLink.getHref(), "testUpdateOnCheckIn");
+ Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
+ assertNotNull(documentRes);
+ String xml = documentRes.getContentAsString();
+ assertNotNull(xml);
+
+ // checkout
+ 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);
+ assertNotNull(pwc);
+
+ // test getCheckedOut is updated
+ CMISObject object = testFolder.getExtension(CMISConstants.OBJECT);
+ String scopeId = object.getObjectId().getValue();
+ Map args = new HashMap();
+ args.put("folderId", scopeId);
+ Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
+ assertNotNull(checkedout);
+ assertEquals(1, checkedout.getEntries().size());
+
+ // checkin (with update)
+ String checkinFile = loadString("/org/alfresco/repo/cmis/rest/test/checkinandupdatedocument.atomentry.xml");
+ String guid = GUID.generate();
+ checkinFile = checkinFile.replace("${NAME}", guid);
+ String checkinUrl = pwc.getSelfLink().getHref().toString();
+ Map args2 = new HashMap();
+ args2.put("checkinComment", guid);
+ args2.put("checkin", "true");
+ Response checkinRes = sendRequest(new PutRequest(checkinUrl, checkinFile, Format.ATOMENTRY.mimetype()).setArgs(args2), 200, getAtomValidator());
+ assertNotNull(checkinRes);
+ String checkinResXML = checkinRes.getContentAsString();
+
+ // test getCheckedOut is updated
+ CMISObject object2 = testFolder.getExtension(CMISConstants.OBJECT);
+ String scopeId2 = object2.getObjectId().getValue();
+ Map args3 = new HashMap();
+ args3.put("folderId", scopeId2);
+ Feed checkedout2 = getFeed(new IRI(checkedoutHREF.toString()), args3);
+ assertNotNull(checkedout2);
+ assertEquals(0, checkedout2.getEntries().size());
+
+ // test checked-in doc has new updates
+ Entry checkedIn = abdera.parseEntry(new StringReader(checkinResXML), null);
+ Entry updatedDoc = getEntry(checkedIn.getSelfLink().getHref());
+ // TODO: issue with updating name on PWC and it not reflecting on checked-in document
+ //assertEquals("Updated Title " + guid, updatedDoc.getTitle());
+ assertEquals("text/plain", updatedDoc.getContentMimeType().toString());
+ Response updatedContentRes = sendRequest(new GetRequest(updatedDoc.getContentSrc().toString()), 200);
+ assertEquals("updated content " + guid, updatedContentRes.getContentAsString());
+ }
+
+ public void testGetAllVersions()
+ throws Exception
+ {
+ int NUMBER_OF_VERSIONS = 3;
+
+ // retrieve test folder for checkins
+ Entry testFolder = createTestFolder("testGetAllVersions");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+
+ // create document for checkout
+ Entry document = createDocument(childrenLink.getHref(), "testGetAllVersions");
+ Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
+ assertNotNull(documentRes);
+ String xml = documentRes.getContentAsString();
+ assertNotNull(xml);
+
+ IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository()));
+ for (int i = 0; i < NUMBER_OF_VERSIONS; i++)
+ {
+ // checkout
+ Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
+ assertNotNull(pwcRes);
+ Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
+ assertNotNull(pwc);
+
+ // checkin
+ String checkinFile = loadString("/org/alfresco/repo/cmis/rest/test/checkinandupdatedocument.atomentry.xml");
+ checkinFile = checkinFile.replace("${NAME}", "checkin " + i);
+ String checkinUrl = pwc.getSelfLink().getHref().toString();
+ Map args2 = new HashMap();
+ args2.put("checkinComment", "checkin" + i);
+ args2.put("checkin", "true");
+ Response checkinRes = sendRequest(new PutRequest(checkinUrl, checkinFile, Format.ATOMENTRY.mimetype()).setArgs(args2), 200, getAtomValidator());
+ assertNotNull(checkinRes);
+ }
+
+ // get all versions
+ Link allVersionsLink = document.getLink(CMISConstants.REL_ALLVERSIONS);
+ assertNotNull(allVersionsLink);
+ Feed allVersions = getFeed(allVersionsLink.getHref());
+ assertNotNull(allVersions);
+ assertEquals(NUMBER_OF_VERSIONS + 1 /** initial version */, allVersions.getEntries().size());
+ for (int i = 0; i < NUMBER_OF_VERSIONS; i++)
+ {
+ Link versionLink = allVersions.getEntries().get(i).getSelfLink();
+ assertNotNull(versionLink);
+ Entry version = getEntry(versionLink.getHref());
+ assertNotNull(version);
+ // TODO: issue with updating name on PWC and it not reflecting on checked-in document
+ //assertEquals("Update Title checkin " + i, version.getTitle());
+ Response versionContentRes = sendRequest(new GetRequest(version.getContentSrc().toString()), 200);
+ assertEquals("updated content checkin " + (NUMBER_OF_VERSIONS -1 - i), versionContentRes.getContentAsString());
+ CMISObject versionObject = version.getExtension(CMISConstants.OBJECT);
+ assertNotNull(versionObject);
+ assertEquals("checkin" + + (NUMBER_OF_VERSIONS -1 - i), versionObject.getCheckinComment().getValue());
+ }
+ }
+
+ public void testGetAllTypeDefinitions()
+ throws Exception
+ {
+ IRI typesHREF = getTypesChildrenCollection(getWorkspace(getRepository()));
+ Feed types = getFeed(typesHREF);
+ assertNotNull(types);
+ Feed typesWithProps = getFeed(typesHREF);
+ assertNotNull(typesWithProps);
+ for (Entry type : types.getEntries())
+ {
+ Entry retrievedType = getEntry(type.getSelfLink().getHref());
+ assertEquals(type.getId(), retrievedType.getId());
+ assertEquals(type.getTitle(), retrievedType.getTitle());
+ // TODO: type specific properties - extension to Abdera
+ }
+ }
+
+ public void testGetHierarchyTypeDefinitions()
+ throws Exception
+ {
+ IRI typesHREF = getTypesChildrenCollection(getWorkspace(getRepository()));
+ Map args = new HashMap();
+ args.put("type", "folder");
+ args.put("includePropertyDefinitions", "true");
+ args.put("maxItems", "5");
+ while (typesHREF != null)
+ {
+ Feed types = getFeed(typesHREF, args);
+
+ for (Entry type : types.getEntries())
+ {
+ Entry retrievedType = getEntry(type.getSelfLink().getHref());
+ assertEquals(type.getId(), retrievedType.getId());
+ assertEquals(type.getTitle(), retrievedType.getTitle());
+ // TODO: type specific properties - extension to Abdera
+ }
+
+ // next page
+ Link nextLink = types.getLink("next");
+ typesHREF = (nextLink != null) ? nextLink.getHref() : null;
+ args.remove("maxItems");
+ };
+ }
+
+ public void testGetTypeDefinition()
+ throws Exception
+ {
+ // retrieve test folder for type definitions
+ Entry testFolder = createTestFolder("testGetEntryTypeDefinition");
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+
+ // create document
+ Entry document = createDocument(childrenLink.getHref(), "testGetEntryTypeDefinitionDoc");
+ Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
+ assertNotNull(documentRes);
+
+ // create folder
+ Entry folder = createFolder(childrenLink.getHref(), "testGetEntryTypeDefinitionFolder");
+ Response folderRes = sendRequest(new GetRequest(folder.getSelfLink().getHref().toString()), 200, getAtomValidator());
+ assertNotNull(folderRes);
+
+ // retrieve children
+ Feed children = getFeed(childrenLink.getHref());
+ for (Entry entry : children.getEntries())
+ {
+ // get type definition
+ Link typeLink = entry.getLink(CMISConstants.REL_TYPE);
+ assertNotNull(typeLink);
+ Entry type = getEntry(typeLink.getHref());
+ assertNotNull(type);
+ // TODO: test correct type for entry & properties of type
+ }
+ }
+
+ public void testQuery()
+ throws Exception
+ {
+ // retrieve query collection
+ IRI queryHREF = getQueryCollection(getWorkspace(getRepository()));
+
+ // retrieve test folder for query
+ Entry testFolder = createTestFolder("testQuery");
+ CMISObject testFolderObject = testFolder.getExtension(CMISConstants.OBJECT);
+ Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
+
+ // create documents to query
+ Entry document1 = createDocument(childrenLink.getHref(), "apple1");
+ assertNotNull(document1);
+ CMISObject document1Object = document1.getExtension(CMISConstants.OBJECT);
+ assertNotNull(document1Object);
+ String doc2name = "name" + System.currentTimeMillis();
+ Entry document2 = createDocument(childrenLink.getHref(), doc2name);
+ assertNotNull(document2);
+ CMISObject document2Object = document2.getExtension(CMISConstants.OBJECT);
+ assertNotNull(document2Object);
+ Entry document3 = createDocument(childrenLink.getHref(), "banana1");
+ assertNotNull(document3);
+
+ // retrieve query request document
+ String queryDoc = loadString("/org/alfresco/repo/cmis/rest/test/query.cmisquery.xml");
+
+ {
+ // construct structured query
+ String query = "SELECT * FROM Document " +
+ "WHERE IN_FOLDER('" + testFolderObject.getObjectId().getValue() + "') " +
+ "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(), CMISConstants.MIMETYPE_QUERY), 200);
+ assertNotNull(queryRes);
+ Feed queryFeed = abdera.parseFeed(new StringReader(queryRes.getContentAsString()), null);
+ assertNotNull(queryFeed);
+ assertEquals(1, queryFeed.getEntries().size());
+ assertNotNull(queryFeed.getEntry(document1.getId().toString()));
+ CMISObject result1 = queryFeed.getEntry(document1.getId().toString()).getExtension(CMISConstants.OBJECT);
+ assertEquals(document1Object.getName().getValue(), result1.getName().getValue());
+ assertEquals(document1Object.getObjectId().getValue(), result1.getObjectId().getValue());
+ assertEquals(document1Object.getObjectTypeId().getValue(), result1.getObjectTypeId().getValue());
+ }
+
+ if (fulltextCapability.equals("fulltextonly") || fulltextCapability.equals("fulltextandstructured"))
+ {
+ // construct fulltext query
+ String query = "SELECT ObjectId, ObjectTypeId, Name FROM Document " +
+ "WHERE CONTAINS('" + doc2name + "')";
+ String queryReq = queryDoc.replace("${STATEMENT}", query);
+ queryReq = queryReq.replace("${PAGESIZE}", "5");
+
+ // issue fulltext query
+ Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), CMISConstants.MIMETYPE_QUERY), 200);
+ assertNotNull(queryRes);
+ Feed queryFeed = abdera.parseFeed(new StringReader(queryRes.getContentAsString()), null);
+ assertNotNull(queryFeed);
+ assertEquals(1, queryFeed.getEntries().size());
+ assertNotNull(queryFeed.getEntry(document2.getId().toString()));
+ CMISObject result1 = queryFeed.getEntry(document2.getId().toString()).getExtension(CMISConstants.OBJECT);
+ assertEquals(document2Object.getName().getValue(), result1.getName().getValue());
+ assertEquals(document2Object.getObjectId().getValue(), result1.getObjectId().getValue());
+ assertEquals(document2Object.getObjectTypeId().getValue(), result1.getObjectTypeId().getValue());
+ }
+
+ if (fulltextCapability.equals("fulltextandstructured"))
+ {
+ // construct fulltext and structured query
+ String query = "SELECT ObjectId, ObjectTypeId, Name FROM Document " +
+ "WHERE IN_FOLDER('" + testFolderObject.getObjectId().getValue() + "') " +
+ "AND Name = 'apple1' " +
+ "AND CONTAINS('apple1')";
+ String queryReq = queryDoc.replace("${STATEMENT}", query);
+ queryReq = queryReq.replace("${PAGESIZE}", "5");
+
+ // issue structured query
+ Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), CMISConstants.MIMETYPE_QUERY), 200);
+ assertNotNull(queryRes);
+ Feed queryFeed = abdera.parseFeed(new StringReader(queryRes.getContentAsString()), null);
+ assertNotNull(queryFeed);
+ assertEquals(1, queryFeed.getEntries().size());
+ assertNotNull(queryFeed.getEntry(document1.getId().toString()));
+ CMISObject result1 = queryFeed.getEntry(document1.getId().toString()).getExtension(CMISConstants.OBJECT);
+ assertEquals(document1Object.getName().getValue(), result1.getName().getValue());
+ assertEquals(document1Object.getObjectId().getValue(), result1.getObjectId().getValue());
+ assertEquals(document1Object.getObjectTypeId().getValue(), result1.getObjectTypeId().getValue());
+ }
+ }
+
+// public void testUnfiled()
+// {
+// }
+
+}
diff --git a/source/java/org/alfresco/repo/cmis/rest/test/CMISTestRunner.java b/source/java/org/alfresco/repo/cmis/rest/test/CMISTestRunner.java
new file mode 100644
index 0000000000..2466f060c8
--- /dev/null
+++ b/source/java/org/alfresco/repo/cmis/rest/test/CMISTestRunner.java
@@ -0,0 +1,259 @@
+/*
+ * Copyright (C) 2005-2008 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.cmis.rest.test;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.alfresco.repo.cmis.rest.test.CMISTest.CMISTestListener;
+import org.alfresco.repo.web.scripts.BaseWebScriptTest.RemoteServer;
+import org.alfresco.repo.web.scripts.BaseWebScriptTest.WebScriptTestListener;
+import org.alfresco.util.CachingDateFormat;
+
+
+/**
+ * CMIS Test Runner
+ *
+ * @author davidc
+ */
+public class CMISTestRunner
+{
+ private String match = null;
+ private WebScriptTestListener listener = new CMISTestListener(System.out);
+ private boolean traceReqRes = false;
+ private String serviceUrl = null;
+ private String userpass = null;
+ private String arguments = "url";
+ private boolean validateResponse = true;
+
+
+ /**
+ * @param match test name to execute (* for wildcards)
+ */
+ public void setMatch(String match)
+ {
+ this.match = match;
+ }
+
+ /**
+ * @param listener test listener
+ */
+ public void setListener(WebScriptTestListener listener)
+ {
+ this.listener = listener;
+ }
+
+ /**
+ * @param traceReqRes true => trace requests / responses
+ */
+ public void setTraceReqRes(boolean traceReqRes)
+ {
+ this.traceReqRes = traceReqRes;
+ }
+
+ /**
+ * @param serviceUrl cmis service document url
+ */
+ public void setServiceUrl(String serviceUrl)
+ {
+ this.serviceUrl = serviceUrl;
+ }
+
+ /**
+ * @param userpass user name / password
+ */
+ public void setUserPass(String userpass)
+ {
+ this.userpass = userpass;
+ }
+
+ /**
+ * @param arguments "url" => url arguments, "headers" => request headers, "both" => url & headers
+ */
+ public void setArguments(String arguments)
+ {
+ this.arguments = arguments;
+ }
+
+ /**
+ * @param validateResponse true => test response against CMIS XSDs
+ */
+ public void setValidateResponse(boolean validateResponse)
+ {
+ this.validateResponse = validateResponse;
+ }
+
+ /**
+ * Gets the names of CMIS tests
+ *
+ * @param match * for wildcard
+ * @return array of test names
+ */
+ public String[] getTestNames(String match)
+ {
+ List namesList = new ArrayList();
+ TestSuite allSuite = new TestSuite(CMISTest.class);
+ for (int i = 0; i < allSuite.countTestCases(); i++)
+ {
+ CMISTest test = (CMISTest)allSuite.testAt(i);
+ if (match == null || match.equals("*") || test.getName().matches(match.replace("*", "[A-Za-z0-9]*")))
+ {
+ namesList.add(test.getName());
+ }
+ }
+ String[] names = new String[namesList.size()];
+ namesList.toArray(names);
+ return names;
+ }
+
+ /**
+ * Execute CMIS Tests
+ */
+ public void execute()
+ {
+ RemoteServer server = null;
+ if (serviceUrl != null)
+ {
+ server = new RemoteServer();
+ if (userpass != null)
+ {
+ String[] credentials = userpass.split("/");
+ server.username = credentials[0];
+ if (credentials.length > 1)
+ {
+ server.password = credentials[1];
+ }
+ }
+ }
+
+ // dump test parameters
+ if (listener != null)
+ {
+ Calendar today = Calendar.getInstance();
+ SimpleDateFormat df = CachingDateFormat.getDateFormat("yyyy-MM-dd HH:mm:ss.SSS", true);
+ listener.addLog(null, "Test Started at " + df.format(today.getTime()));
+ listener.addLog(null, "Service URL: " + (serviceUrl == null ? "[not set]" : serviceUrl));
+ listener.addLog(null, "User: " + (userpass == null ? "[not set]" : userpass));
+ listener.addLog(null, "Args: " + (arguments == null ? "[not set]" : arguments));
+ listener.addLog(null, "Validate Responses: " + validateResponse);
+ listener.addLog(null, "Trace Requests/Responses: " + traceReqRes);
+ listener.addLog(null, "Tests: " + (match == null ? "*" : match));
+ listener.addLog(null, "");
+ }
+
+ // execute cmis tests with url arguments
+ if (arguments.equals("both") || arguments.equals("url"))
+ {
+ executeSuite(match, server, false);
+ }
+
+ // execute cmis tests with headers
+ if (arguments.equals("both") || arguments.equals("headers"))
+ {
+ executeSuite(match, server, true);
+ }
+ }
+
+ /**
+ * Execute suite of CMIS Tests
+ *
+ * @param match tests to execute (* for wildcard)
+ * @param server remote server
+ * @param argsAsHeaders arguments passed in Headers
+ */
+ private void executeSuite(String match, RemoteServer server, boolean argsAsHeaders)
+ {
+ TestSuite allSuite = new TestSuite(CMISTest.class);
+ TestSuite suite = new TestSuite();
+ for (int i = 0; i < allSuite.countTestCases(); i++)
+ {
+ CMISTest test = (CMISTest)allSuite.testAt(i);
+ if (match == null || match.equals("*") || test.getName().matches(match.replace("*", "[A-Za-z0-9]*")))
+ {
+ if (listener != null)
+ {
+ test.setListener(listener);
+ test.setTraceReqRes(traceReqRes);
+ }
+ if (server != null)
+ {
+ test.setServiceUrl(serviceUrl);
+ if (server != null)
+ {
+ test.setRemoteServer(server);
+ }
+ }
+ test.setArgsAsHeaders(argsAsHeaders);
+ test.setValidateResponse(validateResponse);
+ suite.addTest(test);
+ }
+ }
+ TestResult result = new TestResult();
+ if (listener != null)
+ {
+ result.addListener(listener);
+ }
+ suite.run(result);
+ }
+
+ /**
+ * Execute CMIS Tests from command-line
+ *
+ * url={serviceUrl}
+ * user={userpass}
+ * args={"url"|"headers"|"both"}
+ */
+ public static void main(String[] args)
+ {
+ CMISTestRunner runner = new CMISTestRunner();
+
+ for (String arg : args)
+ {
+ String[] argSegment = arg.split("=");
+ if (argSegment[0].equals("url"))
+ {
+ runner.setServiceUrl(argSegment[1]);
+ }
+ else if (argSegment[0].equals("user"))
+ {
+ runner.setUserPass(argSegment[1]);
+ }
+ else if (argSegment[0].equalsIgnoreCase("args"))
+ {
+ runner.setArguments(argSegment[1].toLowerCase());
+ }
+ }
+
+ // execute
+ runner.execute();
+ System.exit(0);
+ }
+
+}
diff --git a/source/java/org/alfresco/repo/cmis/rest/test/CMISTestRunnerWebScript.java b/source/java/org/alfresco/repo/cmis/rest/test/CMISTestRunnerWebScript.java
new file mode 100644
index 0000000000..9cf3152055
--- /dev/null
+++ b/source/java/org/alfresco/repo/cmis/rest/test/CMISTestRunnerWebScript.java
@@ -0,0 +1,91 @@
+/*
+ * 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.cmis.rest.test;
+
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.alfresco.repo.cmis.rest.test.CMISTest.CMISTestListener;
+import org.alfresco.repo.web.scripts.BaseWebScriptTest.WebScriptTestListener;
+import org.alfresco.web.scripts.AbstractWebScript;
+import org.alfresco.web.scripts.WebScriptRequest;
+import org.alfresco.web.scripts.WebScriptResponse;
+
+/**
+ * Execute CMIS Tests
+ *
+ * @author davidc
+ */
+public class CMISTestRunnerWebScript extends AbstractWebScript
+{
+ /* (non-Javadoc)
+ * @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
+ {
+ // setup CMIS tests
+ PrintStream printStream = new PrintStream(res.getOutputStream());
+ WebScriptTestListener testListener = new CMISTestListener(printStream);
+ CMISTestRunner runner = new CMISTestRunner();
+ runner.setListener(testListener);
+
+ // process test parameters
+ String serviceUrl = req.getParameter("url");
+ if (serviceUrl != null && serviceUrl.length() > 0)
+ {
+ runner.setServiceUrl(serviceUrl);
+ }
+ String userpass = req.getParameter("user");
+ if (userpass != null && userpass.length() > 0)
+ {
+ runner.setUserPass(userpass);
+ }
+ String args = req.getParameter("args");
+ if (args != null && args.length() > 0)
+ {
+ runner.setArguments(args);
+ }
+ String validate = req.getParameter("validate");
+ if (validate != null && validate.length() > 0)
+ {
+ runner.setValidateResponse(Boolean.valueOf(validate));
+ }
+ String trace = req.getParameter("trace");
+ if (trace != null && trace.length() > 0)
+ {
+ runner.setTraceReqRes(Boolean.valueOf(trace));
+ }
+ String match = req.getParameter("tests");
+ if (match != null && match.length() > 0)
+ {
+ runner.setMatch(match);
+ }
+
+ // execute tests
+ runner.execute();
+ }
+
+}
diff --git a/source/java/org/alfresco/repo/cmis/rest/CMISWithHeadersTest.java b/source/java/org/alfresco/repo/cmis/rest/test/CMISWithHeadersTest.java
similarity index 97%
rename from source/java/org/alfresco/repo/cmis/rest/CMISWithHeadersTest.java
rename to source/java/org/alfresco/repo/cmis/rest/test/CMISWithHeadersTest.java
index cfc154c048..beb855ffe7 100644
--- a/source/java/org/alfresco/repo/cmis/rest/CMISWithHeadersTest.java
+++ b/source/java/org/alfresco/repo/cmis/rest/test/CMISWithHeadersTest.java
@@ -22,7 +22,7 @@
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
-package org.alfresco.repo.cmis.rest;
+package org.alfresco.repo.cmis.rest.test;
diff --git a/source/test-resources/cmis/rest/checkinandupdatedocument.atomentry.xml b/source/java/org/alfresco/repo/cmis/rest/test/checkinandupdatedocument.atomentry.xml
similarity index 100%
rename from source/test-resources/cmis/rest/checkinandupdatedocument.atomentry.xml
rename to source/java/org/alfresco/repo/cmis/rest/test/checkinandupdatedocument.atomentry.xml
diff --git a/source/test-resources/cmis/rest/checkindocument.atomentry.xml b/source/java/org/alfresco/repo/cmis/rest/test/checkindocument.atomentry.xml
similarity index 77%
rename from source/test-resources/cmis/rest/checkindocument.atomentry.xml
rename to source/java/org/alfresco/repo/cmis/rest/test/checkindocument.atomentry.xml
index b3f81a8d61..a3ddc440ce 100644
--- a/source/test-resources/cmis/rest/checkindocument.atomentry.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/test/checkindocument.atomentry.xml
@@ -1,3 +1,2 @@
-
-
+
diff --git a/source/java/org/alfresco/repo/cmis/rest/test/createdocument.atomentry.xml b/source/java/org/alfresco/repo/cmis/rest/test/createdocument.atomentry.xml
new file mode 100644
index 0000000000..da9c906e91
--- /dev/null
+++ b/source/java/org/alfresco/repo/cmis/rest/test/createdocument.atomentry.xml
@@ -0,0 +1,11 @@
+
+
+ ${NAME}
+ ${NAME} (summary)
+ ${CONTENT}
+
+
+ document
+
+
+
diff --git a/source/java/org/alfresco/repo/cmis/rest/test/createdocument2.atomentry.xml b/source/java/org/alfresco/repo/cmis/rest/test/createdocument2.atomentry.xml
new file mode 100644
index 0000000000..4871aea91d
--- /dev/null
+++ b/source/java/org/alfresco/repo/cmis/rest/test/createdocument2.atomentry.xml
@@ -0,0 +1,10 @@
+
+ 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/java/org/alfresco/repo/cmis/rest/test/createdocumentBase64.atomentry.xml
similarity index 81%
rename from source/test-resources/cmis/rest/createdocumentBase64.atomentry.xml
rename to source/java/org/alfresco/repo/cmis/rest/test/createdocumentBase64.atomentry.xml
index b2d3120053..3f76b65cb5 100644
--- a/source/test-resources/cmis/rest/createdocumentBase64.atomentry.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/test/createdocumentBase64.atomentry.xml
@@ -12,8 +12,10 @@
biB0aGUgcmVwb3NpdG9yeSB3aWxsIGNyZWF0ZSB0aGUgZG9jdW1lbnQgaW4gdGhlIHNwZWNpZmll
ZCBmb2xkZXIuICBJZiB0aGUgY29udGVudCBzdHJlYW0gaXMgc3BlY2lmaWVkIG9uIGNyZWF0ZSwg
aXQgc2hvdWxkIGJlIGJhc2U2NCBlbmNvZGVkIGluIHRoZSBhdG9tIGVudHJ5Lg==
-
-
- document
-
+
+
+
+ document
+
+
diff --git a/source/test-resources/cmis/rest/createdocumentBase64.txt b/source/java/org/alfresco/repo/cmis/rest/test/createdocumentBase64.txt
similarity index 100%
rename from source/test-resources/cmis/rest/createdocumentBase64.txt
rename to source/java/org/alfresco/repo/cmis/rest/test/createdocumentBase64.txt
diff --git a/source/test-resources/cmis/rest/createfolder.atomentry.xml b/source/java/org/alfresco/repo/cmis/rest/test/createfolder.atomentry.xml
similarity index 51%
rename from source/test-resources/cmis/rest/createfolder.atomentry.xml
rename to source/java/org/alfresco/repo/cmis/rest/test/createfolder.atomentry.xml
index e0384743da..d01f6b0cf0 100644
--- a/source/test-resources/cmis/rest/createfolder.atomentry.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/test/createfolder.atomentry.xml
@@ -2,7 +2,9 @@
${NAME}
${NAME} (summary)
-
- folder
-
+
+
+ folder
+
+
diff --git a/source/test-resources/cmis/rest/query.cmissqlquery.xml b/source/java/org/alfresco/repo/cmis/rest/test/query.cmisquery.xml
similarity index 100%
rename from source/test-resources/cmis/rest/query.cmissqlquery.xml
rename to source/java/org/alfresco/repo/cmis/rest/test/query.cmisquery.xml
diff --git a/source/java/org/alfresco/repo/cmis/rest/test/query.cmissqlquery.xml b/source/java/org/alfresco/repo/cmis/rest/test/query.cmissqlquery.xml
new file mode 100644
index 0000000000..e4c46c2a42
--- /dev/null
+++ b/source/java/org/alfresco/repo/cmis/rest/test/query.cmissqlquery.xml
@@ -0,0 +1,4 @@
+
+
+ ${PAGESIZE}
+
diff --git a/source/test-resources/cmis/rest/updatedocument.atomentry.xml b/source/java/org/alfresco/repo/cmis/rest/test/updatedocument.atomentry.xml
similarity index 100%
rename from source/test-resources/cmis/rest/updatedocument.atomentry.xml
rename to source/java/org/alfresco/repo/cmis/rest/test/updatedocument.atomentry.xml
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/APP.xsd b/source/java/org/alfresco/repo/cmis/rest/xsd/APP.xsd
index 0f762b6ee7..76da25bf40 100644
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/APP.xsd
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/APP.xsd
@@ -6,11 +6,12 @@
+ xmlns:cmis="http://www.cmis.org/2008/05"
+ version="0.5">
+ schemaLocation="CMIS.xsd" />
@@ -35,11 +36,29 @@
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/ATOM4CMIS.xsd b/source/java/org/alfresco/repo/cmis/rest/xsd/ATOM4CMIS.xsd
index 8dfdf747f5..9110bad98e 100644
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/ATOM4CMIS.xsd
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/ATOM4CMIS.xsd
@@ -1,24 +1,18 @@
-
+
-
+ elementFormDefault="qualified" targetNamespace="http://www.w3.org/2005/Atom"
+ xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ xmlns:cmis="http://www.cmis.org/2008/05" xmlns:xml="http://www.w3.org/XML/1998/namespace"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
+ jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.1" version="0.5">
+ schemaLocation="xml.xsd" />
+ schemaLocation="CMIS.xsd" />
@@ -41,8 +35,7 @@
-
-
+
@@ -71,10 +64,11 @@
-
-
-
-
+
+
+
+
@@ -91,38 +85,27 @@
-
-
-
+
+
-
-
+
+
-
+
-
-
+
-
-
-
+
@@ -130,55 +113,54 @@
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
@@ -197,8 +179,7 @@
-
+
@@ -233,8 +214,7 @@
-
+
@@ -302,6 +282,7 @@
element.
+
@@ -309,10 +290,10 @@
-
+
+
@@ -397,8 +378,8 @@
@@ -409,16 +390,16 @@
-
+
-
+
@@ -427,13 +408,11 @@
-
-
+
@@ -453,6 +432,5 @@
processContents="lax" />
-
-
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/CMIS-REST.xsd b/source/java/org/alfresco/repo/cmis/rest/xsd/CMIS-REST.xsd
deleted file mode 100644
index 6b38e0b1b2..0000000000
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/CMIS-REST.xsd
+++ /dev/null
@@ -1,455 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/CMIS.xsd b/source/java/org/alfresco/repo/cmis/rest/xsd/CMIS.xsd
new file mode 100644
index 0000000000..824ba10b55
--- /dev/null
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/CMIS.xsd
@@ -0,0 +1,1077 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-AllowableActions.xml b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-AllowableActions.xml
index 181d4d07db..46ee1a5ad7 100755
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-AllowableActions.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-AllowableActions.xml
@@ -3,7 +3,7 @@
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
+ xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS.xsd ">
cmis:parentId
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-DocumentEntry.xml b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-DocumentEntry.xml
index 46d32c6d99..62d7f7a723 100755
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-DocumentEntry.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-DocumentEntry.xml
@@ -1,13 +1,9 @@
-
-
+ xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS.xsd ">
Al Brown
@@ -20,10 +16,8 @@
http://www.cmis.org/rep1/document-entry
-
-
+
+
-
+
2001-12-31T12:00:00
-
-
Document Entry example
2001-12-31T12:00:00
-
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
-
-
-
- false
- true
- true
- true
- false
- false
-
- 2001-12-31T12:00:00
- 2001-12-31T12:00:00
-
- docid1
-
-
- 70
-
- email
- document
-
- This is the initial checkin comment
- 1.0
- text/plain
- foo.txt
-
-
- http://www.cmis.org/rep1/media/document-entry
-
-
-
-
-
-
+
+
+ false
+
+ http://www.cmis.org/rep1/media/document-entry
+ true
+ true
+ true
+ false
+ false
+ abrown
+ 2001-12-31T12:00:00
+ docid1
+
+ 70
+
+ email
+ document
+
+ This is the
+ initial comment
+ 1.0
+ text/plain
+ name
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-DocumentPWCEntry.xml b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-DocumentPWCEntry.xml
index 92c2f6a71e..75889c7ed8 100755
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-DocumentPWCEntry.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-DocumentPWCEntry.xml
@@ -1,13 +1,9 @@
-
-
+ xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS.xsd ">
Al Brown
@@ -20,10 +16,8 @@
http://www.cmis.org/rep1/document-entry
-
-
+
+
-
+
2001-12-31T12:00:00
-
-
Document Entry example
2001-12-31T12:00:00
-
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
-
-
-
+
+
- true
+ docid1pwc
+ email
+
- true
- false
- false
- false
+ true
+
+ true
+ false
+ false
+ false
- true
+ true
+ 2007-12-31T12:00:00
+ 2007-12-31T12:00:00
- 2007-12-31T12:00:00
- 2007-12-31T12:00:00
-
-
- docid1pwc
- docidpwc
+ docidpwc
+ 70
- 70
-
- email
- document
+ document
- Al Brown
- This is the initial checkin comment
+ Al Brown
+ This is the
+ initial checkin comment
- 1.1
- text/plain
- foo.txt
-
-
- http://www.cmis.org/rep1/media/document-entry
-
-
-
+ 1.1
+ text/plain
+ foo.txt
+
+ http://www.cmis.org/rep1/media/document-entry
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+
-
-
+
+
+
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderChildren-Alfresco.xml b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderChildren-Alfresco.xml
index e5c51e6b65..5f17281a27 100644
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderChildren-Alfresco.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderChildren-Alfresco.xml
@@ -7,11 +7,6 @@
-
-
-
-
-
Company Home
2008-07-11T16:51:03.508+01:00
@@ -29,170 +24,23 @@
Site Collaboration Spaces
Sites
2008-07-11T16:51:03.854+01:00
+
-2008-07-11T16:51:03.086+01:00
-2008-07-11T16:51:03.854+01:00
-workspace://SpacesStore/b09bc7f5-19c3-4ad1-9c5d-8f3a95a3417d
-workspace://SpacesStore/ffddcc48-0c6a-4aa3-b9e2-1121c35f6504
-document
-System
-System
-Sites
+2008-07-11T16:51:03.086+01:00
+2008-07-11T16:51:03.854+01:00
+workspace://SpacesStore/b09bc7f5-19c3-4ad1-9c5d-8f3a95a3417d
+workspace://SpacesStore/ffddcc48-0c6a-4aa3-b9e2-1121c35f6504
+document
+System
+System
+Sites
+
+
2008-07-11T16:51:03.854+01:00
http://localhost:80/alfresco/images/icons/space-icon-default-16.gif
-
-System
-dd4f66e4-df9a-4910-94dd-4bc2a5e59443
-urn:uuid:dd4f66e4-df9a-4910-94dd-4bc2a5e59443
-
-
-
-
-
-
-
-2008-07-11T16:50:25.286+01:00
-User managed definitions
-Data Dictionary
-2008-07-11T16:51:03.509+01:00
-
-2008-07-11T16:50:25.286+01:00
-2008-07-11T16:51:03.509+01:00
-workspace://SpacesStore/dd4f66e4-df9a-4910-94dd-4bc2a5e59443
-workspace://SpacesStore/ffddcc48-0c6a-4aa3-b9e2-1121c35f6504
-document
-System
-System
-Data Dictionary
-
-2008-07-11T16:51:03.509+01:00
-http://localhost:80/alfresco/images/icons/space-icon-default-16.gif
-
-
-System
-6dc1e4b5-d959-4ca8-b20c-21ce05fe8889
-urn:uuid:6dc1e4b5-d959-4ca8-b20c-21ce05fe8889
-
-
-
-
-
-
-
-2008-07-11T16:50:25.698+01:00
-The guest root space
-Guest Home
-2008-07-11T16:51:03.515+01:00
-
-2008-07-11T16:50:25.698+01:00
-2008-07-11T16:51:03.515+01:00
-workspace://SpacesStore/6dc1e4b5-d959-4ca8-b20c-21ce05fe8889
-workspace://SpacesStore/ffddcc48-0c6a-4aa3-b9e2-1121c35f6504
-document
-System
-System
-Guest Home
-
-2008-07-11T16:51:03.515+01:00
-http://localhost:80/alfresco/images/icons/space-icon-default-16.gif
-
-
-System
-7d35ea01-5bfd-4785-92c3-3dc19623b162
-urn:uuid:7d35ea01-5bfd-4785-92c3-3dc19623b162
-
-
-
-
-
-
-
-2008-07-11T16:50:25.822+01:00
-User Homes
-User Homes
-2008-07-11T16:51:03.516+01:00
-
-2008-07-11T16:50:25.822+01:00
-2008-07-11T16:51:03.516+01:00
-workspace://SpacesStore/7d35ea01-5bfd-4785-92c3-3dc19623b162
-workspace://SpacesStore/ffddcc48-0c6a-4aa3-b9e2-1121c35f6504
-document
-System
-System
-User Homes
-
-2008-07-11T16:51:03.516+01:00
-http://localhost:80/alfresco/images/icons/space-icon-default-16.gif
-
-
-admin
-605a7b77-c3b7-4583-85e6-04183ba69e44
-urn:uuid:605a7b77-c3b7-4583-85e6-04183ba69e44
-
-
-
-
-
-
-
-2008-07-11T16:51:20.786+01:00
-CMIS Tests (summary)
-CMIS Tests
-2008-07-11T16:51:20.830+01:00
-
-2008-07-11T16:51:20.786+01:00
-2008-07-11T16:51:20.830+01:00
-workspace://SpacesStore/605a7b77-c3b7-4583-85e6-04183ba69e44
-workspace://SpacesStore/ffddcc48-0c6a-4aa3-b9e2-1121c35f6504
-document
-admin
-admin
-CMIS Tests
-
-2008-07-11T16:51:20.830+01:00
-http://localhost:80/alfresco/images/icons/space-icon-default-16.gif
-
-
-System
-79f2bb8b-a0ff-4e96-908c-85e794684104
-urn:uuid:79f2bb8b-a0ff-4e96-908c-85e794684104
-
-
-
-
-
-
-
-2008-07-11T22:08:33.603+01:00
-Web Content Management Spaces
-Web Projects
-2008-07-11T22:08:33.676+01:00
-
-2008-07-11T22:08:33.603+01:00
-2008-07-11T22:08:33.676+01:00
-workspace://SpacesStore/79f2bb8b-a0ff-4e96-908c-85e794684104
-workspace://SpacesStore/ffddcc48-0c6a-4aa3-b9e2-1121c35f6504
-document
-System
-System
-Web Projects
-
-2008-07-11T22:08:33.676+01:00
-http://localhost:80/alfresco/images/icons/space-icon-default-16.gif
-
false
-
-2008-07-11T16:50:25.179+01:00
-2008-07-11T16:51:03.508+01:00
-workspace://SpacesStore/ffddcc48-0c6a-4aa3-b9e2-1121c35f6504
-workspace://SpacesStore/b9a00044-9a14-4733-a745-2bfb83915da8
-document
-System
-System
-Company Home
-
6
0
0
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderChildren.xml b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderChildren.xml
index 6831ea988f..c41960d719 100755
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderChildren.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderChildren.xml
@@ -5,7 +5,7 @@
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
+ xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS.xsd ">
2001-12-31T12:00:00
-
+
+
+
+
+ 2001-12-31T12:00:00
+
+
+ 2001-12-31T12:00:00
+
+
+
+ folderid1
+
+
+ parentFolderId1
+
+
+
+ emailfolder
+
+
+ folder
+
+
+
true
true
@@ -88,29 +112,9 @@
true
true
-
-
-
- 2001-12-31T12:00:00
-
-
- 2001-12-31T12:00:00
-
-
-
- folderid1
-
-
- parentFolderId1
-
-
-
- emailfolder
-
-
- folder
-
-
+
+
+
@@ -167,7 +171,71 @@
2001-12-31T12:00:00
-
+
+
+
+ docid1
+
+
+
+ false
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+ 2001-12-31T12:00:00
+
+
+ 2001-12-31T12:00:00
+
+
+
+
+
+ 70
+
+
+
+ email
+
+
+ document
+
+
+
+ This is the initial checkin comment
+
+
+ 1.0
+
+
+ text/plain
+
+
+ foo.txt
+
+
+
+ http://www.cmis.org/rep1/media/document-entry
+
+
+
true
true
@@ -187,72 +255,11 @@
true
true
-
-
-
- false
-
-
- true
-
-
- true
-
-
- true
-
-
- false
-
-
- false
-
-
-
- 2001-12-31T12:00:00
-
-
- 2001-12-31T12:00:00
-
-
-
- docid1
-
-
-
-
- 70
-
-
-
- email
-
-
- document
-
-
-
-
- This is the initial checkin comment
-
-
- 1.0
-
-
- text/plain
-
-
- foo.txt
-
-
-
- http://www.cmis.org/rep1/media/document-entry
-
-
+
+
+
true
-
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderDescendants.xml b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderDescendants.xml
index 9737a1f9b1..82babcd694 100755
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderDescendants.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderDescendants.xml
@@ -1,41 +1,28 @@
-
-
Al Brown
-
http://www.cmis.org/rep1/folder1/children/3
-
-
+
-
-
-
+
+
+
-
Folder1's Children - page 3
-
2007-12-31T12:00:00
@@ -54,10 +41,8 @@
http://www.cmis.org/rep1/folder-entry2
-
-
+
+
-
+
2001-12-31T12:00:00
-
Folder Entry2 example
2001-12-31T12:00:00
-
-
-
- true
- true
- true
- true
- true
- true
- true
- true
- true
-
-
-
-
- 2001-12-31T12:00:00
-
-
- 2001-12-31T12:00:00
-
-
-
- folderid2
-
-
- folderid1
-
-
-
- emailfolder
-
-
- folder
-
-
+
+
+
+ 2001-12-31T12:00:00
+
+
+ 2001-12-31T12:00:00
+
+
+ folderid2
+
+
+ folderid1
+
+
+ emailfolder
+
+
+ folder
+
+
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+
@@ -119,18 +101,15 @@
-
+
http://www.cmis.org/rep1/document-entry2
-
-
+
+
-
+
2001-12-31T12:00:00
-
-
Document Entry2 example
2001-12-31T12:00:00
-
-
-
- true
-
- true
-
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
-
- true
-
- true
- true
- true
-
-
-
-
- false
-
-
- true
-
-
- true
-
-
- true
-
-
- false
-
-
- false
-
-
-
- 2001-12-31T12:00:00
-
-
- 2001-12-31T12:00:00
-
-
-
- docid2
-
-
-
-
-
- 70
-
-
-
- email
-
-
- document
-
-
-
-
- This is the initial checkin comment
-
-
- 1.0
-
-
- text/plain
-
-
- foo.txt
-
-
-
- http://www.cmis.org/rep1/media/document-entry
-
-
-
+
+
+
+ false
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+ 2001-12-31T12:00:00
+
+
+ 2001-12-31T12:00:00
+
+
+ docid2
+
+
+
+ 70
+
+
+ email
+
+
+ document
+
+
+
+ This is the initial checkin comment
+
+
+ 1.0
+
+
+ text/plain
+
+
+ foo.txt
+
+
+ http://www.cmis.org/rep1/media/document-entry
+
+
+
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+
+
@@ -269,18 +231,15 @@
-
+
http://www.cmis.org/rep1/document-entry
-
-
+
+
-
+
2001-12-31T12:00:00
-
-
Document Entry example
2001-12-31T12:00:00
-
-
-
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
-
-
-
-
- false
-
-
- true
-
-
- true
-
-
- true
-
-
- false
-
-
- false
-
-
-
- 2001-12-31T12:00:00
-
-
- 2001-12-31T12:00:00
-
-
-
- docid1
-
-
-
-
- 70
-
-
-
- email
-
-
- document
-
-
-
-
- This is the initial checkin comment
-
-
- 1.0
-
-
- text/plain
-
-
- foo.txt
-
-
-
- http://www.cmis.org/rep1/media/document-entry
-
-
+
+
+
+ false
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+ 2001-12-31T12:00:00
+
+
+ 2001-12-31T12:00:00
+
+
+ docid1
+
+
+
+ 70
+
+
+ email
+
+
+ document
+
+
+
+
+ This is the initial checkin comment
+
+
+ 1.0
+
+
+ text/plain
+
+
+ foo.txt
+
+
+ http://www.cmis.org/rep1/media/document-entry
+
+
+
+
+
true
-
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderEntry.xml b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderEntry.xml
index 4626c44ca5..efeef5f5ae 100755
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderEntry.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-FolderEntry.xml
@@ -1,13 +1,9 @@
-
-
+ xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS.xsd ">
Al Brown
@@ -24,50 +20,52 @@
-
+
-
+
-
+
2001-12-31T12:00:00
-
Folder Entry example
2001-12-31T12:00:00
-
-
-
- true
- true
- true
- true
- true
- true
- true
- true
- true
-
+
+
+
+ 2001-12-31T12:00:00
+
+
+ 2001-12-31T12:00:00
+
+ folderid1
+ parentFolderId1
+
+ emailfolder
+
+
+ folder
+
+
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+
+
-
- 2001-12-31T12:00:00
- 2001-12-31T12:00:00
-
- folderid1
- parentFolderId1
-
- emailfolder
- folder
-
-
-
-
+
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-PolicyEntry.xml b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-PolicyEntry.xml
index 0666031cfa..66c0f032c5 100755
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-PolicyEntry.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-PolicyEntry.xml
@@ -1,12 +1,9 @@
-
+ xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS.xsd ">
Al Brown
@@ -21,46 +18,48 @@
http://www.cmis.org/rep1/policy-entry
-
-
+
+
-
-
-
+
+
+
2001-12-31T12:00:00
-
Policy Entry example
2001-12-31T12:00:00
-
+
+
+
+ 2001-12-31T12:00:00
+
+
+ 2001-12-31T12:00:00
+
+
+ policyid1
+
+
+ security policy
+
+
+ policy
+
+
-
- true
- true
- true
- true
- true
-
-
-
- 2001-12-31T12:00:00
- 2001-12-31T12:00:00
-
- policyid1
-
- security policy
- policy
-
-
-
+
+ true
+ true
+ true
+ true
+ true
+
+
+
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-Query.xml b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-Query.xml
index e5aec64976..3e93208fe6 100755
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-Query.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-Query.xml
@@ -2,10 +2,10 @@
+ xsi:schemaLocation="http://www.cmis.org/2008/05 CMIS.xsd ">
SELECT * FROM document
true
0
0
false
-
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-RelationshipEntry.xml b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-RelationshipEntry.xml
index ad93a1d0b7..b5308e9794 100755
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-RelationshipEntry.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-RelationshipEntry.xml
@@ -1,12 +1,9 @@
-
+ xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS.xsd ">
Al Brown
@@ -21,16 +18,13 @@
http://www.cmis.org/rep1/relationship-entry
-
-
+
+
-
+
2001-12-31T12:00:00
-
Relationship Entry example
2001-12-31T12:00:00
-
-
-
- true
- true
- true
- true
- true
-
+
+
+
+ 2001-12-31T12:00:00
+
+
+ 2001-12-31T12:00:00
+
+
+ relid1
+
+
+ docid1
+
+
+ docid2
+
+
+ emaillink
+
+
+ relationship
+
+
+
+
+ true
+ true
+ true
+ true
+ true
+
+
-
- 2001-12-31T12:00:00
- 2001-12-31T12:00:00
-
- relid1
- docid1
- docid2
-
- emaillink
- relationship
-
-
+
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-Service.xml b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-Service.xml
index b8343ba592..faf722b305 100755
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-Service.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-Service.xml
@@ -1,45 +1,56 @@
+ xsi:schemaLocation="http://www.w3.org/2007/app APP.xsd http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS.xsd ">
Repository 1
repid1
repository1
+ Self
Repository Description
ACME Vendor
ACME Repository
ACME Version 99.01
+ rootFolderId
true
true
true
true
+ true
true
- innerAndOuter
+ fulltextonly
+ innerandouter
fulltextandstructured
0.43
- Welcome to ACME 99
+ Local Message in vendor specific schema
unfiled collection
-
+
+ root collection
+
+
root collection
checkedout collection
-
+
+ type collection
+
+
type collection
type collection
-
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-Type.xml b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-Type.xml
index f1e2d4453a..786ceb0362 100755
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/Example-Type.xml
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/Example-Type.xml
@@ -1,43 +1,68 @@
-
- documentTypeId
- document
- 2001-12-31T12:00:00
- 2001-12-31T12:00:00
- document
- document
- document
-
- The document type
- true
- true
- true
- true
- true
- allowed
+
+
+ System
+ Document Type
+
+ http://www.cmis.org/id1
+ document
+ 2001-12-31T12:00:00
+
+
+ documentTypeId
+ document
+ document
+
+ document
+ document
+
+
+ The document type
+ true
+ true
+ true
+ true
+ true
-
-
- foo1
- propIdForFoo1
- foo1
- Description of foo1
- false
- String
- Single
- 64
- cmis:choices
- true
- true
- cmis:defaultValue
- ro
- true
- true
-
+
+
+ foo1
+
+ propIdForFoo1
+
+ foo1
+ Description of foo1
+ string
+ single
+ readonly
+
+ false
+ true
+ true
+ true
+
+ foo1
+ foo2
-
\ No newline at end of file
+
+ true
+
+
+ default value
+
+
+ 1024
+
+
+
+ true
+ allowed
+
+
+
+
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/xhtml1-strict.xsd b/source/java/org/alfresco/repo/cmis/rest/xsd/xhtml1-strict.xsd
index dfd54f8bbc..eaced8ed93 100644
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/xhtml1-strict.xsd
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/xhtml1-strict.xsd
@@ -1,5 +1,10 @@
-
+
@@ -211,7 +216,7 @@
-
+
@@ -222,7 +227,7 @@
-
+
@@ -257,7 +262,7 @@
-
+
diff --git a/source/java/org/alfresco/repo/cmis/rest/xsd/xml.xsd b/source/java/org/alfresco/repo/cmis/rest/xsd/xml.xsd
index 9cfd945778..6ec0d476f4 100644
--- a/source/java/org/alfresco/repo/cmis/rest/xsd/xml.xsd
+++ b/source/java/org/alfresco/repo/cmis/rest/xsd/xml.xsd
@@ -1,145 +1,48 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- See http://www.w3.org/XML/1998/namespace.html and
- http://www.w3.org/TR/REC-xml for information about this namespace.
+
+
+
+
+
+
+
+
- This schema document describes the XML namespace, in a form
- suitable for import by other schema documents.
-
- Note that local names in this namespace are intended to be defined
- only by the World Wide Web Consortium or its subgroups. The
- following names are currently defined in this namespace and should
- not be used with conflicting semantics by any Working Group,
- specification, or document instance:
-
- base (as an attribute name): denotes an attribute whose value
- provides a URI to be used as the base for interpreting any
- relative URIs in the scope of the element on which it
- appears; its value is inherited. This name is reserved
- by virtue of its definition in the XML Base specification.
-
- id (as an attribute name): denotes an attribute whose value
- should be interpreted as if declared to be of type ID.
- This name is reserved by virtue of its definition in the
- xml:id specification.
-
- lang (as an attribute name): denotes an attribute whose value
- is a language code for the natural language of the content of
- any element; its value is inherited. This name is reserved
- by virtue of its definition in the XML specification.
-
- space (as an attribute name): denotes an attribute whose
- value is a keyword indicating what whitespace processing
- discipline is intended for the content of the element; its
- value is inherited. This name is reserved by virtue of its
- definition in the XML specification.
-
- Father (in any context at all): denotes Jon Bosak, the chair of
- the original XML Working Group. This name is reserved by
- the following decision of the W3C XML Plenary and
- XML Coordination groups:
-
- In appreciation for his vision, leadership and dedication
- the W3C XML Plenary on this 10th day of February, 2000
- reserves for Jon Bosak in perpetuity the XML name
- xml:Father
-
-
-
-
- This schema defines attributes and an attribute group
- suitable for use by
- schemas wishing to allow xml:base, xml:lang, xml:space or xml:id
- attributes on elements they define.
-
- To enable this, such a schema must import this schema
- for the XML namespace, e.g. as follows:
- <schema . . .>
- . . .
- <import namespace="http://www.w3.org/XML/1998/namespace"
- schemaLocation="http://www.w3.org/2001/xml.xsd"/>
-
- Subsequently, qualified reference to any of the attributes
- or the group defined below will have the desired effect, e.g.
-
- <type . . .>
- . . .
- <attributeGroup ref="xml:specialAttrs"/>
+
+
+ See http://www.w3.org/TR/xmlbase/ for
+ information about this attribute.
+
+
- will define a type which will schema-validate an instance
- element with any of those attributes
-
+
+
+ See http://www.w3.org/TR/xml-id/ for
+ information about this attribute.
+
+
-
- In keeping with the XML Schema WG's standard versioning
- policy, this schema document will persist at
- http://www.w3.org/2007/08/xml.xsd.
- At the date of issue it can also be found at
- http://www.w3.org/2001/xml.xsd.
- The schema document at that URI may however change in the future,
- in order to remain compatible with the latest version of XML Schema
- itself, or with the XML namespace itself. In other words, if the XML
- Schema or XML namespaces change, the version of this document at
- http://www.w3.org/2001/xml.xsd will change
- accordingly; the version at
- http://www.w3.org/2007/08/xml.xsd will not change.
-
-
+
+
+
+
+
+
-
-
- Attempting to install the relevant ISO 2- and 3-letter
- codes as the enumerated possible values is probably never
- going to be a realistic possibility. See
- RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry
- at http://www.iana.org/assignments/lang-tag-apps.htm for
- further information.
-
- The union allows for the 'un-declaration' of xml:lang with
- the empty string.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- See http://www.w3.org/TR/xmlbase/ for
- information about this attribute.
-
-
-
-
-
- See http://www.w3.org/TR/xml-id/ for
- information about this attribute.
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cmis/ws/DMAbstractServicePort.java b/source/java/org/alfresco/repo/cmis/ws/DMAbstractServicePort.java
index 8c652624e4..12b5ab41ab 100644
--- a/source/java/org/alfresco/repo/cmis/ws/DMAbstractServicePort.java
+++ b/source/java/org/alfresco/repo/cmis/ws/DMAbstractServicePort.java
@@ -36,7 +36,6 @@ 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;
@@ -108,7 +107,7 @@ public class DMAbstractServicePort
if (filter.allow(name) && value != null)
{
PropertyBooleanType propBoolean = new PropertyBooleanType();
- propBoolean.setName(CMISPropertyNameMapping.getWebServiceName(name));
+ propBoolean.setName(name);
propBoolean.setValue((Boolean) value);
properties.getPropertyBoolean().add(propBoolean);
}
@@ -120,7 +119,7 @@ public class DMAbstractServicePort
if (filter.allow(name) && value != null)
{
PropertyDateTimeType propDateTime = new PropertyDateTimeType();
- propDateTime.setName(CMISPropertyNameMapping.getWebServiceName(name));
+ propDateTime.setName(name);
propDateTime.setValue(convert((Date) value));
properties.getPropertyDateTime().add(propDateTime);
}
@@ -132,7 +131,7 @@ public class DMAbstractServicePort
if (filter.allow(name) && value != null)
{
PropertyIDType propID = new PropertyIDType();
- propID.setName(CMISPropertyNameMapping.getWebServiceName(name));
+ propID.setName(name);
propID.setValue(value.toString());
properties.getPropertyID().add(propID);
}
@@ -144,7 +143,7 @@ public class DMAbstractServicePort
if (filter.allow(name) && value != null)
{
PropertyIntegerType propInteger = new PropertyIntegerType();
- propInteger.setName(CMISPropertyNameMapping.getWebServiceName(name));
+ propInteger.setName(name);
propInteger.setValue(BigInteger.valueOf((Long) value));
properties.getPropertyInteger().add(propInteger);
}
@@ -156,7 +155,7 @@ public class DMAbstractServicePort
if (filter.allow(name) && value != null)
{
PropertyStringType propString = new PropertyStringType();
- propString.setName(CMISPropertyNameMapping.getWebServiceName(name));
+ propString.setName(name);
propString.setValue(value.toString());
properties.getPropertyString().add(propString);
}
@@ -179,7 +178,7 @@ public class DMAbstractServicePort
if (filter.allow(name) && value != null)
{
PropertyURIType propString = new PropertyURIType();
- propString.setName(CMISPropertyNameMapping.getWebServiceName(name));
+ propString.setName(name);
propString.setValue(value.toString());
properties.getPropertyURI().add(propString);
}
@@ -205,7 +204,7 @@ public class DMAbstractServicePort
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_LATEST_VERSION, nodeRef);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_MAJOR_VERSION, nodeRef);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_LATEST_MAJOR_VERSION, nodeRef);
- addBooleanProperty(properties, filter, CMISMapping.PROP_VERSION_SERIES_IS_CHECKED_OUT, nodeRef);
+ addBooleanProperty(properties, filter, CMISMapping.PROP_IS_VERSION_SERIES_CHECKED_OUT, nodeRef);
addDateTimeProperty(properties, filter, CMISMapping.PROP_CREATION_DATE, nodeRef);
addDateTimeProperty(properties, filter, CMISMapping.PROP_LAST_MODIFICATION_DATE, nodeRef);
addIDProperty(properties, filter, CMISMapping.PROP_OBJECT_ID, nodeRef);
@@ -229,7 +228,7 @@ public class DMAbstractServicePort
addDateTimeProperty(properties, filter, CMISMapping.PROP_CREATION_DATE, nodeRef);
addDateTimeProperty(properties, filter, CMISMapping.PROP_LAST_MODIFICATION_DATE, nodeRef);
addIDProperty(properties, filter, CMISMapping.PROP_OBJECT_ID, nodeRef);
- addIDProperty(properties, filter, CMISMapping.PROP_PARENT, nodeRef);
+ addIDProperty(properties, filter, CMISMapping.PROP_PARENT_ID, nodeRef);
addStringProperty(properties, filter, CMISMapping.PROP_NAME, nodeRef);
addStringProperty(properties, filter, "baseType", "folder");
addIDProperty(properties, filter, CMISMapping.PROP_OBJECT_TYPE_ID, nodeRef);
diff --git a/source/java/org/alfresco/repo/cmis/ws/DMNavigationServicePort.java b/source/java/org/alfresco/repo/cmis/ws/DMNavigationServicePort.java
index 625e58d3d6..1219ff1c7f 100644
--- a/source/java/org/alfresco/repo/cmis/ws/DMNavigationServicePort.java
+++ b/source/java/org/alfresco/repo/cmis/ws/DMNavigationServicePort.java
@@ -27,7 +27,7 @@ package org.alfresco.repo.cmis.ws;
import java.math.BigInteger;
import java.util.List;
-import org.alfresco.cmis.CMISService.TypesFilter;
+import org.alfresco.cmis.CMISTypesFilterEnum;
import org.alfresco.cmis.dictionary.CMISMapping;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -75,15 +75,15 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
switch (parameters.getType())
{
case DOCUMENTS:
- listing = cmisService.getChildren(folderNodeRef, TypesFilter.Documents);
+ listing = cmisService.getChildren(folderNodeRef, CMISTypesFilterEnum.DOCUMENTS);
break;
case FOLDERS:
- listing = cmisService.getChildren(folderNodeRef, TypesFilter.Folders);
+ listing = cmisService.getChildren(folderNodeRef, CMISTypesFilterEnum.FOLDERS);
break;
case POLICIES:
throw new OperationNotSupportedException("Policies listing isn't supported", ExceptionUtils.createBasicFault(null, "Policies listing isn't supported"));
case ANY:
- listing = cmisService.getChildren(folderNodeRef, TypesFilter.Any);
+ listing = cmisService.getChildren(folderNodeRef, CMISTypesFilterEnum.ANY);
break;
}
diff --git a/source/java/org/alfresco/repo/cmis/ws/DMRepositoryServicePort.java b/source/java/org/alfresco/repo/cmis/ws/DMRepositoryServicePort.java
index e49f3a213a..6279488304 100644
--- a/source/java/org/alfresco/repo/cmis/ws/DMRepositoryServicePort.java
+++ b/source/java/org/alfresco/repo/cmis/ws/DMRepositoryServicePort.java
@@ -31,15 +31,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.alfresco.cmis.dictionary.CMISCardinality;
+import org.alfresco.cmis.CMISCardinalityEnum;
+import org.alfresco.cmis.CMISContentStreamAllowedEnum;
+import org.alfresco.cmis.CMISFullTextSearchEnum;
+import org.alfresco.cmis.CMISJoinEnum;
+import org.alfresco.cmis.CMISPropertyTypeEnum;
+import org.alfresco.cmis.CMISUpdatabilityEnum;
import org.alfresco.cmis.dictionary.CMISPropertyDefinition;
-import org.alfresco.cmis.dictionary.CMISPropertyType;
import org.alfresco.cmis.dictionary.CMISTypeDefinition;
import org.alfresco.cmis.dictionary.CMISTypeId;
-import org.alfresco.cmis.dictionary.CMISUpdatability;
-import org.alfresco.cmis.dictionary.ContentStreamAllowed;
-import org.alfresco.cmis.search.FullTextSearchSupport;
-import org.alfresco.cmis.search.JoinSupport;
import org.alfresco.service.descriptor.Descriptor;
/**
@@ -51,49 +51,49 @@ import org.alfresco.service.descriptor.Descriptor;
@javax.jws.WebService(name = "RepositoryServicePort", serviceName = "RepositoryService", portName = "RepositoryServicePort", targetNamespace = "http://www.cmis.org/ns/1.0", endpointInterface = "org.alfresco.repo.cmis.ws.RepositoryServicePort")
public class DMRepositoryServicePort extends DMAbstractServicePort implements RepositoryServicePort
{
- private static Map fulltextEnumMapping;
- private static Map joinEnumMapping;
- private static Map contentStreamAllowedEnumMapping;
- private static Map updatabilityEnumMapping;
- private static Map cardinalityEnumMapping;
- private static Map propertyTypeEnumMapping;
+ private static Map fulltextEnumMapping;
+ private static Map joinEnumMapping;
+ private static Map contentStreamAllowedEnumMapping;
+ private static Map updatabilityEnumMapping;
+ private static Map cardinalityEnumMapping;
+ private static Map propertyTypeEnumMapping;
static
{
- fulltextEnumMapping = new HashMap();
- fulltextEnumMapping.put(FullTextSearchSupport.NO_FULL_TEXT, FulltextEnum.NO_FULLTEXT);
- fulltextEnumMapping.put(FullTextSearchSupport.FULL_TEXT_ONLY, FulltextEnum.FULLTEXT_ONLY);
- fulltextEnumMapping.put(FullTextSearchSupport.FULL_TEXT_AND_STRUCTURED, FulltextEnum.FULLTEXT_AND_STRUCTURED);
+ fulltextEnumMapping = new HashMap();
+ fulltextEnumMapping.put(CMISFullTextSearchEnum.NO_FULL_TEXT, FulltextEnum.NO_FULLTEXT);
+ fulltextEnumMapping.put(CMISFullTextSearchEnum.FULL_TEXT_ONLY, FulltextEnum.FULLTEXT_ONLY);
+ fulltextEnumMapping.put(CMISFullTextSearchEnum.FULL_TEXT_AND_STRUCTURED, FulltextEnum.FULLTEXT_AND_STRUCTURED);
- joinEnumMapping = new HashMap();
- joinEnumMapping.put(JoinSupport.INNER_AND_OUTER_JOIN_SUPPORT, JoinEnum.INNER_AND_OUTER);
- joinEnumMapping.put(JoinSupport.INNER_JOIN_SUPPORT, JoinEnum.INNER_ONLY);
- joinEnumMapping.put(JoinSupport.NO_JOIN_SUPPORT, JoinEnum.NO_JOIN);
+ joinEnumMapping = new HashMap();
+ joinEnumMapping.put(CMISJoinEnum.INNER_AND_OUTER_JOIN_SUPPORT, JoinEnum.INNER_AND_OUTER);
+ joinEnumMapping.put(CMISJoinEnum.INNER_JOIN_SUPPORT, JoinEnum.INNER_ONLY);
+ joinEnumMapping.put(CMISJoinEnum.NO_JOIN_SUPPORT, JoinEnum.NO_JOIN);
- contentStreamAllowedEnumMapping = new HashMap();
- contentStreamAllowedEnumMapping.put(ContentStreamAllowed.ALLOWED, ContentStreamAllowedEnum.ALLOWED);
- contentStreamAllowedEnumMapping.put(ContentStreamAllowed.NOT_ALLOWED, ContentStreamAllowedEnum.NOT_ALLOWED);
- contentStreamAllowedEnumMapping.put(ContentStreamAllowed.REQUIRED, ContentStreamAllowedEnum.REQUIRED);
+ contentStreamAllowedEnumMapping = new HashMap();
+ contentStreamAllowedEnumMapping.put(CMISContentStreamAllowedEnum.ALLOWED, ContentStreamAllowedEnum.ALLOWED);
+ contentStreamAllowedEnumMapping.put(CMISContentStreamAllowedEnum.NOT_ALLOWED, ContentStreamAllowedEnum.NOT_ALLOWED);
+ contentStreamAllowedEnumMapping.put(CMISContentStreamAllowedEnum.REQUIRED, ContentStreamAllowedEnum.REQUIRED);
- updatabilityEnumMapping = new HashMap();
- updatabilityEnumMapping.put(CMISUpdatability.READ_AND_WRITE, UpdatabilityEnum.READ_WRITE);
- updatabilityEnumMapping.put(CMISUpdatability.READ_AND_WRITE_WHEN_CHECKED_OUT, UpdatabilityEnum.READ_WRITE_WHEN_CHECKED_OUT);
- updatabilityEnumMapping.put(CMISUpdatability.READ_ONLY, UpdatabilityEnum.READ_ONLY);
+ updatabilityEnumMapping = new HashMap();
+ updatabilityEnumMapping.put(CMISUpdatabilityEnum.READ_AND_WRITE, UpdatabilityEnum.READ_WRITE);
+ updatabilityEnumMapping.put(CMISUpdatabilityEnum.READ_AND_WRITE_WHEN_CHECKED_OUT, UpdatabilityEnum.READ_WRITE_WHEN_CHECKED_OUT);
+ updatabilityEnumMapping.put(CMISUpdatabilityEnum.READ_ONLY, UpdatabilityEnum.READ_ONLY);
- cardinalityEnumMapping = new HashMap();
- cardinalityEnumMapping.put(CMISCardinality.MULTI_VALUED, CardinalityEnum.MULTI_VALUED);
- cardinalityEnumMapping.put(CMISCardinality.SINGLE_VALUED, CardinalityEnum.SINGLE_VALUED);
+ cardinalityEnumMapping = new HashMap();
+ cardinalityEnumMapping.put(CMISCardinalityEnum.MULTI_VALUED, CardinalityEnum.MULTI_VALUED);
+ cardinalityEnumMapping.put(CMISCardinalityEnum.SINGLE_VALUED, CardinalityEnum.SINGLE_VALUED);
- propertyTypeEnumMapping = new HashMap();
- propertyTypeEnumMapping.put(CMISPropertyType.Boolean, PropertyTypeEnum.BOOLEAN);
- propertyTypeEnumMapping.put(CMISPropertyType.DateTime, PropertyTypeEnum.DATE_TIME);
- propertyTypeEnumMapping.put(CMISPropertyType.Decimal, PropertyTypeEnum.DECIMAL);
- propertyTypeEnumMapping.put(CMISPropertyType.HTML, PropertyTypeEnum.HTML);
- propertyTypeEnumMapping.put(CMISPropertyType.ID, PropertyTypeEnum.ID);
- propertyTypeEnumMapping.put(CMISPropertyType.Integer, PropertyTypeEnum.INTEGER);
- propertyTypeEnumMapping.put(CMISPropertyType.String, PropertyTypeEnum.STRING);
- propertyTypeEnumMapping.put(CMISPropertyType.URI, PropertyTypeEnum.URI);
- propertyTypeEnumMapping.put(CMISPropertyType.XML, PropertyTypeEnum.XML);
+ propertyTypeEnumMapping = new HashMap();
+ propertyTypeEnumMapping.put(CMISPropertyTypeEnum.BOOLEAN, PropertyTypeEnum.BOOLEAN);
+ propertyTypeEnumMapping.put(CMISPropertyTypeEnum.DATETIME, PropertyTypeEnum.DATE_TIME);
+ propertyTypeEnumMapping.put(CMISPropertyTypeEnum.DECIMAL, PropertyTypeEnum.DECIMAL);
+ propertyTypeEnumMapping.put(CMISPropertyTypeEnum.HTML, PropertyTypeEnum.HTML);
+ propertyTypeEnumMapping.put(CMISPropertyTypeEnum.ID, PropertyTypeEnum.ID);
+ propertyTypeEnumMapping.put(CMISPropertyTypeEnum.INTEGER, PropertyTypeEnum.INTEGER);
+ propertyTypeEnumMapping.put(CMISPropertyTypeEnum.STRING, PropertyTypeEnum.STRING);
+ propertyTypeEnumMapping.put(CMISPropertyTypeEnum.URI, PropertyTypeEnum.URI);
+ propertyTypeEnumMapping.put(CMISPropertyTypeEnum.XML, PropertyTypeEnum.XML);
}
public List getRepositories() throws RuntimeException, InvalidArgumentException, OperationNotSupportedException, UpdateConflictException,
@@ -102,7 +102,6 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
RepositoryType repositoryType = new RepositoryType();
Descriptor serverDescriptor = descriptorService.getCurrentRepositoryDescriptor();
repositoryType.setRepositoryID(serverDescriptor.getId());
- System.out.println("**** ID: " + serverDescriptor.getId());
repositoryType.setRepositoryName(serverDescriptor.getName());
return Collections.singletonList(repositoryType);
}
diff --git a/source/java/org/alfresco/repo/web/scripts/BaseWebScriptTest.java b/source/java/org/alfresco/repo/web/scripts/BaseWebScriptTest.java
index 2aeb9e49a1..b0c938e0fb 100644
--- a/source/java/org/alfresco/repo/web/scripts/BaseWebScriptTest.java
+++ b/source/java/org/alfresco/repo/web/scripts/BaseWebScriptTest.java
@@ -25,10 +25,15 @@
package org.alfresco.repo.web.scripts;
import java.io.IOException;
+import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.Map;
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
import junit.framework.TestCase;
+import junit.framework.TestListener;
+import junit.textui.ResultPrinter;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
@@ -47,8 +52,6 @@ import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.params.HttpClientParams;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* Base unit test class for web scripts.
@@ -57,14 +60,111 @@ import org.apache.commons.logging.LogFactory;
*/
public abstract class BaseWebScriptTest extends TestCase
{
- // Logger
- private static final Log logger = LogFactory.getLog(BaseWebScriptTest.class);
+ // Test Listener
+ private WebScriptTestListener listener = null;
+ private boolean traceReqRes = false;
/** Local / Remote Server access */
private String defaultRunAs = null;
private RemoteServer remoteServer = null;
private HttpClient httpClient = null;
+
+ /**
+ * Web Script Test Listener
+ */
+ public static interface WebScriptTestListener extends TestListener
+ {
+ public void addLog(Test test, String log);
+ }
+
+ /**
+ * Default Test Listener
+ */
+ public static class BaseWebScriptTestListener extends ResultPrinter implements WebScriptTestListener
+ {
+ /**
+ * Construct
+ *
+ * @param writer
+ */
+ public BaseWebScriptTestListener(PrintStream writer)
+ {
+ super(writer);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.textui.ResultPrinter#addError(junit.framework.Test, java.lang.Throwable)
+ */
+ @Override
+ public void addError(Test test, Throwable t)
+ {
+ getWriter().println("*** Error: " + ((BaseWebScriptTest)test).getName());
+ t.printStackTrace(getWriter());
+ }
+
+ /* (non-Javadoc)
+ * @see junit.textui.ResultPrinter#addFailure(junit.framework.Test, junit.framework.AssertionFailedError)
+ */
+ @Override
+ public void addFailure(Test test, AssertionFailedError t)
+ {
+ getWriter().println("*** Failed: " + ((BaseWebScriptTest)test).getName());
+ t.printStackTrace(getWriter());
+ }
+
+ /* (non-Javadoc)
+ * @see junit.textui.ResultPrinter#endTest(junit.framework.Test)
+ */
+ @Override
+ public void endTest(Test test)
+ {
+ getWriter().println();
+ getWriter().println("*** Test completed: " + ((BaseWebScriptTest)test).getName());
+ }
+
+ /* (non-Javadoc)
+ * @see junit.textui.ResultPrinter#startTest(junit.framework.Test)
+ */
+ @Override
+ public void startTest(Test test)
+ {
+ getWriter().println();
+ getWriter().println("*** Test started: " + ((BaseWebScriptTest)test).getName() + " (remote: " + (((BaseWebScriptTest)test).getRemoteServer() != null));
+ }
+
+ /**
+ * Add an arbitrary log statement
+ *
+ * @param test
+ * @param log
+ */
+ public void addLog(Test test, String log)
+ {
+ this.getWriter().println(log);
+ }
+ }
+
+ /**
+ * Sets Test Listener
+ *
+ * @param resultPrinter
+ */
+ public void setListener(WebScriptTestListener listener)
+ {
+ this.listener = listener;
+ }
+
+ /**
+ * Sets whether to trace request / response bodies
+ *
+ * @param traceReqRes
+ */
+ public void setTraceReqRes(boolean traceReqRes)
+ {
+ this.traceReqRes = traceReqRes;
+ }
+
/**
* Set Remote Server context
*
@@ -74,6 +174,16 @@ public abstract class BaseWebScriptTest extends TestCase
{
remoteServer = server;
}
+
+ /**
+ * Gets Remote Server
+ *
+ * @return
+ */
+ public RemoteServer getRemoteServer()
+ {
+ return remoteServer;
+ }
/**
* Set Local Run As User
@@ -97,7 +207,6 @@ public abstract class BaseWebScriptTest extends TestCase
httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(remoteServer.username, remoteServer.password));
}
}
-
/** Test web script server */
private static TestWebScriptServer server = null;
@@ -111,6 +220,28 @@ public abstract class BaseWebScriptTest extends TestCase
return BaseWebScriptTest.server;
}
+ /**
+ * Is Log Enabled?
+ *
+ * @return true => enabled
+ */
+ protected boolean isLogEnabled()
+ {
+ return listener != null;
+ }
+
+ /**
+ * Log Message to Test Listener
+ *
+ * @param log
+ */
+ protected void log(String log)
+ {
+ if (listener != null)
+ {
+ listener.addLog(this, log);
+ }
+ }
/**
* Send Request to Test Web Script Server (as admin)
@@ -138,8 +269,11 @@ public abstract class BaseWebScriptTest extends TestCase
protected Response sendRequest(Request req, int expectedStatus, String asUser)
throws IOException
{
- if (logger.isInfoEnabled())
- logger.info("Request: " + req.getMethod() + " " + req.getFullUri() + (req.getBody() == null ? "" : "\n" + new String(req.getBody())));
+ if (traceReqRes && isLogEnabled())
+ {
+ log("");
+ log("* Request: " + req.getMethod() + " " + req.getFullUri() + (req.getBody() == null ? "" : "\n" + new String(req.getBody())));
+ }
Response res = null;
if (remoteServer == null)
@@ -151,15 +285,14 @@ public abstract class BaseWebScriptTest extends TestCase
res = sendRemoteRequest(req, expectedStatus);
}
- if (logger.isInfoEnabled())
- logger.info("Response: " + res.getStatus() + " " + req.getMethod() + " " + req.getFullUri() + "\n" + res.getContentAsString());
+ if (traceReqRes && isLogEnabled())
+ {
+ log("");
+ log("* Response: " + res.getStatus() + " " + req.getMethod() + " " + req.getFullUri() + "\n" + res.getContentAsString());
+ }
if (expectedStatus > 0 && expectedStatus != res.getStatus())
{
-// if (res.getStatus() == 500)
-// {
-// System.out.println(res.getContentAsString());
-// }
fail("Status code " + res.getStatus() + " returned, but expected " + expectedStatus + " for " + req.getFullUri() + " (" + req.getMethod() + ")\n" + res.getContentAsString());
}
diff --git a/source/java/org/apache/abdera/ext/cmis/CMISConstants.java b/source/java/org/apache/abdera/ext/cmis/CMISConstants.java
index 88c9189d63..c7b828f40a 100644
--- a/source/java/org/apache/abdera/ext/cmis/CMISConstants.java
+++ b/source/java/org/apache/abdera/ext/cmis/CMISConstants.java
@@ -26,6 +26,8 @@ package org.apache.abdera.ext.cmis;
import javax.xml.namespace.QName;
+import org.apache.abdera.util.Constants;
+
/**
* CMIS Namespace definitions for the Abdera ATOM library.
@@ -41,10 +43,22 @@ import javax.xml.namespace.QName;
*/
public interface CMISConstants
{
+ // Namespace
public static final String CMIS_200805_NS = "http://www.cmis.org/2008/05";
+
+ // Mimetypes
+ public static final String MIMETYPE_QUERY = "application/cmisquery+xml";
+ public static final String MIMETYPE_ALLOWABLEACTIONS = "application/cmisallowableactions+xml";
// CMIS Service Document
public static final QName COLLECTION_TYPE = new QName(CMIS_200805_NS, "collectionType");
+ public static final String COLLECTION_ROOT_CHILDREN = "root-children";
+ public static final String COLLECTION_ROOT_DESCENDANTS = "root-descendants";
+ public static final String COLLECTION_CHECKEDOUT = "checkedout";
+ public static final String COLLECTION_UNFILED = "unfiled";
+ public static final String COLLECTION_TYPES_CHILDREN = "types-children";
+ public static final String COLLECTION_TYPES_DESCENDANTS = "types-descendants";
+ public static final String COLLECTION_QUERY = "query";
// CMIS Repository Info
public static final QName REPOSITORY_INFO = new QName(CMIS_200805_NS, "repositoryInfo");
@@ -67,35 +81,60 @@ public interface CMISConstants
public static final QName CAPABILITY_JOIN = new QName(CMIS_200805_NS, "capabilityJoin");
public static final QName CAPABILITY_FULLTEXT = new QName(CMIS_200805_NS, "capabilityFullText");
- // CMIS Schema
+ // CMIS Object
+ public static final QName OBJECT = new QName(CMIS_200805_NS, "object");
public static final QName PROPERTIES = new QName(CMIS_200805_NS, "properties");
- public static final QName PROPERTY_STRING = new QName(CMIS_200805_NS, "propertyString");
- public static final QName PROPERTY_ID = new QName(CMIS_200805_NS, "propertyID");
- public static final QName PROPERTY_BOOLEAN = new QName(CMIS_200805_NS, "propertyBoolean");
public static final QName PROPERTY_NAME = new QName(CMIS_200805_NS, "name");
-
- // CMIS Properties
- public static final String PROP_NAME = "name";
- public static final String PROP_OBJECT_ID = "objectId";
- public static final String PROP_BASETYPE = "baseType";
- public static final String PROP_OBJECT_TYPE = "objectType";
- public static final String PROP_IS_IMMUTABLE = "isImmutable";
- public static final String PROP_IS_LATEST_VERSION = "isLatestVersion";
- public static final String PROP_IS_MAJOR_VERSION = "isMajorVersion";
- public static final String PROP_IS_LATEST_MAJOR_VERSION = "isLatestMajorVersion";
- public static final String PROP_VERSION_LABEL = "versionLabel";
- public static final String PROP_VERSION_SERIES_ID = "versionSeriesID";
- public static final String PROP_VERSION_SERIES_IS_CHECKED_OUT = "isVersionSeriesCheckedOut";
- public static final String PROP_VERSION_SERIES_CHECKED_OUT_BY = "versionSeriesCheckedOutBy";
- public static final String PROP_VERSION_SERIES_CHECKED_OUT_ID = "versionSeriesCheckedOutID";
- public static final String PROP_CHECKIN_COMMENT = "checkinComment";
-
+ public static final QName PROPERTY_VALUE = new QName(CMIS_200805_NS, "value");
+ public static final QName PROPERTY_STRING = new QName(CMIS_200805_NS, "propertyString");
+ public static final QName PROPERTY_DECIMAL = new QName(CMIS_200805_NS, "propertyDecimal");
+ public static final QName PROPERTY_INTEGER = new QName(CMIS_200805_NS, "propertyInteger");
+ public static final QName PROPERTY_BOOLEAN = new QName(CMIS_200805_NS, "propertyBoolean");
+ public static final QName PROPERTY_DATETIME = new QName(CMIS_200805_NS, "propertyDateTime");
+ public static final QName PROPERTY_URI = new QName(CMIS_200805_NS, "propertyUri");
+ public static final QName PROPERTY_ID = new QName(CMIS_200805_NS, "propertyId");
+ public static final QName PROPERTY_XML = new QName(CMIS_200805_NS, "propertyXml");
+ public static final QName PROPERTY_HTML = new QName(CMIS_200805_NS, "propertyHtml");
+
// CMIS Relationships
public static final String REL_CHILDREN = "cmis-children";
+ public static final String REL_DESCENDANTS = "cmis-descendants";
public static final String REL_PARENT = "cmis-parent";
public static final String REL_FOLDERPARENT = "cmis-folderparent";
public static final String REL_PARENTS = "cmis-parents";
public static final String REL_ALLVERSIONS = "cmis-allversions";
public static final String REL_TYPE = "cmis-type";
+ public static final String REL_SOURCE = "cmis-source";
+
+ // CMIS Nested Entry
+ public static final QName NESTED_ENTRY = Constants.ENTRY;
+
+
+ // CMIS Properties Names
+ public static final String PROP_NAME = "Name";
+ public static final String PROP_OBJECT_ID = "ObjectId";
+ public static final String PROP_BASETYPE = "BaseType";
+ public static final String PROP_OBJECT_TYPE_ID = "ObjectTypeId";
+ public static final String PROP_IS_IMMUTABLE = "IsImmutable";
+ public static final String PROP_IS_LATEST_VERSION = "IsLatestVersion";
+ public static final String PROP_IS_MAJOR_VERSION = "IsMajorVersion";
+ public static final String PROP_IS_LATEST_MAJOR_VERSION = "IsLatestMajorVersion";
+ public static final String PROP_VERSION_LABEL = "VersionLabel";
+ public static final String PROP_VERSION_SERIES_ID = "VersionSeriesId";
+ public static final String PROP_IS_VERSION_SERIES_CHECKED_OUT = "IsVersionSeriesCheckedOut";
+ public static final String PROP_VERSION_SERIES_CHECKED_OUT_BY = "VersionSeriesCheckedOutBy";
+ public static final String PROP_VERSION_SERIES_CHECKED_OUT_ID = "VersionSeriesCheckedOutId";
+ public static final String PROP_CHECKIN_COMMENT = "CheckinComment";
+
+ // CMIS Property Types
+ public static final String PROP_TYPE_STRING = "string";
+ public static final String PROP_TYPE_DECIMAL = "decimal";
+ public static final String PROP_TYPE_INTEGER = "integer";
+ public static final String PROP_TYPE_BOOLEAN = "boolean";
+ public static final String PROP_TYPE_DATETIME = "datetime";
+ public static final String PROP_TYPE_URI = "uri";
+ public static final String PROP_TYPE_ID = "id";
+ public static final String PROP_TYPE_XML = "xml";
+ public static final String PROP_TYPE_HTML = "html";
}
diff --git a/source/java/org/apache/abdera/ext/cmis/CMISExtensionFactory.java b/source/java/org/apache/abdera/ext/cmis/CMISExtensionFactory.java
index 554438e7d3..df5fdb00bf 100644
--- a/source/java/org/apache/abdera/ext/cmis/CMISExtensionFactory.java
+++ b/source/java/org/apache/abdera/ext/cmis/CMISExtensionFactory.java
@@ -24,6 +24,15 @@
*/
package org.apache.abdera.ext.cmis;
+import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyBoolean;
+import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyDateTime;
+import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyDecimal;
+import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyHtml;
+import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyId;
+import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyInteger;
+import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyString;
+import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyUri;
+import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyXml;
import org.apache.abdera.util.AbstractExtensionFactory;
@@ -48,7 +57,17 @@ public class CMISExtensionFactory extends AbstractExtensionFactory
super(CMIS_200805_NS);
addImpl(REPOSITORY_INFO, CMISRepositoryInfo.class);
addImpl(CAPABILITIES, CMISCapabilities.class);
+ addImpl(OBJECT, CMISObject.class);
addImpl(PROPERTIES, CMISProperties.class);
+ addImpl(PROPERTY_STRING, CMISPropertyString.class);
+ addImpl(PROPERTY_DECIMAL, CMISPropertyDecimal.class);
+ addImpl(PROPERTY_INTEGER, CMISPropertyInteger.class);
+ addImpl(PROPERTY_BOOLEAN, CMISPropertyBoolean.class);
+ addImpl(PROPERTY_DATETIME, CMISPropertyDateTime.class);
+ addImpl(PROPERTY_URI, CMISPropertyUri.class);
+ addImpl(PROPERTY_ID, CMISPropertyId.class);
+ addImpl(PROPERTY_XML, CMISPropertyXml.class);
+ addImpl(PROPERTY_HTML, CMISPropertyHtml.class);
}
}
diff --git a/source/java/org/apache/abdera/ext/cmis/CMISObject.java b/source/java/org/apache/abdera/ext/cmis/CMISObject.java
new file mode 100644
index 0000000000..76dfbddc18
--- /dev/null
+++ b/source/java/org/apache/abdera/ext/cmis/CMISObject.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2005-2008 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.apache.abdera.ext.cmis;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ExtensibleElementWrapper;
+
+
+/**
+ * CMIS Object for the Abdera ATOM library.
+ *
+ * Encapsulates access and modification of CMIS extension values to CMIS
+ * Object.
+ *
+ * NOTE: Potentially, this extension can be contributed to Abdera upon
+ * publication of CMIS. This is why it is organised under a
+ * non-Alfresco Java package. It follows the conventions of all
+ * other Abdera extensions.
+ *
+ * @author davidc
+ */
+public class CMISObject extends ExtensibleElementWrapper
+{
+ /**
+ * @param internal
+ */
+ public CMISObject(Element internal)
+ {
+ super(internal);
+ }
+
+ /**
+ * @param factory
+ */
+ public CMISObject(Factory factory)
+ {
+ super(factory, CMISConstants.OBJECT);
+ }
+
+ /**
+ * Gets all Properties for this CMIS Object
+ *
+ * @return properties
+ */
+ public CMISProperties getProperties()
+ {
+ Element child = getFirstChild(CMISConstants.PROPERTIES);
+ if (child == null)
+ {
+ child = addExtension(CMISConstants.PROPERTIES);
+ }
+ return (CMISProperties)child;
+ }
+
+ /**
+ * Gets name
+ *
+ * @return name property
+ */
+ public CMISProperty getName()
+ {
+ return getProperties().find(CMISConstants.PROP_NAME);
+ }
+
+ /**
+ * Gets id
+ *
+ * @return id property
+ */
+ public CMISProperty getObjectId()
+ {
+ return getProperties().find(CMISConstants.PROP_OBJECT_ID);
+ }
+
+ /**
+ * Gets base type
+ *
+ * @return base type property
+ */
+ public CMISProperty getBaseType()
+ {
+ return getProperties().find(CMISConstants.PROP_BASETYPE);
+ }
+
+ /**
+ * Gets object type
+ *
+ * @return object type property
+ */
+ public CMISProperty getObjectTypeId()
+ {
+ return getProperties().find(CMISConstants.PROP_OBJECT_TYPE_ID);
+ }
+
+ /**
+ * Is immutable?
+ *
+ * @return isImmutable property
+ */
+ public CMISProperty isImmutable()
+ {
+ return getProperties().find(CMISConstants.PROP_IS_IMMUTABLE);
+ }
+
+ /**
+ * Gets Latest Version
+ *
+ * @return latest version property
+ */
+ public CMISProperty isLatestVersion()
+ {
+ return getProperties().find(CMISConstants.PROP_IS_LATEST_VERSION);
+ }
+
+ /**
+ * Is Major Version?
+ *
+ * @return is major version property
+ */
+ public CMISProperty isMajorVersion()
+ {
+ return getProperties().find(CMISConstants.PROP_IS_MAJOR_VERSION);
+ }
+
+ /**
+ * Is Latest Major Version?
+ *
+ * @return is latest major version property
+ */
+ public CMISProperty isLatestMajorVersion()
+ {
+ return getProperties().find(CMISConstants.PROP_IS_LATEST_MAJOR_VERSION);
+ }
+
+ /**
+ * Version label
+ *
+ * @return version label property
+ */
+ public CMISProperty getVersionLabel()
+ {
+ return getProperties().find(CMISConstants.PROP_VERSION_LABEL);
+ }
+
+ /**
+ * Version series id
+ *
+ * @return version series id property
+ */
+ public CMISProperty getVersionSeriesId()
+ {
+ return getProperties().find(CMISConstants.PROP_VERSION_SERIES_ID);
+ }
+
+ /**
+ * Version Series Checked Out
+ *
+ * @return version series checked out property
+ */
+ public CMISProperty isVersionSeriesCheckedOut()
+ {
+ return getProperties().find(CMISConstants.PROP_IS_VERSION_SERIES_CHECKED_OUT);
+ }
+
+ /**
+ * Version Series Checked Out By
+ *
+ * @return version series checked out by property
+ */
+ public CMISProperty getVersionSeriesCheckedOutBy()
+ {
+ return getProperties().find(CMISConstants.PROP_VERSION_SERIES_CHECKED_OUT_BY);
+ }
+
+ /**
+ * Version Series Checked Out Id
+ *
+ * @return version series checked out id property
+ */
+ public CMISProperty getVersionSeriesCheckedOutId()
+ {
+ return getProperties().find(CMISConstants.PROP_VERSION_SERIES_CHECKED_OUT_ID);
+ }
+
+ /**
+ * Checkin Comment
+ *
+ * @return checkin comment property
+ */
+ public CMISProperty getCheckinComment()
+ {
+ return getProperties().find(CMISConstants.PROP_CHECKIN_COMMENT);
+ }
+}
diff --git a/source/java/org/apache/abdera/ext/cmis/CMISProperties.java b/source/java/org/apache/abdera/ext/cmis/CMISProperties.java
index 1eae6885b2..252ad3ca40 100644
--- a/source/java/org/apache/abdera/ext/cmis/CMISProperties.java
+++ b/source/java/org/apache/abdera/ext/cmis/CMISProperties.java
@@ -24,13 +24,16 @@
*/
package org.apache.abdera.ext.cmis;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.abdera.factory.Factory;
import org.apache.abdera.model.Element;
import org.apache.abdera.model.ElementWrapper;
/**
- * CMIS Object Element Wrapper for the Abdera ATOM library.
+ * CMIS Properties Element Wrapper for the Abdera ATOM library.
*
* Encapsulates access and modification of CMIS extension values to ATOM.
*
@@ -43,128 +46,59 @@ import org.apache.abdera.model.ElementWrapper;
*/
public class CMISProperties extends ElementWrapper
{
+ /**
+ * @param internal
+ */
public CMISProperties(Element internal)
{
super(internal);
}
+ /**
+ * @param factory
+ */
public CMISProperties(Factory factory)
{
super(factory, CMISConstants.PROPERTIES);
}
- public String getName()
+ /**
+ * Gets all property names
+ *
+ * @return list of property names
+ */
+ public List getNames()
{
- return findPropertyString(CMISConstants.PROP_NAME);
- }
-
- public String getObjectId()
- {
- return findPropertyID(CMISConstants.PROP_OBJECT_ID);
- }
-
- public String getBaseType()
- {
- return findPropertyString(CMISConstants.PROP_BASETYPE);
- }
-
- public String getObjectType()
- {
- return findPropertyString(CMISConstants.PROP_OBJECT_TYPE);
- }
-
- public boolean isImmutable()
- {
- return findPropertyBoolean(CMISConstants.PROP_IS_IMMUTABLE);
- }
-
- public boolean isLatestVersion()
- {
- return findPropertyBoolean(CMISConstants.PROP_IS_LATEST_VERSION);
- }
-
- public boolean isMajorVersion()
- {
- return findPropertyBoolean(CMISConstants.PROP_IS_MAJOR_VERSION);
- }
-
- public boolean isLatestMajorVersion()
- {
- return findPropertyBoolean(CMISConstants.PROP_IS_LATEST_MAJOR_VERSION);
- }
-
- public String getVersionLabel()
- {
- return findPropertyString(CMISConstants.PROP_VERSION_LABEL);
- }
-
- public String getVersionSeriesId()
- {
- return findPropertyID(CMISConstants.PROP_VERSION_SERIES_ID);
- }
-
- public boolean isVersionSeriesCheckedOut()
- {
- return findPropertyBoolean(CMISConstants.PROP_VERSION_SERIES_IS_CHECKED_OUT);
- }
-
- public String getVersionSeriesCheckedOutBy()
- {
- return findPropertyString(CMISConstants.PROP_VERSION_SERIES_CHECKED_OUT_BY);
- }
-
- public String getVersionSeriesCheckedOutId()
- {
- return findPropertyID(CMISConstants.PROP_VERSION_SERIES_CHECKED_OUT_ID);
- }
-
- public String getCheckinComment()
- {
- return findPropertyString(CMISConstants.PROP_CHECKIN_COMMENT);
- }
-
-
- public String findPropertyString(String name)
- {
- Element child = getFirstChild(CMISConstants.PROPERTY_STRING);
- while(child != null)
+ List props = getElements();
+ List names = new ArrayList(props.size());
+ for (CMISProperty prop : props)
{
- if (name.equals(child.getAttributeValue(CMISConstants.PROPERTY_NAME)))
+ names.add(prop.getName());
+ }
+ return names;
+ }
+
+ /**
+ * Finds property by name
+ *
+ * @param name property name
+ * @return property
+ */
+ public CMISProperty find(String name)
+ {
+ List elements = getElements();
+ for (Element element : elements)
+ {
+ if (element instanceof CMISProperty)
{
- return child.getText();
+ CMISProperty prop = (CMISProperty)element;
+ if (prop.getName().equals(name))
+ {
+ return prop;
+ }
}
- child = child.getNextSibling(CMISConstants.PROPERTY_STRING);
}
return null;
}
-
- public String findPropertyID(String name)
- {
- Element child = getFirstChild(CMISConstants.PROPERTY_ID);
- while(child != null)
- {
- if (name.equals(child.getAttributeValue(CMISConstants.PROPERTY_NAME)))
- {
- return child.getText();
- }
- child = child.getNextSibling(CMISConstants.PROPERTY_ID);
- }
- return null;
- }
-
- public boolean findPropertyBoolean(String name)
- {
- Element child = getFirstChild(CMISConstants.PROPERTY_BOOLEAN);
- while(child != null)
- {
- if (name.equals(child.getAttributeValue(CMISConstants.PROPERTY_NAME)))
- {
- return Boolean.valueOf(child.getText());
- }
- child = child.getNextSibling(CMISConstants.PROPERTY_BOOLEAN);
- }
- return false;
- }
-
-
+
}
diff --git a/source/java/org/apache/abdera/ext/cmis/CMISProperty.java b/source/java/org/apache/abdera/ext/cmis/CMISProperty.java
new file mode 100644
index 0000000000..67e9eed24e
--- /dev/null
+++ b/source/java/org/apache/abdera/ext/cmis/CMISProperty.java
@@ -0,0 +1,387 @@
+/*
+ * Copyright (C) 2005-2008 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.apache.abdera.ext.cmis;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+
+/**
+ * CMIS Property for the Abdera ATOM library.
+ *
+ * Encapsulates access and modification of CMIS extension values to CMIS
+ * Property.
+ *
+ * NOTE: Potentially, this extension can be contributed to Abdera upon
+ * publication of CMIS. This is why it is organised under a
+ * non-Alfresco Java package. It follows the conventions of all
+ * other Abdera extensions.
+ *
+ * @author davidc
+ */
+public abstract class CMISProperty extends ElementWrapper
+{
+ /**
+ * @param internal
+ */
+ public CMISProperty(Element internal)
+ {
+ super(internal);
+ }
+
+ /**
+ * @param factory
+ * @param qname
+ */
+ public CMISProperty(Factory factory, QName qname)
+ {
+ super(factory, qname);
+ }
+
+ /**
+ * Gets the property type
+ *
+ * @return type
+ */
+ public abstract String getType();
+
+ /**
+ * Gets the property name
+ *
+ * @return name
+ */
+ public String getName()
+ {
+ return getAttributeValue(CMISConstants.PROPERTY_NAME);
+ }
+
+ /**
+ * Is property value null?
+ *
+ * @return true => null
+ */
+ public boolean isNull()
+ {
+ return getFirstChild(CMISConstants.PROPERTY_VALUE) == null ? true : false;
+ }
+
+ /**
+ * Gets property value (as String)
+ *
+ * @return property value (or null, if not specified)
+ */
+ public String getValue()
+ {
+ Element child = getFirstChild(CMISConstants.PROPERTY_VALUE);
+ if (child != null)
+ {
+ return child.getText();
+ }
+ return null;
+ }
+
+ /**
+ * Gets String value
+ *
+ * @return string value
+ */
+ public String getStringValue()
+ {
+ return getValue();
+ }
+
+ /**
+ * Gets Decimal value
+ *
+ * @return decimal value
+ */
+ public BigDecimal getDecimalValue()
+ {
+ return new BigDecimal(getValue());
+ }
+
+ /**
+ * Gets Integer value
+ *
+ * @return integer value
+ */
+ public int getIntegerValue()
+ {
+ return new Integer(getValue());
+ }
+
+ /**
+ * Gets Boolean value
+ *
+ * @return boolean value
+ */
+ public boolean getBooleanValue()
+ {
+ return Boolean.valueOf(getValue());
+ }
+
+ /**
+ * Gets Date value
+ *
+ * @return date value
+ */
+ public Date getDateValue()
+ {
+ // TODO:
+ return null;
+ }
+
+
+ /**
+ * String Property
+ */
+ public static class CMISPropertyString extends CMISProperty
+ {
+ public CMISPropertyString(Element internal)
+ {
+ super(internal);
+ }
+
+ public CMISPropertyString(Factory factory, QName qname)
+ {
+ super(factory, qname);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.abdera.ext.cmis.CMISProperty#getType()
+ */
+ @Override
+ public String getType()
+ {
+ return CMISConstants.PROP_TYPE_STRING;
+ }
+ }
+
+ /**
+ * Decimal Property
+ */
+ public static class CMISPropertyDecimal extends CMISProperty
+ {
+ public CMISPropertyDecimal(Element internal)
+ {
+ super(internal);
+ }
+
+ public CMISPropertyDecimal(Factory factory, QName qname)
+ {
+ super(factory, qname);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.abdera.ext.cmis.CMISProperty#getType()
+ */
+ @Override
+ public String getType()
+ {
+ return CMISConstants.PROP_TYPE_DECIMAL;
+ }
+ }
+
+ /**
+ * Integer Property
+ */
+ public static class CMISPropertyInteger extends CMISProperty
+ {
+ public CMISPropertyInteger(Element internal)
+ {
+ super(internal);
+ }
+
+ public CMISPropertyInteger(Factory factory, QName qname)
+ {
+ super(factory, qname);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.abdera.ext.cmis.CMISProperty#getType()
+ */
+ @Override
+ public String getType()
+ {
+ return CMISConstants.PROP_TYPE_INTEGER;
+ }
+ }
+
+ /**
+ * Boolean Property
+ */
+ public static class CMISPropertyBoolean extends CMISProperty
+ {
+ public CMISPropertyBoolean(Element internal)
+ {
+ super(internal);
+ }
+
+ public CMISPropertyBoolean(Factory factory, QName qname)
+ {
+ super(factory, qname);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.abdera.ext.cmis.CMISProperty#getType()
+ */
+ @Override
+ public String getType()
+ {
+ return CMISConstants.PROP_TYPE_BOOLEAN;
+ }
+ }
+
+ /**
+ * DateTime Property
+ */
+ public static class CMISPropertyDateTime extends CMISProperty
+ {
+ public CMISPropertyDateTime(Element internal)
+ {
+ super(internal);
+ }
+
+ public CMISPropertyDateTime(Factory factory, QName qname)
+ {
+ super(factory, qname);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.abdera.ext.cmis.CMISProperty#getType()
+ */
+ @Override
+ public String getType()
+ {
+ return CMISConstants.PROP_TYPE_DATETIME;
+ }
+ }
+
+ /**
+ * URI Property
+ */
+ public static class CMISPropertyUri extends CMISPropertyString
+ {
+ public CMISPropertyUri(Element internal)
+ {
+ super(internal);
+ }
+
+ public CMISPropertyUri(Factory factory, QName qname)
+ {
+ super(factory, qname);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyString#getType()
+ */
+ @Override
+ public String getType()
+ {
+ return CMISConstants.PROP_TYPE_URI;
+ }
+ }
+
+ /**
+ * ID Property
+ */
+ public static class CMISPropertyId extends CMISPropertyString
+ {
+ public CMISPropertyId(Element internal)
+ {
+ super(internal);
+ }
+
+ public CMISPropertyId(Factory factory, QName qname)
+ {
+ super(factory, qname);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyString#getType()
+ */
+ @Override
+ public String getType()
+ {
+ return CMISConstants.PROP_TYPE_ID;
+ }
+ }
+
+ /**
+ * XML Property
+ */
+ public static class CMISPropertyXml extends CMISPropertyString
+ {
+ public CMISPropertyXml(Element internal)
+ {
+ super(internal);
+ }
+
+ public CMISPropertyXml(Factory factory, QName qname)
+ {
+ super(factory, qname);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyString#getType()
+ */
+ @Override
+ public String getType()
+ {
+ return CMISConstants.PROP_TYPE_XML;
+ }
+ }
+
+ /**
+ * HTML Property
+ */
+ public static class CMISPropertyHtml extends CMISPropertyString
+ {
+ public CMISPropertyHtml(Element internal)
+ {
+ super(internal);
+ }
+
+ public CMISPropertyHtml(Factory factory, QName qname)
+ {
+ super(factory, qname);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyString#getType()
+ */
+ @Override
+ public String getType()
+ {
+ return CMISConstants.PROP_TYPE_HTML;
+ }
+ }
+}
diff --git a/source/test-resources/cmis/rest/createdocument.atomentry.xml b/source/test-resources/cmis/rest/createdocument.atomentry.xml
index 2549bf844a..4cdb6fa636 100644
--- a/source/test-resources/cmis/rest/createdocument.atomentry.xml
+++ b/source/test-resources/cmis/rest/createdocument.atomentry.xml
@@ -2,7 +2,7 @@
${NAME}
${NAME} (summary)
- test content ${NAME}
+ ${CONTENT}
document
diff --git a/source/test-resources/cmis/rest/createdocument2.atomentry.xml b/source/test-resources/cmis/rest/createdocument2.atomentry.xml
deleted file mode 100644
index 73f3396ac4..0000000000
--- a/source/test-resources/cmis/rest/createdocument2.atomentry.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
- onesentence.txt
- MQ==
-
- Document
- onesentence.txt
-
-
\ No newline at end of file
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 d9c5ebef7f..32fa700522 100644
--- a/source/test/java/org/alfresco/repo/cmis/ws/BaseServicePortTest.java
+++ b/source/test/java/org/alfresco/repo/cmis/ws/BaseServicePortTest.java
@@ -28,7 +28,6 @@ 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;
@@ -122,11 +121,10 @@ public class BaseServicePortTest extends AbstractDependencyInjectionSpringContex
protected String getPropertyIDValue(PropertiesType properties, String propertyName)
{
String result = null;
- String realPropertyName = CMISPropertyNameMapping.getWebServiceName(propertyName);
for (PropertyIDType property : properties.getPropertyID())
{
- if (realPropertyName.equals(property.getName()))
+ if (propertyName.equals(property.getName()))
{
result = property.getValue();
break;
@@ -139,11 +137,10 @@ public class BaseServicePortTest extends AbstractDependencyInjectionSpringContex
protected String getPropertyStringValue(PropertiesType properties, String propertyName)
{
String result = null;
- String realPropertyName = CMISPropertyNameMapping.getWebServiceName(propertyName);
for (PropertyStringType property : properties.getPropertyString())
{
- if (realPropertyName.equals(property.getName()))
+ if (propertyName.equals(property.getName()))
{
result = property.getValue();
break;
@@ -156,11 +153,10 @@ public class BaseServicePortTest extends AbstractDependencyInjectionSpringContex
protected boolean getPropertyBooleanValue(PropertiesType properties, String propertyName)
{
boolean result = false;
- String realPropertyName = CMISPropertyNameMapping.getWebServiceName(propertyName);
for (PropertyBooleanType property : properties.getPropertyBoolean())
{
- if (realPropertyName.equals(property.getName()))
+ if (propertyName.equals(property.getName()))
{
result = property.isValue();
break;
diff --git a/source/test/java/org/alfresco/repo/cmis/ws/DMObjectServicePortTest.java b/source/test/java/org/alfresco/repo/cmis/ws/DMObjectServicePortTest.java
index 9fce38a475..6d89df6385 100644
--- a/source/test/java/org/alfresco/repo/cmis/ws/DMObjectServicePortTest.java
+++ b/source/test/java/org/alfresco/repo/cmis/ws/DMObjectServicePortTest.java
@@ -53,7 +53,7 @@ public class DMObjectServicePortTest extends BaseServicePortContentTest
GetPropertiesResponse response = objectServicePort.getProperties(request);
assertNotNull(response);
- assertEquals(rootNodeRef.toString(), getPropertyIDValue(response.getObject().getProperties(), CMISMapping.PROP_PARENT));
+ assertEquals(rootNodeRef.toString(), getPropertyIDValue(response.getObject().getProperties(), CMISMapping.PROP_PARENT_ID));
assertEquals(L0_FOLDER_0, getPropertyStringValue(response.getObject().getProperties(), CMISMapping.PROP_NAME));
}
@@ -147,7 +147,7 @@ public class DMObjectServicePortTest extends BaseServicePortContentTest
assertNotNull(response);
assertNull(getPropertyStringValue(response.getObject().getProperties(), CMISMapping.PROP_CHECKIN_COMMENT));
- assertTrue(getPropertyBooleanValue(response.getObject().getProperties(), CMISMapping.PROP_VERSION_SERIES_IS_CHECKED_OUT));
+ assertTrue(getPropertyBooleanValue(response.getObject().getProperties(), CMISMapping.PROP_IS_VERSION_SERIES_CHECKED_OUT));
assertEquals(getPropertyStringValue(response.getObject().getProperties(), CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getSystemUserName());
assertEquals(getPropertyIDValue(response.getObject().getProperties(), CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_ID), workingCopyNodeRef.toString());
@@ -157,7 +157,7 @@ public class DMObjectServicePortTest extends BaseServicePortContentTest
response = objectServicePort.getProperties(request);
assertNotNull(response);
assertNull(getPropertyStringValue(response.getObject().getProperties(), CMISMapping.PROP_CHECKIN_COMMENT));
- assertTrue(getPropertyBooleanValue(response.getObject().getProperties(), CMISMapping.PROP_VERSION_SERIES_IS_CHECKED_OUT));
+ assertTrue(getPropertyBooleanValue(response.getObject().getProperties(), CMISMapping.PROP_IS_VERSION_SERIES_CHECKED_OUT));
assertEquals(getPropertyStringValue(response.getObject().getProperties(), CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getSystemUserName());
assertEquals(getPropertyIDValue(response.getObject().getProperties(), CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_ID), workingCopyNodeRef.toString());
}