Class SeriesServiceDatabaseImpl
java.lang.Object
org.opencastproject.series.impl.persistence.SeriesServiceDatabaseImpl
- All Implemented Interfaces:
SeriesServiceDatabase
Implements
SeriesServiceDatabase. Defines permanent storage for series.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.opencastproject.db.DBSessionprotected org.opencastproject.db.DBSessionFactoryprotected org.opencastproject.metadata.dublincore.DublinCoreCatalogServiceDublin core service for serializing and deserializing Dublin coresprotected javax.persistence.EntityManagerFactoryFactory used to createEntityManagers for transactionsstatic final StringJPA persistence unit nameprotected org.opencastproject.security.api.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.intvoiddeleteSeries(String seriesId) Removes series from persistent storage.booleandeleteSeriesElement(String seriesId, String type) Deletes an element of a given type from a seriesvoiddeleteSeriesProperty(String seriesId, String propertyName) Removes the series property from persistent storage.booleanexistsSeriesElement(String seriesId, String type) Returns true if the series with the given identifier contains an element with the given type.org.opencastproject.security.api.AccessControlListgetAccessControlList(String seriesId) Retrieves ACL for series with given ID.List<org.opencastproject.series.api.Series> getAllForAdministrativeRead(Date from, Optional<Date> to, int limit) Returns all series (including deleted ones!)Returns all series in persistent storage.protected Function<javax.persistence.EntityManager, Optional<SeriesEntity>> Gets a potentially deleted series by its ID, using the current organizational context.org.opencastproject.metadata.dublincore.DublinCoreCatalogGets a single series by its identifier.Optional<byte[]> getSeriesElement(String seriesId, String type) Returns the data of a series element.getSeriesElements(String seriesId) Returns all elements of a series or an empty map if the series does not contain any elements.protected Function<javax.persistence.EntityManager, Optional<SeriesEntity>> Gets a series by its ID, using the current organizational context.getSeriesProperties(String seriesId) Get the properties for particular seriesgetSeriesProperty(String seriesId, String propertyName) Get a series property if it existsvoidsetDBSessionFactory(org.opencastproject.db.DBSessionFactory dbSessionFactory) voidsetDublinCoreService(org.opencastproject.metadata.dublincore.DublinCoreCatalogService dcService) OSGi callback to set dublin core catalog service.voidsetEntityManagerFactory(javax.persistence.EntityManagerFactory emf) OSGi DIvoidsetSecurityService(org.opencastproject.security.api.SecurityService securityService) OSGi callback to set the security service.org.opencastproject.metadata.dublincore.DublinCoreCatalogstoreSeries(org.opencastproject.metadata.dublincore.DublinCoreCatalog dc) Store (or update) series.booleanstoreSeriesAccessControl(String seriesId, org.opencastproject.security.api.AccessControlList accessControl) Store access control associated with specified series.booleanstoreSeriesElement(String seriesId, String type, byte[] data) Adds or updates a series element in the series service database.voidupdateSeriesProperty(String seriesId, String propertyName, String propertyValue) Updates a series' property.
-
Field Details
-
PERSISTENCE_UNIT
JPA persistence unit name- See Also:
-
emf
protected javax.persistence.EntityManagerFactory emfFactory used to createEntityManagers for transactions -
dbSessionFactory
protected org.opencastproject.db.DBSessionFactory dbSessionFactory -
db
protected org.opencastproject.db.DBSession db -
dcService
protected org.opencastproject.metadata.dublincore.DublinCoreCatalogService dcServiceDublin core service for serializing and deserializing Dublin cores -
securityService
protected org.opencastproject.security.api.SecurityService securityServiceThe security service
-
-
Constructor Details
-
SeriesServiceDatabaseImpl
public SeriesServiceDatabaseImpl()
-
-
Method Details
-
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) CreatesEntityManagerFactoryusing persistence provider and properties passed via OSGi.- Parameters:
cc-
-
setSecurityService
public void setSecurityService(org.opencastproject.security.api.SecurityService securityService) OSGi callback to set the security service.- Parameters:
securityService- the securityService to set
-
setDublinCoreService
public void setDublinCoreService(org.opencastproject.metadata.dublincore.DublinCoreCatalogService dcService) OSGi callback to set dublin core catalog service.- Parameters:
dcService-DublinCoreCatalogServiceobject
-
deleteSeries
public void deleteSeries(String seriesId) throws SeriesServiceDatabaseException, org.opencastproject.util.NotFoundException Description copied from interface:SeriesServiceDatabaseRemoves series from persistent storage.- Specified by:
deleteSeriesin interfaceSeriesServiceDatabase- Parameters:
seriesId- ID of the series to be removed- Throws:
SeriesServiceDatabaseException- if exception occursorg.opencastproject.util.NotFoundException- if series with specified ID is not found
-
deleteSeriesProperty
public void deleteSeriesProperty(String seriesId, String propertyName) throws SeriesServiceDatabaseException, org.opencastproject.util.NotFoundException Description copied from interface:SeriesServiceDatabaseRemoves the series property from persistent storage.- Specified by:
deleteSeriesPropertyin interfaceSeriesServiceDatabase- Parameters:
seriesId- ID of the series to be removed.propertyName- The unique name of the property to delete.- Throws:
SeriesServiceDatabaseException- if exception occursorg.opencastproject.util.NotFoundException- if series with specified ID is not found or if there is no property with the property name
-
getAllSeries
Description copied from interface:SeriesServiceDatabaseReturns all series in persistent storage.- Specified by:
getAllSeriesin interfaceSeriesServiceDatabase- Returns:
Tuplearray representing stored series- Throws:
SeriesServiceDatabaseException- if exception occurs
-
getAccessControlList
public org.opencastproject.security.api.AccessControlList getAccessControlList(String seriesId) throws org.opencastproject.util.NotFoundException, SeriesServiceDatabaseException Description copied from interface:SeriesServiceDatabaseRetrieves ACL for series with given ID.- Specified by:
getAccessControlListin interfaceSeriesServiceDatabase- Parameters:
seriesId- series for which ACL will be retrieved- Returns:
AccessControlListof series or null if series does not have ACL associated with it- Throws:
org.opencastproject.util.NotFoundException- if series with given ID does not existSeriesServiceDatabaseException- if exception occurred
-
storeSeries
public org.opencastproject.metadata.dublincore.DublinCoreCatalog storeSeries(org.opencastproject.metadata.dublincore.DublinCoreCatalog dc) throws SeriesServiceDatabaseException, org.opencastproject.security.api.UnauthorizedException Description copied from interface:SeriesServiceDatabaseStore (or update) series.- Specified by:
storeSeriesin interfaceSeriesServiceDatabase- Parameters:
dc-DublinCoreCatalogrepresenting series- Returns:
- Dublin Core catalog representing newly created series or null if series Dublin Core was updated
- Throws:
SeriesServiceDatabaseException- if exception occursorg.opencastproject.security.api.UnauthorizedException- if the current user is not authorized to perform this action
-
getSeries
public org.opencastproject.metadata.dublincore.DublinCoreCatalog getSeries(String seriesId) throws org.opencastproject.util.NotFoundException, SeriesServiceDatabaseException Gets a single series by its identifier.- Specified by:
getSeriesin interfaceSeriesServiceDatabase- Parameters:
seriesId- the series identifier- Returns:
- the dublin core catalog for this series
- Throws:
org.opencastproject.util.NotFoundException- if there is no series with this identifierSeriesServiceDatabaseException- if there is a problem communicating with the underlying data store- See Also:
-
getAllForAdministrativeRead
public List<org.opencastproject.series.api.Series> getAllForAdministrativeRead(Date from, Optional<Date> to, int limit) throws SeriesServiceDatabaseException, org.opencastproject.security.api.UnauthorizedException Description copied from interface:SeriesServiceDatabaseReturns all series (including deleted ones!) that have been modified in the given date rangefrom(inclusive) --to(exclusive). At mostlimitmany series are returned. ACLs/permissions are NOT checked as this is only intended to be used in an administrative context.- Specified by:
getAllForAdministrativeReadin interfaceSeriesServiceDatabase- Throws:
SeriesServiceDatabaseExceptionorg.opencastproject.security.api.UnauthorizedException
-
getSeriesProperties
public Map<String,String> getSeriesProperties(String seriesId) throws org.opencastproject.util.NotFoundException, SeriesServiceDatabaseException Get the properties for particular series- Specified by:
getSeriesPropertiesin interfaceSeriesServiceDatabase- Parameters:
seriesId- The unique series id to retrieve the properties for.- Returns:
- A
Mapof the properties names and values. - Throws:
org.opencastproject.util.NotFoundException- Thrown if the series can't be found.SeriesServiceDatabaseException- If exception occurred- See Also:
-
getSeriesProperty
public String getSeriesProperty(String seriesId, String propertyName) throws org.opencastproject.util.NotFoundException, SeriesServiceDatabaseException Get a series property if it exists- Specified by:
getSeriesPropertyin interfaceSeriesServiceDatabase- Parameters:
seriesId- The id used to get the series.propertyName- The unique name for the property.- Returns:
- The property value
- Throws:
org.opencastproject.util.NotFoundException- Thrown if the series or the property doesn't exist.SeriesServiceDatabaseException- Thrown for all other Exceptions.- See Also:
-
storeSeriesAccessControl
public boolean storeSeriesAccessControl(String seriesId, org.opencastproject.security.api.AccessControlList accessControl) throws org.opencastproject.util.NotFoundException, SeriesServiceDatabaseException Description copied from interface:SeriesServiceDatabaseStore access control associated with specified series. IllegalArgumentException is thrown if accessControl parameter is null.- Specified by:
storeSeriesAccessControlin interfaceSeriesServiceDatabase- Parameters:
seriesId- ID of series to associate access control withaccessControl-AccessControlListrepresenting access control rules for specified series- Returns:
- true if update happened, false if there was no previous entry
- Throws:
org.opencastproject.util.NotFoundException- if series with specified ID does not existSeriesServiceDatabaseException- if exception occurred
-
countSeries
- Specified by:
countSeriesin interfaceSeriesServiceDatabase- Throws:
SeriesServiceDatabaseException
-
updateSeriesProperty
public void updateSeriesProperty(String seriesId, String propertyName, String propertyValue) throws org.opencastproject.util.NotFoundException, SeriesServiceDatabaseException Description copied from interface:SeriesServiceDatabaseUpdates a series' property.- Specified by:
updateSeriesPropertyin interfaceSeriesServiceDatabase- Parameters:
seriesId- The id of the series to add or update the property for.propertyName- A unique name for the property.propertyValue- The value for the property.- Throws:
org.opencastproject.util.NotFoundException- Thrown if the series cannot be found.SeriesServiceDatabaseException- Thrown if another exception occurred
-
getSeriesEntity
protected Function<javax.persistence.EntityManager,Optional<SeriesEntity>> getSeriesEntity(String id) Gets a series by its ID, using the current organizational context.- Parameters:
id- the series identifier- Returns:
- the series entity, or null if not found or if the series is deleted.
-
getPotentiallyDeletedSeriesEntity
protected Function<javax.persistence.EntityManager,Optional<SeriesEntity>> getPotentiallyDeletedSeriesEntity(String id) Gets a potentially deleted series by its ID, using the current organizational context.- Parameters:
id- the series identifier- Returns:
- the series entity, or null if not found
-
storeSeriesElement
public boolean storeSeriesElement(String seriesId, String type, byte[] data) throws SeriesServiceDatabaseException Description copied from interface:SeriesServiceDatabaseAdds or updates a series element in the series service database.- Specified by:
storeSeriesElementin interfaceSeriesServiceDatabase- Parameters:
seriesId- the series identifiertype- the element typedata- the element data- Returns:
- true if the element could be added/updated; false if no such series exists
- Throws:
SeriesServiceDatabaseException- if an error occurs while saving the element in the database
-
deleteSeriesElement
public boolean deleteSeriesElement(String seriesId, String type) throws SeriesServiceDatabaseException Description copied from interface:SeriesServiceDatabaseDeletes an element of a given type from a series- Specified by:
deleteSeriesElementin interfaceSeriesServiceDatabase- Parameters:
seriesId- the series identifiertype- the element type- Returns:
- true if the element could be deleted; false if no such series/element exists
- Throws:
SeriesServiceDatabaseException- if an error occurs while removing the element from the database
-
getSeriesElement
public Optional<byte[]> getSeriesElement(String seriesId, String type) throws SeriesServiceDatabaseException Description copied from interface:SeriesServiceDatabaseReturns the data of a series element.- Specified by:
getSeriesElementin interfaceSeriesServiceDatabase- Parameters:
seriesId- the series identifiertype- the element type- Returns:
- the element data or
Opt.none()if no such series/element exists - Throws:
SeriesServiceDatabaseException- if an error occurs while retrieving the element from the database
-
getSeriesElements
public Optional<Map<String,byte[]>> getSeriesElements(String seriesId) throws SeriesServiceDatabaseException Description copied from interface:SeriesServiceDatabaseReturns all elements of a series or an empty map if the series does not contain any elements. The key of the map marks the element type.- Specified by:
getSeriesElementsin interfaceSeriesServiceDatabase- Parameters:
seriesId- the series identifier- Returns:
- a map of series elements or
Opt.none()if no such series exists - Throws:
SeriesServiceDatabaseException- if an error occurs while retrieving the element from the database
-
existsSeriesElement
public boolean existsSeriesElement(String seriesId, String type) throws SeriesServiceDatabaseException Description copied from interface:SeriesServiceDatabaseReturns true if the series with the given identifier contains an element with the given type.- Specified by:
existsSeriesElementin interfaceSeriesServiceDatabase- Parameters:
seriesId- the series identifiertype- the element type- Returns:
- true, if the element exits; false otherwise
- Throws:
SeriesServiceDatabaseException- if there was an error while checking if the element exits
-