Class Container


  • public class Container
    extends java.lang.Object

    A representation of a container. A container virtually groups a number of blobs under the same Account, so that an operation on a container can be applied to all the blobs of the container. When posting a blob, a container needs to be specified. There can be multiple containers under the the same Account, but containers cannot be nested.

    Container name is provided by a user as an external reference to that container. Container id is an internal identifier of the container, and is one-to-one mapped to a container name. Container name/id has to be distinct within the same Account, but can be the same across different Accounts.

    Container is serialized into JSONObject in the currentJsonVersion, which is version 1 for now. Below lists all the metadata versions and their formats:

    
      {
        "containerName": "MyPrivateContainer",
        "description": "This is my private container",
        "isPrivate": "true",
        "containerId": 0,
        "version": 1,
        "status": "active"
        "parentAccountId": "101"
      }
      

    A container object is immutable. To update a container, refer to ContainerBuilder and AccountBuilder.

    • Field Detail

      • HELIX_ACCOUNT_SERVICE_CONTAINER_ID

        public static final short HELIX_ACCOUNT_SERVICE_CONTAINER_ID
        The id for HelixAccountService to store Account metadata.
        See Also:
        Constant Field Values
      • DEFAULT_PUBLIC_CONTAINER_ID

        public static final short DEFAULT_PUBLIC_CONTAINER_ID
        The id for the containers to be associated with the blobs that are put without specifying a target container, but are specified public. DEFAULT_PUBLIC_CONTAINER is one of the containers that use it.
        See Also:
        Constant Field Values
      • DEFAULT_PRIVATE_CONTAINER_ID

        public static final short DEFAULT_PRIVATE_CONTAINER_ID
        The id for the containers to be associated with the blobs that are put without specifying a target container, but are specified private. DEFAULT_PRIVATE_CONTAINER is one of the containers that use it.
        See Also:
        Constant Field Values
      • DEFAULT_PUBLIC_CONTAINER_NAME

        public static final java.lang.String DEFAULT_PUBLIC_CONTAINER_NAME
        The name for the containers to be associated with the blobs that are put without specifying a target container, but are specified public. DEFAULT_PUBLIC_CONTAINER is one of the containers that use it.
        See Also:
        Constant Field Values
      • DEFAULT_PRIVATE_CONTAINER_NAME

        public static final java.lang.String DEFAULT_PRIVATE_CONTAINER_NAME
        The name for the containers to be associated with the blobs that are put without specifying a target container, but are specified private. DEFAULT_PRIVATE_CONTAINER is one of the containers that use it.
        See Also:
        Constant Field Values
      • DEFAULT_PUBLIC_CONTAINER_STATUS

        public static final Container.ContainerStatus DEFAULT_PUBLIC_CONTAINER_STATUS
        The status for the containers to be associated with the blobs that are put without specifying a target container, but are specified public. DEFAULT_PUBLIC_CONTAINER is one of the containers that use it.
      • DEFAULT_PRIVATE_CONTAINER_STATUS

        public static final Container.ContainerStatus DEFAULT_PRIVATE_CONTAINER_STATUS
        The status for the containers to be associated with the blobs that are put without specifying a target container, but are specified private. DEFAULT_PRIVATE_CONTAINER is one of the containers that use it.
      • DEFAULT_PUBLIC_CONTAINER_DESCRIPTION

        public static final java.lang.String DEFAULT_PUBLIC_CONTAINER_DESCRIPTION
        The description for the containers to be associated with the blobs that are put without specifying a target container, but are specified public. DEFAULT_PUBLIC_CONTAINER is one of the containers that use it.
        See Also:
        Constant Field Values
      • DEFAULT_PRIVATE_CONTAINER_DESCRIPTION

        public static final java.lang.String DEFAULT_PRIVATE_CONTAINER_DESCRIPTION
        The description for the containers to be associated with the blobs that are put without specifying a target container, but are specified private. DEFAULT_PRIVATE_CONTAINER is one of the containers that use it.
        See Also:
        Constant Field Values
      • UNKNOWN_CONTAINER_PREVIOUSLY_ENCRYPTED_SETTING

        public static final boolean UNKNOWN_CONTAINER_PREVIOUSLY_ENCRYPTED_SETTING
        The previously encrypted flag for UNKNOWN_CONTAINER.
        See Also:
        Constant Field Values
      • DEFAULT_PUBLIC_CONTAINER_PREVIOUSLY_ENCRYPTED_SETTING

        public static final boolean DEFAULT_PUBLIC_CONTAINER_PREVIOUSLY_ENCRYPTED_SETTING
        The previously encrypted flag for DEFAULT_PUBLIC_CONTAINER.
        See Also:
        Constant Field Values
      • DEFAULT_PRIVATE_CONTAINER_PREVIOUSLY_ENCRYPTED_SETTING

        public static final boolean DEFAULT_PRIVATE_CONTAINER_PREVIOUSLY_ENCRYPTED_SETTING
        The previously encrypted flag for DEFAULT_PRIVATE_CONTAINER.
        See Also:
        Constant Field Values
      • UNKNOWN_CONTAINER_MEDIA_SCAN_DISABLED_SETTING

        public static final boolean UNKNOWN_CONTAINER_MEDIA_SCAN_DISABLED_SETTING
        The media scan disabled setting for UNKNOWN_CONTAINER.
        See Also:
        Constant Field Values
      • DEFAULT_PUBLIC_CONTAINER_MEDIA_SCAN_DISABLED_SETTING

        public static final boolean DEFAULT_PUBLIC_CONTAINER_MEDIA_SCAN_DISABLED_SETTING
        The media scan disabled setting for DEFAULT_PUBLIC_CONTAINER.
        See Also:
        Constant Field Values
      • DEFAULT_PRIVATE_CONTAINER_MEDIA_SCAN_DISABLED_SETTING

        public static final boolean DEFAULT_PRIVATE_CONTAINER_MEDIA_SCAN_DISABLED_SETTING
        The media scan disabled setting for DEFAULT_PRIVATE_CONTAINER.
        See Also:
        Constant Field Values
      • UNKNOWN_CONTAINER

        @Deprecated
        public static final Container UNKNOWN_CONTAINER
        Deprecated.
        A container defined specifically for the blobs put without specifying target account and container. In the pre-containerization world, a put-blob request does not carry any information which account/container to store the blob. These blobs are literally put into this container, because the target container information is unknown. DO NOT USE IN PRODUCTION CODE.
      • DEFAULT_PUBLIC_CONTAINER

        @Deprecated
        public static final Container DEFAULT_PUBLIC_CONTAINER
        Deprecated.
        A container defined specifically for the blobs put without specifying target container but isPrivate flag is set to false. DO NOT USE IN PRODUCTION CODE.
      • DEFAULT_PRIVATE_CONTAINER

        @Deprecated
        public static final Container DEFAULT_PRIVATE_CONTAINER
        Deprecated.
        A container defined specifically for the blobs put without specifying target container but isPrivate flag is set to true. DO NOT USE IN PRODUCTION CODE.
    • Method Detail

      • getCurrentJsonVersion

        public static short getCurrentJsonVersion()
        Returns:
        the JSON version to serialize in.
      • setCurrentJsonVersion

        public static void setCurrentJsonVersion​(short currentJsonVersion)
        Set the JSON version to serialize in. Note that this is a static setting that will affect all Container serialization.
        Parameters:
        currentJsonVersion - the JSON version to serialize in.
      • fromJson

        public static Container fromJson​(org.json.JSONObject json,
                                         short parentAccountId)
                                  throws org.json.JSONException
        Deserializes a JSONObject to a container object.
        Parameters:
        json - The JSONObject to deserialize.
        parentAccountId - The ID of the parent Account of this container. This is passed in because it is not always included in the JSON record.
        Returns:
        A container object deserialized from the JSONObject.
        Throws:
        org.json.JSONException - If parsing the JSONObject fails.
      • toJson

        public org.json.JSONObject toJson()
                                   throws org.json.JSONException
        Gets the metadata of the container.
        Returns:
        The metadata of the container.
        Throws:
        org.json.JSONException - If fails to compose metadata.
      • getId

        public short getId()
        Gets the id of the container.
        Returns:
        The id of the container.
      • getName

        public java.lang.String getName()
        Gets the name of the container.
        Returns:
        The name of the container.
      • getStatus

        public Container.ContainerStatus getStatus()
        Gets the status of the container.
        Returns:
        The status of the container.
      • getDeleteTriggerTime

        public java.lang.Long getDeleteTriggerTime()
        Gets the delete trigger time of the container.
        Returns:
        The delete trigger time of the container.
      • getDescription

        public java.lang.String getDescription()
        Gets the description of the container.
        Returns:
        The description of the container.
      • isEncrypted

        public boolean isEncrypted()
        Returns:
        true if blobs in the Container should be encrypted, false otherwise.
      • isBackupEnabled

        public boolean isBackupEnabled()
        Returns:
        true if blobs in the Container should be backed up, false otherwise.
      • wasPreviouslyEncrypted

        public boolean wasPreviouslyEncrypted()
        Returns:
        true if this Container was encrypted in the past, and a subset of blobs in it could still be encrypted.
      • isCacheable

        public boolean isCacheable()
        Returns:
        true if cache control headers should be set to allow CDNs and browsers to cache blobs in this container.
      • isMediaScanDisabled

        public boolean isMediaScanDisabled()
        Returns:
        true if media scans should be disabled on content created in this container.
      • getReplicationPolicy

        public java.lang.String getReplicationPolicy()
        Returns:
        the replication policy desired by the container. Can be null if the container has no preference.
      • isTtlRequired

        public boolean isTtlRequired()
        Returns:
        true if ttl is required on content created in this container.
      • getContentTypeWhitelistForFilenamesOnDownload

        public java.util.Set<java.lang.String> getContentTypeWhitelistForFilenamesOnDownload()
        Returns:
        the set of content types for which the filename can be sent on download
      • isSecurePathRequired

        public boolean isSecurePathRequired()
        Returns:
        true if secure path validation is required for url to access blobs in this container.
      • getParentAccountId

        public short getParentAccountId()
        Gets the if of the Account that owns this container.
        Returns:
        The id of the parent Account of this container.
      • getLastModifiedTime

        public long getLastModifiedTime()
        Get the created/modified time of this Container
        Returns:
        epoch time in milliseconds
      • getSnapshotVersion

        public int getSnapshotVersion()
        The snapshot version is generally the number of modifications to the container that were expected to have occurred before the current time. This is used to validate that there were no unexpected container modifications that could be inadvertently overwritten by an container update.
        Returns:
        the expected version for the container record.
      • toString

        public java.lang.String toString()
        Generates a String representation that uniquely identifies this container. The string is in the format of Container[accountId:containerId].
        Overrides:
        toString in class java.lang.Object
        Returns:
        The String representation of this container.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object