No document parents with OpenCMIS and /alfresco/cmisatom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2012 02:57 PM
I am using OpenCMIS 0.6.0 and Alfresco 4.0.0.
I have been using the /alfresco/service/cmis Atom service, but I have come to understand that is deprecated and I should be using /alfresco/cmisatom instead. When I switched to cmisatom, now my Document objects are suddenly not returning any parents. I wrote a simple test to demonstrate this:
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()); } }}
Using the old CMIS service URL results in the following output:
ATOMPUB_URL = http://alfserver:8080/alfresco/service/cmisFound document: workspace://SpacesStore/a8d4729e-c060-4a59-bdfd-480313d2f9a9Found 1 parents workspace://SpacesStore/74e2dd7c-c71e-4f33-ab07-f0c1209c388d
Changing nothing but the service URL results in the following output:
ATOMPUB_URL = http://alfserver:8080/alfresco/cmisatomFound document: workspace://SpacesStore/a8d4729e-c060-4a59-bdfd-480313d2f9a9;1.0Found 0 parents
Has anyone else experienced this problem? What am I doing wrong?
Thanks in advance for your help!
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2012 05:44 PM
Found document: workspace://SpacesStore/89af08c8-499e-4010-983a-7746f7d418dbFound 1 parents workspace://SpacesStore/9853f8c5-b1bb-4bb1-bca7-3f0999033469
I also tested the getObjectParents() call in cmislib against Alfresco and it too was successful.What specific version of Alfresco are you testing against? I ran your code against 4.0.d Community, WAR-only, Lucene.
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2012 05:49 PM
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2012 08:45 AM
I don't know what could possibly be the problem. I will see if we can update to the latest Community version.
Thanks for looking into it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2012 12:12 PM
Let's see if we can fine-tune this test a bit…
- How did you create your test document (via CMIS or the UI)? I created mine via Share as admin.
- Is it an instance of a custom type or just cm:content? My test doc is an instance of cm:content (cmis:document).
- Where in the repo does it live? Mine lives in Company Home/test
- When you run your OpenCMIS code, are you running as admin or some other user? I'm running as admin.
- If you are running as some other user, how are the permissions set in the test folder and that folder's ancestor folders? My test folder has no local permissions set and inherits permissions from Company Home, which are standard, OOTB permissions.
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2012 02:09 PM
In the meantime, I will try to answer your questions. Before I get to that though, I updated and re-ran my test.
Full test code:
@Testpublic 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;}
Results from this test:
ATOMPUB_URL = http://alfserver:8080/alfresco/cmisatomSearching 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.txtFound 0 parentsSearching 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/cmisSearching 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 2012Found 1 parents workspace://SpacesStore/1c0830d3-3c4e-4c9d-be98-fc2400dc91a2Searching 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 2012Found 1 parents workspace://SpacesStore/1c0830d3-3c4e-4c9d-be98-fc2400dc91a2
I am now testing against two files. The first one was added via CMIS, the second one was added via Alfresco Share. It's interesting to note that the file added via Share fails completely when using the /alfresco/cmisatom service. That might have to do with our Solr installation problem?
Anyway, the answers to your questions:
- How did you create your test document (via CMIS or the UI)?
- Both
- Is it an instance of a custom type or just cm:content?
- I have not created a custom type, so I assume it is just cm:content.
- Where in the repo does it live?
- It's in Company Home/Sites/roiweb-file-share
- When you run your OpenCMIS code, are you running as admin or some other user?
- I am using a service account user.
- If you are running as some other user, how are the permissions set in the test folder and that folder's ancestor folders?
- The service account is a member of a group that has "Site Manager" rights to the repository root. All sub-folders inhert permissions from Company Home/Sites/roiweb-file-share
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2012 03:04 PM
In your first test, you appear to be retrieving an object that has been versioned, and the object you are getting back is not the latest version as evidenced by isLatestMajorVersion being set to False.
In the later test, you are grabbing the same object, but you are getting version 8.0 back.
The reason this is happening is because when you are calling getObject with a series ID, not a CMIS object ID. The CMIS object ID will have a version label appended to it, which you can see in your property dump.
I doubt that versioned objects are able to find their parent which is why you are getting no result back.
Try adding this piece of code immediately after your cast of obj to doc:
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.Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2012 03:23 PM
Anyway, that seems to have fixed the problem. Now the test results are inverted such that /alfresco/service/cmis is no longer working, but I guess that's not an issue since it is deprecated anyway.
Do you have any idea why I'm getting an error when trying to retrieve the document added via Share? Is that related to this problem, or something else entirely?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2012 05:31 PM
If you are trying to get Solr to work and you haven't been successful, I suppose that might be a clue. But if you still have Lucene set as your search engine that probably isn't the cause.
Does it fail for every document added via Share, regardless of site, folder path, or user?
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2012 11:11 AM
I have similar problem. I've switched from use http://localhost:8080/alfresco/service/cmis to http://localhost:8080/alfresco/cmisatom cause i've problems sending huge files to Alfresco (>150 Mb). I start by saying that i've created one tenant with (user,userpass), using tenant console, and i have to manipulate object into tenant!!!
When i was using first url this code worked:
Map<String, String> parameter = new HashMap<String, String>();// user credentialsparameter.put(SessionParameter.USER, "user");parameter.put(SessionParameter.PASSWORD, "userpass");// connection settingsparameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/service/cmis");parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());// set the alfresco object factoryparameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");// create sessionSessionFactory factory = SessionFactoryImpl.newInstance();Session session = factory.getRepositories(parameter).get(0).createSession();Folder parent = session.getRootFolder();
Now i've changed only
parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/cmisatom");
And
Folder parent = session.getRootFolder();
throws
org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: Object Info is missing!
I think that there are some problems with permission because if login with (admin,admin) i can retrive rootFolder and navigate its childern.
Hints?
Regards and Thank u
