Interface AssetManager


  • public interface AssetManager
    The AssetManager stores versioned snapshots of media packages.

    It also supports the association of properties to a history of snapshots which is called an episode.

    Terms

    Snapshot

    A snapshot saves a particular version of a media package. Snapshots are immutable and can only be deleted.

    Episode

    An episode is the set of snapshots of a media package.

    Properties

    Properties are associated with an episode and have a volatile character. They support the quick and easy storage of meta data. This removes the need for services to create their own persistence layer if they want to associate metadata with a media package.

    Notes

    Media package IDs are considered to be unique throughout the whole system. The organization ID is just a discriminator and not necessary to uniquely identify a media package.
    • Method Detail

      • getMediaPackage

        com.entwinemedia.fn.data.Opt<org.opencastproject.mediapackage.MediaPackage> getMediaPackage​(String mediaPackageId)
        Get the media package from the lates snapshot.
        Parameters:
        mediaPackageId -
        Returns:
        mediapackage
      • getAsset

        com.entwinemedia.fn.data.Opt<Asset> getAsset​(Version version,
                                                     String mpId,
                                                     String mpeId)
        Get the asset that is uniquely identified by the triple {version, media package ID, media package element ID}.
        Parameters:
        version - the version
        mpId - the media package ID
        mpeId - the media package element ID
        Returns:
        the asset or none, if no such asset exists
      • getAssetStore

        com.entwinemedia.fn.data.Opt<AssetStore> getAssetStore​(String storeId)
        Get an asset store by id (local or remote).
        Parameters:
        storeId - the store id
        Returns:
        the asset store if it exists
      • getRemoteAssetStores

        List<AssetStore> getRemoteAssetStores()
        Get the remote asset stores as a list.
        Returns:
        a list of asset stores
      • getLocalAssetStore

        AssetStore getLocalAssetStore()
        Get the local asset store.
        Returns:
        the asset store
      • snapshotExists

        boolean snapshotExists​(String mediaPackageId)
        Check if any snapshot with the given media package identifier exists.
        Parameters:
        mediaPackageId - The media package identifier to check for
        Returns:
        If a snapshot exists for the given media package
      • snapshotExists

        boolean snapshotExists​(String mediaPackageId,
                               String organization)
        Check if any snapshot with the given media package identifier exists.
        Parameters:
        mediaPackageId - The media package identifier to check for
        organization - The organization to limit the search to
        Returns:
        If a snapshot exists for the given media package
      • getSnapshotsById

        RichAResult getSnapshotsById​(String mpId)
        Returns a stream of RichAResult filtered by mediapackage IDs
        Parameters:
        mpId - The mediapackage ID to filter results for
        Returns:
        The RichAResult stream filtered by mediapackage ID
      • getSnapshotsByIdOrderedByVersion

        RichAResult getSnapshotsByIdOrderedByVersion​(String mpId,
                                                     boolean asc)
        Returns a stream of RichAResult filtered by mediapackage IDs. This stream consists of all versions of all mediapackage ordered by the Version
        Parameters:
        mpId - The mediapackage ID to filter results for
        asc - The asc Boolean decides if to order ascending (true) or descending (false)
        Returns:
        The RichAResult stream filtered by mediapackage ID
      • getSnapshotsByIdAndVersion

        RichAResult getSnapshotsByIdAndVersion​(String mpId,
                                               Version version)
        Returns a stream of RichAResult filtered by mediapackage ID and version
        Parameters:
        mpId - The mediapackage ID to filter results for
        version - The version to filter results for
        Returns:
        The RichAResult stream filtered by mediapackage ID
      • getSnapshotsByDate

        RichAResult getSnapshotsByDate​(Date start,
                                       Date end)
        Returns a stream of RichAResult filtered by date. This stream consists of all versions of all mediapackages archived within the date range.
        Parameters:
        start - The start Date to filter by
        end - The endDate to filter by
        Returns:
        The RichAResult stream filtered by date
      • getSnapshotsByDateOrderedById

        RichAResult getSnapshotsByDateOrderedById​(Date start,
                                                  Date end)
        Returns a stream of RichAResult filtered by date. This stream consists of all a mediapackages which have at least one version archived within the date range.
        Parameters:
        start - The start Date to filter by
        end - The endDate to filter by
        Returns:
        The RichAResult stream filtered by date
      • getSnapshotsByIdAndDate

        RichAResult getSnapshotsByIdAndDate​(String mpId,
                                            Date start,
                                            Date end)
        Returns a stream of RichAResult filtered by date and mediapackage. This stream consists of all versions of a mediapackage archived within the date range.
        Parameters:
        mpId - The mediapackage ID to filter for
        start - The start Date to filter by
        end - The endDate to filter by
        Returns:
        The RichAResult stream filtered by date
      • getSnapshotsByIdAndDateOrderedByVersion

        RichAResult getSnapshotsByIdAndDateOrderedByVersion​(String mpId,
                                                            Date start,
                                                            Date end,
                                                            boolean asc)
        Returns a stream of RichAResult filtered by date and mediapackage. This stream consists of all versions of a mediapackage archived within the date range ordered by there Version.
        Parameters:
        mpId - The mediapackage ID to filter for
        start - The start Date to filter by
        end - The end Date to filter by
        asc - The asc Boolean decides if to order ascending (true) or descending (false)
        Returns:
        The RichAResult stream filtered by date
      • takeSnapshot

        Snapshot takeSnapshot​(String owner,
                              org.opencastproject.mediapackage.MediaPackage mp)
        Take a versioned snapshot of a media package.

        Snapshot are tagged with string identifying the owner. Only the owner of a snapshot is allowed to delete it. Ownership only affects the deletion of a snapshot.

        Parameters:
        owner - the owner of the snapshot, e.g. the name of the calling service
      • takeSnapshot

        Snapshot takeSnapshot​(org.opencastproject.mediapackage.MediaPackage mediaPackage)
        Take a versioned snapshot of a media package using the owner of the last snapshot or the default owner if it does not exist.
        Parameters:
        mediaPackage - The media package to snapshot
        Returns:
        A new snapshot
      • moveSnapshotToStore

        void moveSnapshotToStore​(Version version,
                                 String mpId,
                                 String storeId)
                          throws org.opencastproject.util.NotFoundException
        Move snapshot from current store to new store Note: This may require downloading and re-uploading
        Parameters:
        version - The version to move
        mpId - The media package to move
        storeId - The store to move to
        Throws:
        org.opencastproject.util.NotFoundException
      • moveSnapshotsById

        void moveSnapshotsById​(String mpId,
                               String targetStore)
                        throws org.opencastproject.util.NotFoundException
        Moves all versions of a given mediapackage ID from their respective source stores to a single target store
        Parameters:
        mpId - The mediapackage ID to move
        targetStore - The store ID to move all versions of this mediapackage to
        Throws:
        org.opencastproject.util.NotFoundException
      • moveSnapshotsByIdAndVersion

        void moveSnapshotsByIdAndVersion​(String mpId,
                                         Version version,
                                         String targetStore)
                                  throws org.opencastproject.util.NotFoundException
        Moves a specific version of a given mediapackage ID to a new store
        Parameters:
        mpId - The mediapackage ID to move
        version - The version to move
        targetStore - The store ID to move this version of the mediapackage to
        Throws:
        org.opencastproject.util.NotFoundException
      • moveSnapshotsByDate

        void moveSnapshotsByDate​(Date start,
                                 Date end,
                                 String targetStore)
                          throws org.opencastproject.util.NotFoundException
        Moves all versions of all mediapackages archived within a data range to a new storage location.
        Parameters:
        start - The start Date to filter by
        end - The endDate to filter by
        targetStore - THe store ID to move the snapshots to
        Throws:
        org.opencastproject.util.NotFoundException
      • moveSnapshotsByIdAndDate

        void moveSnapshotsByIdAndDate​(String mpId,
                                      Date start,
                                      Date end,
                                      String targetStore)
                               throws org.opencastproject.util.NotFoundException
        Moves all versions of a mediapackage archived within a data range to a new storage location.
        Parameters:
        mpId - The mediapackage ID to filter for
        start - The start Date to filter by
        end - The endDate to filter by
        targetStore - THe store ID to move the snapshots to
        Throws:
        org.opencastproject.util.NotFoundException
      • setProperty

        boolean setProperty​(Property property)
        Set a property. Use this method to either insert a new property or update an existing one. Properties are stored per episode.
        Returns:
        false, if the referenced episode does not exist.
      • selectProperties

        List<Property> selectProperties​(String mediaPackageId,
                                        String namespace)
        Select all properties for a specific media package.
        Parameters:
        mediaPackageId - Media package identifier to check for
        namespace - Namespace to limit the search to
        Returns:
        List of properties
      • deleteProperties

        int deleteProperties​(String mediaPackageId)
        Delete all properties for a given media package identifier
        Parameters:
        mediaPackageId - Media package identifier
        Returns:
        Number of deleted properties
      • deleteProperties

        int deleteProperties​(String mediaPackageId,
                             String namespace)
        Delete all properties for a given media package identifier and namespace.
        Parameters:
        mediaPackageId - Media package identifier
        namespace - A namespace prefix to use for deletion
        Returns:
        Number of deleted properties
      • createQuery

        AQueryBuilder createQuery()
        Create a new query builder.
      • toVersion

        com.entwinemedia.fn.data.Opt<Version> toVersion​(String version)
        Deserialize a version from a string. This is the inverse function of Version.toString().
        Returns:
        a version or none, if no version can be archived from the given string
      • countEvents

        long countEvents​(String organization)
        Count the number of events stored for a given organization.
        Parameters:
        organization - The organization to check
        Returns:
        Number of events