I personnaly use the DocumentService for those operations :


import org.nuxeo.ecm.automation.client.jaxrs.RemoteException;
import org.nuxeo.ecm.automation.client.jaxrs.Session;
import org.nuxeo.ecm.automation.client.jaxrs.impl.HttpAutomationClient;
import org.nuxeo.ecm.automation.client.jaxrs.model.Document;
import org.nuxeo.ecm.automation.client.jaxrs.model.PropertyMap;
import org.nuxeo.ecm.automation.client.jaxrs.adapters.DocumentService;

public class test
{
    public static void main( String[] args ) throws Exception
    {
HttpAutomationClient client = new HttpAutomationClient(
        "http://localhost:8080/nuxeo/site/automation";);
Session session = client.getSession("Administrator", "Administrator");

DocumentService dc = new DocumentService(session);
Document baseDocument = dc.getDocument("/default-domain/workspaces/workspace");

PropertyMap pMap = new PropertyMap();
pMap.set("dc:title", "My workspace");
pMap.set("dc:description", "What a funny workspace !");

Document doc = null;
try {
       doc = dc.getDocument(baseDocument.getPath()+"/hiphop");
       } catch (RemoteException e) {
       doc = null;
}

if (doc !=null){
       dc.update(doc, pMap);
else {
dc.createDocument(baseDocument, "Workspace", nextLine[0].toLowerCase(), pMap);
}
client.shutdown();

}
}

Le 07/04/2011 17:35, [email protected] a écrit :
Hello

I Have been trying to create a new document using Automation
client, I want to assign a title for the document and a
description, I wrote the next code:


request = session.newRequest("Document.Create");
                                                request.setInput(new 
PathRef(rootPath));
                                                request.set("type", 
typeDocument);
                                                request.set("name", 
documentName);
                                                request.set("properties", 
"dc:title=" + documentName
);
request.set("properties", "dc:description="+ rptname);
                                                request.execute();

When I don't put the line "request.set("properties",
"dc:description="+ rptname)" the document is created
according to what I specified, so I can go to nuxeo an see
the document with the right name, but when I add that line
of code, the document is created with the right description,
but the name of the file has random numbers and letters.

What I am doing wrong?

Thanks
---
Mailing list: [email protected]
Forum: http://forum.nuxeo.org/f/1/


---
Mailing list: [email protected]
Forum: http://forum.nuxeo.org/f/1/

Reply via email to