Package com.logicaldoc.core.store
Class MockStorer
- java.lang.Object
-
- com.logicaldoc.core.store.AbstractStorer
-
- com.logicaldoc.core.store.FSStorer
-
- com.logicaldoc.core.store.MockStorer
-
- All Implemented Interfaces:
Storer,Comparable<Storer>
public class MockStorer extends FSStorer
This is basically aFSStorerbut with a flag that if active makes the store method to return an exception- Since:
- 8.4.2
- Author:
- Marco Meschieri - LogicalDOC
-
-
Constructor Summary
Constructors Constructor Description MockStorer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStreamgetStream(long docId, String resource)Obtains the document's content for the specified resourcebooleanisRaiseError()booleanisUseDummyFile()intmoveResourcesToStore(long docId, int targetStorageId)Moves all the resources of a document from it's original location to a different storagevoidsetErrorOnStore(boolean errorOnStore)voidsetUseDummyFile(boolean useDummyFile)voidstore(File file, long docId, String resource)Stores a filevoidstore(InputStream stream, long docId, String resource)This method has to store a resource in the document's container.-
Methods inherited from class com.logicaldoc.core.store.FSStorer
delete, delete, exists, getBytes, getContainer, getParameterNames, getRoot, getTotalSize, listResources, size, writeToFile
-
Methods inherited from class com.logicaldoc.core.store.AbstractStorer
compareTo, destroy, equals, getBytes, getConfig, getId, getParameters, getResourceName, getResourceName, getString, hashCode, init, isEnabled, setConfig, setId, setManager, test, toString, writeToStream, writeToStream
-
-
-
-
Method Detail
-
isRaiseError
public boolean isRaiseError()
-
setErrorOnStore
public void setErrorOnStore(boolean errorOnStore)
-
store
public void store(File file, long docId, String resource) throws IOException
Description copied from interface:StorerStores a file- Specified by:
storein interfaceStorer- Overrides:
storein classFSStorer- Parameters:
file- the file to storedocId- identifier of the documentresource- name of the resource- Throws:
IOException- the content cannot be stored- See Also:
Storer.store(java.io.InputStream,long,java.lang.String)
-
store
public void store(InputStream stream, long docId, String resource) throws IOException
Description copied from interface:StorerThis 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.- Specified by:
storein interfaceStorer- Overrides:
storein classFSStorer- Parameters:
stream- Document as InputStreamdocId- The document identifierresource- Name of the resource to be stored- Throws:
IOException- the content cannot be stored
-
getStream
public InputStream getStream(long docId, String resource) throws IOException
Description copied from interface:StorerObtains the document's content for the specified resource- Specified by:
getStreamin interfaceStorer- Overrides:
getStreamin classFSStorer- Parameters:
docId- The document's identifierresource- Name of the resource- Returns:
- The document file's content
- Throws:
IOException- cannot open the stream
-
isUseDummyFile
public boolean isUseDummyFile()
-
setUseDummyFile
public void setUseDummyFile(boolean useDummyFile)
-
moveResourcesToStore
public int moveResourcesToStore(long docId, int targetStorageId) throws IOExceptionDescription copied from interface:StorerMoves all the resources of a document from it's original location to a different storage- Specified by:
moveResourcesToStorein interfaceStorer- Overrides:
moveResourcesToStorein classFSStorer- 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
-
-