Cordra HTTP REST Client Library - Java Version

A Cordra HTTP REST client library in Java for interacting with a Cordra service is included in the distribution. This library is specifically designed for use with the Cordra’s REST API for interacting with Cordra.


The client library can be included in your Gradle or Maven build files.


compile group: 'net.cnri.cordra', name: 'cordra-client', version: '2.0.0'



The client library and its dependencies can also be found in this directory in the downloaded package:



The various methods supported by the Cordra Java client library are defined in this Java Interface:


There are two implementations of that Java Interface, one that does not use access tokens and one that does:


The basic approach to using Cordra would be to leverage any of the above implementations to perform create, retrieve, update, and delete (CRUD) operations and other operations. See the code in the aforementioned Java classes for details on the various supported operations.

That said, the basic digital object Java class stated below should be used for adding, removing, or updating information prior to invoking any Cordra client operations to commit the changes on the Cordra service:


Example Usages

  • Create a new instance of CordraClient:

    String baseUri = "http://localhost:8080/cordra/";
    String username = "admin";
    String password = "password";
    CordraClient cordra = new TokenUsingHttpCordraClient(baseUri, username, password);
  • Create a digital object of type Document (without attaching any payload, for brevity sake):

    JsonObject doc = new JsonObject();
    doc.addProperty("name", "example name");
    doc.addProperty("description", "description");
    CordraObject co = new CordraObject(); = "test/123";
    co.type = "Document";
    co = cordra.create(co);
  • Retrieve the digital object:

    CordraObject co = cordra.get("test/123");
  • Update the object:

    CordraObject co = cordra.get("test/123");
    co.content.getAsJsonObject().addProperty("name", "updated example name");
    co = cordra.update(co);
  • Delete the object:

  • Search for objects:

    try (SearchResults<CordraObject> results ="*:*")) {
        for (CordraObject co : results) {
  • Invoke a Type method (instance method):

    JsonElement result ="test/123", "exampleInstanceMethod", params, options);
  • Invoke a Type method (static method):

    JsonElement result = cordra.callForType("Member", "getMemberFromUsername", params, options);