Package com.attivio.sdk.service
Class MockContentStoreProvider
- java.lang.Object
-
- com.attivio.sdk.service.MockContentStoreProvider
-
- All Implemented Interfaces:
ContentStoreProvider
public class MockContentStoreProvider extends java.lang.Object implements ContentStoreProvider
Content store that saves the stream to a byte array in memory.This store provides no memory savings but does allow for ease of development and provides high speed access to the underlying data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classMockContentStoreProvider.MemoryContentPointermemory content pointer.
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<java.lang.String,MockContentStoreProvider.MemoryContentPointer>mapMap of id to stream.-
Fields inherited from interface com.attivio.sdk.api.ContentStoreProvider
DEFAULT_NAMESPACE, description
-
-
Constructor Summary
Constructors Constructor Description MockContentStoreProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.String namespace, java.lang.String id, java.io.InputStream in)Content will be copied from the InputStream and stored within thenamespaceunder theid.booleancontains(java.lang.String namespace, java.lang.String id)voiddelete(java.lang.String namespace, java.lang.String id)Deletesidfrom thenamespace.voiddeleteAll(java.lang.String namespace)Deletes all content from the store within the namespacejava.lang.Stringexternalize(java.lang.String storeName, java.lang.String id)Returns an externally accessible URI for the content suitable for HTTP GET.java.io.InputStreamget(java.lang.String namespace, java.lang.String id)Returns an InputStream to access the content.longgetDiskUtilization()longgetLastModified(java.lang.String namespace, java.lang.String id)java.util.List<java.lang.String>getNamespaces()longgetSize(java.lang.String namespace, java.lang.String id)longgetTotalRecords(java.lang.String namespace)
-
-
-
Field Detail
-
map
protected static final java.util.Map<java.lang.String,MockContentStoreProvider.MemoryContentPointer> map
Map of id to stream.
-
-
Method Detail
-
contains
public boolean contains(java.lang.String namespace, java.lang.String id) throws AttivioException- Specified by:
containsin interfaceContentStoreProvider- Parameters:
namespace- the namespace for the contentid- the id of the content- Returns:
- true if
idexists within thenamespace - Throws:
AttivioException
-
add
public void add(java.lang.String namespace, java.lang.String id, java.io.InputStream in) throws AttivioExceptionContent will be copied from the InputStream and stored within thenamespaceunder theid. If the content currently exists, it will be replaced. The stream is not closed.- Specified by:
addin interfaceContentStoreProvider- Parameters:
namespace- the namespace for the contentid- the id of the contentin- stream containing the content.- Throws:
AttivioException
-
delete
public void delete(java.lang.String namespace, java.lang.String id) throws AttivioExceptionDeletesidfrom thenamespace. The content need not be present.- Specified by:
deletein interfaceContentStoreProvider- Parameters:
namespace- the namespace for the contentid- the id of the content- Throws:
AttivioException
-
deleteAll
public void deleteAll(java.lang.String namespace) throws AttivioExceptionDeletes all content from the store within the namespace- Specified by:
deleteAllin interfaceContentStoreProvider- Parameters:
namespace- the namespace to delete- Throws:
AttivioException
-
getTotalRecords
public long getTotalRecords(java.lang.String namespace) throws AttivioException- Specified by:
getTotalRecordsin interfaceContentStoreProvider- Parameters:
namespace- the namespace to query- Returns:
- the number of unique content records associated with the namespace.
- Throws:
AttivioException
-
get
public java.io.InputStream get(java.lang.String namespace, java.lang.String id) throws AttivioExceptionReturns an InputStream to access the content.- Specified by:
getin interfaceContentStoreProvider- Parameters:
namespace- the namespace for the contentid- the id of the content- Returns:
- an InputStream for the content or
nullif it does not exist - Throws:
AttivioException
-
getSize
public long getSize(java.lang.String namespace, java.lang.String id) throws AttivioException- Specified by:
getSizein interfaceContentStoreProvider- Parameters:
namespace- the namespace for the contentid- the id of the content- Returns:
- the number of bytes the InputStream returned by
ContentStoreProvider.get(String, String)should provide. - Throws:
AttivioException
-
getLastModified
public long getLastModified(java.lang.String namespace, java.lang.String id) throws AttivioException- Specified by:
getLastModifiedin interfaceContentStoreProvider- Parameters:
namespace- the namespace for the contentid- the id of the content- Returns:
- the time of the last
ContentStoreProvider.add(String, String, InputStream)for the content. - Throws:
AttivioException
-
externalize
public java.lang.String externalize(java.lang.String storeName, java.lang.String id) throws AttivioExceptionReturns an externally accessible URI for the content suitable for HTTP GET.- Specified by:
externalizein interfaceContentStoreProvider- Parameters:
storeName- namespace for the contentid- id for the content- Returns:
- URI as a string
- Throws:
AttivioException
-
getNamespaces
public java.util.List<java.lang.String> getNamespaces() throws AttivioException- Specified by:
getNamespacesin interfaceContentStoreProvider- Returns:
- list of all namespaces in the content store
- Throws:
AttivioException
-
getDiskUtilization
public long getDiskUtilization() throws AttivioException- Specified by:
getDiskUtilizationin interfaceContentStoreProvider- Returns:
- the disk space consumed by content store entries
- Throws:
AttivioException
-
-