@Override public void createDocument(JSONObject doc) throws Exception { dd.getDatabase().createDocument(doc); }
public JSONObject deleteDocument( CouchAuthenticationContext authContext ,String dbIdentifier ,String docId ,String rev ) throws Exception { if( "submissionDb".equals(dbIdentifier) ) { if( null == docId || null == rev ){ throw new Exception("Document identifier and revision must be specified"); } JSONObject originalDoc = null; { CouchDocumentOptions options = new CouchDocumentOptions(); options.setRevision( rev ); originalDoc = documentCouchDb.getDocument(docId, options); } JSONObject submissionRequest = buildSubmissionRequest(authContext, null, originalDoc); JSONObject result = submissionDesign.getDatabase().createDocument(submissionRequest); return result; } else { throw new Exception("Only operations against 'submissionDb' are accepted"); } }
userCouchDb.createDocument(doc);
JSONObject result = submissionDesign.getDatabase().createDocument(submissionRequest);
@Override public void saveTree(Tree tree) throws Exception { CouchDb db = atlasDesign.getDatabase(); boolean exists = db.documentExists(DATE_CLUSTER_DOC_ID); JSONObject jsonDoc = null; if( exists ) { jsonDoc = db.getDocument(DATE_CLUSTER_DOC_ID); } else { jsonDoc = new JSONObject(); jsonDoc.put("_id", "org.nunaliit.date_clusters"); } jsonDoc.put("nunaliit_date_clusters", tree.toJSON()); CouchAuthenticationContext authContext = db.getClient().getSession().getAuthenticationContext(); CouchNunaliitUtils.adjustDocumentForStorage(jsonDoc, authContext); if( exists ){ db.updateDocument(jsonDoc); } else { db.createDocument(jsonDoc); } }
targetDb.createDocument(originalDoc);