/** * Updates an object in the database, the object must have the correct <code>_id</code> and <code>_rev</code> values. * @param object The object to update * @throws DocumentConflictException If a conflict is detected during the update. * @return {@link Response} */ public Response update(Object object) { return put(getDBUri(), object, false); }
/** * Saves an object in the database, using HTTP <tt>PUT</tt> request. * <p>If the object doesn't have an <code>_id</code> value, the code will assign a <code>UUID</code> as the document id. * @param object The object to save * @throws DocumentConflictException If a conflict is detected during the save. * @return {@link Response} */ public Response save(Object object) { return put(getDBUri(), object, true); }
/** * Adds a new document to the replicator database. * @return {@link Response} */ public Response save() { assertNotEmpty(replicatorDoc.getSource(), "Source"); assertNotEmpty(replicatorDoc.getTarget(), "Target"); if(userCtxName != null) { UserCtx ctx = replicatorDoc.new UserCtx(); ctx.setName(userCtxName); ctx.setRoles(userCtxRoles); replicatorDoc.setUserCtx(ctx); } return dbc.put(dbURI, replicatorDoc, true); }
/** * Saves an attachment to a new document with a generated <tt>UUID</tt> as the document id. * <p>To retrieve an attachment, see {@link #find(String)}. * @param in The {@link InputStream} holding the binary data. * @param name The attachment name. * @param contentType The attachment "Content-Type". * @return {@link Response} */ public Response saveAttachment(InputStream in, String name, String contentType) { assertNotEmpty(in, "in"); assertNotEmpty(name, "name"); assertNotEmpty(contentType, "ContentType"); final URI uri = buildUri(getDBUri()).path(generateUUID()).path("/").path(name).build(); return put(uri, in, contentType); }
/** * Saves an attachment to an existing document given both a document id * and revision, or save to a new document given only the id, and rev as {@code null}. * <p>To retrieve an attachment, see {@link #find(String)}. * @param in The {@link InputStream} holding the binary data. * @param name The attachment name. * @param contentType The attachment "Content-Type". * @param docId The document id to save the attachment under, or {@code null} to save under a new document. * @param docRev The document revision to save the attachment under, or {@code null} when saving to a new document. * @return {@link Response} */ public Response saveAttachment(InputStream in, String name, String contentType, String docId, String docRev) { assertNotEmpty(in, "in"); assertNotEmpty(name, "name"); assertNotEmpty(contentType, "ContentType"); assertNotEmpty(docId, "docId"); final URI uri = buildUri(getDBUri()).pathEncoded(docId).path("/").path(name).query("rev", docRev).build(); return put(uri, in, contentType); }