Class FileSystemContentManager
- All Implemented Interfaces:
IChannelContentManager
,IContentManager
,IMovingContentManager
Path / File name generation is delegated to an instance of IFileSystemNamingStrategy
.
This manager creates two files for snippet of content that is managed:
- a file that contains the content;
- another file that contains the meta-data related to the content. meta-data file also contains the roles acquired by the content.
This implementation does not explicitly store the file size in the metadata. Instead, whenever a metadata-representation is constructed, the instance is complemented with file size information that is obtained from the filesystem directly.
- Since:
- 9.3
- Author:
- G. der Kinderen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Metadata representation. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFileSystemContentManager
(FileSystemConnection connection) Constructs a new manager, using a default naming strategy.FileSystemContentManager
(FileSystemConnection connection, IFileSystemNamingStrategy namingStrategy, FileRoleCache roleCache) Constructs a new manager. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canMove()
Indicator of the implementation ofIMovingContentManager
is able to directly move contentcreate
(InputStream stream, String name, String contentType, Long processId, String caseId, CustomContentProperties properties, IUserData user, String... roles) Deprecated.create
(ReadableByteChannel readableByteChannel, String name, String contentType, Long processId, String caseId, CustomContentProperties properties, IUserData user, String... roles) Add new content to the repository.void
Delete content from the repositoryThis method returns the content manager's disposable content.Method to retrieve the implementing class of theIMovingContentManager
this method should walk any delegate to the original implementationgetReadableByteChannel
(GUID id, IUserData user) Exposes a Channel for the Content ofid
.boolean
This method checks if the current content manager has anyIDisposableContent
contents.boolean
isAuthorized
(GUID id, IUserData user) This method checks if the user has roles on this content with the given id.move
(GUID fileId, IContentManager targetContentManager, IUserData user) Directly move content from one content manager to another using low level API.void
notifyMove
(GUID id) Notify that a move has taken places on theIMovingContentManager
.int
Deprecated.readMetadata
(GUID id, IUserData user, boolean checkRoles) Reads only the metadata for a given content id.String[]
Reads the required roles for a given content id.protected String
toContentPath
(GUID guid) Calculates the file system path in which content is stored that is identified by the provided identifier.protected String
toMetadataPath
(GUID guid) Calculates the file system path in which metadata is stored for content identified by the provided identifier.void
Deprecated.void
update
(GUID id, InputStream stream, String name, String contentType, Long processId, String caseId, CustomContentProperties properties, IUserData user) Deprecated.void
Update existing content with new metadata, but keep the existing data.void
Update the existing content with new roles, but keep the existing data and metadata.void
update
(GUID id, ReadableByteChannel readableByteChannel, String name, String contentType, IUserData user) Update existing content with new data, but keep the existing metadata.void
update
(GUID id, ReadableByteChannel readableByteChannel, String name, String contentType, Long processId, String caseId, CustomContentProperties properties, IUserData user) Update existing content with new data and metadata.
-
Field Details
-
Constructor Details
-
FileSystemContentManager
Constructs a new manager, using a default naming strategy.- Parameters:
connection
- The connection providing access to the content store (cannot benull
).- Since:
- 9.3
-
FileSystemContentManager
public FileSystemContentManager(FileSystemConnection connection, IFileSystemNamingStrategy namingStrategy, FileRoleCache roleCache) Constructs a new manager.- Parameters:
connection
- The connection providing access to the content store (cannot benull
).namingStrategy
- a path/name converter (cannot benull
).- Since:
- 9.3
-
-
Method Details
-
create
@Deprecated public GUID create(InputStream stream, String name, String contentType, Long processId, String caseId, CustomContentProperties properties, IUserData user, String... roles) Deprecated.Description copied from interface:IContentManager
Add new content to the repository.- Specified by:
create
in interfaceIContentManager
- Parameters:
stream
- The stream containing the data, may not benull
.name
- A name for the content, may not benull
.contentType
- The content type of the data, may benull
ifunknown
.processId
- The id of the process where this content is part of, may benull
.caseId
- The id of the case where this content is part of, may benull
.properties
- Custom properties that should be stored with the content, may not benull
.user
- The user who is considered the creator of the content, may not benull
.roles
- The list of authorized roles associated to this content, may not benull
.- Returns:
- Returns a GUID that uniquely identifies the content, never
null
.
-
create
public GUID create(ReadableByteChannel readableByteChannel, String name, String contentType, Long processId, String caseId, CustomContentProperties properties, IUserData user, String... roles) Description copied from interface:IChannelContentManager
Add new content to the repository.- Specified by:
create
in interfaceIChannelContentManager
- Parameters:
readableByteChannel
- The channel representing connection to the data, may not benull
.name
- A name for the content, may not benull
.contentType
- The content type of the data, may benull
ifunknown
.processId
- The id of the process where this content is part of, may benull
.caseId
- The id of the case where this content is part of, may benull
.properties
- Custom properties that should be stored with the content, may not benull
.user
- The user who is considered the creator of the content, may not benull
.roles
- The list of authorized roles associated to this content, may not benull
.- Returns:
- Returns a GUID that uniquely identifies the content, never
null
.
-
readMetadata
Description copied from interface:IContentManager
Reads only the metadata for a given content id.- Specified by:
readMetadata
in interfaceIContentManager
- Parameters:
id
- The id of the content for which metadata is requested, may not benull
.user
- The user that is reading the content, may not benull
.checkRoles
- Flag indicating if the roles check should be done or not.- Returns:
- Returns an
IContentMetadata
IContentMetadata object containing the requested meta data, nevernull
.
-
readRoles
Description copied from interface:IContentManager
Reads the required roles for a given content id.- Specified by:
readRoles
in interfaceIContentManager
- Parameters:
id
- The id of the content for which roles are requested, may not benull
.user
- The user that is reading the content, may not benull
.- Returns:
- Returns a list of required roles. Can be
null
.
-
update
Description copied from interface:IContentManager
Update the existing content with new roles, but keep the existing data and metadata.- Specified by:
update
in interfaceIContentManager
- Parameters:
id
- The id of the content which should be updated, may not benull
.newRoles
- The list of new roles. May not benull
, may beempty
.user
- The user that is updating the content, may not benull
.
-
update
@Deprecated public void update(GUID id, InputStream stream, String name, String contentType, Long processId, String caseId, CustomContentProperties properties, IUserData user) Deprecated.Description copied from interface:IContentManager
Update existing content with new data and metadata.- Specified by:
update
in interfaceIContentManager
- Parameters:
id
- The id of the content which should be updated, may not benull
.stream
- The InputStream containing the new data, may not benull
.name
- A name for the content, may not benull
.contentType
- The content type of the new data, may benull
.processId
- The id of the case where this content is part of, may benull
.caseId
- The id of the case where this content is part of, may benull
.properties
- The new set of properties, this will completely overwrite the existing properties, may not benull
.user
- The user that is updating the content, may not benull
.
-
update
public void update(GUID id, ReadableByteChannel readableByteChannel, String name, String contentType, Long processId, String caseId, CustomContentProperties properties, IUserData user) Description copied from interface:IChannelContentManager
Update existing content with new data and metadata.- Specified by:
update
in interfaceIChannelContentManager
- Parameters:
id
- The id of the content which should be updated, may not benull
.readableByteChannel
- The channel representing connection to the data, may not benull
.name
- A name for the content, may not benull
.contentType
- The content type of the new data, may benull
.processId
- The id of the case where this content is part of, may benull
.caseId
- The id of the case where this content is part of, may benull
.properties
- The new set of properties, this will completely overwrite the existing properties, may not benull
.user
- The user that is updating the content, may not benull
.
-
update
@Deprecated public void update(GUID id, InputStream stream, String name, String contentType, IUserData user) Deprecated.Description copied from interface:IContentManager
Update existing content with new data, but keep the existing metadata.- Specified by:
update
in interfaceIContentManager
- Parameters:
id
- The id of the content which should be updated, may not benull
.stream
- The InputStream containing the new data, may not benull
.name
- A name for the content, may not benull
.contentType
- The content type of the new data, may benull
.user
- The user that is updating the content, may not benull
.
-
update
public void update(GUID id, ReadableByteChannel readableByteChannel, String name, String contentType, IUserData user) Description copied from interface:IChannelContentManager
Update existing content with new data, but keep the existing metadata.- Specified by:
update
in interfaceIChannelContentManager
- Parameters:
id
- The id of the content which should be updated, may not benull
.readableByteChannel
- The channel representing connection to the data, may not benull
.name
- A name for the content, may not benull
.contentType
- The content type of the new data, may benull
.user
- The user that is updating the content, may not benull
.
-
update
public void update(GUID id, Long processId, String caseId, CustomContentProperties properties, IUserData user) Description copied from interface:IContentManager
Update existing content with new metadata, but keep the existing data.- Specified by:
update
in interfaceIContentManager
- Parameters:
id
- The id of the content which should be updated, may not benull
.processId
- The id of the process where this content is part of, may benull
.caseId
- The id of the case where this content is part of, may benull
.properties
- The new set of properties, this will completely overwrite the existing properties, may not benull
.user
- The user that is updating the content, may not benull
.
-
getImplementation
Description copied from interface:IMovingContentManager
Method to retrieve the implementing class of theIMovingContentManager
this method should walk any delegate to the original implementation- Specified by:
getImplementation
in interfaceIMovingContentManager
- Returns:
- Returns the implementing class of the
IMovingContentManager
-
move
Description copied from interface:IMovingContentManager
Directly move content from one content manager to another using low level API.- Specified by:
move
in interfaceIMovingContentManager
- Parameters:
fileId
- The id of the content, may not benull
targetContentManager
- The targeting content manager to move content to, may not benull
user
- The user that is moving the content, may not benull
.- Returns:
- Returns the new GUID that uniquely the moved content, never
null
.
-
notifyMove
Description copied from interface:IMovingContentManager
Notify that a move has taken places on theIMovingContentManager
.- Specified by:
notifyMove
in interfaceIMovingContentManager
- Parameters:
id
- The id of the content that has been moved towards the content manager, may not benull
-
canMove
public boolean canMove()Description copied from interface:IMovingContentManager
Indicator of the implementation ofIMovingContentManager
is able to directly move content- Specified by:
canMove
in interfaceIMovingContentManager
- Returns:
- Returns true it can directly move content.
-
delete
Description copied from interface:IContentManager
Delete content from the repository- Specified by:
delete
in interfaceIContentManager
- Parameters:
id
- The id of the content which should be deleted, may not benull
.user
- The user that is deleting the content, may not benull
.checkRoles
- Flag indicating if the roles check should be done or not.
-
isAuthorized
Description copied from interface:IContentManager
This method checks if the user has roles on this content with the given id.- Specified by:
isAuthorized
in interfaceIContentManager
- Parameters:
id
- The id of the content, nevernull
.user
- The details of the user that wants to access the content, nevernull
.- Returns:
- A flag indicating if the user has roles on the document or not.
-
readBytes
@Deprecated public int readBytes(GUID id, long position, byte[] buffer, int offset, int length, IUserData user) Deprecated.Description copied from interface:IContentManager
Reads up tolength
bytes of data from content into a byte array. The method blocks until some input is available.Although publicly available, this method primarily facilitates the implementation of
ContentInputStream
. For reading content from anIContentManager
, usage ofContentInputStream
is recommended over direct usage of this method.If the user is not authorized it will throw an exception.
- Specified by:
readBytes
in interfaceIContentManager
- Parameters:
id
- The id of the content that should be read, may not benull
.position
- the start offset in the source content.buffer
- The buffer into which the data is read, may not benull
.offset
- The start offset in the destination arraybuffer
.length
- The maximum number of bytes read.user
- The user that is reading the content, may not benull
.- Returns:
- The total number of bytes read into the buffer, or
-1
if there is no more data because the end of the content has been reached. - See Also:
-
hasDisposableContent
public boolean hasDisposableContent()Description copied from interface:IContentManager
This method checks if the current content manager has anyIDisposableContent
contents.- Specified by:
hasDisposableContent
in interfaceIContentManager
- Returns:
- A flag indicating whether the content manager has disposable content objects.
-
getDisposableContent
Description copied from interface:IContentManager
This method returns the content manager's disposable content.- Specified by:
getDisposableContent
in interfaceIContentManager
-
toMetadataPath
Calculates the file system path in which metadata is stored for content identified by the provided identifier.The path that is returned will:
- reference a file (as opposed to a directory)
- not start with a file name-separator
@param GUID content identifier (cannot be
null
).- Returns:
- A (relative) path (never
null
).
-
toContentPath
Calculates the file system path in which content is stored that is identified by the provided identifier.The path that is returned will:
- reference a file (as opposed to a directory)
- not start with a file name-separator
@param GUID content identifier (cannot be
null
).- Returns:
- A (relative) path (never
null
).
-
getReadableByteChannel
Description copied from interface:IChannelContentManager
Exposes a Channel for the Content ofid
. The caller of this method is responsible for closing the returned channel. If not closed it will acquire a shared (READ) FileLock in case of the FileSystemContentManager. If the user is not authorized it will throw an exception.- Specified by:
getReadableByteChannel
in interfaceIChannelContentManager
- Parameters:
id
- The id of the content where a channel for is needed, may not benull
.user
- The user that is reading the content, may not benull
.- Returns:
- The total number of bytes read into the buffer, or
-1
if there is no more data because the end of the content has been reached.
-