Class ModuleAssets


  • public class ModuleAssets
    extends java.lang.Object
    Assets Module.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  ModuleAssets.Async
      Async 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
      CMAAsset archive​(CMAAsset asset)
      Archive an Asset.
      ModuleAssets.Async async()  
      CMAAsset create​(CMAAsset asset)
      Create a new Asset in the configured space and environment.
      CMAAsset create​(java.lang.String spaceId, java.lang.String environmentId, CMAAsset asset)
      Create a new Asset.
      protected com.contentful.java.cma.ServiceAssets createService​(retrofit2.Retrofit retrofit)  
      java.lang.Integer delete​(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.
      CMAAsset fetchOne​(java.lang.String assetId)
      Fetch an Asset with the given assetId from the configured space and environment.
      CMAAsset fetchOne​(java.lang.String spaceId, java.lang.String environmentId, java.lang.String assetId)
      Fetch an Asset with the given assetId from the given space and environment.
      java.lang.Integer process​(CMAAsset asset, java.lang.String locale)
      Process an Asset.
      CMAAsset publish​(CMAAsset asset)
      Publish an Asset.
      CMAAsset unArchive​(CMAAsset asset)
      Un-Archive an Asset.
      CMAAsset unPublish​(CMAAsset asset)
      Un-Publish an Asset.
      CMAAsset update​(CMAAsset asset)
      Update an Asset.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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:
        CMAAsset result 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 asset has 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) and CMAClient.Builder.setEnvironmentId(String).

        Parameters:
        spaceId - Space ID
        environmentId - Environment ID
        asset - Asset
        Returns:
        CMAAsset result 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 asset has 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:
        CMAAsset result 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 ID
        environmentId - Environment ID
        Returns:
        CMAArray result 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 ID
        environmentId - Environment ID
        query - specifying details about which assets to fetch.
        Returns:
        CMAArray result instance
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
      • fetchOne

        public CMAAsset fetchOne​(java.lang.String spaceId,
                                 java.lang.String environmentId,
                                 java.lang.String assetId)
        Fetch an Asset with the given assetId from the given space and environment.
        Parameters:
        spaceId - Space ID
        environmentId - Environment ID
        assetId - Asset ID
        Returns:
        CMAAsset result 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 - Asset
        locale - 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:
        CMAAsset result 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:
        CMAAsset result 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:
        CMAAsset result 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:
        CMAAsset result 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.