Skip to content

crob1140/confluence-java-client

Repository files navigation

Confluence Java Client

Build Status Test Coverage Maven Central

A simple Java client for the Confluence Cloud REST API

Installation

To add this package to a Gradle project, add the following to your build.gradle:

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'com.github.crob1140', name: 'confluence-java-client', version: '1.0.0'
}

Usage

Create a new client instance:

WebTarget wikiTarget = ClientBuilder.newClient().target("http://www.sample.atlassian.net/wiki");
AuthMethod basicAuth = new BasicAuth("username", "password");
Confluence client = new ConfluenceClient(wikiTarget, basicAuth);

Create some content:

Content newPage = client.createContent(new CreateContentRequest.Builder()
    .setType(StandardContentType.PAGE)
    .setSpaceKey("SAMPLE")
    .setTitle("Sample Page")
    .setBody(ContentBodyType.STORAGE, "<ac:rich-text-body><p>SAMPLE</p></ac:rich-text-body>")
    .build());

Get existing content:

List<Content> existingPages = client.getContent(new GetContentRequest.Builder()
    .setSpaceKey("SAMPLE")
    .setTitle("Sample Page")
    .setExpandedProperties(new ExpandedContentProperties.Builder().addVersion().build())
    .setLimit(1)
    .build())

Update existing content:

Content updatedContent = client.updateContent(new UpdateContentRequest.Builder()
    .setId(existingPage.getId())
    .setType(existingPage.getType())
    .setStatus(ContentStatus.CURRENT)
    .setBody(ContentBodyType.STORAGE, "<ac:rich-text-body><p>Updated body</p></ac:rich-text-body>")
    .setVersion(existingPage.getVersion().getNumber() + 1)
    .build())

Contribution

This client is a work-in-progress, and API methods will be added iteratively. If there is a particular feature you would like added, feel free to raise it as an issue, or fork the repository and create a pull request with your own changes.

License

MIT

About

A simple Java client for the Confluence Cloud REST API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages