public DateRobotThread(CouchDesignDocument atlasDesign, Tree clusterTree) throws Exception { this.atlasDesign = atlasDesign; this.clusterTree = clusterTree; noWorkDelayInMs = DELAY_NO_WORK_POLLING; CouchDbChangeMonitor changeMonitor = atlasDesign.getDatabase().getChangeMonitor(); if( null != changeMonitor ){ changeMonitor.addChangeListener(this); noWorkDelayInMs = DELAY_NO_WORK_MONITOR; } }
private CouchAuthenticationContext getUserFromClient(CouchClient client) throws Exception { CouchSession session = client.getSession(); return session.getAuthenticationContext(); } }
@Override public void createDocument(JSONObject doc) throws Exception { dd.getDatabase().createDocument(doc); }
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 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; }
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 AgreementRobotThread(AgreementRobotSettings settings) throws Exception { this.atlasName = settings.getAtlasName(); this.documentDbDesignDocument = settings.getDocumentDesignDocument(); this.userDbDesignDocument = settings.getUserDb().getDesignDocument("nunaliit_user"); agreementRole = "nunaliit_agreement_atlas"; if( null != atlasName ){ agreementRole = "nunaliit_agreement_" + atlasName; } noWorkDelay = DELAY_NO_WORK_POLLING; CouchDbChangeMonitor changeMonitor = documentDbDesignDocument.getDatabase().getChangeMonitor(); if( null != changeMonitor ){ noWorkDelay = DELAY_NO_WORK_MONITOR; changeMonitor.addChangeListener(this); } }
public CouchDb getDb(CouchContext context, CouchDb clonedDb) throws Exception { CouchClient client = getClient(context, clonedDb.getClient()); CouchDbImpl couchDb = new CouchDbImpl(client, clonedDb.getUrl()); return couchDb; } }
public CouchClient getClient() { return dd.getDatabase().getClient(); }
@Override public boolean treeExists() throws Exception { CouchDb db = atlasDesign.getDatabase(); boolean exists = false; try { exists = db.documentExists(DATE_CLUSTER_DOC_ID); } catch (Exception e) { // Ignore for now throw new Exception("Unable to verify cluster document existence", e); } return exists; }
public ConfigServletActions(CouchDb couchDb, String couchDbName){ this.couchDb = couchDb; this.couchClient = couchDb.getClient(); this.couchDbName = couchDbName; }
@Override public CouchAuthenticationContext getUserFromName(String userName) throws Exception { CouchUserDb userDb = getClient().getUserDatabase(); return userDb.getUserFromName(userName); } }
@Override public CouchContext getContext() { return client.getContext(); }
@Override public void computeUserPassword(JSONObject userDoc, String password) throws Exception { userDb.computeUserPassword(userDoc, password); } }
@Override public JSONObject getUserFromId(String id) throws Exception { return userDb.getDocument(id); }
@Override public void createUser(JSONObject userDoc) throws Exception { userDb.createDocument(userDoc); }
@Override public CouchContext getContext() { return database.getContext(); }
@Override public void updateUser(JSONObject userDoc) throws Exception { userDb.updateDocument(userDoc); }
@Override public CouchContext getContext() { return client.getContext(); }