Class AssetManagerImpl
java.lang.Object
org.opencastproject.elasticsearch.index.rebuild.AbstractIndexProducer
org.opencastproject.assetmanager.impl.AssetManagerImpl
- All Implemented Interfaces:
AssetManager,IndexProducer
The Asset Manager implementation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Set<MediaPackageElement.Type> static final Stringstatic final Stringstatic final StringFields inherited from interface org.opencastproject.assetmanager.api.AssetManager
DEFAULT_OWNER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) OSGi callback.voidaddCatalogUIAdapter(EventCatalogUIAdapter catalogUIAdapter) voidaddRemoteAssetStore(RemoteAssetStore assetStore) longCount the number of assetslongcountEvents(String organization) Count the number of events stored for a given organization.longCount the number of propertieslongcountSnapshots(String organization) Count the number of snapshots stored for a given organization.intRemove all snapshots with the given mediaPackage id, except for the snapshot with the highest version numberintdeleteProperties(String mediaPackageId) Delete all properties for a given media package identifierintdeleteProperties(String mediaPackageId, String namespace) Delete all properties for a given media package identifier and namespace.intdeletePropertiesWithCurrentUser(String mediaPackageId, String namespace) Delete all properties for a given media package identifier and namespace.intdeleteSnapshots(String mpId) Remove all snapshots with the given mediaPackage idGet the asset that is uniquely identified by the triple {version, media package ID, media package element ID}.getAssetStore(String storeId) Get an asset store by id (local or remote).Extract the file name from a media package elements URN.getLatestSnapshot(String mediaPackageId) Get the latest snapshot.getLatestSnapshots(Collection mediaPackageIds) Get the latest snapshots.getLatestSnapshotsBySeriesId(String seriesId) Get the latest snapshots from the seriesGet the local asset store.getMediaPackage(String mediaPackageId) AssetManager implementationGet the remote asset stores as a list.AbstractIndexProducer ImplementationgetSnapshotByMpIdOrgIdAndVersion(String mpId, String orgId, Version version) Gets a snapshot that confirms to the given parametersgetSnapshotsByDateOrderedById(Date start, Date end) Returns a list ofSnapshotfiltered by date.getSnapshotsById(String mpId) Returns a list ofSnapshotfiltered by mediapackage IDsgetSnapshotsByIdAndDate(String mpId, Date start, Date end) Returns a list ofSnapshotfiltered by date and mediapackage.getSnapshotsByIdAndDateOrderedByVersion(String mpId, Date start, Date end, boolean asc) Returns a list ofSnapshotfiltered by date and mediapackage.getSnapshotsByIdAndVersion(String mpId, Version version) Returns a list ofSnapshotfiltered by mediapackage ID and versiongetSnapshotsByIdOrderedByVersion(String mpId, boolean asc) Returns a list ofSnapshotfiltered by mediapackage IDs.getSnapshotStorageLocation(Version version, String mpId) Get supported data types for reindexing.voidmoveSnapshotsByDate(Date start, Date end, String targetStore) Moves all versions of all mediapackages archived within a data range to a new storage location.voidmoveSnapshotsById(String mpId, String targetStore) Moves all versions of a given mediapackage ID from their respective source stores to a single target storevoidmoveSnapshotsByIdAndDate(String mpId, Date start, Date end, String targetStore) Moves all versions of a mediapackage archived within a data range to a new storage location.voidmoveSnapshotsByIdAndVersion(String mpId, Version version, String targetStore) Moves a specific version of a given mediapackage ID to a new storevoidmoveSnapshotToStore(Version version, String mpId, String storeId) Move snapshot from current store to new store Note: This may require downloading and re-uploadingvoidremoveCatalogUIAdapter(EventCatalogUIAdapter catalogUIAdapter) voidvoidrepopulate(IndexRebuildService.DataType dataType) Re-add the data of this service to the index.static SnapshotrewriteUris(Snapshot snapshot, Function<MediaPackageElement, URI> uriCreator) Rewrite URIs of all asset elements of a snapshot's media package.selectProperties(String mediaPackageId, String namespace) Select all properties for a specific media package.voidsetAclServiceFactory(AclServiceFactory aclServiceFactory) voidsetAssetStore(AssetStore assetStore) voidsetAuthorizationService(AuthorizationService authorizationService) voidsetAvailability(Version version, String mpId, Availability availability) Used for testingvoidsetDatabase(Database database) voidsetDBSessionFactory(DBSessionFactory dbSessionFactory) voidsetEntityManagerFactory(javax.persistence.EntityManagerFactory emf) OSGi dependenciesvoidsetHttpAssetProvider(HttpAssetProvider httpAssetProvider) voidsetIndex(ElasticsearchIndex index) voidbooleansetProperty(Property property) PropertiesvoidsetSecurityService(SecurityService securityService) voidsetWorkspace(Workspace workspace) booleansnapshotExists(String mediaPackageId) SnapshotsbooleansnapshotExists(String mediaPackageId, String organization) Check if any snapshot with the given media package identifier exists.takeSnapshot(String owner, MediaPackage mp) Take a versioned snapshot of a media package.Take a versioned snapshot of a media package using the owner of the last snapshot or the default owner if it does not exist.Misc.voidtriggerIndexUpdate(String mediaPackageId) Trigger search index update for event.Methods inherited from class org.opencastproject.elasticsearch.index.rebuild.AbstractIndexProducer
logIndexRebuildBegin, logIndexRebuildBegin, logIndexRebuildError, logIndexRebuildError, logIndexRebuildError, logIndexRebuildProgress, logIndexRebuildProgress, logIndexRebuildProgress, logIndexRebuildProgress, logSkippingElement, logSkippingElementMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opencastproject.elasticsearch.index.rebuild.IndexProducer
dataTypeSupported
-
Field Details
-
WRITE_ACTION
- See Also:
-
READ_ACTION
- See Also:
-
SECURITY_NAMESPACE
- See Also:
-
MOVABLE_TYPES
-
-
Constructor Details
-
AssetManagerImpl
public AssetManagerImpl()
-
-
Method Details
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) OSGi callback. -
setEntityManagerFactory
public void setEntityManagerFactory(javax.persistence.EntityManagerFactory emf) OSGi dependencies -
setDBSessionFactory
-
setSecurityService
-
setAuthorizationService
-
setOrgDir
-
setWorkspace
-
setAssetStore
-
addRemoteAssetStore
-
removeRemoteAssetStore
-
setHttpAssetProvider
-
setAclServiceFactory
-
setIndex
-
addCatalogUIAdapter
-
removeCatalogUIAdapter
-
getMediaPackage
AssetManager implementation- Specified by:
getMediaPackagein interfaceAssetManager- Parameters:
mediaPackageId-- Returns:
- mediapackage
-
getLatestSnapshots
Description copied from interface:AssetManagerGet the latest snapshots.- Specified by:
getLatestSnapshotsin interfaceAssetManager- Parameters:
mediaPackageIds-- Returns:
- Snapshot returns the latest snapshot for each given mediaPackageId
-
getLatestSnapshot
Description copied from interface:AssetManagerGet the latest snapshot.- Specified by:
getLatestSnapshotin interfaceAssetManager- Parameters:
mediaPackageId-- Returns:
- Snapshot
-
getAsset
Description copied from interface:AssetManagerGet the asset that is uniquely identified by the triple {version, media package ID, media package element ID}.- Specified by:
getAssetin interfaceAssetManager- Parameters:
version- the versionmpId- the media package IDmpElementId- the media package element ID- Returns:
- the asset or none, if no such asset exists
-
getAssetStore
Description copied from interface:AssetManagerGet an asset store by id (local or remote).- Specified by:
getAssetStorein interfaceAssetManager- Parameters:
storeId- the store id- Returns:
- the asset store if it exists
-
getLocalAssetStore
Description copied from interface:AssetManagerGet the local asset store.- Specified by:
getLocalAssetStorein interfaceAssetManager- Returns:
- the asset store
-
getRemoteAssetStores
Description copied from interface:AssetManagerGet the remote asset stores as a list.- Specified by:
getRemoteAssetStoresin interfaceAssetManager- Returns:
- a list of asset stores
-
snapshotExists
Snapshots- Specified by:
snapshotExistsin interfaceAssetManager- Parameters:
mediaPackageId- The media package identifier to check for- Returns:
- If a snapshot exists for the given media package
-
snapshotExists
Description copied from interface:AssetManagerCheck if any snapshot with the given media package identifier exists.- Specified by:
snapshotExistsin interfaceAssetManager- Parameters:
mediaPackageId- The media package identifier to check fororganization- The organization to limit the search to- Returns:
- If a snapshot exists for the given media package
-
takeSnapshot
Description copied from interface:AssetManagerTake a versioned snapshot of a media package using the owner of the last snapshot or the default owner if it does not exist.- Specified by:
takeSnapshotin interfaceAssetManager- Parameters:
mp- The media package to snapshot- Returns:
- A new snapshot
-
takeSnapshot
Description copied from interface:AssetManagerTake 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.
- Specified by:
takeSnapshotin interfaceAssetManager- Parameters:
owner- the owner of the snapshot, e.g. the name of the calling service
-
triggerIndexUpdate
public void triggerIndexUpdate(String mediaPackageId) throws NotFoundException, UnauthorizedException Description copied from interface:AssetManagerTrigger search index update for event.- Specified by:
triggerIndexUpdatein interfaceAssetManager- Parameters:
mediaPackageId- The event ID to trigger an index update for- Throws:
NotFoundExceptionUnauthorizedException
-
getSnapshotsById
Description copied from interface:AssetManagerReturns a list ofSnapshotfiltered by mediapackage IDs- Specified by:
getSnapshotsByIdin interfaceAssetManager- Parameters:
mpId- The mediapackage ID to filter results for- Returns:
- The
Snapshotlist filtered by mediapackage ID
-
getSnapshotsByIdOrderedByVersion
Description copied from interface:AssetManagerReturns a list ofSnapshotfiltered by mediapackage IDs. This stream consists of all versions of all mediapackage ordered by the Version- Specified by:
getSnapshotsByIdOrderedByVersionin interfaceAssetManager- Parameters:
mpId- The mediapackage ID to filter results forasc- The ascBooleandecides if to order ascending (true) or descending (false)- Returns:
- The
Snapshotlist filtered by mediapackage ID
-
getSnapshotsByIdAndVersion
Description copied from interface:AssetManagerReturns a list ofSnapshotfiltered by mediapackage ID and version- Specified by:
getSnapshotsByIdAndVersionin interfaceAssetManager- Parameters:
mpId- The mediapackage ID to filter results forversion- The version to filter results for- Returns:
- The
Snapshotlist filtered by mediapackage ID
-
getSnapshotsByDateOrderedById
Description copied from interface:AssetManagerReturns a list ofSnapshotfiltered by date. This stream consists of all a mediapackages which have at least one version archived within the date range.- Specified by:
getSnapshotsByDateOrderedByIdin interfaceAssetManager- Parameters:
start- The startDateto filter byend- The endDateto filter by- Returns:
- The
Snapshotlist filtered by date
-
getSnapshotsByIdAndDate
Description copied from interface:AssetManagerReturns a list ofSnapshotfiltered by date and mediapackage. This stream consists of all versions of a mediapackage archived within the date range.- Specified by:
getSnapshotsByIdAndDatein interfaceAssetManager- Parameters:
mpId- The mediapackage ID to filter forstart- The startDateto filter byend- The endDateto filter by- Returns:
- The
Snapshotlist filtered by date
-
getSnapshotsByIdAndDateOrderedByVersion
public List<Snapshot> getSnapshotsByIdAndDateOrderedByVersion(String mpId, Date start, Date end, boolean asc) Description copied from interface:AssetManagerReturns a list ofSnapshotfiltered by date and mediapackage. This stream consists of all versions of a mediapackage archived within the date range ordered by there Version.- Specified by:
getSnapshotsByIdAndDateOrderedByVersionin interfaceAssetManager- Parameters:
mpId- The mediapackage ID to filter forstart- The startDateto filter byend- The endDateto filter byasc- The ascBooleandecides if to order ascending (true) or descending (false)- Returns:
- The
Snapshotlist filtered by date
-
getLatestSnapshotsBySeriesId
Description copied from interface:AssetManagerGet the latest snapshots from the series- Specified by:
getLatestSnapshotsBySeriesIdin interfaceAssetManager- Parameters:
seriesId- the id of the series- Returns:
- a list of the latest snapshots from the series
-
getSnapshotByMpIdOrgIdAndVersion
public Optional<Snapshot> getSnapshotByMpIdOrgIdAndVersion(String mpId, String orgId, Version version) Description copied from interface:AssetManagerGets a snapshot that confirms to the given parameters- Specified by:
getSnapshotByMpIdOrgIdAndVersionin interfaceAssetManager- Parameters:
mpId- the mediaPackageIdorgId- the organizationIdversion- the version- Returns:
-
deleteSnapshots
Description copied from interface:AssetManagerRemove all snapshots with the given mediaPackage id- Specified by:
deleteSnapshotsin interfaceAssetManager- Parameters:
mpId- the mediaPackage id- Returns:
- the amount of snapshots removed
-
deleteAllButLatestSnapshot
Description copied from interface:AssetManagerRemove all snapshots with the given mediaPackage id, except for the snapshot with the highest version number- Specified by:
deleteAllButLatestSnapshotin interfaceAssetManager- Parameters:
mpId- the mediaPackage id- Returns:
- the amount of snapshots removed
-
moveSnapshotsById
Description copied from interface:AssetManagerMoves all versions of a given mediapackage ID from their respective source stores to a single target store- Specified by:
moveSnapshotsByIdin interfaceAssetManager- Parameters:
mpId- The mediapackage ID to movetargetStore- The store ID to move all versions of this mediapackage to- Throws:
NotFoundException
-
moveSnapshotsByIdAndVersion
public void moveSnapshotsByIdAndVersion(String mpId, Version version, String targetStore) throws NotFoundException Description copied from interface:AssetManagerMoves a specific version of a given mediapackage ID to a new store- Specified by:
moveSnapshotsByIdAndVersionin interfaceAssetManager- Parameters:
mpId- The mediapackage ID to moveversion- The version to movetargetStore- The store ID to move this version of the mediapackage to- Throws:
NotFoundException
-
moveSnapshotsByDate
Description copied from interface:AssetManagerMoves all versions of all mediapackages archived within a data range to a new storage location.- Specified by:
moveSnapshotsByDatein interfaceAssetManager- Parameters:
start- The startDateto filter byend- The endDateto filter bytargetStore- THe store ID to move the snapshots to- Throws:
NotFoundException
-
moveSnapshotsByIdAndDate
public void moveSnapshotsByIdAndDate(String mpId, Date start, Date end, String targetStore) throws NotFoundException Description copied from interface:AssetManagerMoves all versions of a mediapackage archived within a data range to a new storage location.- Specified by:
moveSnapshotsByIdAndDatein interfaceAssetManager- Parameters:
mpId- The mediapackage ID to filter forstart- The startDateto filter byend- The endDateto filter bytargetStore- THe store ID to move the snapshots to- Throws:
NotFoundException
-
moveSnapshotToStore
public void moveSnapshotToStore(Version version, String mpId, String storeId) throws NotFoundException Description copied from interface:AssetManagerMove snapshot from current store to new store Note: This may require downloading and re-uploading- Specified by:
moveSnapshotToStorein interfaceAssetManager- Parameters:
version- The version to movempId- The media package to movestoreId- The store to move to- Throws:
NotFoundException
-
getSnapshotStorageLocation
-
getSnapshotStorageLocation
-
setProperty
Properties- Specified by:
setPropertyin interfaceAssetManager- Returns:
- false, if the referenced episode does not exist.
-
selectProperties
Description copied from interface:AssetManagerSelect all properties for a specific media package.- Specified by:
selectPropertiesin interfaceAssetManager- Parameters:
mediaPackageId- Media package identifier to check fornamespace- Namespace to limit the search to- Returns:
- List of properties
-
deleteProperties
Description copied from interface:AssetManagerDelete all properties for a given media package identifier- Specified by:
deletePropertiesin interfaceAssetManager- Parameters:
mediaPackageId- Media package identifier- Returns:
- Number of deleted properties
-
deleteProperties
Description copied from interface:AssetManagerDelete all properties for a given media package identifier and namespace.- Specified by:
deletePropertiesin interfaceAssetManager- Parameters:
mediaPackageId- Media package identifiernamespace- A namespace prefix to use for deletion- Returns:
- Number of deleted properties
-
deletePropertiesWithCurrentUser
Description copied from interface:AssetManagerDelete all properties for a given media package identifier and namespace. Restricts access based on the current user- Specified by:
deletePropertiesWithCurrentUserin interfaceAssetManager- Parameters:
mediaPackageId- Media package identifiernamespace- A namespace prefix to use for deletion- Returns:
- Number of deleted properties
-
toVersion
Misc.- Specified by:
toVersionin interfaceAssetManager- Returns:
- a version or none, if no version can be archived from the given string
-
countEvents
Description copied from interface:AssetManagerCount the number of events stored for a given organization.- Specified by:
countEventsin interfaceAssetManager- 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
Description copied from interface:AssetManagerCount the number of snapshots stored for a given organization.- Specified by:
countSnapshotsin interfaceAssetManager- Parameters:
organization- The organization to check- Returns:
- Number of snapshots
-
countAssets
public long countAssets()Description copied from interface:AssetManagerCount the number of assets- Specified by:
countAssetsin interfaceAssetManager- Returns:
- Number of assets
-
countProperties
public long countProperties()Description copied from interface:AssetManagerCount the number of properties- Specified by:
countPropertiesin interfaceAssetManager- Returns:
- Number of properties
-
getService
AbstractIndexProducer Implementation- Specified by:
getServicein interfaceIndexProducer- Returns:
- service The service that implements IndexProducer.
-
getSupportedDataTypes
Description copied from interface:IndexProducerGet supported data types for reindexing. Default: All. Should be overridden if a service offers partial index rebuilds.- Specified by:
getSupportedDataTypesin interfaceIndexProducer- Returns:
- Array of supported data types
-
repopulate
Description copied from interface:IndexProducerRe-add the data of this service to the index.- Specified by:
repopulatein interfaceIndexProducer- Parameters:
dataType- Limit the data added to the index. Use ALL to re-index all data.- Throws:
IndexRebuildException
-
setAvailability
Used for testing -
setDatabase
-
getDatabase
-
getHttpAssetProvider
-
getFileNameFromUrn
Extract the file name from a media package elements URN.- Returns:
- the file name or none if it could not be determined
-
rewriteUris
Rewrite URIs of all asset elements of a snapshot's media package. This method does not mutate anything.
-