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();
Name | Type | Description |
---|---|---|
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.
Name | Type | Description |
---|---|---|
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.
Name | Type | Description |
---|---|---|
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.
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.
Name | Type | Description |
---|---|---|
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.
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();
Name | Type | Description |
---|---|---|
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>
Name | Type | Description |
---|---|---|
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>
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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.
Name | Type | Description |
---|---|---|
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.
Name | Type | Description |
---|---|---|
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.
Name | Type | Description |
---|---|---|
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.
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.
Name | Type | Description |
---|---|---|
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.
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.
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.
Name | Type | Description |
---|---|---|
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.
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.
Name | Type | Description |
---|---|---|
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.
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
Name | Type | Description |
---|---|---|
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.
Name | Type | Description |
---|---|---|
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);
Name | Type | Description |
---|---|---|
organizationUid (required) | String | UID of the organization |
findAuthorizedApp
The findAuthorizedApp method returns a call to retrieve authorized apps.
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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();
Name | Type | Description |
---|---|---|
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.
Name | Type | Description |
---|---|---|
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.
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.
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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();
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
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);