public class Stack
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Stack.PublishType |
Modifier and Type | Field and Description |
---|---|
protected Config |
config |
protected java.lang.String |
content_type |
protected java.lang.String |
contentType |
protected java.util.HashMap<java.lang.String,java.lang.Object> |
headerGroup_app |
protected java.lang.String |
localeCode |
protected java.util.LinkedHashMap<java.lang.String,java.lang.Object> |
localHeader |
protected java.lang.String |
pagination_token |
protected Stack.PublishType |
publishType |
protected java.lang.String |
start_from_date |
protected java.lang.String |
SYNC_KEY |
protected java.lang.String |
sync_token |
protected java.lang.String |
URL |
protected java.lang.String |
URLSCHEMA |
protected java.lang.String |
VERSION |
Modifier | Constructor and Description |
---|---|
protected |
Stack(java.lang.String stackApiKey) |
Modifier and Type | Method and Description |
---|---|
protected Asset |
asset() |
Asset |
asset(java.lang.String uid) |
AssetLibrary |
assetLibrary() |
ContentType |
contentType(java.lang.String contentTypeName) |
java.lang.String |
getAccessToken() |
java.lang.String |
getApplicationKey() |
void |
getContentTypes(org.json.JSONObject params,
com.contentstack.sdk.ContentTypesCallback callback) |
java.lang.String |
ImageTransform(java.lang.String image_url,
java.util.LinkedHashMap<java.lang.String,java.lang.Object> parameters) |
void |
removeHeader(java.lang.String key) |
protected void |
setConfig(Config config) |
void |
setHeader(java.lang.String key,
java.lang.String value) |
void |
sync(java.lang.String contentType,
java.util.Date from_date,
com.contentstack.sdk.Language language,
Stack.PublishType type,
SyncResultCallBack syncCallBack) |
void |
sync(SyncResultCallBack syncCallBack) |
void |
syncContentType(java.lang.String content_type,
SyncResultCallBack syncCallBack) |
void |
syncFromDate(java.util.Date from_date,
SyncResultCallBack syncCallBack) |
void |
syncLocale(com.contentstack.sdk.Language language,
SyncResultCallBack syncCallBack) |
void |
syncPaginationToken(java.lang.String pagination_token,
SyncResultCallBack syncCallBack) |
void |
syncPublishType(Stack.PublishType type,
SyncResultCallBack syncCallBack) |
void |
syncToken(java.lang.String sync_token,
SyncResultCallBack syncCallBack) |
protected java.util.LinkedHashMap<java.lang.String,java.lang.Object> localHeader
protected java.lang.String URLSCHEMA
protected java.lang.String URL
protected java.lang.String VERSION
protected Config config
protected java.lang.String SYNC_KEY
protected java.lang.String content_type
protected java.lang.String sync_token
protected java.lang.String pagination_token
protected java.lang.String contentType
protected java.lang.String localeCode
protected Stack.PublishType publishType
protected java.lang.String start_from_date
protected java.util.HashMap<java.lang.String,java.lang.Object> headerGroup_app
protected void setConfig(Config config)
public ContentType contentType(java.lang.String contentTypeName)
public Asset asset(java.lang.String uid)
protected Asset asset()
public AssetLibrary assetLibrary()
public java.lang.String getApplicationKey()
public java.lang.String getAccessToken()
public void removeHeader(java.lang.String key)
public void setHeader(java.lang.String key, java.lang.String value)
public java.lang.String ImageTransform(java.lang.String image_url, java.util.LinkedHashMap<java.lang.String,java.lang.Object> parameters)
image_url
- on which we want to manipulate.parameters
- It is an second parameter in which we want to place different manipulation key and value in array form//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack("blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false);
// resize the image by specifying width and height LinkedHashMap imageParams = new LinkedHashMap(); imageParams.put("width", 100); imageParams.put("height",100); imageUrl = Stack.ImageTransform(image_url, parameters); stack.ImageTransform(image_url, parameters);
public void getContentTypes(org.json.JSONObject params, com.contentstack.sdk.ContentTypesCallback callback)
params
- query parameterscallback
- ContentTypesCallback
This call returns comprehensive information of all the content types available in a particular stack in your account.
JSONObject params = new JSONObject(); params.put("include_snippet_schema", true); params.put("limit", 3); stack.getContentTypes(new ContentTypesCallback() { public void onCompletion(ContentTypesModel contentTypesModel, Error error) { if (error == null){ // do your stuff. } } });
public void sync(SyncResultCallBack syncCallBack)
syncCallBack
- returns callback for sync result.
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 updates later.
stack.sync(SyncResultCallBack syncCallBack){ }
public void syncPaginationToken(java.lang.String pagination_token, SyncResultCallBack syncCallBack)
pagination_token
- 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.
// dummy pagination_token = "blt7f35951d259183fba680e1"; stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {}
public void syncToken(java.lang.String sync_token, SyncResultCallBack syncCallBack)
sync_token
- 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.
//dummy sync_token = "blt28937206743728463"; stack.syncToken(sync_token, new SyncResultCallBack() ){ }
public void syncFromDate(java.util.Date from_date, SyncResultCallBack syncCallBack)
from_date
- 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.
// dummy date final Date start_date = sdf.parse("2018-10-07"); stack.syncFromDate(start_date, new SyncResultCallBack()) { }
public void syncContentType(java.lang.String content_type, SyncResultCallBack syncCallBack)
content_type
- 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.
// dummy content_type like "session" stack.syncContentType(String content_type, new SyncResultCallBack()){ }
public void syncLocale(com.contentstack.sdk.Language language, SyncResultCallBack syncCallBack)
language
- Select the required locale from the Language class.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.
// dummy language- Language.ENGLISH_UNITED_STATES stackInstance.syncLocale(Language.ENGLISH_UNITED_STATES, new SyncResultCallBack() ) { }
public void syncPublishType(Stack.PublishType type, SyncResultCallBack syncCallBack)
type
- - 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.
stackInstance.syncPublishType(Stack.PublishType.entry_published, new SyncResultCallBack()) { }
public void sync(java.lang.String contentType, java.util.Date from_date, com.contentstack.sdk.Language language, Stack.PublishType type, SyncResultCallBack syncCallBack)
contentType
- your content type idfrom_date
- start datelanguage
- language as Language
type
- 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
stackInstance.sync(String contentType, Date from_date, Language language, PublishType type, SyncResultCallBack syncCallBack) { }