Content API for Java Guide

JSON fueled, delivered by Cloud CMS





Current version: gitana-java-driver-1.0.15. Released Nov 23, 2016.

The Cloud CMS Java driver makes it easy for your Java and Android applications to connect to and communicate with the Cloud CMS server. The driver can be utilized with Android mobile devices as well as Java applications running on the server or as a web application (Spring Framework, SEAM, etc, running on Tomcat, Glassfish, WebSphere and many other frameworks).


Maven Repository

Cloud CMS runs a Maven repository where it hosts its Java-related assets including the Cloud CMS driver. If you're building using Maven, Ivy, Gradle or another build framework that manages dependencies, you can probably take advantage of this repository.

For Maven users, you can add the following repository configuration:

<repositories>
    <repository>
        <id>cloudcms-public</id>
        <name>cloudcms-public</name>
        <url>http://maven.cloudcms.com/public</url>
    </repository>
</repositories>

You can then add the Java Driver as a dependency to your pom.xml file:

<dependencies>
    <dependency>
        <groupId>org.gitana</groupId>
        <artifactId>gitana-java-driver</artifactId>
        <version>1.0.15</version>
    </dependency>
</dependencies>

Getting Started

To connect to Cloud CMS, you first need to have a set of API Keys. In Cloud CMS, API Keys consists of a client key/secret and a user key/secret. You pass these keys into the Gitana.connect method as a JSON object.

You can create as many API Keys as you would like. The basic process for getting your own keys is described in the Developers Getting Started Guide. Give that a shot and when you're done, you should have the following:

  • clientKey
  • clientSecret
  • username
  • password

You can then connect to Cloud CMS using a code block like the one shown below. Make sure to plug in the values for clientKey, clientSecret, username and password from the API Keys that you generate.

import org.gitana.platform.client.branch.Branch;
import org.gitana.platform.client.node.BaseNode;
import org.gitana.platform.client.node.Node;
import org.gitana.platform.client.platform.Platform;
import org.gitana.platform.client.repository.Repository;
import org.gitana.platform.support.Pagination;
import org.gitana.platform.support.QueryBuilder;
import org.gitana.platform.support.ResultMap;
import org.gitana.platform.client.Gitana;

public class CloudCMSExample {

    public static void main(String[] args) {

        // these values come from your API Keys
        String clientKey = "{clientKey}";
        String clientSecret = "{clientSecret}";
        String username = "{username}";
        String password = "{password}";

        // connect as to Cloud CMS as your tenant and user
        Gitana gitana = new Gitana(clientKey, clientSecret);
        Platform platform = gitana.authenticate(username, password);

        // create a repository
        Repository repository = platform.createRepository();

        // get the master branch
        Branch master = repository.readBranch("master");

        // create three nodes
        Node node1 = (Node) master.createNode();
        Node node2 = (Node) master.createNode();
        Node node3 = (Node) master.createNode();

        // update a node
        node2.set("axl", "rose");
        node2.update();

        // delete the third node
        node3.delete();

        // query for nodes
        ResultMap nodes = master.queryNodes();
        for (Node node: nodes.values()) {
            System.out.println("Title: " + node.getTitle());
        }
    }
}

Documentation

The Java driver is a useful library that provides access to the capabilities of Cloud CMS from a programmatic perspective. It is therefore important to first familiarize yourself with the concepts presented in the Cloud CMS Documentation.

You should also familiarize with the Cloud CMS REST API which covers HTTP-level information about all of the methods and operations available within Cloud CMS.


Fork the Code

The Cloud CMS Java driver is 100% open-source (Apache 2.0) and so you're free to fork it, extend it and dig into it to learn about how it works. We provide hundreds of test files and thousands of unit tests within that demonstrate various code operations. It's really cool.


Bugs / Problems

If you run into a bug, please create an issue so that we can look at it.
For production support, please contact us at support@cloudcms.com or call us directly.


Support and Terms of Use

The Java driver is free to use in your applications and projects. It is fully supported by Cloud CMS.