public class StdCouchDbConnector extends Object implements CouchDbConnector
| Constructor and Description |
|---|
StdCouchDbConnector(String databaseName,
CouchDbInstance dbInstance) |
StdCouchDbConnector(String databaseName,
CouchDbInstance dbi,
ObjectMapperFactory om) |
| Modifier and Type | Method and Description |
|---|---|
void |
addToBulkBuffer(Object o)
Add the object to the bulk buffer attached to the executing thread.
|
String |
callUpdateHandler(String designDocID,
String function,
String docID) |
String |
callUpdateHandler(String designDocID,
String function,
String docID,
Map<String,String> params) |
String |
callUpdateHandler(UpdateHandlerRequest req) |
<T> T |
callUpdateHandler(UpdateHandlerRequest req,
Class<T> c) |
List<DocumentChange> |
changes(ChangesCommand cmd)
Queries the database for changes.
|
StreamingChangesResult |
changesAsStream(ChangesCommand cmd)
Queries the database for changes. this operation gives you the result as a iterable stream of documentchange objects,
the stream should be closed when finished
|
ChangesFeed |
changesFeed(ChangesCommand cmd)
Sets up a continuous changes feed.
|
void |
cleanupViews()
View indexes on disk are named after their MD5 hash of the view definition.
|
void |
clearBulkBuffer()
Clears the bulk buffer attached the the executing thread.
|
void |
compact()
Compaction compresses the database file by removing unused sections created during updates.
|
void |
compactViews(String designDocumentId)
This compacts the view index from the current version of the design document.
|
boolean |
contains(String id)
Check if the database contains a document.
|
String |
copy(String sourceDocId,
String targetDocId)
Copies a document to the target document id.
|
String |
copy(String sourceDocId,
String targetDocId,
String targetRevision)
Copies a document and overwrites the target document.
|
void |
create(Object o)
Creates the Object as a document in the database.
|
void |
create(String id,
Object node) |
String |
createAttachment(String docId,
AttachmentInputStream data)
Creates both the document and the attachment
|
String |
createAttachment(String docId,
String revision,
AttachmentInputStream data)
Adds an attachment to the specified document id.
|
void |
createDatabaseIfNotExists()
Creates a database on the configured path if it does not exists.
|
String |
delete(Object o)
Deletes the Object in the database.
|
String |
delete(String id,
String revision)
Deletes the document in the database.
|
String |
deleteAttachment(String docId,
String revision,
String attachmentId) |
void |
ensureFullCommit()
Commits any recent changes to the specified database to disk.
|
List<DocumentOperationResult> |
executeAllOrNothing(Collection<?> objects)
Creates, updates or deletes all objects in the supplied collection.
|
List<DocumentOperationResult> |
executeAllOrNothing(InputStream inputStream)
Creates, updates or deletes all objects in the supplied collection.
|
List<DocumentOperationResult> |
executeBulk(Collection<?> objects)
Creates, updates or deletes all objects in the supplied collection.
|
List<DocumentOperationResult> |
executeBulk(InputStream inputStream)
Creates, updates or deletes all objects in the supplied collection.
|
<T> T |
find(Class<T> c,
String id)
Same as get(Class
|
<T> T |
find(Class<T> c,
String id,
Options options)
Same as get(Class
|
List<DocumentOperationResult> |
flushBulkBuffer()
Sends the bulk buffer attached the the executing thread to the database (through a executeBulk call).
|
<T> T |
get(Class<T> c,
String id) |
<T> T |
get(Class<T> c,
String id,
Options options) |
<T> T |
get(Class<T> c,
String id,
String rev) |
List<String> |
getAllDocIds() |
InputStream |
getAsStream(String id)
Please note that the stream has to be closed after usage, otherwise http connection leaks will occur and the
system will eventually hang due to connection starvation.
|
InputStream |
getAsStream(String id,
Options options)
Please note that the stream has to be closed after usage, otherwise http connection leaks will occur and the
system will eventually hang due to connection starvation.
|
InputStream |
getAsStream(String id,
String rev)
Please note that the stream has to be closed after usage, otherwise http connection leaks will occur and the
system will eventually hang due to connection starvation.
|
AttachmentInputStream |
getAttachment(String id,
String attachmentId)
Reads an attachment from the database.
|
AttachmentInputStream |
getAttachment(String id,
String attachmentId,
String revision) |
HttpClient |
getConnection()
Convenience method for accessing the underlying HttpClient.
|
String |
getDatabaseName() |
DbInfo |
getDbInfo()
Provides meta information about this database.
|
DesignDocInfo |
getDesignDocInfo(String designDocId)
Obtains information about a given design document, including the index, index size and current status of the
design document and associated index information.
|
int |
getRevisionLimit()
Revision limit defines a upper bound of document revisions which CouchDB keeps track of
|
List<Revision> |
getRevisions(String id) |
<T> T |
getWithConflicts(Class<T> c,
String id)
Will load the document with any conflicts included.
|
String |
path() |
PurgeResult |
purge(Map<String,List<String>> revisionsToPurge)
Permanently removes the references to deleted documents from the database.
|
<T> Page<T> |
queryForPage(ViewQuery query,
PageRequest pr,
Class<T> type)
Provides paged view results.
|
InputStream |
queryForStream(ViewQuery query) |
StreamingViewResult |
queryForStreamingView(ViewQuery query)
Please note that the StreamingViewResult need to be closed after usage.
|
ViewResult |
queryView(ViewQuery query) |
<T> List<T> |
queryView(ViewQuery query,
Class<T> type)
This method requires the view result values to be document ids or documents :
If the value is a document id, then the document is fetched from couchDB.
|
ReplicationStatus |
replicateFrom(String source)
Replicate the content in the source database into this database.
|
ReplicationStatus |
replicateFrom(String source,
Collection<String> docIds)
Replicate the content in the source database into this database.
|
ReplicationStatus |
replicateTo(String target)
Replicate the content in this database into the specified target database.
|
ReplicationStatus |
replicateTo(String target,
Collection<String> docIds)
Replicate the content in this database into the specified target database.
|
void |
setJsonSerializer(JsonSerializer js) |
void |
setRevisionLimit(int limit) |
void |
update(Object o)
Updates the document.
|
void |
update(String id,
InputStream document,
long length,
Options options)
Sends a document to the Couch server as a JSON stream
|
void |
updateMultipart(String id,
InputStream stream,
String boundary,
long length,
Options options)
Sends a document to the Couch server as a MIME multipart/related message.
|
public StdCouchDbConnector(String databaseName, CouchDbInstance dbInstance)
public StdCouchDbConnector(String databaseName, CouchDbInstance dbi, ObjectMapperFactory om)
public String path()
path in interface CouchDbConnectorpublic void create(Object o)
CouchDbConnectorcreate in interface CouchDbConnectorpublic void create(String id, Object node)
create in interface CouchDbConnectorpublic boolean contains(String id)
CouchDbConnectorcontains in interface CouchDbConnectorpublic String createAttachment(String docId, AttachmentInputStream data)
CouchDbConnectorcreateAttachment in interface CouchDbConnectorpublic String createAttachment(String docId, String revision, AttachmentInputStream data)
CouchDbConnectorcreateAttachment in interface CouchDbConnectorpublic AttachmentInputStream getAttachment(String id, String attachmentId)
CouchDbConnectorgetAttachment in interface CouchDbConnectorpublic AttachmentInputStream getAttachment(String id, String attachmentId, String revision)
getAttachment in interface CouchDbConnectorpublic String delete(Object o)
CouchDbConnectordelete in interface CouchDbConnectorpublic PurgeResult purge(Map<String,List<String>> revisionsToPurge)
CouchDbConnectorpurge in interface CouchDbConnectorrevisionsToPurge - document IDs & revisions to be purgedpublic <T> T get(Class<T> c, String id)
get in interface CouchDbConnectorc - the target class to map to.id - the id of the document in the database.public <T> T get(Class<T> c, String id, Options options)
get in interface CouchDbConnectorc - the target class to map to.id - the id of the document in the database.public <T> T get(Class<T> c, String id, String rev)
get in interface CouchDbConnectorc - the target class to map to.id - the id of the document in the database.rev - of the object.public <T> T getWithConflicts(Class<T> c, String id)
CouchDbConnectorgetWithConflicts in interface CouchDbConnectorc - the target class to map to.id - the id of the document in the database.public <T> T find(Class<T> c, String id)
CouchDbConnectorfind in interface CouchDbConnectorpublic <T> T find(Class<T> c, String id, Options options)
CouchDbConnectorfind in interface CouchDbConnectorpublic List<Revision> getRevisions(String id)
getRevisions in interface CouchDbConnectorpublic InputStream getAsStream(String id)
CouchDbConnectorgetAsStream in interface CouchDbConnectorpublic InputStream getAsStream(String id, Options options)
CouchDbConnectorgetAsStream in interface CouchDbConnectorpublic InputStream getAsStream(String id, String rev)
CouchDbConnectorgetAsStream in interface CouchDbConnectorpublic void update(Object o)
CouchDbConnectorupdate in interface CouchDbConnectorpublic String delete(String id, String revision)
CouchDbConnectordelete in interface CouchDbConnectorpublic String copy(String sourceDocId, String targetDocId)
CouchDbConnectorcopy in interface CouchDbConnectorpublic String copy(String sourceDocId, String targetDocId, String targetRevision)
CouchDbConnectorcopy in interface CouchDbConnectorpublic List<String> getAllDocIds()
getAllDocIds in interface CouchDbConnectorpublic void createDatabaseIfNotExists()
CouchDbConnectorcreateDatabaseIfNotExists in interface CouchDbConnectorpublic String getDatabaseName()
getDatabaseName in interface CouchDbConnectorpublic <T> List<T> queryView(ViewQuery query, Class<T> type)
CouchDbConnectorqueryView in interface CouchDbConnectortype - the type to map the result topublic <T> Page<T> queryForPage(ViewQuery query, PageRequest pr, Class<T> type)
CouchDbConnectorqueryForPage in interface CouchDbConnectorpublic ViewResult queryView(ViewQuery query)
queryView in interface CouchDbConnectorpublic StreamingViewResult queryForStreamingView(ViewQuery query)
CouchDbConnectorqueryForStreamingView in interface CouchDbConnectorpublic InputStream queryForStream(ViewQuery query)
queryForStream in interface CouchDbConnectorpublic String deleteAttachment(String docId, String revision, String attachmentId)
deleteAttachment in interface CouchDbConnectorpublic HttpClient getConnection()
CouchDbConnectorgetConnection in interface CouchDbConnectorpublic DbInfo getDbInfo()
CouchDbConnectorgetDbInfo in interface CouchDbConnectorpublic DesignDocInfo getDesignDocInfo(String designDocId)
CouchDbConnectorgetDesignDocInfo in interface CouchDbConnectorpublic void compact()
CouchDbConnectorcompact in interface CouchDbConnectorpublic void cleanupViews()
CouchDbConnectorcleanupViews in interface CouchDbConnectorpublic ReplicationStatus replicateFrom(String source)
CouchDbConnectorreplicateFrom in interface CouchDbConnectorsource - databasepublic ReplicationStatus replicateFrom(String source, Collection<String> docIds)
CouchDbConnectorreplicateFrom in interface CouchDbConnectorsource - databasepublic ReplicationStatus replicateTo(String target)
CouchDbConnectorreplicateTo in interface CouchDbConnectortarget - databasepublic ReplicationStatus replicateTo(String target, Collection<String> docIds)
CouchDbConnectorreplicateTo in interface CouchDbConnectortarget - databasepublic void compactViews(String designDocumentId)
CouchDbConnectorcompactViews in interface CouchDbConnectorpublic List<DocumentOperationResult> executeAllOrNothing(InputStream inputStream)
CouchDbConnectorexecuteAllOrNothing in interface CouchDbConnectorpublic List<DocumentOperationResult> executeBulk(InputStream inputStream)
CouchDbConnectorexecuteBulk in interface CouchDbConnectorpublic List<DocumentOperationResult> executeAllOrNothing(Collection<?> objects)
CouchDbConnectorexecuteAllOrNothing in interface CouchDbConnectorobjects - , all objects will have their id and revision set.public List<DocumentOperationResult> executeBulk(Collection<?> objects)
CouchDbConnectorexecuteBulk in interface CouchDbConnectorobjects - , all objects will have their id and revision set.public void addToBulkBuffer(Object o)
CouchDbConnectoraddToBulkBuffer in interface CouchDbConnectorpublic void clearBulkBuffer()
CouchDbConnectorclearBulkBuffer in interface CouchDbConnectorpublic List<DocumentOperationResult> flushBulkBuffer()
CouchDbConnectorflushBulkBuffer in interface CouchDbConnectorpublic void setJsonSerializer(JsonSerializer js)
public int getRevisionLimit()
CouchDbConnectorgetRevisionLimit in interface CouchDbConnectorpublic void setRevisionLimit(int limit)
setRevisionLimit in interface CouchDbConnectorpublic List<DocumentChange> changes(ChangesCommand cmd)
CouchDbConnectorchanges in interface CouchDbConnectorpublic StreamingChangesResult changesAsStream(ChangesCommand cmd)
CouchDbConnectorchangesAsStream in interface CouchDbConnectorpublic ChangesFeed changesFeed(ChangesCommand cmd)
CouchDbConnectorchangesFeed in interface CouchDbConnectorpublic String callUpdateHandler(String designDocID, String function, String docID)
callUpdateHandler in interface CouchDbConnectorpublic String callUpdateHandler(String designDocID, String function, String docID, Map<String,String> params)
callUpdateHandler in interface CouchDbConnectorpublic String callUpdateHandler(UpdateHandlerRequest req)
callUpdateHandler in interface CouchDbConnectorpublic <T> T callUpdateHandler(UpdateHandlerRequest req, Class<T> c)
callUpdateHandler in interface CouchDbConnectorpublic void ensureFullCommit()
CouchDbConnectorensureFullCommit in interface CouchDbConnectorpublic void updateMultipart(String id, InputStream stream, String boundary, long length, Options options)
CouchDbConnectorupdateMultipart in interface CouchDbConnectorid - the document IDstream - an InputStream of the multipart message containing
the document and any attachmentsboundary - the boundary of the multipart/related message partslength - the length of the MIME multipart message streamoptions - options to pass to the Couch requestpublic void update(String id, InputStream document, long length, Options options)
CouchDbConnectorupdate in interface CouchDbConnectorid - the document IDdocument - an InputStream of the JSON documentlength - the length of the JSON documentoptions - options to pass to the Couch requestCopyright © 2012. All Rights Reserved.