public ConfigServletActions(CouchDb couchDb, String couchDbName){ this.couchDb = couchDb; this.couchClient = couchDb.getClient(); this.couchDbName = couchDbName; }
public SubmissionMailNotifierImpl( String atlasName ,MailDelivery mailDelivery ,CouchDb couchDb ) throws Exception { this.atlasName = atlasName; this.mailDelivery = mailDelivery; // Set up user database access CouchClient couchClient = couchDb.getClient(); userDesignDocument = UserDesignDocumentImpl.getUserDesignDocument(couchClient); }
public MailNotificationImpl( String atlasName ,MailDelivery mailDelivery ,CouchDb couchDb ) throws Exception { this.atlasName = atlasName; this.mailDelivery = mailDelivery; // this.couchDb = couchDb; // Set up user database access CouchClient couchClient = couchDb.getClient(); userDesignDocument = UserDesignDocumentImpl.getUserDesignDocument(couchClient); }
public CouchClient getClient() { return dd.getDatabase().getClient(); }
public JSONObject getUuids(CouchAuthenticationContext authContext, int count) throws Exception { try { String[] uuids = submissionDesign.getDatabase().getClient().getUuids(count); JSONObject result = new JSONObject(); JSONArray jsonUuids = new JSONArray(); for(int loop=0; loop<uuids.length; ++loop){ jsonUuids.put(uuids[loop]); } result.put("uuids", jsonUuids); return result; } catch (Exception e) { throw new Exception("Error while obtaining uuids",e); } }
synchronized public JSONObject getWelcome() throws Exception{ if( null == cached_welcome ){ cached_welcome = new JSONObject(); cached_welcome.put("SubmissionServlet", true); if( null != submissionDesign ){ cached_welcome.put("submissionDbAvailable", true); } else { cached_welcome.put("submissionDbAvailable", false); } CouchServerVersion version = submissionDesign.getDatabase().getClient().getVersion(); cached_welcome.put("version", version.getFullVersion()); } return cached_welcome; }
public CouchDb getDb(CouchContext context, CouchDb clonedDb) throws Exception { CouchClient client = getClient(context, clonedDb.getClient()); CouchDbImpl couchDb = new CouchDbImpl(client, clonedDb.getUrl()); return couchDb; } }
@Override public CouchAuthenticationContext getRolesFromAuthentication(Cookie[] cookies) throws Exception { CouchContextCookie contextCookie = new CouchContextCookie(); for(Cookie cookie : cookies){ contextCookie.setCookie(cookie.getName(), cookie.getValue()); } CouchFactory factory = new CouchFactory(); CouchDb couchDb = factory.getDb(contextCookie, userDb); CouchSession session = couchDb.getClient().getSession(); CouchAuthenticationContext userContext = session.getAuthenticationContext(); return userContext; }
CouchAuthenticationContext userContext = getUserFromClient(userCouchDb.getClient());
private CouchAuthenticationContext getAuthenticationContextFromCookies(Cookie[] cookies) throws Exception { CouchContextCookie contextCookie = new CouchContextCookie(); if( null != cookies ) { for(Cookie cookie : cookies){ contextCookie.setCookie(cookie.getName(), cookie.getValue()); } } CouchClient client = documentDesign.getDatabase().getClient(); CouchFactory factory = new CouchFactory(); CouchClient userClient = factory.getClient(contextCookie, client); CouchSession session = userClient.getSession(); CouchAuthenticationContext authContext = session.getAuthenticationContext(); return authContext; }
@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); } }