|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.ektorp.impl.StdCouchDbConnector
public class StdCouchDbConnector
| Field Summary | |
|---|---|
protected URI |
dbURI
|
protected com.fasterxml.jackson.databind.ObjectMapper |
objectMapper
|
protected QueryExecutor |
queryExecutor
|
protected RestTemplate |
restTemplate
|
protected RevisionResponseHandler |
revisionHandler
|
| Constructor Summary | |
|---|---|
StdCouchDbConnector(String databaseName,
CouchDbInstance dbInstance)
|
|
StdCouchDbConnector(String databaseName,
CouchDbInstance dbi,
ObjectMapperFactory om)
|
|
| Method Summary | ||
|---|---|---|
void |
addToBulkBuffer(Object o)
Add the object to the bulk buffer attached to the executing thread. |
|
protected void |
assertDocIdHasValue(String docId)
|
|
String |
callUpdateHandler(String designDocID,
String function,
String docID)
|
|
String |
callUpdateHandler(String designDocID,
String function,
String docID,
Map<String,String> params)
|
|
String |
callUpdateHandler(UpdateHandlerRequest req)
|
|
|
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(Collection<?> objects,
boolean allOrNothing)
|
|
List<DocumentOperationResult> |
executeBulk(InputStream inputStream)
Creates, updates or deletes all objects in the supplied collection. |
|
List<DocumentOperationResult> |
executeBulk(InputStream inputStream,
boolean allOrNothing)
|
|
protected
|
executeQuery(ViewQuery query,
ResponseCallback<T> rh)
|
|
|
find(Class<T> c,
String id)
Same as get(Class |
|
|
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). |
|
|
get(Class<T> c,
String id)
|
|
|
get(Class<T> c,
String id,
Options options)
|
|
|
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 |
getCurrentRevision(String id)
Obtain the current revision of a document using a lightweight request. |
|
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)
|
|
Security |
getSecurity()
Provides access to the database's underlying security configuration |
|
|
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. |
|
|
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)
|
|
|
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. |
|
protected String |
serializeToJson(Object o)
|
|
void |
setCollectionBulkExecutor(BulkExecutor<Collection<?>> collectionBulkExecutor)
|
|
void |
setInputStreamBulkExecutor(BulkExecutor<InputStream> inputStreamBulkExecutor)
|
|
void |
setJsonSerializer(JsonSerializer js)
Deprecated. override method serializeToJson in order to change Serialization to JSON. |
|
void |
setLocalBulkBuffer(LocalBulkBuffer localBulkBuffer)
|
|
void |
setQueryExecutor(QueryExecutor queryExecutor)
Set an alternative QueryExecutor instance in order to change the executeQuery implementation as you like. |
|
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. |
|
Status |
updateSecurity(Security security)
Provides a way to update the database's underlying security configuration |
|
protected String |
URIWithDocId(String id)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
protected final URI dbURI
protected final RestTemplate restTemplate
protected QueryExecutor queryExecutor
protected final RevisionResponseHandler revisionHandler
| Constructor Detail |
|---|
public StdCouchDbConnector(String databaseName,
CouchDbInstance dbInstance)
public StdCouchDbConnector(String databaseName,
CouchDbInstance dbi,
ObjectMapperFactory om)
| Method Detail |
|---|
public void setLocalBulkBuffer(LocalBulkBuffer localBulkBuffer)
public void setCollectionBulkExecutor(BulkExecutor<Collection<?>> collectionBulkExecutor)
public void setInputStreamBulkExecutor(BulkExecutor<InputStream> inputStreamBulkExecutor)
public void setQueryExecutor(QueryExecutor queryExecutor)
public String path()
path in interface CouchDbConnectorpublic void create(Object o)
CouchDbConnector
create in interface CouchDbConnector
public void create(String id,
Object node)
create in interface CouchDbConnectorprotected String URIWithDocId(String id)
public boolean contains(String id)
CouchDbConnector
contains in interface CouchDbConnector
public String createAttachment(String docId,
AttachmentInputStream data)
CouchDbConnector
createAttachment in interface CouchDbConnector
public String createAttachment(String docId,
String revision,
AttachmentInputStream data)
CouchDbConnector
createAttachment in interface CouchDbConnector
public AttachmentInputStream getAttachment(String id,
String attachmentId)
CouchDbConnector
getAttachment in interface CouchDbConnector
public AttachmentInputStream getAttachment(String id,
String attachmentId,
String revision)
getAttachment in interface CouchDbConnectorpublic String delete(Object o)
CouchDbConnector
delete in interface CouchDbConnectorpublic PurgeResult purge(Map<String,List<String>> revisionsToPurge)
CouchDbConnector
purge in interface CouchDbConnectorrevisionsToPurge - document IDs & revisions to be purged
public <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)
CouchDbConnector
getWithConflicts 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)
CouchDbConnector
find in interface CouchDbConnector
public <T> T find(Class<T> c,
String id,
Options options)
CouchDbConnector
find in interface CouchDbConnectorpublic List<Revision> getRevisions(String id)
getRevisions in interface CouchDbConnectorpublic String getCurrentRevision(String id)
CouchDbConnector
getCurrentRevision in interface CouchDbConnectorpublic InputStream getAsStream(String id)
CouchDbConnector
getAsStream in interface CouchDbConnector
public InputStream getAsStream(String id,
Options options)
CouchDbConnector
getAsStream in interface CouchDbConnector
public InputStream getAsStream(String id,
String rev)
CouchDbConnector
getAsStream in interface CouchDbConnectorpublic void update(Object o)
CouchDbConnector
update in interface CouchDbConnector
public String delete(String id,
String revision)
CouchDbConnector
delete in interface CouchDbConnector
public String copy(String sourceDocId,
String targetDocId)
CouchDbConnector
copy in interface CouchDbConnector
public String copy(String sourceDocId,
String targetDocId,
String targetRevision)
CouchDbConnector
copy in interface CouchDbConnectorpublic List<String> getAllDocIds()
getAllDocIds in interface CouchDbConnectorpublic void createDatabaseIfNotExists()
CouchDbConnector
createDatabaseIfNotExists in interface CouchDbConnectorpublic String getDatabaseName()
getDatabaseName in interface CouchDbConnector
public <T> List<T> queryView(ViewQuery query,
Class<T> type)
CouchDbConnector
queryView in interface CouchDbConnectortype - the type to map the result to
protected <T> T executeQuery(ViewQuery query,
ResponseCallback<T> rh)
public <T> Page<T> queryForPage(ViewQuery query,
PageRequest pr,
Class<T> type)
CouchDbConnector
queryForPage in interface CouchDbConnectorpublic ViewResult queryView(ViewQuery query)
queryView in interface CouchDbConnectorpublic StreamingViewResult queryForStreamingView(ViewQuery query)
CouchDbConnector
queryForStreamingView in interface CouchDbConnectorpublic InputStream queryForStream(ViewQuery query)
queryForStream in interface CouchDbConnector
public String deleteAttachment(String docId,
String revision,
String attachmentId)
deleteAttachment in interface CouchDbConnectorprotected void assertDocIdHasValue(String docId)
public HttpClient getConnection()
CouchDbConnector
getConnection in interface CouchDbConnectorpublic DbInfo getDbInfo()
CouchDbConnector
getDbInfo in interface CouchDbConnectorpublic Security getSecurity()
CouchDbConnector
getSecurity in interface CouchDbConnectorSecuritypublic Status updateSecurity(Security security)
CouchDbConnector
updateSecurity in interface CouchDbConnectorsecurity - the Security to update
Statuspublic DesignDocInfo getDesignDocInfo(String designDocId)
CouchDbConnector
getDesignDocInfo in interface CouchDbConnectorpublic void compact()
CouchDbConnector
compact in interface CouchDbConnectorpublic void cleanupViews()
CouchDbConnector
cleanupViews in interface CouchDbConnectorpublic ReplicationStatus replicateFrom(String source)
CouchDbConnector
replicateFrom in interface CouchDbConnectorsource - database
public ReplicationStatus replicateFrom(String source,
Collection<String> docIds)
CouchDbConnector
replicateFrom in interface CouchDbConnectorsource - database
public ReplicationStatus replicateTo(String target)
CouchDbConnector
replicateTo in interface CouchDbConnectortarget - database
public ReplicationStatus replicateTo(String target,
Collection<String> docIds)
CouchDbConnector
replicateTo in interface CouchDbConnectortarget - database
public void compactViews(String designDocumentId)
CouchDbConnector
compactViews in interface CouchDbConnectorpublic List<DocumentOperationResult> executeAllOrNothing(InputStream inputStream)
CouchDbConnector
executeAllOrNothing in interface CouchDbConnectorpublic List<DocumentOperationResult> executeBulk(InputStream inputStream)
CouchDbConnector
executeBulk in interface CouchDbConnector
public List<DocumentOperationResult> executeBulk(InputStream inputStream,
boolean allOrNothing)
public List<DocumentOperationResult> executeAllOrNothing(Collection<?> objects)
CouchDbConnector
executeAllOrNothing in interface CouchDbConnectorobjects - , all objects will have their id and revision set.
public List<DocumentOperationResult> executeBulk(Collection<?> objects)
CouchDbConnector
executeBulk in interface CouchDbConnectorobjects - , all objects will have their id and revision set.
public void addToBulkBuffer(Object o)
LocalBulkBuffer
addToBulkBuffer in interface LocalBulkBufferpublic void clearBulkBuffer()
LocalBulkBuffer
clearBulkBuffer in interface LocalBulkBufferpublic List<DocumentOperationResult> flushBulkBuffer()
LocalBulkBuffer
flushBulkBuffer in interface LocalBulkBuffer@Deprecated public void setJsonSerializer(JsonSerializer js)
protected String serializeToJson(Object o)
public List<DocumentOperationResult> executeBulk(Collection<?> objects,
boolean allOrNothing)
public int getRevisionLimit()
CouchDbConnector
getRevisionLimit in interface CouchDbConnectorpublic void setRevisionLimit(int limit)
setRevisionLimit in interface CouchDbConnectorpublic List<DocumentChange> changes(ChangesCommand cmd)
CouchDbConnector
changes in interface CouchDbConnectorpublic StreamingChangesResult changesAsStream(ChangesCommand cmd)
CouchDbConnector
changesAsStream in interface CouchDbConnectorpublic ChangesFeed changesFeed(ChangesCommand cmd)
CouchDbConnector
changesFeed in interface CouchDbConnector
public String callUpdateHandler(String designDocID,
String function,
String docID)
callUpdateHandler in interface CouchDbConnector
public String callUpdateHandler(String designDocID,
String function,
String docID,
Map<String,String> params)
callUpdateHandler in interface CouchDbConnectorpublic String callUpdateHandler(UpdateHandlerRequest req)
callUpdateHandler in interface CouchDbConnector
public <T> T callUpdateHandler(UpdateHandlerRequest req,
Class<T> c)
callUpdateHandler in interface CouchDbConnectorpublic void ensureFullCommit()
CouchDbConnector
ensureFullCommit in interface CouchDbConnector
public void updateMultipart(String id,
InputStream stream,
String boundary,
long length,
Options options)
CouchDbConnector
updateMultipart 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 request
public void update(String id,
InputStream document,
long length,
Options options)
CouchDbConnector
update in interface CouchDbConnectorid - the document IDdocument - an InputStream of the JSON documentlength - the length of the JSON documentoptions - options to pass to the Couch request
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||