package biz.plexers.sparrow.db;

public class DbManager {

}

@@ -32,34 +32,1206 @@
 %0D%0A%0D%0A
-public class DbManager %7B%0D%0A
+import java.net.MalformedURLException;%0D%0A%0D%0Aimport org.ektorp.CouchDbConnector;%0D%0Aimport org.ektorp.CouchDbInstance;%0D%0Aimport org.ektorp.DbAccessException;%0D%0Aimport org.ektorp.http.HttpClient;%0D%0Aimport org.ektorp.http.StdHttpClient;%0D%0Aimport org.ektorp.impl.StdCouchDbInstance;%0D%0A%0D%0Aimport biz.plexers.sparrow.db.exceptions.SignInException;%0D%0A%0D%0Apublic class DbManager %7B%0D%0A%09private static HttpClient client = null;%0D%0A%09private static CouchDbConnector db = null;%0D%0A%09private static String dbURL = %22db.plexers.biz:96%22;%0D%0A%09private static String dbName = %22sol%22;%0D%0A%0D%0A%09public static boolean signIn(String username, String password) throws SignInException %7B%0D%0A%09%09if (client == null) %7B%0D%0A%09%09%09try %7B%0D%0A%09%09%09%09client = new StdHttpClient.Builder().url(dbURL)%0D%0A%09%09%09%09%09%09.username(username).password(password).build();%0D%0A%09%09%09%7D catch (MalformedURLException e) %7B%0D%0A%09%09%09%09e.printStackTrace();%0D%0A%09%09%09%7D%0D%0A%09%09%09CouchDbInstance dbInstance = new StdCouchDbInstance(client);%0D%0A%09%09%09db = dbInstance.createConnector(dbName, true);%0D%0A%09%09%09try %7B%0D%0A%09%09%09%09db.getAsStream(%22welcome%22);%0D%0A%09%09%09%7D catch (DbAccessException e) %7B%0D%0A%09%09%09%09throw new SignInException(%22Invalid Username or Password!%22);%0D%0A%09%09%09%7D%0D%0A%09%09%09return true;%0D%0A%09%09%7D%0D%0A%09%09throw new SignInException(%22You are already signed in!%22);%0D%0A%09%7D
 %0D%0A%7D%0D

Implement signIn method