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.
  • Field Details

  • Method Details

    • getMediaPackage

      Optional<org.opencastproject.mediapackage.MediaPackage> getMediaPackage(String mediaPackageId)
      Get the media package from the latest snapshot.
      Parameters:
      mediaPackageId -
      Returns:
      mediapackage
    • getAsset

      Optional<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

      Optional<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
    • getLatestSnapshot

      Optional<Snapshot> getLatestSnapshot(String mediaPackageId)
      Get the latest snapshot.
      Parameters:
      mediaPackageId -
      Returns:
      Snapshot
    • getLatestSnapshots

      List<Snapshot> getLatestSnapshots(Collection mediaPackageIds)
      Get the latest snapshots.
      Parameters:
      mediaPackageIds -
      Returns:
      Snapshot returns the latest snapshot for each given mediaPackageId
    • 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

      List<Snapshot> getSnapshotsById(String mpId)
      Returns a list of Snapshot filtered by mediapackage IDs
      Parameters:
      mpId - The mediapackage ID to filter results for
      Returns:
      The Snapshot list filtered by mediapackage ID
    • getSnapshotsByIdOrderedByVersion

      List<Snapshot> getSnapshotsByIdOrderedByVersion(String mpId, boolean asc)
      Returns a list of Snapshotfiltered 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 Snapshot list filtered by mediapackage ID
    • getSnapshotsByIdAndVersion

      List<Snapshot> getSnapshotsByIdAndVersion(String mpId, Version version)
      Returns a list of Snapshot filtered by mediapackage ID and version
      Parameters:
      mpId - The mediapackage ID to filter results for
      version - The version to filter results for
      Returns:
      The Snapshot list filtered by mediapackage ID
    • getSnapshotsByDateOrderedById

      List<Snapshot> getSnapshotsByDateOrderedById(Date start, Date end)
      Returns a list of Snapshot 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 Snapshot list filtered by date
    • getSnapshotsByIdAndDate

      List<Snapshot> getSnapshotsByIdAndDate(String mpId, Date start, Date end)
      Returns a list of Snapshot 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 Snapshot list filtered by date
    • getSnapshotsByIdAndDateOrderedByVersion

      List<Snapshot> getSnapshotsByIdAndDateOrderedByVersion(String mpId, Date start, Date end, boolean asc)
      Returns a list of Snapshot 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 Snapshot list filtered by date
    • getLatestSnapshotsBySeriesId

      List<Snapshot> getLatestSnapshotsBySeriesId(String seriesId)
      Get the latest snapshots from the series
      Parameters:
      seriesId - the id of the series
      Returns:
      a list of the latest snapshots from the series
    • getSnapshotByMpIdOrgIdAndVersion

      Optional<Snapshot> getSnapshotByMpIdOrgIdAndVersion(String mpId, String orgId, Version version)
      Gets a snapshot that confirms to the given parameters
      Parameters:
      mpId - the mediaPackageId
      orgId - the organizationId
      version - the version
      Returns:
    • deleteSnapshots

      int deleteSnapshots(String mpId)
      Remove all snapshots with the given mediaPackage id
      Parameters:
      mpId - the mediaPackage id
      Returns:
      the amount of snapshots removed
    • deleteAllButLatestSnapshot

      int deleteAllButLatestSnapshot(String mpId)
      Remove all snapshots with the given mediaPackage id, except for the snapshot with the highest version number
      Parameters:
      mpId - the mediaPackage id
      Returns:
      the amount of snapshots removed
    • 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
    • deletePropertiesWithCurrentUser

      int deletePropertiesWithCurrentUser(String mediaPackageId, String namespace)
      Delete all properties for a given media package identifier and namespace. Restricts access based on the current user
      Parameters:
      mediaPackageId - Media package identifier
      namespace - A namespace prefix to use for deletion
      Returns:
      Number of deleted properties
    • toVersion

      Optional<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. This may be `null` to not filter for an organization which is significantly faster.
      Returns:
      Number of events
    • countSnapshots

      long countSnapshots(String organization)
      Count the number of snapshots stored for a given organization.
      Parameters:
      organization - The organization to check
      Returns:
      Number of snapshots
    • countAssets

      long countAssets()
      Count the number of assets
      Returns:
      Number of assets
    • countProperties

      long countProperties()
      Count the number of properties
      Returns:
      Number of properties
    • triggerIndexUpdate

      void triggerIndexUpdate(String mediaPackageId) throws org.opencastproject.util.NotFoundException, org.opencastproject.security.api.UnauthorizedException
      Trigger search index update for event.
      Parameters:
      mediaPackageId - The event ID to trigger an index update for
      Throws:
      org.opencastproject.util.NotFoundException
      org.opencastproject.security.api.UnauthorizedException