Class Stack
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionAssets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded in your Contentstack repository for future use.The Get all assets request fetches the list of all the assets of a particular stack.contentType
(String contentTypeUid) Content type defines the structure or schema of a page or a section of your web or mobile property.Returns apiKey of particular stackvoid
getContentTypes
(org.json.JSONObject params, ContentTypesCallback callback) The Get all content types call returns comprehensive information of all the content types available in a particular stack in your account..Returns deliveryToken of particular stackimageTransform
(String imageUrl, Map<String, Object> parameters) Image transform string.livePreviewQuery
(Map<String, String> query) Live Preview lets content managers preview entry content across multiple channels before saving or publishing it to a live website.void
removeHeader
(String headerKey) Removes Header by keyvoid
Adds header to the stackvoid
sync
(SyncResultCallBack syncCallBack) The Sync request performs a complete sync of your app data.void
sync
(String contentType, Date fromDate, String localeCode, Stack.PublishType publishType, SyncResultCallBack syncCallBack) Sync.void
syncContentType
(String contentType, SyncResultCallBack syncCallBack) Sync content type.void
syncFromDate
(Date fromDate, SyncResultCallBack syncCallBack) Sync from date.void
syncLocale
(String localeCode, SyncResultCallBack syncCallBack) Sync locale.void
syncPaginationToken
(String paginationToken, SyncResultCallBack syncCallBack) Sync pagination token.void
syncPublishType
(Stack.PublishType publishType, SyncResultCallBack syncCallBack) Sync publish type.void
syncToken
(String syncToken, SyncResultCallBack syncCallBack) Sync token.
-
Method Details
-
livePreviewQuery
Live Preview lets content managers preview entry content across multiple channels before saving or publishing it to a live website. You can edit an entry and preview the content changes side by side in real-time.Note: To be able to preview entry content, developers need to first configure Live Preview for the frontend website and then enable it from the stack settings section in Contentstack. You can set up the base URL and environment across which you want to preview content.
- Parameters:
query
- the query of typeHashMap
- Returns:
- stack
Example
stack = contentstack.Stack("apiKey", "deliveryToken", "environment");
HashMap queryMap = new HashMap();
stack.livePreviewQuery(queryMap)
- Throws:
IOException
- IO Exception
-
contentType
Content type defines the structure or schema of a page or a section of your web or mobile property. To create content for your application, you are required to first create a content type, and then create entries using the content type.- Parameters:
contentTypeUid
- Enter the unique ID of the content type of which you want to retrieve the entries. The UID is often based on the title of the content type and it is unique across a stack.- Returns:
- the
ContentType
Example
Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); ContentType contentType = stack.contentType("contentTypeUid")
-
asset
Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded in your Contentstack repository for future use. These files can be attached and used in multiple entries.The Get a single asset request fetches the latest version of a specific asset of a particular stack.
- Parameters:
uid
- uid ofAsset
- Returns:
Asset
instance Tip: If no version is mentioned, the request will retrieve the latest published version of the asset. To retrieve a specific version, use the version parameter, keep the environment parameter blank, and use the management token instead of the delivery token.Example Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); Asset asset = stack.asset("assetUid");
-
assetLibrary
The Get all assets request fetches the list of all the assets of a particular stack. It returns the content of each asset in JSON format.- Returns:
AssetLibrary
asset libraryExample
Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); AssetLibrary assets = stack.assetLibrary();
-
getApplicationKey
Returns apiKey of particular stack- Returns:
Stack
apiKey
-
getDeliveryToken
Returns deliveryToken of particular stack- Returns:
- deliveryToken delivery token
-
removeHeader
Removes Header by key- Parameters:
headerKey
- of the headerExample: stack.removeHeader("delivery_token");
-
setHeader
Adds header to the stack- Parameters:
headerKey
- the header keyheaderValue
- the header value
-
imageTransform
Image transform string. This document is a detailed reference to Contentstack Image Delivery API and covers the parameters that you can add to the URL to retrieve, manipulate (or convert) image files and display it to your web or mobile properties.- Parameters:
imageUrl
- the image urlparameters
- the parametersLinkedHashMap
- Returns:
- the string
-
getContentTypes
The Get all content types call returns comprehensive information of all the content types available in a particular stack in your account..- Parameters:
params
- query parameterscallback
- ContentTypesCallback This call returns comprehensive information of all the content types available in a particular stack in your account.
-
sync
The Sync request performs a complete sync of your app data. It returns all the published entries and assets of the specified stack in response. The response also contains a sync token, which you need to store, since this token is used to get subsequent delta- Parameters:
syncCallBack
- returns callback for sync result.
-
syncPaginationToken
Sync pagination token.- Parameters:
paginationToken
- If the response is paginated, use the pagination token under this parameter.syncCallBack
- returns callback for sync resultIf the result of the initial sync (or subsequent sync) contains more than 100 records, the response would be paginated. It provides pagination token in the response. However, you do not have to use the pagination token manually to get the next batch, the SDK does that automatically until the sync is complete. Pagination token can be used in case you want to fetch only selected batches. It is especially useful if the sync process is interrupted midway (due to network issues, etc.). In such cases, this token can be used to restart the sync process from where it was interrupted.
Example :
Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); stack.syncPaginationToken("paginationToken)
-
syncToken
Sync token.- Parameters:
syncToken
- Use the sync token that you received in the previous/initial sync under this parameter.syncCallBack
- returns callback for sync resultYou can use the sync token (that you receive after initial sync) to get the updated content next time. The sync token fetches only the content that was added after your last sync, and the details of the content that was deleted or updated.
Example :
Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); stack.syncToken("syncToken") stack.syncToken(sync_token, new SyncResultCallBack() ){ }
-
syncFromDate
Sync from date.- Parameters:
fromDate
- Enter the start date for initial sync.syncCallBack
- Returns callback for sync result.You can also initialize sync with entries published after a specific date. To do this, use syncWithDate and specify the start date as its value.
Example :
Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); stack.syncFromDate("fromDate")
-
syncContentType
Sync content type.- Parameters:
contentType
- Provide uid of your content_typesyncCallBack
- Returns callback for sync result.You can also initialize sync with entries of only specific content_type. To do this, use syncContentType and specify the content type uid as its value. However, if you do this, the subsequent syncs will only include the entries of the specified content_type.
Example :stack.syncContentType(String content_type, new SyncResultCallBack()){ }
-
syncLocale
Sync locale.- Parameters:
localeCode
- Select the required locale code.syncCallBack
- Returns callback for sync result.You can also initialize sync with entries of only specific locales. To do this, use syncLocale and specify the locale code as its value. However, if you do this, the subsequent syncs will only include the entries of the specified locales.
Example :
Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); stack.syncContentType(String content_type, new SyncResultCallBack()){ }
-
syncPublishType
Sync publish type.- Parameters:
publishType
- Use the type parameter to get a specific type of content like(asset_published, entry_published, asset_unpublished, asset_deleted, entry_unpublished, entry_deleted, content_type_deleted.)
syncCallBack
- returns callback for sync result.Use the type parameter to get a specific type of content. You can pass one of the following values: asset_published, entry_published, asset_unpublished, asset_deleted, entry_unpublished, entry_deleted, content_type_deleted. If you do not specify any value, it will bring all published entries and published assets.
Example :
Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); * stack.syncPublishType(PublishType)
-
sync
public void sync(String contentType, Date fromDate, String localeCode, Stack.PublishType publishType, SyncResultCallBack syncCallBack) Sync.- Parameters:
contentType
- your content type idfromDate
- start datelocaleCode
- language as language codepublishType
- type as PublishTypesyncCallBack
- CallbackYou can also initialize sync with entries that satisfy multiple parameters. To do this, use syncWith and specify the parameters. However, if you do this, the subsequent syncs will only include the entries of the specified parameters
Example :
-