Page 1 of 1

Java REST upload new version of document?

Posted: Tue Oct 04, 2016 2:53 pm
by maansson
I am a bit confused, as to how I would go about updating the version of a document by using REST in Java.
I am using LogicalDOC Community Edition, and through Eclipse, I am able to CRUD folders, create, read, update (just the metadata), and delete documents.
But how do I actually upload a new version of a document? I have found check in, checkout etc. methods in a DocumentService class, but is this what I am supposed to be using? :?

I have access to:
RestDocumentClient.create: Creates a new document
RestDocumentClient.getDocument: Gets a document
RestDocumentClient.delete: Deletes a document
RestDocumentClient.update: Updates ONLY the metadata of a document? I am confused.

Thank you :)

Re: Java REST upload new version of document?

Posted: Wed Oct 05, 2016 2:52 pm
by shatzing
Hi,
RestDocumentClient currently allows to update the document metadata, but doesn't have a method to update the content of a document.
Though the DocumentService interface (com.logicaldoc.webservice.rest.DocumentService) exposes some of methods that allows to update the content (file) of a document in 2 ways:
1) via versioning checkout/checking methods
2) using the method upload

That methods are implemented by the class RestDocumentService (com.logicaldoc.webservice.rest.endpoint.RestDocumentService)

So using Apache HttpClient 4.5.2 you can invoke directly the methods in RestDocumentService https://hc.apache.org/httpcomponents-cl ... index.html

See also the attached class (from logicaldoc-webservice package)

Re: Java REST upload new version of document?

Posted: Thu Oct 06, 2016 8:57 am
by maansson
Thank you for the response, shatzing :)
It took me a minute to understand how all this stuff fits together, but I figured it out now, and I think I would be able to use this HttpClient to run all the REST methods from now on!

Have a nice day 8-)