public class Stack extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Stack.PublishType
The enum Publish type.
|
| Modifier and Type | Field and Description |
|---|---|
protected String |
apiKey |
protected Config |
config |
protected String |
contentType |
protected LinkedHashMap<String,Object> |
headers |
protected org.json.JSONObject |
syncParams |
| Modifier | Constructor and Description |
|---|---|
protected |
Stack() |
protected |
Stack(String apiKey) |
| Modifier and Type | Method and Description |
|---|---|
protected Asset |
asset() |
Asset |
asset(String uid)
Assets refer to all the media files (images, videos, PDFs, audio files, and
so on) uploaded in your Contentstack repository for future use.
|
AssetLibrary |
assetLibrary()
The Get all assets request fetches the list of all the assets of a particular
stack.
|
ContentType |
contentType(String contentTypeUid)
Content type defines the structure or schema of a page or a section of your
web or mobile property.
|
protected String |
convertUTCToISO(Date date) |
String |
getAccessToken()
Deprecated.
accessToken of particular stack
|
String |
getApplicationKey()
Returns apiKey of particular stack
|
void |
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..
|
String |
getDeliveryToken()
Returns deliveryToken of particular stack
|
protected String |
getQueryParam(Map<String,Object> params) |
String |
imageTransform(String imageUrl,
Map<String,Object> parameters)
Image transform string.
|
Stack |
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 key
|
protected void |
setConfig(Config config) |
void |
setHeader(String headerKey,
String headerValue)
Adds header to the stack
|
void |
sync(String contentType,
Date fromDate,
String localeCode,
Stack.PublishType publishType,
SyncResultCallBack syncCallBack)
Sync.
|
void |
sync(SyncResultCallBack syncCallBack)
The Sync request performs a complete sync of your app data.
|
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.
|
protected LinkedHashMap<String,Object> headers
protected Config config
protected String contentType
protected String apiKey
protected org.json.JSONObject syncParams
protected Stack()
throws IllegalAccessException
IllegalAccessExceptionprotected Stack(@NotNull
String apiKey)
protected void setConfig(Config config)
public Stack livePreviewQuery(Map<String,String> query)
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.
query - the query of type HashMapExample stack = contentstack.Stack("apiKey", "deliveryToken", "environment");
HashMap queryMap = new HashMap();
stack.livePreviewQuery(queryMap)
public ContentType contentType(String contentTypeUid)
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.ContentType
Example
Stack stack = contentstack.Stack("apiKey",
"deliveryToken", "environment"); ContentType contentType = stack.contentType("contentTypeUid")
public Asset asset(@NotNull String uid)
The Get a single asset request fetches the latest version of a specific asset of a particular stack.
uid - uid of AssetAsset 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");
protected Asset asset()
public AssetLibrary assetLibrary()
AssetLibrary asset library
Example
Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment");
AssetLibrary assets = stack.assetLibrary();
public String getApplicationKey()
Stack apiKey@Deprecated public String getAccessToken()
Stack accessTokenpublic String getDeliveryToken()
public void removeHeader(String headerKey)
headerKey - of the header
Example: stack.removeHeader("delivery_token");
public void setHeader(@NotNull
String headerKey,
@NotNull
String headerValue)
headerKey - the header keyheaderValue - the header valuepublic String imageTransform(@NotNull String imageUrl, @NotNull Map<String,Object> parameters)
imageUrl - the image urlparameters - the parameters LinkedHashMappublic void getContentTypes(@NotNull
org.json.JSONObject params,
ContentTypesCallback callback)
params - query parameterscallback - ContentTypesCallback This call returns comprehensive
information of all the content types available in a
particular stack in your account.public void sync(SyncResultCallBack syncCallBack)
syncCallBack - returns callback for sync result.public void syncPaginationToken(@NotNull
String paginationToken,
SyncResultCallBack syncCallBack)
paginationToken - If the response is paginated, use the pagination token
under this parameter.syncCallBack - returns callback for sync result
If 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 :
public void syncToken(String syncToken, SyncResultCallBack syncCallBack)
syncToken - Use the sync token that you received in the
previous/initial sync under this parameter.syncCallBack - returns callback for sync result
You 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.syncToken(sync_token, new SyncResultCallBack() ){ }
public void syncFromDate(@NotNull
Date fromDate,
SyncResultCallBack syncCallBack)
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 :
final Date start_date = sdf.parse("2018-10-07");
stack.syncFromDate(start_date, SyncResultCallBack()) {
}
public void syncContentType(@NotNull
String contentType,
SyncResultCallBack syncCallBack)
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()){ }
public void syncLocale(String localeCode, SyncResultCallBack syncCallBack)
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 :
public void syncPublishType(Stack.PublishType publishType, SyncResultCallBack syncCallBack)
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 :
stackInstance.syncPublishType(Stack.PublishType.entry_published, new SyncResultCallBack()) { }
public void sync(String contentType, Date fromDate, String localeCode, Stack.PublishType publishType, SyncResultCallBack syncCallBack)
contentType - your content type idfromDate - start datelocaleCode - language as language codepublishType - type as PublishTypesyncCallBack - Callback
You 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 :
Copyright © 2021 Contentstack.. All rights reserved.