Class ModuleContentTypes


  • public class ModuleContentTypes
    extends java.lang.Object
    Content Types Module.
    • Constructor Detail

      • ModuleContentTypes

        public ModuleContentTypes​(retrofit2.Retrofit retrofit,
                                  java.util.concurrent.Executor callbackExecutor,
                                  java.lang.String spaceId,
                                  java.lang.String environmentId,
                                  boolean environmentIdConfigured)
        Create content types 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.ServiceContentTypes createService​(retrofit2.Retrofit retrofit)
      • create

        public CMAContentType create​(CMAContentType contentType)
        Create a new Content Type in the configured space and environment.

        In case the given contentType 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:
        contentType - Content Type
        Returns:
        CMAContentType result instance
        Throws:
        java.lang.IllegalArgumentException - if configured space id is null.
        java.lang.IllegalArgumentException - if configured environment id is null.
        java.lang.IllegalArgumentException - if contentType is null.
        See Also:
        CMAClient.Builder.setSpaceId(String), CMAClient.Builder.setEnvironmentId(String)
      • create

        public CMAContentType create​(java.lang.String spaceId,
                                     java.lang.String environmentId,
                                     CMAContentType contentType)
        Create a new Content Type in an Environment.

        In case the given contentType 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
        contentType - Content Type
        Returns:
        CMAContentType result instance
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
        java.lang.IllegalArgumentException - if environmentId is null.
        java.lang.IllegalArgumentException - if contentType is null.
      • delete

        public java.lang.Integer delete​(CMAContentType contentType)
        Delete a Content Type.
        Parameters:
        contentType - Content Type
        Returns:
        Integer representing the result of the operation
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
        java.lang.IllegalArgumentException - if contentTypeId is null.
      • fetchAll

        public CMAArray<CMAContentType> fetchAll​(java.lang.String spaceId,
                                                 java.lang.String environmentId)
        Fetch all Content Types from an Environment, using default query parameter.

        This fetch uses the default parameter defined in DefaultQueryParameter.FETCH

        This method will override the configuration specified through CMAClient.Builder.setSpaceId(String) and CMAClient.Builder.setEnvironmentId(String).

        Parameters:
        spaceId - Space ID
        environmentId - Environment ID
        Returns:
        CMAArray result instance
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
      • fetchAll

        public CMAArray<CMAContentType> fetchAll​(java.lang.String spaceId,
                                                 java.lang.String environmentId,
                                                 java.util.Map<java.lang.String,​java.lang.String> query)
        Fetch all Content Types from a Space with query parameters.
        Parameters:
        spaceId - Space ID
        environmentId - Environment ID
        query - Query to narrow down the content_types to be searched for
        Returns:
        CMAArray result instance
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
        java.lang.IllegalArgumentException - if environmentId is null.
      • fetchOne

        public CMAContentType fetchOne​(java.lang.String contentTypeId)
        Fetch a Content Type with the given contentTypeId from the configured environment and space.
        Parameters:
        contentTypeId - Content Type ID
        Returns:
        CMAContentType result instance
        Throws:
        java.lang.IllegalArgumentException - if configured space id is null.
        java.lang.IllegalArgumentException - if configured environment id is null.
        java.lang.IllegalArgumentException - if contentTypeId is null.
        See Also:
        CMAClient.Builder.setSpaceId(String), CMAClient.Builder.setEnvironmentId(String)
      • fetchOne

        public CMAContentType fetchOne​(java.lang.String spaceId,
                                       java.lang.String environmentId,
                                       java.lang.String contentTypeId)
        Fetch a Content Type with the given contentTypeId from a given space environment combination.

        This method will override the configuration specified through CMAClient.Builder.setSpaceId(String) and CMAClient.Builder.setEnvironmentId(String).

        Parameters:
        spaceId - Space ID
        environmentId - Environment ID
        contentTypeId - Content Type ID
        Returns:
        CMAContentType result instance
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
        java.lang.IllegalArgumentException - if environmentId is null.
        java.lang.IllegalArgumentException - if contentTypeId is null.
      • publish

        public CMAContentType publish​(CMAContentType contentType)
        Publish a Content Type.
        Parameters:
        contentType - Content Type
        Returns:
        CMAContentType result instance
        Throws:
        java.lang.IllegalArgumentException - if contentType is null.
        java.lang.IllegalArgumentException - if contentType's id is null.
        java.lang.IllegalArgumentException - if contentType's space id is null.
      • unPublish

        public CMAContentType unPublish​(CMAContentType contentType)
        Un-Publish a Content Type.
        Parameters:
        contentType - Content Type
        Returns:
        CMAContentType result instance
        Throws:
        java.lang.IllegalArgumentException - if contentType is null.
        java.lang.IllegalArgumentException - if contentType's id is null.
        java.lang.IllegalArgumentException - if contentType's space id is null.
      • update

        public CMAContentType update​(CMAContentType contentType)
        Update a Content Type.
        Parameters:
        contentType - Content Type
        Returns:
        CMAContentType result instance
        Throws:
        java.lang.IllegalArgumentException - if contentType is null.
        java.lang.IllegalArgumentException - if contentType's name is null.
        java.lang.IllegalArgumentException - if contentType's id is null.
        java.lang.IllegalArgumentException - if contentType's space id is null.
        java.lang.IllegalArgumentException - if contentType's version is null.
      • fetchAllSnapshots

        public CMAArray<CMASnapshot> fetchAllSnapshots​(CMAContentType contentType)
        Fetch all snapshots of this content type.
        Parameters:
        contentType - the contentType whose snapshots to be returned.
        Returns:
        an array of snapshots.
        Throws:
        java.lang.IllegalArgumentException - if contentType is null.
        java.lang.IllegalArgumentException - if contentType's id is null.
        java.lang.IllegalArgumentException - if contentType's space id is null.
      • fetchOneSnapshot

        public CMASnapshot fetchOneSnapshot​(CMAContentType contentType,
                                            java.lang.String snapshotId)
        Fetch a specific snapshot of this content type.
        Parameters:
        contentType - the contentType whose snapshot to be returned.
        snapshotId - the snapshot to be returned.
        Returns:
        an array of snapshots.
        Throws:
        java.lang.IllegalArgumentException - if contentType is null.
        java.lang.IllegalArgumentException - if contentType's id is null.
        java.lang.IllegalArgumentException - if contentType's space id is null.
        java.lang.IllegalArgumentException - if snapshotId is null.