Package com.attivio.sdk.connector
Class MockPublisher
- java.lang.Object
-
- com.attivio.client.ContentFeeder
-
- com.attivio.sdk.connector.MockPublisher
-
- All Implemented Interfaces:
DocumentOutputClient
,IndexCommitter
,IngestClient
,DocumentPublisher
,SecurityFeeder
,java.io.Closeable
,java.lang.AutoCloseable
public class MockPublisher extends ContentFeeder implements DocumentPublisher, IndexCommitter
A ContentFeeder based mock publisher. We had to extend ContentFeeder to support maxDocs and setStopped
-
-
Field Summary
-
Fields inherited from class com.attivio.client.ContentFeeder
DEFAULT_BATCH_SIZE_COUNT, DEFAULT_BATCH_SIZE_MB, DEFAULT_WORKFLOW, log, ORIGINAL_CLIENT_ID
-
-
Constructor Summary
Constructors Constructor Description MockPublisher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bulkUpdate(BulkUpdate message)
Sendmessage
to AIE.void
delete(java.lang.String... docId)
Delete a series of documents from AIE by document id.void
delete(java.lang.String queryWorkflow, Query query)
Delete all documents that match a query.void
deletePrincipal(AttivioPrincipalKey key)
Deletes a principal from the index.void
feed(IngestDocument... docs)
Senddocs
to AIE.void
feed(IngestDocument doc, AttivioAcl acl)
Sendsdoc
to the document receiver with the given ACL.void
feed(AttivioPrincipal principal)
Ingests an AttivioPrincipal.java.util.List<PlatformMessage>
getSentMessages()
boolean
isInTestMode()
Test mode is set by the user to quickly test that scanner can connect and fetch data.boolean
isStopped()
void
put(IngestDocument doc, java.lang.String fieldName, java.lang.String id, java.io.InputStream is)
Store the content stream in the content store an put aContentPointer
in the indicated document field.void
setMaxDocs(long maxDocs)
void
setStopped(boolean stopped)
-
Methods inherited from class com.attivio.client.ContentFeeder
addStaticField, batchDocument, clientHeartbeat, close, commit, delete, deleteByQuery, deleteByQuery, determineMessageSize, dispatchDocumentsInQueue, endMessageGroup, feed, getAuditReader, getClientId, getCommitInterval, getContentStore, getContentStoreCnt, getContentStoreThresholdKB, getDocSize, getDocumentBatchSize, getDocumentsFed, getDocumentsQueued, getDocumentsSent, getIngestWorkflowName, getInMemCnt, getMaxBatchSizeMB, getMessageDefaultDomain, getOptimizeInterval, getSeverity, getSizeToDomain, getStaticFields, getWaitForCompletionTimeout, initializeServiceFactory, isCompleted, isMessageGroupInProgress, isOrderedCommits, makeInactive, optimize, put, put, put, put, refresh, sendIndexMessage, sendMessageInternal, sendQueuedDocuments, setCommitInterval, setContentStoreThresholdKB, setDefaultMessageDomain, setDocumentBatchSize, setIngestWorkflowName, setMaxBatchSizeMB, setOptimizeInterval, setOrderedCommits, setSizeToDomain, setStaticFields, setWaitForCompletionTimeout, startMessageGroup, toString, waitForCompletion, waitForCompletion, waitForCompletion, waitForCompletion
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.attivio.sdk.connector.DocumentPublisher
getClientId, waitForCompletion
-
Methods inherited from interface com.attivio.sdk.client.IndexCommitter
commit
-
-
-
-
Method Detail
-
isStopped
public boolean isStopped()
- Specified by:
isStopped
in interfaceDocumentPublisher
- Returns:
- true if the scan has been stopped by user intervention.
-
delete
public void delete(java.lang.String queryWorkflow, Query query) throws AttivioException
Description copied from interface:DocumentPublisher
Delete all documents that match a query.- Specified by:
delete
in interfaceDocumentPublisher
- Parameters:
queryWorkflow
- to use for query processing- Throws:
AttivioException
-
bulkUpdate
public void bulkUpdate(BulkUpdate message) throws AttivioException
Description copied from class:ContentFeeder
Sendmessage
to AIE.- Specified by:
bulkUpdate
in interfaceDocumentOutputClient
- Specified by:
bulkUpdate
in interfaceDocumentPublisher
- Overrides:
bulkUpdate
in classContentFeeder
- Throws:
AttivioException
-
delete
public void delete(java.lang.String... docId) throws AttivioException
Description copied from class:ContentFeeder
Delete a series of documents from AIE by document id.If batching is enabled, then these delete messages will be batched along with any fed documents. If these deletes are meant to apply to uncommitted documents previously fed with this ContentFeeder, then those documents must be committed to the index before this delete is called. When ordered commits is enabled, this entails calling:
contentFeeder.commit(); contentFeeder.waitForCompletion(); contentFeeder.delete("id1",...);
When ordered commits is disabled, it entails calling:contentFeeder.waitForCompletion(); contentFeeder.commit(); contentFeeder.waitForCompletion(); contentFeeder.delete("id1",...);
- Specified by:
delete
in interfaceDocumentOutputClient
- Specified by:
delete
in interfaceDocumentPublisher
- Overrides:
delete
in classContentFeeder
- Parameters:
docId
- The document IDs of the documents to delete.- Throws:
AttivioException
- if sending of deletes fails.
-
feed
public void feed(IngestDocument... docs) throws AttivioException
Description copied from class:ContentFeeder
Senddocs
to AIE.- Specified by:
feed
in interfaceDocumentOutputClient
- Specified by:
feed
in interfaceDocumentPublisher
- Overrides:
feed
in classContentFeeder
- Parameters:
docs
- the documents to send.- Throws:
AttivioException
- The publisher will throw anAttivioException
with an error code ofConnectorError.CRAWL_STOPPED
if the scanner was stopped by the administrator or the limit on the number of documents was reached - seeAttivioException.getErrorCode()
. Exceptions with other error code indicate an error.
-
deletePrincipal
public void deletePrincipal(AttivioPrincipalKey key) throws AttivioException
Description copied from class:ContentFeeder
Deletes a principal from the index.- Specified by:
deletePrincipal
in interfaceIngestClient
- Specified by:
deletePrincipal
in interfaceSecurityFeeder
- Overrides:
deletePrincipal
in classContentFeeder
- Parameters:
key
- unique ID of the principal- Throws:
AttivioException
- if sending of documents fails.
-
feed
public void feed(IngestDocument doc, AttivioAcl acl) throws AttivioException
Description copied from class:ContentFeeder
Sendsdoc
to the document receiver with the given ACL.- Specified by:
feed
in interfaceIngestClient
- Specified by:
feed
in interfaceSecurityFeeder
- Overrides:
feed
in classContentFeeder
- Parameters:
doc
- the documentacl
- the ACL- Throws:
AttivioException
- if sending of documents fails.
-
feed
public void feed(AttivioPrincipal principal) throws AttivioException
Description copied from class:ContentFeeder
Ingests an AttivioPrincipal. Any existing data for the principal and its associations will be deleted.- Specified by:
feed
in interfaceIngestClient
- Specified by:
feed
in interfaceSecurityFeeder
- Overrides:
feed
in classContentFeeder
- Parameters:
principal
- the principal- Throws:
AttivioException
- if sending of documents fails.
-
put
public void put(IngestDocument doc, java.lang.String fieldName, java.lang.String id, java.io.InputStream is) throws AttivioException
Description copied from interface:DocumentPublisher
Store the content stream in the content store an put aContentPointer
in the indicated document field.- Specified by:
put
in interfaceDocumentPublisher
- Parameters:
doc
- the Attivio document where theContentPointer
should be placed.fieldName
- to put theContentPointer
in.id
- An id to identify the content in the content store. Could be any id that will guarantee uniqueness e.g.UUID.randomUUID()
.is
- the stream of content.- Throws:
AttivioException
-
isInTestMode
public boolean isInTestMode()
Description copied from interface:DocumentPublisher
Test mode is set by the user to quickly test that scanner can connect and fetch data. It is typically used by the scanner to avoid changing the state of incremental scanning when in test mode.- Specified by:
isInTestMode
in interfaceDocumentPublisher
- Returns:
- true if running in test mode
-
setStopped
public void setStopped(boolean stopped)
-
setMaxDocs
public void setMaxDocs(long maxDocs)
-
getSentMessages
public java.util.List<PlatformMessage> getSentMessages() throws AttivioException
- Throws:
AttivioException
-
-