use of com.cloudant.client.internal.DatabaseURIHelper in project java-cloudant by cloudant.
the class CouchDatabaseBase method find.
/**
* Finds an Object of the specified type.
*
* @param <T> Object type.
* @param classType The class of type T.
* @param id The document _id field.
* @param rev The document _rev field.
* @return An object of type T.
* @throws NoDocumentException If the document is not found in the database.
*/
public <T> T find(Class<T> classType, String id, String rev) {
assertNotEmpty(classType, "Class");
assertNotEmpty(id, "id");
assertNotEmpty(id, "rev");
final URI uri = new DatabaseURIHelper(dbUri).documentUri(id, "rev", rev);
return couchDbClient.get(uri, classType);
}
use of com.cloudant.client.internal.DatabaseURIHelper in project java-cloudant by cloudant.
the class CouchDatabaseBase method post.
/**
* Saves an object in the database using HTTP <tt>POST</tt> request.
* <p>The database will be responsible for generating the document id.
*
* @param object The object to save
* @return {@link Response}
*/
public Response post(Object object) {
assertNotEmpty(object, "object");
InputStream response = null;
try {
response = couchDbClient.post(new DatabaseURIHelper(dbUri).getDatabaseUri(), getGson().toJson(object));
return getResponse(response, Response.class, getGson());
} finally {
close(response);
}
}
Aggregations