Merge from SEAMIST3

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10726 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2008-09-04 10:56:47 +00:00
parent e22df58ebb
commit 86fa1c011f
80 changed files with 17833 additions and 2389 deletions

View File

@@ -0,0 +1,257 @@
/*
* 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.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.validation.Validator;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.cmis.rest.xsd.CMISValidator;
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.web.scripts.TestWebScriptServer.Request;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* Base CMIS Web Script Test
*
* @author davidc
*/
public class BaseCMISWebScriptTest extends BaseWebScriptTest
{
private CMISValidator cmisValidator = new CMISValidator();
private boolean argsAsHeaders = false;
/**
* Pass URL arguments as headers
*
* @param argsAsHeaders
*/
protected void setArgsAsHeaders(boolean argsAsHeaders)
{
this.argsAsHeaders = argsAsHeaders;
}
/**
* Determines if URL arguments are passed as headers
*
* @return
*/
protected boolean getArgsAsHeaders()
{
return argsAsHeaders;
}
/**
* Gets CMIS Validator
*
* @return CMIS Validator
*/
protected CMISValidator getCMISValidator()
{
return cmisValidator;
}
/**
* Gets CMIS App Validator
*
* @return CMIS App Validator
*
* @throws SAXException
* @throws IOException
*/
protected Validator getAppValidator()
throws IOException, SAXException
{
return getCMISValidator().getAppValidator();
}
/**
* Gets CMIS Atom Validator
*
* @return CMIS App Validator
*
* @throws SAXException
* @throws IOException
*/
protected Validator getAtomValidator()
throws IOException, SAXException
{
return null;
// TODO: Enable Atom Feed/Entry validator once up-to-date with 0.42
//return getCMISValidator().getCMISAtomValidator();
}
/**
* Asserts XML complies with specified Validator
*
* @param xml xml to assert
* @param validator validator to assert with
* @throws IOException
* @throws ParserConfigurationException
*/
protected void assertValidXML(String xml, Validator validator)
throws IOException, ParserConfigurationException
{
try
{
Document document = cmisValidator.getDocumentBuilder().parse(new InputSource(new StringReader(xml)));
validator.validate(new DOMSource(document));
}
catch (SAXException e)
{
fail(cmisValidator.toString(e, xml));
}
}
/**
* Load text from file specified by class path
*
* @param classPath XML file
* @return XML
* @throws IOException
*/
protected String loadString(String classPath)
throws IOException
{
InputStream input = getClass().getResourceAsStream(classPath);
if (input == null)
{
throw new IOException(classPath + " not found.");
}
InputStreamReader reader = new InputStreamReader(input);
StringWriter writer = new StringWriter();
try
{
char[] buffer = new char[4096];
int bytesRead = -1;
while ((bytesRead = reader.read(buffer)) != -1)
{
writer.write(buffer, 0, bytesRead);
}
writer.flush();
}
finally
{
reader.close();
writer.close();
}
return writer.toString();
}
/**
* Send Request to Test Web Script Server (as admin)
*
* @param req
* @param expectedStatus
* @return response
* @throws IOException
*/
protected Response sendRequest(Request req, int expectedStatus, Validator responseValidator)
throws IOException
{
return sendRequest(req, expectedStatus, responseValidator, null);
}
/**
* Send Request
*
* @param req
* @param expectedStatus
* @param asUser
* @return response
* @throws IOException
*/
protected Response sendRequest(Request req, int expectedStatus, Validator responseValidator, String asUser)
throws IOException
{
Response res = sendRequest(req, expectedStatus, asUser);
if (responseValidator != null)
{
try
{
// Validate response according to validator
String resXML = res.getContentAsString();
assertValidXML(resXML, responseValidator);
}
catch (ParserConfigurationException e)
{
throw new AlfrescoRuntimeException("Failed to validate", e);
}
}
return res;
}
/**
* Send Request to Test Web Script Server
* @param req
* @param expectedStatus
* @param asUser
* @return response
* @throws IOException
*/
protected Response sendRequest(Request req, int expectedStatus, String asUser)
throws IOException
{
if (argsAsHeaders)
{
Map<String, String> args = req.getArgs();
if (args != null)
{
Map<String, String> headers = req.getHeaders();
if (headers == null)
{
headers = new HashMap<String, String>();
}
for (Map.Entry<String, String> arg : args.entrySet())
{
headers.put("CMIS-" + arg.getKey(), arg.getValue());
}
req = new Request(req);
req.setArgs(null);
req.setHeaders(headers);
}
}
return super.sendRequest(req, expectedStatus, asUser);
}
}

View File

@@ -27,7 +27,7 @@ package org.alfresco.repo.cmis.rest;
import org.alfresco.repo.cmis.rest.CMISService.TypesFilter;
import org.alfresco.repo.jscript.BaseScopableProcessorExtension;
import org.alfresco.repo.jscript.ScriptNode;
import org.alfresco.repo.web.scripts.Repository;
import org.alfresco.repo.model.Repository;
import org.alfresco.repo.web.util.paging.Cursor;
import org.alfresco.repo.web.util.paging.Page;
import org.alfresco.repo.web.util.paging.PagedResults;

View File

@@ -30,6 +30,7 @@ import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.model.Repository;
import org.alfresco.repo.search.QueryParameterDefImpl;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
@@ -37,7 +38,6 @@ import org.alfresco.repo.tenant.TenantDeployer;
import org.alfresco.repo.tenant.TenantDeployerService;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.web.scripts.Repository;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -58,7 +58,7 @@ import org.springframework.context.ApplicationListener;
/**
* CMIS Navigation Service
* CMIS Service
*
* @author davidc
*/
@@ -84,13 +84,14 @@ public class CMISService implements ApplicationContextAware, ApplicationListener
private static final String LUCENE_QUERY_SHALLOW_FOLDERS =
"+PARENT:\"${cm:parent}\" " +
"-TYPE:\"" + ContentModel.TYPE_SYSTEM_FOLDER + "\" " +
"+TYPE:\"" + ContentModel.TYPE_FOLDER + "\" ";
"+TYPE:\"" + ContentModel.TYPE_FOLDER + "\"";
/** Shallow search for all files and folders */
private static final String LUCENE_QUERY_SHALLOW_FILES =
"+PARENT:\"${cm:parent}\" " +
"-TYPE:\"" + ContentModel.TYPE_SYSTEM_FOLDER + "\" " +
"+TYPE:\"" + ContentModel.TYPE_CONTENT + "\" ";
"+TYPE:\"" + ContentModel.TYPE_CONTENT + "\" " +
"-ASPECT:\"" + ContentModel.ASPECT_WORKING_COPY + "\"";
private static final String LUCENE_QUERY_CHECKEDOUT =
"+@cm\\:workingCopyOwner:${cm:username}";
@@ -382,16 +383,17 @@ public class CMISService implements ApplicationContextAware, ApplicationListener
}
}
ResultSet resultSet = searchService.query(params);
ResultSet resultSet = null;
try
{
resultSet = searchService.query(params);
List<NodeRef> results = resultSet.getNodeRefs();
NodeRef[] nodeRefs = new NodeRef[results.size()];
return results.toArray(nodeRefs);
}
finally
{
resultSet.close();
if (resultSet != null) resultSet.close();
}
}
@@ -420,17 +422,18 @@ public class CMISService implements ApplicationContextAware, ApplicationListener
{
params.setQuery(LUCENE_QUERY_SHALLOW_FILES);
}
ResultSet resultSet = searchService.query(params);
ResultSet resultSet = null;
try
{
resultSet = searchService.query(params);
List<NodeRef> results = resultSet.getNodeRefs();
NodeRef[] nodeRefs = new NodeRef[results.size()];
return results.toArray(nodeRefs);
}
finally
{
resultSet.close();
if (resultSet != null) resultSet.close();
}
}

View File

@@ -0,0 +1,767 @@
/*
* 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 java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
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.CMISConstants;
import org.apache.abdera.ext.cmis.CMISExtensionFactory;
import org.apache.abdera.ext.cmis.CMISProperties;
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;
/**
* CMIS API Test Harness
*
* @author davidc
*/
public class CMISTest extends BaseCMISWebScriptTest
{
private AbderaService abdera;
// test context
private String repositoryUrl = "http://localhost:8080/alfresco/service/api/repository";
// cached responses
private static Service service = null;
private static Entry testsFolder = null;
private static Entry testRunFolder = null;
/**
* Sets the Repository "service" URL
*
* @param repositoryUrl repository service url
*/
public void setRepositoryUrl(String repositoryUrl)
{
this.repositoryUrl = repositoryUrl;
}
// TODO: checkout/checkin tests need to perform version property assertions
@Override
protected void setUp()
throws Exception
{
// setup client atom support
AbderaServiceImpl abderaImpl = new AbderaServiceImpl();
abderaImpl.afterPropertiesSet();
abderaImpl.registerExtensionFactory(new CMISExtensionFactory());
abdera = abderaImpl;
// setup user
setDefaultRunAs("admin");
super.setUp();
}
private Service getRepository()
throws Exception
{
if (service == null)
{
Response res = sendRequest(new GetRequest(repositoryUrl), 200, getAppValidator());
String xml = res.getContentAsString();
assertNotNull(xml);
assertTrue(xml.length() > 0);
//assertValidXML(xml, getCMISValidator().getAppValidator());
service = abdera.parseService(new StringReader(xml), null);
assertNotNull(service);
}
return service;
}
private IRI getRootCollection(Service service)
{
Collection root = service.getCollection("Main Repository", "root collection");
assertNotNull(root);
IRI rootHREF = root.getHref();
assertNotNull(rootHREF);
return rootHREF;
}
private IRI getCheckedOutCollection(Service service)
{
Collection root = service.getCollection("Main Repository", "checkedout collection");
assertNotNull(root);
IRI rootHREF = root.getHref();
assertNotNull(rootHREF);
return rootHREF;
}
private Entry createFolder(IRI parent, String name)
throws Exception
{
String createFolder = loadString("/cmis/rest/createfolder.atomentry.xml");
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());
CMISProperties props = entry.getExtension(CMISConstants.PROPERTIES);
assertEquals("folder", props.getBaseType());
String testFolderHREF = (String)res.getHeader("Location");
assertNotNull(testFolderHREF);
return entry;
}
private Entry createDocument(IRI parent, String name)
throws Exception
{
String createFile = loadString("/cmis/rest/createdocument.atomentry.xml");
name = name + " " + System.currentTimeMillis();
createFile = createFile.replace("${NAME}", name);
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());
CMISProperties props = entry.getExtension(CMISConstants.PROPERTIES);
assertEquals("document", props.getBaseType());
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 = getRootCollection(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<String, String> 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<String, String> 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
{
Service service = getRepository();
IRI rootHREF = getRootCollection(service);
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");
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 testChildren()
throws Exception
{
// create multiple children
Entry testFolder = createTestFolder("testChildren");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry document1 = createDocument(childrenLink.getHref(), "testChildren1");
assertNotNull(document1);
Entry document2 = createDocument(childrenLink.getHref(), "testChildren2");
assertNotNull(document2);
Entry document3 = createDocument(childrenLink.getHref(), "testChildren3");
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(service);
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()));
// TODO: paging
}
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_PARENT);
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", "tests folder" and "root folder"
Map<String, String> args = new HashMap<String, String>();
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());
assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId());
Feed root = getFeed(getRootCollection(getRepository()));
assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId());
}
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<String, String> args = new HashMap<String, String>();
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());
assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId());
Feed root = getFeed(getRootCollection(getRepository()));
assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId());
}
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);
assertEquals("text/html", document.getContentMimeType().toString());
// update
String updateFile = loadString("/cmis/rest/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());
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");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
assertNotNull(scope);
CMISProperties props = scope.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
assertNotNull(scopeId);
// retrieve checkouts within scope of test checkout folder
Service repository = getRepository();
assertNotNull(repository);
IRI checkedoutHREF = getCheckedOutCollection(service);
Map<String, String> args = new HashMap<String, String>();
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);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().getHref(), "testCheckout");
Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
assertNotNull(documentRes);
String documentXML = documentRes.getContentAsString();
assertNotNull(documentXML);
// checkout
IRI checkedoutHREF = getCheckedOutCollection(service);
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(pwcRes);
// TODO: test private working copy properties
// test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Map<String, String> args = new HashMap<String, String>();
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);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().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(service);
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(pwcRes);
String pwcXml = pwcRes.getContentAsString();
// test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Map<String, String> args = new HashMap<String, String>();
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
CMISProperties props2 = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId2 = props2.getObjectId();
Map<String, String> args2 = new HashMap<String, String>();
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);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().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(service);
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
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(1, checkedout.getEntries().size());
// test update of private working copy
String updateFile = loadString("/cmis/rest/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("/cmis/rest/checkindocument.atomentry.xml");
String checkinUrl = pwc.getSelfLink().getHref().toString();
Map<String, String> args2 = new HashMap<String, String>();
args2.put("checkinComment", guid);
Response checkinRes = sendRequest(new PutRequest(checkinUrl, checkinFile, Format.ATOMENTRY.mimetype()).setArgs(args2), 200, getAtomValidator());
assertNotNull(checkinRes);
String checkinResXML = checkinRes.getContentAsString();
// test getCheckedOut is updated
CMISProperties props2 = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId2 = props2.getObjectId();
Map<String, String> args3 = new HashMap<String, String>();
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 testUpdateOnCheckIn()
throws Exception
{
// retrieve test folder for checkins
Entry testFolder = createTestFolder("testUpdateOnCheckIn");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().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(service);
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
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Map<String, String> args = new HashMap<String, String>();
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("/cmis/rest/checkinandupdatedocument.atomentry.xml");
String guid = GUID.generate();
checkinFile = checkinFile.replace("${NAME}", guid);
String checkinUrl = pwc.getSelfLink().getHref().toString();
Map<String, String> args2 = new HashMap<String, String>();
args2.put("checkinComment", guid);
Response checkinRes = sendRequest(new PutRequest(checkinUrl, checkinFile, Format.ATOMENTRY.mimetype()).setArgs(args2), 200, getAtomValidator());
assertNotNull(checkinRes);
String checkinResXML = checkinRes.getContentAsString();
// test getCheckedOut is updated
CMISProperties props2 = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId2 = props2.getObjectId();
Map<String, String> args3 = new HashMap<String, String>();
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);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().getHref(), "testGetAllVersions");
Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
assertNotNull(documentRes);
String xml = documentRes.getContentAsString();
assertNotNull(xml);
IRI checkedoutHREF = getCheckedOutCollection(service);
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("/cmis/rest/checkinandupdatedocument.atomentry.xml");
checkinFile = checkinFile.replace("${NAME}", "checkin " + i);
String checkinUrl = pwc.getSelfLink().getHref().toString();
Map<String, String> args2 = new HashMap<String, String>();
args2.put("checkinComment", "checkin " + i);
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());
// TODO: test version specific properties e.g. checkin comment
}
}
// public void testUnfiled()
// {
// }
}

View File

@@ -29,6 +29,8 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMSource;
@@ -36,6 +38,8 @@ import javax.xml.validation.Validator;
import org.alfresco.repo.cmis.rest.xsd.CMISValidator;
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.web.scripts.TestWebScriptServer.Request;
import org.springframework.mock.web.MockHttpServletResponse;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -49,7 +53,27 @@ import org.xml.sax.SAXException;
public class CMISWebScriptTest extends BaseWebScriptTest
{
private CMISValidator cmisValidator = new CMISValidator();
private boolean argsAsHeaders = false;
/**
* Pass URL arguments as headers
*
* @param argsAsHeaders
*/
protected void setArgsAsHeaders(boolean argsAsHeaders)
{
this.argsAsHeaders = argsAsHeaders;
}
/**
* Determines if URL arguments are passed as headers
*
* @return
*/
protected boolean getArgsAsHeaders()
{
return argsAsHeaders;
}
/**
* Gets CMIS Validator
@@ -121,4 +145,39 @@ public class CMISWebScriptTest extends BaseWebScriptTest
return writer.toString();
}
/**
* Send Request to Test Web Script Server
* @param req
* @param expectedStatus
* @param asUser
* @return response
* @throws IOException
*/
protected MockHttpServletResponse sendRequest(Request req, int expectedStatus, String asUser)
throws IOException
{
if (argsAsHeaders)
{
Map<String, String> args = req.getArgs();
if (args != null)
{
Map<String, String> headers = req.getHeaders();
if (headers == null)
{
headers = new HashMap<String, String>();
}
for (Map.Entry<String, String> arg : args.entrySet())
{
headers.put("CMIS-" + arg.getKey(), arg.getValue());
}
req = new Request(req);
req.setArgs(null);
req.setHeaders(headers);
}
}
return super.sendRequest(req, expectedStatus, asUser);
}
}

View File

@@ -0,0 +1,45 @@
/*
* 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;
/**
* CMIS API Test Harness
*
* @author davidc
*/
public class CMISWithHeadersTest extends CMISTest
{
@Override
protected void setUp()
throws Exception
{
super.setUp();
setArgsAsHeaders(true);
}
}

View File

@@ -25,11 +25,19 @@
package org.alfresco.repo.cmis.rest;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
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.atom.AbderaService;
import org.alfresco.web.scripts.atom.AbderaServiceImpl;
import org.apache.abdera.ext.cmis.CMISConstants;
import org.apache.abdera.ext.cmis.CMISExtensionFactory;
import org.apache.abdera.ext.cmis.CMISProperties;
import org.apache.abdera.i18n.iri.IRI;
@@ -51,7 +59,11 @@ public class TestCMIS extends CMISWebScriptTest
private AbderaService abdera;
private static Service service = null;
private static Entry testFolder = null;
private static Entry testRunFolder = null;
// TODO: checkout/checkin tests need to perform version property assertions
@Override
@@ -71,7 +83,7 @@ public class TestCMIS extends CMISWebScriptTest
{
if (service == null)
{
MockHttpServletResponse res = getRequest("/api/repository", 200, null);
MockHttpServletResponse res = sendRequest(new GetRequest("/api/repository"), 200);
String xml = res.getContentAsString();
assertNotNull(xml);
assertTrue(xml.length() > 0);
@@ -101,77 +113,96 @@ public class TestCMIS extends CMISWebScriptTest
return rootHREF;
}
private Entry getTestFolder()
private Entry createTestFolder(String name)
throws Exception
{
if (testFolder == null)
if (testRunFolder == null)
{
testFolder = createTestFolder();
Service service = getRepository();
IRI rootFolderHREF = getRootCollection(service);
testRunFolder = createFolder(rootFolderHREF, "CMIS 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
{
MockHttpServletResponse res = getRequest(href.toString(), 200, "admin");
return getEntry(href, null);
}
private Entry getEntry(IRI href, Map<String, String> args)
throws Exception
{
Request get = new GetRequest(href.toString()).setArgs(args);
MockHttpServletResponse res = sendRequest(get, 200);
assertNotNull(res);
String xml = res.getContentAsString();
Entry entry = abdera.parseEntry(new StringReader(xml), null);
assertNotNull(entry);
assertEquals(href, entry.getSelfLink().getHref());
assertEquals(getArgsAsHeaders() ? get.getUri() : get.getFullUri(), entry.getSelfLink().getHref().toString());
return entry;
}
private Feed getFeed(IRI href)
throws Exception
{
MockHttpServletResponse res = getRequest(href.toString(), 200, "admin");
return getFeed(href, null);
}
private Feed getFeed(IRI href, Map<String, String> args)
throws Exception
{
Request get = new GetRequest(href.toString()).setArgs(args);
MockHttpServletResponse res = sendRequest(get, 200);
assertNotNull(res);
String xml = res.getContentAsString();
Feed feed = abdera.parseFeed(new StringReader(xml), null);
assertNotNull(feed);
assertEquals(href, feed.getSelfLink().getHref());
assertEquals(getArgsAsHeaders() ? get.getUri() : get.getFullUri(), feed.getSelfLink().getHref().toString());
return feed;
}
private Entry createTestFolder()
private Entry createFolder(IRI parent, String name)
throws Exception
{
Service service = getRepository();
IRI rootFolderHREF = getRootCollection(service);
String createFolder = loadString("/cmis/rest/createtestfolder.atomentry.xml");
String createFolder = loadString("/cmis/rest/createfolder.atomentry.xml");
String guid = GUID.generate();
createFolder = createFolder.replace("${NAME}", name);
createFolder = createFolder.replace("${GUID}", guid);
MockHttpServletResponse res = postRequest(rootFolderHREF.toString(), 201, createFolder, Format.ATOMENTRY.mimetype(), "admin");
MockHttpServletResponse res = sendRequest(new PostRequest(parent.toString(), createFolder, Format.ATOMENTRY.mimetype()), 201);
assertNotNull(res);
String xml = res.getContentAsString();
Entry entry = abdera.parseEntry(new StringReader(xml), null);
assertNotNull(entry);
assertEquals("CMIS Test Folder " + guid, entry.getTitle());
assertEquals("CMIS Test Folder " + guid + " Summary", entry.getSummary());
CMISProperties props = entry.getExtension(CMISExtensionFactory.PROPERTIES);
assertEquals("Title " + name + " " + guid, entry.getTitle());
assertEquals("Summary " + name + " " + guid, entry.getSummary());
CMISProperties props = entry.getExtension(CMISConstants.PROPERTIES);
assertEquals("folder", props.getBaseType());
String testFolderHREF = (String)res.getHeader("Location");
assertNotNull(testFolderHREF);
return entry;
}
private Entry createTestDocument(IRI parent)
private Entry createDocument(IRI parent, String name)
throws Exception
{
String createFile = loadString("/cmis/rest/createtestdocument.atomentry.xml");
String createFile = loadString("/cmis/rest/createdocument.atomentry.xml");
String guid = GUID.generate();
createFile = createFile.replace("${NAME}", name);
createFile = createFile.replace("${GUID}", guid);
MockHttpServletResponse res = postRequest(parent.toString(), 201, createFile, Format.ATOMENTRY.mimetype(), "admin");
MockHttpServletResponse res = sendRequest(new PostRequest(parent.toString(), createFile, Format.ATOMENTRY.mimetype()), 201);
assertNotNull(res);
String xml = res.getContentAsString();
Entry entry = abdera.parseEntry(new StringReader(xml), null);
assertNotNull(entry);
assertEquals("Test Document " + guid, entry.getTitle());
assertEquals("Test Document " + guid + " Summary", entry.getSummary());
assertEquals("Title " + name + " " + guid, entry.getTitle());
assertEquals("Summary " + name + " " + guid, entry.getSummary());
assertNotNull(entry.getContentSrc());
CMISProperties props = entry.getExtension(CMISExtensionFactory.PROPERTIES);
CMISProperties props = entry.getExtension(CMISConstants.PROPERTIES);
assertEquals("document", props.getBaseType());
String testFileHREF = (String)res.getHeader("Location");
assertNotNull(testFileHREF);
@@ -183,25 +214,19 @@ public class TestCMIS extends CMISWebScriptTest
{
Service service = getRepository();
IRI rootHREF = getRootCollection(service);
getRequest(rootHREF.toString(), 200, "admin");
sendRequest(new GetRequest(rootHREF.toString()), 200);
}
public void testCreateTestFolder()
throws Exception
{
createTestFolder();
}
public void testCreateDocument()
throws Exception
{
Entry testFolder = getTestFolder();
Link childrenLink = testFolder.getLink("cmis-children");
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 = createTestDocument(children.getSelfLink().getHref());
Entry document = createDocument(children.getSelfLink().getHref(), "testCreateDocument");
Feed feedFolderAfter = getFeed(childrenLink.getHref());
int entriesAfter = feedFolderAfter.getEntries().size();
assertEquals(entriesBefore +1, entriesAfter);
@@ -209,15 +234,212 @@ public class TestCMIS extends CMISWebScriptTest
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
MockHttpServletResponse res = sendRequest(new GetRequest("/api/node/workspace/SpacesStore/" + GUID.generate()), 404);
assertNotNull(res);
}
public void testChildren()
throws Exception
{
// create multiple children
Entry testFolder = createTestFolder("testChildren");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry document1 = createDocument(childrenLink.getHref(), "testChildren1");
assertNotNull(document1);
Entry document2 = createDocument(childrenLink.getHref(), "testChildren2");
assertNotNull(document2);
Entry document3 = createDocument(childrenLink.getHref(), "testChildren3");
assertNotNull(document3);
// checkout one of the children to ensure private working copy isn't included
MockHttpServletResponse documentRes = sendRequest(new GetRequest(document2.getSelfLink().getHref().toString()), 200);
assertNotNull(documentRes);
String documentXML = documentRes.getContentAsString();
assertNotNull(documentXML);
IRI checkedoutHREF = getCheckedOutCollection(service);
MockHttpServletResponse pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201);
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()));
// TODO: paging
}
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_PARENT);
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<String, String> args = new HashMap<String, String>();
args.put("returnToRoot", "true");
Feed parentsToRoot = getFeed(new IRI(parentLink.getHref().toString()), args);
assertNotNull(parentsToRoot);
assertEquals(3, parentsToRoot.getEntries().size());
assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId());
assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
Feed root = getFeed(getRootCollection(getRepository()));
assertEquals(root.getId(), parentsToRoot.getEntries().get(2).getId());
}
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<String, String> args = new HashMap<String, String>();
args.put("returnToRoot", "true");
Feed parentsToRoot = getFeed(new IRI(parentLink.getHref().toString()), args);
assertNotNull(parentsToRoot);
assertEquals(3, parentsToRoot.getEntries().size());
assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId());
assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
Feed root = getFeed(getRootCollection(getRepository()));
assertEquals(root.getId(), parentsToRoot.getEntries().get(2).getId());
}
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");
MockHttpServletResponse documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200);
assertNotNull(documentRes);
// ensure document has been created
Feed children2 = getFeed(childrenLink.getHref());
assertNotNull(children2);
int entriesAfterCreate = children2.getEntries().size();
assertEquals(entriesAfterCreate, entriesBefore +1);
// delete
MockHttpServletResponse 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);
assertEquals("text/html", document.getContentMimeType().toString());
// update
String updateFile = loadString("/cmis/rest/updatedocument.atomentry.xml");
String guid = GUID.generate();
updateFile = updateFile.replace("${GUID}", guid);
MockHttpServletResponse res = sendRequest(new PutRequest(document.getSelfLink().getHref().toString(), updateFile, Format.ATOMENTRY.mimetype()), 200);
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());
assertEquals("text/plain", updated.getContentMimeType().toString());
MockHttpServletResponse 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 = getTestFolder();
Link childrenLink = testFolder.getLink("cmis-children");
Entry testFolder = createTestFolder("testGetCheckedOut");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
assertNotNull(scope);
CMISProperties props = scope.getExtension(CMISExtensionFactory.PROPERTIES);
CMISProperties props = scope.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
assertNotNull(scopeId);
@@ -225,7 +447,9 @@ public class TestCMIS extends CMISWebScriptTest
Service repository = getRepository();
assertNotNull(repository);
IRI checkedoutHREF = getCheckedOutCollection(service);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString() + "?folderId=" + scopeId));
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(0, checkedout.getEntries().size());
}
@@ -234,29 +458,154 @@ public class TestCMIS extends CMISWebScriptTest
throws Exception
{
// retrieve test folder for checkouts
Entry testFolder = getTestFolder();
Link childrenLink = testFolder.getLink("cmis-children");
Entry testFolder = createTestFolder("testCheckout");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createTestDocument(scope.getSelfLink().getHref());
MockHttpServletResponse documentRes = getRequest(document.getSelfLink().getHref().toString(), 200, "admin");
Entry document = createDocument(scope.getSelfLink().getHref(), "testCheckout");
MockHttpServletResponse documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200);
assertNotNull(documentRes);
String documentXML = documentRes.getContentAsString();
assertNotNull(documentXML);
// checkout
IRI checkedoutHREF = getCheckedOutCollection(service);
MockHttpServletResponse pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201);
assertNotNull(pwcRes);
// TODO: test private working copy properties
// test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Map<String, String> args = new HashMap<String, String>();
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);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().getHref(), "testCancelCheckout");
MockHttpServletResponse documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200);
assertNotNull(documentRes);
String xml = documentRes.getContentAsString();
assertNotNull(xml);
// checkout
IRI checkedoutHREF = getCheckedOutCollection(service);
MockHttpServletResponse checkoutRes = postRequest(checkedoutHREF.toString(), 201, xml, Format.ATOMENTRY.mimetype(), "admin");
assertNotNull(checkoutRes);
// TODO: test private working copy properties
MockHttpServletResponse pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201);
assertNotNull(pwcRes);
// test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISExtensionFactory.PROPERTIES);
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString() + "?folderId=" + scopeId));
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(1, checkedout.getEntries().size());
// cancel checkout
String pwcXml = pwcRes.getContentAsString();
Entry pwc = abdera.parseEntry(new StringReader(pwcXml), null);
assertNotNull(pwc);
MockHttpServletResponse cancelRes = sendRequest(new DeleteRequest(pwc.getSelfLink().getHref().toString()), 204);
assertNotNull(cancelRes);
// test getCheckedOut is updated
CMISProperties props2 = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId2 = props2.getObjectId();
Map<String, String> args2 = new HashMap<String, String>();
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);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().getHref(), "testCheckin");
MockHttpServletResponse documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200);
assertNotNull(documentRes);
String xml = documentRes.getContentAsString();
assertNotNull(xml);
// checkout
IRI checkedoutHREF = getCheckedOutCollection(service);
MockHttpServletResponse pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201);
assertNotNull(pwcRes);
Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
assertNotNull(pwc);
// test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(1, checkedout.getEntries().size());
// test update of private working copy
String updateFile = loadString("/cmis/rest/updatedocument.atomentry.xml");
String guid = GUID.generate();
updateFile = updateFile.replace("${GUID}", guid);
MockHttpServletResponse pwcUpdatedres = sendRequest(new PutRequest(pwc.getEditLink().getHref().toString(), updateFile, Format.ATOMENTRY.mimetype()), 200);
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());
MockHttpServletResponse pwcContentRes = sendRequest(new GetRequest(pwc.getContentSrc().toString()), 200);
assertEquals("updated content " + guid, pwcContentRes.getContentAsString());
// checkin
String checkinFile = loadString("/cmis/rest/checkindocument.atomentry.xml");
String checkinUrl = pwc.getSelfLink().getHref().toString();
Map<String, String> args2 = new HashMap<String, String>();
args2.put("checkinComment", guid);
MockHttpServletResponse checkinRes = sendRequest(new PutRequest(checkinUrl, checkinFile, Format.ATOMENTRY.mimetype()).setArgs(args2), 200);
assertNotNull(checkinRes);
// test getCheckedOut is updated
CMISProperties props2 = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId2 = props2.getObjectId();
Map<String, String> args3 = new HashMap<String, String>();
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(checkinRes.getContentAsString()), 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());
MockHttpServletResponse updatedContentRes = sendRequest(new GetRequest(updatedDoc.getContentSrc().toString()), 200);
assertEquals("updated content " + guid, updatedContentRes.getContentAsString());
}
// public void testUnfiled()
// {
// }
}

View File

@@ -0,0 +1,45 @@
/*
* 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;
/**
* CMIS API Test Harness
*
* @author davidc
*/
public class TestCMISWithHeaders extends TestCMIS
{
@Override
protected void setUp()
throws Exception
{
super.setUp();
setArgsAsHeaders(true);
}
}

View File

@@ -0,0 +1,95 @@
/*
* 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
{
// remote CMIS server
private static String repositoryUrl = "http://localhost:8080/alfresco/service/api/repository";
private static String username = "admin";
private static String password = "admin";
private static boolean argsAsHeaders = false;
@Override
protected void setUp() throws Exception
{
if (repositoryUrl != null)
{
setRepositoryUrl(repositoryUrl);
RemoteServer server = new RemoteServer();
server.username = username;
server.password = password;
setRemoteServer(server);
}
setArgsAsHeaders(argsAsHeaders);
super.setUp();
}
/**
* Execute Unit Tests as client to remote CMIS Server
*
* args[0] = serverUrl
* args[1] = username/password
*
* @param args args
*/
public static void main(String[] args)
{
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];
}
}
// execute cmis tests with url arguments
TestRunner.run(new TestSuite(TestRemoteCMIS.class));
// execute cmis tests with headers
argsAsHeaders = true;
TestRunner.run(new TestSuite(TestRemoteCMIS.class));
}
}

View File

@@ -22,6 +22,7 @@
<xs:sequence>
<xs:element ref="atom:author" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element ref="app:workspace" minOccurs="1" maxOccurs="unbounded"></xs:element>
<xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax" namespace="##other"/>
</xs:sequence>
</xs:complexType>

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
-*- rnc -*-
RELAX NG Compact Syntax Grammar for the
Atom Format Specification Version 11
-*- rnc -*-
RELAX NG Compact Syntax Grammar for the
Atom Format Specification Version 11
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
@@ -11,428 +11,448 @@
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">
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/xml.xsd" />
<xs:import namespace="http://www.cmis.org/2008/05"
schemaLocation="CMIS-REST.xsd" />
<!-- Common attributes -->
<xs:attributeGroup name="atomCommonAttributes">
<xs:attribute ref="xml:base" />
<xs:attribute ref="xml:lang" />
<xs:attributeGroup ref="atom:undefinedAttribute" />
</xs:attributeGroup>
<!-- Text Constructs -->
<xs:attributeGroup name="atomPlainTextConstruct">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="text" />
<xs:enumeration value="html" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<xs:group name="atomXHTMLTextConstruct">
<xs:sequence>
<!-- xs:element ref="xhtml:div"/> -->
<xs:element name="xhtmldivhere" type="xs:string" />
</xs:sequence>
</xs:group>
<xs:attributeGroup name="atomXHTMLTextConstruct">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
<xs:attribute name="type" use="required">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="xhtml" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<xs:complexType name="atomTextConstruct" mixed="true">
<xs:group minOccurs="0" ref="atom:atomXHTMLTextConstruct" />
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="text" />
<xs:enumeration value="html" />
<xs:enumeration value="xhtml" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attributeGroup ref="atom:atomCommonAttributes" />
</xs:complexType>
<!-- Person Construct -->
<xs:complexType name="atomPersonConstruct">
<xs:sequence>
<xs:element ref="atom:name" minOccurs="0" maxOccurs="1"/>
<xs:element ref="atom:uri" minOccurs="0" maxOccurs="1"/>
<xs:element ref="atom:email" minOccurs="0" maxOccurs="1"/>
<xs:group ref="atom:extensionElement" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attributeGroup ref="atom:atomCommonAttributes" />
</xs:complexType>
<xs:element name="name" type="xs:string" />
<xs:element name="uri" type="xs:string" />
<xs:element name="email" type="atom:atomEmailAddress" />
<!-- Date Construct -->
<xs:complexType name="atomDateConstruct">
<xs:simpleContent>
<xs:extension base="xs:dateTime">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- atom:feed -->
<xs:element name="feed" type="atom:feedType"></xs:element>
<xs:complexType name="feedType">
<xs:sequence>
<xs:element ref="atom:author" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:category" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:contributor" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:generator" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:icon" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:id" minOccurs="1" maxOccurs="1" />
<xs:element ref="atom:link" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:logo" minOccurs="0" maxOccurs="1" />
<xs:element ref="atom:rights" minOccurs="0" maxOccurs="1" />
<xs:element ref="atom:subtitle" minOccurs="0" maxOccurs="1" />
<xs:element ref="atom:title" minOccurs="1" maxOccurs="1" />
<xs:element ref="atom:updated" minOccurs="1" maxOccurs="1" />
<xs:element minOccurs="0" maxOccurs="unbounded"
ref="atom:entry" />
<!-- Start Atom's extension here -->
<xs:element minOccurs="0" maxOccurs="unbounded"
ref="cmis:type" />
<xs:element ref="cmis:hasMoreItems" minOccurs="1"
maxOccurs="1" />
<!-- original atom extension element -->
<xs:group ref="atom:extensionElement" />
</xs:sequence>
<xs:attributeGroup ref="atom:atomCommonAttributes" />
</xs:complexType>
<!-- atom:entry -->
<xs:element name="entry" type="atom:entryType">
</xs:element>
<xs:complexType name="entryType">
<xs:sequence>
<xs:sequence>
<xs:element ref="atom:author" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:category" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:content" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:contributor" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:id" minOccurs="1" maxOccurs="1" />
<xs:element ref="atom:link" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:published" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:rights" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:source" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:summary" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:title" minOccurs="1"
maxOccurs="1" />
<xs:element ref="atom:updated" minOccurs="1"
maxOccurs="1" />
<!-- CMIS AllowableActions, optional for CMIS -->
<xs:element ref="cmis:allowableActions" minOccurs="0" maxOccurs="1" />
<xs:import namespace="http://www.w3.org/1999/xhtml" schemaLocation="xhtml1-strict.xsd"/>
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
<xs:import namespace="http://www.cmis.org/2008/05" schemaLocation="CMIS-REST.xsd"/>
<!-- CMIS Properties, optional if not CMIS -->
<xs:element ref="cmis:properties" minOccurs="1" maxOccurs="1" />
<!-- This is necessary for nested entries such as descendants -->
<xs:element ref="atom:entry" minOccurs="0" maxOccurs="unbounded" />
<!-- Common attributes -->
<xs:attributeGroup name="atomCommonAttributes">
<xs:attribute ref="xml:base"/>
<xs:attribute ref="xml:lang"/>
<xs:attributeGroup ref="atom:undefinedAttribute"/>
</xs:attributeGroup>
<!-- Text Constructs -->
<xs:attributeGroup name="atomPlainTextConstruct">
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="text"/>
<xs:enumeration value="html"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<xs:group name="atomXHTMLTextConstruct">
<xs:sequence>
<xs:element ref="xhtml:div"/>
</xs:sequence>
</xs:group>
<xs:attributeGroup name="atomXHTMLTextConstruct">
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
<xs:attribute name="type" use="required">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="xhtml"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<xs:complexType name="atomTextConstruct" mixed="true">
<xs:group minOccurs="0" ref="atom:atomXHTMLTextConstruct"/>
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="text"/>
<xs:enumeration value="html"/>
<xs:enumeration value="xhtml"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
</xs:complexType>
<!-- Person Construct -->
<xs:complexType name="atomPersonConstruct">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="atom:name"/>
<xs:element ref="atom:uri"/>
<xs:element ref="atom:email"/>
<xs:group ref="atom:extensionElement"/>
</xs:choice>
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
</xs:complexType>
<xs:element name="name" type="xs:string"/>
<xs:element name="uri" type="xs:string"/>
<xs:element name="email" type="atom:atomEmailAddress"/>
<!-- Date Construct -->
<xs:complexType name="atomDateConstruct">
<xs:simpleContent>
<xs:extension base="xs:dateTime">
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- atom:feed -->
<xs:element name="feed">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="atom:author"/>
<xs:element ref="atom:category"/>
<xs:element ref="atom:contributor"/>
<xs:element ref="atom:generator"/>
<xs:element ref="atom:icon"/>
<xs:element ref="atom:id"/>
<xs:element ref="atom:link"/>
<xs:element ref="atom:logo"/>
<xs:element ref="atom:rights"/>
<xs:element ref="atom:subtitle"/>
<xs:element ref="atom:title"/>
<xs:element ref="atom:updated"/>
<xs:group ref="atom:extensionElement"/>
</xs:choice>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="atom:entry"/>
<xs:element minOccurs="0" maxOccurs="1" ref="cmis:hasMoreItems"/>
</xs:sequence>
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
</xs:complexType>
</xs:element>
<!-- atom:entry -->
<xs:element name="entry" type="atom:entryType">
</xs:element>
<xs:complexType name="entryType">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="atom:author" />
<xs:element ref="atom:category" />
<xs:element ref="atom:content" />
<xs:element ref="atom:contributor" />
<xs:element ref="atom:id" />
<xs:element ref="atom:link" />
<xs:element ref="atom:published" />
<xs:element ref="atom:rights" />
<xs:element ref="atom:source" />
<xs:element ref="atom:summary" />
<xs:element ref="atom:title" />
<xs:element ref="atom:updated" />
<xs:group ref="atom:extensionElement" />
<xs:element ref="atom:uri"></xs:element>
</xs:choice>
<xs:sequence>
<xs:element ref="cmis:properties" minOccurs="0" maxOccurs="1"/>
<xs:element ref="cmis:allowableActions" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<!-- This is necessary for nested entries such as descendants -->
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element ref="atom:entry" />
</xs:choice>
</xs:sequence>
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
</xs:complexType>
<!-- atom:content -->
<xs:attributeGroup name="atomInlineTextConstruct">
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="text"/>
<xs:enumeration value="html"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<xs:group name="atomInlineOtherConstruct">
<xs:sequence>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="atom:anyElement"/>
</xs:sequence>
</xs:group>
<xs:attributeGroup name="atomInlineOtherConstruct">
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
<xs:attribute name="type">
<xs:simpleType>
<xs:union memberTypes="atom:atomMediaType">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="xhtml"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<xs:attributeGroup name="atomOutOfLineConstruct">
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
<xs:attribute name="type" type="atom:atomMediaType"/>
<xs:attribute name="src" use="required"/>
</xs:attributeGroup>
<xs:element name="content">
<xs:complexType mixed="true">
<xs:group minOccurs="0" ref="atom:atomInlineOtherConstruct"/>
<xs:attribute name="type">
<xs:simpleType>
<xs:union memberTypes="atom:atomMediaType">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="text"/>
<xs:enumeration value="html"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:union memberTypes="atom:atomMediaType">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="xhtml"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:attribute>
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
<xs:attribute name="src"/>
</xs:complexType>
</xs:element>
<!-- atom:author -->
<xs:element name="author" type="atom:atomPersonConstruct"/>
<!-- atom:category -->
<xs:element name="category">
<xs:complexType>
<xs:complexContent>
<xs:extension base="atom:undefinedContent">
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
<xs:attribute name="term" use="required"/>
<xs:attribute name="scheme"/>
<xs:attribute name="label"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- atom:contributor -->
<xs:element name="contributor" type="atom:atomPersonConstruct"/>
<!-- atom:generator -->
<xs:element name="generator">
<xs:complexType mixed="true">
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
<xs:attribute name="uri"/>
<xs:attribute name="version"/>
</xs:complexType>
</xs:element>
<!-- atom:icon -->
<xs:element name="icon">
<xs:complexType mixed="true">
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
</xs:complexType>
</xs:element>
<!-- atom:id -->
<xs:element name="id">
<xs:complexType mixed="true">
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
</xs:complexType>
</xs:element>
<!-- atom:logo -->
<xs:element name="logo">
<xs:complexType mixed="true">
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
</xs:complexType>
</xs:element>
<!-- atom:link -->
<xs:element name="link">
<xs:annotation>
<xs:documentation>
The "atom:link" element defines a reference from an entry
or feed to a Web resource. This specification assigns no
meaning to the content (if any) of this element.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="atom:undefinedContent">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
<xs:attribute name="href" use="required" />
<xs:attribute name="rel">
</xs:attribute>
<xs:attribute name="type" type="atom:atomMediaType" />
<xs:attribute name="hreflang"
type="atom:atomLanguageTag" />
<xs:attribute name="title" />
<xs:attribute name="length" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- atom:published -->
<xs:element name="published" type="atom:atomDateConstruct"/>
<!-- atom:rights -->
<xs:element name="rights" type="atom:atomTextConstruct"/>
<!-- atom:source -->
<xs:element name="source">
<xs:annotation>
<xs:documentation>
atom:source is used to preserve metadata of a feed when an entry is copied from a feed to another feed.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="atom:author"/>
<xs:element ref="atom:category"/>
<xs:element ref="atom:contributor"/>
<xs:element ref="atom:generator"/>
<xs:element ref="atom:icon"/>
<xs:element ref="atom:id"/>
<xs:element ref="atom:link"/>
<xs:element ref="atom:logo"/>
<xs:element ref="atom:rights"/>
<xs:element ref="atom:subtitle"/>
<xs:element ref="atom:title"/>
<xs:element ref="atom:updated"/>
<xs:group ref="atom:extensionElement"/>
</xs:choice>
<xs:attributeGroup ref="atom:atomCommonAttributes"/>
</xs:complexType>
</xs:element>
<!-- atom:subtitle -->
<xs:element name="subtitle" type="atom:atomTextConstruct"/>
<!-- atom:summary -->
<xs:element name="summary" type="atom:atomTextConstruct"/>
<!-- atom:title -->
<xs:element name="title" type="atom:atomTextConstruct">
<xs:annotation>
<xs:documentation>
The "atom:title" element is a Text construct that conveys a human-
readable title for an entry or feed.
atomTitle = element atom:title { atomTextConstruct }.
</xs:documentation>
</xs:annotation>
</xs:element>
<!-- atom:updated -->
<xs:element name="updated" type="atom:atomDateConstruct">
<xs:annotation>
<xs:documentation>
The "atom:updated" element is a Date construct indicating the most
recent instant in time when an entry or feed was modified in a way
the publisher considers significant. Therefore, not all
modifications necessarily result in a changed atom:updated value.
atomUpdated = element atom:updated { atomDateConstruct }.
Publishers MAY change the value of this element over time.
</xs:documentation>
</xs:annotation>
</xs:element>
<!-- Low-level simple types -->
<xs:simpleType name="atomNCName">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:pattern value="[^:]*"/>
</xs:restriction>
</xs:simpleType>
<!-- Whatever a media type is, it contains at least one slash -->
<xs:simpleType name="atomMediaType">
<xs:restriction base="xs:string">
<xs:pattern value=".+/.+"/>
</xs:restriction>
</xs:simpleType>
<!-- As defined in RFC 3066 -->
<xs:simpleType name="atomLanguageTag">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Za-z]{1,8}(-[A-Za-z0-9]{1,8})*"/>
</xs:restriction>
</xs:simpleType>
<!--
Unconstrained; it's not entirely clear how IRI fit into
xsd:anyURI so let's not try to constrain it here
-->
<!-- Whatever an email address is, it contains at least one @ -->
<xs:simpleType name="atomEmailAddress">
<xs:restriction base="xs:string">
<xs:pattern value=".+@.+"/>
</xs:restriction>
</xs:simpleType>
<!-- Simple Extension -->
<xs:group name="extensionElement">
<xs:choice>
<xs:any namespace="##other" processContents="skip"/>
<xs:any namespace="##local" processContents="skip"/>
</xs:choice>
</xs:group>
<xs:attributeGroup name="undefinedAttribute">
<xs:anyAttribute namespace="##other" processContents="skip"/>
</xs:attributeGroup>
<xs:complexType name="undefinedContent" mixed="true">
<xs:group minOccurs="0" maxOccurs="unbounded" ref="atom:anyForeignElement"/>
</xs:complexType>
<xs:group name="anyElement">
<xs:sequence>
<xs:any processContents="skip"/>
</xs:sequence>
</xs:group>
<xs:group name="anyForeignElement">
<xs:choice>
<xs:any namespace="##other" processContents="skip"/>
<xs:any namespace="##local" processContents="skip"/>
</xs:choice>
</xs:group>
<!-- XHTML -->
<xs:group name="anyXHTML">
<xs:sequence>
<xs:any namespace="http://www.w3.org/1999/xhtml" processContents="skip"/>
</xs:sequence>
</xs:group>
<!-- Normal ATOM extension element -->
<xs:group ref="atom:extensionElement" />
</xs:sequence>
</xs:sequence>
<xs:attributeGroup ref="atom:atomCommonAttributes" />
</xs:complexType>
<!-- atom:content -->
<xs:attributeGroup name="atomInlineTextConstruct">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="text" />
<xs:enumeration value="html" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<xs:group name="atomInlineOtherConstruct">
<xs:sequence>
<xs:group minOccurs="0" maxOccurs="unbounded"
ref="atom:anyElement" />
</xs:sequence>
</xs:group>
<xs:attributeGroup name="atomInlineOtherConstruct">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
<xs:attribute name="type">
<xs:simpleType>
<xs:union memberTypes="atom:atomMediaType">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="xhtml" />
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<xs:attributeGroup name="atomOutOfLineConstruct">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
<xs:attribute name="type" type="atom:atomMediaType" />
<xs:attribute name="src" use="required" />
</xs:attributeGroup>
<xs:element name="content">
<xs:complexType mixed="true">
<xs:group minOccurs="0" ref="atom:atomInlineOtherConstruct" />
<xs:attribute name="type">
<xs:simpleType>
<xs:union memberTypes="atom:atomMediaType">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="text" />
<xs:enumeration value="html" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:union
memberTypes="atom:atomMediaType">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="xhtml" />
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:attribute>
<xs:attributeGroup ref="atom:atomCommonAttributes" />
<xs:attribute name="src" />
</xs:complexType>
</xs:element>
<!-- atom:author -->
<xs:element name="author" type="atom:atomPersonConstruct" />
<!-- atom:category -->
<xs:element name="category">
<xs:complexType>
<xs:complexContent>
<xs:extension base="atom:undefinedContent">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
<xs:attribute name="term" use="required" />
<xs:attribute name="scheme" />
<xs:attribute name="label" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- atom:contributor -->
<xs:element name="contributor" type="atom:atomPersonConstruct" />
<!-- atom:generator -->
<xs:element name="generator">
<xs:complexType mixed="true">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
<xs:attribute name="uri" />
<xs:attribute name="version" />
</xs:complexType>
</xs:element>
<!-- atom:icon -->
<xs:element name="icon">
<xs:complexType mixed="true">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
</xs:complexType>
</xs:element>
<!-- atom:id -->
<xs:element name="id">
<xs:complexType mixed="true">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
</xs:complexType>
</xs:element>
<!-- atom:logo -->
<xs:element name="logo">
<xs:complexType mixed="true">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
</xs:complexType>
</xs:element>
<!-- atom:link -->
<xs:element name="link">
<xs:annotation>
<xs:documentation>
The "atom:link" element defines a reference from an
entry or feed to a Web resource. This specification
assigns no meaning to the content (if any) of this
element.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="atom:undefinedContent">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
<xs:attribute name="href" use="required" />
<xs:attribute name="rel"></xs:attribute>
<xs:attribute name="type" type="atom:atomMediaType" />
<xs:attribute name="hreflang"
type="atom:atomLanguageTag" />
<xs:attribute name="title" />
<xs:attribute name="length" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- atom:published -->
<xs:element name="published" type="atom:atomDateConstruct" />
<!-- atom:rights -->
<xs:element name="rights" type="atom:atomTextConstruct" />
<!-- atom:source -->
<xs:element name="source">
<xs:annotation>
<xs:documentation>
atom:source is used to preserve metadata of a feed when
an entry is copied from a feed to another feed.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="atom:author" />
<xs:element ref="atom:category" />
<xs:element ref="atom:contributor" />
<xs:element ref="atom:generator" />
<xs:element ref="atom:icon" />
<xs:element ref="atom:id" />
<xs:element ref="atom:link" />
<xs:element ref="atom:logo" />
<xs:element ref="atom:rights" />
<xs:element ref="atom:subtitle" />
<xs:element ref="atom:title" />
<xs:element ref="atom:updated" />
<xs:group ref="atom:extensionElement" />
</xs:choice>
<xs:attributeGroup ref="atom:atomCommonAttributes" />
</xs:complexType>
</xs:element>
<!-- atom:subtitle -->
<xs:element name="subtitle" type="atom:atomTextConstruct" />
<!-- atom:summary -->
<xs:element name="summary" type="atom:atomTextConstruct" />
<!-- atom:title -->
<xs:element name="title" type="atom:atomTextConstruct">
<xs:annotation>
<xs:documentation>
The "atom:title" element is a Text construct that
conveys a human- readable title for an entry or feed.
atomTitle = element atom:title { atomTextConstruct }.
</xs:documentation>
</xs:annotation>
</xs:element>
<!-- atom:updated -->
<xs:element name="updated" type="atom:atomDateConstruct">
<xs:annotation>
<xs:documentation>
The "atom:updated" element is a Date construct
indicating the most recent instant in time when an entry
or feed was modified in a way the publisher considers
significant. Therefore, not all modifications
necessarily result in a changed atom:updated value.
atomUpdated = element atom:updated { atomDateConstruct
}. Publishers MAY change the value of this element over
time.
</xs:documentation>
</xs:annotation>
</xs:element>
<!-- Low-level simple types -->
<xs:simpleType name="atomNCName">
<xs:restriction base="xs:string">
<xs:minLength value="1" />
<xs:pattern value="[^:]*" />
</xs:restriction>
</xs:simpleType>
<!-- Whatever a media type is, it contains at least one slash -->
<xs:simpleType name="atomMediaType">
<xs:restriction base="xs:string">
<xs:pattern value=".+/.+" />
</xs:restriction>
</xs:simpleType>
<!-- As defined in RFC 3066 -->
<xs:simpleType name="atomLanguageTag">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Za-z]{1,8}(-[A-Za-z0-9]{1,8})*" />
</xs:restriction>
</xs:simpleType>
<!--
Unconstrained; it's not entirely clear how IRI fit into
xsd:anyURI so let's not try to constrain it here
-->
<!-- Whatever an email address is, it contains at least one @ -->
<xs:simpleType name="atomEmailAddress">
<xs:restriction base="xs:string">
<xs:pattern value=".+@.+" />
</xs:restriction>
</xs:simpleType>
<!-- Simple Extension -->
<xs:group name="extensionElement">
<xs:sequence>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<jaxb:property name='anyOther' />
</xs:appinfo>
</xs:annotation>
</xs:any>
<xs:any namespace="##local" processContents="lax"
minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<jaxb:property name='anyLocal' />
</xs:appinfo>
</xs:annotation>
</xs:any>
</xs:sequence>
</xs:group>
<xs:attributeGroup name="undefinedAttribute">
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:attributeGroup>
<xs:complexType name="undefinedContent" mixed="true">
<xs:group minOccurs="0" maxOccurs="unbounded"
ref="atom:anyForeignElement" />
</xs:complexType>
<xs:group name="anyElement">
<xs:sequence>
<xs:any processContents="lax" />
</xs:sequence>
</xs:group>
<xs:group name="anyForeignElement">
<xs:choice>
<xs:any namespace="##other" processContents="lax" />
<xs:any namespace="##local" processContents="lax" />
</xs:choice>
</xs:group>
<!-- XHTML -->
<xs:group name="anyXHTML">
<xs:sequence>
<xs:any namespace="http://www.w3.org/1999/xhtml"
processContents="lax" />
</xs:sequence>
</xs:group>
<xs:element name="service" type="atom:atomServiceType"></xs:element>
<xs:complexType name="atomServiceType">
<xs:sequence>
<xs:element ref="atom:author"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="workspace" type="atom:atomWorkspaceType"></xs:element>
<xs:complexType name="atomWorkspaceType">
<xs:sequence>
<xs:element ref="atom:title"></xs:element>
<xs:element ref="cmis:repositoryInfo"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="collection" type="xs:string"></xs:element>
<xs:complexType name="atomCollectionType">
<xs:sequence>
<xs:element ref="atom:title"></xs:element>
</xs:sequence>
<xs:attribute ref="cmis:collectionType"></xs:attribute>
<xs:attribute ref="cmis:id"></xs:attribute>
</xs:complexType>
</xs:schema>
<!-- EOF -->

File diff suppressed because it is too large Load Diff

View File

@@ -30,13 +30,8 @@ import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
import javax.xml.XMLConstants;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import junit.framework.TestCase;
@@ -51,7 +46,7 @@ import org.xml.sax.SAXException;
*
* @author davidc
*/
public class TestXSDs extends TestCase
public class CMISSchemaTest extends TestCase
{
private CMISValidator cmisValidator = new CMISValidator();
@@ -127,11 +122,25 @@ public class TestXSDs extends TestCase
// assertValidXML(xml, schema.newValidator());
// }
public void testService()
public void testAllowableActions()
throws Exception
{
String xml = getXML("Example-Service.xml");
assertValidXML(xml, cmisValidator.getAppValidator());
String xml = getXML("Example-AllowableActions.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testDocumentEntry()
throws Exception
{
String xml = getXML("Example-DocumentEntry.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testDocumentPWCEntry()
throws Exception
{
String xml = getXML("Example-DocumentPWCEntry.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testFolderChildren()
@@ -140,5 +149,54 @@ public class TestXSDs extends TestCase
String xml = getXML("Example-FolderChildren.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testFolderDescendants()
throws Exception
{
String xml = getXML("Example-FolderDescendants.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testFolderEntry()
throws Exception
{
String xml = getXML("Example-FolderEntry.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testPolicyEntry()
throws Exception
{
String xml = getXML("Example-PolicyEntry.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testQuery()
throws Exception
{
String xml = getXML("Example-Query.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testRelationshipEntry()
throws Exception
{
String xml = getXML("Example-RelationshipEntry.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testService()
throws Exception
{
String xml = getXML("Example-Service.xml");
assertValidXML(xml, cmisValidator.getAppValidator());
}
public void testType()
throws Exception
{
String xml = getXML("Example-Type.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
}

View File

@@ -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 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<!-- all -->
<cmis:canDelete>true</cmis:canDelete>

View File

@@ -5,26 +5,23 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
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 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<title>Document Entry example</title>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/document-entry</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit-media"
@@ -50,44 +47,17 @@
<atom:link rel="cmis-stream"
href="http://www.cmis.org/rep1/media/document-entry" />
<!-- atom:content -->
<atom:content src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<atom:summary>
<!-- auto-generated HTML table of properties -->
</atom:summary>
<atom:title>Document Entry example</atom:title>
<cmis:properties>
<cmis:objectId>docid1</cmis:objectId>
<cmis:baseType>document</cmis:baseType>
<cmis:lastModifiedBy>2001-12-31T12:00:00</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>email</cmis:objectType>
<cmis:isCheckedOut>false</cmis:isCheckedOut>
<cmis:isLatestVersion>true</cmis:isLatestVersion>
<cmis:isMajorVersion>true</cmis:isMajorVersion>
<cmis:isLatestMajorVersion>true</cmis:isLatestMajorVersion>
<cmis:isImmutable>false</cmis:isImmutable>
<cmis:isVersionSeriesCheckedOut>
false
</cmis:isVersionSeriesCheckedOut>
<cmis:versionSeriesCheckedOutBy></cmis:versionSeriesCheckedOutBy>
<cmis:versionSeriesCheckedOutID></cmis:versionSeriesCheckedOutID>
<cmis:checkinComment>
This is the initial checkin comment
</cmis:checkinComment>
<cmis:versionLabel>1.0</cmis:versionLabel>
<cmis:contentStreamLength>70</cmis:contentStreamLength>
<cmis:contentStreamMimetype>
text/plain
</cmis:contentStreamMimetype>
<cmis:contentStreamName>foo.txt</cmis:contentStreamName>
<cmis:contentStreamURI>
http://www.cmis.org/rep1/media/document-entry
</cmis:contentStreamURI>
</cmis:properties>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -109,4 +79,36 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyBoolean cmis:name="isCheckedOut">false</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestVersion">true</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isMajorVersion">true</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestMajorVersion">true</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isImmutable">false</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isVersionSeriesCheckedOut">false</cmis:propertyBoolean>
<cmis:propertyDateTime cmis:name="lastModifiedBy">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">docid1</cmis:propertyID>
<cmis:propertyID cmis:name="versionSeriesCheckedOutID"></cmis:propertyID>
<cmis:propertyInteger cmis:name="contentStreamLength">70</cmis:propertyInteger>
<cmis:propertyString cmis:name="objectType">email</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">document</cmis:propertyString>
<cmis:propertyString cmis:name="versionSeriesCheckedOutBy"></cmis:propertyString>
<cmis:propertyString cmis:name="checkinComment">This is the initial checkin comment</cmis:propertyString>
<cmis:propertyString cmis:name="versionLabel">1.0</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamMimetype">text/plain</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamName">foo.txt</cmis:propertyString>
<cmis:propertyURI cmis:name="contentStreamURI">
http://www.cmis.org/rep1/media/document-entry
</cmis:propertyURI>
</cmis:properties>
</atom:entry>

View File

@@ -5,26 +5,23 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
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 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<title>Document Entry example PWC</title>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/document-entry</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<!-- lastModifiedDate -->
<atom:updated>2007-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit-media"
@@ -50,50 +47,17 @@
<atom:link rel="cmis-stream"
href="http://www.cmis.org/rep1/media/document-entry" />
<!-- atom:content -->
<atom:content src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<atom:summary>
<!-- auto-generated HTML table of properties -->
</atom:summary>
<atom:title>Document Entry example</atom:title>
<cmis:properties>
<cmis:objectId>docid1pwc</cmis:objectId>
<cmis:baseType>document</cmis:baseType>
<cmis:lastModifiedBy>2001-12-31T12:00:00</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>email</cmis:objectType>
<!-- PWC -->
<cmis:isCheckedOut>true</cmis:isCheckedOut>
<cmis:isLatestVersion>true</cmis:isLatestVersion>
<cmis:isMajorVersion>false</cmis:isMajorVersion>
<cmis:isLatestMajorVersion>false</cmis:isLatestMajorVersion>
<cmis:isImmutable>false</cmis:isImmutable>
<!-- PWC -->
<cmis:isVersionSeriesCheckedOut>
true
</cmis:isVersionSeriesCheckedOut>
<cmis:versionSeriesCheckedOutBy>Al Brown</cmis:versionSeriesCheckedOutBy>
<cmis:versionSeriesCheckedOutID>docid1pwc</cmis:versionSeriesCheckedOutID>
<cmis:checkinComment></cmis:checkinComment>
<!-- PWC -->
<cmis:versionLabel>1.1</cmis:versionLabel>
<cmis:contentStreamLength>70</cmis:contentStreamLength>
<cmis:contentStreamMimetype>
text/plain
</cmis:contentStreamMimetype>
<cmis:contentStreamName>foo.txt</cmis:contentStreamName>
<cmis:contentStreamURI>
http://www.cmis.org/rep1/media/document-entry
</cmis:contentStreamURI>
</cmis:properties>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -104,7 +68,7 @@
<cmis:canMove>true</cmis:canMove>
<cmis:canDeleteVersion>true</cmis:canDeleteVersion>
<cmis:canDeleteContent>true</cmis:canDeleteContent>
<cmis:canCheckout>false</cmis:canCheckout>
<cmis:canCheckout>true</cmis:canCheckout>
<cmis:canCancelCheckout>true</cmis:canCancelCheckout>
<cmis:canCheckin>true</cmis:canCheckin>
<cmis:canSetContent>true</cmis:canSetContent>
@@ -115,4 +79,47 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<!-- PWC -->
<cmis:propertyBoolean cmis:name="isCheckedOut">true</cmis:propertyBoolean>
<!-- PWC -->
<cmis:propertyBoolean cmis:name="isLatestVersion">true</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isMajorVersion">false</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestMajorVersion">false</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isImmutable">false</cmis:propertyBoolean>
<!-- PWC -->
<cmis:propertyBoolean cmis:name="isVersionSeriesCheckedOut">true</cmis:propertyBoolean>
<cmis:propertyDateTime cmis:name="lastModifiedBy">2007-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">2007-12-31T12:00:00</cmis:propertyDateTime>
<!-- PWC -->
<cmis:propertyID cmis:name="objectId">docid1pwc</cmis:propertyID>
<!-- PWC -->
<cmis:propertyID cmis:name="versionSeriesCheckedOutID">docidpwc</cmis:propertyID>
<cmis:propertyInteger cmis:name="contentStreamLength">70</cmis:propertyInteger>
<cmis:propertyString cmis:name="objectType">email</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">document</cmis:propertyString>
<!-- PWC -->
<cmis:propertyString cmis:name="versionSeriesCheckedOutBy">Al Brown</cmis:propertyString>
<cmis:propertyString cmis:name="checkinComment">This is the initial checkin comment</cmis:propertyString>
<!-- PWC -->
<cmis:propertyString cmis:name="versionLabel">1.1</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamMimetype">text/plain</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamName">foo.txt</cmis:propertyString>
<cmis:propertyURI cmis:name="contentStreamURI">
http://www.cmis.org/rep1/media/document-entry
</cmis:propertyURI>
</cmis:properties>
</atom:entry>

View File

@@ -5,23 +5,23 @@
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 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<!-- This is a feed of folder containing:
folder1\
<!-- This is a feed of folder1 containing:
folder2
docid1
-->
-->
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<atom:title>Folder1's Children - page 3</atom:title>
<atom:id>http://www.cmis.org/rep1/folder1/children/3</atom:id>
<atom:link href="http://www.cmis.org/rep1/folder1/children/3" />
<!-- Points to the folder entry document -->
<atom:link rel="cmis-source" href="http://www.cmis.org/rep1/folder1" />
<atom:updated>2007-12-31T12:00:00</atom:updated>
<atom:link rel="cmis-source"
href="http://www.cmis.org/rep1/folder1" />
<!-- RFC 5005 Feed Paging -->
<atom:link rel="first"
@@ -33,25 +33,28 @@
<atom:link rel="last"
href="http://www.cmis.org/rep1/folder1/children/last" />
<!-- sub-folder 1 -->
<atom:entry xml:base="http://tempuri.org" xml:lang="en-US">
<title>Folder Entry example (folder2)</title>
<atom:title>Folder1's Children - page 3</atom:title>
<atom:updated>2007-12-31T12:00:00</atom:updated>
<!-- child folder2 -->
<atom:entry>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Folder Entry Example (folderid2) Property1 Value1
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/folder-entry2</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/folder-entry2" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/folder-entry2" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/folder-entry2" />
@@ -65,22 +68,13 @@
<atom:link rel="cmis-type"
href="http://www.cmis.org/rep1/type/emailfolder" />
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Folder Entry Example (folderid2) Property1 Value1
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<cmis:properties>
<cmis:objectId>folderid2</cmis:objectId>
<cmis:baseType>folder</cmis:baseType>
<cmis:lastModifiedBy>
2001-12-31T12:00:00
</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>emailfolder</cmis:objectType>
<cmis:parentId>folderid1</cmis:parentId>
</cmis:properties>
<atom:title>Folder Entry2 example</atom:title>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -94,26 +88,48 @@
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
<cmis:canGetChildren>true</cmis:canGetChildren>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyDateTime cmis:name="lastModifiedBy">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">
folderid1
</cmis:propertyID>
<cmis:propertyID cmis:name="parentId">
parentFolderId1
</cmis:propertyID>
<cmis:propertyString cmis:name="objectType">
emailfolder
</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">
folder
</cmis:propertyString>
</cmis:properties>
</atom:entry>
<atom:entry xml:base="http://tempuri.org" xml:lang="">
<title>Document Entry example</title>
<!-- child doc -->
<atom:entry>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content
src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/document-entry</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit-media"
@@ -139,47 +155,17 @@
<atom:link rel="cmis-stream"
href="http://www.cmis.org/rep1/media/document-entry" />
<!-- atom:content -->
<atom:content
src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<atom:summary>
<!-- auto-generated HTML table of properties -->
</atom:summary>
<atom:title>Document Entry example</atom:title>
<cmis:properties>
<cmis:objectId>docid1</cmis:objectId>
<cmis:baseType>document</cmis:baseType>
<cmis:lastModifiedBy>
2001-12-31T12:00:00
</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>email</cmis:objectType>
<cmis:isCheckedOut>false</cmis:isCheckedOut>
<cmis:isLatestVersion>true</cmis:isLatestVersion>
<cmis:isMajorVersion>true</cmis:isMajorVersion>
<cmis:isLatestMajorVersion>true</cmis:isLatestMajorVersion>
<cmis:isImmutable>false</cmis:isImmutable>
<cmis:isVersionSeriesCheckedOut>
false
</cmis:isVersionSeriesCheckedOut>
<cmis:versionSeriesCheckedOutBy></cmis:versionSeriesCheckedOutBy>
<cmis:versionSeriesCheckedOutID></cmis:versionSeriesCheckedOutID>
<cmis:checkinComment>
This is the initial checkin comment
</cmis:checkinComment>
<cmis:versionLabel>1.0</cmis:versionLabel>
<cmis:contentStreamLength>70</cmis:contentStreamLength>
<cmis:contentStreamMimetype>
text/plain
</cmis:contentStreamMimetype>
<cmis:contentStreamName>foo.txt</cmis:contentStreamName>
<cmis:contentStreamURI>
http://www.cmis.org/rep1/media/document-entry
</cmis:contentStreamURI>
</cmis:properties>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -201,6 +187,70 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyBoolean cmis:name="isCheckedOut">
false
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isMajorVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestMajorVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isImmutable">
false
</cmis:propertyBoolean>
<cmis:propertyBoolean
cmis:name="isVersionSeriesCheckedOut">
false
</cmis:propertyBoolean>
<cmis:propertyDateTime cmis:name="lastModifiedBy">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">
docid1
</cmis:propertyID>
<cmis:propertyID cmis:name="versionSeriesCheckedOutID"></cmis:propertyID>
<cmis:propertyInteger cmis:name="contentStreamLength">
70
</cmis:propertyInteger>
<cmis:propertyString cmis:name="objectType">
email
</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">
document
</cmis:propertyString>
<cmis:propertyString
cmis:name="versionSeriesCheckedOutBy">
</cmis:propertyString>
<cmis:propertyString cmis:name="checkinComment">
This is the initial checkin comment
</cmis:propertyString>
<cmis:propertyString cmis:name="versionLabel">
1.0
</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamMimetype">
text/plain
</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamName">
foo.txt
</cmis:propertyString>
<cmis:propertyURI cmis:name="contentStreamURI">
http://www.cmis.org/rep1/media/document-entry
</cmis:propertyURI>
</cmis:properties>
</atom:entry>
<!-- notification of more items -->

View File

@@ -5,10 +5,9 @@
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 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<!-- This is a feed of folder containing:
folder1\
<!-- This is a feed of folder1 containing:
folder2\
docid2
docid1
@@ -16,15 +15,15 @@
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<atom:title>Folder1's Children - page 3</atom:title>
<atom:id>http://www.cmis.org/rep1/folder1/children/3</atom:id>
<atom:link href="http://www.cmis.org/rep1/folder1/children/3" />
<!-- Points to the folder entry document -->
<atom:link rel="cmis-source"
href="http://www.cmis.org/rep1/folder1" />
<atom:updated>2007-12-31T12:00:00</atom:updated>
<!-- RFC 5005 Feed Paging -->
<atom:link rel="first"
href="http://www.cmis.org/rep1/folder1/children" />
@@ -35,25 +34,28 @@
<atom:link rel="last"
href="http://www.cmis.org/rep1/folder1/children/last" />
<!-- sub-folder 1 -->
<atom:entry xml:base="http://tempuri.org" xml:lang="en-US">
<title>Folder Entry example (folder2)</title>
<atom:title>Folder1's Children - page 3</atom:title>
<atom:updated>2007-12-31T12:00:00</atom:updated>
<!-- child folder2 -->
<atom:entry>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Folder Entry Example (folderid2) Property1 Value1
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/folder-entry2</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/folder-entry2" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/folder-entry2" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/folder-entry2" />
@@ -67,22 +69,13 @@
<atom:link rel="cmis-type"
href="http://www.cmis.org/rep1/type/emailfolder" />
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Folder Entry Example (folderid2) Property1 Value1
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<cmis:properties>
<cmis:objectId>folderid2</cmis:objectId>
<cmis:baseType>folder</cmis:baseType>
<cmis:lastModifiedBy>
2001-12-31T12:00:00
</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>emailfolder</cmis:objectType>
<cmis:parentId>folderid1</cmis:parentId>
</cmis:properties>
<atom:title>Folder Entry2 example</atom:title>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -97,25 +90,45 @@
<cmis:canGetChildren>true</cmis:canGetChildren>
</cmis:allowableActions>
<!-- docid2 -->
<atom:entry xml:base="http://tempuri.org" xml:lang="">
<title>Document Entry example</title>
<cmis:properties>
<cmis:propertyDateTime cmis:name="lastModifiedBy">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">
folderid2
</cmis:propertyID>
<cmis:propertyID cmis:name="parentId">
folderid1
</cmis:propertyID>
<cmis:propertyString cmis:name="objectType">
emailfolder
</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">
folder
</cmis:propertyString>
</cmis:properties>
<atom:entry>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content
src="http://www.cmis.org/rep1/media/document-entry2">
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/document-entry2</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry2" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry2" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/document-entry2" />
<atom:link rel="edit-media"
@@ -141,51 +154,17 @@
<atom:link rel="cmis-stream"
href="http://www.cmis.org/rep1/media/document-entry2" />
<!-- atom:content -->
<atom:content
src="http://www.cmis.org/rep1/media/document-entry2">
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<atom:summary>
<!-- auto-generated HTML table of properties -->
</atom:summary>
<atom:title>Document Entry2 example</atom:title>
<cmis:properties>
<cmis:objectId>docid2</cmis:objectId>
<cmis:baseType>document</cmis:baseType>
<cmis:lastModifiedBy>
2001-12-31T12:00:00
</cmis:lastModifiedBy>
<cmis:creationDate>
2001-12-31T12:00:00
</cmis:creationDate>
<cmis:objectType>email</cmis:objectType>
<cmis:isCheckedOut>false</cmis:isCheckedOut>
<cmis:isLatestVersion>true</cmis:isLatestVersion>
<cmis:isMajorVersion>true</cmis:isMajorVersion>
<cmis:isLatestMajorVersion>
true
</cmis:isLatestMajorVersion>
<cmis:isImmutable>false</cmis:isImmutable>
<cmis:isVersionSeriesCheckedOut>
false
</cmis:isVersionSeriesCheckedOut>
<cmis:versionSeriesCheckedOutBy></cmis:versionSeriesCheckedOutBy>
<cmis:versionSeriesCheckedOutID></cmis:versionSeriesCheckedOutID>
<cmis:checkinComment>
This is the initial checkin comment
</cmis:checkinComment>
<cmis:versionLabel>1.0</cmis:versionLabel>
<cmis:contentStreamLength>700</cmis:contentStreamLength>
<cmis:contentStreamMimetype>
text/plain
</cmis:contentStreamMimetype>
<cmis:contentStreamName>foo2.txt</cmis:contentStreamName>
<cmis:contentStreamURI>
http://www.cmis.org/rep1/media/document-entry2
</cmis:contentStreamURI>
</cmis:properties>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -211,27 +190,95 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyBoolean cmis:name="isCheckedOut">
false
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isMajorVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean
cmis:name="isLatestMajorVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isImmutable">
false
</cmis:propertyBoolean>
<cmis:propertyBoolean
cmis:name="isVersionSeriesCheckedOut">
false
</cmis:propertyBoolean>
<cmis:propertyDateTime cmis:name="lastModifiedBy">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">
docid2
</cmis:propertyID>
<cmis:propertyID
cmis:name="versionSeriesCheckedOutID">
</cmis:propertyID>
<cmis:propertyInteger cmis:name="contentStreamLength">
70
</cmis:propertyInteger>
<cmis:propertyString cmis:name="objectType">
email
</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">
document
</cmis:propertyString>
<cmis:propertyString
cmis:name="versionSeriesCheckedOutBy">
</cmis:propertyString>
<cmis:propertyString cmis:name="checkinComment">
This is the initial checkin comment
</cmis:propertyString>
<cmis:propertyString cmis:name="versionLabel">
1.0
</cmis:propertyString>
<cmis:propertyString
cmis:name="contentStreamMimetype">
text/plain
</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamName">
foo.txt
</cmis:propertyString>
<cmis:propertyURI cmis:name="contentStreamURI">
http://www.cmis.org/rep1/media/document-entry
</cmis:propertyURI>
</cmis:properties>
</atom:entry>
</atom:entry>
<atom:entry xml:base="http://tempuri.org" xml:lang="">
<title>Document Entry example</title>
<!-- child doc -->
<atom:entry>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content
src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/document-entry</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit-media"
@@ -257,47 +304,17 @@
<atom:link rel="cmis-stream"
href="http://www.cmis.org/rep1/media/document-entry" />
<!-- atom:content -->
<atom:content
src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<atom:summary>
<!-- auto-generated HTML table of properties -->
</atom:summary>
<atom:title>Document Entry example</atom:title>
<cmis:properties>
<cmis:objectId>docid1</cmis:objectId>
<cmis:baseType>document</cmis:baseType>
<cmis:lastModifiedBy>
2001-12-31T12:00:00
</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>email</cmis:objectType>
<cmis:isCheckedOut>false</cmis:isCheckedOut>
<cmis:isLatestVersion>true</cmis:isLatestVersion>
<cmis:isMajorVersion>true</cmis:isMajorVersion>
<cmis:isLatestMajorVersion>true</cmis:isLatestMajorVersion>
<cmis:isImmutable>false</cmis:isImmutable>
<cmis:isVersionSeriesCheckedOut>
false
</cmis:isVersionSeriesCheckedOut>
<cmis:versionSeriesCheckedOutBy></cmis:versionSeriesCheckedOutBy>
<cmis:versionSeriesCheckedOutID></cmis:versionSeriesCheckedOutID>
<cmis:checkinComment>
This is the initial checkin comment
</cmis:checkinComment>
<cmis:versionLabel>1.0</cmis:versionLabel>
<cmis:contentStreamLength>70</cmis:contentStreamLength>
<cmis:contentStreamMimetype>
text/plain
</cmis:contentStreamMimetype>
<cmis:contentStreamName>foo.txt</cmis:contentStreamName>
<cmis:contentStreamURI>
http://www.cmis.org/rep1/media/document-entry
</cmis:contentStreamURI>
</cmis:properties>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -319,8 +336,73 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyBoolean cmis:name="isCheckedOut">
false
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isMajorVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestMajorVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isImmutable">
false
</cmis:propertyBoolean>
<cmis:propertyBoolean
cmis:name="isVersionSeriesCheckedOut">
false
</cmis:propertyBoolean>
<cmis:propertyDateTime cmis:name="lastModifiedBy">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">
docid1
</cmis:propertyID>
<cmis:propertyID cmis:name="versionSeriesCheckedOutID"></cmis:propertyID>
<cmis:propertyInteger cmis:name="contentStreamLength">
70
</cmis:propertyInteger>
<cmis:propertyString cmis:name="objectType">
email
</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">
document
</cmis:propertyString>
<cmis:propertyString
cmis:name="versionSeriesCheckedOutBy">
</cmis:propertyString>
<cmis:propertyString cmis:name="checkinComment">
This is the initial checkin comment
</cmis:propertyString>
<cmis:propertyString cmis:name="versionLabel">
1.0
</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamMimetype">
text/plain
</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamName">
foo.txt
</cmis:propertyString>
<cmis:propertyURI cmis:name="contentStreamURI">
http://www.cmis.org/rep1/media/document-entry
</cmis:propertyURI>
</cmis:properties>
</atom:entry>
<!-- notification of more items -->
<cmis:hasMoreItems>true</cmis:hasMoreItems>
</atom:feed>

View File

@@ -5,25 +5,25 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
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 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<title>Folder Entry example</title>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Folder Entry Example (folderid1) Property1 Value1
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/folder-entry</atom:id>
<atom:link rel='self' href="http://www.cmis.org/rep1/folder-entry" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self' href="http://www.cmis.org/rep1/folder-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/folder-entry" />
@@ -37,21 +37,13 @@
<atom:link rel="cmis-type"
href="http://www.cmis.org/rep1/type/emailfolder" />
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Folder Entry Example (folderid1) Property1 Value1
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<atom:title>Folder Entry example</atom:title>
<cmis:properties>
<cmis:objectId>folderid1</cmis:objectId>
<cmis:baseType>folder</cmis:baseType>
<cmis:lastModifiedBy>2001-12-31T12:00:00</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>emailfolder</cmis:objectType>
<cmis:parentId>ParentFolderId</cmis:parentId>
</cmis:properties>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -65,4 +57,17 @@
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
<cmis:canGetChildren>true</cmis:canGetChildren>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyDateTime cmis:name="lastModifiedBy">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">folderid1</cmis:propertyID>
<cmis:propertyID cmis:name="parentId">parentFolderId1</cmis:propertyID>
<cmis:propertyString cmis:name="objectType">emailfolder</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">folder</cmis:propertyString>
</cmis:properties>
</atom:entry>

View File

@@ -5,25 +5,24 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
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 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
<title>Policy Entry example</title>
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Policy Entry Example (policyid1) Property1 Value1
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/policy-entry</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/policy-entry" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/policy-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/v-entry" />
@@ -37,21 +36,13 @@
<atom:link rel="cmis-target"
href="http://www.cmis.org/rep1/policy-entry/target" />
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Policy Entry Example (policyid1) Property1 Value1
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<cmis:properties>
<cmis:objectId>policyid1</cmis:objectId>
<cmis:baseType>policy</cmis:baseType>
<cmis:lastModifiedBy>2001-12-31T12:00:00</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>securitypolicy</cmis:objectType>
<cmis:source>docid1</cmis:source>
<cmis:target>docid2</cmis:target>
</cmis:properties>
<atom:title>Policy Entry example</atom:title>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -61,4 +52,15 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyDateTime cmis:name="lastModifiedBy">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">policyid1</cmis:propertyID>
<cmis:propertyString cmis:name="objectType">security policy</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">policy</cmis:propertyString>
</cmis:properties>
</atom:entry>

View File

@@ -2,7 +2,7 @@
<cmis:query xmlns:cmis="http://www.cmis.org/2008/05"
xmlns:p="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.cmis.org/2008/05 ../CMIS-REST.xsd ">
xsi:schemaLocation="http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<cmis:statement>SELECT * FROM document</cmis:statement>
<cmis:searchAllVersions>true</cmis:searchAllVersions>
<cmis:pageSize>0</cmis:pageSize>

View File

@@ -5,26 +5,24 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
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 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<title>Relationship Entry example</title>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Relationship Entry Example (relid1) Property1 Value1
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/relationship-entry</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/relationship-entry" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/relationship-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/relationship-entry" />
@@ -38,21 +36,13 @@
<atom:link rel="cmis-target"
href="http://www.cmis.org/rep1/relationship-entry/target" />
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Relationship Entry Example (relid1) Property1 Value1
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<cmis:properties>
<cmis:objectId>relid1</cmis:objectId>
<cmis:baseType>relationship</cmis:baseType>
<cmis:lastModifiedBy>2001-12-31T12:00:00</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>emaillink</cmis:objectType>
<cmis:source>docid1</cmis:source>
<cmis:target>docid2</cmis:target>
</cmis:properties>
<atom:title>Relationship Entry example</atom:title>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -62,4 +52,16 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyDateTime cmis:name="lastModifiedBy">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">relid1</cmis:propertyID>
<cmis:propertyID cmis:name="source">docid1</cmis:propertyID>
<cmis:propertyID cmis:name="target">docid2</cmis:propertyID>
<cmis:propertyString cmis:name="objectType">emaillink</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">relationship</cmis:propertyString>
</cmis:properties>
</atom:entry>

View File

@@ -20,19 +20,18 @@
<cmis:capabilityVersionSpecificFiling>true</cmis:capabilityVersionSpecificFiling>
<cmis:capabilityPWCUpdateable>true</cmis:capabilityPWCUpdateable>
<cmis:capabilityAllVersionsSearchable>true</cmis:capabilityAllVersionsSearchable>
<cmis:capabilityInnerJoin>true</cmis:capabilityInnerJoin>
<cmis:capabilityOuterJoin>true</cmis:capabilityOuterJoin>
<cmis:capabilityFullText>fulltextwithmetadata</cmis:capabilityFullText>
<cmis:capabilityJoin>innerAndOuter</cmis:capabilityJoin>
<cmis:capabilityFullText>fulltextandstructured</cmis:capabilityFullText>
</cmis:capabilities>
<cmis:repositorySpecificInformation>Welcome to ACME 99</cmis:repositorySpecificInformation>
</cmis:repositoryInfo>
<app:collection cmis:collectionType="unfiled" href="http://www.cmis.org/rep1/unfiled">
<atom:title>unfiled collection</atom:title>
</app:collection>
<app:collection cmis:collectionType="root" href="http://www.cmis.org/rep1/root">
<app:collection cmis:collectionType="root" href="http://www.cmis.org/rep1/root">
<atom:title>root collection</atom:title>
</app:collection>
<app:collection cmis:collectionType="checkedout" href="http://www.cmis.org/rep1/checkedout">
<app:collection cmis:collectionType="checkedout" href="http://www.cmis.org/rep1/checkedout">
<atom:title>checkedout collection</atom:title>
</app:collection>
<app:collection cmis:collectionType="types" href="http://www.cmis.org/rep1/types">

View File

@@ -20,6 +20,7 @@
<cmis:isContentStreamAllowed>true</cmis:isContentStreamAllowed>
<cmis:isControllable>true</cmis:isControllable>
<!-- optional property definitions -->
<cmis:property cmis:id="foo1">
<cmis:displayName>foo1</cmis:displayName>
<cmis:description>Description of foo1</cmis:description>

View File

@@ -25,14 +25,30 @@
package org.alfresco.repo.web.scripts;
import java.io.IOException;
import java.util.HashMap;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import junit.framework.TestCase;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.web.scripts.TestWebScriptServer;
import org.springframework.mock.web.MockHttpServletResponse;
import org.alfresco.web.scripts.TestWebScriptServer.Request;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
import org.apache.commons.httpclient.methods.DeleteMethod;
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.
@@ -41,11 +57,47 @@ import org.springframework.mock.web.MockHttpServletResponse;
*/
public abstract class BaseWebScriptTest extends TestCase
{
/** Standard HTTP method names */
protected static final String METHOD_POST = "post";
protected static final String METHOD_GET = "get";
protected static final String METHOD_PUT = "put";
protected static final String METHOD_DELETE = "delete";
// Logger
private static final Log logger = LogFactory.getLog(BaseWebScriptTest.class);
/** Local / Remote Server access */
private String defaultRunAs = null;
private RemoteServer remoteServer = null;
private HttpClient httpClient = null;
/**
* Set Remote Server context
*
* @param server remote server
*/
public void setRemoteServer(RemoteServer server)
{
remoteServer = server;
}
/**
* Set Local Run As User
*
* @param localRunAs
*/
public void setDefaultRunAs(String localRunAs)
{
this.defaultRunAs = localRunAs;
}
@Override
protected void setUp() throws Exception
{
super.setUp();
if (remoteServer != null)
{
httpClient = new HttpClient();
httpClient.getParams().setBooleanParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
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;
@@ -59,160 +111,222 @@ public abstract class BaseWebScriptTest extends TestCase
return BaseWebScriptTest.server;
}
/**
* "GET" the url and check for the expected status code
* Send Request to Test Web Script Server (as admin)
*
* @param url
* @param req
* @param expectedStatus
* @return
* @return response
* @throws IOException
*/
protected MockHttpServletResponse getRequest(String url, int expectedStatus)
protected Response sendRequest(Request req, int expectedStatus)
throws IOException
{
return getRequest(url, expectedStatus, null);
}
/**
* "DELETE" the url and check for the expected status code
*
* @param url
* @param expectedStatus
* @return
* @throws IOException
*/
protected MockHttpServletResponse deleteRequest(String url, int expectedStatus)
throws IOException
{
return sendRequest(METHOD_DELETE, url, expectedStatus, null, null);
return sendRequest(req, expectedStatus, null);
}
/**
* "GET" the url and check for the expected status code
* Send Request
*
* @param url
* @param req
* @param expectedStatus
* @param asUser
* @return
* @return response
* @throws IOException
*/
protected MockHttpServletResponse getRequest(String url, int expectedStatus, String asUser)
protected Response sendRequest(Request req, int expectedStatus, String asUser)
throws IOException
{
return sendRequest(METHOD_GET, url, expectedStatus, null, null, asUser);
}
/**
* "POST" the url and check for the expected status code
*
* @param url
* @param expectedStatus
* @param body
* @param contentType
* @return
* @throws IOException
*/
protected MockHttpServletResponse postRequest(String url, int expectedStatus, String body, String contentType)
throws IOException
{
return postRequest(url, expectedStatus, body.getBytes(), contentType, null);
}
/**
* "POST" the url and check for the expected status code
*
* @param url
* @param expectedStatus
* @param asUser
* @return
* @throws IOException
*/
protected MockHttpServletResponse postRequest(String url, int expectedStatus, String body, String contentType, String asUser)
throws IOException
{
return postRequest(url, expectedStatus, body.getBytes(), contentType, asUser);
}
/**
* "POST" the url and check for the expected status code
*
* @param url
* @param expectedStatus
* @return
* @throws IOException
*/
protected MockHttpServletResponse postRequest(String url, int expectedStatus, byte[] body, String contentType)
throws IOException
{
return postRequest(url, expectedStatus, body, contentType, null);
}
/**
* "POST" the url and check for the expected status code
*
* @param url
* @param expectedStatus
* @param asUser
* @return
* @throws IOException
*/
protected MockHttpServletResponse postRequest(String url, int expectedStatus, byte[] body, String contentType, String asUser)
throws IOException
{
return sendRequest(METHOD_POST, url, expectedStatus, body, contentType, asUser);
}
/**
* Send request to Test Web Script Server
*
* @param url
* @param expectedStatus
* @param body
* @param contentType
* @return
* @throws IOException
*/
protected MockHttpServletResponse putRequest(String url, int expectedStatus, String body, String contentType)
throws IOException
{
return sendRequest(METHOD_PUT, url, expectedStatus, body, contentType);
}
/**
*
* @param method
* @param url
* @param expectedStatus
* @param body
* @param contentType
* @param asUser
* @return
* @throws IOException
*/
private MockHttpServletResponse sendRequest(final String method, final String url, final int expectedStatus, final byte[] body, final String contentType, String asUser)
throws IOException
{
// send request in context of specified user
String runAsUser = (asUser == null) ? AuthenticationUtil.getSystemUserName() : asUser;
MockHttpServletResponse response = AuthenticationUtil.runAs(new RunAsWork<MockHttpServletResponse>()
if (logger.isDebugEnabled())
{
@SuppressWarnings("synthetic-access")
public MockHttpServletResponse doWork() throws Exception
{
return BaseWebScriptTest.getServer().submitRequest(method, url, new HashMap<String, String>(), body, contentType);
}
}, runAsUser);
if (expectedStatus > 0 && expectedStatus != response.getStatus())
{
//if (response.getStatus() == 500)
//{
// System.out.println(response.getContentAsString());
//}
fail("Status code " + response.getStatus() + " returned, but expected " + expectedStatus + " for " + url + " (" + method + ")");
logger.debug("Request");
logger.debug(req.getBody() == null ? null : new String(req.getBody()));
}
return response;
Response res = null;
if (remoteServer == null)
{
res = sendLocalRequest(req, expectedStatus, asUser);
}
else
{
res = sendRemoteRequest(req, expectedStatus);
}
if (logger.isDebugEnabled())
{
logger.debug("Response:");
logger.debug(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() + ")");
}
return res;
}
/**
* Send Local Request to Test Web Script Server
*
* @param req
* @param expectedStatus
* @param asUser
* @return response
* @throws IOException
*/
protected Response sendLocalRequest(final Request req, final int expectedStatus, String asUser)
throws IOException
{
asUser = (asUser == null) ? defaultRunAs : asUser;
if (asUser == null)
{
return BaseWebScriptTest.getServer().submitRequest(req.getMethod(), req.getFullUri(), req.getHeaders(), req.getBody(), req.getType());
}
else
{
// send request in context of specified user
return AuthenticationUtil.runAs(new RunAsWork<Response>()
{
@SuppressWarnings("synthetic-access")
public Response doWork() throws Exception
{
return BaseWebScriptTest.getServer().submitRequest(req.getMethod(), req.getFullUri(), req.getHeaders(), req.getBody(), req.getType());
}
}, asUser);
}
}
/**
* Send Remote Request to stand-alone Web Script Server
*
* @param req
* @param expectedStatus
* @param asUser
* @return response
* @throws IOException
*/
protected Response sendRemoteRequest(Request req, int expectedStatus)
throws IOException
{
String uri = req.getFullUri();
if (!uri.startsWith("http"))
{
uri = remoteServer.baseAddress + uri;
}
// construct method
HttpMethod httpMethod = null;
String method = req.getMethod();
if (method.equalsIgnoreCase("GET"))
{
GetMethod get = new GetMethod(req.getFullUri());
httpMethod = get;
}
else if (method.equalsIgnoreCase("POST"))
{
PostMethod post = new PostMethod(req.getFullUri());
post.setRequestEntity(new ByteArrayRequestEntity(req.getBody(), req.getType()));
httpMethod = post;
}
else if (method.equalsIgnoreCase("PUT"))
{
PutMethod put = new PutMethod(req.getFullUri());
put.setRequestEntity(new ByteArrayRequestEntity(req.getBody(), req.getType()));
httpMethod = put;
}
else if (method.equalsIgnoreCase("DELETE"))
{
DeleteMethod del = new DeleteMethod(req.getFullUri());
httpMethod = del;
}
else
{
throw new AlfrescoRuntimeException("Http Method " + method + " not supported");
}
if (req.getHeaders() != null)
{
for (Map.Entry<String, String> header : req.getHeaders().entrySet())
{
httpMethod.setRequestHeader(header.getKey(), header.getValue());
}
}
// execute method
httpClient.executeMethod(httpMethod);
return new HttpMethodResponse(httpMethod);
}
/**
* Remote Context
*/
public static class RemoteServer
{
public String baseAddress;
public String username;
public String password;
}
/**
* HttpMethod wrapped as Web Script Test Response
*/
public static class HttpMethodResponse
implements Response
{
private HttpMethod method;
public HttpMethodResponse(HttpMethod method)
{
this.method = method;
}
public byte[] getContentAsByteArray()
{
try
{
return method.getResponseBody();
}
catch (IOException e)
{
return null;
}
}
public String getContentAsString() throws UnsupportedEncodingException
{
try
{
return method.getResponseBodyAsString();
}
catch (IOException e)
{
return null;
}
}
public String getContentType()
{
return getHeader("Content-Type");
}
public String getHeader(String name)
{
Header header = method.getResponseHeader(name);
return (header != null) ? header.getValue() : null;
}
public int getStatus()
{
return method.getStatusCode();
}
}
}

View File

@@ -30,11 +30,14 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.PropertyMap;
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.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test the Activity Service's User Feed Control Web Script API
@@ -116,7 +119,7 @@ public class FeedControlTest extends BaseWebScriptTest
feedControl.put("appToolId", appToolId);
int expectedStatus = 200;
MockHttpServletResponse response = postRequest(URL_CONTROL, expectedStatus, feedControl.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_CONTROL, feedControl.toString(), "application/json"), expectedStatus);
if (logger.isDebugEnabled())
{
@@ -128,7 +131,7 @@ public class FeedControlTest extends BaseWebScriptTest
{
// Get (retrieve) feed controls
int expectedStatus = 200;
MockHttpServletResponse response = getRequest(URL_CONTROLS, expectedStatus);
Response response = sendRequest(new GetRequest(URL_CONTROLS), expectedStatus);
JSONArray result = new JSONArray(response.getContentAsString());
if (logger.isDebugEnabled())
@@ -151,7 +154,7 @@ public class FeedControlTest extends BaseWebScriptTest
{
// Unset (delete) feed control
int expectedStatus = 200;
MockHttpServletResponse response = deleteRequest(URL_CONTROL + "?s=" + TEST_SITE_ID + "&a=" + TEST_APP_TOOL_ID, expectedStatus);
Response response = sendRequest(new DeleteRequest(URL_CONTROL + "?s=" + TEST_SITE_ID + "&a=" + TEST_APP_TOOL_ID), expectedStatus);
if (logger.isDebugEnabled())
{

View File

@@ -37,11 +37,15 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.PropertyMap;
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.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit Test to test Blog Web Script API
@@ -178,7 +182,7 @@ public class BlogServiceTest extends BaseWebScriptTest
throws Exception
{
JSONObject post = getRequestObject(title, content, tags, isDraft);
MockHttpServletResponse response = postRequest(URL_BLOG_POSTS, expectedStatus, post.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_BLOG_POSTS, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -203,7 +207,7 @@ public class BlogServiceTest extends BaseWebScriptTest
throws Exception
{
JSONObject post = getRequestObject(title, content, tags, isDraft);
MockHttpServletResponse response = putRequest(URL_BLOG_POST + name, expectedStatus, post.toString(), "application/json");
Response response = sendRequest(new PutRequest(URL_BLOG_POST + name, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -217,7 +221,7 @@ public class BlogServiceTest extends BaseWebScriptTest
private JSONObject getPost(String name, int expectedStatus)
throws Exception
{
MockHttpServletResponse response = getRequest(URL_BLOG_POST + name, expectedStatus);
Response response = sendRequest(new GetRequest(URL_BLOG_POST + name), expectedStatus);
if (expectedStatus == 200)
{
JSONObject result = new JSONObject(response.getContentAsString());
@@ -245,7 +249,7 @@ public class BlogServiceTest extends BaseWebScriptTest
JSONObject comment = new JSONObject();
comment.put("title", title);
comment.put("content", content);
MockHttpServletResponse response = postRequest(getCommentsUrl(nodeRef), expectedStatus, comment.toString(), "application/json");
Response response = sendRequest(new PostRequest(getCommentsUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -263,7 +267,7 @@ public class BlogServiceTest extends BaseWebScriptTest
JSONObject comment = new JSONObject();
comment.put("title", title);
comment.put("content", content);
MockHttpServletResponse response = putRequest(getCommentUrl(nodeRef), expectedStatus, comment.toString(), "application/json");
Response response = sendRequest(new PutRequest(getCommentUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -385,7 +389,7 @@ public class BlogServiceTest extends BaseWebScriptTest
public void testGetAll() throws Exception
{
String url = URL_BLOG_POSTS;
MockHttpServletResponse response = getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have posts.size + drafts.size together
@@ -395,7 +399,7 @@ public class BlogServiceTest extends BaseWebScriptTest
public void testGetNew() throws Exception
{
String url = URL_BLOG_POSTS + "/new";
MockHttpServletResponse response = getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have posts.size
@@ -405,7 +409,7 @@ public class BlogServiceTest extends BaseWebScriptTest
public void _testGetDrafts() throws Exception
{
String url = URL_BLOG_POSTS + "/mydrafts";
MockHttpServletResponse response = getRequest(URL_BLOG_POSTS, 200);
Response response = sendRequest(new GetRequest(URL_BLOG_POSTS), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have drafts.size resultss
@@ -413,7 +417,7 @@ public class BlogServiceTest extends BaseWebScriptTest
// the second user should have zero
this.authenticationComponent.setCurrentUser(USER_TWO);
response = getRequest(url, 200);
response = sendRequest(new GetRequest(url), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(0, result.getInt("total"));
this.authenticationComponent.setCurrentUser(USER_ONE);
@@ -423,7 +427,7 @@ public class BlogServiceTest extends BaseWebScriptTest
public void _testMyPublished() throws Exception
{
String url = URL_BLOG_POSTS + "/mypublished";
MockHttpServletResponse response = getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have posts.size results
@@ -431,7 +435,7 @@ public class BlogServiceTest extends BaseWebScriptTest
// the second user should have zero
this.authenticationComponent.setCurrentUser(USER_TWO);
response = getRequest(url, 200);
response = sendRequest(new GetRequest(url), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(0, result.getInt("total"));
this.authenticationComponent.setCurrentUser(USER_ONE);
@@ -447,21 +451,21 @@ public class BlogServiceTest extends BaseWebScriptTest
JSONObject commentTwo = createComment(nodeRef, "comment", "content", 200);
// fetch the comments
MockHttpServletResponse response = getRequest(getCommentsUrl(nodeRef), 200);
Response response = sendRequest(new GetRequest(getCommentsUrl(nodeRef)), 200);
JSONObject result = new JSONObject(response.getContentAsString());
assertEquals(2, result.getInt("total"));
// add another one
JSONObject commentThree = createComment(nodeRef, "comment", "content", 200);
response = getRequest(getCommentsUrl(nodeRef), 200);
response = sendRequest(new GetRequest(getCommentsUrl(nodeRef)), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(3, result.getInt("total"));
// delete the last comment
response = deleteRequest(getCommentUrl(commentThree.getString("nodeRef")), 200);
response = sendRequest(new DeleteRequest(getCommentUrl(commentThree.getString("nodeRef"))), 200);
response = getRequest(getCommentsUrl(nodeRef), 200);
response = sendRequest(new GetRequest(getCommentsUrl(nodeRef)), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(2, result.getInt("total"));

View File

@@ -36,10 +36,14 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.PropertyMap;
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.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit Test to test Discussions Web Script API
@@ -151,7 +155,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
JSONObject post = new JSONObject();
post.put("title", title);
post.put("content", content);
MockHttpServletResponse response = postRequest(URL_FORUM_POSTS, expectedStatus, post.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_FORUM_POSTS, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -171,7 +175,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
JSONObject post = new JSONObject();
post.put("title", title);
post.put("content", content);
MockHttpServletResponse response = putRequest(getPostUrl(nodeRef), expectedStatus, post.toString(), "application/json");
Response response = sendRequest(new PutRequest(URL_FORUM_POST + name, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -185,7 +189,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
private JSONObject getPost(String name, int expectedStatus)
throws Exception
{
MockHttpServletResponse response = getRequest(URL_FORUM_POST + name, expectedStatus);
Response response = sendRequest(new GetRequest(URL_FORUM_POST + name), expectedStatus);
if (expectedStatus == 200)
{
JSONObject result = new JSONObject(response.getContentAsString());
@@ -213,7 +217,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
JSONObject reply = new JSONObject();
reply.put("title", title);
reply.put("content", content);
MockHttpServletResponse response = postRequest(getRepliesUrl(nodeRef), expectedStatus, reply.toString(), "application/json");
Response response = sendRequest(new PostRequest(getRepliesUrl(nodeRef), reply.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -224,6 +228,23 @@ public class DiscussionServiceTest extends BaseWebScriptTest
return result.getJSONObject("item");
}
private JSONObject updateComment(String nodeRef, String title, String content, int expectedStatus)
throws Exception
{
JSONObject comment = new JSONObject();
comment.put("title", title);
comment.put("content", content);
Response response = sendRequest(new PutRequest(getPostUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
return null;
}
//logger.debug("Comment updated: " + response.getContentAsString());
JSONObject result = new JSONObject(response.getContentAsString());
return result.getJSONObject("item");
}
// Tests
@@ -268,7 +289,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
public void testGetAll() throws Exception
{
String url = URL_FORUM_POSTS;
MockHttpServletResponse response = getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have posts.size + drafts.size together
@@ -282,10 +303,10 @@ public class DiscussionServiceTest extends BaseWebScriptTest
String name = item.getString("name");
// delete the post
MockHttpServletResponse response = deleteRequest(URL_FORUM_POST + name, 200);
Response response = sendRequest(new DeleteRequest(URL_FORUM_POST + name), 200);
// try to fetch it again
getRequest(URL_FORUM_POST + name, 404);
sendRequest(new GetRequest(URL_FORUM_POST + name), 404);
}
public void testAddReply() throws Exception
@@ -307,7 +328,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
assertEquals("test2", reply2.getString("content"));
// fetch all replies for the post
MockHttpServletResponse response = getRequest(getRepliesUrl(postNodeRef), 200);
Response response = sendRequest(new GetRequest(getRepliesUrl(postNodeRef)), 200);
logger.debug(response.getContentAsString());
JSONObject result = new JSONObject(response.getContentAsString());
// check the number of replies

View File

@@ -50,9 +50,13 @@ import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.util.PropertyMap;
import org.alfresco.util.URLEncoder;
import org.alfresco.web.scripts.Status;
<<<<<<< .working
import org.apache.commons.lang.RandomStringUtils;
=======
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
>>>>>>> .merge-right.r9819
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit Test to test Invite Web Script API
@@ -279,11 +283,18 @@ public class InviteServiceTest extends BaseWebScriptTest
private void deletePersonByUserName(String userName)
{
<<<<<<< .working
// delete authentication if authentication exists for given user name
if (this.authenticationService.authenticationExists(userName))
{
this.authenticationService.deleteAuthentication(userName);
}
=======
// Inviter sends invitation to Invitee to join a Site
String startInviteUrl = URL_INVITE_SERVICE + "/" + INVITE_ACTION_START + "?inviteeEmail=" + inviteeEmail
+ "&siteShortName=" + siteShortName;
Response response = sendRequest(new GetRequest(startInviteUrl), expectedStatus);
>>>>>>> .merge-right.r9819
// delete user account
if (this.mutableAuthenticationDao.userExists(userName))
@@ -480,10 +491,15 @@ public class InviteServiceTest extends BaseWebScriptTest
String inviteId = result.getString("inviteId");
// Inviter cancels pending invitation
<<<<<<< .working
String cancelInviteUrl = URL_INVITE_SERVICE + "/"
+ INVITE_ACTION_CANCEL + "?inviteId=" + inviteId;
MockHttpServletResponse response = getRequest(cancelInviteUrl,
Status.STATUS_OK);
=======
String cancelInviteUrl = URL_INVITE_SERVICE + "/" + INVITE_ACTION_CANCEL + "?workflowId=" + workflowId;
Response response = sendRequest(new GetRequest(cancelInviteUrl), Status.STATUS_OK);
>>>>>>> .merge-right.r9819
}
public void testAcceptInvite() throws Exception
@@ -501,6 +517,7 @@ public class InviteServiceTest extends BaseWebScriptTest
String inviteeUserName = result.getString("inviteeUserName");
// Invitee accepts invitation to a Site from Inviter
<<<<<<< .working
String acceptInviteUrl = URL_INVITE_SERVICE + "/" + inviteId + "/" + inviteTicket + "/accept";
MockHttpServletResponse response = putRequest(acceptInviteUrl,
Status.STATUS_OK, null, null);
@@ -518,6 +535,11 @@ public class InviteServiceTest extends BaseWebScriptTest
// there should no longer be any invites identified by invite ID pending
assertEquals(getInvitesResult.getJSONArray("invites").length(), 0);
=======
String acceptInviteUrl = URL_INVITERSP_SERVICE + "/" + INVITE_RSP_ACCEPT + "?workflowId=" + workflowId
+ "&inviteeUserName=" + inviteeUserName + "&siteShortName=" + SITE_SHORT_NAME_INVITE;
Response response = sendRequest(new GetRequest(acceptInviteUrl), Status.STATUS_OK);
>>>>>>> .merge-right.r9819
}
public void testRejectInvite() throws Exception
@@ -570,11 +592,21 @@ public class InviteServiceTest extends BaseWebScriptTest
JSONObject getInvitesResult = getInvitesByInviteId(inviteId,
Status.STATUS_OK);
<<<<<<< .working
assertEquals(getInvitesResult.getJSONArray("invites").length(), 1);
JSONObject inviteJSONObj = getInvitesResult.getJSONArray("invites").getJSONObject(0);
assertEquals(inviteId, inviteJSONObj.get("inviteId"));
=======
// get hold of invitee user name that was generated as part of starting the invite
String inviteeUserName = result.getString("inviteeUserName");
// Invitee rejects invitation to a Site from Inviter
String rejectInviteUrl = URL_INVITERSP_SERVICE + "/" + INVITE_RSP_REJECT + "?workflowId=" + workflowId
+ "&inviteeUserName=" + inviteeUserName + "&siteShortName=" + SITE_SHORT_NAME_INVITE;
Response response = sendRequest(new GetRequest(rejectInviteUrl), Status.STATUS_OK);
>>>>>>> .merge-right.r9819
}
public void testGetInvitesByInviterUserName() throws Exception

View File

@@ -33,10 +33,11 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.PropertyMap;
import org.alfresco.web.scripts.Status;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.apache.commons.lang.RandomStringUtils;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test person Web Script API
@@ -168,7 +169,8 @@ public class PersonServiceTest extends BaseWebScriptTest
person.put("jobtitle", jobTitle);
person.put("email", email);
MockHttpServletResponse response = postRequest(URL_PEOPLE, expectedStatus, person.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_PEOPLE, person.toString(), "application/json"), expectedStatus);
this.createdPeople.add(userName);
if ((userName != null) && (userName.length() != 0))
{
@@ -202,22 +204,20 @@ public class PersonServiceTest extends BaseWebScriptTest
{
// Test basic GET people with no filters ==
MockHttpServletResponse response = getRequest(URL_PEOPLE, Status.STATUS_OK);
Response response = sendRequest(new GetRequest(URL_PEOPLE), 200);
System.out.println(response.getContentAsString());
}
public void testGetPerson() throws Exception
{
// Get a person that doesn't exist
MockHttpServletResponse response = getRequest(URL_PEOPLE + "/" + "nonExistantUser", 404);
Response response = sendRequest(new GetRequest(URL_PEOPLE + "/" + "nonExistantUser"), 404);
// Create a person and get him/her
String userName = RandomStringUtils.randomNumeric(6);
JSONObject result = createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation",
"myJobTitle", "myEmailAddress", "myBio", "images/avatar.jpg", Status.STATUS_OK);
response = getRequest(URL_PEOPLE + "/" + userName, Status.STATUS_OK);
"myJobTitle", "myEmailAddress", "myBio", "images/avatar.jpg", 200);
response = sendRequest(new GetRequest(URL_PEOPLE + "/" + userName), 200);
}
public void testUpdatePerson() throws Exception

View File

@@ -24,21 +24,17 @@
*/
package org.alfresco.repo.web.scripts.preference;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.site.SiteModel;
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.GUID;
import org.alfresco.util.PropertyMap;
import org.json.JSONArray;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test preference Web Script API
@@ -102,7 +98,7 @@ public class PreferenceServiceTest extends BaseWebScriptTest
{
// Get the preferences before they have been set
MockHttpServletResponse resp = getRequest(URL, 200);
Response resp = sendRequest(new GetRequest(URL), 200);
JSONObject jsonResult = new JSONObject(resp.getContentAsString());
assertNotNull(jsonResult);
@@ -113,12 +109,12 @@ public class PreferenceServiceTest extends BaseWebScriptTest
JSONObject jsonObject = getPreferenceObj();
jsonObject.put("comp1", getPreferenceObj());
resp = postRequest(URL, 200, jsonObject.toString(), "application/json");
assertEquals(0, resp.getContentLength());
resp = sendRequest(new PostRequest(URL, jsonObject.toString(), "application/json"), 200);
assertEquals(0, resp.getContentAsByteArray().length);
// Get the preferences
resp = getRequest(URL, 200);
resp = sendRequest(new GetRequest(URL), 200);
jsonResult = new JSONObject(resp.getContentAsString());
assertNotNull(jsonResult);
assertTrue(jsonResult.keys().hasNext());
@@ -131,12 +127,12 @@ public class PreferenceServiceTest extends BaseWebScriptTest
jsonObject.put("stringValue", "updated");
jsonObject.put("comp2", getPreferenceObj());
resp = postRequest(URL, 200, jsonObject.toString(), "application/json");
assertEquals(0, resp.getContentLength());
resp = sendRequest(new PostRequest(URL, jsonObject.toString(), "application/json"), 200);
assertEquals(0, resp.getContentAsByteArray().length);
// Get the preferences
resp = getRequest(URL, 200);
resp = sendRequest(new GetRequest(URL), 200);
jsonResult = new JSONObject(resp.getContentAsString());
assertNotNull(jsonResult);
assertTrue(jsonResult.keys().hasNext());
@@ -149,7 +145,7 @@ public class PreferenceServiceTest extends BaseWebScriptTest
// Filter the preferences retrieved
resp = getRequest(URL + "?pf=comp2", 200);
resp = sendRequest(new GetRequest(URL + "?pf=comp2"), 200);
jsonResult = new JSONObject(resp.getContentAsString());
assertNotNull(jsonResult);
assertTrue(jsonResult.keys().hasNext());
@@ -163,10 +159,10 @@ public class PreferenceServiceTest extends BaseWebScriptTest
// Clear all the preferences
// Test trying to update another user's permissions
postRequest("/api/people/" + USER_BAD + "/preferences", 500, jsonObject.toString(), "application/json");
sendRequest(new PostRequest("/api/people/" + USER_BAD + "/preferences", jsonObject.toString(), "application/json"), 500);
// Test error conditions
getRequest("/api/people/noExistUser/preferences", 404);
sendRequest(new GetRequest("/api/people/noExistUser/preferences"), 404);
}
private JSONObject getPreferenceObj()

View File

@@ -35,9 +35,13 @@ import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.GUID;
import org.alfresco.util.PropertyMap;
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.Response;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test site Web Script API
@@ -103,7 +107,7 @@ public class SiteServiceTest extends BaseWebScriptTest
// Tidy-up any site's create during the execution of the test
for (String shortName : this.createdSites)
{
deleteRequest(URL_SITES + "/" + shortName, 0);
sendRequest(new DeleteRequest(URL_SITES + "/" + shortName), 0);
}
// Clear the list
@@ -137,14 +141,14 @@ public class SiteServiceTest extends BaseWebScriptTest
site.put("title", title);
site.put("description", description);
site.put("isPublic", isPublic);
MockHttpServletResponse response = postRequest(URL_SITES, expectedStatus, site.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_SITES, site.toString(), "application/json"), expectedStatus);
this.createdSites.add(shortName);
return new JSONObject(response.getContentAsString());
}
public void testGetSites() throws Exception
{
MockHttpServletResponse response = getRequest(URL_SITES, 200);
Response response = sendRequest(new GetRequest(URL_SITES), 200);
JSONArray result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(0, result.length());
@@ -174,12 +178,12 @@ public class SiteServiceTest extends BaseWebScriptTest
public void testGetSite() throws Exception
{
// Get a site that doesn't exist
MockHttpServletResponse response = getRequest(URL_SITES + "/" + "somerandomshortname", 404);
Response response = sendRequest(new GetRequest(URL_SITES + "/" + "somerandomshortname"), 404);
// Create a site and get it
String shortName = GUID.generate();
JSONObject result = createSite("myPreset", shortName, "myTitle", "myDescription", true, 200);
response = getRequest(URL_SITES + "/" + shortName, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
}
@@ -193,14 +197,14 @@ public class SiteServiceTest extends BaseWebScriptTest
result.put("title", "abs123abc");
result.put("description", "123abc123");
result.put("isPublic", false);
MockHttpServletResponse response = putRequest(URL_SITES + "/" + shortName, 200, result.toString(), "application/json");
Response response = sendRequest(new PutRequest(URL_SITES + "/" + shortName, result.toString(), "application/json"), 200);
result = new JSONObject(response.getContentAsString());
assertEquals("abs123abc", result.get("title"));
assertEquals("123abc123", result.get("description"));
assertFalse(result.getBoolean("isPublic"));
// Try and get the site and double check it's changed
response = getRequest(URL_SITES + "/" + shortName, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
result = new JSONObject(response.getContentAsString());
assertEquals("abs123abc", result.get("title"));
assertEquals("123abc123", result.get("description"));
@@ -210,20 +214,20 @@ public class SiteServiceTest extends BaseWebScriptTest
public void testDeleteSite() throws Exception
{
// Delete non-existant site
MockHttpServletResponse response = deleteRequest(URL_SITES + "/" + "somerandomshortname", 404);
Response response = sendRequest(new DeleteRequest(URL_SITES + "/" + "somerandomshortname"), 404);
// Create a site
String shortName = GUID.generate();
JSONObject result = createSite("myPreset", shortName, "myTitle", "myDescription", true, 200);
// Get the site
response = getRequest(URL_SITES + "/" + shortName, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
// Delete the site
response = deleteRequest(URL_SITES + "/" + shortName, 200);
response = sendRequest(new DeleteRequest(URL_SITES + "/" + shortName), 200);
// Get the site
response = getRequest(URL_SITES + "/" + shortName, 404);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 404);
}
public void testGetMemeberships() throws Exception
@@ -233,7 +237,7 @@ public class SiteServiceTest extends BaseWebScriptTest
createSite("myPreset", shortName, "myTitle", "myDescription", true, 200);
// Check the memberships
MockHttpServletResponse response = getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200);
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS), 200);
JSONArray result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(1, result.length());
@@ -256,7 +260,7 @@ public class SiteServiceTest extends BaseWebScriptTest
membership.put("person", person);
// Post the memebership
MockHttpServletResponse response = postRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200, membership.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// Check the result
@@ -264,7 +268,7 @@ public class SiteServiceTest extends BaseWebScriptTest
assertEquals(USER_TWO, membership.getJSONObject("person").get("userName"));
// Get the membership list
response = getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS), 200);
JSONArray result2 = new JSONArray(response.getContentAsString());
assertNotNull(result2);
assertEquals(2, result2.length());
@@ -277,11 +281,11 @@ public class SiteServiceTest extends BaseWebScriptTest
createSite("myPreset", shortName, "myTitle", "myDescription", true, 200);
// Test error conditions
getRequest(URL_SITES + "/badsite" + URL_MEMBERSHIPS + "/" + USER_ONE, 404);
getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/baduser", 404);
getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 404);
sendRequest(new GetRequest(URL_SITES + "/badsite" + URL_MEMBERSHIPS + "/" + USER_ONE), 404);
sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/baduser"), 404);
sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 404);
MockHttpServletResponse response = getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_ONE, 200);
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_ONE), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// Check the result
@@ -306,12 +310,12 @@ public class SiteServiceTest extends BaseWebScriptTest
membership.put("person", person);
// Post the memebership
MockHttpServletResponse response = postRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200, membership.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
JSONObject newMember = new JSONObject(response.getContentAsString());
// Update the role
newMember.put("role", SiteModel.SITE_COLLABORATOR);
response = putRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 200, newMember.toString(), "application/json");
response = sendRequest(new PutRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, newMember.toString(), "application/json"), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// Check the result
@@ -319,7 +323,7 @@ public class SiteServiceTest extends BaseWebScriptTest
assertEquals(USER_TWO, result.getJSONObject("person").get("userName"));
// Double check and get the membership for user two
response = getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(SiteModel.SITE_COLLABORATOR, result.get("role"));
assertEquals(USER_TWO, result.getJSONObject("person").get("userName"));
@@ -339,13 +343,13 @@ public class SiteServiceTest extends BaseWebScriptTest
membership.put("person", person);
// Post the membership
postRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200, membership.toString(), "application/json");
sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
// Delete the membership
deleteRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 200);
sendRequest(new DeleteRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 200);
// Check that the membership has been deleted
getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 404);
sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 404);
}

View File

@@ -37,9 +37,11 @@ import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.util.GUID;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test thumbnail web script API
@@ -110,13 +112,13 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "webpreview");
MockHttpServletResponse response = this.postRequest(url, 200, tn.toString(), "application/json");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
System.out.println(response.getContentAsString());
}
// Check getAll whilst we are here
MockHttpServletResponse getAllResp = this.getRequest(getThumbnailsURL(jpgNode), 200);
Response getAllResp = sendRequest(new GetRequest(getThumbnailsURL(jpgNode)), 200);
JSONArray getArr = new JSONArray(getAllResp.getContentAsString());
assertNotNull(getArr);
assertEquals(0, getArr.length());
@@ -125,16 +127,16 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnails";
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "medium");
MockHttpServletResponse response = this.postRequest(url, 200, tn.toString(), "application/json");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
System.out.println(response.getContentAsString());
JSONObject result = new JSONObject(response.getContentAsString());
String thumbnailUrl = result.getString("url").substring(17);
System.out.println(thumbnailUrl);
response = getRequest(thumbnailUrl, 200);
response = sendRequest(new GetRequest(thumbnailUrl), 200);
// Check getAll whilst we are here
getAllResp = this.getRequest(getThumbnailsURL(jpgNode), 200);
getAllResp = sendRequest(new GetRequest(getThumbnailsURL(jpgNode)), 200);
getArr = new JSONArray(getAllResp.getContentAsString());
assertNotNull(getArr);
assertEquals(1, getArr.length());
@@ -203,7 +205,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "webpreview");
MockHttpServletResponse response = this.postRequest(url, 200, tn.toString(), "application/json");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
assertEquals("", response.getContentAsString().trim());
getWait(pdfNode, "webpreview");
}
@@ -212,7 +214,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnails?as=true";
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "medium");
MockHttpServletResponse response = this.postRequest(url, 200, tn.toString(), "application/json");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
assertEquals("", response.getContentAsString().trim());
getWait(jpgNode, "medium");
@@ -232,7 +234,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
fail("Thumbnail never gets created " + thumbnailName);
}
MockHttpServletResponse response = getRequest(url, 0);
Response response = sendRequest(new GetRequest(url), 0);
if (response.getStatus() == 200)
{
break;
@@ -257,13 +259,13 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
if (this.contentService.getTransformer(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_FLASH) != null)
{
// Check that there is no place holder set for webpreview
this.getRequest(getThumbnailsURL(pdfNode) + "/webpreview", 404);
this.getRequest(getThumbnailsURL(pdfNode) + "/webpreview?ph=true", 404);
sendRequest(new GetRequest(getThumbnailsURL(pdfNode) + "/webpreview"), 404);
sendRequest(new GetRequest(getThumbnailsURL(pdfNode) + "/webpreview?ph=true"), 404);
}
// Check that here is a place holder for medium
this.getRequest(getThumbnailsURL(jpgNode) + "/medium", 404);
this.getRequest(getThumbnailsURL(jpgNode) + "/medium?ph=true", 200);
sendRequest(new GetRequest(getThumbnailsURL(jpgNode) + "/medium"), 404);
sendRequest(new GetRequest(getThumbnailsURL(jpgNode) + "/medium?ph=true"), 200);
System.out.println(getThumbnailsURL(jpgNode) + "/medium?ph=true");
}

View File

@@ -4,6 +4,6 @@
<beans>
<import resource="classpath:alfresco/application-context.xml" />
<import resource="classpath:web-services-application-context.xml" />
<import resource="classpath:alfresco/web-services-application-context.xml" />
</beans>

View File

@@ -46,5 +46,9 @@ public interface CMISConstants
public static final QName PROPERTIES = new QName(CMIS_200805_NS, "properties");
public static final QName OBJECTID = new QName(CMIS_200805_NS, "objectId");
public static final QName BASETYPE = new QName(CMIS_200805_NS, "baseType");
public static final String REL_CHILDREN = "cmis-children";
public static final String REL_PARENT = "cmis-parent";
public static final String REL_PARENTS = "cmis-parents";
public static final String REL_ALLVERSIONS = "cmis-allversions";
}