public AtlasInfo getAtlasInfo(CouchDb db, String databaseName) throws Exception { JSONObject atlasDesign = db.getDocument("_design/atlas"); JSONObject nunaliit = atlasDesign.optJSONObject("nunaliit"); String atlasName = nunaliit.getString("name"); boolean restricted = nunaliit.optBoolean("restricted",false); String submissionDbName = nunaliit.optString("submissionDbName",null); boolean submissionDbEnabled = nunaliit.optBoolean("submissionDbEnabled",false); AtlasInfo info = new AtlasInfo(databaseName, atlasName, restricted); info.setSubmissionDbName(submissionDbName); info.setSubmissionDbEnabled(submissionDbEnabled); return info; }
@Override public JSONObject getDocument() throws Exception { if( null == doc ){ logger.debug("Loading document "+docId); doc = documentDbDesign.getDatabase().getDocument(docId); originalDoc = JSONSupport.copyObject(doc); } return doc; }
@Override public Tree loadTree() throws Exception { CouchDb db = atlasDesign.getDatabase(); JSONObject jsonDoc = null; try { jsonDoc = db.getDocument(DATE_CLUSTER_DOC_ID); } catch (Exception e) { // Ignore for now throw new Exception("Unable to retrieve date cluster information", e); } // Rebuild tree from node information Tree tree = null; try { JSONObject jsonTree = jsonDoc.optJSONObject("nunaliit_date_clusters"); tree = Tree.restoreTree(jsonTree, this); } catch (Exception e) { throw new Exception("Unable to parse date cluster data", e); } return tree; }
JSONObject jsonObj = this.couchDb.getDocument(docId); this.jsonObj = jsonObj; } catch(Exception e) {
@Override public JSONObject getDocument() throws Exception { if( null == submittedDoc ){ logger.debug("Loading document "+docId); submissionDoc = submissionDbDesign.getDatabase().getDocument(docId); submittedDoc = SubmissionUtils.getSubmittedDocumentFromSubmission(submissionDoc); originalSubmissionDoc = JSONSupport.copyObject(submissionDoc); } return submittedDoc; }
JSONObject userDoc = userDbDesignDocument.getDatabase().getDocument(docId);
public JSONObject acceptUserAgreement(Cookie[] cookies, String userAgreement) throws Exception { JSONObject agreementDoc = couchDb.getDocument("org.nunaliit.user_agreement"); boolean agreementEnabled = AgreementUtils.getEnabledFromAgreementDocument(agreementDoc); Set<String> agreementContents =
public void performWork(String submissionDocId) throws Exception { JSONObject submissionDoc = submissionDb.getDocument(submissionDocId); JSONObject currentDoc = null; try { currentDoc = documentDb.getDocument(docId); } catch(Exception e) {
JSONObject agreementDoc = couchDb.getDocument("org.nunaliit.user_agreement"); Set<String> agreementContents = AgreementUtils.getContentsFromAgreementDocument(agreementDoc);
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"); } }
&& null != docId ) { try { doc = documentDb.getDocument(docId); } catch(Exception e) { logger.error("Unable load CouchDb e-mail template: "+docId);
CouchDocumentOptions options = new CouchDocumentOptions(); options.setRevision( doc.getString("_rev") ); originalDoc = documentCouchDb.getDocument(docId, options);
JSONObject uploaded = couchDb.getDocument(DD_ID); if( null != uploaded ){ uploadedVersion = uploaded.optInt(PROP_NAME_VERSION, 0);
boolean exist = db.documentExists(DOC_ID_NUNALIIT_USER_AGREEMENT); if( exist ) { agreementDoc = db.getDocument(DOC_ID_NUNALIIT_USER_AGREEMENT); } else { logger.error("User agreement document not found in database");
public void performProcessDocument(String docId) throws Exception { JSONObject jsonDoc = db.getDocument(docId);
@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); } }
JSONObject uploadRequestDoc = documentDbDesign.getDatabase().getDocument(uploadRequestDocId);
JSONObject toDeleteDoc = targetDb.getDocument(docId); targetDb.deleteDocument(toDeleteDoc);
currentTargetDoc = couchDb.getDocument(docId);