cs-icon.svg

Contentstack Java Marketplace SDK

Introduction to Java Marketplace SDK

Contentstack offers Java Marketplace SDK. Seamlessly integrated, this SDK empowers Java developers to effortlessly build, deploy, and manage marketplace applications. Below is an in-depth guide to initiate your journey with the Java Marketplace SDK.

Additional Resource: To know more about the Java Marketplace SDK, refer to the About Java Marketplace SDK and Get Started with Java Marketplace SDK documentation.

Marketplace

Contentstack Marketplace is a hub for apps and other resources that help you extend the capabilities of our core CMS and customize its functionalities. It houses third-party integrations, UI extensions (such as dashboard, sidebar, custom field, and RTE plugins), and other tools that you can plug into Contentstack at the stack as well as organizational level.

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID").host("marketplace.contentstack.io").region(Region.EU).build();
NameTypeDescription

organizationUid (required)

String

UID of the org

host

String

A custom host

region

Region.EU

DB region for Stack. You can choose from five regions namely, NA, EU, Azure NA, Azure EU, and GCP NA. The default region is set to NA.

login

The login method is an optional method for the user to perform CRUD operations. Alternatively, users can perform CRUD operations directly using an authtoken without logging in.

NameTypeDescription

emailId (required)

String

Your email id

password (required)

String

Your password

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID").login(“emailId”, “password”).build();

app

The app method creates and retrieves a new instance of the App class with the given parameters.

Returns:
Type
App
NameTypeDescription

uid

String

UID of the app

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
App app = marketplace.app("app_uid");

authorizations

The authorizations method retrieves a new instance of the Auth class with the given client and orgId.

Returns:
Type
Auth

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
Auth authorizations = marketplace.authorizations();

installation

The installation method retrieves a new instance of the Installation class with the specified client and orgId.

Returns:
Type
Installation
NameTypeDescription

installationId

String

UID to create a new installation object.

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
Auth authorizations = marketplace.installation();

request

The request method retrieves a new instance of the AppRequest class with the specified client and orgId.

Returns:
Type
AppRequest

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
AppRequest request = marketplace.request();

App

App/Manifest is used for creating/updating/deleting an app in your organization.

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID").host("marketplace.contentstack.io").build(); 
App app = marketplace.app("installationId"); 
(or) App app = marketplace.app();
NameTypeDescription

organizationUid (required)

String

UID of the organization

installationId

String

UID of the app

addParam

The addParam method adds a header with the specified key and value to the current location and returns the updated location.

Specified by:

addParam in interface BaseImplementation<App>

Returns:
Type
App
NameTypeDescription

key (required)

String

The key of the header to be added

value (required)

Object

The value of the header to be added

Throws:

java.lang.NullPointerException - if the key or value argument is null

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marktetplace.contentstack.io").build(); 
App app = marketplace.app().addParam("key","value");

addHeader

The addHeader method adds a header with the specified key and value to this location and returns the updated location.

Specified by:

addHeader in interface BaseImplementation<App>

Returns:
Type
App
NameTypeDescription

key (required)

String

The key of the header to be added

value (required)

String

The value of the header to be added

Throws:

java.lang.NullPointerException - if the key or value argument is null

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
App app = marketplace.app().addHeader("key","value");

addParams

The addParams method adds the specified parameters to this location and returns the updated location.

Specified by:

addParams

Returns:
Type
App
NameTypeDescription

params (required)

HashMap

The parameters to be added

Throws:

java.lang.NullPointerException - if the params argument is null

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
HashMap param = new HashMap(); 
App app = marketplace.app().addParams(param);

addHeaders

The addHeaders method adds the specified parameters to this location and returns the updated location.

Specified by:

addHeaders provides support to add custom header to the request.

Returns:
Type
App
NameTypeDescription

headers (required)

HashMap

The parameters to be added

Throws:

java.lang.NullPointerException - if the params argument is null

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
HashMap param = new HashMap(); 
App app = marketplace.app().addHeaders(param);

createInstallation

The createInstallation method creates an installation call.

Returns:
Type
call
NameTypeDescription

body (required)

JSONObject

The body of the call

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
JSONObject body = new JSONObject(); 
App app = marketplace.app().createInstallation(body); 
Call response = app.execute();

updateVersion

The updateVersion method updates the version call.

Returns:
Type
call
NameTypeDescription

body (required)

String

The body of the call

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
JSONObject body = new JSONObject(); 
App app = marketplace.app().updateVersion(body); 
Call response = app.execute();

findAppAuthorizations

The findAppAuthorizations method finds the app authorizations call.

Returns:
Type
call

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
App app = marketplace.app().findAppAuthorizations(); 
Call response = app.execute();

deleteAuthorization

The deleteAuthorization method deletes the authorization call.

Returns:
Type
call
NameTypeDescription

authorizationUid (required)

String

UID of the authorization call

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("api.contentstack.io").build(); 
App app = marketplace.app().deleteAuthorization("authorizationUid"); 
Call response = app.execute();

findAppInstallations

The findAppInstallations method finds the app installation call.

Returns:
Type
call

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
App app = marketplace.app().findAppInstallations(); 
Call response = app.execute();

findApps

The findApps method finds the app's call.

Returns:
Type
call

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
App app = marketplace.app().findApps(); 
Call response = app.execute();

createApp

The createApp method creates an app call.

Returns:
Type
call
NameTypeDescription

body (required)

JSONObject

The body of the call

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
JSONObject body = new JSONObject(); 
App app = marketplace.app().createApp(body); 
Call response = app.execute();

fetchApp

The fetchApp method fetches the app call.

Returns:
Type
call

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
App app = marketplace.app().fetchApp(); 
Call response = app.execute();

updateApp

The updateApp method updates the app call.

Returns:
Type
call
NameTypeDescription

body (required)

JSONObject

The body of the call

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
JSONObject body = new JSONObject(); 
App app = marketplace.app().updateApp(); 
Call response = app.execute();

findAppRequests

The findAppRequests method retrieves a call to list app requests with specified headers, app UID, and parameters.

Returns:
Type
call

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
App app = marketplace.app().findAppRequests(); 
Call response = app.execute();

oauth

The oauth method retrieves an instance of oauth

Returns:
Type
oauth
NameTypeDescription

id

String

The UID of the app

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
Oauth oauth = marketplace.app().oauth("id");

hosting

The hosting method retrieves an instance of hosting.

Returns:
Type
hosting
NameTypeDescription

id

String

The UID of the app

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
Hosting hosting = marketplace.app().hosting("appId");

Auth

While authorizing a Contentstack App, the app requests permissions from the user to perform a set of operations on behalf of the user. The app receives an access token after a user authenticates and authorizes access, then passes it as a credential when it calls the Contentstack APIs.

The Auth class handles user-requested permissions, allowing users to either request for the permission or, once their task is finished, request permission revocations.

Example:

Auth auth = marketplace.authorizations()
.addParam("param1", "value1")
.addHeader("authtoken", ORG_UID);
NameTypeDescription

organizationUid (required)

String

UID of the organization

findAuthorizedApp

The findAuthorizedApp method returns a call to retrieve authorized apps.

Returns:
Type
call

Example:

Call<ResponseBody> request = auth.findAuthorizedApp().execute();

addParam

The addParam method adds a header with the specified key and value

Specified by:

addParam in interface BaseImplementation

Returns:
Type
Auth
NameTypeDescription

key (required)

String

The key of the header to be added

value (required)

Object

The value of the header to be added

Throws:

NullPointerException - if the key or value argument is null

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
Auth authorizations = marketplace.authorizations(); 
authorizations.addParam("param1", "value1");

addHeader

The addHeader adds a header with the specified key and value.

Specified by:

addHeader provides support to add custom header to the request

Returns:
Type
Auth
NameTypeDescription

key (required)

String

The key of the header to be added

value (required)

Object

The value of the header to be added

Throws:

NullPointerException - if the key or value argument is null

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
Auth authorizations = marketplace.authorizations(); 
authorizations.addHeader("key", "value");

addParams

The addParams method adds the specified parameters.

Specified by:

addParams in interface BaseImplementation

Returns:
Type
Auth
NameTypeDescription

params (required)

HashMap

The parameters to be added

Throws:

NullPointerException - if the params argument is null

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
Auth authorizations = marketplace.authorizations(); 
HashMap params = new HashMap(); 
authorizations.addParams(params);

addHeaders

The addHeaders method adds the specified parameters.

Specified by:

addHeaders in interface BaseImplementation

Returns:
Type
Auth
NameTypeDescription

headers (required)

HashMap

The parameters to be added

Throws:

NullPointerException - if the params argument is null

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("api.contentstack.io").build(); 
Auth authorizations = marketplace.authorizations(); 
HashMap params = new HashMap(); 
authorizations.addHeaders(params);

Installation

Contentstack Marketplace enables users to directly install prebuilt apps and starters. However, app installations are subject to access restrictions, meaning your ability to view all or certain installed apps depends on the permissions granted at both the stack and organization levels.

  • If you are an organization admin or owner, you will be able to see all the stack and organization apps installed by any user in your organization.
  • If you are a stack admin or owner, you will be able to see the apps installed for the stacks that you have access to.
  • If you are not a stack admin or owner, you will be able to see the apps installed for the stacks that you have access to.

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
Installation installation = marketplace.installation();
NameTypeDescription

organizationId (required)

String

UID of the organization

installationId

String

UID for the installation

validateInstallationId

The validateInstallationId method validates if the installationId is not null or empty.

Returns:
Type
void
NameTypeDescription

installationId (required)

String

UI for the installation

Example:

Installation installation = marketplace.installation();
Installation installation = marketplace.installation("installationId");

location

The location method returns a new Location object with the specified client, organisationId, and installationId.

Returns:
Type
location

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
Installation installation = marketplace.installation(); 
Call result = installation.location().execute();

webhook

The webhook method creates and returns a new Webhook object with the given parameters.

Returns:
Type
Webhook
NameTypeDescription

webhookId (required)

String

UID of the webhook

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
Installation installation = marketplace.installation(); 
JSONObject body = new JSONObject(); 
Call result = installation.webhook("webhookId").execute();

addParam

The addParam method adds a parameter to the collection using a key-value pair.

Specified by:

addParam in interface BaseImplementation

Returns:
Type
Installation
NameTypeDescription

key (required)

String

The key of the header to be added

value (required)

Object

The value of the header to be added

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
Installation installation = marketplace.installation().addParam("key", "value");

addParams

The addParams method takes a HashMap of parameters and returns a generic type T.

Specified by:

addParams in interface BaseImplementation

Returns:
Type
Installation
NameTypeDescription

key (required)

String

The key of the header to be added

value (required)

Object

The value of the header to be added

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
HashMap parameters = new HashMap(); 
Installation installation = marketplace.installation().addParams(parameters);

addHeader

The addHeader method adds a header with a specified key and value to a request.

Specified by:

addHeader in interface BaseImplementation

Returns:
Type
Installation
NameTypeDescription

key (required)

String

The key of the header to be added

value (required)

String

The value of the header to be added

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
Installation installation = marketplace.installation().addHeader("key", "value");

addHeaders

The addHeaders method takes a HashMap of headers and adds them to the request.

Specified by:

addHeaders provides support to add custom header to the request

Returns:
Type
Installation
NameTypeDescription

key (required)

String

The key of the header to be added

value (required)

String

The value of the header to be added

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
HashMap parameters = new HashMap(); 
Installation installation = marketplace.installation().addHeaders(parameters);

AppRequest

If a user does not have the necessary permissions to install an app in an organization or stack, they can request the organization or stack administrator to install the app on their behalf. To do this, the user clicks the Request Install button.

Once the request is made, the organization or stack administrator can then approve or reject the request.

Example:

AppRequest appRequest = marketplace.request();
NameTypeDescription

orgId (required)

String

UID of the organization

addParam

The addParam method adds a parameter to a collection using a key-value pair.

Specified by:

addParam in interface BaseImplementation

Returns:
Type
AppRequest
NameTypeDescription

key (required)

String

The key of the header to be added

value (required)

Object

The value of the given key in the queryParams map

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
AppRequest appRequest = marketplace.request(); 
appRequest.addParam("key", "value");

addHeader

The addHeader method adds a header with a specified key and value to a request.

Specified by:

addHeader in interface BaseImplementation

Returns:
Type
AppRequest
NameTypeDescription

key (required)

String

The key of the header to be added

value (required)

String

The value of the header to be added

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
AppRequest appRequest = marketplace.request(); 
appRequest.addHeader("key", "value");

addHeaders

The addHeaders method adds headers to a HashMap and adds them to the request.

Specified by:

addHeaders provides support to add custom header to the request

Returns:
Type
AppRequest
NameTypeDescription

key (required)

String

The key of the header to be added

value (required)

Object

The value of the header to be added

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("marketplace.contentstack.io").build(); 
AppRequest appRequest = marketplace.request(); 
HashMap headers = new HashMap(); 
appRequest.addHeaders(headers);

addParams

The addParams method adds all the key-value pairs from the given HashMap to the queryParams HashMap and returns the updated AppRequest object.

Specified by:

addParams in interface BaseImplementation

Returns:
Type
AppRequest
NameTypeDescription

key (required)

String

The key of the header to be added

value (required)

Object

The value of the header to be added

Example:

Marketplace marketplace = new Marketplace.Builder("ORGANIZATION_UID") .host("api.contentstack.io").build(); 
AppRequest appRequest = marketplace.request(); 
HashMap headers = new HashMap(); 
appRequest.addParams(headers);