Package de.xima.fc.logic.filesystem
Class FileProvidingEntityAdapter<Entity extends IFileProviding<File,Data>,File extends IFileEntity<Entity,Data> & IFileSizeProviding,Data extends IFileDataEntity<File>,Context>
- java.lang.Object
-
- de.xima.fc.logic.filesystem.FileProvidingEntityAdapter<Entity,File,Data,Context>
-
- Type Parameters:
Entity
- The type of the entity.File
- The type of the file entity.Data
- The type of the file data entity.Context
- The type of the context for the entities.
- All Implemented Interfaces:
ICrudPersistenceAdapter<IEntityContext,Entity>
,IFileDataPersistenceAdapter<IEntityContext,Entity>
,IScopedEntityPersistenceAdapter<IEntityContext,Entity,Context>
,IEntityFileSystemPersistenceAdapter<IEntityContext,Entity,Context>
,Serializable
public abstract class FileProvidingEntityAdapter<Entity extends IFileProviding<File,Data>,File extends IFileEntity<Entity,Data> & IFileSizeProviding,Data extends IFileDataEntity<File>,Context> extends Object implements IEntityFileSystemPersistenceAdapter<IEntityContext,Entity,Context>
Afile entity adapter
for a generalfile providing
entity.- Since:
- 8.3.0
- Author:
- XIMA MEDIA GmbH
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FileProvidingEntityAdapter(Class<Entity> entityType, Class<File> fileEntityType, Class<Data> fileDataEntityType)
Creates afile entity adapter
for a generalfile providing
entity.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Entity
create(IEntityContext ec, Entity entity)
Persists the file entity in the database and returns the persisted entity.protected abstract de.xima.cmn.criteria.FilterCriterion
createContextualFilter(Context context)
void
delete(IEntityContext ec, Entity entity)
Deletes the file entity and all its children (such as file data).List<Entity>
list(IEntityContext ec, Context context)
Reads all file entities that exist in the given context.InputStream
openForRead(Supplier<IEntityContext> ec, Entity entity)
Opens an input stream to the content of a file entity.OutputStream
openForWrite(Supplier<IEntityContext> ec, Entity entity)
Opens an output stream for changing the content of a file entity.Entity
read(IEntityContext ec, Entity entity)
Reads the entity from the persistence layer, returning a fresh version of the entity.Entity
update(IEntityContext ec, Entity entity)
Updates the file entity in the persistence layer and returns the updated entity.
-
-
-
Constructor Detail
-
FileProvidingEntityAdapter
public FileProvidingEntityAdapter(Class<Entity> entityType, Class<File> fileEntityType, Class<Data> fileDataEntityType)
Creates afile entity adapter
for a generalfile providing
entity.- Parameters:
entityType
- The type of the entity.fileEntityType
- The type of the file entity.fileDataEntityType
- The type of the file data entity.
-
-
Method Detail
-
create
public final Entity create(IEntityContext ec, Entity entity)
Description copied from interface:ICrudPersistenceAdapter
Persists the file entity in the database and returns the persisted entity.- Specified by:
create
in interfaceICrudPersistenceAdapter<Entity extends IFileProviding<File,Data>,File extends IFileEntity<Entity,Data> & IFileSizeProviding>
- Parameters:
ec
- Persistence context to use for accessing the database.entity
- The entity to create.- Returns:
- The persisted entity.
-
delete
public final void delete(IEntityContext ec, Entity entity)
Description copied from interface:ICrudPersistenceAdapter
Deletes the file entity and all its children (such as file data).- Specified by:
delete
in interfaceICrudPersistenceAdapter<Entity extends IFileProviding<File,Data>,File extends IFileEntity<Entity,Data> & IFileSizeProviding>
- Parameters:
ec
- Persistence context to use for accessing the persistence layer.entity
- The entity to delete.
-
openForRead
public final InputStream openForRead(Supplier<IEntityContext> ec, Entity entity) throws IOException
Description copied from interface:IFileDataPersistenceAdapter
Opens an input stream to the content of a file entity.- Specified by:
openForRead
in interfaceIFileDataPersistenceAdapter<Entity extends IFileProviding<File,Data>,File extends IFileEntity<Entity,Data> & IFileSizeProviding>
- Parameters:
ec
- Persistence context factory to use for accessing the persistence layer.entity
- The entity to open.- Returns:
- An input stream to the file content.
- Throws:
IOException
- If an error occurs while opening the file.
-
openForWrite
public final OutputStream openForWrite(Supplier<IEntityContext> ec, Entity entity) throws IOException
Description copied from interface:IFileDataPersistenceAdapter
Opens an output stream for changing the content of a file entity. This should also update the file metadata, such as the user who last modified the file and the last modified time.- Specified by:
openForWrite
in interfaceIFileDataPersistenceAdapter<Entity extends IFileProviding<File,Data>,File extends IFileEntity<Entity,Data> & IFileSizeProviding>
- Parameters:
ec
- Persistence context factory to use for accessing the persistence layer.entity
- The entity to open.- Returns:
- An output stream to the file content.
- Throws:
IOException
- If an error occurs while opening the file.
-
read
public final Entity read(IEntityContext ec, Entity entity)
Description copied from interface:ICrudPersistenceAdapter
Reads the entity from the persistence layer, returning a fresh version of the entity.- Specified by:
read
in interfaceICrudPersistenceAdapter<Entity extends IFileProviding<File,Data>,File extends IFileEntity<Entity,Data> & IFileSizeProviding>
- Parameters:
ec
- Persistence context to use for accessing the persistence layer.entity
- The entity to read.- Returns:
- The entity read from the persistence layer.
-
list
public final List<Entity> list(IEntityContext ec, Context context)
Description copied from interface:IScopedEntityPersistenceAdapter
Reads all file entities that exist in the given context.- Specified by:
list
in interfaceIScopedEntityPersistenceAdapter<Entity extends IFileProviding<File,Data>,File extends IFileEntity<Entity,Data> & IFileSizeProviding,Data extends IFileDataEntity<File>>
- Parameters:
ec
- Persistence context to use for accessing the persistence layer.context
- The context in which to read the entities, such as a client or project.- Returns:
- A list of all file entities in the context.
-
update
public final Entity update(IEntityContext ec, Entity entity)
Description copied from interface:ICrudPersistenceAdapter
Updates the file entity in the persistence layer and returns the updated entity.- Specified by:
update
in interfaceICrudPersistenceAdapter<Entity extends IFileProviding<File,Data>,File extends IFileEntity<Entity,Data> & IFileSizeProviding>
- Parameters:
ec
- Persistence context to use for accessing the database.entity
- The entity to update.- Returns:
- The updated entity.
-
createContextualFilter
protected abstract de.xima.cmn.criteria.FilterCriterion createContextualFilter(Context context)
-
-