package biz.plexers.sparrow.db;

import java.net.MalformedURLException;

import org.ektorp.CouchDbConnector;
import org.ektorp.CouchDbInstance;
import org.ektorp.DbAccessException;
import org.ektorp.http.HttpClient;
import org.ektorp.http.StdHttpClient;
import org.ektorp.impl.StdCouchDbInstance;

import biz.plexers.sparrow.db.exceptions.SignInException;

public class DbManager {
	private static HttpClient client = null;
	private static CouchDbConnector db = null;
	private static String dbURL = "db.plexers.biz:96";
	private static String dbName = "sol";

	public static boolean signIn(String username, String password) throws SignInException {
		if (client == null) {
			try {
				client = new StdHttpClient.Builder().url(dbURL)
						.username(username).password(password).build();
			} catch (MalformedURLException e) {
				e.printStackTrace();
			}
			CouchDbInstance dbInstance = new StdCouchDbInstance(client);
			db = dbInstance.createConnector(dbName, true);
			try {
				db.getAsStream("welcome");
			} catch (DbAccessException e) {
				throw new SignInException("Invalid Username or Password!");
			}
			return true;
		}
		throw new SignInException("You are already signed in!");
	}
}

@@ -509,16 +509,23 @@
 bURL = %22
+http://
 db.plexe
@@ -642,17 +642,21 @@
 assword)
- 
+%0D%0A%09%09%09
 throws S
@@ -953,16 +953,27 @@
 ient);%0D%0A
+%09%09%09try %7B%0D%0A%09
 %09%09%09db = 
@@ -1019,50 +1019,8 @@
 );%0D%0A
-%09%09%09try %7B%0D%0A%09%09%09%09db.getAsStream(%22welcome%22);%0D%0A
 %09%09%09%7D

Fix db link and signIn method