Package com.contentful.java.cma
Class ModuleAssets
- java.lang.Object
-
- com.contentful.java.cma.ModuleAssets
-
public class ModuleAssets extends java.lang.ObjectAssets Module.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classModuleAssets.AsyncAsync module.
-
Constructor Summary
Constructors Constructor Description ModuleAssets(retrofit2.Retrofit retrofit, java.util.concurrent.Executor callbackExecutor, java.lang.String spaceId, java.lang.String environmentId, boolean environmentIdConfigured)Create the assets module.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CMAAssetarchive(CMAAsset asset)Archive an Asset.ModuleAssets.Asyncasync()CMAAssetcreate(CMAAsset asset)Create a new Asset in the configured space and environment.CMAAssetcreate(java.lang.String spaceId, java.lang.String environmentId, CMAAsset asset)Create a new Asset.protected com.contentful.java.cma.ServiceAssetscreateService(retrofit2.Retrofit retrofit)java.lang.Integerdelete(CMAAsset asset)Delete an Asset.CMAArray<CMAAsset>fetchAll()Fetch all Assets using configured space id and environment id.CMAArray<CMAAsset>fetchAll(java.lang.String spaceId, java.lang.String environmentId)Fetch all Assets from the given space and environment.CMAArray<CMAAsset>fetchAll(java.lang.String spaceId, java.lang.String environmentId, java.util.Map<java.lang.String,java.lang.String> query)Fetch all Assets matching the given query from the given space and environment.CMAArray<CMAAsset>fetchAll(java.util.Map<java.lang.String,java.lang.String> map)Fetch all Assets matching a query using configured space id and environment id.CMAAssetfetchOne(java.lang.String assetId)Fetch an Asset with the givenassetIdfrom the configured space and environment.CMAAssetfetchOne(java.lang.String spaceId, java.lang.String environmentId, java.lang.String assetId)Fetch an Asset with the givenassetIdfrom the given space and environment.java.lang.Integerprocess(CMAAsset asset, java.lang.String locale)Process an Asset.CMAAssetpublish(CMAAsset asset)Publish an Asset.CMAAssetunArchive(CMAAsset asset)Un-Archive an Asset.CMAAssetunPublish(CMAAsset asset)Un-Publish an Asset.CMAAssetupdate(CMAAsset asset)Update an Asset.
-
-
-
Constructor Detail
-
ModuleAssets
public ModuleAssets(retrofit2.Retrofit retrofit, java.util.concurrent.Executor callbackExecutor, java.lang.String spaceId, java.lang.String environmentId, boolean environmentIdConfigured)Create the assets module.- Parameters:
retrofit- the retrofit instance to be used to create the service.callbackExecutor- to tell on which thread it should run.spaceId- the space to be used when not given.environmentId- the environment to be used when not given.environmentIdConfigured- internal helper to see if environment was set.
-
-
Method Detail
-
createService
protected com.contentful.java.cma.ServiceAssets createService(retrofit2.Retrofit retrofit)
-
archive
public CMAAsset archive(CMAAsset asset)
Archive an Asset.- Parameters:
asset- Asset- Returns:
CMAAssetresult instance- Throws:
java.lang.IllegalArgumentException- if asset is null.java.lang.IllegalArgumentException- if asset id is null.java.lang.IllegalArgumentException- if asset space id is null.
-
create
public CMAAsset create(java.lang.String spaceId, java.lang.String environmentId, CMAAsset asset)
Create a new Asset.In case the given
assethas an ID associated with it, that ID will be used, otherwise the server will auto-generate an ID that will be contained in the response upon success.This method will override the configuration specified through
CMAClient.Builder.setSpaceId(String)andCMAClient.Builder.setEnvironmentId(String).- Parameters:
spaceId- Space IDenvironmentId- Environment IDasset- Asset- Returns:
CMAAssetresult instance- Throws:
java.lang.IllegalArgumentException- if asset is null.java.lang.IllegalArgumentException- if asset space id is null.java.lang.IllegalArgumentException- if asset environment id is null.
-
create
public CMAAsset create(CMAAsset asset)
Create a new Asset in the configured space and environment.In case the given
assethas an ID associated with it, that ID will be used, otherwise the server will auto-generate an ID that will be contained in the response upon success.- Parameters:
asset- Asset- Returns:
CMAAssetresult instance- Throws:
java.lang.IllegalArgumentException- if asset is null.java.lang.IllegalArgumentException- if configured space id is null.java.lang.IllegalArgumentException- if configured environment id is null.- See Also:
CMAClient.Builder.setSpaceId(String),CMAClient.Builder.setEnvironmentId(String)
-
delete
public java.lang.Integer delete(CMAAsset asset)
Delete an Asset.- Parameters:
asset- Asset- Returns:
- An integer representing the result of the delete operation
- Throws:
java.lang.IllegalArgumentException- if spaceId is null.java.lang.IllegalArgumentException- if assetId is null.
-
fetchAll
public CMAArray<CMAAsset> fetchAll()
Fetch all Assets using configured space id and environment id.This fetch uses the default parameter defined in
DefaultQueryParameter.FETCH- Returns:
- all assets of this space environment.
- Throws:
java.lang.IllegalArgumentException- if configured space id is null.java.lang.IllegalArgumentException- if configured environment id is null.- See Also:
CMAClient.Builder.setSpaceId(String),CMAClient.Builder.setEnvironmentId(String)
-
fetchAll
public CMAArray<CMAAsset> fetchAll(java.util.Map<java.lang.String,java.lang.String> map)
Fetch all Assets matching a query using configured space id and environment id.This fetch uses the default parameter defined in
DefaultQueryParameter.FETCH- Parameters:
map- the query to narrow down the results.- Returns:
- matching assets.
- Throws:
java.lang.IllegalArgumentException- if configured space id is null.java.lang.IllegalArgumentException- if configured environment id is null.- See Also:
CMAClient.Builder.setSpaceId(String),CMAClient.Builder.setEnvironmentId(String)
-
fetchAll
public CMAArray<CMAAsset> fetchAll(java.lang.String spaceId, java.lang.String environmentId)
Fetch all Assets from the given space and environment.This fetch uses the default parameter defined in
DefaultQueryParameter.FETCH- Parameters:
spaceId- Space IDenvironmentId- Environment ID- Returns:
CMAArrayresult instance- Throws:
java.lang.IllegalArgumentException- if spaceId is null.java.lang.IllegalArgumentException- if environment id is null.
-
fetchAll
public CMAArray<CMAAsset> fetchAll(java.lang.String spaceId, java.lang.String environmentId, java.util.Map<java.lang.String,java.lang.String> query)
Fetch all Assets matching the given query from the given space and environment.- Parameters:
spaceId- Space IDenvironmentId- Environment IDquery- specifying details about which assets to fetch.- Returns:
CMAArrayresult instance- Throws:
java.lang.IllegalArgumentException- if spaceId is null.
-
fetchOne
public CMAAsset fetchOne(java.lang.String assetId)
Fetch an Asset with the givenassetIdfrom the configured space and environment.- Parameters:
assetId- Asset ID- Returns:
CMAAssetresult instance- Throws:
java.lang.IllegalArgumentException- if configured space id is null.java.lang.IllegalArgumentException- if configured environment id is null.- See Also:
CMAClient.Builder.setSpaceId(String),CMAClient.Builder.setEnvironmentId(String)
-
fetchOne
public CMAAsset fetchOne(java.lang.String spaceId, java.lang.String environmentId, java.lang.String assetId)
Fetch an Asset with the givenassetIdfrom the given space and environment.- Parameters:
spaceId- Space IDenvironmentId- Environment IDassetId- Asset ID- Returns:
CMAAssetresult instance- Throws:
java.lang.IllegalArgumentException- if spaceId is null.java.lang.IllegalArgumentException- if assetId is null.
-
process
public java.lang.Integer process(CMAAsset asset, java.lang.String locale)
Process an Asset.- Parameters:
asset- Assetlocale- Locale- Returns:
- integer representing the success (204 = no content) of processing
- Throws:
java.lang.IllegalArgumentException- if asset is null.java.lang.IllegalArgumentException- if asset has no id.java.lang.IllegalArgumentException- if asset has no space.java.lang.IllegalArgumentException- if locale is null.
-
publish
public CMAAsset publish(CMAAsset asset)
Publish an Asset.- Parameters:
asset- Asset- Returns:
CMAAssetresult instance- Throws:
java.lang.IllegalArgumentException- if asset is null.java.lang.IllegalArgumentException- if asset has no id.java.lang.IllegalArgumentException- if asset has no space id.
-
unArchive
public CMAAsset unArchive(CMAAsset asset)
Un-Archive an Asset.- Parameters:
asset- Asset- Returns:
CMAAssetresult instance- Throws:
java.lang.IllegalArgumentException- if asset is null.java.lang.IllegalArgumentException- if asset id is empty.java.lang.IllegalArgumentException- if asset's space id is empty.
-
unPublish
public CMAAsset unPublish(CMAAsset asset)
Un-Publish an Asset.- Parameters:
asset- Asset- Returns:
CMAAssetresult instance- Throws:
java.lang.IllegalArgumentException- if asset is null.java.lang.IllegalArgumentException- if asset's id is not set.java.lang.IllegalArgumentException- if asset's space id is not set.
-
update
public CMAAsset update(CMAAsset asset)
Update an Asset.- Parameters:
asset- Asset- Returns:
CMAAssetresult instance- Throws:
java.lang.IllegalArgumentException- if asset is null.java.lang.IllegalArgumentException- if asset's id is null.java.lang.IllegalArgumentException- if asset's space id is null.java.lang.IllegalArgumentException- if asset's version is null.
-
async
public ModuleAssets.Async async()
- Returns:
- a module with a set of asynchronous methods.
-
-