cancel
Showing results for 
Search instead for 
Did you mean: 

How to know if a document is a version with Java Client 3.5.0

Rodri_
Star Contributor
Star Contributor

Hello,

I am trying to know if a document is a version, but Java Client doesn't retrieve that information about a document. When I use the "fetchDocumentById" method, I get a "Document" object, but I have no properties to know if it is a version or not. I have included the "properties" header with the "*" value in order to retrieve all propoerties, but "ecm" properties are not retrieved.

I have used the REST API and I can see two properties that can tell me if the document is a version or not: versionableId and isVersion. However, none of them are present in the "Document" object retrieved by the fetchDocumentById method.

Then, how can I know if a document is a version? I have also seen a facet called "Immutable" present in versions, but I am not sure if it is possible there are other documents with that facet without being a version.

Thank you.

1 ACCEPTED ANSWER

Kevin_Leturc
Star Contributor
Star Contributor

Hello,

I've just created JAVACLIENT-197 ticket to add missing fields to Document class.

In the meantime, you should be able to extend the Document class in order to add missing fields + register this new class during client construction. You can find more information in the documentation, in your case you should have something like below:

NuxeoClient client = new NuxeoClient.Builder()
                            .url("http://localhost:8080/nuxeo")
                            .authentication("Administrator", "Administrator")
                            .registerEntity(EntityTypes.DOCUMENT, YourDocument.class);
                            .connect();

View answer in original post

7 REPLIES 7

Gregory_Carlin
Elite Collaborator
Elite Collaborator

Hello,

The property which differentiate a live document from a version is ecm:isVersion.

Regards

Hello. I knew about that property, and it is retrieved with the REST API. However, that property it is not retrieved with Java Client when doing a "fetchDocumentById" (and I am including the "properties" header with an "*" to see all properties). The "Document" object retrieved doesn't have such property, nor any of "ecm". So, how can I know if the document is a version in this situation? Is it a Java Client bug?

Hi, I'm not an expert of the .NET client but you should retrieve any document property no?

Hello. I am using Java Client, not .NET Client. However, I think they work similar. All SDKs work over the nuxeo REST API. If you retrieve a document and all its properties using the REST API, properties from "ecm" schema are not retrieved (as "ecm" is not a "real" schema). With the REST API you can get the "isVersion" property, but not in the "properties" array (https

Kevin_Leturc
Star Contributor
Star Contributor

Hello,

I've just created JAVACLIENT-197 ticket to add missing fields to Document class.

In the meantime, you should be able to extend the Document class in order to add missing fields + register this new class during client construction. You can find more information in the documentation, in your case you should have something like below:

NuxeoClient client = new NuxeoClient.Builder()
                            .url("http://localhost:8080/nuxeo")
                            .authentication("Administrator", "Administrator")
                            .registerEntity(EntityTypes.DOCUMENT, YourDocument.class);
                            .connect();

Hello,

Amazing! I will update my Nuxeo Java Client version to 3.6.0. Thank you!