The contents you find here are totally obsolete so do not use this website to obtain a solution for your issues: the indications you get from here will not be accurate and may lead to data loss or other mayor problems

Java REST upload new version of document?

Do you want to create a native client or integrate with third party applications: webservices are the solution.

Moderator: car031

maansson
Posts: 10
Joined: Wed Sep 28, 2016 12:23 pm

Java REST upload new version of document?

Tue Oct 04, 2016 2:53 pm

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 :)
shatzing
Posts: 80
Joined: Tue Jan 21, 2014 9:46 am

Re: Java REST upload new version of document?

Wed Oct 05, 2016 2:52 pm

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)
Attachments
HttpRestWb.zip
(2.98 KiB) Downloaded 381 times
maansson
Posts: 10
Joined: Wed Sep 28, 2016 12:23 pm

Re: Java REST upload new version of document?

Thu Oct 06, 2016 8:57 am

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-)

Return to “Web Services”

Who is online

Users browsing this forum: No registered users and 29 guests

× Attention! This forum has been dismissed and will be soon removed. The contents you find here are totally obsolete so do not use this website to obtain a solution for your issues: the indications you get from here will not be accurate and may lead to data loss or other mayor problems.