Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package ca.carleton.gcrc.couch.command.impl;
 
 
public class CommandSupport {
	static public CouchClient createCouchClient(
		,AtlasProperties atlasProperties
throws Exception {
		// Create couch client
		CouchClient couchClient = null;
		{
			Properties couchClientProps = new Properties();
			couchClientProps.put("couchdb.server"atlasProperties.getCouchDbUrl().toExternalForm());
			couchClientProps.put("couchdb.user"atlasProperties.getCouchDbAdminUser());
			couchClientProps.put("couchdb.password"atlasProperties.getCouchDbAdminPassword());
			CouchFactory couchFactory = new CouchFactory();
			couchClient = couchFactory.getClient(couchClientProps);
			// Verify that we can connect to the server
			try {
				couchClient.validateContext();
catch(Exception e) {
				throw new Exception("Unable to connect to the server. Probably wrong user name or password.",e);
			}
		}
		return couchClient;
	}
	static public CouchDb createCouchDb(
		,AtlasProperties atlasProperties
throws Exception {
		CouchClient couchClient = createCouchClient(gsatlasProperties);
		// Get database from Couch Client
		CouchDb couchDb = null;
		{
			String dbName = atlasProperties.getCouchDbName();
			iffalse == couchClient.databaseExists(dbName) ) {
				couchClient.createDatabase(dbName);
			}
			couchDb = couchClient.getDatabase(dbName);
		}
		return couchDb;
	}
New to GrepCode? Check out our FAQ X