04-09-2012 02:57 PM
public void testDocParents() {
CmisObject obj = getSession().getObject("workspace://SpacesStore/a8d4729e-c060-4a59-bdfd-480313d2f9a9");
if(obj instanceof Document) {
Document doc = (Document)obj;
System.out.println("Found document: "+doc.getId());
List<Folder> parents = doc.getParents();
System.out.println("Found "+parents.size()+" parents");
for(Folder folder : parents) {
System.out.println("\t"+folder.getId());
}
}
}
ATOMPUB_URL = http://alfserver:8080/alfresco/service/cmis
Found document: workspace://SpacesStore/a8d4729e-c060-4a59-bdfd-480313d2f9a9
Found 1 parents
workspace://SpacesStore/74e2dd7c-c71e-4f33-ab07-f0c1209c388d
ATOMPUB_URL = http://alfserver:8080/alfresco/cmisatom
Found document: workspace://SpacesStore/a8d4729e-c060-4a59-bdfd-480313d2f9a9;1.0
Found 0 parents
04-09-2012 05:44 PM
Found document: workspace://SpacesStore/89af08c8-499e-4010-983a-7746f7d418db
Found 1 parents
workspace://SpacesStore/9853f8c5-b1bb-4bb1-bca7-3f0999033469
I also tested the getObjectParents() call in cmislib against Alfresco and it too was successful.04-09-2012 05:49 PM
04-10-2012 08:45 AM
04-10-2012 12:12 PM
04-10-2012 02:09 PM
@Test
public void testDocParents() {
Session session = getSession("http://alfserver:8080/alfresco/cmisatom");
// Test file added via CMIS
testGetParents(session, "workspace://SpacesStore/ce05803c-858f-43bb-bedf-8df0849a79f9");
// Test file added via Alfresco Share
testGetParents(session, "workspace://SpacesStore/f6d3c572-30ae-4755-9944-71ca25331620");
session = getSession("http://alfserver:8080/alfresco/service/cmis");
// Test file added via CMIS
testGetParents(session, "workspace://SpacesStore/ce05803c-858f-43bb-bedf-8df0849a79f9");
// Test file added via Alfresco Share
testGetParents(session, "workspace://SpacesStore/f6d3c572-30ae-4755-9944-71ca25331620");
}
private void testGetParents(Session session, String objectId) {
try {
System.out.println("Searching for document: "+objectId);
CmisObject obj = session.getObject(objectId);
if(obj instanceof Document) {
Document doc = (Document)obj;
printProps(doc);
List<Folder> parents = doc.getParents();
System.out.println("Found "+parents.size()+" parents");
for(Folder folder : parents) {
System.out.println("\t"+folder.getId());
}
}
} catch(CmisRuntimeException e) {
//e.printStackTrace();
System.out.println(e.getErrorContent());
}
System.out.println();
}
private void printProps(CmisObject obj) {
List<Property<?>> props = obj.getProperties();
for(Property<?> property : props) {
System.out.println("\t"+property.getId()+" = "+property.getValueAsString());
}
}
private Session getSession(String connectionString) {
Session session = null;
// default factory implementation
SessionFactory factory = SessionFactoryImpl.newInstance();
Map<String, String> parameters = new HashMap<String, String>();
// user credentials
parameters.put(SessionParameter.USER, alfrescoUser);
parameters.put(SessionParameter.PASSWORD, alfrescoPassword);
// connection settings
System.out.println("ATOMPUB_URL = "+connectionString);
parameters.put(SessionParameter.ATOMPUB_URL, connectionString);
parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// get repositories
long start = System.currentTimeMillis();
List<Repository> repositories = factory.getRepositories(parameters);
session = repositories.get(0).createSession();
session.getDefaultContext().setCacheEnabled(false);
return session;
}
ATOMPUB_URL = http://alfserver:8080/alfresco/cmisatom
Searching for document: workspace://SpacesStore/ce05803c-858f-43bb-bedf-8df0849a79f9
cmis:isLatestMajorVersion = false
cmis:contentStreamLength = 44
cmis:contentStreamId = store://2012/4/9/20/39/d31a2ff0-ca9d-4e1c-a400-0fd059319a21.bin
cmis:objectTypeId = cmis:document
cmis:versionSeriesCheckedOutBy = null
cmis:versionSeriesCheckedOutId = null
cmis:name = Test Text Document.txt
cmis:contentStreamMimeType = text/plain
cmis:versionSeriesId = workspace://SpacesStore/ce05803c-858f-43bb-bedf-8df0849a79f9
cmis:creationDate = Mon Apr 09 08:25:34 CDT 2012
cmis:changeToken = null
cmis:versionLabel = 1.0
cmis:isLatestVersion = true
cmis:isVersionSeriesCheckedOut = false
cmis:lastModifiedBy = svcROIWeb
cmis:createdBy = svcROIWeb
cmis:checkinComment = Initial Version
cmis:objectId = workspace://SpacesStore/ce05803c-858f-43bb-bedf-8df0849a79f9;1.0
cmis:isMajorVersion = true
cmis:isImmutable = false
alfcmis:nodeRef = workspace://SpacesStore/ce05803c-858f-43bb-bedf-8df0849a79f9
cmis:baseTypeId = cmis:document
cmis:lastModificationDate = Mon Apr 09 20:39:06 CDT 2012
cmis:contentStreamFileName = Test Text Document.txt
Found 0 parents
Searching for document: workspace://SpacesStore/f6d3c572-30ae-4755-9944-71ca25331620
<html><head><title>Apache Tomcat/6.0.26 - Error report</title><style><!–H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}–></style> </head><body><h1>HTTP Status 500 - Object Info not found for: workspace://SpacesStore/f6d3c572-30ae-4755-9944-71ca25331620;1.0</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Object Info not found for: workspace://SpacesStore/f6d3c572-30ae-4755-9944-71ca25331620;1.0</u></p><p><b>description</b> <u>The server encountered an internal error (Object Info not found for: workspace://SpacesStore/f6d3c572-30ae-4755-9944-71ca25331620;1.0) that prevented it from fulfilling this request.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.26</h3></body></html>
ATOMPUB_URL = http://alfserver:8080/alfresco/service/cmis
Searching for document: workspace://SpacesStore/ce05803c-858f-43bb-bedf-8df0849a79f9
cmis:isLatestMajorVersion = true
cmis:contentStreamLength = 44
cmis:contentStreamId = store://2012/4/9/20/39/d31a2ff0-ca9d-4e1c-a400-0fd059319a21.bin
cmis:versionSeriesCheckedOutBy = null
cmis:objectTypeId = cmis:document
cmis:versionSeriesCheckedOutId = null
cmis:name = Test Text Document.txt
cmis:contentStreamMimeType = text/plain
cmis:versionSeriesId = workspace://SpacesStore/ce05803c-858f-43bb-bedf-8df0849a79f9
cmis:creationDate = Mon Apr 09 08:25:34 CDT 2012
cmis:changeToken = null
cmis:versionLabel = 8.0
cmis:isLatestVersion = true
cmis:isVersionSeriesCheckedOut = false
cmis:lastModifiedBy = svcROIWeb
cmis:createdBy = svcROIWeb
cmis:checkinComment = Checked in via ROiWeb Portal by Lukas VanNoord
cmis:objectId = workspace://SpacesStore/ce05803c-858f-43bb-bedf-8df0849a79f9
cmis:isImmutable = false
cmis:isMajorVersion = true
cmis:baseTypeId = cmis:document
alfcmis:nodeRef = null
cmis:contentStreamFileName = Test Text Document.txt
cmis:lastModificationDate = Mon Apr 09 20:39:06 CDT 2012
Found 1 parents
workspace://SpacesStore/1c0830d3-3c4e-4c9d-be98-fc2400dc91a2
Searching for document: workspace://SpacesStore/f6d3c572-30ae-4755-9944-71ca25331620
cmis:isLatestMajorVersion = false
cmis:contentStreamLength = 43
cmis:contentStreamId = store://2012/4/10/12/25/5c3dbdc1-5e1f-4387-aaad-5c5d129a3433.bin
cmis:versionSeriesCheckedOutBy = null
cmis:objectTypeId = cmis:document
cmis:versionSeriesCheckedOutId = null
cmis:name = Test Share Document.txt
cmis:contentStreamMimeType = text/plain
cmis:versionSeriesId = workspace://SpacesStore/f6d3c572-30ae-4755-9944-71ca25331620
cmis:creationDate = Tue Apr 10 12:25:40 CDT 2012
cmis:changeToken = null
cmis:versionLabel = 0.1
cmis:isLatestVersion = true
cmis:isVersionSeriesCheckedOut = false
cmis:lastModifiedBy = svcROIWeb
cmis:createdBy = svcROIWeb
cmis:checkinComment = null
cmis:objectId = workspace://SpacesStore/f6d3c572-30ae-4755-9944-71ca25331620
cmis:isImmutable = false
cmis:isMajorVersion = false
cmis:baseTypeId = cmis:document
alfcmis:nodeRef = null
cmis:contentStreamFileName = Test Share Document.txt
cmis:lastModificationDate = Tue Apr 10 12:25:40 CDT 2012
Found 1 parents
workspace://SpacesStore/1c0830d3-3c4e-4c9d-be98-fc2400dc91a2
04-10-2012 03:04 PM
doc = doc.getObjectOfLatestVersion(false);
This will make sure you get the latest version of the object and that version should be able to give you its parent.04-10-2012 03:23 PM
04-10-2012 05:31 PM
09-12-2012 11:11 AM
Map<String, String> parameter = new HashMap<String, String>();
// user credentials
parameter.put(SessionParameter.USER, "user");
parameter.put(SessionParameter.PASSWORD, "userpass");
// connection settings
parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/service/cmis");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// set the alfresco object factory
parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
// create session
SessionFactory factory = SessionFactoryImpl.newInstance();
Session session = factory.getRepositories(parameter).get(0).createSession();
Folder parent = session.getRootFolder();
parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/cmisatom");
Folder parent = session.getRootFolder();
org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: Object Info is missing!
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.