Package com.logicaldoc.core.store
Interface Store
- All Superinterfaces:
Comparable<Store>
- All Known Implementing Classes:
AbstractStore,FSStore,MockStore
The Store manages the repository where document files are maintained and all
general resources are stored.
- Author:
- Michael Scholz, Marco Meschieri
-
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(long docId) Deletes all resources of a document from the store.voiddelete(StoreResource resource) Deletes a specific resource of a document from the store.voiddestroy()Destroy methodbooleanexists(StoreResource resource) Checks if the passed resource exists in the document's containerstatic Storeget()Gets the object available in the application contextbyte[]getBytes(StoreResource resource) Obtains the document's raw bytes for the specified resourcebyte[]getBytes(StoreResource resource, long start, long length) Obtains the document's raw bytes for the specified resourceintgetId()The unique identifierImplementations should return the list of the required parameters.Returns the map of parametersRetrieves the stores definitions grouped by typegetStream(StoreResource resource) Obtains the document's content for the specified resourcegetString(StoreResource resource) Obtains the resource's content as string for the specified resourcelongComputes the total size of the documents repository(in bytes)voidinit()Initialization methodbooleanTests if the store is enabledlistResources(long docId, String fileVersion) Lists all resources in the document's containerintmoveResourcesToStore(long docId, int targetStoreId) Moves all the resources of a document from it's original location to a different storenewStore(int id) Instantiate a new store and fully configures it.voidsetId(int id) Sets the unique identifierlongsize(StoreResource resource) Computed the size of a specific resource.voidstore(File file, StoreResource resource) Stores a filevoidstore(InputStream stream, StoreResource resource) This method has to store a resource in the document's container.booleantest()Tests if the store can read and writevoidwriteToFile(StoreResource resource, File out) Writes the specified resource in a filevoidwriteToStream(StoreResource resource, OutputStream output) Writes the specified resource in an output streamvoidwriteToStream(StoreResource resource, OutputStream output, long start, long length) Writes the specified resource in an output streamMethods inherited from interface java.lang.Comparable
compareTo
-
Method Details
-
get
Gets the object available in the application context- Returns:
- the instance of this object in the application context
-
getId
int getId()The unique identifier- Returns:
- the store identifier
-
setId
void setId(int id) Sets the unique identifier- Parameters:
id- the store 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 InputStreamresource- Resource to be stored, make sure to provide the right document's ID- Throws:
IOException- the content cannot be stored
-
store
Stores a file- Parameters:
file- the file to storeresource- Resource to be stored, make sure to provide the right document's ID- Throws:
IOException- the content cannot be stored
-
delete
void delete(long docId) Deletes all resources of a document from the store.- Parameters:
docId- The document identifier
-
delete
Deletes a specific resource of a document from the store.- Parameters:
resource- The resource to be deleted
-
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 resources
-
size
Computed the size of a specific resource.- Parameters:
resource- The resource- Returns:
- the size in bytes
-
exists
Checks if the passed resource exists in the document's container- Parameters:
resource- The resource- Returns:
- true only if the resource already exists
-
writeToFile
Writes the specified resource in a file- Parameters:
resource- The resourceout- File that will receive the resource's content- Throws:
IOException- error writing the file or reading the resource
-
writeToStream
void writeToStream(StoreResource resource, OutputStream output, long start, long length) throws IOException Writes the specified resource in an output stream- Parameters:
resource- 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:
resource- 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:
resource- 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:
resource- 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:
resource- 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 store- Parameters:
docId- identifier of the document to processtargetStoreId- identifier of the store that will receive the files- Returns:
- number of moved resources
- Throws:
IOException- In case of error during the process
-
getString
Obtains the resource's content as string for the specified resource- Parameters:
resource- 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 store.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 store can read and write- Returns:
- if the store can read and write
-
isEnabled
boolean isEnabled()Tests if the store is enabled- Returns:
- if the store is enabled
-
init
@PostConstruct void init()Initialization method -
destroy
@PreDestroy void destroy()Destroy method -
newStore
Instantiate a new store and fully configures it.- Parameters:
id- identifier of the store to create- Returns:
- the created instance
-
getStoreDefinitions
Retrieves the stores definitions grouped by type- Returns:
- a map with definitions type - store prototype
-