cancel
Showing results for 
Search instead for 
Did you mean: 

Create folders with Abdera

tremalnaik
Champ in-the-making
Champ in-the-making
Hi,

I'm trying create a new Space across a Web Script with an Abdera Client. I've tried the six POST in http://localhost:8080/alfresco/service/index/all



Abdera abdera = new Abdera();
AbderaClient client = new AbderaClient(abdera);

InputStream is = Utilidades.stringToInputStream(""); //Personal method

ClientResponse resp =
  client.post("http://localhost:8080/alfresco/service/cmis/s/SpaceStore/id_parent_folder/children +
                   "?alf_ticket=ticket", is2);

  // OR

  ClientResponse resp =
         client.post("http://localhost:8080/alfresco/service +
                "/cmis" +
                "/s/SpaceStore" +
                "/p/One/Two/Three" +
                "/children" +
                "?alf_ticket=ticket", is2);

All the time the response is:


400 Description: Request sent by the client was syntactically incorrect.    
Message:Posting of media resource not supported          
Community v3.4.0 (d 3370) schema 4.113
Diagnostics:Inspect Web Script (org/alfresco/cmis/children.post)

POST /alfresco/service/cmis/i/{id}/children?sourceFolderId={sourceFolderId}&versioningState={versioningState?}
POST /alfresco/service/cmis/s/{store}/i/{id}/children?sourceFolderId={sourceFolderId}&versioningState={versioningState?}
POST /alfresco/service/cmis/p{path}/children?sourceFolderId={sourceFolderId}&versioningState={versioningState?}
POST /alfresco/service/cmis/s/{store}/p{path}/children?sourceFolderId={sourceFolderId}&versioningState={versioningState?}
POST /alfresco/service/api/node/{store_type}/{store_id}/{id}/children?sourceFolderId={sourceFolderId}&versioningState={versioningState?}
POST /alfresco/service/api/path/{store_type}/{store_id}/{nodepath}/children?sourceFolderId={sourceFolderId}&versioningState={versioningState?}
2 REPLIES 2

tremalnaik
Champ in-the-making
Champ in-the-making
Hi,

I've modified my code like this:


Abdera abdera = new Abdera();
AbderaClient client = new AbderaClient(abdera);

Feed feed = abdera.newFeed();

String uri = "http://localhost:8080/alfresco/service/cmis/s/SpaceStore/p/One/Two/Three/children?alf_ticket='+my_ti...;
            
Factory factory = abdera.getFactory();
Entry entry = factory.newEntry();

entry.setTitle("Four");
entry.setSummary("Folder Four");

RequestOptions options = new RequestOptions();
options.setHeader("Content-Type", "application/atom+xml");
options.setHeader("type", "entry");
      
ClientResponse resp = client.post(uri, entry, options);

This works and createa a cmis:document in the folder Three but I want a new Folder but I don't know how change this parameter…

tremalnaik
Champ in-the-making
Champ in-the-making
Hi!

I've resolved. Let's hope it serves to something


public static final String NS_CMIS_RESTATOM = "http://docs.oasis-open.org/ns/cmis/restatom/200908/";
public static final String CMISRA = "cmisra";
public static final String NS_CMIS_CORE = "http://docs.oasis-open.org/ns/cmis/core/200908/";
public static final String CMIS = "cmis";

….

Abdera abdera = new Abdera();
AbderaClient client = new AbderaClient(abdera);

Feed feed = abdera.newFeed();

String uri = "http://localhost:8080/alfresco/service/cmis/s/SpaceStore/p/One/Two/Three/children?alf_ticket='+my_ti...;
            
Factory factory = abdera.getFactory();
Entry entry = factory.newEntry();

entry.setTitle("Four");
entry.setSummary("Folder Four");

ExtensibleElement objElement = entry.addExtension(NS_CMIS_RESTATOM, "object", CMISRA);
ExtensibleElement propsElement = objElement.addExtension(NS_CMIS_CORE, "properties", CMIS);
ExtensibleElement stringElement = propsElement.addExtension(NS_CMIS_CORE, "propertyId", CMIS);
stringElement.setAttributeValue("propertyDefinitionId","cmis:objectTypeId");
Element valueElement = stringElement.addExtension(NS_CMIS_CORE, "value", CMIS);
valueElement.setText("cmis:folder");

RequestOptions options = new RequestOptions();
options.setHeader("Content-Type", "application/atom+xml");
options.setHeader("type", "entry");
     
ClientResponse resp = client.post(uri, entry, options);