Package de.xima.fc.logic.filesystem
Class FileEntityPersistenceAdapter<File extends IFileEntity<?,Data> & IFileSizeProviding,Data extends IFileDataEntity<File>,Context>
- java.lang.Object
-
- de.xima.fc.logic.filesystem.FileEntityPersistenceAdapter<File,Data,Context>
-
- Type Parameters:
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,File>,IFileDataPersistenceAdapter<IEntityContext,File>,IScopedEntityPersistenceAdapter<IEntityContext,File,Context>,IEntityFileSystemPersistenceAdapter<IEntityContext,File,Context>,Serializable
public abstract class FileEntityPersistenceAdapter<File extends IFileEntity<?,Data> & IFileSizeProviding,Data extends IFileDataEntity<File>,Context> extends Object implements IEntityFileSystemPersistenceAdapter<IEntityContext,File,Context>
Afile entity adapterfor a generalfile entity.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFileEntityPersistenceAdapter(Class<File> fileEntityType, Class<Data> fileDataEntityType)Creates afile entity adapterfor a generalfile entity.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Filecreate(IEntityContext ec, File file)Persists the file entity in the database and returns the persisted entity.protected abstract de.xima.cmn.criteria.FilterCriterioncreateContextualFilter(Context context)voiddelete(IEntityContext ec, File fileEntity)Deletes the file entity and all its children (such as file data).protected booleanignoreLockingVersion()List<File>list(IEntityContext ec, Context context)Reads all file entities that exist in the given context.InputStreamopenForRead(Supplier<IEntityContext> ec, File fileEntity)Opens an input stream to the content of a file entity.OutputStreamopenForWrite(Supplier<IEntityContext> ec, File fileEntity)Opens an output stream for changing the content of a file entity.Fileread(IEntityContext ec, File file)Reads the entity from the persistence layer, returning a fresh version of the entity.Fileupdate(IEntityContext ec, File file)Updates the file entity in the persistence layer and returns the updated entity.
-
-
-
Constructor Detail
-
FileEntityPersistenceAdapter
protected FileEntityPersistenceAdapter(Class<File> fileEntityType, Class<Data> fileDataEntityType)
Creates afile entity adapterfor a generalfile entity.- Parameters:
fileEntityType- The type of the file entity.fileDataEntityType- The type of the file data entity.
-
-
Method Detail
-
create
public final File create(IEntityContext ec, File file)
Description copied from interface:ICrudPersistenceAdapterPersists the file entity in the database and returns the persisted entity.- Specified by:
createin interfaceICrudPersistenceAdapter<File extends IFileEntity<?,Data> & IFileSizeProviding,Data extends IFileDataEntity<File>>- Parameters:
ec- Persistence context to use for accessing the database.file- The entity to create.- Returns:
- The persisted entity.
-
delete
public final void delete(IEntityContext ec, File fileEntity)
Description copied from interface:ICrudPersistenceAdapterDeletes the file entity and all its children (such as file data).- Specified by:
deletein interfaceICrudPersistenceAdapter<File extends IFileEntity<?,Data> & IFileSizeProviding,Data extends IFileDataEntity<File>>- Parameters:
ec- Persistence context to use for accessing the persistence layer.fileEntity- The entity to delete.
-
list
public final List<File> list(IEntityContext ec, Context context)
Description copied from interface:IScopedEntityPersistenceAdapterReads all file entities that exist in the given context.- Specified by:
listin interfaceIScopedEntityPersistenceAdapter<File extends IFileEntity<?,Data> & IFileSizeProviding,Data extends IFileDataEntity<File>,Context>- 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.
-
openForRead
public final InputStream openForRead(Supplier<IEntityContext> ec, File fileEntity) throws IOException
Description copied from interface:IFileDataPersistenceAdapterOpens an input stream to the content of a file entity.- Specified by:
openForReadin interfaceIFileDataPersistenceAdapter<File extends IFileEntity<?,Data> & IFileSizeProviding,Data extends IFileDataEntity<File>>- Parameters:
ec- Persistence context factory to use for accessing the persistence layer.fileEntity- 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, File fileEntity) throws IOException
Description copied from interface:IFileDataPersistenceAdapterOpens 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:
openForWritein interfaceIFileDataPersistenceAdapter<File extends IFileEntity<?,Data> & IFileSizeProviding,Data extends IFileDataEntity<File>>- Parameters:
ec- Persistence context factory to use for accessing the persistence layer.fileEntity- 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 File read(IEntityContext ec, File file)
Description copied from interface:ICrudPersistenceAdapterReads the entity from the persistence layer, returning a fresh version of the entity.- Specified by:
readin interfaceICrudPersistenceAdapter<File extends IFileEntity<?,Data> & IFileSizeProviding,Data extends IFileDataEntity<File>>- Parameters:
ec- Persistence context to use for accessing the persistence layer.file- The entity to read.- Returns:
- The entity read from the persistence layer.
-
update
public final File update(IEntityContext ec, File file)
Description copied from interface:ICrudPersistenceAdapterUpdates the file entity in the persistence layer and returns the updated entity.- Specified by:
updatein interfaceICrudPersistenceAdapter<File extends IFileEntity<?,Data> & IFileSizeProviding,Data extends IFileDataEntity<File>>- Parameters:
ec- Persistence context to use for accessing the database.file- The entity to update.- Returns:
- The updated entity.
-
createContextualFilter
protected abstract de.xima.cmn.criteria.FilterCriterion createContextualFilter(Context context)
-
ignoreLockingVersion
protected boolean ignoreLockingVersion()
-
-