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 class
MockContentStoreProvider.MemoryContentPointer
memory content pointer.
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<java.lang.String,MockContentStoreProvider.MemoryContentPointer>
map
Map 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 void
add(java.lang.String namespace, java.lang.String id, java.io.InputStream in)
Content will be copied from the InputStream and stored within thenamespace
under theid
.boolean
contains(java.lang.String namespace, java.lang.String id)
void
delete(java.lang.String namespace, java.lang.String id)
Deletesid
from thenamespace
.void
deleteAll(java.lang.String namespace)
Deletes all content from the store within the namespacejava.lang.String
externalize(java.lang.String storeName, java.lang.String id)
Returns an externally accessible URI for the content suitable for HTTP GET.java.io.InputStream
get(java.lang.String namespace, java.lang.String id)
Returns an InputStream to access the content.long
getDiskUtilization()
long
getLastModified(java.lang.String namespace, java.lang.String id)
java.util.List<java.lang.String>
getNamespaces()
long
getSize(java.lang.String namespace, java.lang.String id)
long
getTotalRecords(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:
contains
in interfaceContentStoreProvider
- Parameters:
namespace
- the namespace for the contentid
- the id of the content- Returns:
- true if
id
exists within thenamespace
- Throws:
AttivioException
-
add
public void add(java.lang.String namespace, java.lang.String id, java.io.InputStream in) throws AttivioException
Content will be copied from the InputStream and stored within thenamespace
under theid
. If the content currently exists, it will be replaced. The stream is not closed.- Specified by:
add
in 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 AttivioException
Deletesid
from thenamespace
. The content need not be present.- Specified by:
delete
in interfaceContentStoreProvider
- Parameters:
namespace
- the namespace for the contentid
- the id of the content- Throws:
AttivioException
-
deleteAll
public void deleteAll(java.lang.String namespace) throws AttivioException
Deletes all content from the store within the namespace- Specified by:
deleteAll
in interfaceContentStoreProvider
- Parameters:
namespace
- the namespace to delete- Throws:
AttivioException
-
getTotalRecords
public long getTotalRecords(java.lang.String namespace) throws AttivioException
- Specified by:
getTotalRecords
in 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 AttivioException
Returns an InputStream to access the content.- Specified by:
get
in interfaceContentStoreProvider
- Parameters:
namespace
- the namespace for the contentid
- the id of the content- Returns:
- an InputStream for the content or
null
if it does not exist - Throws:
AttivioException
-
getSize
public long getSize(java.lang.String namespace, java.lang.String id) throws AttivioException
- Specified by:
getSize
in 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:
getLastModified
in 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 AttivioException
Returns an externally accessible URI for the content suitable for HTTP GET.- Specified by:
externalize
in 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:
getNamespaces
in interfaceContentStoreProvider
- Returns:
- list of all namespaces in the content store
- Throws:
AttivioException
-
getDiskUtilization
public long getDiskUtilization() throws AttivioException
- Specified by:
getDiskUtilization
in interfaceContentStoreProvider
- Returns:
- the disk space consumed by content store entries
- Throws:
AttivioException
-
-