As we constantly strive to make the Nuxeo Platform better and more efficient than ever, this time we turned our attention to the new REST API Java client.

The Story

The initial Java Automation Client fulfilled a lot of needs but there were two versions, one for Java and one for Android.

  • The nuxeo-automation-client design was based on Automation API before REST endpoints were available in the Nuxeo Platform
  • Upload and download were missing
  • Marshalling was difficult to use and debug
  • The nuxeo-automation-client was then forked to build an Android version with some caching.

Since our REST APIs have evolved, we wanted to create a new one compliant with Android that uses the latest Java client libraries.

The Release!

Today, we are very happy to announce the release of the Nuxeo Java Client 1.0 with these cool features:

  • Supports the latest REST and resource centric API of the Nuxeo Platform
  • Fluent programming with objects, such as documents, users, groups, workflows, etc.
  • Upload in normal or chunk mode
  • Automation REST API calls
  • Android compatible (using OkHttp/Retrofit of Square)
  • Simple marshalling with Jackson FasterXML

Test it out and give us your feedback!

Usage

Here’s the documentation that will show you how to get the Nuxeo Java Client 1.0 through Maven. It also has some exhaustive examples to help you begin your implementation quickly.

Here are some examples on how to use the client:

Creating a Client

Here’s how you can create a create a client:

For a given url:

String url = "http://localhost:8080/nuxeo";

And given credentials:

import org.nuxeo.client.api.NuxeoClient;
NuxeoClient nuxeoClient = new NuxeoClient(url, "Administrator", "Administrator");

Automation

To use the Automation API, org.nuxeo.client.api.NuxeoClient#automation() is the entry point for all calls:

import org.nuxeo.client.api.objects.Document;

// Fetch the root document
Document result = nuxeoClient.automation().param("value", "/").execute("Repository.GetDocument");

import org.nuxeo.client.api.objects.Operation;
import org.nuxeo.client.api.objects.Documents;

// Execute query
Operation operation = nuxeoClient.automation("Repository.Query").param("query", "SELECT * " + "FROM Document"); Documents result = operation.execute();

Repository API

import org.nuxeo.client.api.objects.Document;

// Fetch the root document
Document root = nuxeoClient.repository().fetchDocumentRoot();
// Fetch document by path
Document folder = nuxeoClient.repository().fetchDocumentByPath("/folder_2");
// Create a document
Document folder = nuxeoClient.repository().fetchDocumentByPath("/folder_1"); Document document = new Document("file", "File");
document.set("dc:title", "new title");
document = nuxeoClient.repository().createDocumentByPath("/folder_1", document);

Android Nuxeo Share

In the same repository on GitHub, you will find an Android Nuxeo Share sample using nuxeo-java-client for sharing binary files from your Android to a remote Nuxeo server.

Here is a short demo to give you an idea of Nuxeo Share!