Class SearchServiceDatabaseImpl
- java.lang.Object
-
- org.opencastproject.search.impl.persistence.SearchServiceDatabaseImpl
-
- All Implemented Interfaces:
SearchServiceDatabase
public class SearchServiceDatabaseImpl extends Object implements SearchServiceDatabase
ImplementsSearchServiceDatabase. Defines permanent storage for series.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.opencastproject.db.DBSessiondbprotected org.opencastproject.db.DBSessionFactorydbSessionFactoryprotected javax.persistence.EntityManagerFactoryemfFactory used to createEntityManagers for transactionsstatic StringPERSISTENCE_UNITJPA persistence unit nameprotected org.opencastproject.security.api.SecurityServicesecurityServiceThe security service
-
Constructor Summary
Constructors Constructor Description SearchServiceDatabaseImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate(org.osgi.service.component.ComponentContext cc)CreatesEntityManagerFactoryusing persistence provider and properties passed via OSGi.intcountMediaPackages()Returns the number of mediapackages in persistent storage, including deleted entries.voiddeleteMediaPackage(String mediaPackageId, Date deletionDate)Removes media package from persistent storage.org.opencastproject.security.api.AccessControlListgetAccessControlList(String mediaPackageId)Retrieves ACL for episode with given ID.Collection<org.opencastproject.security.api.AccessControlList>getAccessControlLists(String seriesId, String... excludeIds)Retrieves ACLs for series with given ID.Stream<org.opencastproject.util.data.Tuple<org.opencastproject.mediapackage.MediaPackage,String>>getAllMediaPackages(int pagesize, int offset)Returns all search entries in persistent storage.DategetDeletionDate(String mediaPackageId)Returns the deletion date from the selected media package.org.opencastproject.mediapackage.MediaPackagegetMediaPackage(String mediaPackageId)Gets a single media package by its identifier.DategetModificationDate(String mediaPackageId)Returns the modification date from the selected media package.StringgetOrganizationId(String mediaPackageId)Returns the organization id of the selected media packageCollection<org.apache.commons.lang3.tuple.Pair<org.opencastproject.security.api.Organization,org.opencastproject.mediapackage.MediaPackage>>getSeries(String seriesId)Gets media packages from a specific seriesvoidsetDBSessionFactory(org.opencastproject.db.DBSessionFactory dbSessionFactory)voidsetEntityManagerFactory(javax.persistence.EntityManagerFactory emf)OSGi DIvoidsetSecurityService(org.opencastproject.security.api.SecurityService securityService)OSGi callback to set the security service.voidstoreMediaPackage(org.opencastproject.mediapackage.MediaPackage mediaPackage, org.opencastproject.security.api.AccessControlList acl, Date now)Store (or update) media package.
-
-
-
Field Detail
-
PERSISTENCE_UNIT
public static final String PERSISTENCE_UNIT
JPA persistence unit name- See Also:
- Constant Field Values
-
emf
protected javax.persistence.EntityManagerFactory emf
Factory used to createEntityManagers for transactions
-
dbSessionFactory
protected org.opencastproject.db.DBSessionFactory dbSessionFactory
-
db
protected org.opencastproject.db.DBSession db
-
securityService
protected org.opencastproject.security.api.SecurityService securityService
The security service
-
-
Method Detail
-
setEntityManagerFactory
public void setEntityManagerFactory(javax.persistence.EntityManagerFactory emf)
OSGi DI
-
setDBSessionFactory
public void setDBSessionFactory(org.opencastproject.db.DBSessionFactory dbSessionFactory)
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) throws SearchServiceDatabaseExceptionCreatesEntityManagerFactoryusing persistence provider and properties passed via OSGi.- Parameters:
cc-- Throws:
SearchServiceDatabaseException
-
setSecurityService
public void setSecurityService(org.opencastproject.security.api.SecurityService securityService)
OSGi callback to set the security service.- Parameters:
securityService- the securityService to set
-
deleteMediaPackage
public void deleteMediaPackage(String mediaPackageId, Date deletionDate) throws SearchServiceDatabaseException, org.opencastproject.util.NotFoundException
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 occursorg.opencastproject.util.NotFoundException- if media package with specified id is not found- See Also:
SearchServiceDatabase.deleteMediaPackage(String, Date)
-
countMediaPackages
public int countMediaPackages() throws SearchServiceDatabaseExceptionReturns 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:
SearchServiceDatabase.countMediaPackages()
-
getAllMediaPackages
public Stream<org.opencastproject.util.data.Tuple<org.opencastproject.mediapackage.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:
SearchServiceDatabase.getAllMediaPackages(int, int)
-
getAccessControlList
public org.opencastproject.security.api.AccessControlList getAccessControlList(String mediaPackageId) throws org.opencastproject.util.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:
org.opencastproject.util.NotFoundException- if media package with given ID does not existSearchServiceDatabaseException- if exception occurred- See Also:
SearchServiceDatabase.getAccessControlList(String)
-
getAccessControlLists
public Collection<org.opencastproject.security.api.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
AccessControlListof media packages from the series - Throws:
SearchServiceDatabaseException- if exception occurred- See Also:
SearchServiceDatabase.getAccessControlLists(String, String...)
-
getSeries
public Collection<org.apache.commons.lang3.tuple.Pair<org.opencastproject.security.api.Organization,org.opencastproject.mediapackage.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:
SearchServiceDatabase.getSeries(String)
-
storeMediaPackage
public void storeMediaPackage(org.opencastproject.mediapackage.MediaPackage mediaPackage, org.opencastproject.security.api.AccessControlList acl, Date now) throws SearchServiceDatabaseException, org.opencastproject.security.api.UnauthorizedExceptionStore (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 occursorg.opencastproject.security.api.UnauthorizedException- if the current user is not authorized to perform this action- See Also:
SearchServiceDatabase.storeMediaPackage(MediaPackage, AccessControlList, Date)
-
getMediaPackage
public org.opencastproject.mediapackage.MediaPackage getMediaPackage(String mediaPackageId) throws org.opencastproject.util.NotFoundException, SearchServiceDatabaseException, org.opencastproject.security.api.UnauthorizedException
Gets a single media package by its identifier.- Specified by:
getMediaPackagein interfaceSearchServiceDatabase- Parameters:
mediaPackageId- the media package identifier- Returns:
- the media package
- Throws:
org.opencastproject.util.NotFoundException- if there is no media package with this identifierSearchServiceDatabaseException- if there is a problem communicating with the underlying data storeorg.opencastproject.security.api.UnauthorizedException- See Also:
SearchServiceDatabase.getMediaPackage(String)
-
getModificationDate
public Date getModificationDate(String mediaPackageId) throws org.opencastproject.util.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:
org.opencastproject.util.NotFoundException- if media package with specified id and version does not existSearchServiceDatabaseException- if an error occurs- See Also:
SearchServiceDatabase.getModificationDate(String)
-
getDeletionDate
public Date getDeletionDate(String mediaPackageId) throws org.opencastproject.util.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:
org.opencastproject.util.NotFoundException- if media package with specified id does not existSearchServiceDatabaseException- if an error occurs- See Also:
SearchServiceDatabase.getDeletionDate(String)
-
getOrganizationId
public String getOrganizationId(String mediaPackageId) throws org.opencastproject.util.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:
org.opencastproject.util.NotFoundException- if media package with specified id and version does not existSearchServiceDatabaseException- if an error occurs- See Also:
SearchServiceDatabase.getOrganizationId(String)
-
-