You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by er...@apache.org on 2011/07/09 11:02:34 UTC

svn commit: r1144620 [1/2] - in /tuscany/collaboration/GSoC-2011-Eranda: cassandra/ cassandra/src/main/java/org/apache/tuscany/nosqldatastore/ cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/ cassandra/src/main/java/org/apache/tusca...

Author: eranda
Date: Sat Jul  9 09:02:32 2011
New Revision: 1144620

URL: http://svn.apache.org/viewvc?rev=1144620&view=rev
Log:
1. Remove static variable in SessionFactory
2. Set spaces to 4
3. Exception handling
4. Rename *Test to *TestCase
5. Convert test cases in to JUnit
6. Rename addValue() method in Group.java to addEntry()
7. Updated the addEntry method signature to accept String type only


Added:
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/SessionException.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTestCase.java
      - copied, changed from r1137637, tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/SessionException.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/test/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBTestCase.java
      - copied, changed from r1137637, tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/test/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBTest.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/SessionException.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/test/java/org/apache/tuscany/nosqldatastore/hbase/HBaseTestCase.java
      - copied, changed from r1137637, tuscany/collaboration/GSoC-2011-Eranda/hbase/src/test/java/org/apache/tuscany/nosqldatastore/hbase/HBaseTest.java
Removed:
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/test/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBTest.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/test/java/org/apache/tuscany/nosqldatastore/hbase/HBaseTest.java
Modified:
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/pom.xml
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/pom.xml
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Database.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Group.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Session.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBDatatabase.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBGroup.java
    tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBSession.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/pom.xml
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Database.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Group.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Session.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/hbase/HBaseDatatabase.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/hbase/HBaseGroup.java
    tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/hbase/HBaseSession.java

Modified: tuscany/collaboration/GSoC-2011-Eranda/cassandra/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/pom.xml?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/pom.xml (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/pom.xml Sat Jul  9 09:02:32 2011
@@ -48,6 +48,11 @@ under the License.
             <artifactId>cassandra-all</artifactId>
             <version>0.7.4</version>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.8.2</version>
+        </dependency>
     </dependencies>
 
     <build>

Modified: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java Sat Jul  9 09:02:32 2011
@@ -18,8 +18,17 @@
  */
 package org.apache.tuscany.nosqldatastore;
 
+import org.apache.tuscany.nosqldatastore.exception.GroupNotFoundException;
+
+/*
+Database:
+Use to manipulate the groups, where  groups are use to categorize the data
+1. Creating a group
+2. Retrieving a group
+3. Deleting a group
+*/
 public interface Database {
-	Group createGroup(String groupId);
-	Group getGroup(String groupId);
-	void deleteGroup(String groupId);
+    Group createGroup(String groupId);
+    Group getGroup(String groupId);
+    void deleteGroup(String groupId) throws GroupNotFoundException;
 }

Modified: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java Sat Jul  9 09:02:32 2011
@@ -18,9 +18,20 @@
  */
 package org.apache.tuscany.nosqldatastore;
 
+import org.apache.tuscany.nosqldatastore.exception.DuplicateEntryException;
+import org.apache.tuscany.nosqldatastore.exception.EntryNotFoundException;
+
+/*
+Group:
+Group use to categorize the data into different categories
+1. Add entry to the database
+2. Update an existing entry
+3. Delete  an existing entry
+4. Get a existing entry
+ */
 public interface Group {
-	void addEntry(String key, Object value);
-	void updateEntry(String key, Object value);
-	void deleteEntry(String key);
-    Object getValue(String key);
+    void addEntry(String key, String value) throws DuplicateEntryException;
+    void updateEntry(String key, String value) throws EntryNotFoundException;
+    void deleteEntry(String key) throws EntryNotFoundException;
+    String getEntry(String key) throws EntryNotFoundException;
 }

Modified: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java Sat Jul  9 09:02:32 2011
@@ -18,8 +18,19 @@
  */
 package org.apache.tuscany.nosqldatastore;
 
+import org.apache.tuscany.nosqldatastore.exception.DatabaseNotFoundException;
+import org.apache.tuscany.nosqldatastore.exception.GroupNotFoundException;
+import org.apache.tuscany.nosqldatastore.exception.SessionException;
+
+/*
+Session:
+Session is a database session use to access the database
+1. Create a database
+2. Get instance of existing database
+3. Delete a database
+*/
 public interface Session {
-	Database createDatabase(String databaseName);
-	Database getDatabase(String databaseName);
-	void deleteDatabase(String databaseName);
+    Database createDatabase(String databaseName) throws SessionException;
+    Database getDatabase(String databaseName) throws SessionException;
+    void deleteDatabase(String databaseName) throws DatabaseNotFoundException, SessionException;
 }

Modified: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java Sat Jul  9 09:02:32 2011
@@ -20,16 +20,17 @@ package org.apache.tuscany.nosqldatastor
 
 import org.apache.tuscany.nosqldatastore.cassandra.CassandraSession;
 
-public class SessionFactory {
-	
-	private static org.apache.tuscany.nosqldatastore.Session session;
-	
-	private SessionFactory(){
-	}
-	
-	public static Session getCassandraSession(){
-		session = new CassandraSession("DataCluster");
-		return session;
-	}
-	
+public class
+        SessionFactory {
+
+    private org.apache.tuscany.nosqldatastore.Session session;
+
+    public SessionFactory(){
+    }
+
+    public Session getCassandraSession(){
+        session = new CassandraSession("DataCluster");
+        return session;
+    }
+
 }

Modified: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java Sat Jul  9 09:02:32 2011
@@ -23,17 +23,19 @@ import me.prettyprint.hector.api.Cluster
 import me.prettyprint.hector.api.Keyspace;
 import me.prettyprint.hector.api.ddl.KeyspaceDefinition;
 import me.prettyprint.hector.api.exceptions.HInvalidRequestException;
+import me.prettyprint.hector.api.exceptions.HectorException;
 import me.prettyprint.hector.api.factory.HFactory;
 import org.apache.tuscany.nosqldatastore.Database;
 import org.apache.tuscany.nosqldatastore.Group;
+import org.apache.tuscany.nosqldatastore.exception.GroupNotFoundException;
 
 class CassandraDatabase implements Database {
-	
+
 	private Keyspace keyspace;
 	private Cluster cluster;
-	
-	CassandraDatabase(String databaseName, Cluster cluster) {
-        try{            
+
+	CassandraDatabase(String databaseName, Cluster cluster) throws HectorException{
+        try{
             KeyspaceDefinition ksDef = new ThriftKsDef(databaseName, "org.apache.cassandra.locator.SimpleStrategy", 1, null);
             cluster.addKeyspace(ksDef);
         }catch (HInvalidRequestException e){
@@ -44,17 +46,22 @@ class CassandraDatabase implements Datab
 	}
 
 	public Group createGroup(String groupId) {
-		CassandraGroup group = new CassandraGroup(groupId, keyspace, cluster);
-		return group;
+		Group group = new CassandraGroup(groupId, keyspace, cluster);
+        return group;
 	}
 
     public Group getGroup(String groupId) {
-		return createGroup(groupId);
+		Group group = createGroup(groupId);
+        return group;
     }
 
 
-    public void deleteGroup(String key) {
-		cluster.dropColumnFamily(keyspace.getKeyspaceName(), key);
+    public void deleteGroup(String groupId) throws GroupNotFoundException {
+        try{
+		    cluster.dropColumnFamily(keyspace.getKeyspaceName(), groupId);
+        } catch(HInvalidRequestException e){
+            throw new GroupNotFoundException("Group does not exists "+groupId);
+        }
 	}
 
 }

Modified: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java Sat Jul  9 09:02:32 2011
@@ -29,6 +29,8 @@ import me.prettyprint.hector.api.ddl.Col
 import me.prettyprint.hector.api.exceptions.HInvalidRequestException;
 import me.prettyprint.hector.api.factory.HFactory;
 import org.apache.tuscany.nosqldatastore.Group;
+import org.apache.tuscany.nosqldatastore.exception.DuplicateEntryException;
+import org.apache.tuscany.nosqldatastore.exception.EntryNotFoundException;
 
 class CassandraGroup implements Group {
 
@@ -36,35 +38,57 @@ class CassandraGroup implements Group {
     private ColumnFamilyUpdater<String, String> updater;
     private final StringSerializer se = StringSerializer.get();
 
-	CassandraGroup(String groupId, Keyspace keyspace, Cluster cluster) {
+    CassandraGroup(String groupId, Keyspace keyspace, Cluster cluster) {
         try{
-        ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(keyspace.getKeyspaceName(), groupId);
-		cluster.addColumnFamily(cfDef);
+            ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(keyspace.getKeyspaceName(), groupId);
+            cluster.addColumnFamily(cfDef);
         }catch (HInvalidRequestException e){
             System.out.println("Connect to the existing group...");
         }
         template = new ThriftColumnFamilyTemplate<String, String>(keyspace,groupId,se,se,HFactory.createMutator(keyspace, se));
-	}
+    }
 
-	public void addEntry(String key, Object value) {
-        updater = template.createUpdater(key);
-		updater.setString(key, (String) value);
-		template.update(updater);
-		template.addColumn(key, se);		
-	}
-
-	public void deleteEntry(String key) {
-		template.deleteColumn(key, key);
-		
-	}
+    public void addEntry(String key, String value) throws DuplicateEntryException {
+        ColumnFamilyResult wrapper = template.queryColumns(key);
+        if(wrapper.getString(key) == null){
+            updater = template.createUpdater(key);
+            updater.setString(key, value);
+            template.update(updater);
+            template.addColumn(key, se);
+            return;
+        }
+        throw new DuplicateEntryException("Entry already exist for key "+key);
+    }
 
-    public Object getValue(String key) {
+    public void deleteEntry(String key) throws EntryNotFoundException {
         ColumnFamilyResult wrapper = template.queryColumns(key);
-        return wrapper.getString(key);
+        if(wrapper.getString(key) != null){
+            template.deleteColumn(key, key);
+            return;
+        }
+        throw new EntryNotFoundException("Entry does not exist for key "+key);
     }
 
-    public void updateEntry(String key, Object value) {
-		addEntry(key, value);
-	}
+    public String getEntry(String key) throws EntryNotFoundException {
+        ColumnFamilyResult wrapper = template.queryColumns(key);
+        String entry =  wrapper.getString(key);
+        if(entry != null){
+            return entry;
+        }
+        throw new EntryNotFoundException("Entry does not exist for key "+key);
+
+    }
+
+    public void updateEntry(String key, String value) throws EntryNotFoundException {
+        ColumnFamilyResult wrapper = template.queryColumns(key);
+        if(wrapper.getString(key) != null){
+            updater = template.createUpdater(key);
+            updater.setString(key, value);
+            template.update(updater);
+            template.addColumn(key, se);
+            return;
+        }
+        throw new EntryNotFoundException("Entry does not exist for key "+key);
+    }
 
 }

Modified: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java Sat Jul  9 09:02:32 2011
@@ -20,31 +20,46 @@ package org.apache.tuscany.nosqldatastor
 
 import me.prettyprint.cassandra.service.CassandraHostConfigurator;
 import me.prettyprint.hector.api.Cluster;
+import me.prettyprint.hector.api.exceptions.HInvalidRequestException;
+import me.prettyprint.hector.api.exceptions.HectorException;
 import me.prettyprint.hector.api.factory.HFactory;
 import org.apache.tuscany.nosqldatastore.Database;
 import org.apache.tuscany.nosqldatastore.Session;
+import org.apache.tuscany.nosqldatastore.exception.DatabaseNotFoundException;
+import org.apache.tuscany.nosqldatastore.exception.GroupNotFoundException;
+import org.apache.tuscany.nosqldatastore.exception.SessionException;
 
 public class CassandraSession implements Session {
-	
-	private CassandraHostConfigurator cassandraHostConfigurator;
-	private Cluster cluster;
-	
-	public CassandraSession(String clusterName) {
-		cluster = HFactory.getOrCreateCluster("Test Cluster", "127.0.0.1:9160");
-	}
-
-	public Database createDatabase(String keyspaceName) {
-		Database database = new CassandraDatabase(keyspaceName, cluster);
-		return database;
-	}
-
-	public Database getDatabase(String keyspaceName) {
-		Database database = new CassandraDatabase(keyspaceName, cluster);
-		return database;
-	}
-
-	public void deleteDatabase(String keyspaceName) {
-		cluster.dropKeyspace(keyspaceName);
-	}
+
+    private CassandraHostConfigurator cassandraHostConfigurator;
+    private Cluster cluster;
+
+    public CassandraSession(String clusterName) {
+        cluster = HFactory.getOrCreateCluster("Test Cluster", "127.0.0.1:9160");
+    }
+
+    public Database createDatabase(String databaseName) throws SessionException {
+        Database database = null;
+        try{
+            database = new CassandraDatabase(databaseName, cluster);
+        } catch (HectorException e){
+            throw new SessionException("Session error");
+        }
+        return database;
+    }
+
+    public Database getDatabase(String databaseName) throws SessionException {
+        return createDatabase(databaseName);
+    }
+
+    public void deleteDatabase(String databaseName) throws DatabaseNotFoundException, SessionException {
+        try{
+            cluster.dropKeyspace(databaseName);
+        } catch(HInvalidRequestException e){
+            throw new DatabaseNotFoundException("Database "+databaseName+" not found");
+        } catch (HectorException e){
+            throw new SessionException("Session error");
+        }
+    }
 
 }

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class DatabaseNotFoundException extends Exception{
+
+    public DatabaseNotFoundException(String msg){
+        super(msg);
+    }
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class DuplicateEntryException extends Exception{
+    public DuplicateEntryException(String msg) {
+        super(msg);
+    }
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class EntryNotFoundException extends Exception{
+    public EntryNotFoundException(String msg) {
+        super(msg);
+    }
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class GroupNotFoundException extends Exception{
+    public GroupNotFoundException(String msg){
+        super(msg);
+    }
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/SessionException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/SessionException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/SessionException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/exception/SessionException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class SessionException extends Exception{
+    public SessionException(String msg){
+        super(msg);
+    }
+}

Copied: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTestCase.java (from r1137637, tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java)
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTestCase.java?p2=tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTestCase.java&p1=tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java&r1=1137637&r2=1144620&rev=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTestCase.java Sat Jul  9 09:02:32 2011
@@ -22,47 +22,75 @@ import org.apache.tuscany.nosqldatastore
 import org.apache.tuscany.nosqldatastore.Group;
 import org.apache.tuscany.nosqldatastore.Session;
 import org.apache.tuscany.nosqldatastore.SessionFactory;
+import org.apache.tuscany.nosqldatastore.exception.*;
+import org.junit.Before;
+import org.junit.Test;
 
+import org.junit.Assert;
 
-public class CassandraTest {
-	
-	Session session;
-	
-	public CassandraTest(){
-		session = SessionFactory.getCassandraSession();
-	}
-	
-	public static void main(String[] args){
-		CassandraTest test = new CassandraTest();
-		test.create();
-		test.delete();
-	}
-
-	public void create(){
-		Database db = session.createDatabase("TwitApp");
-		Group group1 = db.createGroup("twits");
-
-        group1.addEntry("twitName1", "Here I am");
-        group1.addEntry("twitName2", "I am not here");
-        group1.addEntry("twitName3", "Sometimes");
-
-		Group group2 = db.createGroup("users");
-
-        group2.addEntry("userName1", "eranda");
-        group2.addEntry("userName2", "ishara");
-        group2.addEntry("userName3", "ravi");
-
-        group2.deleteEntry("userName3");
-        group2.updateEntry("userName2", "eranda");
-
-        System.out.println(group2.getValue("userName1"));
-	}
-	
-	public void delete(){
-		Database db = session.getDatabase("TwitApp");
-		db.deleteGroup("twits");
-		db.deleteGroup("users");
-		session.deleteDatabase("TwitApp");
-	}
-	
+
+public class CassandraTestCase {
+
+    private Session session;
+
+    @Before
+    public void init(){
+        SessionFactory factory = new SessionFactory();
+        session = factory.getCassandraSession();
+    }
+
+    @Test
+    public void testAddEntry() throws Exception {
+        Database db = session.createDatabase("TwitApp");
+        Group group = db.createGroup("twits");
+
+        group.addEntry("twitName1", "Here I am");
+        group.addEntry("twitName2", "I am not here");
+        group.addEntry("twitName3", "Sometimes");
+
+        Assert.assertEquals(group.getEntry("twitName1"), "Here I am");
+        Assert.assertEquals(group.getEntry("twitName2"), "I am not here");
+        Assert.assertEquals(group.getEntry("twitName3"), "Sometimes");
+
+        db.deleteGroup("twits");
+        session.deleteDatabase("TwitApp");
+    }
+
+    @Test
+    public void testDeleteEntry() throws Exception {
+        Database db = session.createDatabase("TwitApp");
+        Group group = db.createGroup("twits");
+
+        group.addEntry("twitName1", "Here I am");
+        group.addEntry("twitName2", "I am not here");
+        group.addEntry("twitName3", "Sometimes");
+
+        group.deleteEntry("twitName1");
+
+        try {
+            Assert.assertNull(group.getEntry("twitName1"));
+            Assert.fail("Deleted entry exists");
+        } catch(EntryNotFoundException e) {
+            //Expected
+        }
+
+        db.deleteGroup("twits");
+        session.deleteDatabase("TwitApp");
+    }
+
+    @Test
+    public void testUpdateEntry() throws Exception {
+        Database db = session.createDatabase("TwitApp");
+        Group group = db.createGroup("twits");
+
+        group.addEntry("twitName1", "Here I am");
+        group.addEntry("twitName2", "I am not here");
+        group.addEntry("twitName3", "Sometimes");
+
+        group.updateEntry("twitName3", "Never");
+        Assert.assertEquals(group.getEntry("twitName3"), "Never");
+
+        db.deleteGroup("twits");
+        session.deleteDatabase("TwitApp");
+    }
 }

Modified: tuscany/collaboration/GSoC-2011-Eranda/couchdb/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/pom.xml?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/pom.xml (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/pom.xml Sat Jul  9 09:02:32 2011
@@ -34,10 +34,15 @@ under the License.
 
     <dependencies>
         <dependency>
-    		<groupId>com.google.code.jcouchdb</groupId>
-    		<artifactId>jcouchdb</artifactId>
-    		<version>0.10.0-1</version>
-	</dependency>
+            <groupId>com.google.code.jcouchdb</groupId>
+            <artifactId>jcouchdb</artifactId>
+            <version>0.10.0-1</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.8.2</version>
+        </dependency>
     </dependencies>
 
     <build>

Modified: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Database.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Database.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Database.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Database.java Sat Jul  9 09:02:32 2011
@@ -1,26 +1,34 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.nosqldatastore;
-
-public interface Database {
-	Group createGroup(String groupId);
-	Group getGroup(String groupId);
-	void deleteGroup(String groupId);
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.exception.GroupNotFoundException;
+
+/*
+Database:
+Use to manipulate the groups, where  groups are use to categorize the data
+1. Creating a group
+2. Retrieving a group
+3. Deleting a group
+*/
+public interface Database {
+    Group createGroup(String groupId);
+    Group getGroup(String groupId);
+    void deleteGroup(String groupId) throws GroupNotFoundException;
+}

Modified: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Group.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Group.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Group.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Group.java Sat Jul  9 09:02:32 2011
@@ -1,27 +1,37 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.nosqldatastore;
-
-public interface Group {
-	void addEntry(String key, Object value);
-	void updateEntry(String key, Object value);
-	void deleteEntry(String key);
-    Object getValue(String key);
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.exception.DuplicateEntryException;
+import org.apache.tuscany.nosqldatastore.exception.EntryNotFoundException;
+
+/*
+Group:
+Group use to categorize the data into different categories
+1. Add entry to the database
+2. Update an existing entry
+3. Delete  an existing entry
+4. Get a existing entry
+ */
+public interface Group {
+    void addEntry(String key, String value) throws DuplicateEntryException;
+    void updateEntry(String key, String value) throws EntryNotFoundException;
+    void deleteEntry(String key) throws EntryNotFoundException;
+    String getEntry(String key) throws EntryNotFoundException;
+}

Modified: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Session.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Session.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Session.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/Session.java Sat Jul  9 09:02:32 2011
@@ -1,26 +1,36 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.nosqldatastore;
-
-public interface Session {
-	Database createDatabase(String databaseName);
-	Database getDatabase(String databaseName);
-	void deleteDatabase(String databaseName);
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.exception.DatabaseNotFoundException;
+import org.apache.tuscany.nosqldatastore.exception.GroupNotFoundException;
+import org.apache.tuscany.nosqldatastore.exception.SessionException;
+
+/*
+Session:
+Session is a database session use to access the database
+1. Create a database
+2. Get instance of existing database
+3. Delete a database
+*/
+public interface Session {
+    Database createDatabase(String databaseName) throws SessionException;
+    Database getDatabase(String databaseName) throws SessionException;
+    void deleteDatabase(String databaseName) throws DatabaseNotFoundException, SessionException;
+}

Modified: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java Sat Jul  9 09:02:32 2011
@@ -22,15 +22,15 @@ package org.apache.tuscany.nosqldatastor
 import org.apache.tuscany.nosqldatastore.couchdb.CouchDBSession;
 
 public class SessionFactory {
-	
-	private static org.apache.tuscany.nosqldatastore.Session session;
-	
-	private SessionFactory(){
-	}
-	
-	public static Session getCouchDBSession(){
-		session = new CouchDBSession();
-		return session;
-	}
-	
+
+    private org.apache.tuscany.nosqldatastore.Session session;
+
+    public SessionFactory(){
+    }
+
+    public Session getCouchDBSession(){
+        session = new CouchDBSession("couchdb");
+        return session;
+    }
+
 }

Modified: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBDatatabase.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBDatatabase.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBDatatabase.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBDatatabase.java Sat Jul  9 09:02:32 2011
@@ -21,23 +21,25 @@ package org.apache.tuscany.nosqldatastor
 
 import org.apache.tuscany.nosqldatastore.Database;
 import org.apache.tuscany.nosqldatastore.Group;
+import org.apache.tuscany.nosqldatastore.exception.GroupNotFoundException;
 import org.jcouchdb.db.Server;
 import org.jcouchdb.document.DesignDocument;
+import org.jcouchdb.exception.CouchDBException;
 
 public class CouchDBDatatabase implements Database{
 
     private org.jcouchdb.db.Database db;
     private String dbname;
 
-    CouchDBDatatabase(String dbname){
+    CouchDBDatatabase(String dbname) throws CouchDBException{
         this.dbname = dbname;
         db = new org.jcouchdb.db.Database("localhost",dbname);
         Server server = db.getServer();
         if(!server.listDatabases().contains(dbname)){
             server.createDatabase(dbname);
-            System.out.println("New database created...");
+            return;
         }
-
+        System.out.println("Connect to the existing database...");
     }
 
     public Group createGroup(String groupId) {
@@ -50,8 +52,12 @@ public class CouchDBDatatabase implement
         return group;
     }
 
-    public void deleteGroup(String groupId) {
+    public void deleteGroup(String groupId) throws GroupNotFoundException{
         DesignDocument doc = db.getDesignDocument(groupId);
-        db.delete(doc);
+        if(doc != null){
+            db.delete(doc);
+            return;
+        }
+        throw new GroupNotFoundException("Group does not exists "+groupId);
     }
 }

Modified: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBGroup.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBGroup.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBGroup.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBGroup.java Sat Jul  9 09:02:32 2011
@@ -20,6 +20,8 @@
 package org.apache.tuscany.nosqldatastore.couchdb;
 
 import org.apache.tuscany.nosqldatastore.Group;
+import org.apache.tuscany.nosqldatastore.exception.DuplicateEntryException;
+import org.apache.tuscany.nosqldatastore.exception.EntryNotFoundException;
 import org.jcouchdb.document.DesignDocument;
 import org.jcouchdb.document.DocumentHelper;
 import org.jcouchdb.exception.UpdateConflictException;
@@ -42,33 +44,52 @@ public class CouchDBGroup implements Gro
         try{
             database.createOrUpdateDocument(doc);
         }catch(UpdateConflictException e){
-            System.out.println("Connect to the doc "+groupId);   
+            System.out.println("Connect to the doc "+groupId);
         }
     }
 
-    public void addEntry(String key, Object value) {
+    public void addEntry(String key, String value) throws DuplicateEntryException {
         DesignDocument doc = database.getDesignDocument(groupId);
         Map<String, String> lists  = doc.getListFunctions();
-        lists.put(key, (String)value);
-        doc.setListFunctions(lists);
-        database.updateDocument(doc);
+        if(!lists.containsKey(key)){
+            lists.put(key, value);
+            doc.setListFunctions(lists);
+            database.updateDocument(doc);
+            return;
+        }
+        throw new DuplicateEntryException("Entry already exist for key "+key);
     }
 
-    public void updateEntry(String key, Object value) {
-        addEntry(key, value);
+    public void updateEntry(String key, String value) throws EntryNotFoundException{
+        DesignDocument doc = database.getDesignDocument(groupId);
+        Map<String, String> lists  = doc.getListFunctions();
+        if(lists.containsKey(key)){
+            lists.put(key, value);
+            doc.setListFunctions(lists);
+            database.updateDocument(doc);
+            return;
+        }
+        throw new EntryNotFoundException("Entry does not exist for key "+key);
     }
 
-    public void deleteEntry(String key) {
+    public void deleteEntry(String key) throws EntryNotFoundException {
         DesignDocument doc = database.getDesignDocument(groupId);
         Map<String, String> lists  = doc.getListFunctions();
-        lists.remove(key);
-        doc.setListFunctions(lists);
-        database.updateDocument(doc);
+        if(lists.containsKey(key)){
+            lists.remove(key);
+            doc.setListFunctions(lists);
+            database.updateDocument(doc);
+            return;
+        }
+        throw new EntryNotFoundException("Entry does not exist for key "+key);
     }
 
-    public Object getValue(String key) {
+    public String getEntry(String key) throws EntryNotFoundException {
         DesignDocument doc = database.getDesignDocument(groupId);
         Map<String, String> lists  = doc.getListFunctions();
-        return lists.get(key);
+        if(lists.containsKey(key)){
+            return lists.get(key);
+        }
+        throw new EntryNotFoundException("Entry does not exist for key "+key);
     }
 }

Modified: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBSession.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBSession.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBSession.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBSession.java Sat Jul  9 09:02:32 2011
@@ -21,25 +21,44 @@ package org.apache.tuscany.nosqldatastor
 
 import org.apache.tuscany.nosqldatastore.Database;
 import org.apache.tuscany.nosqldatastore.Session;
+import org.apache.tuscany.nosqldatastore.exception.DatabaseNotFoundException;
+import org.apache.tuscany.nosqldatastore.exception.SessionException;
 import org.jcouchdb.db.Server;
+import org.jcouchdb.exception.CouchDBException;
 
 public class CouchDBSession implements Session{
 
-    public CouchDBSession(){
+    private String sessionName;
+
+    public CouchDBSession(String name){
+        sessionName = name;
     }
 
-    public Database createDatabase(String databaseName) {
-        Database database = new CouchDBDatatabase(databaseName);
+    public Database createDatabase(String databaseName) throws SessionException {
+        Database database = null;
+        try{
+            database = new CouchDBDatatabase(databaseName);
+        } catch(CouchDBException e){
+            throw new SessionException("Session error");
+        }
         return database;
     }
 
-    public Database getDatabase(String databaseName) {
-        Database database = new CouchDBDatatabase(databaseName);
+    public Database getDatabase(String databaseName) throws SessionException {
+        Database database = createDatabase(databaseName);
         return database;
     }
 
-    public void deleteDatabase(String databaseName) {
+    public void deleteDatabase(String databaseName) throws SessionException, DatabaseNotFoundException {
         org.jcouchdb.db.Database db = new org.jcouchdb.db.Database("localhost",databaseName);
-        db.getServer().deleteDatabase(databaseName);                                                     
+        if(db.getServer().listDatabases().contains(databaseName)){
+            try{
+                db.getServer().deleteDatabase(databaseName);
+            } catch(CouchDBException e){
+                throw new SessionException("Session error");
+            }
+        } else {
+            throw new DatabaseNotFoundException("Database "+databaseName+" not found");
+        }
     }
 }

Added: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class DatabaseNotFoundException extends Exception{
+
+    public DatabaseNotFoundException(String msg){
+        super(msg);
+    }
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class DuplicateEntryException extends Exception{
+    public DuplicateEntryException(String msg) {
+        super(msg);
+    }
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class EntryNotFoundException extends Exception{
+    public EntryNotFoundException(String msg) {
+        super(msg);
+    }
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class GroupNotFoundException extends Exception{
+    public GroupNotFoundException(String msg){
+        super(msg);
+    }
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/SessionException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/SessionException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/SessionException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/main/java/org/apache/tuscany/nosqldatastore/exception/SessionException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class SessionException extends Exception{
+    public SessionException(String msg){
+        super(msg);
+    }
+}

Copied: tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/test/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBTestCase.java (from r1137637, tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/test/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBTest.java)
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/test/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBTestCase.java?p2=tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/test/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBTestCase.java&p1=tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/test/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBTest.java&r1=1137637&r2=1144620&rev=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/test/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBTest.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/couchdb/src/test/java/org/apache/tuscany/nosqldatastore/couchdb/CouchDBTestCase.java Sat Jul  9 09:02:32 2011
@@ -23,32 +23,74 @@ import org.apache.tuscany.nosqldatastore
 import org.apache.tuscany.nosqldatastore.Session;
 import org.apache.tuscany.nosqldatastore.SessionFactory;
 
-public class CouchDBTest {
+import org.apache.tuscany.nosqldatastore.exception.EntryNotFoundException;
+import org.junit.Before;
+import org.junit.Test;
 
-    Session session;
+import org.junit.Assert;
 
-    private CouchDBTest(){
-        session = SessionFactory.getCouchDBSession();
+public class CouchDBTestCase {
+
+    private Session session;
+
+    @Before
+    public void init(){
+        SessionFactory factory = new SessionFactory();
+        session = factory.getCouchDBSession();
+    }
+
+    @Test
+    public void testAddEntry() throws Exception {
+        Database db = session.createDatabase("twitapp");
+        Group group = db.createGroup("twits");
+
+        group.addEntry("twitName1", "Here I am");
+        group.addEntry("twitName2", "I am not here");
+        group.addEntry("twitName3", "Sometimes");
+
+        Assert.assertEquals(group.getEntry("twitName1"), "Here I am");
+        Assert.assertEquals(group.getEntry("twitName2"), "I am not here");
+        Assert.assertEquals(group.getEntry("twitName3"), "Sometimes");
+
+        db.deleteGroup("twits");
+        session.deleteDatabase("twitapp");
     }
 
-    public static void main(String[] args){
-        CouchDBTest test = new CouchDBTest();
-        test.start();
+    @Test
+    public void testDeleteEntry() throws Exception {
+        Database db = session.createDatabase("twitapp");
+        Group group = db.createGroup("twits");
+
+        group.addEntry("twitName1", "Here I am");
+        group.addEntry("twitName2", "I am not here");
+        group.addEntry("twitName3", "Sometimes");
+
+        group.deleteEntry("twitName1");
+
+        try {
+            Assert.assertNull(group.getEntry("twitName1"));
+            Assert.fail("Deleted entry exists");
+        } catch(EntryNotFoundException e) {
+            //Expected
+        }
+
+        db.deleteGroup("twits");
+        session.deleteDatabase("twitapp");
     }
 
-    public void start(){
-        
-        Database db = session.createDatabase("db1");
-        Group group = db.createGroup("group4");
-        group.addEntry("eranda", "Eranda Sooriyabandara");
-        group.addEntry("ishara", "Ishara Karunarathne");
-        group.addEntry("mahesh", "Eranda Sooriyabandara");
-        group.deleteEntry("eranda");
-        group.deleteEntry("ishara");
-        System.out.println(group.getValue("mahesh"));
-        db.deleteGroup("group4");
-        session.deleteDatabase("db1");
+    @Test
+    public void testUpdateEntry() throws Exception {
+        Database db = session.createDatabase("twitapp");
+        Group group = db.createGroup("twits");
+
+        group.addEntry("twitName1", "Here I am");
+        group.addEntry("twitName2", "I am not here");
+        group.addEntry("twitName3", "Sometimes");
 
+        group.updateEntry("twitName3", "Never");
+        Assert.assertEquals(group.getEntry("twitName3"), "Never");
 
+        db.deleteGroup("twits");
+        session.deleteDatabase("twitapp");
     }
 }

Modified: tuscany/collaboration/GSoC-2011-Eranda/hbase/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/hbase/pom.xml?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/hbase/pom.xml (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/hbase/pom.xml Sat Jul  9 09:02:32 2011
@@ -38,6 +38,11 @@ under the License.
             <artifactId>hbase</artifactId>
             <version>0.90.3</version>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.8.2</version>
+        </dependency>
     </dependencies>
 
     <build>

Modified: tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Database.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Database.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Database.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Database.java Sat Jul  9 09:02:32 2011
@@ -1,26 +1,34 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.nosqldatastore;
-
-public interface Database {
-	Group createGroup(String groupId);
-	Group getGroup(String groupId);
-	void deleteGroup(String groupId);
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.exception.GroupNotFoundException;
+
+/*
+Database:
+Use to manipulate the groups, where  groups are use to categorize the data
+1. Creating a group
+2. Retrieving a group
+3. Deleting a group
+*/
+public interface Database {
+    Group createGroup(String groupId);
+    Group getGroup(String groupId);
+    void deleteGroup(String groupId) throws GroupNotFoundException;
+}

Modified: tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Group.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Group.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Group.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Group.java Sat Jul  9 09:02:32 2011
@@ -1,27 +1,37 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.nosqldatastore;
-
-public interface Group {
-	void addEntry(String key, Object value);
-	void updateEntry(String key, Object value);
-	void deleteEntry(String key);
-    Object getValue(String key);
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.exception.DuplicateEntryException;
+import org.apache.tuscany.nosqldatastore.exception.EntryNotFoundException;
+
+/*
+Group:
+Group use to categorize the data into different categories
+1. Add entry to the database
+2. Update an existing entry
+3. Delete  an existing entry
+4. Get a existing entry
+ */
+public interface Group {
+    void addEntry(String key, String value) throws DuplicateEntryException;
+    void updateEntry(String key, String value) throws EntryNotFoundException;
+    void deleteEntry(String key) throws EntryNotFoundException;
+    String getEntry(String key) throws EntryNotFoundException;
+}

Modified: tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Session.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Session.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Session.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/Session.java Sat Jul  9 09:02:32 2011
@@ -1,26 +1,36 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.nosqldatastore;
-
-public interface Session {
-	Database createDatabase(String databaseName);
-	Database getDatabase(String databaseName);
-	void deleteDatabase(String databaseName);
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.exception.DatabaseNotFoundException;
+import org.apache.tuscany.nosqldatastore.exception.GroupNotFoundException;
+import org.apache.tuscany.nosqldatastore.exception.SessionException;
+
+/*
+Session:
+Session is a database session use to access the database
+1. Create a database
+2. Get instance of existing database
+3. Delete a database
+*/
+public interface Session {
+    Database createDatabase(String databaseName) throws SessionException;
+    Database getDatabase(String databaseName) throws SessionException;
+    void deleteDatabase(String databaseName) throws DatabaseNotFoundException, SessionException;
+}

Modified: tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java?rev=1144620&r1=1144619&r2=1144620&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java (original)
+++ tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java Sat Jul  9 09:02:32 2011
@@ -22,15 +22,15 @@ package org.apache.tuscany.nosqldatastor
 import org.apache.tuscany.nosqldatastore.hbase.HBaseSession;
 
 public class SessionFactory {
-	
-	private static org.apache.tuscany.nosqldatastore.Session session;
-	
-	private SessionFactory(){
-	}
-	
-	public static Session getHBaseSession(){
-		session = new HBaseSession("hbase");
-		return session;
-	}
-	
+
+    private static org.apache.tuscany.nosqldatastore.Session session;
+
+    public SessionFactory(){
+    }
+
+    public Session getHBaseSession(){
+        session = new HBaseSession("hbase");
+        return session;
+    }
+
 }

Added: tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/DatabaseNotFoundException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class DatabaseNotFoundException extends Exception{
+
+    public DatabaseNotFoundException(String msg){
+        super(msg);
+    }
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/DuplicateEntryException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class DuplicateEntryException extends Exception{
+    public DuplicateEntryException(String msg) {
+        super(msg);
+    }
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/EntryNotFoundException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class EntryNotFoundException extends Exception{
+    public EntryNotFoundException(String msg) {
+        super(msg);
+    }
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java?rev=1144620&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/hbase/src/main/java/org/apache/tuscany/nosqldatastore/exception/GroupNotFoundException.java Sat Jul  9 09:02:32 2011
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.nosqldatastore.exception;
+
+public class GroupNotFoundException extends Exception{
+    public GroupNotFoundException(String msg){
+        super(msg);
+    }
+}