Class SearchServiceDatabaseImpl
java.lang.Object
org.opencastproject.search.impl.persistence.SearchServiceDatabaseImpl
- All Implemented Interfaces:
SearchServiceDatabase
Implements
SearchServiceDatabase. Defines permanent storage for series.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DBSessionprotected DBSessionFactoryprotected javax.persistence.EntityManagerFactoryFactory used to createEntityManagers for transactionsstatic final StringJPA persistence unit nameprotected SecurityServiceThe security service -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) CreatesEntityManagerFactoryusing persistence provider and properties passed via OSGi.intReturns the number of mediapackages in persistent storage, including deleted entries.voiddeleteMediaPackage(String mediaPackageId, Date deletionDate) Removes media package from persistent storage.getAccessControlList(String mediaPackageId) Retrieves ACL for episode with given ID.Collection<org.apache.commons.lang3.tuple.Pair<String, AccessControlList>> getAccessControlLists(String seriesId, String... excludeIds) Retrieves ACLs for series with given ID.getAllMediaPackages(int pagesize, int offset) Returns all search entries in persistent storage.getDeletionDate(String mediaPackageId) Returns the deletion date from the selected media package.getMediaPackage(String mediaPackageId) Gets a single media package by its identifier.getModificationDate(String mediaPackageId) Returns the modification date from the selected media package.getOrganizationId(String mediaPackageId) Returns the organization id of the selected media packageCollection<org.apache.commons.lang3.tuple.Pair<Organization, MediaPackage>> Gets media packages from a specific seriesbooleanisAvailable(String mediaPackageId) Checks if a mediapackage is available.voidsetDBSessionFactory(DBSessionFactory dbSessionFactory) voidsetEntityManagerFactory(javax.persistence.EntityManagerFactory emf) OSGi DIvoidsetSecurityService(SecurityService securityService) OSGi callback to set the security service.voidstoreMediaPackage(MediaPackage mediaPackage, AccessControlList acl, Date now) Store (or update) media package.
-
Field Details
-
PERSISTENCE_UNIT
JPA persistence unit name- See Also:
-
emf
protected javax.persistence.EntityManagerFactory emfFactory used to createEntityManagers for transactions -
dbSessionFactory
-
db
-
securityService
The security service
-
-
Constructor Details
-
SearchServiceDatabaseImpl
public SearchServiceDatabaseImpl()
-
-
Method Details
-
setEntityManagerFactory
public void setEntityManagerFactory(javax.persistence.EntityManagerFactory emf) OSGi DI -
setDBSessionFactory
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) throws SearchServiceDatabaseException CreatesEntityManagerFactoryusing persistence provider and properties passed via OSGi.- Parameters:
cc-- Throws:
SearchServiceDatabaseException
-
setSecurityService
OSGi callback to set the security service.- Parameters:
securityService- the securityService to set
-
deleteMediaPackage
public void deleteMediaPackage(String mediaPackageId, Date deletionDate) throws SearchServiceDatabaseException, NotFoundException, UnauthorizedException Removes media package from persistent storage.- Specified by:
deleteMediaPackagein interfaceSearchServiceDatabase- Parameters:
mediaPackageId- id of the media package to be removeddeletionDate- the deletion date to set- Throws:
SearchServiceDatabaseException- if exception occursNotFoundException- if media package with specified id is not foundUnauthorizedException- if the current user is not authorized to perform this action- See Also:
-
countMediaPackages
Returns the number of mediapackages in persistent storage, including deleted entries.- Specified by:
countMediaPackagesin interfaceSearchServiceDatabase- Returns:
- the number of mediapackages in storage
- Throws:
SearchServiceDatabaseException- if an error occurs- See Also:
-
getAllMediaPackages
public Stream<Tuple<MediaPackage,String>> getAllMediaPackages(int pagesize, int offset) throws SearchServiceDatabaseException Returns all search entries in persistent storage.- Specified by:
getAllMediaPackagesin interfaceSearchServiceDatabase- Parameters:
pagesize- the number of results to get from the database at onceoffset- the offset into the full result list to fetch- Returns:
Tuplearray of mediapackage-orgid pairs representing stored media packages- Throws:
SearchServiceDatabaseException- if exception occurs- See Also:
-
getAccessControlList
public AccessControlList getAccessControlList(String mediaPackageId) throws NotFoundException, SearchServiceDatabaseException Retrieves ACL for episode with given ID.- Specified by:
getAccessControlListin interfaceSearchServiceDatabase- Parameters:
mediaPackageId- media package for which ACL will be retrieved- Returns:
AccessControlListof media package or null if media package does not have ACL associated with it- Throws:
NotFoundException- if media package with given ID does not existSearchServiceDatabaseException- if exception occurred- See Also:
-
getAccessControlLists
public Collection<org.apache.commons.lang3.tuple.Pair<String,AccessControlList>> getAccessControlLists(String seriesId, String... excludeIds) throws SearchServiceDatabaseException Retrieves ACLs for series with given ID.- Specified by:
getAccessControlListsin interfaceSearchServiceDatabase- Parameters:
seriesId- series identifier for which ACL will be retrievedexcludeIds- list of media package identifier to exclude from the list- Returns:
- Collection of pairs of media package id and its
AccessControlListof media packages from the series - Throws:
SearchServiceDatabaseException- if exception occurred- See Also:
-
getSeries
public Collection<org.apache.commons.lang3.tuple.Pair<Organization,MediaPackage>> getSeries(String seriesId) throws SearchServiceDatabaseException Gets media packages from a specific series- Specified by:
getSeriesin interfaceSearchServiceDatabase- Parameters:
seriesId- the series identifier- Returns:
- collection of media packages
- Throws:
SearchServiceDatabaseException- if there is a problem communicating with the underlying data store- See Also:
-
storeMediaPackage
public void storeMediaPackage(MediaPackage mediaPackage, AccessControlList acl, Date now) throws SearchServiceDatabaseException, UnauthorizedException Store (or update) media package.- Specified by:
storeMediaPackagein interfaceSearchServiceDatabase- Parameters:
mediaPackage-MediaPackageto storeacl- the acl of the media packagenow- the store date- Throws:
SearchServiceDatabaseException- if exception occursUnauthorizedException- if the current user is not authorized to perform this action- See Also:
-
getMediaPackage
public MediaPackage getMediaPackage(String mediaPackageId) throws NotFoundException, SearchServiceDatabaseException, UnauthorizedException Gets a single media package by its identifier.- Specified by:
getMediaPackagein interfaceSearchServiceDatabase- Parameters:
mediaPackageId- the media package identifier- Returns:
- the media package
- Throws:
NotFoundException- if there is no media package with this identifierSearchServiceDatabaseException- if there is a problem communicating with the underlying data storeUnauthorizedException- See Also:
-
getModificationDate
public Date getModificationDate(String mediaPackageId) throws NotFoundException, SearchServiceDatabaseException Returns the modification date from the selected media package.- Specified by:
getModificationDatein interfaceSearchServiceDatabase- Parameters:
mediaPackageId- the media package id to select- Returns:
- the modification date
- Throws:
NotFoundException- if media package with specified id and version does not existSearchServiceDatabaseException- if an error occurs- See Also:
-
getDeletionDate
public Date getDeletionDate(String mediaPackageId) throws NotFoundException, SearchServiceDatabaseException Returns the deletion date from the selected media package.- Specified by:
getDeletionDatein interfaceSearchServiceDatabase- Parameters:
mediaPackageId- the media package id to select- Returns:
- the deletion date
- Throws:
NotFoundException- if media package with specified id does not existSearchServiceDatabaseException- if an error occurs- See Also:
-
isAvailable
Checks if a mediapackage is available.- Specified by:
isAvailablein interfaceSearchServiceDatabase- Parameters:
mediaPackageId- The ID of theMediaPackagefor which the availability is to be checked- Returns:
- True if two conditions are met: The mediapackage exists in the database and the deletion date is not set
- Throws:
SearchServiceDatabaseException- if an exception occurs- See Also:
-
getOrganizationId
public String getOrganizationId(String mediaPackageId) throws NotFoundException, SearchServiceDatabaseException Returns the organization id of the selected media package- Specified by:
getOrganizationIdin interfaceSearchServiceDatabase- Parameters:
mediaPackageId- the media package id to select- Returns:
- the organization id
- Throws:
NotFoundException- if media package with specified id and version does not existSearchServiceDatabaseException- if an error occurs- See Also:
-