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 SummaryModifier and TypeMethodDescriptionvoiddelete(long docId) Deletes all resources of a document from the store.voidDeletes a specific resource of a document from the store.voiddestroy()Destroy methodbooleanChecks 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 resourceintgetId()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 stores definitions grouped by typeObtains the document's content for the specified resourceObtains the document'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 identifierlongComputed the size of a specific resource.voidStores a filevoidstore(InputStream stream, long docId, String resource) This method has to store a resource in the document's container.booleantest()Tests if the store can read and writevoidwriteToFile(long docId, String resource, File out) Writes the specified resource in a filevoidwriteToStream(long docId, String resource, OutputStream output) Writes the specified resource in an output streamvoidwriteToStream(long docId, String resource, OutputStream output, long start, long length) Writes the specified resource in an output streamMethods inherited from interface java.lang.ComparablecompareTo
- 
Method Details- 
getIdint getId()The unique identifier- Returns:
- the store identifier
 
- 
setIdvoid setId(int id) Sets the unique identifier- Parameters:
- id- the store identifier
 
- 
storeThis 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 InputStream
- docId- The document identifier
- resource- Name of the resource to be stored
- Throws:
- IOException- the content cannot be stored
 
- 
storeStores a file- Parameters:
- file- the file to store
- docId- identifier of the document
- resource- name of the resource
- Throws:
- IOException- the content cannot be stored
- See Also:
 
- 
deletevoid delete(long docId) Deletes all resources of a document from the store.- Parameters:
- docId- The document identifier
 
- 
deleteDeletes a specific resource of a document from the store.- Parameters:
- docId- The document identifier
- resource- Name of the resource to be deleted
 
- 
getResourceNameComputes the resource name inside the container- Parameters:
- doc- The document representation
- fileVersion- 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
 
- 
getResourceNameComputes the resource name inside the container- Parameters:
- docId- The document identifier
- fileVersion- 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
 
- 
listResourcesLists all resources in the document's container- Parameters:
- docId- The document's identifier
- fileVersion- If specified, lists the resources for that specific file version only
- Returns:
- list of resource names
 
- 
sizeComputed the size of a specific resource.- Parameters:
- docId- The document's identifier
- resource- The resource
- Returns:
- the size in bytes
 
- 
existsChecks if the passed resource exists in the document's container- Parameters:
- docId- ID of the document
- resource- Name of the resource
- Returns:
- true only if the resource already exists
 
- 
writeToFileWrites the specified resource in a file- Parameters:
- docId- The document identifier
- resource- Name of the resource
- out- File that will receive the resource's content
- Throws:
- IOException- error writing the file or reading the resource
 
- 
writeToStreamvoid 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 identifier
- resource- Name of the resource
- output- The output stream
- start- Index of the starting byte
- length- Total packet length
- Throws:
- IOException- error writing the stream or reading the resource
 
- 
writeToStreamWrites the specified resource in an output stream- Parameters:
- docId- The document's identifier
- resource- Name of the resource
- output- The output stream
- Throws:
- IOException- error writing the stream or reading the resource
 
- 
getStreamObtains the document's content for the specified resource- Parameters:
- docId- The document's identifier
- resource- Name of the resource
- Returns:
- The document file's content
- Throws:
- IOException- cannot open the stream
 
- 
getBytesObtains the document's raw bytes for the specified resource- Parameters:
- docId- The document's identifier
- resource- Name of the resource
- Returns:
- The document file's bytes
- Throws:
- IOException- cannot open the resource to get the bytes
 
- 
getBytesObtains the document's raw bytes for the specified resource- Parameters:
- docId- The document's identifier
- resource- Name of the resource
- start- Index of the starting byte
- length- Total packet length
- Returns:
- The document file's bytes
- Throws:
- IOException- cannot open the resource to get the bytes
 
- 
moveResourcesToStoreMoves all the resources of a document from it's original location to a different store- Parameters:
- docId- identifier of the document to process
- targetStoreId- identifier of the store that will receive the files
- Returns:
- number of moved resources
- Throws:
- IOException- In case of error during the process
 
- 
getStringObtains the document's content as string for the specified resource- Parameters:
- docId- The document's identifier
- resource- Name of the resource
- Returns:
- The document file's as string representation
 
- 
getTotalSizelong getTotalSize()Computes the total size of the documents repository(in bytes)- Returns:
- sum of the sizes of all the documents expressed in bytes
 
- 
getParameterNamesImplementations 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
 
- 
getParametersReturns the map of parameters- Returns:
- a map with settings setting_name - setting_value
 
- 
testboolean test()Tests if the store can read and write- Returns:
- if the store can read and write
 
- 
isEnabledboolean 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
- 
newStoreInstantiate a new store and fully configures it.- Parameters:
- id- identifier of the store to create
- Returns:
- the created instance
 
- 
getStoreDefinitionsRetrieves the stores definitions grouped by type- Returns:
- a map with definitions type - store prototype
 
 
-