mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge from SEAMIST3
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10734 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -55,6 +55,7 @@ public class BaseCMISWebScriptTest extends BaseWebScriptTest
|
||||
{
|
||||
private CMISValidator cmisValidator = new CMISValidator();
|
||||
private boolean argsAsHeaders = false;
|
||||
private boolean validateResponse = true;
|
||||
|
||||
/**
|
||||
* Pass URL arguments as headers
|
||||
@@ -65,7 +66,17 @@ public class BaseCMISWebScriptTest extends BaseWebScriptTest
|
||||
{
|
||||
this.argsAsHeaders = argsAsHeaders;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate Response
|
||||
*
|
||||
* @param validateResponse
|
||||
*/
|
||||
protected void setValidateResponse(boolean validateResponse)
|
||||
{
|
||||
this.validateResponse = validateResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if URL arguments are passed as headers
|
||||
*
|
||||
@@ -125,14 +136,17 @@ public class BaseCMISWebScriptTest extends BaseWebScriptTest
|
||||
protected void assertValidXML(String xml, Validator validator)
|
||||
throws IOException, ParserConfigurationException
|
||||
{
|
||||
try
|
||||
if (validateResponse)
|
||||
{
|
||||
Document document = cmisValidator.getDocumentBuilder().parse(new InputSource(new StringReader(xml)));
|
||||
validator.validate(new DOMSource(document));
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
fail(cmisValidator.toString(e, xml));
|
||||
try
|
||||
{
|
||||
Document document = cmisValidator.getDocumentBuilder().parse(new InputSource(new StringReader(xml)));
|
||||
validator.validate(new DOMSource(document));
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
fail(cmisValidator.toString(e, xml));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,7 @@ package org.alfresco.repo.cmis.rest;
|
||||
import java.io.StringReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -63,31 +64,27 @@ import org.apache.commons.logging.LogFactory;
|
||||
*/
|
||||
public class CMISTest extends BaseCMISWebScriptTest
|
||||
{
|
||||
// test context
|
||||
protected static boolean remote = false;
|
||||
|
||||
// Alfresco
|
||||
protected static String repositoryUrl = "http://localhost:8080/alfresco/service/api/repository";
|
||||
protected static boolean validateResponse = true;
|
||||
protected static String username = "admin";
|
||||
protected static String password = "admin";
|
||||
protected static boolean argsAsHeaders = false;
|
||||
|
||||
// Logger
|
||||
private static final Log logger = LogFactory.getLog(CMISTest.class);
|
||||
|
||||
private AbderaService abdera;
|
||||
|
||||
// test context
|
||||
private String repositoryUrl = "http://localhost:8080/alfresco/service/api/repository";
|
||||
|
||||
|
||||
// cached responses
|
||||
private AbderaService abdera;
|
||||
private static Service service = null;
|
||||
private static String fulltextCapability = null;
|
||||
private static Entry testsFolder = null;
|
||||
private static Entry testRunFolder = null;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the Repository "service" URL
|
||||
*
|
||||
* @param repositoryUrl repository service url
|
||||
*/
|
||||
public void setRepositoryUrl(String repositoryUrl)
|
||||
{
|
||||
this.repositoryUrl = repositoryUrl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp()
|
||||
@@ -99,8 +96,21 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
abderaImpl.registerExtensionFactory(new CMISExtensionFactory());
|
||||
abdera = abderaImpl;
|
||||
|
||||
// setup user
|
||||
setDefaultRunAs("admin");
|
||||
if (remote)
|
||||
{
|
||||
RemoteServer server = new RemoteServer();
|
||||
server.username = username;
|
||||
server.password = password;
|
||||
setRemoteServer(server);
|
||||
}
|
||||
else
|
||||
{
|
||||
// setup user
|
||||
setDefaultRunAs("admin");
|
||||
}
|
||||
|
||||
setArgsAsHeaders(argsAsHeaders);
|
||||
setValidateResponse(validateResponse);
|
||||
|
||||
super.setUp();
|
||||
|
||||
@@ -120,7 +130,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
|
||||
service = abdera.parseService(new StringReader(xml), null);
|
||||
assertNotNull(service);
|
||||
Workspace workspace = service.getWorkspaces().get(0);
|
||||
Workspace workspace = getWorkspace(service);
|
||||
CMISRepositoryInfo repoInfo = workspace.getExtension(CMISConstants.REPOSITORY_INFO);
|
||||
assertNotNull(repoInfo);
|
||||
CMISCapabilities capabilities = repoInfo.getCapabilities();
|
||||
@@ -131,36 +141,55 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
return service;
|
||||
}
|
||||
|
||||
private IRI getRootCollection(Service service)
|
||||
private Workspace getWorkspace(Service service)
|
||||
{
|
||||
Collection root = service.getCollection("Main Repository", "root collection");
|
||||
return service.getWorkspaces().get(0);
|
||||
}
|
||||
|
||||
private Collection getCMISCollection(Workspace workspace, String collectionId)
|
||||
{
|
||||
List<Collection> collections = workspace.getCollections();
|
||||
for (Collection collection : collections)
|
||||
{
|
||||
String id = collection.getAttributeValue(CMISConstants.COLLECTION_TYPE);
|
||||
if (id != null && id.equals(collectionId))
|
||||
{
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private IRI getRootCollection(Workspace workspace)
|
||||
{
|
||||
Collection root = getCMISCollection(workspace, "root");
|
||||
assertNotNull(root);
|
||||
IRI rootHREF = root.getHref();
|
||||
assertNotNull(rootHREF);
|
||||
return rootHREF;
|
||||
}
|
||||
|
||||
private IRI getCheckedOutCollection(Service service)
|
||||
private IRI getCheckedOutCollection(Workspace workspace)
|
||||
{
|
||||
Collection root = service.getCollection("Main Repository", "checkedout collection");
|
||||
Collection root = getCMISCollection(workspace, "checkedout");
|
||||
assertNotNull(root);
|
||||
IRI rootHREF = root.getHref();
|
||||
assertNotNull(rootHREF);
|
||||
return rootHREF;
|
||||
}
|
||||
|
||||
private IRI getTypesCollection(Service service)
|
||||
private IRI getTypesCollection(Workspace workspace)
|
||||
{
|
||||
Collection root = service.getCollection("Main Repository", "type collection");
|
||||
Collection root = getCMISCollection(workspace, "types");
|
||||
assertNotNull(root);
|
||||
IRI rootHREF = root.getHref();
|
||||
assertNotNull(rootHREF);
|
||||
return rootHREF;
|
||||
}
|
||||
|
||||
private IRI getQueryCollection(Service service)
|
||||
private IRI getQueryCollection(Workspace workspace)
|
||||
{
|
||||
Collection root = service.getCollection("Main Repository", "query collection");
|
||||
Collection root = getCMISCollection(workspace, "query");
|
||||
assertNotNull(root);
|
||||
IRI rootHREF = root.getHref();
|
||||
assertNotNull(rootHREF);
|
||||
@@ -241,7 +270,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
if (testRunFolder == null)
|
||||
{
|
||||
Service service = getRepository();
|
||||
IRI rootFolderHREF = getRootCollection(service);
|
||||
IRI rootFolderHREF = getRootCollection(getWorkspace(service));
|
||||
testsFolder = createTestsFolder(rootFolderHREF);
|
||||
Link testsChildrenLink = testsFolder.getLink(CMISConstants.REL_CHILDREN);
|
||||
testRunFolder = createFolder(testsChildrenLink.getHref(), "Test Run " + System.currentTimeMillis());
|
||||
@@ -293,7 +322,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
public void testRepository()
|
||||
throws Exception
|
||||
{
|
||||
IRI rootHREF = getRootCollection(getRepository());
|
||||
IRI rootHREF = getRootCollection(getWorkspace(getRepository()));
|
||||
sendRequest(new GetRequest(rootHREF.toString()), 200, getAtomValidator());
|
||||
}
|
||||
|
||||
@@ -316,7 +345,22 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
Entry entry = feedFolderAfter.getEntry(document.getId().toString());
|
||||
assertNotNull(entry);
|
||||
}
|
||||
|
||||
|
||||
public void testCreateDocument2()
|
||||
throws Exception
|
||||
{
|
||||
Entry testFolder = createTestFolder("testCreateDocument2");
|
||||
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
|
||||
assertNotNull(childrenLink);
|
||||
String createFile = loadString("/cmis/rest/createdocument2.atomentry.xml");
|
||||
Response res = sendRequest(new PostRequest(childrenLink.getHref().toString(), createFile, Format.ATOM.mimetype()), 201, getAtomValidator());
|
||||
String xml = res.getContentAsString();
|
||||
Entry entry = abdera.parseEntry(new StringReader(xml), null);
|
||||
Response documentContentRes = sendRequest(new GetRequest(entry.getContentSrc().toString()), 200);
|
||||
String resContent = documentContentRes.getContentAsString();
|
||||
assertEquals("1", resContent);
|
||||
}
|
||||
|
||||
public void testCreateDocumentBase64()
|
||||
throws Exception
|
||||
{
|
||||
@@ -400,7 +444,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
assertNotNull(documentRes);
|
||||
String documentXML = documentRes.getContentAsString();
|
||||
assertNotNull(documentXML);
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getRepository());
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository()));
|
||||
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
|
||||
assertNotNull(pwcRes);
|
||||
Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
|
||||
@@ -529,7 +573,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
assertNotNull(parentsToRoot.getEntries().get(1).getLink(CMISConstants.REL_PARENT));
|
||||
assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId());
|
||||
assertNotNull(parentsToRoot.getEntries().get(2).getLink(CMISConstants.REL_PARENT));
|
||||
Feed root = getFeed(getRootCollection(getRepository()));
|
||||
Feed root = getFeed(getRootCollection(getWorkspace(getRepository())));
|
||||
assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId());
|
||||
assertNull(parentsToRoot.getEntries().get(3).getLink(CMISConstants.REL_PARENT));
|
||||
}
|
||||
@@ -563,7 +607,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
assertNotNull(parentsToRoot.getEntries().get(1).getLink(CMISConstants.REL_PARENT));
|
||||
assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId());
|
||||
assertNotNull(parentsToRoot.getEntries().get(2).getLink(CMISConstants.REL_PARENT));
|
||||
Feed root = getFeed(getRootCollection(getRepository()));
|
||||
Feed root = getFeed(getRootCollection(getWorkspace(getRepository())));
|
||||
assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId());
|
||||
assertNull(parentsToRoot.getEntries().get(3).getLink(CMISConstants.REL_PARENT));
|
||||
}
|
||||
@@ -640,7 +684,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
// retrieve checkouts within scope of test checkout folder
|
||||
Service repository = getRepository();
|
||||
assertNotNull(repository);
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getRepository());
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository()));
|
||||
Map<String, String> args = new HashMap<String, String>();
|
||||
args.put("folderId", scopeId);
|
||||
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
|
||||
@@ -664,7 +708,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
assertNotNull(documentXML);
|
||||
|
||||
// checkout
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getRepository());
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository()));
|
||||
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
|
||||
assertNotNull(pwcRes);
|
||||
String pwcXml = pwcRes.getContentAsString();
|
||||
@@ -703,7 +747,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
assertNotNull(xml);
|
||||
|
||||
// checkout
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getRepository());
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository()));
|
||||
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
|
||||
assertNotNull(pwcRes);
|
||||
String pwcXml = pwcRes.getContentAsString();
|
||||
@@ -748,7 +792,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
assertNotNull(xml);
|
||||
|
||||
// checkout
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getRepository());
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository()));
|
||||
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
|
||||
assertNotNull(pwcRes);
|
||||
Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
|
||||
@@ -841,7 +885,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
assertNotNull(xml);
|
||||
|
||||
// checkout
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getRepository());
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository()));
|
||||
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
|
||||
assertNotNull(pwcRes);
|
||||
Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
|
||||
@@ -903,7 +947,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
String xml = documentRes.getContentAsString();
|
||||
assertNotNull(xml);
|
||||
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getRepository());
|
||||
IRI checkedoutHREF = getCheckedOutCollection(getWorkspace(getRepository()));
|
||||
for (int i = 0; i < NUMBER_OF_VERSIONS; i++)
|
||||
{
|
||||
// checkout
|
||||
@@ -948,7 +992,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
public void testGetAllTypeDefinitions()
|
||||
throws Exception
|
||||
{
|
||||
IRI typesHREF = getTypesCollection(getRepository());
|
||||
IRI typesHREF = getTypesCollection(getWorkspace(getRepository()));
|
||||
Feed types = getFeed(typesHREF);
|
||||
assertNotNull(types);
|
||||
Feed typesWithProps = getFeed(typesHREF);
|
||||
@@ -966,7 +1010,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
public void testGetHierarchyTypeDefinitions()
|
||||
throws Exception
|
||||
{
|
||||
IRI typesHREF = getTypesCollection(getRepository());
|
||||
IRI typesHREF = getTypesCollection(getWorkspace(getRepository()));
|
||||
Map<String, String> args = new HashMap<String, String>();
|
||||
args.put("type", "FOLDER_OBJECT_TYPE");
|
||||
args.put("includePropertyDefinitions", "true");
|
||||
@@ -1027,14 +1071,14 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
throws Exception
|
||||
{
|
||||
// retrieve query collection
|
||||
IRI queryHREF = getQueryCollection(getRepository());
|
||||
IRI queryHREF = getQueryCollection(getWorkspace(getRepository()));
|
||||
|
||||
// retrieve test folder for query
|
||||
Entry testFolder = createTestFolder("testQuery");
|
||||
CMISProperties testFolderProps = testFolder.getExtension(CMISConstants.PROPERTIES);
|
||||
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
|
||||
|
||||
// create documents query
|
||||
// create documents to query
|
||||
Entry document1 = createDocument(childrenLink.getHref(), "apple1");
|
||||
assertNotNull(document1);
|
||||
CMISProperties document1Props = document1.getExtension(CMISConstants.PROPERTIES);
|
||||
@@ -1046,20 +1090,22 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
assertNotNull(document2Props);
|
||||
Entry document3 = createDocument(childrenLink.getHref(), "banana1");
|
||||
assertNotNull(document3);
|
||||
|
||||
// TODO: query based on query capabilities
|
||||
|
||||
// retrieve query request document
|
||||
String queryDoc = loadString("/cmis/rest/query.cmissqlquery.xml");
|
||||
|
||||
// TODO: Enable XSD Validation when cmis:propertyXXX mapping is sorted in spec
|
||||
|
||||
{
|
||||
// construct structured query
|
||||
String query = "SELECT OBJECT_ID, OBJECT_TYPE_ID, NAME FROM DOCUMENT_OBJECT_TYPE " +
|
||||
String query = "SELECT * FROM DOCUMENT_OBJECT_TYPE " +
|
||||
"WHERE IN_FOLDER('" + testFolderProps.getObjectId() + "') " +
|
||||
"AND NAME = 'apple1'";
|
||||
String queryReq = queryDoc.replace("${STATEMENT}", query);
|
||||
queryReq = queryReq.replace("${PAGESIZE}", "5");
|
||||
|
||||
// issue structured query
|
||||
Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), "application/cmisrequest+xml;type=query"), 200, getAtomValidator());
|
||||
Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), "application/cmisrequest+xml;type=query"), 200);
|
||||
assertNotNull(queryRes);
|
||||
Feed queryFeed = abdera.parseFeed(new StringReader(queryRes.getContentAsString()), null);
|
||||
assertNotNull(queryFeed);
|
||||
@@ -1080,7 +1126,7 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
queryReq = queryReq.replace("${PAGESIZE}", "5");
|
||||
|
||||
// issue fulltext query
|
||||
Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), "application/cmisrequest+xml;type=query"), 200, getAtomValidator());
|
||||
Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), "application/cmisrequest+xml;type=query"), 200);
|
||||
assertNotNull(queryRes);
|
||||
Feed queryFeed = abdera.parseFeed(new StringReader(queryRes.getContentAsString()), null);
|
||||
assertNotNull(queryFeed);
|
||||
@@ -1097,13 +1143,13 @@ public class CMISTest extends BaseCMISWebScriptTest
|
||||
// construct fulltext and structured query
|
||||
String query = "SELECT OBJECT_ID, OBJECT_TYPE_ID, NAME FROM DOCUMENT_OBJECT_TYPE " +
|
||||
"WHERE IN_FOLDER('" + testFolderProps.getObjectId() + "') " +
|
||||
"AND NAME = 'apple1'" +
|
||||
"AND NAME = 'apple1' " +
|
||||
"AND CONTAINS('test content')";
|
||||
String queryReq = queryDoc.replace("${STATEMENT}", query);
|
||||
queryReq = queryReq.replace("${PAGESIZE}", "5");
|
||||
|
||||
// issue structured query
|
||||
Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), "application/cmisrequest+xml;type=query"), 200, getAtomValidator());
|
||||
Response queryRes = sendRequest(new PostRequest(queryHREF.toString(), queryReq.getBytes(), "application/cmisrequest+xml;type=query"), 200);
|
||||
assertNotNull(queryRes);
|
||||
Feed queryFeed = abdera.parseFeed(new StringReader(queryRes.getContentAsString()), null);
|
||||
assertNotNull(queryFeed);
|
||||
|
@@ -35,29 +35,6 @@ import junit.textui.TestRunner;
|
||||
*/
|
||||
public class TestRemoteCMIS extends CMISTest
|
||||
{
|
||||
// remote CMIS server
|
||||
private static String repositoryUrl = "http://localhost:8080/alfresco/service/api/repository";
|
||||
private static String username = "admin";
|
||||
private static String password = "admin";
|
||||
private static boolean argsAsHeaders = false;
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
if (repositoryUrl != null)
|
||||
{
|
||||
setRepositoryUrl(repositoryUrl);
|
||||
RemoteServer server = new RemoteServer();
|
||||
server.username = username;
|
||||
server.password = password;
|
||||
setRemoteServer(server);
|
||||
}
|
||||
|
||||
setArgsAsHeaders(argsAsHeaders);
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute Unit Tests as client to remote CMIS Server
|
||||
@@ -70,6 +47,8 @@ public class TestRemoteCMIS extends CMISTest
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
remote = true;
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
repositoryUrl = args[0];
|
||||
@@ -88,7 +67,7 @@ public class TestRemoteCMIS extends CMISTest
|
||||
String params = "both";
|
||||
if (args.length > 2)
|
||||
{
|
||||
String[] paramSegment = args[1].split("=");
|
||||
String[] paramSegment = args[2].split("=");
|
||||
if (paramSegment[0].equalsIgnoreCase("params"))
|
||||
{
|
||||
params = paramSegment[1].toLowerCase();
|
||||
|
@@ -1,57 +0,0 @@
|
||||
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.dictionary.CMISMapping;
|
||||
|
||||
/**
|
||||
* Mappings of CMIS properties to names in response
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
*
|
||||
*/
|
||||
public class CMISPropNamesMapping
|
||||
{
|
||||
private static Map<String, String> cmisPropertiesNamesMapping = new HashMap<String, String>();
|
||||
|
||||
static
|
||||
{
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_IS_IMMUTABLE, "isImmutable");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_IS_LATEST_VERSION, "isLatestVersion");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_IS_MAJOR_VERSION, "isMajorVersion");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_IS_LATEST_MAJOR_VERSION, "isLatestMajorVersion");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_SERIES_IS_CHECKED_OUT, "versionSeriesIsCheckedOut");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_CREATION_DATE, "creationDate");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_LAST_MODIFICATION_DATE, "lastModificationDate");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_OBJECT_ID, "objectID");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_SERIES_ID, "versionSeriesID");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_ID, "versionSeriesCheckedOutID");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_LENGTH, "contentStreamLength");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_NAME, "name");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_OBJECT_TYPE_ID, "objectTypeID");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_CREATED_BY, "createdBy");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_LAST_MODIFIED_BY, "lastModifiedBy");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_MIME_TYPE, "contentStreamMimeType");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_FILENAME, "contentStreamFileName");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_LABEL, "versionLabel");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_BY, "versionSeriesCheckedOutBy");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_CHECKIN_COMMENT, "checkinComment");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_CONTENT_STREAM_URI, "contentStreamURI");
|
||||
cmisPropertiesNamesMapping.put(CMISMapping.PROP_PARENT, "parent");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get property name in response
|
||||
*
|
||||
* @param internalName internal property name
|
||||
* @return property name in response
|
||||
*/
|
||||
public static String getResponsePropertyName(String internalName)
|
||||
{
|
||||
//return cmisPropertiesNamesMapping.get(internalName);
|
||||
return internalName;
|
||||
}
|
||||
|
||||
}
|
@@ -36,6 +36,7 @@ import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import org.alfresco.cmis.CMISService;
|
||||
import org.alfresco.cmis.dictionary.CMISDictionaryService;
|
||||
import org.alfresco.cmis.dictionary.CMISMapping;
|
||||
import org.alfresco.cmis.property.CMISPropertyNameMapping;
|
||||
import org.alfresco.cmis.property.CMISPropertyService;
|
||||
import org.alfresco.cmis.search.CMISQueryService;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
@@ -107,7 +108,7 @@ public class DMAbstractServicePort
|
||||
if (filter.allow(name) && value != null)
|
||||
{
|
||||
PropertyBooleanType propBoolean = new PropertyBooleanType();
|
||||
propBoolean.setName(CMISPropNamesMapping.getResponsePropertyName(name));
|
||||
propBoolean.setName(CMISPropertyNameMapping.getWebServiceName(name));
|
||||
propBoolean.setValue((Boolean) value);
|
||||
properties.getPropertyBoolean().add(propBoolean);
|
||||
}
|
||||
@@ -119,7 +120,7 @@ public class DMAbstractServicePort
|
||||
if (filter.allow(name) && value != null)
|
||||
{
|
||||
PropertyDateTimeType propDateTime = new PropertyDateTimeType();
|
||||
propDateTime.setName(CMISPropNamesMapping.getResponsePropertyName(name));
|
||||
propDateTime.setName(CMISPropertyNameMapping.getWebServiceName(name));
|
||||
propDateTime.setValue(convert((Date) value));
|
||||
properties.getPropertyDateTime().add(propDateTime);
|
||||
}
|
||||
@@ -131,7 +132,7 @@ public class DMAbstractServicePort
|
||||
if (filter.allow(name) && value != null)
|
||||
{
|
||||
PropertyIDType propID = new PropertyIDType();
|
||||
propID.setName(CMISPropNamesMapping.getResponsePropertyName(name));
|
||||
propID.setName(CMISPropertyNameMapping.getWebServiceName(name));
|
||||
propID.setValue(value.toString());
|
||||
properties.getPropertyID().add(propID);
|
||||
}
|
||||
@@ -143,7 +144,7 @@ public class DMAbstractServicePort
|
||||
if (filter.allow(name) && value != null)
|
||||
{
|
||||
PropertyIntegerType propInteger = new PropertyIntegerType();
|
||||
propInteger.setName(CMISPropNamesMapping.getResponsePropertyName(name));
|
||||
propInteger.setName(CMISPropertyNameMapping.getWebServiceName(name));
|
||||
propInteger.setValue(BigInteger.valueOf((Long) value));
|
||||
properties.getPropertyInteger().add(propInteger);
|
||||
}
|
||||
@@ -155,7 +156,7 @@ public class DMAbstractServicePort
|
||||
if (filter.allow(name) && value != null)
|
||||
{
|
||||
PropertyStringType propString = new PropertyStringType();
|
||||
propString.setName(CMISPropNamesMapping.getResponsePropertyName(name));
|
||||
propString.setName(CMISPropertyNameMapping.getWebServiceName(name));
|
||||
propString.setValue(value.toString());
|
||||
properties.getPropertyString().add(propString);
|
||||
}
|
||||
@@ -178,7 +179,7 @@ public class DMAbstractServicePort
|
||||
if (filter.allow(name) && value != null)
|
||||
{
|
||||
PropertyURIType propString = new PropertyURIType();
|
||||
propString.setName(CMISPropNamesMapping.getResponsePropertyName(name));
|
||||
propString.setName(CMISPropertyNameMapping.getWebServiceName(name));
|
||||
propString.setValue(value.toString());
|
||||
properties.getPropertyURI().add(propString);
|
||||
}
|
||||
|
@@ -205,7 +205,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
objectTypeDefinitionType.setObjectTypeID(typeDefinition.getObjectTypeId().getTypeId());
|
||||
objectTypeDefinitionType.setObjectTypeQueryName(typeDefinition.getObjectTypeQueryName());
|
||||
objectTypeDefinitionType.setObjectTypeDisplayName(typeDefinition.getObjectTypeDisplayName());
|
||||
objectTypeDefinitionType.setParentTypeID(typeDefinition.getParentTypeId().getTypeId());
|
||||
objectTypeDefinitionType.setParentTypeID(typeDefinition.getParentTypeId() == null ? null : typeDefinition.getParentTypeId().getTypeId());
|
||||
objectTypeDefinitionType.setRootTypeQueryName(typeDefinition.getRootTypeQueryName());
|
||||
objectTypeDefinitionType.setDescription(typeDefinition.getDescription());
|
||||
objectTypeDefinitionType.setCreatable(typeDefinition.isCreatable());
|
||||
|
@@ -43,6 +43,9 @@ public interface CMISConstants
|
||||
{
|
||||
public static final String CMIS_200805_NS = "http://www.cmis.org/2008/05";
|
||||
|
||||
// CMIS Service Document
|
||||
public static final QName COLLECTION_TYPE = new QName(CMIS_200805_NS, "collectionType");
|
||||
|
||||
// CMIS Repository Info
|
||||
public static final QName REPOSITORY_INFO = new QName(CMIS_200805_NS, "repositoryInfo");
|
||||
public static final QName REPOSITORY_ID = new QName(CMIS_200805_NS, "repositoryId");
|
||||
|
Reference in New Issue
Block a user