cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot create a folder via CMIS/REST;

bnmaxim
Champ in-the-making
Champ in-the-making
Hi everyone,

I'm facing a really awkward situation here. I'm trying to create a Folder in Alfresco 3.1.1 EE via CMIS but an empty document gets created instead.

In order to see exactly where the problem lies, I've output the contents of the Get Request, before it gets fired against Alfresco. I also printed Alfresco's response and I'm absolutely baffled by the dissimilarities between the two.

Here's my request:


<?xml version="1.0" encoding="utf-8"?>                                                                                                                                                                  
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901">                                                                            
    <title>ReallyMyFOLDER1253535827322</title>                                                                                                                                     
    <summary>ReallyMyFOLDER1253535827322 (summary)</summary>                                                                                                                       
    <cmis:object>                                                                                                                                                                  
        <cmis:properties>                                                                                                                                                          
                <cmis:propertyString cmis:name="ObjectTypeId"><cmis:value>folder</cmis:value></cmis:propertyString>                                                                
                </cmis:properties>                                                                                                                                                 
    </cmis:object>                                                                                                                                                                 
                                                                                                                                                                                   
</entry>                                                                                                                                                                           


And here is what Alfresco says it created:


<?xml version="1.0" encoding="UTF-8"?>                                            
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:cmis="http://www.cmis.org/2008/05" xmlns:alf="http://www.alfresco.org">                    
<author><name>admin</name></author>                                                                                                                                                
<content type="application/octet-stream" src="http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/e42dea28-e2cb-4037-9f59-0839c1...><id>urn:uuid:e42dea28-e2cb-4037-9f59-0839c18794a4</id>                                                                                                                  
<link rel="self" href="http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/e42dea28-e2cb-4037-9f59-0839c1...>                                               
<link rel="enclosure" type="application/octet-stream" href="http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/e42dea28-e2cb-4037-9f59-0839c1...><link rel="edit" href="http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/e42dea28-e2cb-4037-9f59-0839c1...>                      
<link rel="edit-media" type="application/octet-stream" href="http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/e42dea28-e2cb-4037-9f59-0839c1...><link rel="cmis-allowableactions" href="http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/e42dea28-e2cb-4037-9f59-0839c1...>                                                                                                                                                                            
<link rel="cmis-relationships" href="http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/e42dea28-e2cb-4037-9f59-0839c1...>                    
<link rel="cmis-parents" href="http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/e42dea28-e2cb-4037-9f59-0839c1...>                               
<link rel="cmis-allversions" href="http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/e42dea28-e2cb-4037-9f59-0839c1...>                          
<link rel="cmis-stream" type="application/octet-stream" href="http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/e42dea28-e2cb-4037-9f59-0839c1...><link rel="cmis-type" href="http://localhost:8080/alfresco/service/api/type/document'/>                                                                 
<link rel="cmis-repository" href="http://localhost:8080/alfresco/service/api/repository'/>                                                                                         
<published>2009-09-21T12:23:47.836Z</published>                                                                                                                                    
<summary>ReallyMyFOLDER1253535827322 (summary)</summary>                                                                                                                           
<title>ReallyMyFOLDER1253535827322</title>                                                                                                                                         
<updated>2009-09-21T12:23:48.061Z</updated>                                                                                                                                        
<cmis:object>                                                                                                                                                                      
<cmis:properties>                                                                                                                                                                  
<cmis:propertyId cmis:name="ObjectId"><cmis:value>workspace://SpacesStore/e42dea28-e2cb-4037-9f59-0839c18794a4</cmis:value></cmis:propertyId>                                      
<cmis:propertyString cmis:name="BaseType"><cmis:value>document</cmis:value></cmis:propertyString>                                                                                  
<cmis:propertyString cmis:name="ObjectTypeId"><cmis:value>document</cmis:value></cmis:propertyString>                                                                              
<cmis:propertyString cmis:name="CreatedBy"><cmis:value>admin</cmis:value></cmis:propertyString>                                                                                    
<cmis:propertyDateTime cmis:name="CreationDate"><cmis:value>2009-09-21T12:23:47.836Z</cmis:value></cmis:propertyDateTime>                                                          
<cmis:propertyString cmis:name="LastModifiedBy"><cmis:value>admin</cmis:value></cmis:propertyString>                                                                               
<cmis:propertyDateTime cmis:name="LastModificationDate"><cmis:value>2009-09-21T12:23:48.061Z</cmis:value></cmis:propertyDateTime>                                                  
<cmis:propertyString cmis:name="Name"><cmis:value>ReallyMyFOLDER1253535827322</cmis:value></cmis:propertyString>                                                                   
<cmis:propertyBoolean cmis:name="IsImmutable"><cmis:value>false</cmis:value></cmis:propertyBoolean>                                                                                
<cmis:propertyBoolean cmis:name="IsLatestVersion"><cmis:value>true</cmis:value></cmis:propertyBoolean>                                                                             
<cmis:propertyBoolean cmis:name="IsMajorVersion"><cmis:value>false</cmis:value></cmis:propertyBoolean>                                                                             
<cmis:propertyBoolean cmis:name="IsLatestMajorVersion"><cmis:value>false</cmis:value></cmis:propertyBoolean>                                                                       
<cmis:propertyString cmis:name="VersionLabel"/>                                                                                                                                    
<cmis:propertyId cmis:name="VersionSeriesId"><cmis:value>workspace://SpacesStore/e42dea28-e2cb-4037-9f59-0839c18794a4</cmis:value></cmis:propertyId>                               
<cmis:propertyBoolean cmis:name="IsVersionSeriesCheckedOut"><cmis:value>false</cmis:value></cmis:propertyBoolean>                                                                  
<cmis:propertyString cmis:name="VersionSeriesCheckedOutBy"/>                                                                                                                       
<cmis:propertyId cmis:name="VersionSeriesCheckedOutId"/>                                                                                                                           
<cmis:propertyString cmis:name="CheckinComment"/>                                                                                                                                  
<cmis:propertyInteger cmis:name="ContentStreamLength"><cmis:value>0</cmis:value></cmis:propertyInteger>                                                                            
<cmis:propertyString cmis:name="ContentStreamMimeType"><cmis:value>application/octet-stream</cmis:value></cmis:propertyString>                                                     
<cmis:propertyString cmis:name="ContentStreamFilename"><cmis:value>ReallyMyFOLDER1253535827322</cmis:value></cmis:propertyString>                                                  
<cmis:propertyString cmis:name="ContentStreamURI"><cmis:value>http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/e42dea28-e2cb-4037-9f59-0839c1...</cmis:value></cmis:propertyString>                                                                                                                        
</cmis:properties>                                                                                                                                                                 
</cmis:object>                                                                                                                                                                     
<cmis:terminator/>                                                                                                                                                                 
<app:edited>2009-09-21T12:23:48.061Z</app:edited>                                                                                                                                  
<alf:icon>http://localhost:8080/alfresco/images/filetypes/_default.gif</alf:icon>                                                                                                  
</entry>                                                                                             
                                               

Here is my Java-Method.
public Entry createFolder(IRI parent, String name, String atomEntryFile) throws Exception {
        String createFolder = templates.load(atomEntryFile == null ? "createfolder.atomentry.xml" : atomEntryFile);
        createFolder = createFolder.replace("${NAME}", name);
        Request req = new PostRequest(parent.toString(), createFolder, CMISConstants.MIMETYPE_ATOMENTRY); //the constant is "application/atom+xml;type=entry"
        Response res = executeRequest(req, 201, cmisValidator.getCMISAtomValidator());
        String xml = res.getContentAsString();
        Entry entry = appModel.parseEntry(new StringReader(xml), null);
        CMISObject object = entry.getExtension(CMISConstants.OBJECT);
        String testFolderHREF = (String) res.getHeader("Location");
        return entry;
    }

So, I obviously  tell Alfresco: "Make me a folder", to which Alfresco replies: "Ok, I'll make you an empty document, with  <content type="application/octet-stream" …>"

I suppose I'm doing something wrong here, since Alfresco's own tests seem to be working quite well indeed. I've compared my code stack with the one used by the Alfresco's own tests (org.alfresco.repo.cmis.rest.test.CMISTest.java from SVN) and I have been unable to spot any differences between the two. I am pretty much stuck here.

Any input would be much appreciated. Thanks!

Max
3 REPLIES 3

bnmaxim
Champ in-the-making
Champ in-the-making
Ooook, i've managed to answer my own question. In case anyone is interested in this, later on.

My folder template (which I took from the Apache Chemistry project) declared the XML-Namespace for CMIS as

 xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901" 
whereas the more recent Alfresco versions employ
 xmlns:cmis="http://www.cmis.org/2008/05"

That was it. Turns out the cardboard programmer principle (http://www.c2.com/cgi/wiki?CardboardProgrammer) works.

rmorant
Champ in-the-making
Champ in-the-making
I'm in troubles with this.
Chemistry returns null for the query collection IRI.

IRI queryHREF = client.getQueryCollection(client.getWorkspace());
I suppose it is because the namespace.
The chemistry-tck-atompub trunk uses CMIS_NS = "http://docs.oasis-open.org/ns/cmis/core/200908/"
(http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tck-atompub/src/main/java...)

And the template resources. (e. query.cmisquery.xml )

<cmis:query xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">
  <cmis:statement><![CDATA[${STATEMENT}]]></cmis:statement>
  <cmis:skipCount>${SKIPCOUNT}</cmis:skipCount>
  <cmis:maxItems>${MAXITEMS}</cmis:maxItems>
</cmis:query>
Then … There are any java client library that we can use out of the box?

bnmaxim, You had to change the source of chemistry-tck-atompub?

rmorant
Champ in-the-making
Champ in-the-making
this is definitely a post monologo.
ok, I was using mismatch versions.
chemistry-tck-atompub /trunk works with Alfresco 3.2r2 but not with 3.2r (me)
bye