Hi, i'm using Nuxeo Automation Client to upload documents. Java platform (1.6 update 35), only text files at the moment.
- I want to check if a document already exists
- If the doc doesn't exist i want to create the first version for it
- If the document already exists i want to "update" it (i mean: create a new version and upload the new content).
To check for the document on the repository i use the following code:
doc = (Document) session.newRequest(DocumentService.FetchDocument).setHeader(Constants.HEADER_NX_SCHEMAS, "*").set("value", workingPath + "/" + fileName).execute();
It throws an exception if the doc doesn't exist, so in my catch block i create it this way:
session.newRequest(DocumentService.CreateDocument).setInput(customFolder).set("type", "File").set("name", fileName).set("properties", props).execute();
session.newRequest(DocumentService.SetBlob).setHeader(Constants.HEADER_NX_VOIDOP, "true").setInput(fb).set("document", workingPath + "/" + fileName).execute();
where "fb" is my FileBlob containing the file content. It works for new files (already tested it), but feel free to give me advice if it could be improved some way... π
The problem i have is to create the new version and upload the new content on the repository. The check in the first code block doesn't throw any exception if the doc exist, so i know when i should create a new version of the doc BUT i'm having a hard time figuring out how to do that... π
Can anyone pls help me?
( Sorry in advance for my poor english π )