Package com.logicaldoc.core.store
Interface Storer
- All Superinterfaces:
Comparable<Storer>
- All Known Implementing Classes:
AbstractStorer
,FSStorer
,MockStorer
The Storer manages the repository where document files are maintained and all
general resources are stored.
- Author:
- Michael Scholz, Marco Meschieri
-
Method Summary
Modifier and TypeMethodDescriptionvoid
delete
(long docId) Deletes all resources of a document from the storage.void
Deletes a specific resource of a document from the storage.void
destroy()
Destroy methodboolean
Checks if the passed resource exists in the document's containerbyte[]
Obtains the document's raw bytes for the specified resourcebyte[]
Obtains the document's raw bytes for the specified resourceint
getId()
The unique identifierImplementations should return the list of the required parameters.Returns the map of parametersgetResourceName
(long docId, String fileVersion, String suffix) Computes the resource name inside the containergetResourceName
(Document doc, String fileVersion, String suffix) Computes the resource name inside the containerRetrieves the storers definitions grouped by typeObtains the document's content for the specified resourceObtains the document's content as string for the specified resourcelong
Computes the total size of the documents repository(in bytes)void
init()
Initialization methodboolean
Tests if the storer is enabledlistResources
(long docId, String fileVersion) Lists all resources in the document's containerint
moveResourcesToStore
(long docId, int targetStorageId) Moves all the resources of a document from it's original location to a different storagenewStorer
(int id) Instantiate a new storer and fully configures it.void
setId
(int id) Sets the unique identifierlong
Computed the size of a specific resource.void
Stores a filevoid
store
(InputStream stream, long docId, String resource) This method has to store a resource in the document's container.boolean
test()
Tests if the storer can read and writevoid
writeToFile
(long docId, String resource, File out) Writes the specified resource in a filevoid
writeToStream
(long docId, String resource, OutputStream output) Writes the specified resource in an output streamvoid
writeToStream
(long docId, String resource, OutputStream output, long start, long length) Writes the specified resource in an output streamMethods inherited from interface java.lang.Comparable
compareTo
-
Method Details
-
getId
int getId()The unique identifier- Returns:
- the storer identifier
-
setId
void setId(int id) Sets the unique identifier- Parameters:
id
- the storer identifier
-
store
This method has to store a resource in the document's container. The location where (DBMS, Filesystem, other) the document should be stored is defined by the concrete implementation. It is possible to store a new document or a new version of an existing document.- Parameters:
stream
- Document as InputStreamdocId
- The document identifierresource
- Name of the resource to be stored- Throws:
IOException
- the content cannot be stored
-
store
Stores a file- Parameters:
file
- the file to storedocId
- identifier of the documentresource
- name of the resource- Throws:
IOException
- the content cannot be stored- See Also:
-
delete
void delete(long docId) Deletes all resources of a document from the storage.- Parameters:
docId
- The document identifier
-
delete
Deletes a specific resource of a document from the storage.- Parameters:
docId
- The document identifierresource
- Name of the resource to be deleted
-
getResourceName
Computes the resource name inside the container- Parameters:
doc
- The document representationfileVersion
- The file version (use null for the latest version)suffix
- The file suffix (use null if you want the exact document file)- Returns:
- The document's resource name
-
getResourceName
Computes the resource name inside the container- Parameters:
docId
- The document identifierfileVersion
- The file version (use null for the latest version)suffix
- The file suffix (use null if you want the exact document file)- Returns:
- The document's resource name
-
listResources
Lists all resources in the document's container- Parameters:
docId
- The document's identifierfileVersion
- If specified, lists the resources for that specific file version only- Returns:
- list of resource names
-
size
Computed the size of a specific resource.- Parameters:
docId
- The document's identifierresource
- The resource- Returns:
- the size in bytes
-
exists
Checks if the passed resource exists in the document's container- Parameters:
docId
- ID of the documentresource
- Name of the resource- Returns:
- true only if the resource already exists
-
writeToFile
Writes the specified resource in a file- Parameters:
docId
- The document identifierresource
- Name of the resourceout
- File that will receive the resource's content- Throws:
IOException
- error writing the file or reading the resource
-
writeToStream
void writeToStream(long docId, String resource, OutputStream output, long start, long length) throws IOException Writes the specified resource in an output stream- Parameters:
docId
- The document's identifierresource
- Name of the resourceoutput
- The output streamstart
- Index of the starting bytelength
- Total packet length- Throws:
IOException
- error writing the stream or reading the resource
-
writeToStream
Writes the specified resource in an output stream- Parameters:
docId
- The document's identifierresource
- Name of the resourceoutput
- The output stream- Throws:
IOException
- error writing the stream or reading the resource
-
getStream
Obtains the document's content for the specified resource- Parameters:
docId
- The document's identifierresource
- Name of the resource- Returns:
- The document file's content
- Throws:
IOException
- cannot open the stream
-
getBytes
Obtains the document's raw bytes for the specified resource- Parameters:
docId
- The document's identifierresource
- Name of the resource- Returns:
- The document file's bytes
- Throws:
IOException
- cannot open the resource to get the bytes
-
getBytes
Obtains the document's raw bytes for the specified resource- Parameters:
docId
- The document's identifierresource
- Name of the resourcestart
- Index of the starting bytelength
- Total packet length- Returns:
- The document file's bytes
- Throws:
IOException
- cannot open the resource to get the bytes
-
moveResourcesToStore
Moves all the resources of a document from it's original location to a different storage- Parameters:
docId
- identifier of the document to processtargetStorageId
- identifier of the storage that will receive the files- Returns:
- number of moved resources
- Throws:
IOException
- In case of error during the process
-
getString
Obtains the document's content as string for the specified resource- Parameters:
docId
- The document's identifierresource
- Name of the resource- Returns:
- The document file's as string representation
-
getTotalSize
long getTotalSize()Computes the total size of the documents repository(in bytes)- Returns:
- sum of the sizes of all the documents expressed in bytes
-
getParameterNames
Implementations should return the list of the required parameters. A parameter is stored in the context as storer.id.parameter = value- Returns:
- list of parameter names
-
getParameters
Returns the map of parameters- Returns:
- a map with settings setting_name - setting_value
-
test
boolean test()Tests if the storer can read and write- Returns:
- if the storer can read and write
-
isEnabled
boolean isEnabled()Tests if the storer is enabled- Returns:
- if the storer is enabled
-
init
@PostConstruct void init()Initialization method -
destroy
@PreDestroy void destroy()Destroy method -
newStorer
Instantiate a new storer and fully configures it.- Parameters:
id
- identifier of the storer to create- Returns:
- the created instance
-
getStorerDefinitions
Retrieves the storers definitions grouped by type- Returns:
- a map with definitions type - storer prototype
-