You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2014/05/30 21:53:56 UTC

[01/11] adding proper entity manager closing and exception handling - AIRAVATA-1285

Repository: airavata
Updated Branches:
  refs/heads/master 0fadb0806 -> bf5f8c3c5


http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ApplicationJobAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ApplicationJobAlreadyExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ApplicationJobAlreadyExistsException.java
index 7c87443..7662200 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ApplicationJobAlreadyExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ApplicationJobAlreadyExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class ApplicationJobAlreadyExistsException extends RegistryException {
+public class ApplicationJobAlreadyExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ApplicationJobDoesNotExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ApplicationJobDoesNotExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ApplicationJobDoesNotExistsException.java
index 455afd0..349d119 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ApplicationJobDoesNotExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ApplicationJobDoesNotExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class ApplicationJobDoesNotExistsException extends RegistryException {
+public class ApplicationJobDoesNotExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ExperimentAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ExperimentAlreadyExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ExperimentAlreadyExistsException.java
index 6d8e8b1..0be0e74 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ExperimentAlreadyExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ExperimentAlreadyExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class ExperimentAlreadyExistsException extends RegistryException {
+public class ExperimentAlreadyExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ExperimentDoesNotExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ExperimentDoesNotExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ExperimentDoesNotExistsException.java
index 77d2316..09d2d05 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ExperimentDoesNotExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/ExperimentDoesNotExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class ExperimentDoesNotExistsException extends RegistryException {
+public class ExperimentDoesNotExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/InvalidApplicationJobIDException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/InvalidApplicationJobIDException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/InvalidApplicationJobIDException.java
index 3278c75..d3b7749 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/InvalidApplicationJobIDException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/InvalidApplicationJobIDException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class InvalidApplicationJobIDException extends RegistryException {
+public class InvalidApplicationJobIDException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/UserWorkflowAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/UserWorkflowAlreadyExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/UserWorkflowAlreadyExistsException.java
index a8f13df..8c62521 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/UserWorkflowAlreadyExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/UserWorkflowAlreadyExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class UserWorkflowAlreadyExistsException extends RegistryException {
+public class UserWorkflowAlreadyExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/UserWorkflowDoesNotExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/UserWorkflowDoesNotExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/UserWorkflowDoesNotExistsException.java
index f1f47a6..9b9d6b4 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/UserWorkflowDoesNotExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/UserWorkflowDoesNotExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class UserWorkflowDoesNotExistsException extends RegistryException {
+public class UserWorkflowDoesNotExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceAlreadyExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceAlreadyExistsException.java
index 4e7d911..585f6ba 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceAlreadyExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceAlreadyExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class WorkflowInstanceAlreadyExistsException extends RegistryException {
+public class WorkflowInstanceAlreadyExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceDoesNotExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceDoesNotExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceDoesNotExistsException.java
index d0814e8..9a2f18e 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceDoesNotExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceDoesNotExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class WorkflowInstanceDoesNotExistsException extends RegistryException {
+public class WorkflowInstanceDoesNotExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeAlreadyExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeAlreadyExistsException.java
index 077117e..4cf0c5d 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeAlreadyExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeAlreadyExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class WorkflowInstanceNodeAlreadyExistsException extends RegistryException {
+public class WorkflowInstanceNodeAlreadyExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeDoesNotExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeDoesNotExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeDoesNotExistsException.java
index 8362e99..4dc9eea 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeDoesNotExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkflowInstanceNodeDoesNotExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class WorkflowInstanceNodeDoesNotExistsException extends RegistryException {
+public class WorkflowInstanceNodeDoesNotExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkspaceProjectAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkspaceProjectAlreadyExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkspaceProjectAlreadyExistsException.java
index 37a5efb..869fe92 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkspaceProjectAlreadyExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkspaceProjectAlreadyExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class WorkspaceProjectAlreadyExistsException extends RegistryException {
+public class WorkspaceProjectAlreadyExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkspaceProjectDoesNotExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkspaceProjectDoesNotExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkspaceProjectDoesNotExistsException.java
index 4257d09..c36f719 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkspaceProjectDoesNotExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/worker/WorkspaceProjectDoesNotExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.worker;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class WorkspaceProjectDoesNotExistsException extends RegistryException {
+public class WorkspaceProjectDoesNotExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/util/RegistryUtils.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/util/RegistryUtils.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/util/RegistryUtils.java
index 8911df6..6968d04 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/util/RegistryUtils.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/util/RegistryUtils.java
@@ -32,11 +32,8 @@ import org.apache.airavata.registry.api.AiravataRegistry2;
 import org.apache.airavata.registry.api.AiravataRegistryFactory;
 import org.apache.airavata.registry.api.AiravataUser;
 import org.apache.airavata.registry.api.Gateway;
-import org.apache.airavata.registry.api.exception.RegistryAccessorInstantiateException;
-import org.apache.airavata.registry.api.exception.RegistryAccessorInvalidException;
-import org.apache.airavata.registry.api.exception.RegistryAccessorNotFoundException;
-import org.apache.airavata.registry.api.exception.RegistryAccessorUndefinedException;
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.*;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,7 +41,7 @@ public class RegistryUtils {
     private static final Logger log = LoggerFactory.getLogger(RegistryUtils.class);
 
 
-    public static String validateAxisService(String urlString)throws RegistryException {
+    public static String validateAxisService(String urlString)throws RegException {
         if(!urlString.endsWith("?wsdl")){
             urlString = urlString + "?wsdl";
         }
@@ -54,24 +51,24 @@ public class RegistryUtils {
             conn.connect();
         } catch (MalformedURLException e) {
             // the URL is not in a valid form
-            throw new RegistryException("Given Axis2 Service URL : " + urlString + " is Invalid",e);
+            throw new RegException("Given Axis2 Service URL : " + urlString + " is Invalid",e);
         } catch (IOException e) {
             // the connection couldn't be established
-            throw new RegistryException("Given Axis2 Service URL : " + urlString + " is Invalid",e);
+            throw new RegException("Given Axis2 Service URL : " + urlString + " is Invalid",e);
         }
         return  urlString;
     }
-    public static String validateURL(String urlString)throws RegistryException{
+    public static String validateURL(String urlString)throws RegException {
         try {
             URL url = new URL(urlString);
             URLConnection conn = url.openConnection();
             conn.connect();
         } catch (MalformedURLException e) {
             // the URL is not in a valid form
-            throw new RegistryException("Given URL: " + urlString + " is Invalid",e);
+            throw new RegException("Given URL: " + urlString + " is Invalid",e);
         } catch (IOException e) {
             // the connection couldn't be established
-            throw new RegistryException("Given URL: " + urlString + " is Invalid",e);
+            throw new RegException("Given URL: " + urlString + " is Invalid",e);
         }
         return  urlString;
     }
@@ -109,17 +106,17 @@ public class RegistryUtils {
                     new AiravataUser(username));
         } catch (AiravataConfigurationException e) {
             log.error("Error initializing AiravataRegistry2");
-        } catch (RegistryAccessorNotFoundException e) {
+        } catch (RegAccessorNotFoundException e) {
             log.error("Error initializing AiravataRegistry2");
-        } catch (RegistryAccessorInstantiateException e) {
+        } catch (RegAccessorInstantiateException e) {
             log.error("Error initializing AiravataRegistry2");
-        } catch (RegistryAccessorInvalidException e) {
+        } catch (RegAccessorInvalidException e) {
             log.error("Error initializing AiravataRegistry2");
-        } catch (RegistryAccessorUndefinedException e) {
+        } catch (RegAccessorUndefinedException e) {
             log.error("Error initializing AiravataRegistry2");
         } catch (ApplicationSettingsException e) {
         	log.error("Error initializing AiravataRegistry2",e);
-		} catch (RegistryException e) {
+		} catch (RegException e) {
             log.error("Error initializing AiravataRegistry2",e);
         }
         return registry;


[05/11] adding proper entity manager closing and exception handling - AIRAVATA-1285

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
index 95745ec..e7354ea 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
@@ -31,6 +31,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.NodeOutput;
 import org.apache.airavata.persistance.registry.jpa.model.NodeOutput_PK;
 import org.apache.airavata.persistance.registry.jpa.model.WorkflowNodeDetail;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -83,60 +84,69 @@ public class NodeOutputResource extends AbstractResource {
         this.value = value;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void save() {
-
-        EntityManager em = ResourceUtils.getEntityManager();
-        NodeOutput existingOutput = em.find(NodeOutput.class, new NodeOutput_PK(outputKey, nodeDetailResource.getNodeInstanceId()));
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        NodeOutput nodeOutput = new NodeOutput();
-        WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, nodeDetailResource.getNodeInstanceId());
-        nodeOutput.setNode(nodeDetail);
-        nodeOutput.setNodeId(nodeDetail.getNodeId());
-        nodeOutput.setOutputKey(outputKey);
-        nodeOutput.setOutputKeyType(outputType);
-        nodeOutput.setValue(value);
-        nodeOutput.setMetadata(metadata);
-        
-        if (existingOutput != null){
-            existingOutput.setNode(nodeDetail);
-            existingOutput.setNodeId(nodeDetail.getNodeId());
-            existingOutput.setOutputKey(outputKey);
-            existingOutput.setOutputKeyType(outputType);
-            existingOutput.setValue(value);
-            existingOutput.setMetadata(metadata);
-            nodeOutput = em.merge(existingOutput);
-        }else {
-            em.persist(nodeOutput);
+    
+    public void save() throws RegistryException{
+
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            NodeOutput existingOutput = em.find(NodeOutput.class, new NodeOutput_PK(outputKey, nodeDetailResource.getNodeInstanceId()));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            NodeOutput nodeOutput = new NodeOutput();
+            WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, nodeDetailResource.getNodeInstanceId());
+            nodeOutput.setNode(nodeDetail);
+            nodeOutput.setNodeId(nodeDetail.getNodeId());
+            nodeOutput.setOutputKey(outputKey);
+            nodeOutput.setOutputKeyType(outputType);
+            nodeOutput.setValue(value);
+            nodeOutput.setMetadata(metadata);
+
+            if (existingOutput != null) {
+                existingOutput.setNode(nodeDetail);
+                existingOutput.setNodeId(nodeDetail.getNodeId());
+                existingOutput.setOutputKey(outputKey);
+                existingOutput.setOutputKeyType(outputType);
+                existingOutput.setValue(value);
+                existingOutput.setMetadata(metadata);
+                nodeOutput = em.merge(existingOutput);
+            } else {
+                em.persist(nodeOutput);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
index 9d8b894..bb8755c 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
@@ -32,6 +32,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.*;
 import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -67,7 +68,7 @@ public class ProjectResource extends AbstractResource {
      * @param type child resource type
      * @return child resource
      */
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type) throws RegistryException {
         if (type == ResourceType.EXPERIMENT) {
             ExperimentResource experimentResource = new ExperimentResource();
             experimentResource.setGateway(getGateway());
@@ -91,26 +92,35 @@ public class ProjectResource extends AbstractResource {
      * @param type child resource type
      * @param name child resource name
      */
-    public void remove(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        if (type == ResourceType.EXPERIMENT) {
-        	QueryGenerator generator = new QueryGenerator(EXPERIMENT);
-        	generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
-        	Query q = generator.deleteQuery(em);
-        	q.executeUpdate();
-        }else if (type == ResourceType.PROJECT_USER){
-            QueryGenerator generator = new QueryGenerator(PROJECT_USER);
-            generator.setParameter(ProjectUserConstants.USERNAME, name);
-            generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
-            Query q = generator.deleteQuery(em);
-            q.executeUpdate();
-        }else {
-            logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
-            throw new IllegalArgumentException("Unsupported resource type for project resource.");
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            if (type == ResourceType.EXPERIMENT) {
+                QueryGenerator generator = new QueryGenerator(EXPERIMENT);
+                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+                Query q = generator.deleteQuery(em);
+                q.executeUpdate();
+            } else if (type == ResourceType.PROJECT_USER) {
+                QueryGenerator generator = new QueryGenerator(PROJECT_USER);
+                generator.setParameter(ProjectUserConstants.USERNAME, name);
+                generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
+                Query q = generator.deleteQuery(em);
+                q.executeUpdate();
+            } else {
+                logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported resource type for project resource.");
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
     /**
@@ -119,35 +129,44 @@ public class ProjectResource extends AbstractResource {
      * @param name child resource name
      * @return child resource
      */
-    public Resource get(ResourceType type, Object name) {
-        if (type == ResourceType.EXPERIMENT) {
-            EntityManager em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-        	QueryGenerator generator = new QueryGenerator(EXPERIMENT);
-        	generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
-        	Query q = generator.selectQuery(em);
-            Experiment experiment = (Experiment) q.getSingleResult();
-            ExperimentResource experimentResource = (ExperimentResource)
-                    Utils.getResource(ResourceType.EXPERIMENT, experiment);
-            em.getTransaction().commit();
-            em.close();
-            return experimentResource;
-        } else if (type == ResourceType.PROJECT_USER){
-            EntityManager em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            QueryGenerator generator = new QueryGenerator(PROJECT_USER);
-            generator.setParameter(ProjectUserConstants.USERNAME, name);
-            generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
-            Query q = generator.selectQuery(em);
-            ProjectUser prUser = (ProjectUser) q.getSingleResult();
-            ExperimentResource experimentResource = (ExperimentResource)
-                    Utils.getResource(ResourceType.PROJECT_USER, prUser);
-            em.getTransaction().commit();
-            em.close();
-            return experimentResource;
-        }else{
-            logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
-            throw new IllegalArgumentException("Unsupported resource type for project resource.");
+    public Resource get(ResourceType type, Object name) throws RegistryException {
+        EntityManager em = null;
+        try {
+            if (type == ResourceType.EXPERIMENT) {
+                em = ResourceUtils.getEntityManager();
+                em.getTransaction().begin();
+                QueryGenerator generator = new QueryGenerator(EXPERIMENT);
+                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+                Query q = generator.selectQuery(em);
+                Experiment experiment = (Experiment) q.getSingleResult();
+                ExperimentResource experimentResource = (ExperimentResource)
+                        Utils.getResource(ResourceType.EXPERIMENT, experiment);
+                em.getTransaction().commit();
+                em.close();
+                return experimentResource;
+            } else if (type == ResourceType.PROJECT_USER) {
+                em = ResourceUtils.getEntityManager();
+                em.getTransaction().begin();
+                QueryGenerator generator = new QueryGenerator(PROJECT_USER);
+                generator.setParameter(ProjectUserConstants.USERNAME, name);
+                generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
+                Query q = generator.selectQuery(em);
+                ProjectUser prUser = (ProjectUser) q.getSingleResult();
+                ExperimentResource experimentResource = (ExperimentResource)
+                        Utils.getResource(ResourceType.PROJECT_USER, prUser);
+                em.getTransaction().commit();
+                em.close();
+                return experimentResource;
+            } else {
+                logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported resource type for project resource.");
+            }
+        } catch (Exception e) {
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
     }
 
@@ -156,45 +175,55 @@ public class ProjectResource extends AbstractResource {
      * @param type child resource type
      * @return list of child resources
      */
-    public List<Resource> get(ResourceType type) {
+    public List<Resource> get(ResourceType type) throws RegistryException{
         List<Resource> resourceList = new ArrayList<Resource>();
-        if (type == ResourceType.EXPERIMENT) {
-            EntityManager em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-        	QueryGenerator generator = new QueryGenerator(EXPERIMENT);
-        	generator.setParameter(ExperimentConstants.PROJECT_ID, id);
-        	Query q = generator.selectQuery(em);
-            List<?> results = q.getResultList();
-            if (results.size() != 0) {
-                for (Object result : results) {
-                    Experiment experiment = (Experiment) result;
-                    ExperimentResource experimentResource = (ExperimentResource)
-                            Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                    resourceList.add(experimentResource);
+        EntityManager em = null;
+        try {
+            if (type == ResourceType.EXPERIMENT) {
+                em = ResourceUtils.getEntityManager();
+                em.getTransaction().begin();
+                QueryGenerator generator = new QueryGenerator(EXPERIMENT);
+                generator.setParameter(ExperimentConstants.PROJECT_ID, id);
+                Query q = generator.selectQuery(em);
+                List<?> results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        Experiment experiment = (Experiment) result;
+                        ExperimentResource experimentResource = (ExperimentResource)
+                                Utils.getResource(ResourceType.EXPERIMENT, experiment);
+                        resourceList.add(experimentResource);
+                    }
                 }
-            }
-            em.getTransaction().commit();
-            em.close();
-        }else if (type == ResourceType.PROJECT_USER) {
-            EntityManager em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            QueryGenerator generator = new QueryGenerator(PROJECT_USER);
-            generator.setParameter(ProjectUserConstants.PROJECT_ID, id);
-            Query q = generator.selectQuery(em);
-            List<?> results = q.getResultList();
-            if (results.size() != 0) {
-                for (Object result : results) {
-                    ProjectUser projectUser = (ProjectUser) result;
-                    ProjectUserResource pr = (ProjectUserResource)
-                            Utils.getResource(ResourceType.PROJECT_USER, projectUser);
-                    resourceList.add(pr);
+                em.getTransaction().commit();
+                em.close();
+            } else if (type == ResourceType.PROJECT_USER) {
+                em = ResourceUtils.getEntityManager();
+                em.getTransaction().begin();
+                QueryGenerator generator = new QueryGenerator(PROJECT_USER);
+                generator.setParameter(ProjectUserConstants.PROJECT_ID, id);
+                Query q = generator.selectQuery(em);
+                List<?> results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ProjectUser projectUser = (ProjectUser) result;
+                        ProjectUserResource pr = (ProjectUserResource)
+                                Utils.getResource(ResourceType.PROJECT_USER, projectUser);
+                        resourceList.add(pr);
+                    }
                 }
+                em.getTransaction().commit();
+                em.close();
+            } else {
+                logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported resource type for project resource.");
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
             }
-            em.getTransaction().commit();
-            em.close();
-        }else {
-            logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
-            throw new IllegalArgumentException("Unsupported resource type for project resource.");
         }
         return resourceList;
     }
@@ -202,38 +231,47 @@ public class ProjectResource extends AbstractResource {
     /**
      * save project to the database
      */
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        Project existingProject = em.find(Project.class, id);
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Project project = new Project();
-        project.setProject_id(id);
-        project.setProject_name(name);
-        Gateway modelGateway = em.find(Gateway.class, gateway.getGatewayName());
-        project.setGateway(modelGateway);
-        Users user = em.find(Users.class, worker.getUser());
-        project.setUsers(user);
-        project.setUser_name(user.getUser_name());
-        project.setDescription(description);
-        project.setCreationTime(creationTime);
-
-        if(existingProject != null){
-           existingProject.setProject_name(name);
-           existingProject.setGateway(modelGateway);
-           existingProject.setUsers(user);
-           existingProject.setUser_name(user.getUser_name());
-           existingProject.setDescription(description);
-           existingProject.setCreationTime(creationTime);
-           project = em.merge(existingProject);
-        }else {
-            em.persist(project);
-        }
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            Project existingProject = em.find(Project.class, id);
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Project project = new Project();
+            project.setProject_id(id);
+            project.setProject_name(name);
+            Gateway modelGateway = em.find(Gateway.class, gateway.getGatewayName());
+            project.setGateway(modelGateway);
+            Users user = em.find(Users.class, worker.getUser());
+            project.setUsers(user);
+            project.setUser_name(user.getUser_name());
+            project.setDescription(description);
+            project.setCreationTime(creationTime);
+
+            if (existingProject != null) {
+                existingProject.setProject_name(name);
+                existingProject.setGateway(modelGateway);
+                existingProject.setUsers(user);
+                existingProject.setUser_name(user.getUser_name());
+                existingProject.setDescription(description);
+                existingProject.setCreationTime(creationTime);
+                project = em.merge(existingProject);
+            } else {
+                em.persist(project);
+            }
 
-        em.getTransaction().commit();
-        em.close();
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
+        }
     }
 
     public String getId() {
@@ -313,7 +351,7 @@ public class ProjectResource extends AbstractResource {
      * @param experimentId experiment ID
      * @return whether the experiment exist
      */
-    public boolean isExperimentExists(String experimentId){
+    public boolean isExperimentExists(String experimentId) throws RegistryException{
 		return isExists(ResourceType.EXPERIMENT, experimentId);
 	}
 
@@ -322,7 +360,7 @@ public class ProjectResource extends AbstractResource {
      * @param experimentId experiment ID
      * @return  experiment resource
      */
-    public ExperimentResource createExperiment(String experimentId){
+    public ExperimentResource createExperiment(String experimentId) throws RegistryException{
 		ExperimentResource experimentResource = (ExperimentResource)create(ResourceType.EXPERIMENT);
 		experimentResource.setExpID(experimentId);
 		return experimentResource;
@@ -333,7 +371,7 @@ public class ProjectResource extends AbstractResource {
      * @param experimentId experiment ID
      * @return experiment resource
      */
-	public ExperimentResource getExperiment(String experimentId){
+	public ExperimentResource getExperiment(String experimentId) throws RegistryException{
 		return (ExperimentResource)get(ResourceType.EXPERIMENT,experimentId);
 	}
 
@@ -341,7 +379,7 @@ public class ProjectResource extends AbstractResource {
      *
      * @return  list of experiments
      */
-    public List<ExperimentResource> getExperiments(){
+    public List<ExperimentResource> getExperiments() throws RegistryException{
 		List<Resource> list = get(ResourceType.EXPERIMENT);
 		List<ExperimentResource> result=new ArrayList<ExperimentResource>();
 		for (Resource resource : list) {
@@ -354,11 +392,11 @@ public class ProjectResource extends AbstractResource {
      *
      * @param experimentId experiment ID
      */
-    public void removeExperiment(String experimentId){
+    public void removeExperiment(String experimentId) throws RegistryException{
 		remove(ResourceType.EXPERIMENT, experimentId);
 	}
 
-    public List<ProjectUserResource> getProjectUserList (){
+    public List<ProjectUserResource> getProjectUserList () throws RegistryException{
         List<Resource> resources = get(ResourceType.PROJECT_USER);
         List<ProjectUserResource> projectUserResources = new ArrayList<ProjectUserResource>();
         if (resources != null && !resources.isEmpty()){

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
index 3eade6a..d1b34ee 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
@@ -25,6 +25,7 @@ import org.apache.airavata.persistance.registry.jpa.Resource;
 import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.*;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -53,57 +54,66 @@ public class ProjectUserResource extends AbstractResource {
         this.userName = userName;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        ProjectUser existingPrUser = em.find(ProjectUser.class, new ProjectUser_PK(projectId, userName));
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        ProjectUser prUser = new ProjectUser();
-        prUser.setProjectID(projectId);
-        prUser.setUserName(userName);
-        Users user = em.find(Users.class, userName);
-        prUser.setUser(user);
-        Project project = em.find(Project.class, projectId);
-        prUser.setProject(project);
-
-        if(existingPrUser != null){
-            existingPrUser.setProjectID(projectId);
-            existingPrUser.setUserName(userName);
-            existingPrUser.setUser(user);
-            existingPrUser.setProject(project);
-            prUser = em.merge(existingPrUser);
-        }else {
-            em.persist(prUser);
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            ProjectUser existingPrUser = em.find(ProjectUser.class, new ProjectUser_PK(projectId, userName));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            ProjectUser prUser = new ProjectUser();
+            prUser.setProjectID(projectId);
+            prUser.setUserName(userName);
+            Users user = em.find(Users.class, userName);
+            prUser.setUser(user);
+            Project project = em.find(Project.class, projectId);
+            prUser.setProject(project);
+
+            if (existingPrUser != null) {
+                existingPrUser.setProjectID(projectId);
+                existingPrUser.setUserName(userName);
+                existingPrUser.setUser(user);
+                existingPrUser.setProject(project);
+                prUser = em.merge(existingPrUser);
+            } else {
+                em.persist(prUser);
+            }
+
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-
-        em.getTransaction().commit();
-        em.close();
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/PublishWorkflowResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/PublishWorkflowResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/PublishWorkflowResource.java
index 0ee7da0..a4bbc52 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/PublishWorkflowResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/PublishWorkflowResource.java
@@ -27,14 +27,12 @@ import org.apache.airavata.persistance.registry.jpa.model.Gateway;
 import org.apache.airavata.persistance.registry.jpa.model.Published_Workflow;
 import org.apache.airavata.persistance.registry.jpa.model.Published_Workflow_PK;
 import org.apache.airavata.persistance.registry.jpa.model.Users;
-import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.persistence.EntityManager;
-import javax.persistence.Query;
 import java.sql.Timestamp;
-import java.util.ArrayList;
 import java.util.List;
 
 public class PublishWorkflowResource extends AbstractResource {
@@ -155,7 +153,7 @@ public class PublishWorkflowResource extends AbstractResource {
      * @param type type of the child resource
      * @return UnsupportedOperationException
      */
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for published workflow resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
@@ -166,7 +164,7 @@ public class PublishWorkflowResource extends AbstractResource {
      * @param type type of the child resource
      * @param name name of the child resource
      */
-    public void remove(ResourceType type, Object name) {
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for published workflow resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
@@ -178,40 +176,18 @@ public class PublishWorkflowResource extends AbstractResource {
      * @param name name of the child resource
      * @return UnsupportedOperationException
      */
-    public Resource get(ResourceType type, Object name) {
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for published workflow resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
     /**
-     *
-     * @param keys object list including gateway name and published workflow name
-     * @return published workflow resource
-     */
-    public List<Resource> populate(Object[] keys) {
-        List<Resource> list = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator = new QueryGenerator(PUBLISHED_WORKFLOW);
-        generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, keys[0]);
-        generator.setParameter(PublishedWorkflowConstants.PUBLISH_WORKFLOW_NAME, keys[1]);
-        Query q = generator.selectQuery(em);
-        Published_Workflow publishedWorkflow = (Published_Workflow)q.getSingleResult();
-        PublishWorkflowResource publishWorkflowResource = (PublishWorkflowResource)
-                Utils.getResource(ResourceType.PUBLISHED_WORKFLOW, publishedWorkflow);
-        em.getTransaction().commit();
-        em.close();
-        list.add(publishWorkflowResource);
-        return list;
-    }
-
-    /**
      * since published workflows are at the leaf level of the
      * data structure, this method is not valid
      * @param type type of the child resource
      * @return UnsupportedOperationException
      */
-    public List<Resource> get(ResourceType type) {
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for published workflow resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
@@ -219,38 +195,47 @@ public class PublishWorkflowResource extends AbstractResource {
     /**
      * save published workflow to the database
      */
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        Published_Workflow existingWF = em.find(Published_Workflow.class, new Published_Workflow_PK(gateway.getGatewayName(), name));
-        em.close();
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            Published_Workflow existingWF = em.find(Published_Workflow.class, new Published_Workflow_PK(gateway.getGatewayName(), name));
+            em.close();
 
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Published_Workflow publishedWorkflow = new Published_Workflow();
-        publishedWorkflow.setPublish_workflow_name(getName());
-        publishedWorkflow.setPublished_date(publishedDate);
-        publishedWorkflow.setVersion(version);
-        byte[] bytes = content.getBytes();
-        publishedWorkflow.setWorkflow_content(bytes);
-        Gateway gateway = new Gateway();
-        gateway.setGateway_name(this.gateway.getGatewayName());
-        publishedWorkflow.setGateway(gateway);
-        Users user = new Users();
-        user.setUser_name(createdUser);
-        publishedWorkflow.setUser(user);
-        if(existingWF != null){
-            existingWF.setUser(user);
-            existingWF.setPublished_date(publishedDate);
-            existingWF.setWorkflow_content(bytes);
-            existingWF.setVersion(version);
-            existingWF.setPath(path);
-            publishedWorkflow = em.merge(existingWF);
-        }else {
-            em.merge(publishedWorkflow);
-        }
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Published_Workflow publishedWorkflow = new Published_Workflow();
+            publishedWorkflow.setPublish_workflow_name(getName());
+            publishedWorkflow.setPublished_date(publishedDate);
+            publishedWorkflow.setVersion(version);
+            byte[] bytes = content.getBytes();
+            publishedWorkflow.setWorkflow_content(bytes);
+            Gateway gateway = new Gateway();
+            gateway.setGateway_name(this.gateway.getGatewayName());
+            publishedWorkflow.setGateway(gateway);
+            Users user = new Users();
+            user.setUser_name(createdUser);
+            publishedWorkflow.setUser(user);
+            if (existingWF != null) {
+                existingWF.setUser(user);
+                existingWF.setPublished_date(publishedDate);
+                existingWF.setWorkflow_content(bytes);
+                existingWF.setVersion(version);
+                existingWF.setPath(path);
+                publishedWorkflow = em.merge(existingWF);
+            } else {
+                em.merge(publishedWorkflow);
+            }
 
-        em.getTransaction().commit();
-        em.close();
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
+        }
     }
 
 
@@ -261,7 +246,7 @@ public class PublishWorkflowResource extends AbstractResource {
      * @param name name of the child resource
      * @return UnsupportedOperationException
      */
-    public boolean isExists(ResourceType type, Object name) {
+    public boolean isExists(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for published workflow resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
index eaef63f..f2ce6a0 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
@@ -29,6 +29,7 @@ import org.apache.airavata.persistance.registry.jpa.model.QosParam;
 import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.airavata.registry.cpi.RegistryException;
 
 import javax.persistence.EntityManager;
 import java.util.List;
@@ -90,49 +91,58 @@ public class QosParamResource extends AbstractResource {
         this.noOfRetries = noOfRetries;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QosParam qosParam = new QosParam();
-        Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-        if (taskDetailResource != null){
-            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-            qosParam.setTaskId(taskDetailResource.getTaskId());
-            qosParam.setTask(taskDetail);
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            QosParam qosParam = new QosParam();
+            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+            if (taskDetailResource != null) {
+                TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+                qosParam.setTaskId(taskDetailResource.getTaskId());
+                qosParam.setTask(taskDetail);
+            }
+            qosParam.setExpId(experimentResource.getExpID());
+            qosParam.setExperiment(experiment);
+            qosParam.setStartExecutionAt(startExecutionAt);
+            qosParam.setExecuteBefore(executeBefore);
+            qosParam.setNoOfRetries(noOfRetries);
+            em.persist(qosParam);
+            qosId = qosParam.getQosId();
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        qosParam.setExpId(experimentResource.getExpID());
-        qosParam.setExperiment(experiment);
-        qosParam.setStartExecutionAt(startExecutionAt);
-        qosParam.setExecuteBefore(executeBefore);
-        qosParam.setNoOfRetries(noOfRetries);
-        em.persist(qosParam);
-        qosId = qosParam.getQosId();
-        em.getTransaction().commit();
-        em.close();
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ServiceDescriptorResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ServiceDescriptorResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ServiceDescriptorResource.java
index d0a93ba..371e4ea 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ServiceDescriptorResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ServiceDescriptorResource.java
@@ -27,6 +27,7 @@ import org.apache.airavata.persistance.registry.jpa.model.*;
 import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.airavata.registry.cpi.RegistryException;
 
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
@@ -72,7 +73,7 @@ public class ServiceDescriptorResource extends AbstractResource {
         this.content = content;
     }
 
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type) throws RegistryException{
         if (type == ResourceType.APPLICATION_DESCRIPTOR) {
             ApplicationDescriptorResource applicationDescriptorResource = new ApplicationDescriptorResource();
             applicationDescriptorResource.setGatewayName(gatewayName);
@@ -83,84 +84,86 @@ public class ServiceDescriptorResource extends AbstractResource {
         throw new IllegalArgumentException("Unsupported resource type for service descriptor resource.");
     }
 
-    public void remove(ResourceType type, Object name) {
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for service descriptor resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public Resource get(ResourceType type, Object name) {
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for service descriptor resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public List<Resource> populate(Object[] keys) {
-        List<Resource> list = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator = new QueryGenerator(SERVICE_DESCRIPTOR);
-        generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, keys[0]);
-        generator.setParameter(ServiceDescriptorConstants.SERVICE_DESC_ID, keys[1]);
-        Query q = generator.selectQuery(em);
-        Service_Descriptor serviceDescriptor = (Service_Descriptor)q.getSingleResult();
-        ServiceDescriptorResource serviceDescriptorResource = (ServiceDescriptorResource)Utils.getResource(ResourceType.SERVICE_DESCRIPTOR, serviceDescriptor);
-        em.getTransaction().commit();
-        em.close();
-        list.add(serviceDescriptorResource);
-        return list;
-    }
 
-    public List<Resource> get(ResourceType type) {
+    public List<Resource> get(ResourceType type) throws RegistryException{
         List<Resource> resourceList = new ArrayList<Resource>();
-        if (type == ResourceType.APPLICATION_DESCRIPTOR) {
-            EntityManager em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            QueryGenerator queryGenerator = new QueryGenerator(APPLICATION_DESCRIPTOR);
-            queryGenerator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
-            queryGenerator.setParameter(ApplicationDescriptorConstants.SERVICE_DESC_ID, serviceDescName);
-            Query q = queryGenerator.selectQuery(em);
-            List results = q.getResultList();
-            if (results.size() != 0) {
-                for (Object result : results) {
-                    Application_Descriptor applicationDescriptor = (Application_Descriptor) result;
-                    ApplicationDescriptorResource applicationDescriptorResource = (ApplicationDescriptorResource)Utils.getResource(ResourceType.APPLICATION_DESCRIPTOR, applicationDescriptor);
-                    resourceList.add(applicationDescriptorResource);
+        EntityManager em = null;
+        try {
+            if (type == ResourceType.APPLICATION_DESCRIPTOR) {
+                em = ResourceUtils.getEntityManager();
+                em.getTransaction().begin();
+                QueryGenerator queryGenerator = new QueryGenerator(APPLICATION_DESCRIPTOR);
+                queryGenerator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
+                queryGenerator.setParameter(ApplicationDescriptorConstants.SERVICE_DESC_ID, serviceDescName);
+                Query q = queryGenerator.selectQuery(em);
+                List results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        Application_Descriptor applicationDescriptor = (Application_Descriptor) result;
+                        ApplicationDescriptorResource applicationDescriptorResource = (ApplicationDescriptorResource) Utils.getResource(ResourceType.APPLICATION_DESCRIPTOR, applicationDescriptor);
+                        resourceList.add(applicationDescriptorResource);
+                    }
                 }
+                em.getTransaction().commit();
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
             }
-            em.getTransaction().commit();
-            em.close();
         }
         return resourceList;
     }
 
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        Service_Descriptor existingServiceDesc = em.find(Service_Descriptor.class, new Service_Descriptor_PK(gatewayName, serviceDescName));
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-
-        Service_Descriptor serviceDescriptor = new Service_Descriptor();
-        serviceDescriptor.setService_descriptor_ID(getServiceDescName());
-        Gateway gateway = em.find(Gateway.class, gatewayName);
-        serviceDescriptor.setGateway(gateway);
-        byte[] bytes = content.getBytes();
-        serviceDescriptor.setService_descriptor_xml(bytes);
-        Users user = em.find(Users.class, userName);
-        serviceDescriptor.setUser(user);
-        if(existingServiceDesc != null) {
-            existingServiceDesc.setUser(user);
-            existingServiceDesc.setService_descriptor_xml(bytes);
-            serviceDescriptor = em.merge(existingServiceDesc);
-        }else {
-            em.merge(serviceDescriptor);
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            Service_Descriptor existingServiceDesc = em.find(Service_Descriptor.class, new Service_Descriptor_PK(gatewayName, serviceDescName));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Service_Descriptor serviceDescriptor = new Service_Descriptor();
+            serviceDescriptor.setService_descriptor_ID(getServiceDescName());
+            Gateway gateway = em.find(Gateway.class, gatewayName);
+            serviceDescriptor.setGateway(gateway);
+            byte[] bytes = content.getBytes();
+            serviceDescriptor.setService_descriptor_xml(bytes);
+            Users user = em.find(Users.class, userName);
+            serviceDescriptor.setUser(user);
+            if (existingServiceDesc != null) {
+                existingServiceDesc.setUser(user);
+                existingServiceDesc.setService_descriptor_xml(bytes);
+                serviceDescriptor = em.merge(existingServiceDesc);
+            } else {
+                em.merge(serviceDescriptor);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
 
     }
 
-    public boolean isExists(ResourceType type, Object name) {
+    public boolean isExists(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for service descriptor resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
index 426b9c4..f821e4d 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
@@ -27,6 +27,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.airavata.registry.cpi.RegistryException;
 
 import javax.persistence.EntityManager;
 import java.sql.Timestamp;
@@ -116,67 +117,75 @@ public class StatusResource extends AbstractResource {
         this.statusType = statusType;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Status status;
-        if (statusId != 0){
-            status = em.find(Status.class, statusId);
-            status.setStatusId(statusId);
-        }else {
-            status = new Status();
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Status status;
+            if (statusId != 0) {
+                status = em.find(Status.class, statusId);
+                status.setStatusId(statusId);
+            } else {
+                status = new Status();
+            }
+            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+            if (taskDetailResource != null) {
+                TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+                status.setTask(taskDetail);
+                status.setTaskId(taskDetailResource.getTaskId());
+            }
+            if (workflowNodeDetail != null) {
+                WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, workflowNodeDetail.getNodeInstanceId());
+                status.setNode(nodeDetail);
+                status.setNodeId(workflowNodeDetail.getNodeInstanceId());
+            }
+            if (dataTransferDetail != null) {
+                DataTransferDetail transferDetail = em.find(DataTransferDetail.class, dataTransferDetail.getTransferId());
+                status.setTransferDetail(transferDetail);
+                status.setTransferId(dataTransferDetail.getTransferId());
+            }
+            status.setExperiment(experiment);
+            status.setJobId(jobId);
+            status.setExpId(experimentResource.getExpID());
+            status.setState(state);
+            status.setStatusUpdateTime(statusUpdateTime);
+            status.setStatusType(statusType);
+            em.persist(status);
+            statusId = status.getStatusId();
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-
-        Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-        if (taskDetailResource != null){
-            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-            status.setTask(taskDetail);
-            status.setTaskId(taskDetailResource.getTaskId());
-        }
-        if (workflowNodeDetail != null){
-            WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, workflowNodeDetail.getNodeInstanceId());
-            status.setNode(nodeDetail);
-            status.setNodeId(workflowNodeDetail.getNodeInstanceId());
-        }
-        if (dataTransferDetail != null){
-            DataTransferDetail transferDetail = em.find(DataTransferDetail.class, dataTransferDetail.getTransferId());
-            status.setTransferDetail(transferDetail);
-            status.setTransferId(dataTransferDetail.getTransferId());
-        }
-        status.setExperiment(experiment);
-        status.setJobId(jobId);
-        status.setExpId(experimentResource.getExpID());
-        status.setState(state);
-        status.setStatusUpdateTime(statusUpdateTime);
-        status.setStatusType(statusType);
-        em.persist(status);
-        statusId = status.getStatusId();
-        em.getTransaction().commit();
-        em.close();
     }
 }


[06/11] adding proper entity manager closing and exception handling - AIRAVATA-1285

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GatewayResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GatewayResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GatewayResource.java
index aac889c..fff2e3e 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GatewayResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GatewayResource.java
@@ -31,6 +31,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.*;
 import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -93,7 +94,7 @@ public class GatewayResource extends AbstractResource {
      * @param type resource type of the children
      * @return specific child resource type
      */
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type) throws RegistryException {
         switch (type) {
             case PROJECT:
                 ProjectResource projectResource = new ProjectResource();
@@ -139,59 +140,67 @@ public class GatewayResource extends AbstractResource {
      * @param type child resource type
      * @param name child resource name
      */
-    public void remove(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-        switch (type){
-            case USER:
-                generator = new QueryGenerator(USERS);
-                generator.setParameter(UserConstants.USERNAME, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case PUBLISHED_WORKFLOW:
-                generator = new QueryGenerator(PUBLISHED_WORKFLOW);
-                generator.setParameter(PublishedWorkflowConstants.PUBLISH_WORKFLOW_NAME, name);
-                generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, gatewayName);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case HOST_DESCRIPTOR:
-                generator = new QueryGenerator(HOST_DESCRIPTOR);
-                generator.setParameter(HostDescriptorConstants.HOST_DESC_ID, name);
-                generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, gatewayName);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case SERVICE_DESCRIPTOR:
-                generator = new QueryGenerator(SERVICE_DESCRIPTOR);
-                generator.setParameter(ServiceDescriptorConstants.SERVICE_DESC_ID, name);
-                generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, gatewayName);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case EXPERIMENT:
-                generator = new QueryGenerator(EXPERIMENT);
-                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case APPLICATION_DESCRIPTOR:
-                generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
-                generator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID, name);
-                generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            default:
-                logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
-                break;
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            switch (type) {
+                case USER:
+                    generator = new QueryGenerator(USERS);
+                    generator.setParameter(UserConstants.USERNAME, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case PUBLISHED_WORKFLOW:
+                    generator = new QueryGenerator(PUBLISHED_WORKFLOW);
+                    generator.setParameter(PublishedWorkflowConstants.PUBLISH_WORKFLOW_NAME, name);
+                    generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case HOST_DESCRIPTOR:
+                    generator = new QueryGenerator(HOST_DESCRIPTOR);
+                    generator.setParameter(HostDescriptorConstants.HOST_DESC_ID, name);
+                    generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case SERVICE_DESCRIPTOR:
+                    generator = new QueryGenerator(SERVICE_DESCRIPTOR);
+                    generator.setParameter(ServiceDescriptorConstants.SERVICE_DESC_ID, name);
+                    generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case EXPERIMENT:
+                    generator = new QueryGenerator(EXPERIMENT);
+                    generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case APPLICATION_DESCRIPTOR:
+                    generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
+                    generator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID, name);
+                    generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                default:
+                    logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
+                    break;
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-
-        em.getTransaction().commit();
-        em.close();
     }
 
     /**
@@ -200,95 +209,103 @@ public class GatewayResource extends AbstractResource {
      * @param name child resource name
      * @return specific child resource type
      */
-    public Resource get(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator;
-        Query q;
-        switch (type) {
-            case GATEWAY_WORKER:
-                generator = new QueryGenerator(GATEWAY_WORKER);
-                generator.setParameter(GatewayWorkerConstants.USERNAME, name);
-                generator.setParameter(GatewayWorkerConstants.GATEWAY_NAME, gatewayName);
-                q = generator.selectQuery(em);
-                Gateway_Worker worker = (Gateway_Worker) q.getSingleResult();
-                WorkerResource workerResource =
-                        (WorkerResource)Utils.getResource(ResourceType.GATEWAY_WORKER, worker);
-                em.getTransaction().commit();
-                em.close();
-                return workerResource;
-            case USER:
-                generator = new QueryGenerator(USERS);
-                generator.setParameter(UserConstants.USERNAME, name);
-                q = generator.selectQuery(em);
-                Users user = (Users) q.getSingleResult();
-                UserResource userResource =
-                        (UserResource)Utils.getResource(ResourceType.USER, user);
-                em.getTransaction().commit();
-                em.close();
-                return userResource;
-            case PUBLISHED_WORKFLOW:
-                generator = new QueryGenerator(PUBLISHED_WORKFLOW);
-                generator.setParameter(PublishedWorkflowConstants.PUBLISH_WORKFLOW_NAME, name);
-                generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, gatewayName);
-                q = generator.selectQuery(em);
-                Published_Workflow ePub_workflow = (Published_Workflow) q.getSingleResult();
-                PublishWorkflowResource publishWorkflowResource =
-                        (PublishWorkflowResource)Utils.getResource(ResourceType.PUBLISHED_WORKFLOW, ePub_workflow);
-                em.getTransaction().commit();
-                em.close();
-                return publishWorkflowResource;
-            case HOST_DESCRIPTOR:
-                generator = new QueryGenerator(HOST_DESCRIPTOR);
-                generator.setParameter(HostDescriptorConstants.HOST_DESC_ID, name);
-                generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, gatewayName);
-                q = generator.selectQuery(em);
-                Host_Descriptor eHostDesc = (Host_Descriptor) q.getSingleResult();
-                HostDescriptorResource hostDescriptorResource =
-                        (HostDescriptorResource)Utils.getResource(ResourceType.HOST_DESCRIPTOR, eHostDesc);
-                em.getTransaction().commit();
-                em.close();
-                return hostDescriptorResource;
-            case EXPERIMENT:
-                generator = new QueryGenerator(EXPERIMENT);
-                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
-                q = generator.selectQuery(em);
-                Experiment experiment = (Experiment)q.getSingleResult();
-                ExperimentResource experimentResource =
-                        (ExperimentResource)Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                em.getTransaction().commit();
-                em.close();
-                return experimentResource;
-            case SERVICE_DESCRIPTOR:
-                generator = new QueryGenerator(SERVICE_DESCRIPTOR);
-                generator.setParameter(ServiceDescriptorConstants.SERVICE_DESC_ID, name);
-                generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, gatewayName);
-                q = generator.selectQuery(em);
-                Service_Descriptor eServiceDesc = (Service_Descriptor) q.getSingleResult();
-                ServiceDescriptorResource serviceDescriptorResource =
-                        (ServiceDescriptorResource)Utils.getResource(ResourceType.SERVICE_DESCRIPTOR, eServiceDesc);
-                em.getTransaction().commit();
-                em.close();
-                return serviceDescriptorResource;
-            case APPLICATION_DESCRIPTOR:
-                generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
-                generator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID, name);
-                generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
-                q = generator.selectQuery(em);
-                Application_Descriptor eAppDesc = (Application_Descriptor) q.getSingleResult();
-                ApplicationDescriptorResource applicationDescriptorResource =
-                        (ApplicationDescriptorResource)Utils.getResource(ResourceType.APPLICATION_DESCRIPTOR, eAppDesc);
-                em.getTransaction().commit();
-                em.close();
-                return applicationDescriptorResource;
-            default:
-                em.getTransaction().commit();
+    public Resource get(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            QueryGenerator generator;
+            Query q;
+            switch (type) {
+                case GATEWAY_WORKER:
+                    generator = new QueryGenerator(GATEWAY_WORKER);
+                    generator.setParameter(GatewayWorkerConstants.USERNAME, name);
+                    generator.setParameter(GatewayWorkerConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.selectQuery(em);
+                    Gateway_Worker worker = (Gateway_Worker) q.getSingleResult();
+                    WorkerResource workerResource =
+                            (WorkerResource) Utils.getResource(ResourceType.GATEWAY_WORKER, worker);
+                    em.getTransaction().commit();
+                    em.close();
+                    return workerResource;
+                case USER:
+                    generator = new QueryGenerator(USERS);
+                    generator.setParameter(UserConstants.USERNAME, name);
+                    q = generator.selectQuery(em);
+                    Users user = (Users) q.getSingleResult();
+                    UserResource userResource =
+                            (UserResource) Utils.getResource(ResourceType.USER, user);
+                    em.getTransaction().commit();
+                    em.close();
+                    return userResource;
+                case PUBLISHED_WORKFLOW:
+                    generator = new QueryGenerator(PUBLISHED_WORKFLOW);
+                    generator.setParameter(PublishedWorkflowConstants.PUBLISH_WORKFLOW_NAME, name);
+                    generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.selectQuery(em);
+                    Published_Workflow ePub_workflow = (Published_Workflow) q.getSingleResult();
+                    PublishWorkflowResource publishWorkflowResource =
+                            (PublishWorkflowResource) Utils.getResource(ResourceType.PUBLISHED_WORKFLOW, ePub_workflow);
+                    em.getTransaction().commit();
+                    em.close();
+                    return publishWorkflowResource;
+                case HOST_DESCRIPTOR:
+                    generator = new QueryGenerator(HOST_DESCRIPTOR);
+                    generator.setParameter(HostDescriptorConstants.HOST_DESC_ID, name);
+                    generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.selectQuery(em);
+                    Host_Descriptor eHostDesc = (Host_Descriptor) q.getSingleResult();
+                    HostDescriptorResource hostDescriptorResource =
+                            (HostDescriptorResource) Utils.getResource(ResourceType.HOST_DESCRIPTOR, eHostDesc);
+                    em.getTransaction().commit();
+                    em.close();
+                    return hostDescriptorResource;
+                case EXPERIMENT:
+                    generator = new QueryGenerator(EXPERIMENT);
+                    generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+                    q = generator.selectQuery(em);
+                    Experiment experiment = (Experiment) q.getSingleResult();
+                    ExperimentResource experimentResource =
+                            (ExperimentResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
+                    em.getTransaction().commit();
+                    em.close();
+                    return experimentResource;
+                case SERVICE_DESCRIPTOR:
+                    generator = new QueryGenerator(SERVICE_DESCRIPTOR);
+                    generator.setParameter(ServiceDescriptorConstants.SERVICE_DESC_ID, name);
+                    generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.selectQuery(em);
+                    Service_Descriptor eServiceDesc = (Service_Descriptor) q.getSingleResult();
+                    ServiceDescriptorResource serviceDescriptorResource =
+                            (ServiceDescriptorResource) Utils.getResource(ResourceType.SERVICE_DESCRIPTOR, eServiceDesc);
+                    em.getTransaction().commit();
+                    em.close();
+                    return serviceDescriptorResource;
+                case APPLICATION_DESCRIPTOR:
+                    generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
+                    generator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID, name);
+                    generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.selectQuery(em);
+                    Application_Descriptor eAppDesc = (Application_Descriptor) q.getSingleResult();
+                    ApplicationDescriptorResource applicationDescriptorResource =
+                            (ApplicationDescriptorResource) Utils.getResource(ResourceType.APPLICATION_DESCRIPTOR, eAppDesc);
+                    em.getTransaction().commit();
+                    em.close();
+                    return applicationDescriptorResource;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
-
+            }
         }
-
     }
 
     /**
@@ -296,155 +313,173 @@ public class GatewayResource extends AbstractResource {
      * @param type child resource type
      * @return list of child resources
      */
-    public List<Resource> get(ResourceType type) {
+    public List<Resource> get(ResourceType type) throws RegistryException{
         List<Resource> resourceList = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-        List results;
-        switch (type){
-            case PROJECT:
-                generator = new QueryGenerator(PROJECT);
-                Gateway gatewayModel = em.find(Gateway.class, gatewayName);
-                generator.setParameter("gateway", gatewayModel);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Project project = (Project) result;
-                        ProjectResource projectResource =
-                                (ProjectResource)Utils.getResource(ResourceType.PROJECT, project);
-                        resourceList.add(projectResource);
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            List results;
+            switch (type) {
+                case PROJECT:
+                    generator = new QueryGenerator(PROJECT);
+                    Gateway gatewayModel = em.find(Gateway.class, gatewayName);
+                    generator.setParameter("gateway", gatewayModel);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Project project = (Project) result;
+                            ProjectResource projectResource =
+                                    (ProjectResource) Utils.getResource(ResourceType.PROJECT, project);
+                            resourceList.add(projectResource);
+                        }
                     }
-                }
-                break;
-            case GATEWAY_WORKER:
-                generator = new QueryGenerator(GATEWAY_WORKER);
-                generator.setParameter(GatewayWorkerConstants.GATEWAY_NAME, gatewayName);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Gateway_Worker gatewayWorker = (Gateway_Worker) result;
-                        WorkerResource workerResource =
-                                (WorkerResource)Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
-                        resourceList.add(workerResource);
+                    break;
+                case GATEWAY_WORKER:
+                    generator = new QueryGenerator(GATEWAY_WORKER);
+                    generator.setParameter(GatewayWorkerConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Gateway_Worker gatewayWorker = (Gateway_Worker) result;
+                            WorkerResource workerResource =
+                                    (WorkerResource) Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
+                            resourceList.add(workerResource);
+                        }
                     }
-                }
-                break;
-            case  PUBLISHED_WORKFLOW :
-                generator = new QueryGenerator(PUBLISHED_WORKFLOW);
-                generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, gatewayName);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Published_Workflow publishedWorkflow = (Published_Workflow) result;
-                        PublishWorkflowResource publishWorkflowResource =
-                                (PublishWorkflowResource)Utils.getResource(ResourceType.PUBLISHED_WORKFLOW, publishedWorkflow);
-                        resourceList.add(publishWorkflowResource);
+                    break;
+                case PUBLISHED_WORKFLOW:
+                    generator = new QueryGenerator(PUBLISHED_WORKFLOW);
+                    generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Published_Workflow publishedWorkflow = (Published_Workflow) result;
+                            PublishWorkflowResource publishWorkflowResource =
+                                    (PublishWorkflowResource) Utils.getResource(ResourceType.PUBLISHED_WORKFLOW, publishedWorkflow);
+                            resourceList.add(publishWorkflowResource);
+                        }
                     }
-                }
-                break;
-            case HOST_DESCRIPTOR:
-                generator = new QueryGenerator(HOST_DESCRIPTOR);
-                generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, gatewayName);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Host_Descriptor hostDescriptor = (Host_Descriptor) result;
-                        HostDescriptorResource hostDescriptorResource =
-                                (HostDescriptorResource)Utils.getResource(ResourceType.HOST_DESCRIPTOR, hostDescriptor);
-                        resourceList.add(hostDescriptorResource);
+                    break;
+                case HOST_DESCRIPTOR:
+                    generator = new QueryGenerator(HOST_DESCRIPTOR);
+                    generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Host_Descriptor hostDescriptor = (Host_Descriptor) result;
+                            HostDescriptorResource hostDescriptorResource =
+                                    (HostDescriptorResource) Utils.getResource(ResourceType.HOST_DESCRIPTOR, hostDescriptor);
+                            resourceList.add(hostDescriptorResource);
+                        }
                     }
-                }
-                break;
-            case SERVICE_DESCRIPTOR:
-                generator = new QueryGenerator(SERVICE_DESCRIPTOR);
-                generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, gatewayName);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Service_Descriptor serviceDescriptor = (Service_Descriptor) result;
-                        ServiceDescriptorResource serviceDescriptorResource =
-                                (ServiceDescriptorResource)Utils.getResource(ResourceType.SERVICE_DESCRIPTOR, serviceDescriptor);
-                        resourceList.add(serviceDescriptorResource);
+                    break;
+                case SERVICE_DESCRIPTOR:
+                    generator = new QueryGenerator(SERVICE_DESCRIPTOR);
+                    generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Service_Descriptor serviceDescriptor = (Service_Descriptor) result;
+                            ServiceDescriptorResource serviceDescriptorResource =
+                                    (ServiceDescriptorResource) Utils.getResource(ResourceType.SERVICE_DESCRIPTOR, serviceDescriptor);
+                            resourceList.add(serviceDescriptorResource);
+                        }
                     }
-                }
-                break;
-            case APPLICATION_DESCRIPTOR:
-                generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
-                generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Application_Descriptor applicationDescriptor = (Application_Descriptor) result;
-                        ApplicationDescriptorResource applicationDescriptorResource =
-                                (ApplicationDescriptorResource)Utils.getResource(ResourceType.APPLICATION_DESCRIPTOR, applicationDescriptor);
-                        resourceList.add(applicationDescriptorResource);
+                    break;
+                case APPLICATION_DESCRIPTOR:
+                    generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
+                    generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Application_Descriptor applicationDescriptor = (Application_Descriptor) result;
+                            ApplicationDescriptorResource applicationDescriptorResource =
+                                    (ApplicationDescriptorResource) Utils.getResource(ResourceType.APPLICATION_DESCRIPTOR, applicationDescriptor);
+                            resourceList.add(applicationDescriptorResource);
+                        }
                     }
-                }
-                break;
-            case EXPERIMENT:
-                generator = new QueryGenerator(EXPERIMENT);
-                generator.setParameter(ExperimentConstants.GATEWAY_NAME, gatewayName);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Experiment experiment = (Experiment) result;
-                        ExperimentResource experimentResource =
-                                (ExperimentResource)Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                        resourceList.add(experimentResource);
+                    break;
+                case EXPERIMENT:
+                    generator = new QueryGenerator(EXPERIMENT);
+                    generator.setParameter(ExperimentConstants.GATEWAY_NAME, gatewayName);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Experiment experiment = (Experiment) result;
+                            ExperimentResource experimentResource =
+                                    (ExperimentResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
+                            resourceList.add(experimentResource);
+                        }
                     }
-                }
-                break;
-            case USER:
-		        generator = new QueryGenerator(USERS);
-		        q = generator.selectQuery(em);
-		        for (Object o : q.getResultList()) {
-		        	Users user = (Users) o;
-		        	UserResource userResource =
-	                        (UserResource)Utils.getResource(ResourceType.USER, user);
-		        	resourceList.add(userResource);
-		        }
-		        break;
-            default:
-                em.getTransaction().commit();
+                    break;
+                case USER:
+                    generator = new QueryGenerator(USERS);
+                    q = generator.selectQuery(em);
+                    for (Object o : q.getResultList()) {
+                        Users user = (Users) o;
+                        UserResource userResource =
+                                (UserResource) Utils.getResource(ResourceType.USER, user);
+                        resourceList.add(userResource);
+                    }
+                    break;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
+            }
         }
-        em.getTransaction().commit();
-        em.close();
         return resourceList;
     }
 
     /**
      * save the gateway to the database
      */
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        Gateway existingGateway = em.find(Gateway.class, gatewayName);
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Gateway gateway = new Gateway();
-        gateway.setGateway_name(gatewayName);
-        gateway.setOwner(owner);
-        if (existingGateway != null) {
-            existingGateway.setOwner(owner);
-            gateway = em.merge(existingGateway);
-        } else {
-            em.persist(gateway);
+    public void save() throws RegistryException {
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            Gateway existingGateway = em.find(Gateway.class, gatewayName);
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Gateway gateway = new Gateway();
+            gateway.setGateway_name(gatewayName);
+            gateway.setOwner(owner);
+            if (existingGateway != null) {
+                existingGateway.setOwner(owner);
+                gateway = em.merge(existingGateway);
+            } else {
+                em.persist(gateway);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
 
     }
 
@@ -454,50 +489,57 @@ public class GatewayResource extends AbstractResource {
      * @param name name of the child resource
      * @return true or false
      */
-    public boolean isExists(ResourceType type, Object name) {
-        EntityManager em;
-        Query q;
-        Number count;
-        switch (type){
-            case GATEWAY_WORKER:
-                em = ResourceUtils.getEntityManager();
-                Gateway_Worker existingWorker = em.find(Gateway_Worker.class, new Gateway_Worker_PK(gatewayName, name.toString()));
-                em.close();
-                return existingWorker!= null;
-            case USER:
-                em = ResourceUtils.getEntityManager();
-                Users existingUser = em.find(Users.class, name);
-                em.close();
-                return existingUser!= null;
-            case PUBLISHED_WORKFLOW:
-                em = ResourceUtils.getEntityManager();
-                Published_Workflow existingWf = em.find(Published_Workflow.class, new Published_Workflow_PK(gatewayName, name.toString()));
-                em.close();
-                boolean a = existingWf != null;
-                return existingWf != null;
-            case HOST_DESCRIPTOR:
-                em = ResourceUtils.getEntityManager();
-                Host_Descriptor existingHostDesc = em.find(Host_Descriptor.class, new Host_Descriptor_PK(gatewayName, name.toString()));
-                em.close();
-                return existingHostDesc != null;
-            case SERVICE_DESCRIPTOR:
-                em = ResourceUtils.getEntityManager();
-                Service_Descriptor existingServiceDesc = em.find(Service_Descriptor.class, new Service_Descriptor_PK(gatewayName, name.toString()));
-                em.close();
-                return existingServiceDesc != null;
-            case APPLICATION_DESCRIPTOR:
-                em = ResourceUtils.getEntityManager();
-                Application_Descriptor existingAppDesc = em.find(Application_Descriptor.class, new Application_Descriptor_PK(gatewayName, name.toString()));
-                em.close();
-                return existingAppDesc != null;
-            case EXPERIMENT:
-                em = ResourceUtils.getEntityManager();
-                Experiment existingExp = em.find(Experiment.class, name.toString());
+    public boolean isExists(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            switch (type) {
+                case GATEWAY_WORKER:
+                    em = ResourceUtils.getEntityManager();
+                    Gateway_Worker existingWorker = em.find(Gateway_Worker.class, new Gateway_Worker_PK(gatewayName, name.toString()));
+                    em.close();
+                    return existingWorker != null;
+                case USER:
+                    em = ResourceUtils.getEntityManager();
+                    Users existingUser = em.find(Users.class, name);
+                    em.close();
+                    return existingUser != null;
+                case PUBLISHED_WORKFLOW:
+                    em = ResourceUtils.getEntityManager();
+                    Published_Workflow existingWf = em.find(Published_Workflow.class, new Published_Workflow_PK(gatewayName, name.toString()));
+                    em.close();
+                    boolean a = existingWf != null;
+                    return existingWf != null;
+                case HOST_DESCRIPTOR:
+                    em = ResourceUtils.getEntityManager();
+                    Host_Descriptor existingHostDesc = em.find(Host_Descriptor.class, new Host_Descriptor_PK(gatewayName, name.toString()));
+                    em.close();
+                    return existingHostDesc != null;
+                case SERVICE_DESCRIPTOR:
+                    em = ResourceUtils.getEntityManager();
+                    Service_Descriptor existingServiceDesc = em.find(Service_Descriptor.class, new Service_Descriptor_PK(gatewayName, name.toString()));
+                    em.close();
+                    return existingServiceDesc != null;
+                case APPLICATION_DESCRIPTOR:
+                    em = ResourceUtils.getEntityManager();
+                    Application_Descriptor existingAppDesc = em.find(Application_Descriptor.class, new Application_Descriptor_PK(gatewayName, name.toString()));
+                    em.close();
+                    return existingAppDesc != null;
+                case EXPERIMENT:
+                    em = ResourceUtils.getEntityManager();
+                    Experiment existingExp = em.find(Experiment.class, name.toString());
+                    em.close();
+                    return existingExp != null;
+                default:
+                    logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                return existingExp != null;
-            default:
-                logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
+            }
         }
     }
 
@@ -506,7 +548,7 @@ public class GatewayResource extends AbstractResource {
      * @param descriptorName host descriptor name
      * @return whether host descriptor already available
      */
-    public boolean isHostDescriptorExists(String descriptorName){
+    public boolean isHostDescriptorExists(String descriptorName) throws RegistryException{
     	return isExists(ResourceType.HOST_DESCRIPTOR, descriptorName);
     }
 
@@ -515,7 +557,7 @@ public class GatewayResource extends AbstractResource {
      * @param hostDescriptorName host descriptor name
      * @return HostDescriptorResource
      */
-    public HostDescriptorResource createHostDescriptorResource(String hostDescriptorName){
+    public HostDescriptorResource createHostDescriptorResource(String hostDescriptorName) throws RegistryException{
     	HostDescriptorResource hdr = (HostDescriptorResource)create(ResourceType.HOST_DESCRIPTOR);
     	hdr.setHostDescName(hostDescriptorName);
     	return hdr;
@@ -526,7 +568,7 @@ public class GatewayResource extends AbstractResource {
      * @param hostDescriptorName host descriptor name
      * @return HostDescriptorResource
      */
-    public HostDescriptorResource getHostDescriptorResource(String hostDescriptorName){
+    public HostDescriptorResource getHostDescriptorResource(String hostDescriptorName) throws RegistryException{
     	return (HostDescriptorResource)get(ResourceType.HOST_DESCRIPTOR,hostDescriptorName);
     }
 
@@ -534,7 +576,7 @@ public class GatewayResource extends AbstractResource {
      *
      * @param descriptorName host descriptor name
      */
-    public void removeHostDescriptor(String descriptorName){
+    public void removeHostDescriptor(String descriptorName) throws RegistryException{
     	remove(ResourceType.HOST_DESCRIPTOR, descriptorName);
     }
 
@@ -542,7 +584,7 @@ public class GatewayResource extends AbstractResource {
      *
      * @return list of host descriptors available for the gateway
      */
-    public List<HostDescriptorResource> getHostDescriptorResources(){
+    public List<HostDescriptorResource> getHostDescriptorResources() throws RegistryException{
     	List<HostDescriptorResource> results=new ArrayList<HostDescriptorResource>();
     	List<Resource> list = get(ResourceType.HOST_DESCRIPTOR);
     	for (Resource resource : list) {
@@ -556,7 +598,7 @@ public class GatewayResource extends AbstractResource {
      * @param descriptorName service descriptor name
      * @return whether service descriptor already available
      */
-    public boolean isServiceDescriptorExists(String descriptorName){
+    public boolean isServiceDescriptorExists(String descriptorName) throws RegistryException{
     	return isExists(ResourceType.SERVICE_DESCRIPTOR, descriptorName);
     }
 
@@ -565,7 +607,7 @@ public class GatewayResource extends AbstractResource {
      * @param descriptorName  service descriptor name
      * @return  ServiceDescriptorResource
      */
-    public ServiceDescriptorResource createServiceDescriptorResource(String descriptorName){
+    public ServiceDescriptorResource createServiceDescriptorResource(String descriptorName) throws RegistryException{
     	ServiceDescriptorResource hdr = (ServiceDescriptorResource)create(ResourceType.SERVICE_DESCRIPTOR);
     	hdr.setServiceDescName(descriptorName);
     	return hdr;
@@ -576,7 +618,7 @@ public class GatewayResource extends AbstractResource {
      * @param descriptorName   service descriptor name
      * @return ServiceDescriptorResource
      */
-    public ServiceDescriptorResource getServiceDescriptorResource(String descriptorName){
+    public ServiceDescriptorResource getServiceDescriptorResource(String descriptorName) throws RegistryException{
     	return (ServiceDescriptorResource)get(ResourceType.SERVICE_DESCRIPTOR,descriptorName);
     }
 
@@ -584,7 +626,7 @@ public class GatewayResource extends AbstractResource {
      *
      * @param descriptorName Service descriptor name
      */
-    public void removeServiceDescriptor(String descriptorName){
+    public void removeServiceDescriptor(String descriptorName) throws RegistryException{
     	remove(ResourceType.SERVICE_DESCRIPTOR, descriptorName);
     }
 
@@ -592,7 +634,7 @@ public class GatewayResource extends AbstractResource {
      *
      * @return list of service descriptors for the gateway
      */
-    public List<ServiceDescriptorResource> getServiceDescriptorResources(){
+    public List<ServiceDescriptorResource> getServiceDescriptorResources() throws RegistryException{
     	List<ServiceDescriptorResource> results=new ArrayList<ServiceDescriptorResource>();
     	List<Resource> list = get(ResourceType.SERVICE_DESCRIPTOR);
     	for (Resource resource : list) {
@@ -606,7 +648,7 @@ public class GatewayResource extends AbstractResource {
      * @param descriptorName application descriptor name
      * @return  whether application descriptor already available
      */
-    public boolean isApplicationDescriptorExists(String descriptorName){
+    public boolean isApplicationDescriptorExists(String descriptorName) throws RegistryException{
     	return isExists(ResourceType.APPLICATION_DESCRIPTOR, descriptorName);
     }
 
@@ -615,7 +657,7 @@ public class GatewayResource extends AbstractResource {
      * @param descriptorName  application descriptor name
      * @return ApplicationDescriptorResource
      */
-    public ApplicationDescriptorResource createApplicationDescriptorResource(String descriptorName){
+    public ApplicationDescriptorResource createApplicationDescriptorResource(String descriptorName) throws RegistryException{
     	ApplicationDescriptorResource hdr = (ApplicationDescriptorResource)create(ResourceType.APPLICATION_DESCRIPTOR);
     	hdr.setName(descriptorName);
     	return hdr;
@@ -626,7 +668,7 @@ public class GatewayResource extends AbstractResource {
      * @param descriptorName application descriptor name
      * @return ApplicationDescriptorResource
      */
-    public ApplicationDescriptorResource getApplicationDescriptorResource(String descriptorName){
+    public ApplicationDescriptorResource getApplicationDescriptorResource(String descriptorName) throws RegistryException{
     	return (ApplicationDescriptorResource)get(ResourceType.APPLICATION_DESCRIPTOR,descriptorName);
     }
 
@@ -634,7 +676,7 @@ public class GatewayResource extends AbstractResource {
      *
      * @param descriptorName  application descriptor name
      */
-    public void removeApplicationDescriptor(String descriptorName){
+    public void removeApplicationDescriptor(String descriptorName) throws RegistryException{
     	remove(ResourceType.APPLICATION_DESCRIPTOR, descriptorName);
     }
 
@@ -642,7 +684,7 @@ public class GatewayResource extends AbstractResource {
      *
      * @return list of application descriptors for the gateway
      */
-    public List<ApplicationDescriptorResource> getApplicationDescriptorResources(){
+    public List<ApplicationDescriptorResource> getApplicationDescriptorResources() throws RegistryException{
     	List<ApplicationDescriptorResource> results=new ArrayList<ApplicationDescriptorResource>();
     	List<Resource> list = get(ResourceType.APPLICATION_DESCRIPTOR);
     	for (Resource resource : list) {
@@ -657,44 +699,53 @@ public class GatewayResource extends AbstractResource {
      * @param hostName host descriptor name
      * @return  list of application descriptors for the gateway
      */
-    public List<ApplicationDescriptorResource> getApplicationDescriptorResources(String serviceName,String hostName){
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        String qString = "SELECT p FROM Application_Descriptor p WHERE " +
-                "p.gateway_name =:gate_name";
-        if (hostName!=null){
-        	qString+=" and p.host_descriptor_ID =:host_name";
-        }
-        if (serviceName!=null){
-        	qString+=" and p.service_descriptor_ID =:service_name";
-        }
-		Query q = em.createQuery(qString);
-        q.setParameter("gate_name", gatewayName);
-        if (serviceName!=null){
-        	q.setParameter("service_name", serviceName);
-        }
-        if (hostName!=null){
-        	q.setParameter("host_name",hostName);
-        }
-        List<?> results = q.getResultList();
-    	List<ApplicationDescriptorResource> resourceList = new ArrayList<ApplicationDescriptorResource>();
-        if (results.size() != 0) {
-            for (Object result : results) {
-                Application_Descriptor applicationDescriptor = (Application_Descriptor) result;
-                ApplicationDescriptorResource applicationDescriptorResource =
-                        new ApplicationDescriptorResource(
-                                applicationDescriptor.getApplication_descriptor_ID(),
-                                applicationDescriptor.getGateway().getGateway_name());
-                applicationDescriptorResource.setContent(new String(applicationDescriptor.getApplication_descriptor_xml()));
-                applicationDescriptorResource.setUpdatedUser(applicationDescriptor.getUser().getUser_name());
-                applicationDescriptorResource.setHostDescName(applicationDescriptor.getHost_descriptor_ID());
-                applicationDescriptorResource.setServiceDescName(applicationDescriptor.getService_descriptor_ID());
-                resourceList.add(applicationDescriptorResource);
+    public List<ApplicationDescriptorResource> getApplicationDescriptorResources(String serviceName,String hostName) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            String qString = "SELECT p FROM Application_Descriptor p WHERE " +
+                    "p.gateway_name =:gate_name";
+            if (hostName != null) {
+                qString += " and p.host_descriptor_ID =:host_name";
+            }
+            if (serviceName != null) {
+                qString += " and p.service_descriptor_ID =:service_name";
+            }
+            Query q = em.createQuery(qString);
+            q.setParameter("gate_name", gatewayName);
+            if (serviceName != null) {
+                q.setParameter("service_name", serviceName);
+            }
+            if (hostName != null) {
+                q.setParameter("host_name", hostName);
+            }
+            List<?> results = q.getResultList();
+            List<ApplicationDescriptorResource> resourceList = new ArrayList<ApplicationDescriptorResource>();
+            if (results.size() != 0) {
+                for (Object result : results) {
+                    Application_Descriptor applicationDescriptor = (Application_Descriptor) result;
+                    ApplicationDescriptorResource applicationDescriptorResource =
+                            new ApplicationDescriptorResource(
+                                    applicationDescriptor.getApplication_descriptor_ID(),
+                                    applicationDescriptor.getGateway().getGateway_name());
+                    applicationDescriptorResource.setContent(new String(applicationDescriptor.getApplication_descriptor_xml()));
+                    applicationDescriptorResource.setUpdatedUser(applicationDescriptor.getUser().getUser_name());
+                    applicationDescriptorResource.setHostDescName(applicationDescriptor.getHost_descriptor_ID());
+                    applicationDescriptorResource.setServiceDescName(applicationDescriptor.getService_descriptor_ID());
+                    resourceList.add(applicationDescriptorResource);
+                }
+            }
+            em.getTransaction().commit();
+            return resourceList;
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
             }
         }
-        em.getTransaction().commit();
-        em.close();
-        return resourceList;
     }
 
     /**
@@ -702,7 +753,7 @@ public class GatewayResource extends AbstractResource {
      * @param workflowTemplateName published workflow template name
      * @return boolean - whether workflow with the same name exists
      */
-    public boolean isPublishedWorkflowExists(String workflowTemplateName){
+    public boolean isPublishedWorkflowExists(String workflowTemplateName) throws RegistryException{
     	return isExists(ResourceType.PUBLISHED_WORKFLOW, workflowTemplateName);
     }
 
@@ -711,7 +762,7 @@ public class GatewayResource extends AbstractResource {
      * @param workflowTemplateName published workflow template name
      * @return publish workflow resource
      */
-    public PublishWorkflowResource createPublishedWorkflow(String workflowTemplateName){
+    public PublishWorkflowResource createPublishedWorkflow(String workflowTemplateName) throws RegistryException{
     	PublishWorkflowResource publishedWorkflowResource =
                 (PublishWorkflowResource)create(ResourceType.PUBLISHED_WORKFLOW);
     	publishedWorkflowResource.setName(workflowTemplateName);
@@ -725,7 +776,7 @@ public class GatewayResource extends AbstractResource {
      * @param workflowTemplateName published workflow template name
      * @return publish workflow resource
      */
-    public PublishWorkflowResource getPublishedWorkflow(String workflowTemplateName){
+    public PublishWorkflowResource getPublishedWorkflow(String workflowTemplateName) throws RegistryException{
     	return (PublishWorkflowResource)get(ResourceType.PUBLISHED_WORKFLOW,workflowTemplateName);
     }
 
@@ -733,7 +784,7 @@ public class GatewayResource extends AbstractResource {
      *
      * @return list of publish workflows for the gateway
      */
-    public List<PublishWorkflowResource> getPublishedWorkflows(){
+    public List<PublishWorkflowResource> getPublishedWorkflows() throws RegistryException{
     	List<PublishWorkflowResource> result=new ArrayList<PublishWorkflowResource>();
     	List<Resource> list = get(ResourceType.PUBLISHED_WORKFLOW);
     	for (Resource resource : list) {
@@ -746,21 +797,21 @@ public class GatewayResource extends AbstractResource {
      *
      * @param workflowTemplateName published workflow template name
      */
-    public void removePublishedWorkflow(String workflowTemplateName){
+    public void removePublishedWorkflow(String workflowTemplateName) throws RegistryException{
     	remove(ResourceType.PUBLISHED_WORKFLOW, workflowTemplateName);
     }
     
-    public ExperimentResource createExperiment (String experimentID){
+    public ExperimentResource createExperiment (String experimentID) throws RegistryException{
         ExperimentResource metadataResource = (ExperimentResource)create(ResourceType.EXPERIMENT);
         metadataResource.setExpID(experimentID);
         return metadataResource;
     }
 
-    public ExperimentResource getExperiment (String expId){
+    public ExperimentResource getExperiment (String expId) throws RegistryException{
         return (ExperimentResource)get(ResourceType.EXPERIMENT, expId);
     }
 
-    public List<ExperimentResource> getExperiments (){
+    public List<ExperimentResource> getExperiments () throws RegistryException{
         List<ExperimentResource> experiments = new ArrayList<ExperimentResource>();
         List<Resource> resources = get(ResourceType.EXPERIMENT);
         for (Resource resource : resources){

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/HostDescriptorResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/HostDescriptorResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/HostDescriptorResource.java
index ca28006..172bf65 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/HostDescriptorResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/HostDescriptorResource.java
@@ -25,6 +25,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.*;
 import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -107,7 +108,7 @@ public class HostDescriptorResource extends AbstractResource {
      * @param type child resource type
      * @return child resource
      */
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type) throws RegistryException {
         if (type == ResourceType.APPLICATION_DESCRIPTOR) {
             ApplicationDescriptorResource applicationDescriptorResource = new ApplicationDescriptorResource();
             applicationDescriptorResource.setGatewayName(gatewayName);
@@ -125,7 +126,7 @@ public class HostDescriptorResource extends AbstractResource {
      * @param type child resource type
      * @param name child resource name
      */
-    public void remove(ResourceType type, Object name) {
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for host descriptor resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
@@ -136,59 +137,47 @@ public class HostDescriptorResource extends AbstractResource {
      * @param name child resource name
      * @return UnsupportedOperationException
      */
-    public Resource get(ResourceType type, Object name) {
+    public Resource get(ResourceType type, Object name) throws RegistryException {
         logger.error("Unsupported resource type for host descriptor resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    /**
-     * key should be host_descriptor_name
-     * @param keys host descriptor names
-     * @return list of host descriptors
-     */
-    public List<Resource> populate(Object[] keys) {
-        List<Resource> list = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator = new QueryGenerator(HOST_DESCRIPTOR);
-        generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, keys [0]);
-        generator.setParameter(HostDescriptorConstants.HOST_DESC_ID, keys[1]);
-        Query q = generator.selectQuery(em);
-        Host_Descriptor hostDescriptor = (Host_Descriptor)q.getSingleResult();
-        HostDescriptorResource hostDescriptorResource =
-                (HostDescriptorResource)Utils.getResource(ResourceType.HOST_DESCRIPTOR, hostDescriptor);
-        em.getTransaction().commit();
-        em.close();
-        list.add(hostDescriptorResource);
-        return list;
-    }
 
     /**
      * Host descriptors can get a list of application descriptors
      * @param type child resource type
      * @return list of child resources
      */
-    public List<Resource> get(ResourceType type) {
+    public List<Resource> get(ResourceType type) throws RegistryException{
         List<Resource> resourceList = new ArrayList<Resource>();
-        if (type == ResourceType.APPLICATION_DESCRIPTOR) {
-            EntityManager em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            QueryGenerator generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
-            generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
-            generator.setParameter(ApplicationDescriptorConstants.HOST_DESC_ID, getHostDescName());
-            Query q = generator.selectQuery(em);
-            List results = q.getResultList();
-            if (results.size() != 0) {
-                for (Object result : results) {
-                    Application_Descriptor applicationDescriptor = (Application_Descriptor) result;
-                    ApplicationDescriptorResource applicationDescriptorResource =
-                            (ApplicationDescriptorResource)Utils.getResource(
-                                    ResourceType.APPLICATION_DESCRIPTOR, applicationDescriptor);
-                    resourceList.add(applicationDescriptorResource);
+        EntityManager em = null;
+        try {
+            if (type == ResourceType.APPLICATION_DESCRIPTOR) {
+                em = ResourceUtils.getEntityManager();
+                em.getTransaction().begin();
+                QueryGenerator generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
+                generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
+                generator.setParameter(ApplicationDescriptorConstants.HOST_DESC_ID, getHostDescName());
+                Query q = generator.selectQuery(em);
+                List results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        Application_Descriptor applicationDescriptor = (Application_Descriptor) result;
+                        ApplicationDescriptorResource applicationDescriptorResource =
+                                (ApplicationDescriptorResource) Utils.getResource(
+                                        ResourceType.APPLICATION_DESCRIPTOR, applicationDescriptor);
+                        resourceList.add(applicationDescriptorResource);
+                    }
                 }
+                em.getTransaction().commit();
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
             }
-            em.getTransaction().commit();
-            em.close();
         }
         return resourceList;
     }
@@ -196,9 +185,10 @@ public class HostDescriptorResource extends AbstractResource {
     /**
      * save host descriptor to the database
      */
-    public void save() {
+    public void save() throws RegistryException{
+        EntityManager em = null;
         try {
-            EntityManager em = ResourceUtils.getEntityManager();
+            em = ResourceUtils.getEntityManager();
             Host_Descriptor existingHost_desc = em.find(Host_Descriptor.class, new Host_Descriptor_PK(gatewayName, hostDescName));
             em.close();
 
@@ -225,11 +215,14 @@ public class HostDescriptorResource extends AbstractResource {
             }
 
             em.getTransaction().commit();
-            em.close();
         } catch (Exception e) {
-            e.printStackTrace();
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-
     }
 
     /**
@@ -238,7 +231,7 @@ public class HostDescriptorResource extends AbstractResource {
      * @param name child resource name
      * @return boolean whether the child resource already exists
      */
-    public boolean isExists(ResourceType type, Object name) {
+    public boolean isExists(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for host descriptor resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java
index aebdf15..e1eea67 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java
@@ -26,6 +26,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.*;
 import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.apache.airavata.registry.cpi.utils.StatusType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -84,8 +85,8 @@ public class JobDetailResource extends AbstractResource {
         this.computeResourceConsumed = computeResourceConsumed;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException {
         switch (type){
             case STATUS:
                 StatusResource statusResource = new StatusResource();
@@ -101,150 +102,186 @@ public class JobDetailResource extends AbstractResource {
         }
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-        switch (type){
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.JOB_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case ERROR_DETAIL:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(ErrorDetailConstants.JOB_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            default:
-                logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException());
-                break;
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            switch (type) {
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.JOB_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(ErrorDetailConstants.JOB_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                default:
+                    logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException());
+                    break;
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator;
-        Query q;
-        switch (type) {
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.JOB_ID, name);
-                q = generator.selectQuery(em);
-                Status status = (Status)q.getSingleResult();
-                StatusResource statusResource = (StatusResource)Utils.getResource(ResourceType.STATUS, status);
-                em.getTransaction().commit();
-                em.close();
-                return statusResource;
-            case ERROR_DETAIL:
-                generator = new QueryGenerator(ERROR_DETAIL);
-                generator.setParameter(ErrorDetailConstants.JOB_ID, name);
-                q = generator.selectQuery(em);
-                ErrorDetail errorDetail = (ErrorDetail)q.getSingleResult();
-                ErrorDetailResource errorDetailResource = (ErrorDetailResource)Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
-                em.getTransaction().commit();
-                em.close();
-                return errorDetailResource;
-            default:
-                em.getTransaction().commit();
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException {
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            QueryGenerator generator;
+            Query q;
+            switch (type) {
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.JOB_ID, name);
+                    q = generator.selectQuery(em);
+                    Status status = (Status) q.getSingleResult();
+                    StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+                    em.getTransaction().commit();
+                    em.close();
+                    return statusResource;
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.JOB_ID, name);
+                    q = generator.selectQuery(em);
+                    ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
+                    ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+                    em.getTransaction().commit();
+                    em.close();
+                    return errorDetailResource;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Unsupported resource type for job details resource.");
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for job details resource.");
+            }
         }
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
         List<Resource> resourceList = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-        List results;
-        switch (type){
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.JOB_ID, jobId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Status status = (Status) result;
-                        StatusResource statusResource =
-                                (StatusResource)Utils.getResource(ResourceType.STATUS, status);
-                        resourceList.add(statusResource);
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            List results;
+            switch (type) {
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.JOB_ID, jobId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Status status = (Status) result;
+                            StatusResource statusResource =
+                                    (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+                            resourceList.add(statusResource);
+                        }
                     }
-                }
-                break;
-            case ERROR_DETAIL:
-                generator = new QueryGenerator(ERROR_DETAIL);
-                generator.setParameter(ErrorDetailConstants.JOB_ID, jobId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        ErrorDetail errorDetail = (ErrorDetail) result;
-                        ErrorDetailResource errorDetailResource =
-                                (ErrorDetailResource)Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
-                        resourceList.add(errorDetailResource);
+                    break;
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.JOB_ID, jobId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            ErrorDetail errorDetail = (ErrorDetail) result;
+                            ErrorDetailResource errorDetailResource =
+                                    (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+                            resourceList.add(errorDetailResource);
+                        }
                     }
-                }
-                break;
-            default:
-                em.getTransaction().commit();
+                    break;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
+                    throw new UnsupportedOperationException();
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
-                throw new UnsupportedOperationException();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
         return resourceList;
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        JobDetail existingJobDetail = em.find(JobDetail.class, new JobDetails_PK(jobId, taskDetailResource.getTaskId()));
-        em.close();
+    
+    public void save()  throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            JobDetail existingJobDetail = em.find(JobDetail.class, new JobDetails_PK(jobId, taskDetailResource.getTaskId()));
+            em.close();
 
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        JobDetail jobDetail = new JobDetail();
-        TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-        jobDetail.setJobId(jobId);
-        jobDetail.setTask(taskDetail);
-        jobDetail.setTaskId(taskDetailResource.getTaskId());
-        jobDetail.setCreationTime(creationTime);
-        if (jobDescription != null){
-            jobDetail.setJobDescription(jobDescription.toCharArray());
-        }
-        jobDetail.setComputeResourceConsumed(computeResourceConsumed);
-        if (existingJobDetail != null){
-            existingJobDetail.setJobId(jobId);
-            existingJobDetail.setTask(taskDetail);
-            existingJobDetail.setTaskId(taskDetailResource.getTaskId());
-            existingJobDetail.setCreationTime(creationTime);
-            if (jobDescription != null){
-                existingJobDetail.setJobDescription(jobDescription.toCharArray());
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            JobDetail jobDetail = new JobDetail();
+            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+            jobDetail.setJobId(jobId);
+            jobDetail.setTask(taskDetail);
+            jobDetail.setTaskId(taskDetailResource.getTaskId());
+            jobDetail.setCreationTime(creationTime);
+            if (jobDescription != null) {
+                jobDetail.setJobDescription(jobDescription.toCharArray());
+            }
+            jobDetail.setComputeResourceConsumed(computeResourceConsumed);
+            if (existingJobDetail != null) {
+                existingJobDetail.setJobId(jobId);
+                existingJobDetail.setTask(taskDetail);
+                existingJobDetail.setTaskId(taskDetailResource.getTaskId());
+                existingJobDetail.setCreationTime(creationTime);
+                if (jobDescription != null) {
+                    existingJobDetail.setJobDescription(jobDescription.toCharArray());
+                }
+                existingJobDetail.setComputeResourceConsumed(computeResourceConsumed);
+                jobDetail = em.merge(existingJobDetail);
+            } else {
+                em.merge(jobDetail);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
             }
-            existingJobDetail.setComputeResourceConsumed(computeResourceConsumed);
-            jobDetail = em.merge(existingJobDetail);
-        }else {
-            em.merge(jobDetail);
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
-    public StatusResource getJobStatus(){
+    public StatusResource getJobStatus() throws RegistryException{
         List<Resource> resources = get(ResourceType.STATUS);
         for (Resource resource : resources) {
             StatusResource jobStatus = (StatusResource) resource;
@@ -258,7 +295,7 @@ public class JobDetailResource extends AbstractResource {
         return null;
     }
 
-    public StatusResource getApplicationStatus(){
+    public StatusResource getApplicationStatus() throws RegistryException{
         List<Resource> resources = get(ResourceType.STATUS);
         for (Resource resource : resources) {
             StatusResource appStatus = (StatusResource) resource;
@@ -272,7 +309,7 @@ public class JobDetailResource extends AbstractResource {
         return null;
     }
 
-    public List<ErrorDetailResource> getErrorDetails (){
+    public List<ErrorDetailResource> getErrorDetails () throws RegistryException{
         List<ErrorDetailResource> errorDetailResources = new ArrayList<ErrorDetailResource>();
         List<Resource> resources = get(ResourceType.ERROR_DETAIL);
         for(Resource resource : resources){

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java
index 2b12c95..5f19a4f 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java
@@ -31,6 +31,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.NodeInput;
 import org.apache.airavata.persistance.registry.jpa.model.NodeInput_PK;
 import org.apache.airavata.persistance.registry.jpa.model.WorkflowNodeDetail;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -83,59 +84,69 @@ public class NodeInputResource extends AbstractResource {
         this.value = value;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException {
         logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        NodeInput existingInput = em.find(NodeInput.class, new NodeInput_PK(inputKey, nodeDetailResource.getNodeInstanceId()));
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        NodeInput nodeInput = new NodeInput();
-        WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, nodeDetailResource.getNodeInstanceId());
-        nodeInput.setNodeDetails(nodeDetail);
-        nodeInput.setNodeId(nodeDetail.getNodeId());
-        nodeInput.setInputKey(inputKey);
-        nodeInput.setInputKeyType(inputType);
-        nodeInput.setValue(value);
-        nodeInput.setMetadata(metadata);
-        
-        if (existingInput != null){
-            existingInput.setNodeDetails(nodeDetail);
-            existingInput.setNodeId(nodeDetail.getNodeId());
-            existingInput.setInputKey(inputKey);
-            existingInput.setInputKeyType(inputType);
-            existingInput.setValue(value);
-            existingInput.setMetadata(metadata);
-            nodeInput = em.merge(existingInput);
-        }else {
-            em.persist(nodeInput);
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            NodeInput existingInput = em.find(NodeInput.class, new NodeInput_PK(inputKey, nodeDetailResource.getNodeInstanceId()));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            NodeInput nodeInput = new NodeInput();
+            WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, nodeDetailResource.getNodeInstanceId());
+            nodeInput.setNodeDetails(nodeDetail);
+            nodeInput.setNodeId(nodeDetail.getNodeId());
+            nodeInput.setInputKey(inputKey);
+            nodeInput.setInputKeyType(inputType);
+            nodeInput.setValue(value);
+            nodeInput.setMetadata(metadata);
+
+            if (existingInput != null){
+                existingInput.setNodeDetails(nodeDetail);
+                existingInput.setNodeId(nodeDetail.getNodeId());
+                existingInput.setInputKey(inputKey);
+                existingInput.setInputKeyType(inputType);
+                existingInput.setValue(value);
+                existingInput.setMetadata(metadata);
+                nodeInput = em.merge(existingInput);
+            }else {
+                em.persist(nodeInput);
+            }
+            em.getTransaction().commit();
+            em.close();
+        }catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 }


[07/11] adding proper entity manager closing and exception handling - AIRAVATA-1285

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java
index fc5e32f..64a63bb 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java
@@ -32,6 +32,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.*;
 import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.apache.airavata.registry.cpi.utils.StatusType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -130,7 +131,7 @@ public class ExperimentResource extends AbstractResource {
      * @param type  child resource types
      * @return UnsupportedOperationException
      */
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type) throws RegistryException {
     	switch (type){
 	        case EXPERIMENT_INPUT:
 	        	ExperimentInputResource inputResource = new ExperimentInputResource();
@@ -184,78 +185,87 @@ public class ExperimentResource extends AbstractResource {
      * @param name name of the child resource
      * @return UnsupportedOperationException
      */
-    public void remove(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-        switch (type){
-            case EXPERIMENT_INPUT:
-                generator = new QueryGenerator(EXPERIMENT_INPUT);
-                generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case EXPERIMENT_OUTPUT:
-                generator = new QueryGenerator(EXPERIMENT_OUTPUT);
-                generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case WORKFLOW_NODE_DETAIL:
-                generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
-                generator.setParameter(WorkflowNodeDetailsConstants.NODE_INSTANCE_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case ERROR_DETAIL:
-                generator = new QueryGenerator(ERROR_DETAIL);
-                generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.EXPERIMENT_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case CONFIG_DATA:
-                generator = new QueryGenerator(CONFIG_DATA);
-                generator.setParameter(ExperimentConfigurationDataConstants.EXPERIMENT_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case COMPUTATIONAL_RESOURCE_SCHEDULING:
-                generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
-                generator.setParameter(ComputationalResourceSchedulingConstants.EXPERIMENT_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case ADVANCE_INPUT_DATA_HANDLING:
-                generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
-                generator.setParameter(AdvancedInputDataHandlingConstants.EXPERIMENT_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case ADVANCE_OUTPUT_DATA_HANDLING:
-                generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
-                generator.setParameter(AdvancedOutputDataHandlingConstants.EXPERIMENT_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case QOS_PARAM:
-                generator = new QueryGenerator(QOS_PARAMS);
-                generator.setParameter(QosParamsConstants.EXPERIMENT_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            default:
-                logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
-                break;
+    public void remove(ResourceType type, Object name) throws RegistryException {
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            switch (type) {
+                case EXPERIMENT_INPUT:
+                    generator = new QueryGenerator(EXPERIMENT_INPUT);
+                    generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case EXPERIMENT_OUTPUT:
+                    generator = new QueryGenerator(EXPERIMENT_OUTPUT);
+                    generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case WORKFLOW_NODE_DETAIL:
+                    generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
+                    generator.setParameter(WorkflowNodeDetailsConstants.NODE_INSTANCE_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.EXPERIMENT_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case CONFIG_DATA:
+                    generator = new QueryGenerator(CONFIG_DATA);
+                    generator.setParameter(ExperimentConfigurationDataConstants.EXPERIMENT_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case COMPUTATIONAL_RESOURCE_SCHEDULING:
+                    generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
+                    generator.setParameter(ComputationalResourceSchedulingConstants.EXPERIMENT_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case ADVANCE_INPUT_DATA_HANDLING:
+                    generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
+                    generator.setParameter(AdvancedInputDataHandlingConstants.EXPERIMENT_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case ADVANCE_OUTPUT_DATA_HANDLING:
+                    generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
+                    generator.setParameter(AdvancedOutputDataHandlingConstants.EXPERIMENT_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case QOS_PARAM:
+                    generator = new QueryGenerator(QOS_PARAMS);
+                    generator.setParameter(QosParamsConstants.EXPERIMENT_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                default:
+                    logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
+                    break;
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
     /**
@@ -264,111 +274,120 @@ public class ExperimentResource extends AbstractResource {
      * @param name name of the child resource
      * @return UnsupportedOperationException
      */
-    public Resource get(ResourceType type, Object name) {
-    	EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator;
-        Query q;
-        switch (type) {
-            case EXPERIMENT_INPUT:
-                generator = new QueryGenerator(EXPERIMENT_INPUT);
-                generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, name);
-                q = generator.selectQuery(em);
-                Experiment_Input experimentInput = (Experiment_Input)q.getSingleResult();
-                ExperimentInputResource inputResource = (ExperimentInputResource)Utils.getResource(ResourceType.EXPERIMENT_INPUT, experimentInput);
-                em.getTransaction().commit();
-                em.close();
-                return inputResource;
-            case EXPERIMENT_OUTPUT:
-                generator = new QueryGenerator(EXPERIMENT_OUTPUT);
-                generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, name);
-                q = generator.selectQuery(em);
-                Experiment_Output experimentOutput = (Experiment_Output)q.getSingleResult();
-                ExperimentOutputResource outputResource = (ExperimentOutputResource)Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, experimentOutput);
-                em.getTransaction().commit();
-                em.close();
-                return outputResource;
-            case WORKFLOW_NODE_DETAIL:
-                generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
-                generator.setParameter(WorkflowNodeDetailsConstants.NODE_INSTANCE_ID, name);
-                q = generator.selectQuery(em);
-                WorkflowNodeDetail workflowNodeDetail = (WorkflowNodeDetail)q.getSingleResult();
-                WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource)Utils.getResource(ResourceType.WORKFLOW_NODE_DETAIL, workflowNodeDetail);
-                em.getTransaction().commit();
-                em.close();
-                return nodeDetailResource;
-            case ERROR_DETAIL:
-                generator = new QueryGenerator(ERROR_DETAIL);
-                generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, name);
-                q = generator.selectQuery(em);
-                ErrorDetail errorDetail = (ErrorDetail)q.getSingleResult();
-                ErrorDetailResource errorDetailResource = (ErrorDetailResource)Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
-                em.getTransaction().commit();
-                em.close();
-                return errorDetailResource;
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.EXPERIMENT_ID, name);
-                q = generator.selectQuery(em);
-                Status status = (Status)q.getSingleResult();
-                StatusResource statusResource = (StatusResource)Utils.getResource(ResourceType.STATUS, status);
-                em.getTransaction().commit();
-                em.close();
-                return statusResource;
-            case CONFIG_DATA:
-                generator = new QueryGenerator(CONFIG_DATA);
-                generator.setParameter(ExperimentConfigurationDataConstants.EXPERIMENT_ID, name);
-                q = generator.selectQuery(em);
-                ExperimentConfigData configData = (ExperimentConfigData)q.getSingleResult();
-                ConfigDataResource configDataResource = (ConfigDataResource)Utils.getResource(ResourceType.CONFIG_DATA, configData);
-                em.getTransaction().commit();
-                em.close();
-                return configDataResource;
-            case COMPUTATIONAL_RESOURCE_SCHEDULING:
-                generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
-                generator.setParameter(ComputationalResourceSchedulingConstants.EXPERIMENT_ID, name);
-                generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, null);
-                q = generator.selectQuery(em);
-                Computational_Resource_Scheduling scheduling = (Computational_Resource_Scheduling)q.getSingleResult();
-                ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource)Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, scheduling);
-                em.getTransaction().commit();
-                em.close();
-                return schedulingResource;
-            case ADVANCE_INPUT_DATA_HANDLING:
-                generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
-                generator.setParameter(AdvancedInputDataHandlingConstants.EXPERIMENT_ID, name);
-                generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, null);
-                q = generator.selectQuery(em);
-                AdvancedInputDataHandling inputDataHandling = (AdvancedInputDataHandling)q.getSingleResult();
-                AdvanceInputDataHandlingResource dataHandlingResource = (AdvanceInputDataHandlingResource)Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, inputDataHandling);
-                em.getTransaction().commit();
-                em.close();
-                return dataHandlingResource;
-            case ADVANCE_OUTPUT_DATA_HANDLING:
-                generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
-                generator.setParameter(AdvancedOutputDataHandlingConstants.EXPERIMENT_ID, name);
-                generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, null);
-                q = generator.selectQuery(em);
-                AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling)q.getSingleResult();
-                AdvancedOutputDataHandlingResource outputDataHandlingResource = (AdvancedOutputDataHandlingResource)Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
-                em.getTransaction().commit();
-                em.close();
-                return outputDataHandlingResource;
-            case QOS_PARAM:
-                generator = new QueryGenerator(QOS_PARAMS);
-                generator.setParameter(QosParamsConstants.EXPERIMENT_ID, name);
-                generator.setParameter(QosParamsConstants.TASK_ID, null);
-                q = generator.selectQuery(em);
-                QosParam qosParam = (QosParam)q.getSingleResult();
-                QosParamResource qosParamResource = (QosParamResource)Utils.getResource(ResourceType.QOS_PARAM, qosParam);
-                em.getTransaction().commit();
-                em.close();
-                return qosParamResource;
-            default:
-                em.getTransaction().commit();
+    public Resource get(ResourceType type, Object name) throws RegistryException {
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            QueryGenerator generator;
+            Query q;
+            switch (type) {
+                case EXPERIMENT_INPUT:
+                    generator = new QueryGenerator(EXPERIMENT_INPUT);
+                    generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, name);
+                    q = generator.selectQuery(em);
+                    Experiment_Input experimentInput = (Experiment_Input) q.getSingleResult();
+                    ExperimentInputResource inputResource = (ExperimentInputResource) Utils.getResource(ResourceType.EXPERIMENT_INPUT, experimentInput);
+                    em.getTransaction().commit();
+                    em.close();
+                    return inputResource;
+                case EXPERIMENT_OUTPUT:
+                    generator = new QueryGenerator(EXPERIMENT_OUTPUT);
+                    generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, name);
+                    q = generator.selectQuery(em);
+                    Experiment_Output experimentOutput = (Experiment_Output) q.getSingleResult();
+                    ExperimentOutputResource outputResource = (ExperimentOutputResource) Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, experimentOutput);
+                    em.getTransaction().commit();
+                    em.close();
+                    return outputResource;
+                case WORKFLOW_NODE_DETAIL:
+                    generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
+                    generator.setParameter(WorkflowNodeDetailsConstants.NODE_INSTANCE_ID, name);
+                    q = generator.selectQuery(em);
+                    WorkflowNodeDetail workflowNodeDetail = (WorkflowNodeDetail) q.getSingleResult();
+                    WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource) Utils.getResource(ResourceType.WORKFLOW_NODE_DETAIL, workflowNodeDetail);
+                    em.getTransaction().commit();
+                    em.close();
+                    return nodeDetailResource;
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, name);
+                    q = generator.selectQuery(em);
+                    ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
+                    ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+                    em.getTransaction().commit();
+                    em.close();
+                    return errorDetailResource;
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.EXPERIMENT_ID, name);
+                    q = generator.selectQuery(em);
+                    Status status = (Status) q.getSingleResult();
+                    StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+                    em.getTransaction().commit();
+                    em.close();
+                    return statusResource;
+                case CONFIG_DATA:
+                    generator = new QueryGenerator(CONFIG_DATA);
+                    generator.setParameter(ExperimentConfigurationDataConstants.EXPERIMENT_ID, name);
+                    q = generator.selectQuery(em);
+                    ExperimentConfigData configData = (ExperimentConfigData) q.getSingleResult();
+                    ConfigDataResource configDataResource = (ConfigDataResource) Utils.getResource(ResourceType.CONFIG_DATA, configData);
+                    em.getTransaction().commit();
+                    em.close();
+                    return configDataResource;
+                case COMPUTATIONAL_RESOURCE_SCHEDULING:
+                    generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
+                    generator.setParameter(ComputationalResourceSchedulingConstants.EXPERIMENT_ID, name);
+                    generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, null);
+                    q = generator.selectQuery(em);
+                    Computational_Resource_Scheduling scheduling = (Computational_Resource_Scheduling) q.getSingleResult();
+                    ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource) Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, scheduling);
+                    em.getTransaction().commit();
+                    em.close();
+                    return schedulingResource;
+                case ADVANCE_INPUT_DATA_HANDLING:
+                    generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
+                    generator.setParameter(AdvancedInputDataHandlingConstants.EXPERIMENT_ID, name);
+                    generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, null);
+                    q = generator.selectQuery(em);
+                    AdvancedInputDataHandling inputDataHandling = (AdvancedInputDataHandling) q.getSingleResult();
+                    AdvanceInputDataHandlingResource dataHandlingResource = (AdvanceInputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, inputDataHandling);
+                    em.getTransaction().commit();
+                    em.close();
+                    return dataHandlingResource;
+                case ADVANCE_OUTPUT_DATA_HANDLING:
+                    generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
+                    generator.setParameter(AdvancedOutputDataHandlingConstants.EXPERIMENT_ID, name);
+                    generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, null);
+                    q = generator.selectQuery(em);
+                    AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling) q.getSingleResult();
+                    AdvancedOutputDataHandlingResource outputDataHandlingResource = (AdvancedOutputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
+                    em.getTransaction().commit();
+                    em.close();
+                    return outputDataHandlingResource;
+                case QOS_PARAM:
+                    generator = new QueryGenerator(QOS_PARAMS);
+                    generator.setParameter(QosParamsConstants.EXPERIMENT_ID, name);
+                    generator.setParameter(QosParamsConstants.TASK_ID, null);
+                    q = generator.selectQuery(em);
+                    QosParam qosParam = (QosParam) q.getSingleResult();
+                    QosParamResource qosParamResource = (QosParamResource) Utils.getResource(ResourceType.QOS_PARAM, qosParam);
+                    em.getTransaction().commit();
+                    em.close();
+                    return qosParamResource;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Unsupported resource type for experiment data resource.");
+            }
+        } catch (Exception e) {
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for experiment data resource.");
+            }
         }
 
     }
@@ -378,141 +397,159 @@ public class ExperimentResource extends AbstractResource {
      * @param type  child resource types
      * @return UnsupportedOperationException
      */
-    public List<Resource> get(ResourceType type) {
+    public List<Resource> get(ResourceType type)  throws RegistryException{
         List<Resource> resourceList = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-        List results;
-        switch (type){
-            case EXPERIMENT_INPUT:
-                generator = new QueryGenerator(EXPERIMENT_INPUT);
-                generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, expID);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Experiment_Input exInput = (Experiment_Input) result;
-                        ExperimentInputResource inputResource =
-                                (ExperimentInputResource)Utils.getResource(ResourceType.EXPERIMENT_INPUT, exInput);
-                        resourceList.add(inputResource);
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            List results;
+            switch (type) {
+                case EXPERIMENT_INPUT:
+                    generator = new QueryGenerator(EXPERIMENT_INPUT);
+                    generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, expID);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Experiment_Input exInput = (Experiment_Input) result;
+                            ExperimentInputResource inputResource =
+                                    (ExperimentInputResource) Utils.getResource(ResourceType.EXPERIMENT_INPUT, exInput);
+                            resourceList.add(inputResource);
+                        }
                     }
-                }
-                break;
-            case EXPERIMENT_OUTPUT:
-                generator = new QueryGenerator(EXPERIMENT_OUTPUT);
-                generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, expID);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Experiment_Output output = (Experiment_Output) result;
-                        ExperimentOutputResource outputResource =
-                                (ExperimentOutputResource)Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, output);
-                        resourceList.add(outputResource);
+                    break;
+                case EXPERIMENT_OUTPUT:
+                    generator = new QueryGenerator(EXPERIMENT_OUTPUT);
+                    generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, expID);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Experiment_Output output = (Experiment_Output) result;
+                            ExperimentOutputResource outputResource =
+                                    (ExperimentOutputResource) Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, output);
+                            resourceList.add(outputResource);
+                        }
                     }
-                }
-                break;
-            case WORKFLOW_NODE_DETAIL:
-                generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
-                generator.setParameter(WorkflowNodeDetailsConstants.EXPERIMENT_ID, expID);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        WorkflowNodeDetail nodeDetail = (WorkflowNodeDetail) result;
-                        WorkflowNodeDetailResource nodeDetailResource =
-                                (WorkflowNodeDetailResource)Utils.getResource(ResourceType.WORKFLOW_NODE_DETAIL, nodeDetail);
-                        resourceList.add(nodeDetailResource);
+                    break;
+                case WORKFLOW_NODE_DETAIL:
+                    generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
+                    generator.setParameter(WorkflowNodeDetailsConstants.EXPERIMENT_ID, expID);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            WorkflowNodeDetail nodeDetail = (WorkflowNodeDetail) result;
+                            WorkflowNodeDetailResource nodeDetailResource =
+                                    (WorkflowNodeDetailResource) Utils.getResource(ResourceType.WORKFLOW_NODE_DETAIL, nodeDetail);
+                            resourceList.add(nodeDetailResource);
+                        }
                     }
-                }
-                break;
-            case ERROR_DETAIL:
-                generator = new QueryGenerator(ERROR_DETAIL);
-                generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, expID);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        ErrorDetail errorDetail = (ErrorDetail) result;
-                        ErrorDetailResource errorDetailResource =
-                                (ErrorDetailResource)Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
-                        resourceList.add(errorDetailResource);
+                    break;
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, expID);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            ErrorDetail errorDetail = (ErrorDetail) result;
+                            ErrorDetailResource errorDetailResource =
+                                    (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+                            resourceList.add(errorDetailResource);
+                        }
                     }
-                }
-                break;
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.EXPERIMENT_ID, expID);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Status status = (Status) result;
-                        StatusResource statusResource =
-                                (StatusResource)Utils.getResource(ResourceType.STATUS, status);
-                        resourceList.add(statusResource);
+                    break;
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.EXPERIMENT_ID, expID);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Status status = (Status) result;
+                            StatusResource statusResource =
+                                    (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+                            resourceList.add(statusResource);
+                        }
                     }
-                }
-                break;
-            default:
-                em.getTransaction().commit();
+                    break;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for experiment resource.", new UnsupportedOperationException());
+                    throw new UnsupportedOperationException();
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                logger.error("Unsupported resource type for experiment resource.", new UnsupportedOperationException());
-                throw new UnsupportedOperationException();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
         return resourceList;
     }
 
     /**
      * save experiment
      */
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        Experiment existingExp = em.find(Experiment.class, expID);
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Experiment experiment = new Experiment();
-        Project projectmodel = em.find(Project.class, project.getId());
-        experiment.setProject(projectmodel);
-        Gateway gateway = em.find(Gateway.class, getGateway().getGatewayName());
-        experiment.setExpId(expID);
-        experiment.setExecutionUser(executionUser);
-        Users userModel = em.find(Users.class, executionUser);
-        experiment.setUser(userModel);
-        experiment.setGateway(gateway);
-        experiment.setCreationTime(creationTime);
-        experiment.setExpName(expName);
-        experiment.setExpDesc(description);
-        experiment.setApplicationId(applicationId);
-        experiment.setAppVersion(applicationVersion);
-        experiment.setWorkflowExecutionId(workflowExecutionId);
-        experiment.setWorkflowTemplateVersion(workflowTemplateVersion);
-        experiment.setWorkflowExecutionId(workflowExecutionId);
-        if(existingExp != null){
-            existingExp.setGateway(gateway);
-            existingExp.setProject(projectmodel);
-            existingExp.setExecutionUser(executionUser);
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            Experiment existingExp = em.find(Experiment.class, expID);
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Experiment experiment = new Experiment();
+            Project projectmodel = em.find(Project.class, project.getId());
+            experiment.setProject(projectmodel);
+            Gateway gateway = em.find(Gateway.class, getGateway().getGatewayName());
+            experiment.setExpId(expID);
+            experiment.setExecutionUser(executionUser);
+            Users userModel = em.find(Users.class, executionUser);
             experiment.setUser(userModel);
-            existingExp.setCreationTime(creationTime);
-            existingExp.setExpName(expName);
-            existingExp.setExpDesc(description);
-            existingExp.setApplicationId(applicationId);
-            existingExp.setAppVersion(applicationVersion);
-            existingExp.setWorkflowExecutionId(workflowExecutionId);
-            existingExp.setWorkflowTemplateVersion(workflowTemplateVersion);
-            existingExp.setWorkflowExecutionId(workflowExecutionId);
-            experiment = em.merge(existingExp);
-        } else{
-           em.merge(experiment);
+            experiment.setGateway(gateway);
+            experiment.setCreationTime(creationTime);
+            experiment.setExpName(expName);
+            experiment.setExpDesc(description);
+            experiment.setApplicationId(applicationId);
+            experiment.setAppVersion(applicationVersion);
+            experiment.setWorkflowExecutionId(workflowExecutionId);
+            experiment.setWorkflowTemplateVersion(workflowTemplateVersion);
+            experiment.setWorkflowExecutionId(workflowExecutionId);
+            if (existingExp != null) {
+                existingExp.setGateway(gateway);
+                existingExp.setProject(projectmodel);
+                existingExp.setExecutionUser(executionUser);
+                experiment.setUser(userModel);
+                existingExp.setCreationTime(creationTime);
+                existingExp.setExpName(expName);
+                existingExp.setExpDesc(description);
+                existingExp.setApplicationId(applicationId);
+                existingExp.setAppVersion(applicationVersion);
+                existingExp.setWorkflowExecutionId(workflowExecutionId);
+                existingExp.setWorkflowTemplateVersion(workflowTemplateVersion);
+                existingExp.setWorkflowExecutionId(workflowExecutionId);
+                experiment = em.merge(existingExp);
+            } else {
+                em.merge(experiment);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
     /**
@@ -563,7 +600,7 @@ public class ExperimentResource extends AbstractResource {
 		this.project = project;
 	}
 
-    public List<ExperimentInputResource> getExperimentInputs (){
+    public List<ExperimentInputResource> getExperimentInputs () throws RegistryException{
         List<ExperimentInputResource> expInputs = new ArrayList<ExperimentInputResource>();
         List<Resource> resources = get(ResourceType.EXPERIMENT_INPUT);
         for (Resource resource : resources) {
@@ -572,7 +609,7 @@ public class ExperimentResource extends AbstractResource {
         return expInputs;
     }
 
-    public List<ExperimentOutputResource> getExperimentOutputs (){
+    public List<ExperimentOutputResource> getExperimentOutputs () throws RegistryException{
         List<ExperimentOutputResource> expOutputs = new ArrayList<ExperimentOutputResource>();
         List<Resource> resources = get(ResourceType.EXPERIMENT_OUTPUT);
         for (Resource resource : resources) {
@@ -581,7 +618,7 @@ public class ExperimentResource extends AbstractResource {
         return expOutputs;
     }
 
-    public StatusResource getExperimentStatus(){
+    public StatusResource getExperimentStatus() throws RegistryException{
         List<Resource> resources = get(ResourceType.STATUS);
         for (Resource resource : resources) {
             StatusResource expStatus = (StatusResource) resource;
@@ -595,7 +632,7 @@ public class ExperimentResource extends AbstractResource {
         return null;
     }
 
-    public List<StatusResource> getWorkflowNodeStatuses(){
+    public List<StatusResource> getWorkflowNodeStatuses() throws RegistryException{
         List<StatusResource> statuses = new ArrayList<StatusResource>();
         List<Resource> resources = get(ResourceType.STATUS);
         for (Resource resource : resources) {
@@ -610,7 +647,7 @@ public class ExperimentResource extends AbstractResource {
         return statuses;
     }
 
-    public List<WorkflowNodeDetailResource> getWorkflowNodeDetails (){
+    public List<WorkflowNodeDetailResource> getWorkflowNodeDetails () throws RegistryException{
         List<WorkflowNodeDetailResource> workflowNodeDetailResourceList = new ArrayList<WorkflowNodeDetailResource>();
         List<Resource> resources = get(ResourceType.WORKFLOW_NODE_DETAIL);
         for (Resource resource : resources) {
@@ -620,7 +657,7 @@ public class ExperimentResource extends AbstractResource {
         return workflowNodeDetailResourceList;
     }
 
-    public List<ErrorDetailResource> getErrorDetails (){
+    public List<ErrorDetailResource> getErrorDetails () throws RegistryException{
         List<ErrorDetailResource> errorDetailResources = new ArrayList<ErrorDetailResource>();
         List<Resource> resources = get(ResourceType.ERROR_DETAIL);
         for (Resource resource : resources) {
@@ -630,26 +667,26 @@ public class ExperimentResource extends AbstractResource {
         return errorDetailResources;
     }
 
-    public ComputationSchedulingResource getComputationScheduling (String expId){
+    public ComputationSchedulingResource getComputationScheduling (String expId) throws RegistryException{
         return  (ComputationSchedulingResource)get(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, expId);
     }
 
-    public AdvanceInputDataHandlingResource getInputDataHandling (String expId){
+    public AdvanceInputDataHandlingResource getInputDataHandling (String expId) throws RegistryException{
         return  (AdvanceInputDataHandlingResource)get(ResourceType.ADVANCE_INPUT_DATA_HANDLING, expId);
     }
 
-    public AdvancedOutputDataHandlingResource getOutputDataHandling (String expId){
+    public AdvancedOutputDataHandlingResource getOutputDataHandling (String expId) throws RegistryException{
         return  (AdvancedOutputDataHandlingResource)get(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, expId);
     }
 
-    public QosParamResource getQOSparams (String expId){
+    public QosParamResource getQOSparams (String expId) throws RegistryException{
         return  (QosParamResource)get(ResourceType.QOS_PARAM, expId);
     }
 
-    public ConfigDataResource getUserConfigData(String expID){
+    public ConfigDataResource getUserConfigData(String expID) throws RegistryException{
         return (ConfigDataResource)get(ResourceType.CONFIG_DATA, expID);
     }
-    public WorkflowNodeDetailResource getWorkflowNode (String nodeId){
+    public WorkflowNodeDetailResource getWorkflowNode (String nodeId) throws RegistryException{
         return (WorkflowNodeDetailResource)get(ResourceType.WORKFLOW_NODE_DETAIL, nodeId);
     }
 }


[09/11] adding proper entity manager closing and exception handling - AIRAVATA-1285

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
index 6df557f..c390cc2 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
@@ -29,6 +29,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.resources.*;
 import org.apache.airavata.persistance.registry.jpa.utils.ThriftDataModelConversion;
 import org.apache.airavata.registry.cpi.CompositeIdentifier;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.apache.airavata.registry.cpi.RegistryModelType;
 import org.apache.airavata.registry.cpi.utils.Constants;
 import org.apache.airavata.registry.cpi.utils.StatusType;
@@ -42,7 +43,7 @@ public class ExperimentRegistry {
     private WorkerResource workerResource;
     private final static Logger logger = LoggerFactory.getLogger(ExperimentRegistry.class);
 
-    public ExperimentRegistry(GatewayResource gateway, UserResource user) {
+    public ExperimentRegistry(GatewayResource gateway, UserResource user) throws RegistryException {
         gatewayResource = gateway;
         if (!gatewayResource.isExists(ResourceType.GATEWAY_WORKER, user.getUserName())){
             workerResource = ResourceUtils.addGatewayWorker(gateway, user);
@@ -52,7 +53,7 @@ public class ExperimentRegistry {
 
     }
 
-    public String addExperiment(Experiment experiment) throws Exception {
+    public String addExperiment(Experiment experiment) throws RegistryException {
         String experimentID;
         try {
             if (!ResourceUtils.isUserExist(experiment.getUserName())) {
@@ -120,12 +121,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while saving experiment to registry", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return experimentID;
     }
 
-    public String addUserConfigData(UserConfigurationData configurationData, String experimentID) throws Exception {
+    public String addUserConfigData(UserConfigurationData configurationData, String experimentID) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment(experimentID);
             ConfigDataResource configData = (ConfigDataResource) experiment.create(ResourceType.CONFIG_DATA);
@@ -154,12 +155,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Unable to save user config data", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return experimentID;
     }
 
-    public void addQosParams(QualityOfServiceParams qosParams, Resource resource) throws Exception {
+    public void addQosParams(QualityOfServiceParams qosParams, Resource resource) throws RegistryException {
         try {
             QosParamResource qosr = new QosParamResource();
             if (resource instanceof ExperimentResource) {
@@ -177,12 +178,12 @@ public class ExperimentRegistry {
             qosr.save();
         } catch (Exception e) {
             logger.error("Unable to save QOS params", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public void addOutputDataHandling(AdvancedOutputDataHandling outputDataHandling, Resource resource) throws Exception {
+    public void addOutputDataHandling(AdvancedOutputDataHandling outputDataHandling, Resource resource) throws RegistryException {
         AdvancedOutputDataHandlingResource adodh = new AdvancedOutputDataHandlingResource();
         try {
             if (resource instanceof ExperimentResource) {
@@ -200,12 +201,12 @@ public class ExperimentRegistry {
             adodh.save();
         } catch (Exception e) {
             logger.error("Unable to save output data handling data", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public void addInputDataHandling(AdvancedInputDataHandling inputDataHandling, Resource resource) throws Exception {
+    public void addInputDataHandling(AdvancedInputDataHandling inputDataHandling, Resource resource) throws RegistryException {
         AdvanceInputDataHandlingResource adidh = new AdvanceInputDataHandlingResource();
         try {
             if (resource instanceof ExperimentResource) {
@@ -224,12 +225,12 @@ public class ExperimentRegistry {
             adidh.save();
         } catch (Exception e) {
             logger.error("Unable to save input data handling data", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public void addComputationScheduling(ComputationalResourceScheduling resourceScheduling, Resource resource) throws Exception {
+    public void addComputationScheduling(ComputationalResourceScheduling resourceScheduling, Resource resource) throws RegistryException {
         ComputationSchedulingResource cmsr = new ComputationSchedulingResource();
         try {
             if (resource instanceof ExperimentResource) {
@@ -253,12 +254,12 @@ public class ExperimentRegistry {
             cmsr.save();
         } catch (Exception e) {
             logger.error("Unable to save computational scheduling data", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public void addExpInputs(List<DataObjectType> exInputs, ExperimentResource experimentResource) throws Exception {
+    public void addExpInputs(List<DataObjectType> exInputs, ExperimentResource experimentResource) throws RegistryException {
         try {
             for (DataObjectType input : exInputs) {
                 ExperimentInputResource resource = (ExperimentInputResource) experimentResource.create(ResourceType.EXPERIMENT_INPUT);
@@ -271,11 +272,11 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Unable to save experiment inputs", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void updateExpInputs(List<DataObjectType> exInputs, ExperimentResource experimentResource) throws Exception {
+    public void updateExpInputs(List<DataObjectType> exInputs, ExperimentResource experimentResource) throws RegistryException {
         try {
             List<ExperimentInputResource> experimentInputs = experimentResource.getExperimentInputs();
             for (DataObjectType input : exInputs) {
@@ -290,12 +291,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Unable to update experiment inputs", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public String addExpOutputs(List<DataObjectType> exOutput, String expId) throws Exception {
+    public String addExpOutputs(List<DataObjectType> exOutput, String expId) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment(expId);
             for (DataObjectType output : exOutput) {
@@ -309,12 +310,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while adding experiment outputs...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return expId;
     }
 
-    public void updateExpOutputs(List<DataObjectType> exOutput, String expId) throws Exception {
+    public void updateExpOutputs(List<DataObjectType> exOutput, String expId) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment(expId);
             List<ExperimentOutputResource> existingExpOutputs = experiment.getExperimentOutputs();
@@ -332,11 +333,11 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating experiment outputs", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public String addNodeOutputs(List<DataObjectType> wfOutputs, CompositeIdentifier ids) throws Exception {
+    public String addNodeOutputs(List<DataObjectType> wfOutputs, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
             WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode((String) ids.getSecondLevelIdentifier());
@@ -351,12 +352,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while adding node outputs...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return (String) ids.getSecondLevelIdentifier();
     }
 
-    public void updateNodeOutputs(List<DataObjectType> wfOutputs, String nodeId) throws Exception {
+    public void updateNodeOutputs(List<DataObjectType> wfOutputs, String nodeId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode(nodeId);
@@ -373,11 +374,11 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating node outputs...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public String addApplicationOutputs(List<DataObjectType> appOutputs, CompositeIdentifier ids) throws Exception {
+    public String addApplicationOutputs(List<DataObjectType> appOutputs, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode((String) ids.getTopLevelIdentifier());
@@ -393,12 +394,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while adding application outputs...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return (String) ids.getSecondLevelIdentifier();
     }
 
-    public String updateExperimentStatus(ExperimentStatus experimentStatus, String expId) throws Exception {
+    public String updateExperimentStatus(ExperimentStatus experimentStatus, String expId) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment(expId);
             StatusResource status = experiment.getExperimentStatus();
@@ -416,12 +417,12 @@ public class ExperimentRegistry {
             status.save();
         } catch (Exception e) {
             logger.error("Error while updating experiment status...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return expId;
     }
 
-    public String addWorkflowNodeStatus(WorkflowNodeStatus status, CompositeIdentifier ids) throws Exception {
+    public String addWorkflowNodeStatus(WorkflowNodeStatus status, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
             WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode((String) ids.getSecondLevelIdentifier());
@@ -439,11 +440,11 @@ public class ExperimentRegistry {
             return String.valueOf(statusResource.getStatusId());
         } catch (Exception e) {
             logger.error("Error while adding workflow node status...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public String updateWorkflowNodeStatus(WorkflowNodeStatus status, String nodeId) throws Exception {
+    public String updateWorkflowNodeStatus(WorkflowNodeStatus status, String nodeId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode(nodeId);
@@ -460,11 +461,11 @@ public class ExperimentRegistry {
             return String.valueOf(statusResource.getStatusId());
         } catch (Exception e) {
             logger.error("Error whilw updating workflow node status...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public String addTaskStatus(TaskStatus status, CompositeIdentifier ids) throws Exception {
+    public String addTaskStatus(TaskStatus status, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode((String) ids.getTopLevelIdentifier());
@@ -484,11 +485,11 @@ public class ExperimentRegistry {
             return String.valueOf(statusResource.getStatusId());
         } catch (Exception e) {
             logger.error("Error while adding task status...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void updateTaskStatus(TaskStatus status, String taskId) throws Exception {
+    public void updateTaskStatus(TaskStatus status, String taskId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -508,7 +509,7 @@ public class ExperimentRegistry {
             statusResource.save();
         } catch (Exception e) {
             logger.error("Error while updating task status...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
@@ -517,7 +518,7 @@ public class ExperimentRegistry {
      * @param ids    composite id will contain taskid and jobid
      * @return status id
      */
-    public String addJobStatus(JobStatus status, CompositeIdentifier ids) throws Exception {
+    public String addJobStatus(JobStatus status, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -538,11 +539,11 @@ public class ExperimentRegistry {
             return String.valueOf(statusResource.getStatusId());
         } catch (Exception e) {
             logger.error("Error while adding job status...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public String updateJobStatus(JobStatus status, CompositeIdentifier ids) throws Exception {
+    public String updateJobStatus(JobStatus status, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -561,7 +562,7 @@ public class ExperimentRegistry {
             return String.valueOf(statusResource.getStatusId());
         } catch (Exception e) {
             logger.error("Error while updating job status...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
@@ -570,7 +571,7 @@ public class ExperimentRegistry {
      * @param ids    composite id will contain taskid and jobid
      * @return status id
      */
-    public String addApplicationStatus(ApplicationStatus status, CompositeIdentifier ids) throws Exception {
+    public String addApplicationStatus(ApplicationStatus status, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -591,11 +592,11 @@ public class ExperimentRegistry {
             return String.valueOf(statusResource.getStatusId());
         } catch (Exception e) {
             logger.error("Unable to read airavata-server properties", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void updateApplicationStatus(ApplicationStatus status, String jobId) throws Exception {
+    public void updateApplicationStatus(ApplicationStatus status, String jobId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -611,7 +612,7 @@ public class ExperimentRegistry {
             statusResource.save();
         } catch (Exception e) {
             logger.error("Error while updating application status...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
@@ -621,7 +622,7 @@ public class ExperimentRegistry {
      * @param ids    contains taskId and transfer id
      * @return status id
      */
-    public String addTransferStatus(TransferStatus status, CompositeIdentifier ids) throws Exception {
+    public String addTransferStatus(TransferStatus status, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -643,11 +644,11 @@ public class ExperimentRegistry {
             return String.valueOf(statusResource.getStatusId());
         } catch (Exception e) {
             logger.error("Error while adding transfer status...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void updateTransferStatus(TransferStatus status, String transferId) throws Exception {
+    public void updateTransferStatus(TransferStatus status, String transferId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -668,11 +669,11 @@ public class ExperimentRegistry {
             statusResource.save();
         } catch (Exception e) {
             logger.error("Error while updating transfer status...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public String addWorkflowNodeDetails(WorkflowNodeDetails nodeDetails, String expId) throws Exception {
+    public String addWorkflowNodeDetails(WorkflowNodeDetails nodeDetails, String expId) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment(expId);
             WorkflowNodeDetailResource resource = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -724,11 +725,11 @@ public class ExperimentRegistry {
             return nodeId;
         } catch (Exception e) {
             logger.error("Error while adding workflow node details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void updateWorkflowNodeDetails(WorkflowNodeDetails nodeDetails, String nodeId) throws Exception {
+    public void updateWorkflowNodeDetails(WorkflowNodeDetails nodeDetails, String nodeId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode(nodeId);
@@ -773,12 +774,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating workflow node details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
 
-    public void addWorkflowInputs(List<DataObjectType> wfInputs, WorkflowNodeDetailResource nodeDetailResource) throws Exception {
+    public void addWorkflowInputs(List<DataObjectType> wfInputs, WorkflowNodeDetailResource nodeDetailResource) throws RegistryException {
         try {
             for (DataObjectType input : wfInputs) {
                 NodeInputResource resource = (NodeInputResource) nodeDetailResource.create(ResourceType.NODE_INPUT);
@@ -791,12 +792,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while adding workflow inputs...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public void updateWorkflowInputs(List<DataObjectType> wfInputs, WorkflowNodeDetailResource nodeDetailResource) throws Exception {
+    public void updateWorkflowInputs(List<DataObjectType> wfInputs, WorkflowNodeDetailResource nodeDetailResource) throws RegistryException {
         try {
             List<NodeInputResource> nodeInputs = nodeDetailResource.getNodeInputs();
             for (DataObjectType input : wfInputs) {
@@ -811,12 +812,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating workflow inputs...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public String addTaskDetails(TaskDetails taskDetails, String nodeId) throws Exception {
+    public String addTaskDetails(TaskDetails taskDetails, String nodeId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode(nodeId);
@@ -887,11 +888,11 @@ public class ExperimentRegistry {
             return taskDetail.getTaskId();
         } catch (Exception e) {
             logger.error("Error while adding task details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public String updateTaskDetails(TaskDetails taskDetails, String taskId) throws Exception {
+    public String updateTaskDetails(TaskDetails taskDetails, String taskId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -946,11 +947,11 @@ public class ExperimentRegistry {
             return taskDetail.getTaskId();
         } catch (Exception e) {
             logger.error("Error while updating task details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void addAppInputs(List<DataObjectType> appInputs, TaskDetailResource taskDetailResource) throws Exception {
+    public void addAppInputs(List<DataObjectType> appInputs, TaskDetailResource taskDetailResource) throws RegistryException {
         try {
             for (DataObjectType input : appInputs) {
                 ApplicationInputResource resource = (ApplicationInputResource) taskDetailResource.create(ResourceType.APPLICATION_INPUT);
@@ -963,12 +964,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while adding application inputs...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public void addAppOutputs(List<DataObjectType> appInputs, TaskDetailResource taskDetailResource) throws Exception {
+    public void addAppOutputs(List<DataObjectType> appInputs, TaskDetailResource taskDetailResource) throws RegistryException {
         try {
             for (DataObjectType input : appInputs) {
                 ApplicationOutputResource resource = (ApplicationOutputResource) taskDetailResource.create(ResourceType.APPLICATION_OUTPUT);
@@ -981,12 +982,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while adding application outputs...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public void updateAppOutputs(List<DataObjectType> appOutputs, String taskId) throws Exception {
+    public void updateAppOutputs(List<DataObjectType> appOutputs, String taskId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -1004,11 +1005,11 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating application outputs...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void updateAppInputs(List<DataObjectType> appInputs, TaskDetailResource taskDetailResource) throws Exception {
+    public void updateAppInputs(List<DataObjectType> appInputs, TaskDetailResource taskDetailResource) throws RegistryException {
         try {
             List<ApplicationInputResource> inputs = taskDetailResource.getApplicationInputs();
             for (DataObjectType input : appInputs) {
@@ -1024,12 +1025,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating application inputs...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public String addJobDetails(JobDetails jobDetails, CompositeIdentifier ids) throws Exception {
+    public String addJobDetails(JobDetails jobDetails, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -1067,12 +1068,12 @@ public class ExperimentRegistry {
             return jobDetail.getJobId();
         } catch (Exception e) {
             logger.error("Error while adding job details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
     // ids - taskId + jobid
-    public void updateJobDetails(JobDetails jobDetails, CompositeIdentifier ids) throws Exception {
+    public void updateJobDetails(JobDetails jobDetails, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -1111,11 +1112,11 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating job details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public String addDataTransferDetails(DataTransferDetails transferDetails, String taskId) throws Exception {
+    public String addDataTransferDetails(DataTransferDetails transferDetails, String taskId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -1140,11 +1141,11 @@ public class ExperimentRegistry {
             return resource.getTransferId();
         } catch (Exception e) {
             logger.error("Error while adding transfer details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public String updateDataTransferDetails(DataTransferDetails transferDetails, String transferId) throws Exception {
+    public String updateDataTransferDetails(DataTransferDetails transferDetails, String transferId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -1168,7 +1169,7 @@ public class ExperimentRegistry {
             return resource.getTransferId();
         } catch (Exception e) {
             logger.error("Error while updating transfer details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
@@ -1177,7 +1178,7 @@ public class ExperimentRegistry {
      * @param ids        contains expId and taskId, if it is an experiment, task id can be null
      * @return scheduling id
      */
-    public String addComputationalResourceScheduling(ComputationalResourceScheduling scheduling, CompositeIdentifier ids) throws Exception {
+    public String addComputationalResourceScheduling(ComputationalResourceScheduling scheduling, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
             ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource) experiment.create(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING);
@@ -1200,7 +1201,7 @@ public class ExperimentRegistry {
             return String.valueOf(schedulingResource.getSchedulingId());
         } catch (Exception e) {
             logger.error("Error while adding scheduling parameters...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
@@ -1209,7 +1210,7 @@ public class ExperimentRegistry {
      * @param ids          contains expId and taskId
      * @return data handling id
      */
-    public String addInputDataHandling(AdvancedInputDataHandling dataHandling, CompositeIdentifier ids) throws Exception {
+    public String addInputDataHandling(AdvancedInputDataHandling dataHandling, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
             AdvanceInputDataHandlingResource dataHandlingResource = (AdvanceInputDataHandlingResource) experiment.create(ResourceType.ADVANCE_INPUT_DATA_HANDLING);
@@ -1227,7 +1228,7 @@ public class ExperimentRegistry {
             return String.valueOf(dataHandlingResource.getDataHandlingId());
         } catch (Exception e) {
             logger.error("Error while adding input data handling...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
@@ -1236,7 +1237,7 @@ public class ExperimentRegistry {
      * @param ids          contains expId and taskId
      * @return data handling id
      */
-    public String addOutputDataHandling(AdvancedOutputDataHandling dataHandling, CompositeIdentifier ids) throws Exception {
+    public String addOutputDataHandling(AdvancedOutputDataHandling dataHandling, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
             AdvancedOutputDataHandlingResource dataHandlingResource = (AdvancedOutputDataHandlingResource) experiment.create(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING);
@@ -1253,11 +1254,11 @@ public class ExperimentRegistry {
             return String.valueOf(dataHandlingResource.getOutputDataHandlingId());
         } catch (Exception e) {
             logger.error("Error while adding output data handling...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public String addQosParams(QualityOfServiceParams qosParams, CompositeIdentifier ids) throws Exception {
+    public String addQosParams(QualityOfServiceParams qosParams, CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
             QosParamResource qosParamResource = (QosParamResource) experiment.create(ResourceType.QOS_PARAM);
@@ -1274,11 +1275,11 @@ public class ExperimentRegistry {
             return String.valueOf(qosParamResource.getQosId());
         } catch (Exception e) {
             logger.error("Error while adding QOS params...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public String addErrorDetails(ErrorDetails error, Object id) throws Exception {
+    public String addErrorDetails(ErrorDetails error, Object id) throws RegistryException {
         try {
 
             ErrorDetailResource errorResource = null;
@@ -1349,7 +1350,7 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Unable to add error details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
@@ -1374,7 +1375,7 @@ public class ExperimentRegistry {
         return task + "_" + UUID.randomUUID();
     }
 
-    public void updateExperimentField(String expID, String fieldName, Object value) throws Exception {
+    public void updateExperimentField(String expID, String fieldName, Object value) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment(expID);
             if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME)) {
@@ -1404,11 +1405,11 @@ public class ExperimentRegistry {
 
         } catch (Exception e) {
             logger.error("Error while updating fields in experiment...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void updateExpConfigDataField(String expID, String fieldName, Object value) throws Exception {
+    public void updateExpConfigDataField(String expID, String fieldName, Object value) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment(expID);
             ConfigDataResource exConfigData = (ConfigDataResource) experiment.get(ResourceType.CONFIG_DATA, expID);
@@ -1435,11 +1436,11 @@ public class ExperimentRegistry {
 
         } catch (Exception e) {
             logger.error("Error while updating fields in experiment config...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void updateExperiment(Experiment experiment, String expId) throws Exception {
+    public void updateExperiment(Experiment experiment, String expId) throws RegistryException {
         try {
             ExperimentResource existingExperiment = gatewayResource.getExperiment(expId);
             existingExperiment.setExpName(experiment.getName());
@@ -1491,12 +1492,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating experiment...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public void updateUserConfigData(UserConfigurationData configData, String expId) throws Exception {
+    public void updateUserConfigData(UserConfigurationData configData, String expId) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment(expId);
             ConfigDataResource resource = (ConfigDataResource) experiment.get(ResourceType.CONFIG_DATA, expId);
@@ -1524,12 +1525,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating user config data...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public void updateQosParams(QualityOfServiceParams qosParams, Resource resource) throws Exception {
+    public void updateQosParams(QualityOfServiceParams qosParams, Resource resource) throws RegistryException {
         try {
             if (resource instanceof ExperimentResource) {
                 ExperimentResource expResource = (ExperimentResource) resource;
@@ -1542,12 +1543,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating QOS data...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public void updateOutputDataHandling(AdvancedOutputDataHandling outputDataHandling, Resource resource) throws Exception {
+    public void updateOutputDataHandling(AdvancedOutputDataHandling outputDataHandling, Resource resource) throws RegistryException {
         AdvancedOutputDataHandlingResource adodh;
         try {
             if (resource instanceof ExperimentResource) {
@@ -1566,12 +1567,12 @@ public class ExperimentRegistry {
             adodh.save();
         } catch (Exception e) {
             logger.error("Error while updating output data handling...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public void updateInputDataHandling(AdvancedInputDataHandling inputDataHandling, Resource resource) throws Exception {
+    public void updateInputDataHandling(AdvancedInputDataHandling inputDataHandling, Resource resource) throws RegistryException {
         AdvanceInputDataHandlingResource adidh;
         try {
             if (resource instanceof ExperimentResource) {
@@ -1591,12 +1592,12 @@ public class ExperimentRegistry {
             adidh.save();
         } catch (Exception e) {
             logger.error("Error while updating input data handling...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public void updateSchedulingData(ComputationalResourceScheduling resourceScheduling, Resource resource) throws Exception {
+    public void updateSchedulingData(ComputationalResourceScheduling resourceScheduling, Resource resource) throws RegistryException {
         ComputationSchedulingResource cmsr;
         try {
             if (resource instanceof ExperimentResource) {
@@ -1621,12 +1622,12 @@ public class ExperimentRegistry {
             cmsr.save();
         } catch (Exception e) {
             logger.error("Error while updating scheduling data...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
 
     }
 
-    public List<Experiment> getExperimentList(String fieldName, Object value) throws Exception {
+    public List<Experiment> getExperimentList(String fieldName, Object value) throws RegistryException {
         List<Experiment> experiments = new ArrayList<Experiment>();
         try {
             if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.USER_NAME)) {
@@ -1659,12 +1660,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while getting experiment list...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return experiments;
     }
 
-    public List<WorkflowNodeDetails> getWFNodeDetails(String fieldName, Object value) throws Exception {
+    public List<WorkflowNodeDetails> getWFNodeDetails(String fieldName, Object value) throws RegistryException {
         try {
             if (fieldName.equals(Constants.FieldConstants.WorkflowNodeConstants.EXPERIMENT_ID)) {
                 ExperimentResource experiment = gatewayResource.getExperiment((String) value);
@@ -1675,12 +1676,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while getting workfkow details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
 
-    public List<WorkflowNodeStatus> getWFNodeStatusList(String fieldName, Object value) throws Exception {
+    public List<WorkflowNodeStatus> getWFNodeStatusList(String fieldName, Object value) throws RegistryException {
         try {
             if (fieldName.equals(Constants.FieldConstants.WorkflowNodeStatusConstants.EXPERIMENT_ID)) {
                 ExperimentResource experiment = gatewayResource.getExperiment((String) value);
@@ -1691,12 +1692,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while getting workflow status...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
 
-    public List<TaskDetails> getTaskDetails(String fieldName, Object value) throws Exception {
+    public List<TaskDetails> getTaskDetails(String fieldName, Object value) throws RegistryException {
         try {
             if (fieldName.equals(Constants.FieldConstants.TaskDetailConstants.NODE_ID)) {
                 ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
@@ -1708,12 +1709,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while getting task details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
 
-    public List<JobDetails> getJobDetails(String fieldName, Object value) throws Exception {
+    public List<JobDetails> getJobDetails(String fieldName, Object value) throws RegistryException {
         try {
             if (fieldName.equals(Constants.FieldConstants.JobDetaisConstants.TASK_ID)) {
                 ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
@@ -1726,12 +1727,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while job details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
 
-    public List<DataTransferDetails> getDataTransferDetails(String fieldName, Object value) throws Exception {
+    public List<DataTransferDetails> getDataTransferDetails(String fieldName, Object value) throws RegistryException {
         try {
             if (fieldName.equals(Constants.FieldConstants.DataTransferDetailConstants.TASK_ID)) {
                 ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
@@ -1744,12 +1745,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while getting data transfer details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
 
-    public List<ErrorDetails> getErrorDetails(String fieldName, Object value) throws Exception {
+    public List<ErrorDetails> getErrorDetails(String fieldName, Object value) throws RegistryException {
         try {
             if (fieldName.equals(Constants.FieldConstants.ErrorDetailsConstants.EXPERIMENT_ID)) {
                 ExperimentResource experiment = gatewayResource.getExperiment((String) value);
@@ -1779,12 +1780,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Unable to get error details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
 
-    public Object getExperiment(String expId, String fieldName) throws Exception {
+    public Object getExperiment(String expId, String fieldName) throws RegistryException {
         try {
             ExperimentResource resource = gatewayResource.getExperiment(expId);
             if (fieldName == null) {
@@ -1826,12 +1827,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while getting experiment info...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
 
-    public Object getConfigData(String expId, String fieldName) throws Exception {
+    public Object getConfigData(String expId, String fieldName) throws RegistryException {
         try {
             ExperimentResource resource = gatewayResource.getExperiment(expId);
             ConfigDataResource userConfigData = resource.getUserConfigData(expId);
@@ -1856,12 +1857,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while getting config data..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
 
-    public List<DataObjectType> getExperimentOutputs(String expId) throws Exception {
+    public List<DataObjectType> getExperimentOutputs(String expId) throws RegistryException {
         try {
             ExperimentResource resource = gatewayResource.getExperiment(expId);
             List<ExperimentOutputResource> experimentOutputs = resource.getExperimentOutputs();
@@ -1872,18 +1873,18 @@ public class ExperimentRegistry {
         return null;
     }
 
-    public ExperimentStatus getExperimentStatus(String expId) throws Exception {
+    public ExperimentStatus getExperimentStatus(String expId) throws RegistryException {
         try {
             ExperimentResource resource = gatewayResource.getExperiment(expId);
             StatusResource experimentStatus = resource.getExperimentStatus();
             return ThriftDataModelConversion.getExperimentStatus(experimentStatus);
         } catch (Exception e) {
             logger.error("Error while getting experiment status...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public ComputationalResourceScheduling getComputationalScheduling(RegistryModelType type, String id) throws Exception {
+    public ComputationalResourceScheduling getComputationalScheduling(RegistryModelType type, String id) throws RegistryException {
         try {
             ComputationSchedulingResource computationScheduling = null;
             switch (type) {
@@ -1903,12 +1904,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while getting scheduling data..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
 
-    public AdvancedInputDataHandling getInputDataHandling(RegistryModelType type, String id) throws Exception {
+    public AdvancedInputDataHandling getInputDataHandling(RegistryModelType type, String id) throws RegistryException {
         try {
             AdvanceInputDataHandlingResource dataHandlingResource = null;
             switch (type) {
@@ -1928,12 +1929,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while getting input data handling..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
 
-    public AdvancedOutputDataHandling getOutputDataHandling(RegistryModelType type, String id) throws Exception {
+    public AdvancedOutputDataHandling getOutputDataHandling(RegistryModelType type, String id) throws RegistryException {
         try {
             AdvancedOutputDataHandlingResource dataHandlingResource = null;
             switch (type) {
@@ -1953,12 +1954,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while getting output data handling...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
 
-    public QualityOfServiceParams getQosParams(RegistryModelType type, String id) throws Exception {
+    public QualityOfServiceParams getQosParams(RegistryModelType type, String id) throws RegistryException {
         try {
             QosParamResource qosParamResource = null;
             switch (type) {
@@ -1972,23 +1973,23 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while getting qos params..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return null;
     }
 
-    public WorkflowNodeDetails getWorkflowNodeDetails(String nodeId) throws Exception {
+    public WorkflowNodeDetails getWorkflowNodeDetails(String nodeId) throws RegistryException {
         try {
             ExperimentResource resource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = resource.getWorkflowNode(nodeId);
             return ThriftDataModelConversion.getWorkflowNodeDetails(workflowNode);
         } catch (Exception e) {
             logger.error("Error while getting workflow node details...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public WorkflowNodeStatus getWorkflowNodeStatus(String nodeId) throws Exception {
+    public WorkflowNodeStatus getWorkflowNodeStatus(String nodeId) throws RegistryException {
         try {
             ExperimentResource resource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = resource.getWorkflowNode(nodeId);
@@ -1996,11 +1997,11 @@ public class ExperimentRegistry {
             return ThriftDataModelConversion.getWorkflowNodeStatus(workflowNodeStatus);
         } catch (Exception e) {
             logger.error("Error while getting workflow node status..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public List<DataObjectType> getNodeOutputs(String nodeId) throws Exception {
+    public List<DataObjectType> getNodeOutputs(String nodeId) throws RegistryException {
         try {
             ExperimentResource resource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = resource.getWorkflowNode(nodeId);
@@ -2008,11 +2009,11 @@ public class ExperimentRegistry {
             return ThriftDataModelConversion.getNodeOutputs(nodeOutputs);
         } catch (Exception e) {
             logger.error("Error while getting node outputs..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public TaskDetails getTaskDetails(String taskId) throws Exception {
+    public TaskDetails getTaskDetails(String taskId) throws RegistryException {
         try {
             ExperimentResource resource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) resource.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -2020,11 +2021,11 @@ public class ExperimentRegistry {
             return ThriftDataModelConversion.getTaskDetail(taskDetail);
         } catch (Exception e) {
             logger.error("Error while getting task details..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public List<DataObjectType> getApplicationOutputs(String taskId) throws Exception {
+    public List<DataObjectType> getApplicationOutputs(String taskId) throws RegistryException {
         try {
             ExperimentResource resource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) resource.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -2033,11 +2034,11 @@ public class ExperimentRegistry {
             return ThriftDataModelConversion.getApplicationOutputs(applicationOutputs);
         } catch (Exception e) {
             logger.error("Error while getting application outputs..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public TaskStatus getTaskStatus(String taskId) throws Exception {
+    public TaskStatus getTaskStatus(String taskId) throws RegistryException {
         try {
             ExperimentResource resource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) resource.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -2046,13 +2047,13 @@ public class ExperimentRegistry {
             return ThriftDataModelConversion.getTaskStatus(taskStatus);
         } catch (Exception e) {
             logger.error("Error while getting experiment outputs..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
 
     // ids contains task id + job id
-    public JobDetails getJobDetails(CompositeIdentifier ids) throws Exception {
+    public JobDetails getJobDetails(CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource resource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) resource.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -2061,12 +2062,12 @@ public class ExperimentRegistry {
             return ThriftDataModelConversion.getJobDetail(jobDetail);
         } catch (Exception e) {
             logger.error("Error while getting job details..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
     // ids contains task id + job id
-    public JobStatus getJobStatus(CompositeIdentifier ids) throws Exception {
+    public JobStatus getJobStatus(CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource resource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) resource.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -2076,11 +2077,11 @@ public class ExperimentRegistry {
             return ThriftDataModelConversion.getJobStatus(jobStatus);
         } catch (Exception e) {
             logger.error("Error while getting job status..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public ApplicationStatus getApplicationStatus(CompositeIdentifier ids) throws Exception {
+    public ApplicationStatus getApplicationStatus(CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource resource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) resource.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -2090,11 +2091,11 @@ public class ExperimentRegistry {
             return ThriftDataModelConversion.getApplicationStatus(applicationStatus);
         } catch (Exception e) {
             logger.error("Error while getting application status..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public DataTransferDetails getDataTransferDetails(String transferId) throws Exception {
+    public DataTransferDetails getDataTransferDetails(String transferId) throws RegistryException {
         try {
             ExperimentResource resource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) resource.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -2103,11 +2104,11 @@ public class ExperimentRegistry {
             return ThriftDataModelConversion.getDataTransferDetail(dataTransferDetail);
         } catch (Exception e) {
             logger.error("Error while getting data transfer details..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public TransferStatus getDataTransferStatus(String transferId) throws Exception {
+    public TransferStatus getDataTransferStatus(String transferId) throws RegistryException {
         try {
             ExperimentResource resource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) resource.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -2117,11 +2118,11 @@ public class ExperimentRegistry {
             return ThriftDataModelConversion.getTransferStatus(dataTransferStatus);
         } catch (Exception e) {
             logger.error("Error while getting data transfer status..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public List<String> getExperimentIDs(String fieldName, Object value) throws Exception {
+    public List<String> getExperimentIDs(String fieldName, Object value) throws RegistryException {
         List<String> expIDs = new ArrayList<String>();
         try {
             if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.GATEWAY)) {
@@ -2148,12 +2149,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while retrieving experiment ids..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return expIDs;
     }
 
-    public List<String> getWorkflowNodeIds(String fieldName, Object value) throws Exception {
+    public List<String> getWorkflowNodeIds(String fieldName, Object value) throws RegistryException {
         List<String> wfIds = new ArrayList<String>();
         List<WorkflowNodeDetails> wfNodeDetails = getWFNodeDetails(fieldName, value);
         for (WorkflowNodeDetails wf : wfNodeDetails) {
@@ -2162,7 +2163,7 @@ public class ExperimentRegistry {
         return wfIds;
     }
 
-    public List<String> getTaskDetailIds(String fieldName, Object value) throws Exception {
+    public List<String> getTaskDetailIds(String fieldName, Object value) throws RegistryException {
         List<String> taskDetailIds = new ArrayList<String>();
         List<TaskDetails> taskDetails = getTaskDetails(fieldName, value);
         for (TaskDetails td : taskDetails) {
@@ -2171,7 +2172,7 @@ public class ExperimentRegistry {
         return taskDetailIds;
     }
 
-    public List<String> getJobDetailIds(String fieldName, Object value) throws Exception {
+    public List<String> getJobDetailIds(String fieldName, Object value) throws RegistryException {
         List<String> jobIds = new ArrayList<String>();
         List<JobDetails> jobDetails = getJobDetails(fieldName, value);
         for (JobDetails jd : jobDetails) {
@@ -2180,7 +2181,7 @@ public class ExperimentRegistry {
         return jobIds;
     }
 
-    public List<String> getTransferDetailIds(String fieldName, Object value) throws Exception {
+    public List<String> getTransferDetailIds(String fieldName, Object value) throws RegistryException {
         List<String> transferIds = new ArrayList<String>();
         List<DataTransferDetails> dataTransferDetails = getDataTransferDetails(fieldName, value);
         for (DataTransferDetails dtd : dataTransferDetails) {
@@ -2190,47 +2191,47 @@ public class ExperimentRegistry {
     }
 
 
-    public void removeExperiment(String experimentId) throws Exception {
+    public void removeExperiment(String experimentId) throws RegistryException {
         try {
             gatewayResource.remove(ResourceType.EXPERIMENT, experimentId);
         } catch (Exception e) {
             logger.error("Error while removing experiment..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void removeExperimentConfigData(String experimentId) throws Exception {
+    public void removeExperimentConfigData(String experimentId) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment(experimentId);
             experiment.remove(ResourceType.CONFIG_DATA, experimentId);
         } catch (Exception e) {
             logger.error("Error while removing experiment config..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void removeWorkflowNode(String nodeId) throws Exception {
+    public void removeWorkflowNode(String nodeId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             experiment.remove(ResourceType.WORKFLOW_NODE_DETAIL, nodeId);
         } catch (Exception e) {
             logger.error("Error while removing workflow node..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void removeTaskDetails(String taskId) throws Exception {
+    public void removeTaskDetails(String taskId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
             nodeDetailResource.remove(ResourceType.TASK_DETAIL, taskId);
         } catch (Exception e) {
             logger.error("Error while removing task details..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void removeJobDetails(CompositeIdentifier ids) throws Exception {
+    public void removeJobDetails(CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -2238,11 +2239,11 @@ public class ExperimentRegistry {
             taskDetailResource.remove(ResourceType.JOB_DETAIL, (String) ids.getSecondLevelIdentifier());
         } catch (Exception e) {
             logger.error("Error while removing job details..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void removeDataTransferDetails(String transferId) throws Exception {
+    public void removeDataTransferDetails(String transferId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -2250,11 +2251,11 @@ public class ExperimentRegistry {
             taskDetail.remove(ResourceType.DATA_TRANSFER_DETAIL, transferId);
         } catch (Exception e) {
             logger.error("Error while removing transfer details..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void removeComputationalScheduling(RegistryModelType dataType, String id) throws Exception {
+    public void removeComputationalScheduling(RegistryModelType dataType, String id) throws RegistryException {
         try {
             switch (dataType) {
                 case EXPERIMENT:
@@ -2272,11 +2273,11 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while removing scheduling data..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void removeInputDataHandling(RegistryModelType dataType, String id) throws Exception {
+    public void removeInputDataHandling(RegistryModelType dataType, String id) throws RegistryException {
         try {
             switch (dataType) {
                 case EXPERIMENT:
@@ -2294,11 +2295,11 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while removing input data handling..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void removeOutputDataHandling(RegistryModelType dataType, String id) throws Exception {
+    public void removeOutputDataHandling(RegistryModelType dataType, String id) throws RegistryException {
         try {
             switch (dataType) {
                 case EXPERIMENT:
@@ -2316,11 +2317,11 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while removing output data handling..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void removeQOSParams(RegistryModelType dataType, String id) throws Exception {
+    public void removeQOSParams(RegistryModelType dataType, String id) throws RegistryException {
         try {
             switch (dataType) {
                 case EXPERIMENT:
@@ -2332,52 +2333,52 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while removing QOS params", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public boolean isExperimentExist(String expID) throws Exception {
+    public boolean isExperimentExist(String expID) throws RegistryException {
         try {
             return gatewayResource.isExists(ResourceType.EXPERIMENT, expID);
         } catch (Exception e) {
             logger.error("Error while retrieving experiment...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public boolean isExperimentConfigDataExist(String expID) throws Exception {
+    public boolean isExperimentConfigDataExist(String expID) throws RegistryException {
         try {
             ExperimentResource experiment = gatewayResource.getExperiment(expID);
             experiment.isExists(ResourceType.CONFIG_DATA, expID);
             return true;
         } catch (Exception e) {
             logger.error("Error while retrieving experiment...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public boolean isWFNodeExist(String nodeId) throws Exception {
+    public boolean isWFNodeExist(String nodeId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             return experiment.isExists(ResourceType.WORKFLOW_NODE_DETAIL, nodeId);
         } catch (Exception e) {
             logger.error("Error while retrieving workflow...", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public boolean isTaskDetailExist(String taskId) throws Exception {
+    public boolean isTaskDetailExist(String taskId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource wf = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
             return wf.isExists(ResourceType.TASK_DETAIL, taskId);
         } catch (Exception e) {
             logger.error("Error while retrieving task.....", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public boolean isJobDetailExist(CompositeIdentifier ids) throws Exception {
+    public boolean isJobDetailExist(CompositeIdentifier ids) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource wf = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -2385,11 +2386,11 @@ public class ExperimentRegistry {
             return taskDetail.isExists(ResourceType.JOB_DETAIL, (String) ids.getSecondLevelIdentifier());
         } catch (Exception e) {
             logger.error("Error while retrieving job details.....", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public boolean isTransferDetailExist(String transferId) throws Exception {
+    public boolean isTransferDetailExist(String transferId) throws RegistryException {
         try {
             ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
             WorkflowNodeDetailResource wf = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
@@ -2397,11 +2398,11 @@ public class ExperimentRegistry {
             return taskDetail.isExists(ResourceType.DATA_TRANSFER_DETAIL, transferId);
         } catch (Exception e) {
             logger.error("Error while retrieving transfer details.....", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public boolean isComputationalSchedulingExist(RegistryModelType dataType, String id) throws Exception {
+    public boolean isComputationalSchedulingExist(RegistryModelType dataType, String id) throws RegistryException {
         try {
             switch (dataType) {
                 case EXPERIMENT:
@@ -2418,12 +2419,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while retrieving scheduling data.....", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return false;
     }
 
-    public boolean isInputDataHandlingExist(RegistryModelType dataType, String id) throws Exception {
+    public boolean isInputDataHandlingExist(RegistryModelType dataType, String id) throws RegistryException {
         try {
             switch (dataType) {
                 case EXPERIMENT:
@@ -2439,12 +2440,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while retrieving input data handling.....", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return false;
     }
 
-    public boolean isOutputDataHandlingExist(RegistryModelType dataType, String id) throws Exception {
+    public boolean isOutputDataHandlingExist(RegistryModelType dataType, String id) throws RegistryException {
         try {
             switch (dataType) {
                 case EXPERIMENT:
@@ -2460,12 +2461,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while retrieving output data handling..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return false;
     }
 
-    public boolean isQOSParamsExist(RegistryModelType dataType, String id) throws Exception {
+    public boolean isQOSParamsExist(RegistryModelType dataType, String id) throws RegistryException {
         try {
             switch (dataType) {
                 case EXPERIMENT:
@@ -2481,12 +2482,12 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while retrieving qos params..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
         return false;
     }
 
-    public void updateScheduling(ComputationalResourceScheduling scheduling, String id, String type) throws Exception {
+    public void updateScheduling(ComputationalResourceScheduling scheduling, String id, String type) throws RegistryException {
         try {
             if (type.equals(RegistryModelType.EXPERIMENT.toString())) {
                 ExperimentResource experiment = gatewayResource.getExperiment(id);
@@ -2499,11 +2500,11 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating scheduling..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void updateInputDataHandling(AdvancedInputDataHandling dataHandling, String id, String type) throws Exception {
+    public void updateInputDataHandling(AdvancedInputDataHandling dataHandling, String id, String type) throws RegistryException {
         try {
             if (type.equals(RegistryModelType.EXPERIMENT.toString())) {
                 ExperimentResource experiment = gatewayResource.getExperiment(id);
@@ -2516,11 +2517,11 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating input data handling..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void updateOutputDataHandling(AdvancedOutputDataHandling dataHandling, String id, String type) throws Exception {
+    public void updateOutputDataHandling(AdvancedOutputDataHandling dataHandling, String id, String type) throws RegistryException {
         try {
             if (type.equals(RegistryModelType.EXPERIMENT.toString())) {
                 ExperimentResource experiment = gatewayResource.getExperiment(id);
@@ -2533,11 +2534,11 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating output data handling", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public void updateQOSParams(QualityOfServiceParams params, String id, String type) throws Exception {
+    public void updateQOSParams(QualityOfServiceParams params, String id, String type) throws RegistryException {
         try {
             if (type.equals(RegistryModelType.EXPERIMENT.toString())) {
                 ExperimentResource experiment = gatewayResource.getExperiment(id);
@@ -2550,11 +2551,11 @@ public class ExperimentRegistry {
             }
         } catch (Exception e) {
             logger.error("Error while updating QOS data..", e);
-            throw new Exception(e);
+            throw new RegistryException(e);
         }
     }
 
-    public List<ExperimentSummary> searchExperiments (Map<String, String> filters) throws Exception{
+    public List<ExperimentSummary> searchExperiments (Map<String, String> filters) throws RegistryException{
         Map<String, String> fil = new HashMap<String, String>();
         if (filters != null && filters.size() != 0){
             List<ExperimentSummary> experimentSummaries = new ArrayList<ExperimentSummary>();
@@ -2580,7 +2581,7 @@ public class ExperimentRegistry {
 
             }catch (Exception e){
                 logger.error("Error while retrieving experiment summary from registry", e);
-                throw new Exception(e);
+                throw new RegistryException(e);
             }
         }
         return null;

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/GatewayRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/GatewayRegistry.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/GatewayRegistry.java
index db6b139..f39bd46 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/GatewayRegistry.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/GatewayRegistry.java
@@ -25,13 +25,14 @@ import org.apache.airavata.common.exception.ApplicationSettingsException;
 import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.resources.GatewayResource;
+import org.apache.airavata.registry.cpi.RegistryException;
 
 public class GatewayRegistry {
-    public GatewayResource getDefaultGateway () throws ApplicationSettingsException {
+    public GatewayResource getDefaultGateway () throws ApplicationSettingsException, RegistryException {
         return (GatewayResource)ResourceUtils.getGateway(ServerSettings.getSystemUserGateway());
     }
 
-    public GatewayResource getExistingGateway (String gatewayName) {
+    public GatewayResource getExistingGateway (String gatewayName) throws RegistryException {
         return (GatewayResource)ResourceUtils.getGateway(gatewayName);
     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ProjectRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ProjectRegistry.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ProjectRegistry.java
index f288b85..4de4ba3 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ProjectRegistry.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ProjectRegistry.java
@@ -29,6 +29,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.resources.*;
 import org.apache.airavata.persistance.registry.jpa.utils.ThriftDataModelConversion;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.apache.airavata.registry.cpi.utils.Constants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -38,7 +39,7 @@ public class ProjectRegistry {
     private WorkerResource workerResource;
     private final static Logger logger = LoggerFactory.getLogger(ProjectRegistry.class);
 
-    public ProjectRegistry(GatewayResource gatewayResource, UserResource user) {
+    public ProjectRegistry(GatewayResource gatewayResource, UserResource user) throws RegistryException {
         if (!ResourceUtils.isGatewayExist(gatewayResource.getGatewayName())){
             this.gatewayResource = gatewayResource;
         }else {
@@ -51,7 +52,7 @@ public class ProjectRegistry {
         }
     }
 
-    public String addProject (Project project) throws Exception{
+    public String addProject (Project project) throws RegistryException{
         String projectId;
         try {
             if (!ResourceUtils.isUserExist(project.getOwner())){
@@ -90,7 +91,7 @@ public class ProjectRegistry {
             }
         }catch (Exception e){
             logger.error("Error while saving project to registry", e);
-            throw new Exception(e);
+           throw new RegistryException(e);
         }
         return projectId;
     }
@@ -100,7 +101,7 @@ public class ProjectRegistry {
         return pro + "_" + UUID.randomUUID();
     }
 
-    public void updateProject (Project project, String projectId) throws Exception{
+    public void updateProject (Project project, String projectId) throws RegistryException{
         try {
             ProjectResource existingProject = workerResource.getProject(projectId);
             existingProject.setDescription(project.getDescription());
@@ -137,11 +138,11 @@ public class ProjectRegistry {
             }
         }catch (Exception e){
             logger.error("Error while saving project to registry", e);
-            throw new Exception(e);
+           throw new RegistryException(e);
         }
     }
 
-    public Project getProject (String projectId) throws Exception{
+    public Project getProject (String projectId) throws RegistryException{
         try {
             ProjectResource project = workerResource.getProject(projectId);
             if (project != null){
@@ -149,12 +150,12 @@ public class ProjectRegistry {
             }
         }catch (Exception e){
             logger.error("Error while retrieving project from registry", e);
-            throw new Exception(e);
+           throw new RegistryException(e);
         }
         return null;
     }
 
-    public List<Project> getProjectList (String fieldName, Object value) throws Exception{
+    public List<Project> getProjectList (String fieldName, Object value) throws RegistryException{
         List<Project> projects = new ArrayList<Project>();
         try {
             if (fieldName.equals(Constants.FieldConstants.ProjectConstants.OWNER)){
@@ -169,12 +170,12 @@ public class ProjectRegistry {
             }
         }catch (Exception e){
             logger.error("Error while retrieving project from registry", e);
-            throw new Exception(e);
+           throw new RegistryException(e);
         }
         return projects;
     }
 
-    public List<Project> searchProjects (Map<String, String> filters) throws Exception{
+    public List<Project> searchProjects (Map<String, String> filters) throws RegistryException{
         Map<String, String> fil = new HashMap<String, String>();
         if (filters != null && filters.size() != 0){
             List<Project> projects = new ArrayList<Project>();
@@ -197,13 +198,13 @@ public class ProjectRegistry {
                 return projects;
             }catch (Exception e){
                 logger.error("Error while retrieving project from registry", e);
-                throw new Exception(e);
+               throw new RegistryException(e);
             }
         }
         return null;
     }
 
-    public List<String> getProjectIDs (String fieldName, Object value) throws Exception{
+    public List<String> getProjectIDs (String fieldName, Object value) throws RegistryException{
         List<String> projectIds = new ArrayList<String>();
         try {
             if (fieldName.equals(Constants.FieldConstants.ProjectConstants.OWNER)){
@@ -218,26 +219,26 @@ public class ProjectRegistry {
             }
         }catch (Exception e){
             logger.error("Error while retrieving projects from registry", e);
-            throw new Exception(e);
+           throw new RegistryException(e);
         }
         return projectIds;
     }
 
-    public void removeProject (String projectId) throws Exception {
+    public void removeProject (String projectId) throws RegistryException {
         try {
             workerResource.removeProject(projectId);
         } catch (Exception e) {
             logger.error("Error while removing the project..", e);
-            throw new Exception(e);
+           throw new RegistryException(e);
         }
     }
 
-    public boolean isProjectExist(String projectId) throws Exception {
+    public boolean isProjectExist(String projectId) throws RegistryException {
         try {
             return workerResource.isProjectExists(projectId);
         } catch (Exception e) {
             logger.error("Error while retrieving project...", e);
-            throw new Exception(e);
+           throw new RegistryException(e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryFactory.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryFactory.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryFactory.java
index 3d21e95..91d2bc4 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryFactory.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryFactory.java
@@ -22,20 +22,34 @@
 package org.apache.airavata.persistance.registry.jpa.impl;
 
 import org.apache.airavata.registry.cpi.Registry;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class RegistryFactory {
     private static Registry registry;
+    private static Logger logger = LoggerFactory.getLogger(RegistryFactory.class);
 
-    public static Registry getRegistry(String gateway, String username, String password){
-        if (registry == null){
-            registry = new RegistryImpl(gateway, username, password);
+    public static Registry getRegistry(String gateway, String username, String password) throws RegistryException {
+        try {
+            if (registry == null) {
+                registry = new RegistryImpl(gateway, username, password);
+            }
+        } catch (RegistryException e) {
+            logger.error("Unable to create registry instance", e);
+            throw new RegistryException(e);
         }
         return registry;
     }
 
-    public static Registry getDefaultRegistry () {
-        if (registry == null){
-            registry = new RegistryImpl();
+    public static Registry getDefaultRegistry () throws RegistryException {
+        try {
+            if (registry == null) {
+                registry = new RegistryImpl();
+            }
+        } catch (RegistryException e) {
+            logger.error("Unable to create registry instance", e);
+            throw new RegistryException(e);
         }
         return registry;
     }


[10/11] adding proper entity manager closing and exception handling - AIRAVATA-1285

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
index 086d996..db049ea 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
@@ -51,6 +51,7 @@ import org.apache.airavata.registry.api.util.RegistrySettings;
 import org.apache.airavata.registry.api.workflow.*;
 import org.apache.airavata.registry.api.workflow.ApplicationJob.ApplicationJobStatus;
 import org.apache.airavata.registry.api.workflow.WorkflowExecutionStatus.State;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.apache.xmlbeans.XmlException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -94,7 +95,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
     private SSHCredentialGenerator credentialGenerator;
     
     @Override
-    protected void initialize() throws RegistryException {
+    protected void initialize() throws RegException {
     	jpa = new JPAResourceAccessor(this);
     	//TODO check if the db connections are proper & accessible & the relevant db/tables are
     	//present
@@ -126,19 +127,23 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 						e1.printStackTrace();
 					}
 				}else{
-					throw new AiravataRegistryUninitializedException("Airavata Registry has not yet initialized properly!!!", e);
+					throw new AiravataRegUninitializedException("Airavata Registry has not yet initialized properly!!!", e);
 				}
 			}
         }
         String[] list = compatibleVersionMap.get(apiVersion);
         if (list == null || (!Arrays.asList(list).contains(registryVersion))){
-            throw new RegistryAPIVersionIncompatibleException("Incompatible registry versions. Please check whether you updated the API and Registry " +
+            throw new RegAPIVersionIncompatibleException("Incompatible registry versions. Please check whether you updated the API and Registry " +
                     "versions.");
         }
-        if (!ResourceUtils.isGatewayExist(getGateway().getGatewayName())){
-    		throw new GatewayNotRegisteredException(getGateway().getGatewayName());
-    	}
-        
+        try {
+            if (!ResourceUtils.isGatewayExist(getGateway().getGatewayName())){
+                throw new GatewayNotRegisteredException(getGateway().getGatewayName());
+            }
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+
     }
 
     static {
@@ -154,9 +159,9 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 
     /**
      * Initialize the custom registries defined in the registry settings
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	private void initializeCustomRegistries() throws RegistryException {
+	private void initializeCustomRegistries() throws RegException {
 		// retrieving user defined registry classes from registry settings
         try {
             configurationRegistry = (ConfigurationRegistry)getClassInstance(ConfigurationRegistry.class,RegistryConstants.CONFIGURATION_REGISTRY_ACCESSOR_CLASS);
@@ -167,7 +172,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
             publishedWorkflowRegistry = (PublishedWorkflowRegistry)getClassInstance(ConfigurationRegistry.class,RegistryConstants.PUBLISHED_WF_REGISTRY_ACCESSOR_CLASS);
             userRegistry = (UserRegistry)getClassInstance(ConfigurationRegistry.class,RegistryConstants.USER_REGISTRY_ACCESSOR_CLASS);
         } catch (AiravataConfigurationException e) {
-            throw new RegistryException("An error occured when attempting to determine any custom implementations of the registries!!!", e);
+            throw new RegException("An error occured when attempting to determine any custom implementations of the registries!!!", e);
         }
 	}
 
@@ -178,12 +183,12 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 			return registryClass;
 		} catch (ClassCastException e){
 			logger.error("The class defined for accessor type "+registryAccessorKey+" MUST be an extention of the interface "+c.getName(),e);
-		} catch (RegistryAccessorNotFoundException e) {
+		} catch (RegAccessorNotFoundException e) {
 			logger.error("Error in loading class for registry accessor "+registryAccessorKey,e);
-		} catch (RegistryAccessorUndefinedException e) {
+		} catch (RegAccessorUndefinedException e) {
 			// happens when user has not defined an accessor for the registry accessor key
 			// thus ignore error
-		} catch (RegistryAccessorInstantiateException e) {
+		} catch (RegAccessorInstantiateException e) {
 			logger.error("Error in instantiating instance from class for registry accessor "+registryAccessorKey,e);
 		}
 		return null;
@@ -196,12 +201,12 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 
     /**---------------------------------Configuration Registry----------------------------------**/
 
-    public Object getConfiguration(String key) throws RegistryException{
+    public Object getConfiguration(String key) throws RegException {
 		ConfigurationResource configuration = ResourceUtils.getConfiguration(key);
 		return configuration==null? null: configuration.getConfigVal();
     }
     // Not sure about this.. need some description
-    public List<Object> getConfigurationList(String key) throws RegistryException{
+    public List<Object> getConfigurationList(String key) throws RegException {
         if (configurationRegistry != null){
             return configurationRegistry.getConfigurationList(key);
         } else {
@@ -215,49 +220,65 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 
     }
 
-    public void setConfiguration(String key, String value, Date expire) throws RegistryException{
-        if (configurationRegistry != null){
+    public void setConfiguration(String key, String value, Date expire) throws RegException {
+        if (configurationRegistry != null) {
             configurationRegistry.setConfiguration(key, value, expire);
-        }else {
-            ConfigurationResource config;
-            if (ResourceUtils.isConfigurationExist(key)) {
-                config = ResourceUtils.getConfiguration(key);
-            }else{
-                config = ResourceUtils.createConfiguration(key);
+        } else {
+            try {
+                ConfigurationResource config;
+                if (ResourceUtils.isConfigurationExist(key)) {
+                    config = ResourceUtils.getConfiguration(key);
+                } else {
+                    config = ResourceUtils.createConfiguration(key);
+                }
+                config.setConfigVal(value);
+                config.setExpireDate(new Timestamp(expire.getTime()));
+                config.save();
+            } catch (RegistryException e) {
+                e.printStackTrace();
             }
-            config.setConfigVal(value);
-            config.setExpireDate(new Timestamp(expire.getTime()));
-            config.save();
         }
     }
 
-    public void addConfiguration(String key, String value, Date expire) throws RegistryException{
-        if (configurationRegistry != null){
+    public void addConfiguration(String key, String value, Date expire) throws RegException {
+        if (configurationRegistry != null) {
             configurationRegistry.addConfiguration(key, value, expire);
         } else {
-            ConfigurationResource config = ResourceUtils.createConfiguration(key);
-            config.setConfigVal(value);
-            config.setExpireDate(new Timestamp(expire.getTime()));
-            config.save();
+            try {
+                ConfigurationResource config = ResourceUtils.createConfiguration(key);
+                config.setConfigVal(value);
+                config.setExpireDate(new Timestamp(expire.getTime()));
+                config.save();
+            } catch (RegistryException e) {
+                e.printStackTrace();
+            }
         }
 
 
     }
 
-    public void removeAllConfiguration(String key) throws RegistryException{
+    public void removeAllConfiguration(String key) throws RegException {
         if (configurationRegistry  != null){
             configurationRegistry.removeAllConfiguration(key);
         } else {
-            ResourceUtils.removeConfiguration(key);
+            try {
+                ResourceUtils.removeConfiguration(key);
+            } catch (RegistryException e) {
+                e.printStackTrace();
+            }
         }
 
     }
 
-    public void removeConfiguration(String key, String value) throws RegistryException{
+    public void removeConfiguration(String key, String value) throws RegException {
         if (configurationRegistry != null){
             configurationRegistry.removeConfiguration(key, value);
         } else {
-            ResourceUtils.removeConfiguration(key, value);
+            try {
+                ResourceUtils.removeConfiguration(key, value);
+            } catch (RegistryException e) {
+                e.printStackTrace();
+            }
         }
     }
 
@@ -266,7 +287,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
     private static final String MESSAGE_BOX_URL="messagebox.url";
     private static final String EVENTING_URL="eventing.url";
 
-    public List<URI> getGFacURIs() throws RegistryException{
+    public List<URI> getGFacURIs() throws RegException {
         if (configurationRegistry != null) {
             return configurationRegistry.getGFacURIs();
         } else {
@@ -274,7 +295,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-	private List<URI> retrieveURIsFromConfiguration(String urlType) throws RegistryException{
+	private List<URI> retrieveURIsFromConfiguration(String urlType) throws RegException {
 		List<URI> urls=new ArrayList<URI>();
     	List<Object> configurationList = getConfigurationList(urlType);
     	for (Object o : configurationList) {
@@ -287,7 +308,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         return urls;
 	}
 
-    public List<URI> getWorkflowInterpreterURIs() throws RegistryException{
+    public List<URI> getWorkflowInterpreterURIs() throws RegException {
         if (configurationRegistry != null) {
             return configurationRegistry.getWorkflowInterpreterURIs();
         }  else {
@@ -295,7 +316,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public URI getEventingServiceURI() throws RegistryException{
+    public URI getEventingServiceURI() throws RegException {
         if (configurationRegistry != null) {
            return configurationRegistry.getEventingServiceURI();
         }else {
@@ -304,7 +325,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public URI getMessageBoxURI() throws RegistryException{
+    public URI getMessageBoxURI() throws RegException {
         if (configurationRegistry != null) {
             return configurationRegistry.getMessageBoxURI();
         }
@@ -312,7 +333,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 		return messageboxURLs.size()==0? null: messageboxURLs.get(0);
     }
 
-    public void addGFacURI(URI uri) throws RegistryException{
+    public void addGFacURI(URI uri) throws RegException {
         if (configurationRegistry != null) {
             addGFacURI(uri);
         } else {
@@ -320,18 +341,18 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-	private void addConfigurationURL(String urlType,URI uri) throws RegistryException{
+	private void addConfigurationURL(String urlType,URI uri) throws RegException {
 		Calendar instance = Calendar.getInstance();
         instance.add(Calendar.MINUTE, AiravataRegistry2.SERVICE_TTL);
 		Date expire = instance.getTime();
 		addConfigurationURL(urlType, uri, expire);
 	}
 
-	private void addConfigurationURL(String urlType, URI uri, Date expire) throws RegistryException{
+	private void addConfigurationURL(String urlType, URI uri, Date expire) throws RegException {
 		addConfiguration(urlType, uri.toString(), expire);
 	}
 
-    public void addWorkflowInterpreterURI(URI uri) throws RegistryException{
+    public void addWorkflowInterpreterURI(URI uri) throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.addWorkflowInterpreterURI(uri);
         }else {
@@ -339,7 +360,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void setEventingURI(URI uri) throws RegistryException{
+    public void setEventingURI(URI uri) throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.setEventingURI(uri);
         } else {
@@ -347,7 +368,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void setMessageBoxURI(URI uri) throws RegistryException{
+    public void setMessageBoxURI(URI uri) throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.setMessageBoxURI(uri);
         } else {
@@ -355,7 +376,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void addGFacURI(URI uri, Date expire) throws RegistryException{
+    public void addGFacURI(URI uri, Date expire) throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.addGFacURI(uri, expire);
         } else {
@@ -363,7 +384,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void addWorkflowInterpreterURI(URI uri, Date expire) throws RegistryException{
+    public void addWorkflowInterpreterURI(URI uri, Date expire) throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.addWorkflowInterpreterURI(uri, expire);
         } else {
@@ -371,7 +392,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void setEventingURI(URI uri, Date expire) throws RegistryException{
+    public void setEventingURI(URI uri, Date expire) throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.setEventingURI(uri, expire);
         } else {
@@ -379,7 +400,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void setMessageBoxURI(URI uri, Date expire) throws RegistryException{
+    public void setMessageBoxURI(URI uri, Date expire) throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.setMessageBoxURI(uri, expire);
         } else {
@@ -387,7 +408,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void removeGFacURI(URI uri) throws RegistryException{
+    public void removeGFacURI(URI uri) throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.removeGFacURI(uri);
         } else {
@@ -395,7 +416,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void removeWorkflowInterpreterURI(URI uri) throws RegistryException{
+    public void removeWorkflowInterpreterURI(URI uri) throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.removeWorkflowInterpreterURI(uri);
         } else {
@@ -403,7 +424,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void removeAllGFacURI() throws RegistryException{
+    public void removeAllGFacURI() throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.removeAllGFacURI();
         } else {
@@ -411,7 +432,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void removeAllWorkflowInterpreterURI() throws RegistryException{
+    public void removeAllWorkflowInterpreterURI() throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.removeAllWorkflowInterpreterURI();
         } else {
@@ -419,7 +440,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void unsetEventingURI() throws RegistryException{
+    public void unsetEventingURI() throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.unsetEventingURI();
         } else {
@@ -428,7 +449,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 
     }
 
-    public void unsetMessageBoxURI() throws RegistryException{
+    public void unsetMessageBoxURI() throws RegException {
         if (configurationRegistry != null) {
             configurationRegistry.unsetMessageBoxURI();
         } else {
@@ -439,55 +460,74 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 
     /**---------------------------------Descriptor Registry----------------------------------**/
 
-    public boolean isHostDescriptorExists(String descriptorName)throws RegistryException{
+    public boolean isHostDescriptorExists(String descriptorName)throws RegException {
         if (descriptorRegistry != null){
             return descriptorRegistry.isHostDescriptorExists(descriptorName);
         }
-    	return jpa.getGateway().isHostDescriptorExists(descriptorName);
+        try {
+            return jpa.getGateway().isHostDescriptorExists(descriptorName);
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+        return false;
     }
-    public void addHostDescriptor(HostDescription descriptor) throws RegistryException {
-        if (descriptorRegistry != null){
+    public void addHostDescriptor(HostDescription descriptor) throws RegException {
+        if (descriptorRegistry != null) {
             descriptorRegistry.addHostDescriptor(descriptor);
         } else {
-            GatewayResource gateway = jpa.getGateway();
-            WorkerResource workerResource = jpa.getWorker();
-            String hostName = descriptor.getType().getHostName();
-            if (isHostDescriptorExists(hostName)){
-                throw new DescriptorAlreadyExistsException(hostName);
+            try {
+                GatewayResource gateway = jpa.getGateway();
+                WorkerResource workerResource = jpa.getWorker();
+                String hostName = descriptor.getType().getHostName();
+                if (isHostDescriptorExists(hostName)) {
+                    throw new DescriptorAlreadyExistsException(hostName);
+                }
+                HostDescriptorResource hostDescriptorResource = gateway.createHostDescriptorResource(hostName);
+                hostDescriptorResource.setUserName(workerResource.getUser());
+                hostDescriptorResource.setContent(descriptor.toXML());
+                hostDescriptorResource.save();
+            } catch (RegistryException e) {
+                e.printStackTrace();
             }
-            HostDescriptorResource hostDescriptorResource = gateway.createHostDescriptorResource(hostName);
-            hostDescriptorResource.setUserName(workerResource.getUser());
-            hostDescriptorResource.setContent(descriptor.toXML());
-            hostDescriptorResource.save();
         }
     }
 
-    public void updateHostDescriptor(HostDescription descriptor) throws RegistryException {
-        if (descriptorRegistry != null){
+    public void updateHostDescriptor(HostDescription descriptor) throws RegException {
+        if (descriptorRegistry != null) {
             descriptorRegistry.updateHostDescriptor(descriptor);
         } else {
-            GatewayResource gateway = jpa.getGateway();
-            String hostName = descriptor.getType().getHostName();
-            if (!isHostDescriptorExists(hostName)){
-                throw new DescriptorDoesNotExistsException(hostName);
+            try {
+                GatewayResource gateway = jpa.getGateway();
+                String hostName = descriptor.getType().getHostName();
+                if (!isHostDescriptorExists(hostName)) {
+                    throw new DescriptorDoesNotExistsException(hostName);
+                }
+                HostDescriptorResource hostDescriptorResource = gateway.getHostDescriptorResource(hostName);
+                hostDescriptorResource.setContent(descriptor.toXML());
+                hostDescriptorResource.save();
+            } catch (RegistryException e) {
+                e.printStackTrace();
             }
-            HostDescriptorResource hostDescriptorResource = gateway.getHostDescriptorResource(hostName);
-            hostDescriptorResource.setContent(descriptor.toXML());
-            hostDescriptorResource.save();
         }
     }
 
-    public HostDescription getHostDescriptor(String hostName) throws RegistryException {
-        if (descriptorRegistry != null){
+    public HostDescription getHostDescriptor(String hostName) throws RegException {
+        if (descriptorRegistry != null) {
             return descriptorRegistry.getHostDescriptor(hostName);
         } else {
-            GatewayResource gateway = jpa.getGateway();
-            if (!isHostDescriptorExists(hostName)){
-                return null;
+            try {
+
+                GatewayResource gateway = jpa.getGateway();
+                if (!isHostDescriptorExists(hostName)) {
+                    return null;
+                }
+                HostDescriptorResource hostDescriptorResource = gateway.getHostDescriptorResource(hostName);
+                return createHostDescriptor(hostDescriptorResource);
+            } catch (RegistryException e) {
+                e.printStackTrace();
             }
-            HostDescriptorResource hostDescriptorResource = gateway.getHostDescriptorResource(hostName);
-            return createHostDescriptor(hostDescriptorResource);
         }
+        return null;
     }
 
 	private HostDescription createHostDescriptor(
@@ -500,61 +540,72 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
 	}
 
-    public void removeHostDescriptor(String hostName) throws RegistryException {
-        if (descriptorRegistry != null){
+    public void removeHostDescriptor(String hostName) throws RegException {
+        if (descriptorRegistry != null) {
             descriptorRegistry.removeHostDescriptor(hostName);
         } else {
-            GatewayResource gateway = jpa.getGateway();
-            if (!isHostDescriptorExists(hostName)){
-                throw new DescriptorDoesNotExistsException(hostName);
-            }
-            gateway.removeHostDescriptor(hostName);
             try {
+                GatewayResource gateway = jpa.getGateway();
+                if (!isHostDescriptorExists(hostName)) {
+                    throw new DescriptorDoesNotExistsException(hostName);
+                }
+                gateway.removeHostDescriptor(hostName);
                 //we need to delete the application descriptors bound to this host
-				Map<String, ApplicationDescription> applicationDescriptors = getApplicationDescriptorsFromHostName(hostName);
-				for (String serviceName : applicationDescriptors.keySet()) {
-					removeApplicationDescriptor(serviceName, hostName, applicationDescriptors.get(serviceName).getType().getApplicationName().getStringValue());
-				}
-			} catch (Exception e) {
-				logger.error("Error while removing application descriptors bound to host "+hostName, e);
-			}
+                Map<String, ApplicationDescription> applicationDescriptors = getApplicationDescriptorsFromHostName(hostName);
+                for (String serviceName : applicationDescriptors.keySet()) {
+                    removeApplicationDescriptor(serviceName, hostName, applicationDescriptors.get(serviceName).getType().getApplicationName().getStringValue());
+                }
+            } catch (RegistryException e) {
+                logger.error("Error while removing application descriptors bound to host " + hostName, e);
+            }
         }
     }
 
 	@Override
 	public List<HostDescription> getHostDescriptors()
-			throws MalformedDescriptorException, RegistryException {
-        if (descriptorRegistry != null){
+			throws MalformedDescriptorException, RegException {
+        if (descriptorRegistry != null) {
             return descriptorRegistry.getHostDescriptors();
         }
-		GatewayResource gateway = jpa.getGateway();
-		List<HostDescription> list=new ArrayList<HostDescription>();
-		List<HostDescriptorResource> hostDescriptorResources = gateway.getHostDescriptorResources();
-		for (HostDescriptorResource resource : hostDescriptorResources) {
-			list.add(createHostDescriptor(resource));
-		}
-		return list;
-	}
+        try {
+            GatewayResource gateway = jpa.getGateway();
+            List<HostDescription> list = new ArrayList<HostDescription>();
+            List<HostDescriptorResource> hostDescriptorResources = gateway.getHostDescriptorResources();
+            for (HostDescriptorResource resource : hostDescriptorResources) {
+                list.add(createHostDescriptor(resource));
+            }
+            return list;
+        } catch (RegistryException e) {
+            logger.error("Error while getting host descriptors ", e);
+        }
+        return null;
+    }
 
-    public ResourceMetadata getHostDescriptorMetadata(String hostName) throws RegistryException {
+    public ResourceMetadata getHostDescriptorMetadata(String hostName) throws RegException {
     	if (descriptorRegistry != null) {
             return descriptorRegistry.getHostDescriptorMetadata(hostName);
         }
     	//TODO
-        throw new UnimplementedRegistryOperationException();
+        throw new UnimplementedRegOperationException();
     }
 
-    public boolean isServiceDescriptorExists(String descriptorName)throws RegistryException{
+    public boolean isServiceDescriptorExists(String descriptorName)throws RegException {
         if (descriptorRegistry != null) {
             return descriptorRegistry.isServiceDescriptorExists(descriptorName);
         }
-    	return jpa.getGateway().isServiceDescriptorExists(descriptorName);
+        try {
+            return jpa.getGateway().isServiceDescriptorExists(descriptorName);
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+        return false;
     }
 
-    public void addServiceDescriptor(ServiceDescription descriptor) throws RegistryException {
+    public void addServiceDescriptor(ServiceDescription descriptor) throws RegException {
         if (descriptorRegistry != null) {
             descriptorRegistry.addServiceDescriptor(descriptor);
         }else {
+            try {
             GatewayResource gateway = jpa.getGateway();
             WorkerResource workerResource = jpa.getWorker();
             String serviceName = descriptor.getType().getName();
@@ -565,13 +616,17 @@ public class AiravataJPARegistry extends AiravataRegistry2{
             serviceDescriptorResource.setUserName(workerResource.getUser());
             serviceDescriptorResource.setContent(descriptor.toXML());
             serviceDescriptorResource.save();
+            } catch (RegistryException e) {
+                e.printStackTrace();
+            }
         }
     }
 
-    public void updateServiceDescriptor(ServiceDescription descriptor) throws RegistryException {
+    public void updateServiceDescriptor(ServiceDescription descriptor) throws RegException {
         if (descriptorRegistry != null) {
             descriptorRegistry.updateServiceDescriptor(descriptor);
         }else {
+            try {
             GatewayResource gateway = jpa.getGateway();
             String serviceName = descriptor.getType().getName();
             if (!isServiceDescriptorExists(serviceName)){
@@ -580,20 +635,28 @@ public class AiravataJPARegistry extends AiravataRegistry2{
             ServiceDescriptorResource serviceDescriptorResource = gateway.getServiceDescriptorResource(serviceName);
             serviceDescriptorResource.setContent(descriptor.toXML());
             serviceDescriptorResource.save();
+            } catch (RegistryException e) {
+                e.printStackTrace();
+            }
         }
     }
 
-    public ServiceDescription getServiceDescriptor(String serviceName) throws RegistryException, MalformedDescriptorException {
+    public ServiceDescription getServiceDescriptor(String serviceName) throws RegException, MalformedDescriptorException {
         if (descriptorRegistry != null) {
             return descriptorRegistry.getServiceDescriptor(serviceName);
-        }else {
-            GatewayResource gateway = jpa.getGateway();
-            if (!gateway.isServiceDescriptorExists(serviceName)){
-                return null;
+        } else {
+            try {
+                GatewayResource gateway = jpa.getGateway();
+                if (!gateway.isServiceDescriptorExists(serviceName)) {
+                    return null;
+                }
+                ServiceDescriptorResource serviceDescriptorResource = gateway.getServiceDescriptorResource(serviceName);
+                return createServiceDescriptor(serviceDescriptorResource);
+            } catch (RegistryException e) {
+                e.printStackTrace();
             }
-            ServiceDescriptorResource serviceDescriptorResource = gateway.getServiceDescriptorResource(serviceName);
-            return createServiceDescriptor(serviceDescriptorResource);
         }
+        return null;
     }
 
 	private ServiceDescription createServiceDescriptor(
@@ -606,49 +669,54 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
 	}
 
-    public void removeServiceDescriptor(String serviceName) throws RegistryException {
+    public void removeServiceDescriptor(String serviceName) throws RegException {
         if (descriptorRegistry != null) {
             descriptorRegistry.removeServiceDescriptor(serviceName);
-        }else {
-            GatewayResource gateway = jpa.getGateway();
-            if (!isServiceDescriptorExists(serviceName)){
-                throw new DescriptorDoesNotExistsException(serviceName);
-            }
-            gateway.removeServiceDescriptor(serviceName);
+        } else {
             try {
-				//we need to delete the application descriptors bound to this service
-				Map<String, ApplicationDescription> applicationDescriptors = getApplicationDescriptors(serviceName);
-				for (String hostName : applicationDescriptors.keySet()) {
-					removeApplicationDescriptor(serviceName, hostName, applicationDescriptors.get(hostName).getType().getApplicationName().getStringValue());
-				}
-			} catch (Exception e) {
-				logger.error("Error while removing application descriptors bound to service "+serviceName, e);
-			}
+                GatewayResource gateway = jpa.getGateway();
+                if (!isServiceDescriptorExists(serviceName)) {
+                    throw new DescriptorDoesNotExistsException(serviceName);
+                }
+                gateway.removeServiceDescriptor(serviceName);
+                //we need to delete the application descriptors bound to this service
+                Map<String, ApplicationDescription> applicationDescriptors = getApplicationDescriptors(serviceName);
+                for (String hostName : applicationDescriptors.keySet()) {
+                    removeApplicationDescriptor(serviceName, hostName, applicationDescriptors.get(hostName).getType().getApplicationName().getStringValue());
+                }
+            } catch (Exception e) {
+                logger.error("Error while removing application descriptors bound to service " + serviceName, e);
+            }
         }
     }
 
     @Override
 	public List<ServiceDescription> getServiceDescriptors()
-			throws MalformedDescriptorException, RegistryException {
+			throws MalformedDescriptorException, RegException {
+        List<ServiceDescription> list=new ArrayList<ServiceDescription>();
         if (descriptorRegistry != null) {
             return descriptorRegistry.getServiceDescriptors();
         }else {
+            try {
             GatewayResource gateway = jpa.getGateway();
-            List<ServiceDescription> list=new ArrayList<ServiceDescription>();
             List<ServiceDescriptorResource> serviceDescriptorResources = gateway.getServiceDescriptorResources();
             for (ServiceDescriptorResource resource : serviceDescriptorResources) {
                 list.add(createServiceDescriptor(resource));
             }
             return list;
+            } catch (RegistryException e) {
+                e.printStackTrace();
+            }
         }
+        return list;
 	}
 
-    public ResourceMetadata getServiceDescriptorMetadata(String serviceName) throws RegistryException {
+    public ResourceMetadata getServiceDescriptorMetadata(String serviceName) throws RegException {
         if (descriptorRegistry != null) {
             return descriptorRegistry.getServiceDescriptorMetadata(serviceName);
         }else {
             //TODO
-            throw new UnimplementedRegistryOperationException();
+            throw new UnimplementedRegOperationException();
         }
     }
 
@@ -658,17 +726,22 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 
     public boolean isApplicationDescriptorExists(String serviceName,
                                                  String hostName,
-                                                 String descriptorName)throws RegistryException{
+                                                 String descriptorName)throws RegException {
         if (descriptorRegistry != null) {
             return descriptorRegistry.isApplicationDescriptorExists(serviceName, hostName, descriptorName);
         }else {
-            return jpa.getGateway().isApplicationDescriptorExists(createAppName(serviceName, hostName, descriptorName));
+            try {
+                return jpa.getGateway().isApplicationDescriptorExists(createAppName(serviceName, hostName, descriptorName));
+            } catch (RegistryException e) {
+                e.printStackTrace();
+            }
         }
+        return false;
     }
 
     public void addApplicationDescriptor(ServiceDescription serviceDescription,
                                          HostDescription hostDescriptor,
-                                         ApplicationDescription descriptor) throws RegistryException {
+                                         ApplicationDescription descriptor) throws RegException {
         if (descriptorRegistry != null) {
             descriptorRegistry.addApplicationDescriptor(serviceDescription, hostDescriptor, descriptor);
         }else {
@@ -676,32 +749,37 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void addApplicationDescriptor(String serviceName, String hostName, ApplicationDescription descriptor) throws RegistryException {
-        if (descriptorRegistry != null){
+    public void addApplicationDescriptor(String serviceName, String hostName, ApplicationDescription descriptor) throws RegException {
+        if (descriptorRegistry != null) {
             descriptorRegistry.addApplicationDescriptor(serviceName, hostName, descriptor);
-        }  else {
-            if (serviceName==null || hostName==null){
+        } else {
+            if (serviceName == null || hostName == null) {
                 throw new InsufficientDataException("Service name or Host name cannot be null");
             }
-            GatewayResource gateway = jpa.getGateway();
-            WorkerResource workerResource = jpa.getWorker();
-            String applicationName = descriptor.getType().getApplicationName().getStringValue();
-            applicationName = createAppName(serviceName, hostName, applicationName);
-            if (isApplicationDescriptorExists(serviceName,hostName,descriptor.getType().getApplicationName().getStringValue())){
-                throw new DescriptorAlreadyExistsException(applicationName);
+            try {
+
+                GatewayResource gateway = jpa.getGateway();
+                WorkerResource workerResource = jpa.getWorker();
+                String applicationName = descriptor.getType().getApplicationName().getStringValue();
+                applicationName = createAppName(serviceName, hostName, applicationName);
+                if (isApplicationDescriptorExists(serviceName, hostName, descriptor.getType().getApplicationName().getStringValue())) {
+                    throw new DescriptorAlreadyExistsException(applicationName);
+                }
+                ApplicationDescriptorResource applicationDescriptorResource = gateway.createApplicationDescriptorResource(applicationName);
+                applicationDescriptorResource.setUpdatedUser(workerResource.getUser());
+                applicationDescriptorResource.setServiceDescName(serviceName);
+                applicationDescriptorResource.setHostDescName(hostName);
+                applicationDescriptorResource.setContent(descriptor.toXML());
+                applicationDescriptorResource.save();
+            } catch (RegistryException e) {
+                e.printStackTrace();
             }
-            ApplicationDescriptorResource applicationDescriptorResource = gateway.createApplicationDescriptorResource(applicationName);
-            applicationDescriptorResource.setUpdatedUser(workerResource.getUser());
-            applicationDescriptorResource.setServiceDescName(serviceName);
-            applicationDescriptorResource.setHostDescName(hostName);
-            applicationDescriptorResource.setContent(descriptor.toXML());
-            applicationDescriptorResource.save();
         }
     }
 
     public void udpateApplicationDescriptor(ServiceDescription serviceDescription,
                                             HostDescription hostDescriptor,
-                                            ApplicationDescription descriptor) throws RegistryException {
+                                            ApplicationDescription descriptor) throws RegException {
         if (descriptorRegistry != null){
             descriptorRegistry.udpateApplicationDescriptor(serviceDescription,hostDescriptor,descriptor);
         } else {
@@ -709,13 +787,14 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public void updateApplicationDescriptor(String serviceName, String hostName, ApplicationDescription descriptor) throws RegistryException {
+    public void updateApplicationDescriptor(String serviceName, String hostName, ApplicationDescription descriptor) throws RegException {
     	if (descriptorRegistry != null){
             descriptorRegistry.updateApplicationDescriptor(serviceName, hostName, descriptor);
         } else {
             if (serviceName==null || hostName==null){
                 throw new InsufficientDataException("Service name or Host name cannot be null");
             }
+            try {
             GatewayResource gateway = jpa.getGateway();
             String applicationName = descriptor.getType().getApplicationName().getStringValue();
             applicationName = createAppName(serviceName, hostName, applicationName);
@@ -725,6 +804,9 @@ public class AiravataJPARegistry extends AiravataRegistry2{
             ApplicationDescriptorResource serviceDescriptorResource = gateway.getApplicationDescriptorResource(applicationName);
             serviceDescriptorResource.setContent(descriptor.toXML());
             serviceDescriptorResource.save();
+            } catch (RegistryException e) {
+                e.printStackTrace();
+            }
         }
     }
     private ApplicationDescription createApplicationDescriptor(
@@ -737,7 +819,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
 	}
 
-    public ApplicationDescription getApplicationDescriptor(String serviceName, String hostname, String applicationName)throws DescriptorDoesNotExistsException, MalformedDescriptorException, RegistryException{
+    public ApplicationDescription getApplicationDescriptor(String serviceName, String hostname, String applicationName)throws DescriptorDoesNotExistsException, MalformedDescriptorException, RegException {
         if (descriptorRegistry != null){
             return descriptorRegistry.getApplicationDescriptor(serviceName, hostname, applicationName);
         }
@@ -748,77 +830,107 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 		if (!isApplicationDescriptorExists(serviceName,hostname,applicationName)){
         	throw new DescriptorDoesNotExistsException(createAppName(serviceName, hostname, applicationName));
         }
-        return createApplicationDescriptor(gateway.getApplicationDescriptorResource(createAppName(serviceName, hostname, applicationName)));
+        try {
+            return createApplicationDescriptor(gateway.getApplicationDescriptorResource(createAppName(serviceName, hostname, applicationName)));
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+        return null;
     }
 
-    public ApplicationDescription getApplicationDescriptors(String serviceName, String hostname) throws RegistryException {
-        if (descriptorRegistry != null){
+    public ApplicationDescription getApplicationDescriptors(String serviceName, String hostname) throws RegException {
+        if (descriptorRegistry != null) {
             return descriptorRegistry.getApplicationDescriptors(serviceName, hostname);
         }
-        GatewayResource gateway = jpa.getGateway();
-		List<ApplicationDescriptorResource> applicationDescriptorResources = gateway.getApplicationDescriptorResources(serviceName, hostname);
-		if (applicationDescriptorResources.size()>0){
-			return createApplicationDescriptor(applicationDescriptorResources.get(0));
-		}
-		return null;
+        try {
+            GatewayResource gateway = jpa.getGateway();
+            List<ApplicationDescriptorResource> applicationDescriptorResources = gateway.getApplicationDescriptorResources(serviceName, hostname);
+            if (applicationDescriptorResources.size() > 0) {
+                return createApplicationDescriptor(applicationDescriptorResources.get(0));
+            }
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+        return null;
     }
 
-    public Map<String, ApplicationDescription> getApplicationDescriptors(String serviceName) throws RegistryException {
-        if (descriptorRegistry != null){
+    public Map<String, ApplicationDescription> getApplicationDescriptors(String serviceName) throws RegException {
+        if (descriptorRegistry != null) {
             return descriptorRegistry.getApplicationDescriptors(serviceName);
         }
-        GatewayResource gateway = jpa.getGateway();
-		Map<String, ApplicationDescription> map=new HashMap<String,ApplicationDescription>();
-		List<ApplicationDescriptorResource> applicationDescriptorResources = gateway.getApplicationDescriptorResources(serviceName, null);
-		for (ApplicationDescriptorResource resource : applicationDescriptorResources) {
-			map.put(resource.getHostDescName(),createApplicationDescriptor(resource));
-		}
-		return map;
+        Map<String, ApplicationDescription> map = new HashMap<String, ApplicationDescription>();
+        try {
+            GatewayResource gateway = jpa.getGateway();
+
+            List<ApplicationDescriptorResource> applicationDescriptorResources = gateway.getApplicationDescriptorResources(serviceName, null);
+            for (ApplicationDescriptorResource resource : applicationDescriptorResources) {
+                map.put(resource.getHostDescName(), createApplicationDescriptor(resource));
+            }
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+        return map;
     }
 
-    private Map<String,ApplicationDescription> getApplicationDescriptorsFromHostName(String hostName)throws RegistryException {
-        GatewayResource gateway = jpa.getGateway();
-		Map<String, ApplicationDescription> map=new HashMap<String,ApplicationDescription>();
-		List<ApplicationDescriptorResource> applicationDescriptorResources = gateway.getApplicationDescriptorResources(null, hostName);
-		for (ApplicationDescriptorResource resource : applicationDescriptorResources) {
-			map.put(resource.getServiceDescName(),createApplicationDescriptor(resource));
-		}
-		return map;
+    private Map<String,ApplicationDescription> getApplicationDescriptorsFromHostName(String hostName)throws RegException {
+        Map<String, ApplicationDescription> map=new HashMap<String,ApplicationDescription>();
+        try {
+            GatewayResource gateway = jpa.getGateway();
+            List<ApplicationDescriptorResource> applicationDescriptorResources = gateway.getApplicationDescriptorResources(null, hostName);
+            for (ApplicationDescriptorResource resource : applicationDescriptorResources) {
+                map.put(resource.getServiceDescName(),createApplicationDescriptor(resource));
+            }
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+
+        return map;
     }
     
-    public Map<String[],ApplicationDescription> getApplicationDescriptors()throws MalformedDescriptorException, RegistryException{
+    public Map<String[],ApplicationDescription> getApplicationDescriptors()throws MalformedDescriptorException, RegException {
+        Map<String[], ApplicationDescription> map=new HashMap<String[],ApplicationDescription>();
         if (descriptorRegistry != null){
             return descriptorRegistry.getApplicationDescriptors();
         }
+        try {
+
         GatewayResource gateway = jpa.getGateway();
-		Map<String[], ApplicationDescription> map=new HashMap<String[],ApplicationDescription>();
+
 		List<ApplicationDescriptorResource> applicationDescriptorResources = gateway.getApplicationDescriptorResources();
 		for (ApplicationDescriptorResource resource : applicationDescriptorResources) {
 			map.put(new String[]{resource.getServiceDescName(),resource.getHostDescName()},createApplicationDescriptor(resource));
 		}
 		return map;
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+        return map;
     }
 
-    public void removeApplicationDescriptor(String serviceName, String hostName, String applicationName) throws RegistryException {
+    public void removeApplicationDescriptor(String serviceName, String hostName, String applicationName) throws RegException {
         if (descriptorRegistry != null){
              descriptorRegistry.removeApplicationDescriptor(serviceName, hostName, applicationName);
         } else {
+            try {
             GatewayResource gateway = jpa.getGateway();
             String appName = createAppName(serviceName, hostName, applicationName);
             if (!isApplicationDescriptorExists(serviceName,hostName,applicationName)){
                 throw new DescriptorDoesNotExistsException(appName);
             }
             gateway.removeApplicationDescriptor(appName);
+            } catch (RegistryException e) {
+                e.printStackTrace();
+            }
         }
 
     }
 
-    public ResourceMetadata getApplicationDescriptorMetadata(String serviceName, String hostName, String applicationName) throws RegistryException {
+    public ResourceMetadata getApplicationDescriptorMetadata(String serviceName, String hostName, String applicationName) throws RegException {
     	if (descriptorRegistry != null) {
             return descriptorRegistry.getApplicationDescriptorMetadata(serviceName, hostName, applicationName);
         }
     	//TODO
-        throw new UnimplementedRegistryOperationException();
+        throw new UnimplementedRegOperationException();
     }
 
     /**---------------------------------Project Registry----------------------------------**/
@@ -838,7 +950,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 
 	@Override
 	public boolean isWorkspaceProjectExists(String projectName)
-			throws RegistryException {
+			throws RegException {
         if (projectsRegistry != null){
             return projectsRegistry.isWorkspaceProjectExists(projectName);
         }
@@ -847,10 +959,12 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 
 	@Override
 	public boolean isWorkspaceProjectExists(String projectName,
-			boolean createIfNotExists) throws RegistryException {
+			boolean createIfNotExists) throws RegException {
         if (projectsRegistry != null){
             return projectsRegistry.isWorkspaceProjectExists(projectName, createIfNotExists);
         }
+        try {
+
 		if (jpa.getWorker().isProjectExists(createProjName(projectName))){
 			return true;
 		}else if (createIfNotExists){
@@ -859,75 +973,85 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 		}else{
 			return false;
 		}
-	}
-
-    public void addWorkspaceProject(WorkspaceProject project) throws RegistryException {
-        if (projectsRegistry != null){
-            projectsRegistry.addWorkspaceProject(project);
-        } else {
-            WorkerResource worker = jpa.getWorker();
-            if (isWorkspaceProjectExists(project.getProjectName())){
-                throw new WorkspaceProjectAlreadyExistsException(createProjName(project.getProjectName()));
-            }
-            ProjectResource projectResource = worker.createProject(createProjName(project.getProjectName()));
-            projectResource.save();
+        } catch (RegistryException e) {
+            e.printStackTrace();
         }
+        return false;
     }
 
-    public void updateWorkspaceProject(WorkspaceProject project) throws RegistryException {
-        if (projectsRegistry != null){
-            projectsRegistry.updateWorkspaceProject(project);
-        }else {
-            WorkerResource worker = jpa.getWorker();
-            if (!isWorkspaceProjectExists(project.getProjectName())){
-                throw new WorkspaceProjectDoesNotExistsException(createProjName(project.getProjectName()));
-            }
-            ProjectResource projectResource = worker.getProject(createProjName(project.getProjectName()));
-            projectResource.save();
-        }
+    public void addWorkspaceProject(WorkspaceProject project) throws RegException {
+//        if (projectsRegistry != null){
+//            projectsRegistry.addWorkspaceProject(project);
+//        } else {
+//            WorkerResource worker = jpa.getWorker();
+//            if (isWorkspaceProjectExists(project.getProjectName())){
+//                throw new WorkspaceProjectAlreadyExistsException(createProjName(project.getProjectName()));
+//            }
+//            try {
+//            ProjectResource projectResource = worker.createProject(createProjName(project.getProjectName()));
+//            projectResource.save();
+//            } catch (RegistryException e) {
+//                e.printStackTrace();
+//            }
+//        }
     }
 
-    public void deleteWorkspaceProject(String projectName) throws RegistryException {
-        if (projectsRegistry != null){
-            projectsRegistry.deleteWorkspaceProject(projectName);
-        }else {
-            WorkerResource worker = jpa.getWorker();
-            if (!isWorkspaceProjectExists(projectName)){
-                throw new WorkspaceProjectDoesNotExistsException(createProjName(projectName));
-            }
-            worker.removeProject(createProjName(projectName));
-        }
+    public void updateWorkspaceProject(WorkspaceProject project) throws RegException {
+//        if (projectsRegistry != null){
+//            projectsRegistry.updateWorkspaceProject(project);
+//        }else {
+//            WorkerResource worker = jpa.getWorker();
+//            if (!isWorkspaceProjectExists(project.getProjectName())){
+//                throw new WorkspaceProjectDoesNotExistsException(createProjName(project.getProjectName()));
+//            }
+//            ProjectResource projectResource = worker.getProject(createProjName(project.getProjectName()));
+//            projectResource.save();
+//        }
     }
 
-    public WorkspaceProject getWorkspaceProject(String projectName) throws RegistryException {
-        if (projectsRegistry != null){
-            return projectsRegistry.getWorkspaceProject(projectName);
-        }
-    	WorkerResource worker = jpa.getWorker();
-		if (!isWorkspaceProjectExists(projectName)){
-        	throw new WorkspaceProjectDoesNotExistsException(createProjName(projectName));
-        }
-		ProjectResource projectResource = worker.getProject(createProjName(projectName));
-		return new WorkspaceProject(getProjName(projectResource.getName()), this);
+    public void deleteWorkspaceProject(String projectName) throws RegException {
+//        if (projectsRegistry != null){
+//            projectsRegistry.deleteWorkspaceProject(projectName);
+//        }else {
+//            WorkerResource worker = jpa.getWorker();
+//            if (!isWorkspaceProjectExists(projectName)){
+//                throw new WorkspaceProjectDoesNotExistsException(createProjName(projectName));
+//            }
+//            worker.removeProject(createProjName(projectName));
+//        }
     }
 
-    public List<WorkspaceProject> getWorkspaceProjects() throws RegistryException{
-        if (projectsRegistry != null){
-            return projectsRegistry.getWorkspaceProjects();
-        }
-    	WorkerResource worker = jpa.getWorker();
-    	List<WorkspaceProject> projects=new ArrayList<WorkspaceProject>();
-    	List<ProjectResource> projectResouces = worker.getProjects();
-    	for (ProjectResource resource : projectResouces) {
-			projects.add(new WorkspaceProject(getProjName(resource.getName()), this));
-		}
-    	return projects;
+    public WorkspaceProject getWorkspaceProject(String projectName) throws RegException {
+//        if (projectsRegistry != null){
+//            return projectsRegistry.getWorkspaceProject(projectName);
+//        }
+//    	WorkerResource worker = jpa.getWorker();
+//		if (!isWorkspaceProjectExists(projectName)){
+//        	throw new WorkspaceProjectDoesNotExistsException(createProjName(projectName));
+//        }
+//		ProjectResource projectResource = worker.getProject(createProjName(projectName));
+//		return new WorkspaceProject(getProjName(projectResource.getName()), this);
+        return null;
     }
 
-    public void addExperiment(String projectName, AiravataExperiment experiment) throws RegistryException {
-    	if (projectsRegistry != null){
-            projectsRegistry.addExperiment(projectName, experiment);
-        }else {
+    public List<WorkspaceProject> getWorkspaceProjects() throws RegException {
+//        if (projectsRegistry != null){
+//            return projectsRegistry.getWorkspaceProjects();
+//        }
+//    	WorkerResource worker = jpa.getWorker();
+//    	List<WorkspaceProject> projects=new ArrayList<WorkspaceProject>();
+//    	List<ProjectResource> projectResouces = worker.getProjects();
+//    	for (ProjectResource resource : projectResouces) {
+//			projects.add(new WorkspaceProject(getProjName(resource.getName()), this));
+//		}
+//    	return projects;
+        return null;
+    }
+
+    public void addExperiment(String projectName, AiravataExperiment experiment) throws RegException {
+//    	if (projectsRegistry != null){
+//            projectsRegistry.addExperiment(projectName, experiment);
+//        }else {
 //            WorkspaceProject workspaceProject = getWorkspaceProject(projectName);
 //            ProjectResource project = jpa.getWorker().getProject(createProjName(workspaceProject.getProjectName()));
 //            String experimentId = experiment.getExperimentId();
@@ -943,27 +1067,27 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 //                experimentResource.setSubmittedDate(new Timestamp(experiment.getSubmittedDate().getTime()));
 //            }
 //            experimentResource.save();
-        }
+//        }
     }
 
     public void removeExperiment(String experimentId) throws ExperimentDoesNotExistsException {
-        if (projectsRegistry != null){
-            projectsRegistry.removeExperiment(experimentId);
-        }else {
-            WorkerResource worker = jpa.getWorker();
-            if (!worker.isExperimentExists(experimentId)){
-                throw new ExperimentDoesNotExistsException(experimentId);
-            }
-            worker.removeExperiment(experimentId);
-        }
+//        if (projectsRegistry != null){
+//            projectsRegistry.removeExperiment(experimentId);
+//        }else {
+//            WorkerResource worker = jpa.getWorker();
+//            if (!worker.isExperimentExists(experimentId)){
+//                throw new ExperimentDoesNotExistsException(experimentId);
+//            }
+//            worker.removeExperiment(experimentId);
+//        }
     }
 
-    public List<AiravataExperiment> getExperiments() throws RegistryException{
-        if (projectsRegistry != null){
-            return projectsRegistry.getExperiments();
-        }
-        WorkerResource worker = jpa.getWorker();
-    	List<AiravataExperiment> result=new ArrayList<AiravataExperiment>();
+    public List<AiravataExperiment> getExperiments() throws RegException {
+//        if (projectsRegistry != null){
+//            return projectsRegistry.getExperiments();
+//        }
+//        WorkerResource worker = jpa.getWorker();
+//    	List<AiravataExperiment> result=new ArrayList<AiravataExperiment>();
 //    	List<ExperimentMetadataResource> experiments = worker.getExperiments();
 //    	for (ExperimentMetadataResource resource : experiments) {
 //			AiravataExperiment e = createAiravataExperimentObj(resource);
@@ -984,11 +1108,11 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 //		return e;
 //	}
 
-    public List<AiravataExperiment> getExperiments(String projectName)throws RegistryException {
-        if (projectsRegistry != null){
-            return projectsRegistry.getExperiments(projectName);
-        }
-        ProjectResource project = jpa.getWorker().getProject(createProjName(projectName));
+    public List<AiravataExperiment> getExperiments(String projectName)throws RegException {
+//        if (projectsRegistry != null){
+//            return projectsRegistry.getExperiments(projectName);
+//        }
+//        ProjectResource project = jpa.getWorker().getProject(createProjName(projectName));
 //    	List<ExperimentMetadataResource> experiments = project.getExperiments();
 //    	List<AiravataExperiment> result=new ArrayList<AiravataExperiment>();
 //    	for (ExperimentMetadataResource resource : experiments) {
@@ -999,51 +1123,59 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         return null;
     }
 
-    public List<AiravataExperiment> getExperiments(Date from, Date to)throws RegistryException {
-        if (projectsRegistry != null){
-            return projectsRegistry.getExperiments(from, to);
-        }
-        List<AiravataExperiment> experiments = getExperiments();
-        List<AiravataExperiment> newExperiments = new ArrayList<AiravataExperiment>();
-        for(AiravataExperiment exp:experiments){
-            Date submittedDate = exp.getSubmittedDate();
-            if(submittedDate.after(from) && submittedDate.before(to)) {
-                newExperiments.add(exp);
-            }
-        }
-        return newExperiments;
+    public List<AiravataExperiment> getExperiments(Date from, Date to)throws RegException {
+//        if (projectsRegistry != null){
+//            return projectsRegistry.getExperiments(from, to);
+//        }
+//        List<AiravataExperiment> experiments = getExperiments();
+//        List<AiravataExperiment> newExperiments = new ArrayList<AiravataExperiment>();
+//        for(AiravataExperiment exp:experiments){
+//            Date submittedDate = exp.getSubmittedDate();
+//            if(submittedDate.after(from) && submittedDate.before(to)) {
+//                newExperiments.add(exp);
+//            }
+//        }
+//        return newExperiments;
+        return null;
     }
 
-    public List<AiravataExperiment> getExperiments(String projectName, Date from, Date to)throws RegistryException {
-        if (projectsRegistry != null){
-            return projectsRegistry.getExperiments(projectName, from, to);
-        }
-        List<AiravataExperiment> experiments = getExperiments(projectName);
-        List<AiravataExperiment> newExperiments = new ArrayList<AiravataExperiment>();
-        for (AiravataExperiment exp : experiments) {
-            Date submittedDate = exp.getSubmittedDate();
-            if (submittedDate.after(from) && submittedDate.before(to)) {
-                newExperiments.add(exp);
-            }
-        }
-        return newExperiments;
+    public List<AiravataExperiment> getExperiments(String projectName, Date from, Date to)throws RegException {
+//        if (projectsRegistry != null){
+//            return projectsRegistry.getExperiments(projectName, from, to);
+//        }
+//        List<AiravataExperiment> experiments = getExperiments(projectName);
+//        List<AiravataExperiment> newExperiments = new ArrayList<AiravataExperiment>();
+//        for (AiravataExperiment exp : experiments) {
+//            Date submittedDate = exp.getSubmittedDate();
+//            if (submittedDate.after(from) && submittedDate.before(to)) {
+//                newExperiments.add(exp);
+//            }
+//        }
+//        return newExperiments;
+        return null;
     }
 
     /**---------------------------------Published Workflow Registry----------------------------------**/
 
 	@Override
 	public boolean isPublishedWorkflowExists(String workflowName)
-			throws RegistryException {
+			throws RegException {
         if (publishedWorkflowRegistry != null){
             return publishedWorkflowRegistry.isPublishedWorkflowExists(workflowName);
         }
-		return jpa.getGateway().isPublishedWorkflowExists(workflowName);
-	}
+        try {
+            return jpa.getGateway().isPublishedWorkflowExists(workflowName);
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
 
-    public void publishWorkflow(String workflowName, String publishWorkflowName) throws RegistryException {
+    public void publishWorkflow(String workflowName, String publishWorkflowName) throws RegException {
         if (publishedWorkflowRegistry != null){
             publishedWorkflowRegistry.publishWorkflow(workflowName, publishWorkflowName);
         } else {
+            try {
             GatewayResource gateway = jpa.getGateway();
             String workflowGraphXML = getWorkflowGraphXML(workflowName);
             if (gateway.isPublishedWorkflowExists(publishWorkflowName)){
@@ -1054,10 +1186,13 @@ public class AiravataJPARegistry extends AiravataRegistry2{
             publishedWorkflow.setContent(workflowGraphXML);
             publishedWorkflow.setPublishedDate(new Timestamp(Calendar.getInstance().getTime().getTime()));
             publishedWorkflow.save();
+            } catch (RegistryException e) {
+                e.printStackTrace();
+            }
         }
     }
 
-    public void publishWorkflow(String workflowName) throws RegistryException {
+    public void publishWorkflow(String workflowName) throws RegException {
         if (publishedWorkflowRegistry != null){
             publishedWorkflowRegistry.publishWorkflow(workflowName);
         } else {
@@ -1065,7 +1200,7 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         }
     }
 
-    public String getPublishedWorkflowGraphXML(String workflowName) throws RegistryException {
+    public String getPublishedWorkflowGraphXML(String workflowName) throws RegException {
         if (publishedWorkflowRegistry != null){
             return publishedWorkflowRegistry.getPublishedWorkflowGraphXML(workflowName);
         }
@@ -1073,67 +1208,90 @@ public class AiravataJPARegistry extends AiravataRegistry2{
         if (!isPublishedWorkflowExists(workflowName)){
         	throw new PublishedWorkflowDoesNotExistsException(workflowName);
         }
-        return gateway.getPublishedWorkflow(workflowName).getContent();
+        try {
+            return gateway.getPublishedWorkflow(workflowName).getContent();
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+        return null;
     }
 
-	public List<String> getPublishedWorkflowNames() throws RegistryException{
+	public List<String> getPublishedWorkflowNames() throws RegException {
+        List<String> result=new ArrayList<String>();
         if (publishedWorkflowRegistry != null){
             return publishedWorkflowRegistry.getPublishedWorkflowNames();
         }
 		GatewayResource gateway = jpa.getGateway();
-		List<String> result=new ArrayList<String>();
+		try {
     	List<PublishWorkflowResource> publishedWorkflows = gateway.getPublishedWorkflows();
     	for (PublishWorkflowResource resource : publishedWorkflows) {
 			result.add(resource.getName());
 		}
-    	return result;
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+        return result;
 	}
 
-    public Map<String,String> getPublishedWorkflows() throws RegistryException{
+    public Map<String,String> getPublishedWorkflows() throws RegException {
+        Map<String,String> result=new HashMap<String, String>();
         if (publishedWorkflowRegistry != null){
             return publishedWorkflowRegistry.getPublishedWorkflows();
         }
+        try {
     	GatewayResource gateway = jpa.getGateway();
-    	Map<String,String> result=new HashMap<String, String>();
+
     	List<PublishWorkflowResource> publishedWorkflows = gateway.getPublishedWorkflows();
     	for (PublishWorkflowResource resource : publishedWorkflows) {
 			result.put(resource.getName(), resource.getContent());
 		}
-    	return result;
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+        return result;
     }
 
-    public void removePublishedWorkflow(String workflowName) throws RegistryException {
+    public void removePublishedWorkflow(String workflowName) throws RegException {
         if (publishedWorkflowRegistry != null){
             publishedWorkflowRegistry.removePublishedWorkflow(workflowName);
         } else {
+            try {
             GatewayResource gateway = jpa.getGateway();
             if (!isPublishedWorkflowExists(workflowName)){
                 throw new PublishedWorkflowDoesNotExistsException(workflowName);
             }
             gateway.removePublishedWorkflow(workflowName);
+        } catch (RegistryException e) {
+                e.printStackTrace();
+            }
         }
     }
 
-    public ResourceMetadata getPublishedWorkflowMetadata(String workflowName) throws RegistryException {
+    public ResourceMetadata getPublishedWorkflowMetadata(String workflowName) throws RegException {
         if (publishedWorkflowRegistry != null){
             return publishedWorkflowRegistry.getPublishedWorkflowMetadata(workflowName);
         }
         //TODO
-        throw new UnimplementedRegistryOperationException();
+        throw new UnimplementedRegOperationException();
     }
 
     /**---------------------------------User Workflow Registry----------------------------------**/
 
 	@Override
 	public boolean isWorkflowExists(String workflowName)
-			throws RegistryException {
+			throws RegException {
         if (userWorkflowRegistry != null){
            return userWorkflowRegistry.isWorkflowExists(workflowName);
         }
-		return jpa.getWorker().isWorkflowTemplateExists(workflowName);
-	}
+        try {
+            return jpa.getWorker().isWorkflowTemplateExists(workflowName);
+        } catch (RegistryException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
 
-    public void addWorkflow(String workflowName, String workflowGraphXml) throws RegistryException {
+    public void addWorkflow(String workflowName, String workflowGraphXml) throws RegException {
         if (userWorkflowRegistry != null){
             userWorkflowRegistry.addWorkflow(workflowName, workflowGraphXml);
         }else {
@@ -1141,69 +1299,75 @@ public class AiravataJPARegistry extends AiravataRegistry2{
             if (isWorkflowExists(workflowName)){
                 throw new UserWorkflowAlreadyExistsException(workflowName);
             }
+            try {
             UserWorkflowResource workflowResource = worker.createWorkflowTemplate(workflowName);
             workflowResource.setContent(workflowGraphXml);
             workflowResource.save();
+            } catch (RegistryException e) {
+                e.printStackTrace();
+            }
         }
     }
 
-    public void updateWorkflow(String workflowName, String workflowGraphXml) throws RegistryException {
-        if (userWorkflowRegistry != null){
-            userWorkflowRegistry.updateWorkflow(workflowName, workflowGraphXml);
-        }else {
-            WorkerResource worker = jpa.getWorker();
-            if (!isWorkflowExists(workflowName)){
-                throw new UserWorkflowDoesNotExistsException(workflowName);
-            }
-            UserWorkflowResource workflowResource = worker.getWorkflowTemplate(workflowName);
-            workflowResource.setContent(workflowGraphXml);
-            workflowResource.save();
-        }
+    public void updateWorkflow(String workflowName, String workflowGraphXml) throws RegException {
+//        if (userWorkflowRegistry != null){
+//            userWorkflowRegistry.updateWorkflow(workflowName, workflowGraphXml);
+//        }else {
+//            WorkerResource worker = jpa.getWorker();
+//            if (!isWorkflowExists(workflowName)){
+//                throw new UserWorkflowDoesNotExistsException(workflowName);
+//            }
+//            UserWorkflowResource workflowResource = worker.getWorkflowTemplate(workflowName);
+//            workflowResource.setContent(workflowGraphXml);
+//            workflowResource.save();
+//        }
     }
 
-    public String getWorkflowGraphXML(String workflowName) throws RegistryException {
-        if (userWorkflowRegistry != null){
-            return userWorkflowRegistry.getWorkflowGraphXML(workflowName);
-        }
-        WorkerResource worker = jpa.getWorker();
-		if (!isWorkflowExists(workflowName)){
-        	throw new UserWorkflowDoesNotExistsException(workflowName);
-        }
-		return worker.getWorkflowTemplate(workflowName).getContent();
+    public String getWorkflowGraphXML(String workflowName) throws RegException {
+//        if (userWorkflowRegistry != null){
+//            return userWorkflowRegistry.getWorkflowGraphXML(workflowName);
+//        }
+//        WorkerResource worker = jpa.getWorker();
+//		if (!isWorkflowExists(workflowName)){
+//        	throw new UserWorkflowDoesNotExistsException(workflowName);
+//        }
+//		return worker.getWorkflowTemplate(workflowName).getContent();
+        return null;
     }
 
 	@Override
-	public Map<String, String> getWorkflows() throws RegistryException {
-        if (userWorkflowRegistry != null){
-            return userWorkflowRegistry.getWorkflows();
-        }
-        WorkerResource worker = jpa.getWorker();
-    	Map<String, String> workflows=new HashMap<String, String>();
-    	List<UserWorkflowResource> workflowTemplates = worker.getWorkflowTemplates();
-    	for (UserWorkflowResource resource : workflowTemplates) {
-    		workflows.put(resource.getName(), resource.getContent());
-		}
-    	return workflows;
+	public Map<String, String> getWorkflows() throws RegException {
+//        if (userWorkflowRegistry != null){
+//            return userWorkflowRegistry.getWorkflows();
+//        }
+//        WorkerResource worker = jpa.getWorker();
+//    	Map<String, String> workflows=new HashMap<String, String>();
+//    	List<UserWorkflowResource> workflowTemplates = worker.getWorkflowTemplates();
+//    	for (UserWorkflowResource resource : workflowTemplates) {
+//    		workflows.put(resource.getName(), resource.getContent());
+//		}
+//    	return workflows;
+        return null;
 	}
 
-    public void removeWorkflow(String workflowName) throws RegistryException {
-        if (userWorkflowRegistry != null){
-            userWorkflowRegistry.removeWorkflow(workflowName);
-        }else {
-            WorkerResource worker = jpa.getWorker();
-            if (!isWorkflowExists(workflowName)){
-                throw new UserWorkflowDoesNotExistsException(workflowName);
-            }
-            worker.removeWorkflowTemplate(workflowName);
-        }
+    public void removeWorkflow(String workflowName) throws RegException {
+//        if (userWorkflowRegistry != null){
+//            userWorkflowRegistry.removeWorkflow(workflowName);
+//        }else {
+//            WorkerResource worker = jpa.getWorker();
+//            if (!isWorkflowExists(workflowName)){
+//                throw new UserWorkflowDoesNotExistsException(workflowName);
+//            }
+//            worker.removeWorkflowTemplate(workflowName);
+//        }
     }
 
-    public ResourceMetadata getWorkflowMetadata(String workflowName) throws RegistryException {
+    public ResourceMetadata getWorkflowMetadata(String workflowName) throws RegException {
         if (userWorkflowRegistry != null){
             return userWorkflowRegistry.getWorkflowMetadata(workflowName);
         }
     	//TODO
-        throw new UnimplementedRegistryOperationException();
+        throw new UnimplementedRegOperationException();
     }
     public void setAiravataRegistry(AiravataRegistry2 registry) {
         //redundant
@@ -1221,115 +1385,119 @@ public class AiravataJPARegistry extends AiravataRegistry2{
     /**---------------------------------Provenance Registry----------------------------------**/
 
 	@Override
-	public boolean isExperimentExists(String experimentId, boolean createIfNotPresent)throws RegistryException {
-		if (provenanceRegistry != null){
-             return provenanceRegistry.isExperimentExists(experimentId, createIfNotPresent);
-        }
-        if (jpa.getWorker().isExperimentExists(experimentId)){
-			return true;
-		}else if (createIfNotPresent){
-			if (!isWorkspaceProjectExists(DEFAULT_PROJECT_NAME, true)){
-				throw new WorkspaceProjectDoesNotExistsException(createProjName(DEFAULT_PROJECT_NAME));
-			}
-			AiravataExperiment experiment = new AiravataExperiment();
-			experiment.setExperimentId(experimentId);
-			experiment.setSubmittedDate(Calendar.getInstance().getTime());
-			experiment.setGateway(getGateway());
-			experiment.setUser(getUser());
-			addExperiment(DEFAULT_PROJECT_NAME, experiment);
-			return jpa.getWorker().isExperimentExists(experimentId);
-		}else{
-			return false;
-		}
+	public boolean isExperimentExists(String experimentId, boolean createIfNotPresent)throws RegException {
+//		if (provenanceRegistry != null){
+//             return provenanceRegistry.isExperimentExists(experimentId, createIfNotPresent);
+//        }
+//        if (jpa.getWorker().isExperimentExists(experimentId)){
+//			return true;
+//		}else if (createIfNotPresent){
+//			if (!isWorkspaceProjectExists(DEFAULT_PROJECT_NAME, true)){
+//				throw new WorkspaceProjectDoesNotExistsException(createProjName(DEFAULT_PROJECT_NAME));
+//			}
+//			AiravataExperiment experiment = new AiravataExperiment();
+//			experiment.setExperimentId(experimentId);
+//			experiment.setSubmittedDate(Calendar.getInstance().getTime());
+//			experiment.setGateway(getGateway());
+//			experiment.setUser(getUser());
+//			addExperiment(DEFAULT_PROJECT_NAME, experiment);
+//			return jpa.getWorker().isExperimentExists(experimentId);
+//		}else{
+//			return false;
+//		}
+        return false;
 	}
 
 	@Override
 	public boolean isExperimentExists(String experimentId)
-			throws RegistryException {
-        if (provenanceRegistry != null){
-            return provenanceRegistry.isExperimentExists(experimentId);
-        }
-		return isExperimentExists(experimentId, false);
+			throws RegException {
+//        if (provenanceRegistry != null){
+//            return provenanceRegistry.isExperimentExists(experimentId);
+//        }
+//		return isExperimentExists(experimentId, false);
+        return false;
 	}
 
 	@Override
 	public void updateExperimentExecutionUser(String experimentId,
-			String user) throws RegistryException {
-        if (provenanceRegistry != null){
-            provenanceRegistry.updateExperimentExecutionUser(experimentId, user);
-        }else {
-            if (!isExperimentExists(experimentId, true)){
-                throw new ExperimentDoesNotExistsException(experimentId);
-            }
-//            ExperimentMetadataResource experiment = jpa.getWorker().getExperiment(experimentId);
-//            experiment.setExecutionUser(user);
-//            experiment.save();
-        }
+			String user) throws RegException {
+//        if (provenanceRegistry != null){
+//            provenanceRegistry.updateExperimentExecutionUser(experimentId, user);
+//        }else {
+//            if (!isExperimentExists(experimentId, true)){
+//                throw new ExperimentDoesNotExistsException(experimentId);
+//            }
+////            ExperimentMetadataResource experiment = jpa.getWorker().getExperiment(experimentId);
+////            experiment.setExecutionUser(user);
+////            experiment.save();
+//        }
 	}
 
 
 	@Override
 	public String getExperimentExecutionUser(String experimentId)
-			throws RegistryException {
-        if (provenanceRegistry != null){
-            return provenanceRegistry.getExperimentExecutionUser(experimentId);
-        }
-		if (!isExperimentExists(experimentId)){
-			throw new ExperimentDoesNotExistsException(experimentId);
-		}
+			throws RegException {
+//        if (provenanceRegistry != null){
+//            return provenanceRegistry.getExperimentExecutionUser(experimentId);
+//        }
+//		if (!isExperimentExists(experimentId)){
+//			throw new ExperimentDoesNotExistsException(experimentId);
+//		}
 //		ExperimentMetadataResource experiment = jpa.getWorker().getExperiment(experimentId);
 //		return experiment.getExecutionUser();
         return null;
 	}
 
     @Override
-    public boolean isExperimentNameExist(String experimentName) throws RegistryException {
-        if (provenanceRegistry != null){
-            return provenanceRegistry.isExperimentNameExist(experimentName);
-        }
-        return (new ExperimentDataRetriever()).isExperimentNameExist(experimentName);
+    public boolean isExperimentNameExist(String experimentName) throws RegException {
+//        if (provenanceRegistry != null){
+//            return provenanceRegistry.isExperimentNameExist(experimentName);
+//        }
+//        return (new ExperimentDataRetriever()).isExperimentNameExist(experimentName);
+        return false;
     }
 
 
     @Override
 	public String getExperimentName(String experimentId)
-			throws RegistryException {
-        if (provenanceRegistry != null){
-            return provenanceRegistry.getExperimentName(experimentId);
-        }
-		if (!isExperimentExists(experimentId)){
-			throw new ExperimentDoesNotExistsException(experimentId);
-		}
-        return (new ExperimentDataRetriever()).getExperimentName(experimentId);
+			throws RegException {
+//        if (provenanceRegistry != null){
+//            return provenanceRegistry.getExperimentName(experimentId);
+//        }
+//		if (!isExperimentExists(experimentId)){
+//			throw new ExperimentDoesNotExistsException(experimentId);
+//		}
+//        return (new ExperimentDataRetriever()).getExperimentName(experimentId);
+        return null;
 	}
 
 
 	@Override
 	public void updateExperimentName(String experimentId,
-			String experimentName) throws RegistryException {
-        if (provenanceRegistry != null){
-            provenanceRegistry.updateExperimentName(experimentId, experimentName);
-        }else {
-            if (!isExperimentExists(experimentId, true)){
-                throw new ExperimentDoesNotExistsException(experimentId);
-            }
+			String experimentName) throws RegException {
+//        if (provenanceRegistry != null){
+//            provenanceRegistry.updateExperimentName(experimentId, experimentName);
+//        }else {
+//            if (!isExperimentExists(experimentId, true)){
+//                throw new ExperimentDoesNotExistsException(experimentId);
+//            }
 //            ExperimentMetadataResource experiment = jpa.getWorker().getExperiment(experimentId);
 //            experiment.setExperimentName(experimentName);
 //            experiment.save();
-        }
+//        }
 	}
 
 
     // FIXME : Need to replace with new Experiment_Generated_Data
 	@Override
 	public String getExperimentMetadata(String experimentId)
-			throws RegistryException {
-        if (provenanceRegistry != null){
-            return provenanceRegistry.getExperimentMetadata(experimentId);
-        }
-		if (!isExperimentExists(experimentId, true)){
-			throw new ExperimentDoesNotExistsException(experimentId);
-		}
+			throws RegException {
+//        if (provenanceRegistry != null){
+//            return provenanceRegistry.getExperimentMetadata(experimentId);
+//        }
+//		if (!isExperimentExists(experimentId, true)){
+//			throw new ExperimentDoesNotExistsException(experimentId);
+//		}
 //		ExperimentMetadataResource experiment = jpa.getWorker().getExperiment(experimentId);
 //		ExperimentDataResource data = experiment.getData();
 //		if (data.isExperimentMetadataPresent()){
@@ -1342,13 +1510,13 @@ public class AiravataJPARegistry extends AiravataRegistry2{
     // FIXME : Need to replace with new Experiment_Generated_Data
 	@Override
 	public void updateExperimentMetadata(String experimentId, String metadata)
-			throws RegistryException {
-        if (provenanceRegistry != null){
-            provenanceRegistry.updateExperimentMetadata(experimentId, metadata);
-        }else {
-            if (!isExperimentExists(experimentId, true)){
-                throw new ExperimentDoesNotExistsException(experimentId);
-            }
+			throws RegException {
+//        if (provenanceRegistry != null){
+//            provenanceRegistry.updateExperimentMetadata(experimentId, metadata);
+//        }else {
+//            if (!isExperimentExists(experimentId, true)){
+//                throw new ExperimentDoesNotExistsException(experimentId);
+//            }
 //            ExperimentResource experiment = jpa.getWorker().getExperiment(experimentId);
 //            ExperimentDataResource data = experiment.getData();
 //            ExperimentMetadataResource experimentMetadata;
@@ -1360,18 +1528,18 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 //                experimentMetadata.setMetadata(metadata);
 //            }
 //            experimentMetadata.save();
-        }
+//        }
 	}
 
 
 	@Override
-	public String getWorkflowExecutionTemplateName(String workflowInstanceId) throws RegistryException {
-        if (provenanceRegistry != null){
-            return provenanceRegistry.getWorkflowExecutionTemplateName(workflowInstanceId);
-        }
-		if (!isWorkflowInstanceExists(workflowInstanceId, true)){
-			throw new WorkflowInstanceDoesNotExistsException(workflowInstanceId);
-		}
+	public String getWorkflowExecutionTemplateName(String workflowInstanceId) throws RegException {
+//        if (provenanceRegistry != null){
+//            return provenanceRegistry.getWorkflowExecutionTemplateName(workflowInstanceId);
+//        }
+//		if (!isWorkflowInstanceExists(workflowInstanceId, true)){
+//			throw new WorkflowInstanceDoesNotExistsException(workflowInstanceId);
+//		}
 //		WorkflowDataResource wi = jpa.getWorker().getWorkflowInstance(workflowInstanceId);
 //		return wi.getTemplateName();
         return null;
@@ -1380,29 +1548,29 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 
 	@Override
 	public void setWorkflowInstanceTemplateName(String workflowInstanceId,
-			String templateName) throws RegistryException {
-        if (provenanceRegistry != null){
-            provenanceRegistry.setWorkflowInstanceTemplateName(workflowInstanceId, templateName);
-        }else {
-            if (!isWorkflowInstanceExists(workflowInstanceId, true)){
-                throw new WorkflowInstanceDoesNotExistsException(workflowInstanceId);
-            }
+			String templateName) throws RegException {
+//        if (provenanceRegistry != null){
+//            provenanceRegistry.setWorkflowInstanceTemplateName(workflowInstanceId, templateName);
+//        }else {
+//            if (!isWorkflowInstanceExists(workflowInstanceId, true)){
+//                throw new WorkflowInstanceDoesNotExistsException(workflowInstanceId);
+//            }
 //            WorkflowDataResource wi = jpa.getWorker().getWorkflowInstance(workflowInstanceId);
 //            wi.setTemplateName(templateName);
 //            wi.save();
-        }
+//        }
 	}
 
 
 	@Override
 	public List<WorkflowExecution> getExperimentWorkflowInstances(
-			String experimentId) throws RegistryException {
-        if (provenanceRegistry != null){
-            return provenanceRegistry.getExperimentWorkflowInstances(experimentId);
-        }
-		if (!isExperimentExists(experimentId)){
-			throw new ExperimentDoesNotExistsException(experimentId);
-		}
+			String experimentId) throws RegException {
+//        if (provenanceRegistry != null){
+//            return provenanceRegistry.getExperimentWorkflowInstances(experimentId);
+//        }
+//		if (!isExperimentExists(experimentId)){
+//			throw new ExperimentDoesNotExistsException(experimentId);
+//		}
 //		ExperimentMetadataResource experiment = jpa.getWorker().getExperiment(experimentId);
 //		List<WorkflowExecution> result=new ArrayList<WorkflowExecution>();
 //		List<WorkflowDataResource> workflowInstances = experiment.getWorkflowInstances();
@@ -1417,10 +1585,10 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 
 
 	@Override
-	public boolean isWorkflowInstanceExists(String instanceId, boolean createIfNotPresent) throws RegistryException {
-        if (provenanceRegistry != null){
-            return provenanceRegistry.isWorkflowInstanceExists(instanceId, createIfNotPresent);
-        }
+	public boolean isWorkflowInstanceExists(String instanceId, boolean createIfNotPresent) throws RegException {
+//        if (provenanceRegistry != null){
+//            return provenanceRegistry.isWorkflowInstanceExists(instanceId, createIfNotPresent);
+//        }
 //        if (jpa.getWorker().isWorkflowInstancePresent(instanceId)){
 //			return true;
 //		}else if (createIfNotPresent){
@@ -1439,23 +1607,24 @@ public class AiravataJPARegistry extends AiravataRegistry2{
 
 	@Override
 	public boolean isWorkflowInstanceExists(String instanceId)
-			throws RegistryException {
-        if (provenanceRegistry != null){
-            return provenanceRegistry.isWorkflowInstanceExists(instanceId);
-        }
-        return isWorkflowInstanceExists(instanceId, false);
+			throws RegException {
+//        if (provenanceRegistry != null){
+//            return provenanceRegistry.isWorkflowInstanceExists(instanceId);
+//        }
+//        return isWorkflowInstanceExists(instanceId, false);
+        return false;
 	}
 
 
 	@Override
 	public void updateWorkflowInstanceStatus(String instanceId,
-			State status) throws RegistryException {
-        if (provenanceRegistry != null){
-            provenanceRegistry.updateWorkflowInstanceStatus(instanceId, status);
-        }else {
-            if (!isWorkflowInstanceExists(instanceId, true)){
-                throw new WorkflowInstanceDoesNotExistsException(instanceId);
-            }
+			State status) throws RegException {
+//        if (provenanceRegistry != null){
+//            provenanceRegistry.updateWorkflowInstanceStatus(instanceId, status);
+//        }else {
+//            if (!isWorkflowInstanceExists(instanceId, true)){
+//                throw new WorkflowInstanceDoesNotExistsException(instanceId);
+//            }
 //            WorkflowDataResource wi = jpa.getWorker().getWorkflowInstance(instanceId);
 //            Timestamp currentTime = new Timestamp(Calendar.getInstance().getTime().getTime());
 //            wi.setStatus(status.toString());
@@ -1464

<TRUNCATED>

[11/11] git commit: adding proper entity manager closing and exception handling - AIRAVATA-1285

Posted by ch...@apache.org.
adding proper entity manager closing and exception handling - AIRAVATA-1285


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/bf5f8c3c
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/bf5f8c3c
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/bf5f8c3c

Branch: refs/heads/master
Commit: bf5f8c3c53f9aa8e1c86fc1238c6707fcbfbe091
Parents: 0fadb08
Author: Chathuri Wimalasena <ka...@gmail.com>
Authored: Fri May 30 15:53:04 2014 -0400
Committer: Chathuri Wimalasena <ka...@gmail.com>
Committed: Fri May 30 15:53:04 2014 -0400

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   |  102 +-
 .../handler/ApplicationCatalogHandler.java      |    4 +-
 .../samples/TestCreateLaunchExperiment.java     |    6 +-
 .../apache/airavata/client/AiravataClient.java  |    8 +-
 .../client/api/CredentialStoreManager.java      |    9 +-
 .../airavata/client/api/ProvenanceManager.java  |    5 +-
 .../client/impl/ApplicationManagerImpl.java     |   26 +-
 .../client/impl/ProvenanceManagerImpl.java      |    4 +-
 .../client/impl/WorkflowManagerImpl.java        |   10 +-
 .../airavata/gfac/server/GfacServerHandler.java |    9 +-
 .../gfac/client/GfacClientFactoryTest.java      |    2 +-
 .../airavata/gfac/client/util/Initialize.java   |    3 +
 .../gfac/core/handler/AbstractHandler.java      |    7 +-
 .../gfac/core/provider/AbstractProvider.java    |    7 +-
 .../server/OrchestratorServerHandler.java       |    2 +
 .../client/OrchestratorClientFactoryTest.java   |    2 +-
 .../orchestrator/client/util/Initialize.java    |    3 +
 .../client/sample/OrchestratorClientSample.java |    3 +
 .../core/utils/OrchestratorUtils.java           |    4 +-
 .../validator/impl/SimpleAppDataValidator.java  |    7 +-
 .../cpi/impl/AbstractOrchestrator.java          |   11 +-
 .../orchestrator/core/util/Initialize.java      |    3 +
 .../persistance/registry/jpa/Resource.java      |   14 +-
 .../persistance/registry/jpa/ResourceUtils.java |  279 ++--
 .../registry/jpa/impl/AiravataJPARegistry.java  | 1435 ++++++++++--------
 .../registry/jpa/impl/ExperimentRegistry.java   |  421 ++---
 .../registry/jpa/impl/GatewayRegistry.java      |    5 +-
 .../registry/jpa/impl/ProjectRegistry.java      |   35 +-
 .../registry/jpa/impl/RegistryFactory.java      |   26 +-
 .../registry/jpa/impl/RegistryImpl.java         |    4 +-
 .../persistance/registry/jpa/impl/UserReg.java  |   11 +-
 .../jpa/resources/AbstractResource.java         |    5 +-
 .../AdvanceInputDataHandlingResource.java       |   80 +-
 .../AdvancedOutputDataHandlingResource.java     |   78 +-
 ...avataRegistryConnectionDataProviderImpl.java |    5 -
 .../ApplicationDescriptorResource.java          |   50 +-
 .../jpa/resources/ApplicationInputResource.java |   85 +-
 .../resources/ApplicationOutputResource.java    |   87 +-
 .../ComputationSchedulingResource.java          |   88 +-
 .../jpa/resources/ConfigDataResource.java       |   79 +-
 .../jpa/resources/ConfigurationResource.java    |   46 +-
 .../resources/DataTransferDetailResource.java   |  231 +--
 .../jpa/resources/ErrorDetailResource.java      |   84 +-
 .../jpa/resources/ExperimentInputResource.java  |   74 +-
 .../jpa/resources/ExperimentOutputResource.java |   33 +-
 .../jpa/resources/ExperimentResource.java       |  651 ++++----
 .../registry/jpa/resources/GatewayResource.java |  799 +++++-----
 .../jpa/resources/HostDescriptorResource.java   |   89 +-
 .../jpa/resources/JobDetailResource.java        |  293 ++--
 .../jpa/resources/NodeInputResource.java        |   85 +-
 .../jpa/resources/NodeOutputResource.java       |   86 +-
 .../registry/jpa/resources/ProjectResource.java |  280 ++--
 .../jpa/resources/ProjectUserResource.java      |   80 +-
 .../jpa/resources/PublishWorkflowResource.java  |  105 +-
 .../jpa/resources/QosParamResource.java         |   64 +-
 .../resources/ServiceDescriptorResource.java    |  121 +-
 .../registry/jpa/resources/StatusResource.java  |   99 +-
 .../jpa/resources/TaskDetailResource.java       |  660 ++++----
 .../registry/jpa/resources/UserResource.java    |   74 +-
 .../jpa/resources/UserWorkflowResource.java     |  111 +-
 .../registry/jpa/resources/WorkerResource.java  |  499 +++---
 .../resources/WorkflowNodeDetailResource.java   |  452 +++---
 .../jpa/utils/ThriftDataModelConversion.java    |   25 +-
 .../registry/jpa/util/Initialize.java           |    3 +
 .../registry/api/AiravataRegistry2.java         |    6 +-
 .../AiravataRegistryConnectionDataProvider.java |    1 -
 .../registry/api/AiravataRegistryFactory.java   |   54 +-
 .../registry/api/ConfigurationRegistry.java     |   50 +-
 .../registry/api/CredentialRegistry.java        |   18 +-
 .../airavata/registry/api/DataRegistry.java     |   10 +-
 .../registry/api/DescriptorRegistry.java        |   52 +-
 .../registry/api/OrchestratorRegistry.java      |   38 +-
 .../airavata/registry/api/ProjectsRegistry.java |   26 +-
 .../registry/api/ProvenanceRegistry.java        |  244 +--
 .../registry/api/PublishedWorkflowRegistry.java |   18 +-
 .../airavata/registry/api/UserRegistry.java     |    6 +-
 .../registry/api/UserWorkflowRegistry.java      |   16 +-
 .../airavata/registry/api/WorkspaceProject.java |    8 +-
 .../AiravataRegUninitializedException.java      |   32 +
 .../AiravataRegistryUninitializedException.java |   32 -
 .../DeploymentDescriptionRetrieveException.java |    2 +-
 .../GatewayNotRegisteredException.java          |    2 +-
 .../HostDescriptionRetrieveException.java       |    2 +-
 .../RegAPIVersionIncompatibleException.java     |   39 +
 .../RegAccessorInstantiateException.java        |   32 +
 .../exception/RegAccessorInvalidException.java  |   32 +
 .../exception/RegAccessorNotFoundException.java |   32 +
 .../RegAccessorUndefinedException.java          |   40 +
 .../registry/api/exception/RegException.java    |   39 +
 ...RegistryAPIVersionIncompatibleException.java |   41 -
 .../RegistryAccessorInstantiateException.java   |   32 -
 .../RegistryAccessorInvalidException.java       |   32 -
 .../RegistryAccessorNotFoundException.java      |   32 -
 .../RegistryAccessorUndefinedException.java     |   40 -
 .../api/exception/RegistryException.java        |   39 -
 .../ServiceDescriptionRetrieveException.java    |    2 +-
 .../UnimplementedRegOperationException.java     |   32 +
 ...UnimplementedRegistryOperationException.java |   32 -
 .../UnknownRegConnectionDataException.java      |   36 +
 .../UnknownRegistryConnectionDataException.java |   36 -
 .../DescriptorAlreadyExistsException.java       |    4 +-
 .../DescriptorDoesNotExistsException.java       |    4 +-
 .../gateway/InsufficientDataException.java      |    4 +-
 .../gateway/MalformedDescriptorException.java   |    4 +-
 ...PublishedWorkflowAlreadyExistsException.java |    4 +-
 ...PublishedWorkflowDoesNotExistsException.java |    4 +-
 .../ApplicationJobAlreadyExistsException.java   |    4 +-
 .../ApplicationJobDoesNotExistsException.java   |    4 +-
 .../ExperimentAlreadyExistsException.java       |    4 +-
 .../ExperimentDoesNotExistsException.java       |    4 +-
 .../InvalidApplicationJobIDException.java       |    4 +-
 .../UserWorkflowAlreadyExistsException.java     |    4 +-
 .../UserWorkflowDoesNotExistsException.java     |    4 +-
 .../WorkflowInstanceAlreadyExistsException.java |    4 +-
 .../WorkflowInstanceDoesNotExistsException.java |    4 +-
 ...kflowInstanceNodeAlreadyExistsException.java |    4 +-
 ...kflowInstanceNodeDoesNotExistsException.java |    4 +-
 .../WorkspaceProjectAlreadyExistsException.java |    4 +-
 .../WorkspaceProjectDoesNotExistsException.java |    4 +-
 .../registry/api/util/RegistryUtils.java        |   29 +-
 120 files changed, 5066 insertions(+), 4292 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index 8615480..c808713 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -162,15 +162,15 @@ public class AiravataServerHandler implements Airavata.Iface {
             exception.setMessage("Username cannot be empty. Please provide a valid user..");
             throw exception;
         }
-        if (!ResourceUtils.isUserExist(userName)){
-            logger.error("User does not exist in the system. Please provide a valid user..");
-            AiravataSystemException exception = new AiravataSystemException();
-            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
-            exception.setMessage("User does not exist in the system. Please provide a valid user..");
-            throw exception;
-        }
         List<Project> projects = new ArrayList<Project>();
         try {
+            if (!ResourceUtils.isUserExist(userName)){
+                logger.error("User does not exist in the system. Please provide a valid user..");
+                AiravataSystemException exception = new AiravataSystemException();
+                exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+                exception.setMessage("User does not exist in the system. Please provide a valid user..");
+                throw exception;
+            }
             registry = RegistryFactory.getDefaultRegistry();
             List<Object> list = registry.get(RegistryModelType.PROJECT, Constants.FieldConstants.ProjectConstants.OWNER, userName);
             if (list != null && !list.isEmpty()){
@@ -199,14 +199,14 @@ public class AiravataServerHandler implements Airavata.Iface {
             exception.setMessage("Username cannot be empty. Please provide a valid user..");
             throw exception;
         }
-        if (!ResourceUtils.isUserExist(userName)){
-            logger.error("User does not exist in the system. Please provide a valid user..");
-            AiravataSystemException exception = new AiravataSystemException();
-            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
-            exception.setMessage("User does not exist in the system. Please provide a valid user..");
-            throw exception;
-        }
         try {
+            if (!ResourceUtils.isUserExist(userName)){
+                logger.error("User does not exist in the system. Please provide a valid user..");
+                AiravataSystemException exception = new AiravataSystemException();
+                exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+                exception.setMessage("User does not exist in the system. Please provide a valid user..");
+                throw exception;
+            }
             List<Project> projects = new ArrayList<Project>();
             registry = RegistryFactory.getDefaultRegistry();
             Map<String, String> filters = new HashMap<String, String>();
@@ -237,14 +237,14 @@ public class AiravataServerHandler implements Airavata.Iface {
             exception.setMessage("Username cannot be empty. Please provide a valid user..");
             throw exception;
         }
-        if (!ResourceUtils.isUserExist(userName)){
-            logger.error("User does not exist in the system. Please provide a valid user..");
-            AiravataSystemException exception = new AiravataSystemException();
-            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
-            exception.setMessage("User does not exist in the system. Please provide a valid user..");
-            throw exception;
-        }
         try {
+            if (!ResourceUtils.isUserExist(userName)){
+                logger.error("User does not exist in the system. Please provide a valid user..");
+                AiravataSystemException exception = new AiravataSystemException();
+                exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+                exception.setMessage("User does not exist in the system. Please provide a valid user..");
+                throw exception;
+            }
             List<Project> projects = new ArrayList<Project>();
             registry = RegistryFactory.getDefaultRegistry();
             Map<String, String> filters = new HashMap<String, String>();
@@ -275,14 +275,14 @@ public class AiravataServerHandler implements Airavata.Iface {
             exception.setMessage("Username cannot be empty. Please provide a valid user..");
             throw exception;
         }
-        if (!ResourceUtils.isUserExist(userName)){
-            logger.error("User does not exist in the system. Please provide a valid user..");
-            AiravataSystemException exception = new AiravataSystemException();
-            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
-            exception.setMessage("User does not exist in the system. Please provide a valid user..");
-            throw exception;
-        }
         try {
+            if (!ResourceUtils.isUserExist(userName)){
+                logger.error("User does not exist in the system. Please provide a valid user..");
+                AiravataSystemException exception = new AiravataSystemException();
+                exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+                exception.setMessage("User does not exist in the system. Please provide a valid user..");
+                throw exception;
+            }
             List<ExperimentSummary> summaries = new ArrayList<ExperimentSummary>();
             registry = RegistryFactory.getDefaultRegistry();
             Map<String, String> filters = new HashMap<String, String>();
@@ -313,14 +313,14 @@ public class AiravataServerHandler implements Airavata.Iface {
             exception.setMessage("Username cannot be empty. Please provide a valid user..");
             throw exception;
         }
-        if (!ResourceUtils.isUserExist(userName)){
-            logger.error("User does not exist in the system. Please provide a valid user..");
-            AiravataSystemException exception = new AiravataSystemException();
-            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
-            exception.setMessage("User does not exist in the system. Please provide a valid user..");
-            throw exception;
-        }
         try {
+            if (!ResourceUtils.isUserExist(userName)){
+                logger.error("User does not exist in the system. Please provide a valid user..");
+                AiravataSystemException exception = new AiravataSystemException();
+                exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+                exception.setMessage("User does not exist in the system. Please provide a valid user..");
+                throw exception;
+            }
             List<ExperimentSummary> summaries = new ArrayList<ExperimentSummary>();
             registry = RegistryFactory.getDefaultRegistry();
             Map<String, String> filters = new HashMap<String, String>();
@@ -348,14 +348,14 @@ public class AiravataServerHandler implements Airavata.Iface {
             exception.setMessage("Username cannot be empty. Please provide a valid user..");
             throw exception;
         }
-        if (!ResourceUtils.isUserExist(userName)){
-            logger.error("User does not exist in the system. Please provide a valid user..");
-            AiravataSystemException exception = new AiravataSystemException();
-            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
-            exception.setMessage("User does not exist in the system. Please provide a valid user..");
-            throw exception;
-        }
         try {
+            if (!ResourceUtils.isUserExist(userName)){
+                logger.error("User does not exist in the system. Please provide a valid user..");
+                AiravataSystemException exception = new AiravataSystemException();
+                exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+                exception.setMessage("User does not exist in the system. Please provide a valid user..");
+                throw exception;
+            }
             List<ExperimentSummary> summaries = new ArrayList<ExperimentSummary>();
             registry = RegistryFactory.getDefaultRegistry();
             Map<String, String> filters = new HashMap<String, String>();
@@ -431,14 +431,14 @@ public class AiravataServerHandler implements Airavata.Iface {
             exception.setMessage("Username cannot be empty. Please provide a valid user..");
             throw exception;
         }
-        if (!ResourceUtils.isUserExist(userName)){
-            logger.error("User does not exist in the system. Please provide a valid user..");
-            AiravataSystemException exception = new AiravataSystemException();
-            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
-            exception.setMessage("User does not exist in the system. Please provide a valid user..");
-            throw exception;
-        }
         try {
+            if (!ResourceUtils.isUserExist(userName)){
+                logger.error("User does not exist in the system. Please provide a valid user..");
+                AiravataSystemException exception = new AiravataSystemException();
+                exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+                exception.setMessage("User does not exist in the system. Please provide a valid user..");
+                throw exception;
+            }
             List<Experiment> experiments = new ArrayList<Experiment>();
             registry = RegistryFactory.getDefaultRegistry();
             List<Object> list = registry.get(RegistryModelType.EXPERIMENT, Constants.FieldConstants.ExperimentConstants.USER_NAME, userName);
@@ -717,8 +717,8 @@ public class AiravataServerHandler implements Airavata.Iface {
      */
     @Override
     public boolean validateExperiment(String airavataExperimentId) throws InvalidRequestException, ExperimentNotFoundException, AiravataClientException, AiravataSystemException, TException {
-    	 registry = RegistryFactory.getDefaultRegistry();
      	try {
+            registry = RegistryFactory.getDefaultRegistry();
  			if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){
  			    throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
  			}
@@ -871,8 +871,8 @@ public class AiravataServerHandler implements Airavata.Iface {
      */
     @Override
     public void launchExperiment(String airavataExperimentId, String airavataCredStoreToken) throws InvalidRequestException, ExperimentNotFoundException, AiravataClientException, AiravataSystemException, LaunchValidationException, TException {
-    	 registry = RegistryFactory.getDefaultRegistry();
     	try {
+            registry = RegistryFactory.getDefaultRegistry();
 			if (!registry.isExist(RegistryModelType.EXPERIMENT, airavataExperimentId)){
 			    throw new ExperimentNotFoundException("Requested experiment id " + airavataExperimentId + " does not exist in the system..");
 			}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/ApplicationCatalogHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/ApplicationCatalogHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/ApplicationCatalogHandler.java
index 85357de..b3ce8fb 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/ApplicationCatalogHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/ApplicationCatalogHandler.java
@@ -54,7 +54,7 @@ import org.apache.airavata.registry.api.AiravataRegistry2;
 import org.apache.airavata.registry.api.AiravataRegistryFactory;
 import org.apache.airavata.registry.api.AiravataUser;
 import org.apache.airavata.registry.api.Gateway;
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.apache.airavata.schemas.gfac.ExportProperties;
 import org.apache.airavata.schemas.gfac.GlobusHostType;
 import org.apache.airavata.schemas.gfac.GsisshHostType;
@@ -67,7 +67,7 @@ public class ApplicationCatalogHandler implements Iface {
     private static final Logger logger = LoggerFactory.getLogger(AiravataServerHandler.class);
 
 	AiravataRegistry2 registry;
-	private AiravataRegistry2 getRegistry() throws RegistryException, AiravataConfigurationException{
+	private AiravataRegistry2 getRegistry() throws RegException, AiravataConfigurationException{
 		 if (registry==null){
 			 registry = AiravataRegistryFactory.getRegistry(new Gateway("default"), new AiravataUser("admin"));
 		 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/TestCreateLaunchExperiment.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/TestCreateLaunchExperiment.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/TestCreateLaunchExperiment.java
index 8dc907b..666e140 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/TestCreateLaunchExperiment.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/TestCreateLaunchExperiment.java
@@ -110,10 +110,12 @@ public class TestCreateLaunchExperiment {
 //                }
 //            }
 
-            for (int i = 0; i < 100 ; i++){
+            for (int i = 0; i < 500 ; i++){
                 long time = System.currentTimeMillis();
                 List<Experiment> experiments = getExperimentsForUser(airavata, "admin");
-                System.out.println("Experiment count : " + experiments.size());
+                int count = i+1;
+//                System.out.println("Experiment count : " + experiments.size());
+                System.out.println("iteration : " + String.valueOf(count));
                 System.out.println(System.currentTimeMillis() - time);
             }
 //            List<Experiment> experiments = getExperimentsForUser(airavata, "admin");

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
----------------------------------------------------------------------
diff --git a/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java b/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
index 235c6e4..d516918 100644
--- a/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
+++ b/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
@@ -58,7 +58,7 @@ import org.apache.airavata.registry.api.AiravataRegistryFactory;
 import org.apache.airavata.registry.api.AiravataUser;
 import org.apache.airavata.registry.api.Gateway;
 import org.apache.airavata.registry.api.PasswordCallback;
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.apache.airavata.workflow.model.wf.WorkflowInput;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -107,7 +107,7 @@ public class AiravataClient extends Observable implements AiravataAPI {
 
 	private static HashMap<String, String> createConfig(URI registryUrl, String gateway,
 			String username, String password) throws RepositoryException,
-			RegistryException, AiravataConfigurationException {
+            RegException, AiravataConfigurationException {
 		HashMap<String, String> config = new HashMap<String, String>();
 		if (registryUrl != null) {
 			config.put(AiravataClient.REGISTRY, registryUrl.toString());
@@ -291,7 +291,7 @@ public class AiravataClient extends Observable implements AiravataAPI {
 	}
 
 	public AiravataRegistry2 getRegistryClient()
-			throws AiravataConfigurationException, RegistryException {
+			throws AiravataConfigurationException, RegException {
 		if (registry == null) {
 			registry = getRegistry(getRegitryURI(), getGateway(),
 					getCurrentUser(), getCallBack());
@@ -301,7 +301,7 @@ public class AiravataClient extends Observable implements AiravataAPI {
 
 	public static AiravataRegistry2 getRegistry(URI registryURI,
 			String gateway, String username, PasswordCallback callback)
-			throws RegistryException, AiravataConfigurationException {
+			throws RegException, AiravataConfigurationException {
 		return AiravataRegistryFactory.getRegistry(registryURI, new Gateway(
 				gateway), new AiravataUser(username), callback);
 	}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/airavata-client/src/main/java/org/apache/airavata/client/api/CredentialStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/airavata-client/src/main/java/org/apache/airavata/client/api/CredentialStoreManager.java b/modules/airavata-client/src/main/java/org/apache/airavata/client/api/CredentialStoreManager.java
index b110abd..418c944 100644
--- a/modules/airavata-client/src/main/java/org/apache/airavata/client/api/CredentialStoreManager.java
+++ b/modules/airavata-client/src/main/java/org/apache/airavata/client/api/CredentialStoreManager.java
@@ -22,7 +22,6 @@
 package org.apache.airavata.client.api;
 
 import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
-import org.apache.airavata.registry.api.exception.RegistryException;
 
 public interface CredentialStoreManager {
 
@@ -31,7 +30,7 @@ public interface CredentialStoreManager {
 	 * @param String gatewayId
 	 * @param String tokenId
 	 * @return a boolean (true is credential exists, false if not)
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
 	public boolean isCredentialExist(String gatewayId, String tokenId) throws AiravataAPIInvocationException;
 	
@@ -40,7 +39,7 @@ public interface CredentialStoreManager {
 	 * @param String gatewayId
 	 * @param String tokenId
 	 * @return String The public key of the credential
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
 	public String getCredentialPublicKey(String gatewayId, String tokenId) throws AiravataAPIInvocationException;
 	
@@ -50,7 +49,7 @@ public interface CredentialStoreManager {
 	 * @param String gatewayId
 	 * @param String tokenId
 	 * @return String The public key of the credential
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
 	public String createCredential(String gatewayId, String tokenId) throws AiravataAPIInvocationException;
 	
@@ -61,7 +60,7 @@ public interface CredentialStoreManager {
 	 * @param String tokenId
 	 * @param String username
 	 * @return String The public key of the credential
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
 	public String createCredential(String gatewayId, String tokenId, String username) throws AiravataAPIInvocationException;
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ProvenanceManager.java
----------------------------------------------------------------------
diff --git a/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ProvenanceManager.java b/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ProvenanceManager.java
index d1d4c38..3c0d5ec 100644
--- a/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ProvenanceManager.java
+++ b/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ProvenanceManager.java
@@ -26,7 +26,6 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
-import org.apache.airavata.registry.api.exception.RegistryException;
 import org.apache.airavata.registry.api.workflow.ApplicationJobStatusData;
 import org.apache.airavata.registry.api.workflow.ExperimentData;
 import org.apache.airavata.registry.api.workflow.ExperimentMetadata;
@@ -372,7 +371,7 @@ public interface ProvenanceManager {
       * Returns <code>true</code> if a Application job data is existing in Airavata
       * @param jobId
       * @return
-      * @throws RegistryException
+      * @throws org.apache.airavata.registry.api.exception.RegException
       */
      public boolean isApplicationJobExists(String jobId) throws AiravataAPIInvocationException;
      
@@ -403,7 +402,7 @@ public interface ProvenanceManager {
 	 * Update the status of the job for the current server time
 	 * @param jobId
 	 * @param status
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
      public void updateApplicationJobStatus(String jobId, ApplicationJobStatus status) throws AiravataAPIInvocationException;
      

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ApplicationManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ApplicationManagerImpl.java b/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ApplicationManagerImpl.java
index 1fea53d..804ca40 100644
--- a/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ApplicationManagerImpl.java
+++ b/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ApplicationManagerImpl.java
@@ -34,8 +34,8 @@ import org.apache.airavata.common.exception.AiravataConfigurationException;
 import org.apache.airavata.commons.gfac.type.ApplicationDescription;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
-import org.apache.airavata.registry.api.exception.RegistryException;
-import org.apache.airavata.registry.api.exception.UnimplementedRegistryOperationException;
+import org.apache.airavata.registry.api.exception.RegException;
+import org.apache.airavata.registry.api.exception.UnimplementedRegOperationException;
 
 public class ApplicationManagerImpl implements ApplicationManager {
 	private AiravataClient client;
@@ -93,7 +93,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
             throw new DescriptorAlreadyExistsException("Service descriptor "
                     + serviceDescription.getType().getName()
                     + " already exists.", e);
-        } catch (RegistryException e) {
+        } catch (RegException e) {
             throw new AiravataAPIInvocationException("An internal error occurred while trying to add service descriptor"
                     + serviceDescription.getType().getName(),
                     e);
@@ -108,7 +108,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
     public void updateServiceDescription(ServiceDescription serviceDescription) throws AiravataAPIInvocationException {
         try {
             getClient().getRegistryClient().updateServiceDescriptor(serviceDescription);
-        } catch (RegistryException e) {
+        } catch (RegException e) {
             throw new AiravataAPIInvocationException("An internal error occurred while trying to add service descriptor"
                     + serviceDescription.getType().getName(),
                     e);
@@ -134,7 +134,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
 	@Override
 	public List<ServiceDescription> searchServiceDescription(String nameRegEx)
 			throws AiravataAPIInvocationException {
-		throw new AiravataAPIInvocationException(new UnimplementedRegistryOperationException());
+		throw new AiravataAPIInvocationException(new UnimplementedRegOperationException());
 	}
 
 	@Override
@@ -178,7 +178,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
                     applicationDeploymentDescription.getType().getApplicationName().getStringValue()
                     + " already associated to host " + hostDescription.getType().getHostName()
                     + " and service " + serviceDescription.getType().getName(), e);
-        } catch (RegistryException e) {
+        } catch (RegException e) {
 
             throw new AiravataAPIInvocationException("An internal error occurred while trying to add " +
                     "application descriptor " +
@@ -204,7 +204,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
         try {
             getClient().getRegistryClient().updateApplicationDescriptor(serviceDescription.getType().getName(),
                     hostDescription.getType().getHostName(), applicationDeploymentDescription);
-        } catch (RegistryException e) {
+        } catch (RegException e) {
 
             throw new AiravataAPIInvocationException("An internal error occurred while trying to add " +
                     "application descriptor " +
@@ -227,7 +227,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
 	public List<ApplicationDescription> searchApplicationDescription(
             String serviceName, String hostName)
 			throws AiravataAPIInvocationException {
-		throw new AiravataAPIInvocationException(new UnimplementedRegistryOperationException());
+		throw new AiravataAPIInvocationException(new UnimplementedRegOperationException());
 	}
 
 	@Override
@@ -244,7 +244,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
 	public List<ApplicationDescription> searchApplicationDescription(
             String serviceName, String hostName, String applicationName)
 			throws AiravataAPIInvocationException {
-		throw new AiravataAPIInvocationException(new UnimplementedRegistryOperationException());
+		throw new AiravataAPIInvocationException(new UnimplementedRegOperationException());
 	}
 
 	@Override
@@ -319,7 +319,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
         } catch (org.apache.airavata.registry.api.exception.gateway.DescriptorAlreadyExistsException e) {
             throw new DescriptorAlreadyExistsException("Host descriptor " + host.getType().getHostName()
                     + " already exists.", e);
-        } catch (RegistryException e) {
+        } catch (RegException e) {
             throw new AiravataAPIInvocationException("An internal error occurred while trying to add host descriptor"
                     + host.getType().getHostName(),
                     e);
@@ -335,7 +335,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
     public void updateHostDescription(HostDescription host) throws AiravataAPIInvocationException {
         try {
             getClient().getRegistryClient().updateHostDescriptor(host);
-        } catch (RegistryException e) {
+        } catch (RegException e) {
             throw new AiravataAPIInvocationException("An internal error occurred while trying to add host descriptor"
                     + host.getType().getHostName(),
                     e);
@@ -350,7 +350,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
     @Override
 	public List<HostDescription> searchHostDescription(String regExName)
 			throws AiravataAPIInvocationException {
-		throw new AiravataAPIInvocationException(new UnimplementedRegistryOperationException());
+		throw new AiravataAPIInvocationException(new UnimplementedRegOperationException());
 	}
 
 	@Override
@@ -366,7 +366,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
 	@Override
 	public boolean deployServiceOnHost(String serviceName, String hostName)
 			throws AiravataAPIInvocationException {
-		throw new AiravataAPIInvocationException(new UnimplementedRegistryOperationException());
+		throw new AiravataAPIInvocationException(new UnimplementedRegOperationException());
 	}
 
     @Override

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ProvenanceManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ProvenanceManagerImpl.java b/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ProvenanceManagerImpl.java
index 293bca8..d311fbf 100644
--- a/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ProvenanceManagerImpl.java
+++ b/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ProvenanceManagerImpl.java
@@ -32,7 +32,7 @@ import org.apache.airavata.client.api.ProvenanceManager;
 import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
 import org.apache.airavata.common.exception.AiravataConfigurationException;
 import org.apache.airavata.registry.api.AiravataExperiment;
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.apache.airavata.registry.api.workflow.ApplicationJob;
 import org.apache.airavata.registry.api.workflow.ApplicationJob.ApplicationJobStatus;
 import org.apache.airavata.registry.api.workflow.ApplicationJobStatusData;
@@ -498,7 +498,7 @@ public class ProvenanceManagerImpl implements ProvenanceManager {
     public void updateWorkflowNodeGramData(WorkflowNodeGramData data) throws AiravataAPIInvocationException {
         try {
             client.getRegistryClient().updateWorkflowNodeGramData(data);
-        } catch (RegistryException e) {
+        } catch (RegException e) {
             throw new AiravataAPIInvocationException(e);
         } catch (AiravataConfigurationException e) {
             throw new AiravataAPIInvocationException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java b/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java
index 608db5a..484fd57 100644
--- a/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java
+++ b/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/WorkflowManagerImpl.java
@@ -33,7 +33,7 @@ import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
 import org.apache.airavata.client.api.exception.WorkflowAlreadyExistsException;
 import org.apache.airavata.common.exception.AiravataConfigurationException;
 import org.apache.airavata.common.utils.XMLUtil;
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.apache.airavata.registry.api.exception.worker.UserWorkflowAlreadyExistsException;
 import org.apache.airavata.workflow.model.wf.Workflow;
 import org.apache.airavata.workflow.model.wf.WorkflowData;
@@ -111,7 +111,7 @@ public class WorkflowManagerImpl implements WorkflowManager {
             throw new WorkflowAlreadyExistsException("Workflow " +
                     workflow.getName()
                     + " already exists in the system.", e);
-        } catch (RegistryException e) {
+        } catch (RegException e) {
             throw new AiravataAPIInvocationException("An internal error occurred while adding workflow " +
                     workflow.getName(), e);
         } catch (AiravataConfigurationException e) {
@@ -122,7 +122,7 @@ public class WorkflowManagerImpl implements WorkflowManager {
         if (owner == null) {
             try {
                 getClient().getRegistryClient().publishWorkflow(workflow.getName());
-            } catch (RegistryException e) {
+            } catch (RegException e) {
                 throw new AiravataAPIInvocationException("An internal error occurred while adding workflow " +
                         workflow.getName(), e);
             } catch (AiravataConfigurationException e) {
@@ -136,7 +136,7 @@ public class WorkflowManagerImpl implements WorkflowManager {
             throws AiravataAPIInvocationException {
         try {
             getClient().getRegistryClient().updateWorkflow(workflow.getName(), workflowAsString);
-        } catch (RegistryException e) {
+        } catch (RegException e) {
             throw new AiravataAPIInvocationException("An internal error occurred while adding workflow " +
                     workflow.getName(), e);
         } catch (AiravataConfigurationException e) {
@@ -147,7 +147,7 @@ public class WorkflowManagerImpl implements WorkflowManager {
         if (owner == null) {
             try {
                 getClient().getRegistryClient().publishWorkflow(workflow.getName());
-            } catch (RegistryException e) {
+            } catch (RegException e) {
                 throw new AiravataAPIInvocationException("An internal error occurred while adding workflow " +
                         workflow.getName(), e);
             } catch (AiravataConfigurationException e) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java b/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
index 923163b..1b8d1e8 100644
--- a/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
+++ b/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
@@ -32,10 +32,7 @@ import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
 import org.apache.airavata.registry.api.AiravataRegistryFactory;
 import org.apache.airavata.registry.api.AiravataUser;
 import org.apache.airavata.registry.api.Gateway;
-import org.apache.airavata.registry.api.exception.RegistryAccessorInstantiateException;
-import org.apache.airavata.registry.api.exception.RegistryAccessorInvalidException;
-import org.apache.airavata.registry.api.exception.RegistryAccessorUndefinedException;
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.apache.airavata.registry.cpi.Registry;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
@@ -52,8 +49,8 @@ public class GfacServerHandler implements GfacService.Iface {
     private String airavataUserName;
 
     public GfacServerHandler() {
-        registry = RegistryFactory.getDefaultRegistry();
         try {
+            registry = RegistryFactory.getDefaultRegistry();
             setGatewayProperties();
         }catch (Exception e){
            logger.error("Error initialising GFAC",e);
@@ -120,7 +117,7 @@ public class GfacServerHandler implements GfacService.Iface {
             return new GFacImpl(registry, null,
                                 AiravataRegistryFactory.getRegistry(new Gateway(getGatewayName()),
                                         new AiravataUser(getAiravataUserName())));
-        } catch (RegistryException e) {
+        } catch (RegException e) {
             throw new TException("Error initializing gfac instance",e);
         } catch (AiravataConfigurationException e) {
             throw new TException("Error initializing gfac instance",e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/gfac/airavata-gfac-service/src/test/java/org/apache/airavata/gfac/client/GfacClientFactoryTest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/airavata-gfac-service/src/test/java/org/apache/airavata/gfac/client/GfacClientFactoryTest.java b/modules/gfac/airavata-gfac-service/src/test/java/org/apache/airavata/gfac/client/GfacClientFactoryTest.java
index 4207f05..8d64046 100644
--- a/modules/gfac/airavata-gfac-service/src/test/java/org/apache/airavata/gfac/client/GfacClientFactoryTest.java
+++ b/modules/gfac/airavata-gfac-service/src/test/java/org/apache/airavata/gfac/client/GfacClientFactoryTest.java
@@ -50,10 +50,10 @@ public class GfacClientFactoryTest {
         try {
             service = (new GfacServer());
             service.start();
+            registry = RegistryFactory.getDefaultRegistry();
         } catch (Exception e) {
             e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
         }
-        registry = RegistryFactory.getDefaultRegistry();
         AiravataUtils.setExecutionAsServer();
         documentCreator = new DocumentCreator(getAiravataAPI());
         documentCreator.createLocalHostDocs();

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/gfac/airavata-gfac-service/src/test/java/org/apache/airavata/gfac/client/util/Initialize.java
----------------------------------------------------------------------
diff --git a/modules/gfac/airavata-gfac-service/src/test/java/org/apache/airavata/gfac/client/util/Initialize.java b/modules/gfac/airavata-gfac-service/src/test/java/org/apache/airavata/gfac/client/util/Initialize.java
index 6e0e7e6..0046204 100644
--- a/modules/gfac/airavata-gfac-service/src/test/java/org/apache/airavata/gfac/client/util/Initialize.java
+++ b/modules/gfac/airavata-gfac-service/src/test/java/org/apache/airavata/gfac/client/util/Initialize.java
@@ -25,6 +25,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.resources.*;
 import org.apache.airavata.registry.api.exception.RegistrySettingsException;
 import org.apache.airavata.registry.api.util.RegistrySettings;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.apache.derby.drda.NetworkServerControl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -158,6 +159,8 @@ public class Initialize {
 
         } catch (RegistrySettingsException e) {
             logger.error("Unable to read properties", e);
+        } catch (RegistryException e) {
+            logger.error("Error while saving data to registry", e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractHandler.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractHandler.java
index 0049c3c..81d2072 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractHandler.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractHandler.java
@@ -25,6 +25,7 @@ import org.apache.airavata.gfac.core.cpi.GFacImpl;
 import org.apache.airavata.gfac.core.notification.MonitorPublisher;
 import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
 import org.apache.airavata.registry.cpi.Registry;
+import org.apache.airavata.registry.cpi.RegistryException;
 
 public abstract class AbstractHandler implements GFacHandler {
 	protected Registry registry = null;
@@ -38,7 +39,11 @@ public abstract class AbstractHandler implements GFacHandler {
     public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
 		registry = jobExecutionContext.getRegistry();
         if(registry == null){
-            registry = RegistryFactory.getDefaultRegistry();
+            try {
+                registry = RegistryFactory.getDefaultRegistry();
+            } catch (RegistryException e) {
+                throw new GFacHandlerException("unable to create registry instance", e);
+            }
         }
 	}
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/provider/AbstractProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/provider/AbstractProvider.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/provider/AbstractProvider.java
index afc1894..7b24eb9 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/provider/AbstractProvider.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/provider/AbstractProvider.java
@@ -30,6 +30,7 @@ import org.apache.airavata.model.workspace.experiment.JobDetails;
 import org.apache.airavata.model.workspace.experiment.JobStatus;
 import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
 import org.apache.airavata.registry.cpi.Registry;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,7 +51,11 @@ public abstract class AbstractProvider implements GFacProvider{
     public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
         log.debug("Initializing " + this.getClass().getName());
         if(jobExecutionContext.getRegistry() == null) {
-            registry = RegistryFactory.getDefaultRegistry();
+            try {
+                registry = RegistryFactory.getDefaultRegistry();
+            } catch (RegistryException e) {
+                throw new GFacException("Unable to create registry instance", e);
+            }
         }else{
             registry = jobExecutionContext.getRegistry();
         }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java b/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
index 3dd0625..2c66293 100644
--- a/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
+++ b/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
@@ -64,6 +64,8 @@ public class OrchestratorServerHandler implements OrchestratorService.Iface {
             orchestrator.initialize();
         }catch (OrchestratorException e) {
             e.printStackTrace();
+        } catch (RegistryException e) {
+            e.printStackTrace();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactoryTest.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactoryTest.java b/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactoryTest.java
index f625489..67b72f2 100644
--- a/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactoryTest.java
+++ b/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/OrchestratorClientFactoryTest.java
@@ -50,10 +50,10 @@ public class OrchestratorClientFactoryTest {
         try {
             service = (new OrchestratorServer());
             service.start();
+            registry = RegistryFactory.getDefaultRegistry();
         } catch (Exception e) {
             e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
         }
-        registry = RegistryFactory.getDefaultRegistry();
         AiravataUtils.setExecutionAsServer();
         documentCreator = new DocumentCreator(getAiravataAPI());
         documentCreator.createLocalHostDocs();

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/util/Initialize.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/util/Initialize.java b/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/util/Initialize.java
index 16d10f9..8301ac7 100644
--- a/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/util/Initialize.java
+++ b/modules/orchestrator/airavata-orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/util/Initialize.java
@@ -25,6 +25,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.resources.*;
 import org.apache.airavata.registry.api.exception.RegistrySettingsException;
 import org.apache.airavata.registry.api.util.RegistrySettings;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.apache.derby.drda.NetworkServerControl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -158,6 +159,8 @@ public class Initialize {
 
         } catch (RegistrySettingsException e) {
             logger.error("Unable to read properties", e);
+        } catch (RegistryException e) {
+            logger.error("Error while saving data to registry", e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/orchestrator/orchestrator-client-sdks/src/main/java/org/apache/airavata/orchestrator/client/sample/OrchestratorClientSample.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-client-sdks/src/main/java/org/apache/airavata/orchestrator/client/sample/OrchestratorClientSample.java b/modules/orchestrator/orchestrator-client-sdks/src/main/java/org/apache/airavata/orchestrator/client/sample/OrchestratorClientSample.java
index e7c5a13..ec026d4 100644
--- a/modules/orchestrator/orchestrator-client-sdks/src/main/java/org/apache/airavata/orchestrator/client/sample/OrchestratorClientSample.java
+++ b/modules/orchestrator/orchestrator-client-sdks/src/main/java/org/apache/airavata/orchestrator/client/sample/OrchestratorClientSample.java
@@ -35,6 +35,7 @@ import org.apache.airavata.orchestrator.cpi.OrchestratorService;
 import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
 import org.apache.airavata.registry.cpi.ParentDataType;
 import org.apache.airavata.registry.cpi.Registry;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.apache.thrift.TException;
 
 import java.util.ArrayList;
@@ -67,6 +68,8 @@ public class OrchestratorClientSample {
             storeExperimentDetail();
         } catch (ApplicationSettingsException e) {
             e.printStackTrace();
+        } catch (RegistryException e) {
+            e.printStackTrace();
         }
 
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
index 624ced7..2a8b27b 100644
--- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
+++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java
@@ -35,7 +35,7 @@ import org.apache.airavata.orchestrator.core.job.JobSubmitter;
 import org.apache.airavata.orchestrator.cpi.Orchestrator;
 import org.apache.airavata.orchestrator.cpi.impl.SimpleOrchestratorImpl;
 import org.apache.airavata.registry.api.AiravataRegistry2;
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -66,7 +66,7 @@ public class OrchestratorUtils {
         String resourceHostId = taskScheduling.getResourceHostId();
         try {
             return registry.getHostDescriptor(resourceHostId);
-        } catch (RegistryException e) {
+        } catch (RegException e) {
             throw new OrchestratorException(e);
         }
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/impl/SimpleAppDataValidator.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/impl/SimpleAppDataValidator.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/impl/SimpleAppDataValidator.java
index f5916d5..8847500 100644
--- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/impl/SimpleAppDataValidator.java
+++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/impl/SimpleAppDataValidator.java
@@ -28,6 +28,7 @@ import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
 import org.apache.airavata.orchestrator.core.validator.JobMetadataValidator;
 import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
 import org.apache.airavata.registry.cpi.Registry;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -37,7 +38,11 @@ public class SimpleAppDataValidator implements JobMetadataValidator {
     private Registry registry;
 
     public SimpleAppDataValidator() {
-        this.registry = RegistryFactory.getDefaultRegistry();
+        try {
+            this.registry = RegistryFactory.getDefaultRegistry();
+        } catch (RegistryException e) {
+            logger.error("Unable to initialize registry", e);
+        }
     }
 
     public ValidatorResult validate(Experiment experiment, WorkflowNodeDetails workflowNodeDetail, TaskDetails taskID) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/AbstractOrchestrator.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/AbstractOrchestrator.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/AbstractOrchestrator.java
index 7147ef9..5bbe4e6 100644
--- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/AbstractOrchestrator.java
+++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/AbstractOrchestrator.java
@@ -46,7 +46,8 @@ import org.apache.airavata.registry.api.AiravataRegistry2;
 import org.apache.airavata.registry.api.AiravataRegistryFactory;
 import org.apache.airavata.registry.api.AiravataUser;
 import org.apache.airavata.registry.api.Gateway;
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -116,7 +117,7 @@ public abstract class AbstractOrchestrator implements Orchestrator {
 
             /* initializing registry cpi */
             orchestratorContext.setNewRegistry(new RegistryImpl());
-        } catch (RegistryException e) {
+        } catch (RegException e) {
             logger.error("Failed to initializing Orchestrator");
             OrchestratorException orchestratorException = new OrchestratorException(e);
             throw orchestratorException;
@@ -130,7 +131,11 @@ public abstract class AbstractOrchestrator implements Orchestrator {
             throw orchestratorException;
 		} catch (ApplicationSettingsException e) {
 			throw new OrchestratorException(e);
-		}
+		} catch (RegistryException e) {
+            logger.error("Failed to initializing Orchestrator - Error initializing registry");
+            OrchestratorException orchestratorException = new OrchestratorException(e);
+            throw orchestratorException;
+        }
     }
 	
 	//get the registry URL and the credentials from the property file

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/Initialize.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/Initialize.java b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/Initialize.java
index ba68259..fe71df5 100644
--- a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/Initialize.java
+++ b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/Initialize.java
@@ -25,6 +25,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.resources.*;
 import org.apache.airavata.registry.api.exception.RegistrySettingsException;
 import org.apache.airavata.registry.api.util.RegistrySettings;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.apache.derby.drda.NetworkServerControl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -158,6 +159,8 @@ public class Initialize {
 
         } catch (RegistrySettingsException e) {
             logger.error("Unable to read properties", e);
+        } catch (RegistryException e) {
+            logger.error("Error while saving data to registry", e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/Resource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/Resource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/Resource.java
index 3897d2a..26b7371 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/Resource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/Resource.java
@@ -20,6 +20,8 @@
 */
 package org.apache.airavata.persistance.registry.jpa;
 
+import org.apache.airavata.registry.cpi.RegistryException;
+
 import java.util.List;
 
 public interface Resource {
@@ -28,14 +30,14 @@ public interface Resource {
      * @param type child resource type
      * @return associate child resource
      */
-    Resource create(ResourceType type);
+    Resource create(ResourceType type) throws RegistryException, RegistryException;
 
     /**
      * This method will remove the given child resource from the database
      * @param type child resource type
      * @param name child resource name
      */
-    void remove(ResourceType type, Object name);
+    void remove(ResourceType type, Object name) throws RegistryException;
 
     /**
      *  This method will return the given child resource from the database
@@ -43,19 +45,19 @@ public interface Resource {
      * @param name child resource name
      * @return associate child resource
      */
-    Resource get(ResourceType type, Object name);
+    Resource get(ResourceType type, Object name) throws RegistryException;
 
     /**
      * This method will list all the child resources for the given resource type
      * @param type child resource type
      * @return list of child resources of the given child resource type
      */
-    List<Resource> get(ResourceType type);
+    List<Resource> get(ResourceType type) throws RegistryException;
 
     /**
      * This method will save the resource to the database.
      */
-    void save();
+    void save() throws RegistryException;
 
     /**
      * This method will check whether an entry from the given resource type and resource name
@@ -64,6 +66,6 @@ public interface Resource {
      * @param name child resource name
      * @return whether the entry exists in the database or not
      */
-    boolean isExists(ResourceType type, Object name);
+    boolean isExists(ResourceType type, Object name) throws RegistryException;
 
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceUtils.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceUtils.java
index 9670c33..410a393 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceUtils.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceUtils.java
@@ -29,15 +29,13 @@ import java.util.concurrent.locks.ReentrantLock;
 
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityNotFoundException;
 import javax.persistence.Persistence;
 import javax.persistence.Query;
 
 import org.apache.airavata.persistance.registry.jpa.model.*;
 import org.apache.airavata.persistance.registry.jpa.resources.*;
 import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
-import org.apache.airavata.registry.api.exception.AiravataRegistryUninitializedException;
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -63,8 +61,8 @@ public class ResourceUtils {
             properties.put("openjpa.ConnectionProperties", connectionProperties);
             properties.put("openjpa.DynamicEnhancementAgent", "true");
             properties.put("openjpa.RuntimeUnenhancedClasses", "unsupported");
-            properties.put("openjpa.DataCache","true(CacheSize=5000)");
-            properties.put("openjpa.QueryCache","true(CacheSize=5000)");
+            properties.put("openjpa.DataCache","true(CacheSize=5000, SoftReferenceSize=0)");
+            properties.put("openjpa.QueryCache","true(CacheSize=5000, SoftReferenceSize=0)");
             properties.put("openjpa.RemoteCommitProvider","sjvm");
             properties.put("openjpa.Log","DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=INFO");
             properties.put("openjpa.ReadLockLevel", "none");
@@ -83,7 +81,7 @@ public class ResourceUtils {
      * @param gatewayName
      * @return
      */
-    public static Resource createGateway(String gatewayName){
+    public static Resource createGateway(String gatewayName) throws RegistryException {
         if (!isGatewayExist(gatewayName)) {
             GatewayResource gatewayResource = new GatewayResource();
             gatewayResource.setGatewayName(gatewayName);
@@ -93,7 +91,7 @@ public class ResourceUtils {
         }
     }
 
-    public static UserResource createUser(String username, String password){
+    public static UserResource createUser(String username, String password) throws RegistryException {
         if (!isUserExist(username)) {
             UserResource userResource = new UserResource();
             userResource.setUserName(username);
@@ -105,54 +103,97 @@ public class ResourceUtils {
 
     }
 
-    public static Resource getGateway(String gatewayName){
-        if (isGatewayExist(gatewayName)) {
-            EntityManager em = getEntityManager();
-            Gateway gateway = em.find(Gateway.class, gatewayName);
-            GatewayResource gatewayResource = (GatewayResource)Utils.getResource(ResourceType.GATEWAY, gateway);
-            em.close();
-            return gatewayResource;
+    public static Resource getGateway(String gatewayName) throws RegistryException{
+        EntityManager em = null;
+        try {
+            if (isGatewayExist(gatewayName)) {
+                em = getEntityManager();
+                Gateway gateway = em.find(Gateway.class, gatewayName);
+                GatewayResource gatewayResource = (GatewayResource)Utils.getResource(ResourceType.GATEWAY, gateway);
+                em.close();
+                return gatewayResource;
+            }
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
         }
         return null;
-
     }
 
-    public static void addUser (String userName, String password){
+    public static void addUser (String userName, String password) throws RegistryException{
         UserResource resource = new UserResource();
         resource.setUserName(userName);
         resource.setPassword(password);
         resource.save();
     }
 
-    public static boolean isUserExist (String username){
-        EntityManager em = getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator = new QueryGenerator(AbstractResource.USERS);
-        generator.setParameter(AbstractResource.UserConstants.USERNAME, username);
-        Query q = generator.selectQuery(em);
-        int size = q.getResultList().size();
-        em.getTransaction().commit();
-        em.close();
-        return size>0;
-    }
-    public static Resource getUser(String userName){
-        if (isUserExist(userName)) {
-            EntityManager em = getEntityManager();
-            Users user =  em.find(Users.class, userName);
-            UserResource userResource = (UserResource)Utils.getResource(ResourceType.USER, user);
+    public static boolean isUserExist (String username) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = getEntityManager();
+            em.getTransaction().begin();
+            QueryGenerator generator = new QueryGenerator(AbstractResource.USERS);
+            generator.setParameter(AbstractResource.UserConstants.USERNAME, username);
+            Query q = generator.selectQuery(em);
+            int size = q.getResultList().size();
+            em.getTransaction().commit();
             em.close();
-            return userResource;
+            return size>0;
+        } catch (Exception e){
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
+        }
+    }
+
+
+    public static Resource getUser(String userName) throws RegistryException{
+        EntityManager em = null;
+        try {
+            if (isUserExist(userName)) {
+                em = getEntityManager();
+                Users user =  em.find(Users.class, userName);
+                UserResource userResource = (UserResource)Utils.getResource(ResourceType.USER, user);
+                em.close();
+                return userResource;
+            }
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
         }
         return null;
 
     }
 
-    public static Resource getWorker(String gatewayName, String userName) {
-        EntityManager em = getEntityManager();
-        Gateway_Worker gatewayWorker = em.find(Gateway_Worker.class, new Gateway_Worker_PK(gatewayName, userName));
-        WorkerResource workerResource = (WorkerResource) Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
-        em.close();
-        return workerResource;
+    public static Resource getWorker(String gatewayName, String userName) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = getEntityManager();
+            Gateway_Worker gatewayWorker = em.find(Gateway_Worker.class, new Gateway_Worker_PK(gatewayName, userName));
+            WorkerResource workerResource = (WorkerResource) Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
+            em.close();
+            return workerResource;
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
+        }
+
+
     }
 
 
@@ -160,17 +201,27 @@ public class ResourceUtils {
      * @param gatewayName
      * @return
      */
-    public static boolean isGatewayExist(String gatewayName){
-
-        EntityManager em = getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator = new QueryGenerator(AbstractResource.GATEWAY);
-        generator.setParameter(AbstractResource.GatewayConstants.GATEWAY_NAME, gatewayName);
-        Query q = generator.selectQuery(em);
-        int size = q.getResultList().size();
-        em.getTransaction().commit();
-        em.close();
-		return size>0;
+    public static boolean isGatewayExist(String gatewayName) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = getEntityManager();
+            em.getTransaction().begin();
+            QueryGenerator generator = new QueryGenerator(AbstractResource.GATEWAY);
+            generator.setParameter(AbstractResource.GatewayConstants.GATEWAY_NAME, gatewayName);
+            Query q = generator.selectQuery(em);
+            int size = q.getResultList().size();
+            em.getTransaction().commit();
+            em.close();
+            return size>0;
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
+        }
+
     }
 
     /**
@@ -178,8 +229,9 @@ public class ResourceUtils {
      * @return
      */
     public static boolean removeGateway(String gatewayName) {
+        EntityManager em = null;
         try {
-            EntityManager em = getEntityManager();
+            em = getEntityManager();
             em.getTransaction().begin();
             QueryGenerator generator = new QueryGenerator(AbstractResource.GATEWAY);
             generator.setParameter(AbstractResource.GatewayConstants.GATEWAY_NAME, gatewayName);
@@ -191,18 +243,21 @@ public class ResourceUtils {
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             return false;
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
         }
-
-
     }
 
     /**
      * @param gatewayResource
      * @param userResource
      */
-    public static WorkerResource addGatewayWorker(GatewayResource gatewayResource, UserResource userResource) {
+    public static WorkerResource addGatewayWorker(GatewayResource gatewayResource, UserResource userResource) throws RegistryException{
+        EntityManager em = null;
         try {
-            EntityManager em = getEntityManager();
+            em = getEntityManager();
             em.getTransaction().begin();
             if (!isGatewayExist(gatewayResource.getGatewayName())){
                 gatewayResource.save();
@@ -218,12 +273,15 @@ public class ResourceUtils {
             em.persist(gatewayWorker);
             em.getTransaction().commit();
             em.close();
-            WorkerResource resource = (WorkerResource)Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
-            return resource;
-        } catch (Exception e) {
+            return (WorkerResource)Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
+        } catch (Exception e){
             logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
         }
-        return null;
     }
 
     /**
@@ -232,8 +290,9 @@ public class ResourceUtils {
      * @return
      */
     public static boolean removeGatewayWorker(GatewayResource gatewayResource, UserResource userResource) {
+        EntityManager em = null;
         try {
-            EntityManager em = getEntityManager();
+            em = getEntityManager();
             em.getTransaction().begin();
             QueryGenerator generator = new QueryGenerator(AbstractResource.GATEWAY_WORKER);
             generator.setParameter(AbstractResource.GatewayWorkerConstants.GATEWAY_NAME,
@@ -247,6 +306,10 @@ public class ResourceUtils {
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             return false;
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
         }
 
     }
@@ -257,20 +320,29 @@ public class ResourceUtils {
      */
     public static List<ConfigurationResource> getConfigurations(String configKey){
         List<ConfigurationResource> list = new ArrayList<ConfigurationResource>();
-        EntityManager em = getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator = new QueryGenerator(AbstractResource.CONFIGURATION);
-        generator.setParameter(AbstractResource.ConfigurationConstants.CONFIG_KEY, configKey);
-        Query q = generator.selectQuery(em);
-        List<?> resultList = q.getResultList();
-        if (resultList.size() != 0) {
-            for (Object result : resultList) {
-                ConfigurationResource configurationResource = createConfigurationResourceObject(result);
-                list.add(configurationResource);
+        EntityManager em = null;
+        try {
+            em = getEntityManager();
+            em.getTransaction().begin();
+            QueryGenerator generator = new QueryGenerator(AbstractResource.CONFIGURATION);
+            generator.setParameter(AbstractResource.ConfigurationConstants.CONFIG_KEY, configKey);
+            Query q = generator.selectQuery(em);
+            List<?> resultList = q.getResultList();
+            if (resultList.size() != 0) {
+                for (Object result : resultList) {
+                    ConfigurationResource configurationResource = createConfigurationResourceObject(result);
+                    list.add(configurationResource);
+                }
+            }
+            em.getTransaction().commit();
+            em.close();
+        }catch (Exception e) {
+            logger.error(e.getMessage(), e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
             }
         }
-        em.getTransaction().commit();
-        em.close();
         return list;
     }
 
@@ -318,46 +390,71 @@ public class ResourceUtils {
      * @param configkey
      * @param configValue
      */
-    public static void removeConfiguration(String configkey, String configValue){
+    public static void removeConfiguration(String configkey, String configValue) throws RegistryException{
         QueryGenerator queryGenerator = new QueryGenerator(AbstractResource.CONFIGURATION);
         queryGenerator.setParameter(AbstractResource.ConfigurationConstants.CONFIG_KEY, configkey);
         queryGenerator.setParameter(AbstractResource.ConfigurationConstants.CONFIG_VAL, configValue);
-        if(isConfigurationExists(configkey, configValue)){
-            EntityManager em = getEntityManager();
-            em.getTransaction().begin();
-            Query q = queryGenerator.deleteQuery(em);
-            q.executeUpdate();
-            em.getTransaction().commit();
-            em.close();
+        EntityManager em = null;
+        try {
+            if(isConfigurationExists(configkey, configValue)){
+                em = getEntityManager();
+                em.getTransaction().begin();
+                Query q = queryGenerator.deleteQuery(em);
+                q.executeUpdate();
+                em.getTransaction().commit();
+                em.close();
+            }
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
         }
     }
 
     /**
      * @param configkey
      */
-    public static void removeConfiguration(String configkey){
+    public static void removeConfiguration(String configkey) throws RegistryException{
         QueryGenerator queryGenerator = new QueryGenerator(AbstractResource.CONFIGURATION);
         queryGenerator.setParameter(AbstractResource.ConfigurationConstants.CONFIG_KEY, configkey);
-        if(isConfigurationExist(configkey)){
-            EntityManager em = getEntityManager();
-            em.getTransaction().begin();
-            Query q = queryGenerator.deleteQuery(em);
-            q.executeUpdate();
-            em.getTransaction().commit();
-            em.close();
+        EntityManager em = null;
+        try {
+            if(isConfigurationExist(configkey)){
+                em = getEntityManager();
+                em.getTransaction().begin();
+                Query q = queryGenerator.deleteQuery(em);
+                q.executeUpdate();
+                em.getTransaction().commit();
+                em.close();
+            }
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
         }
     }
 
-    public static boolean isConfigurationExists(String configKey, String configVal){
+    public static boolean isConfigurationExists(String configKey, String configVal) throws RegistryException{
+        EntityManager em = null;
         try{
             //Currently categoryID is hardcoded value
-            EntityManager em = ResourceUtils.getEntityManager();
+            em = ResourceUtils.getEntityManager();
             Configuration existing = em.find(Configuration.class, new Configuration_PK(configKey, configVal, AbstractResource.ConfigurationConstants.CATEGORY_ID_DEFAULT_VALUE));
             em.close();
             return existing!= null;
         } catch (Exception e){
             logger.error(e.getMessage(), e);
-            throw new EntityNotFoundException();
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
         }
     }
 


[03/11] adding proper entity manager closing and exception handling - AIRAVATA-1285

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java
index 559080f..1fed39c 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java
@@ -29,6 +29,7 @@ import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
 import org.apache.airavata.registry.cpi.utils.StatusType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.airavata.registry.cpi.RegistryException;
 
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
@@ -75,8 +76,7 @@ public class WorkflowNodeDetailResource extends AbstractResource {
         this.nodeName = nodeName;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type) throws RegistryException{
         switch (type){
             case TASK_DETAIL:
                 TaskDetailResource taskDetailResource = new TaskDetailResource();
@@ -104,230 +104,262 @@ public class WorkflowNodeDetailResource extends AbstractResource {
         }
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-        switch (type){
-            case TASK_DETAIL:
-                generator = new QueryGenerator(TASK_DETAIL);
-                generator.setParameter(TaskDetailConstants.TASK_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case ERROR_DETAIL:
-                generator = new QueryGenerator(ERROR_DETAIL);
-                generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case NODE_INPUT:
-                generator = new QueryGenerator(NODE_INPUT);
-                generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case NODE_OUTPUT:
-                generator = new QueryGenerator(NODE_OUTPUT);
-                generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.NODE_INSTANCE_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            default:
-                logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
-                break;
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            switch (type) {
+                case TASK_DETAIL:
+                    generator = new QueryGenerator(TASK_DETAIL);
+                    generator.setParameter(TaskDetailConstants.TASK_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case NODE_INPUT:
+                    generator = new QueryGenerator(NODE_INPUT);
+                    generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case NODE_OUTPUT:
+                    generator = new QueryGenerator(NODE_OUTPUT);
+                    generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.NODE_INSTANCE_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                default:
+                    logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
+                    break;
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator;
-        Query q;
-        switch (type) {
-            case TASK_DETAIL:
-                generator = new QueryGenerator(TASK_DETAIL);
-                generator.setParameter(TaskDetailConstants.TASK_ID, name);
-                q = generator.selectQuery(em);
-                TaskDetail taskDetail = (TaskDetail)q.getSingleResult();
-                TaskDetailResource taskDetailResource = (TaskDetailResource)Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
-                em.getTransaction().commit();
-                em.close();
-                return taskDetailResource;
-            case ERROR_DETAIL:
-                generator = new QueryGenerator(ERROR_DETAIL);
-                generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, name);
-                q = generator.selectQuery(em);
-                ErrorDetail errorDetail = (ErrorDetail)q.getSingleResult();
-                ErrorDetailResource errorDetailResource = (ErrorDetailResource)Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
-                em.getTransaction().commit();
-                em.close();
-                return errorDetailResource;
-            case NODE_INPUT:
-                generator = new QueryGenerator(NODE_INPUT);
-                generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
-                q = generator.selectQuery(em);
-                NodeInput nodeInput = (NodeInput)q.getSingleResult();
-                NodeInputResource nodeInputResource = (NodeInputResource)Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
-                em.getTransaction().commit();
-                em.close();
-                return nodeInputResource;
-            case NODE_OUTPUT:
-                generator = new QueryGenerator(NODE_OUTPUT);
-                generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
-                q = generator.selectQuery(em);
-                NodeOutput nodeOutput = (NodeOutput)q.getSingleResult();
-                NodeOutputResource nodeOutputResource = (NodeOutputResource)Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
-                em.getTransaction().commit();
-                em.close();
-                return nodeOutputResource;
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.NODE_INSTANCE_ID, name);
-                q = generator.selectQuery(em);
-                Status status = (Status)q.getSingleResult();
-                StatusResource statusResource = (StatusResource)Utils.getResource(ResourceType.STATUS, status);
-                em.getTransaction().commit();
-                em.close();
-                return statusResource;
-            default:
-                em.getTransaction().commit();
+    public Resource get(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            QueryGenerator generator;
+            Query q;
+            switch (type) {
+                case TASK_DETAIL:
+                    generator = new QueryGenerator(TASK_DETAIL);
+                    generator.setParameter(TaskDetailConstants.TASK_ID, name);
+                    q = generator.selectQuery(em);
+                    TaskDetail taskDetail = (TaskDetail) q.getSingleResult();
+                    TaskDetailResource taskDetailResource = (TaskDetailResource) Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
+                    em.getTransaction().commit();
+                    em.close();
+                    return taskDetailResource;
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, name);
+                    q = generator.selectQuery(em);
+                    ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
+                    ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+                    em.getTransaction().commit();
+                    em.close();
+                    return errorDetailResource;
+                case NODE_INPUT:
+                    generator = new QueryGenerator(NODE_INPUT);
+                    generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
+                    q = generator.selectQuery(em);
+                    NodeInput nodeInput = (NodeInput) q.getSingleResult();
+                    NodeInputResource nodeInputResource = (NodeInputResource) Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
+                    em.getTransaction().commit();
+                    em.close();
+                    return nodeInputResource;
+                case NODE_OUTPUT:
+                    generator = new QueryGenerator(NODE_OUTPUT);
+                    generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
+                    q = generator.selectQuery(em);
+                    NodeOutput nodeOutput = (NodeOutput) q.getSingleResult();
+                    NodeOutputResource nodeOutputResource = (NodeOutputResource) Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
+                    em.getTransaction().commit();
+                    em.close();
+                    return nodeOutputResource;
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.NODE_INSTANCE_ID, name);
+                    q = generator.selectQuery(em);
+                    Status status = (Status) q.getSingleResult();
+                    StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+                    em.getTransaction().commit();
+                    em.close();
+                    return statusResource;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
+            }
+        } catch (Exception e) {
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
+            }
         }
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    public List<Resource> get(ResourceType type) throws RegistryException{
         List<Resource> resourceList = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-        List results;
-        switch (type){
-            case TASK_DETAIL:
-                generator = new QueryGenerator(TASK_DETAIL);
-                generator.setParameter(TaskDetailConstants.NODE_INSTANCE_ID, nodeInstanceId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        TaskDetail taskDetail = (TaskDetail) result;
-                        TaskDetailResource taskDetailResource =
-                                (TaskDetailResource)Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
-                        resourceList.add(taskDetailResource);
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            List results;
+            switch (type) {
+                case TASK_DETAIL:
+                    generator = new QueryGenerator(TASK_DETAIL);
+                    generator.setParameter(TaskDetailConstants.NODE_INSTANCE_ID, nodeInstanceId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            TaskDetail taskDetail = (TaskDetail) result;
+                            TaskDetailResource taskDetailResource =
+                                    (TaskDetailResource) Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
+                            resourceList.add(taskDetailResource);
+                        }
                     }
-                }
-                break;
-            case ERROR_DETAIL:
-                generator = new QueryGenerator(ERROR_DETAIL);
-                generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, nodeInstanceId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        ErrorDetail errorDetail = (ErrorDetail) result;
-                        ErrorDetailResource errorDetailResource =
-                                (ErrorDetailResource)Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
-                        resourceList.add(errorDetailResource);
+                    break;
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, nodeInstanceId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            ErrorDetail errorDetail = (ErrorDetail) result;
+                            ErrorDetailResource errorDetailResource =
+                                    (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+                            resourceList.add(errorDetailResource);
+                        }
                     }
-                }
-                break;
-            case NODE_INPUT:
-                generator = new QueryGenerator(NODE_INPUT);
-                generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, nodeInstanceId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        NodeInput nodeInput = (NodeInput) result;
-                        NodeInputResource nodeInputResource =
-                                (NodeInputResource)Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
-                        resourceList.add(nodeInputResource);
+                    break;
+                case NODE_INPUT:
+                    generator = new QueryGenerator(NODE_INPUT);
+                    generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, nodeInstanceId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            NodeInput nodeInput = (NodeInput) result;
+                            NodeInputResource nodeInputResource =
+                                    (NodeInputResource) Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
+                            resourceList.add(nodeInputResource);
+                        }
                     }
-                }
-                break;
-            case NODE_OUTPUT:
-                generator = new QueryGenerator(NODE_OUTPUT);
-                generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, nodeInstanceId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        NodeOutput nodeOutput = (NodeOutput) result;
-                        NodeOutputResource nodeOutputResource =
-                                (NodeOutputResource)Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
-                        resourceList.add(nodeOutputResource);
+                    break;
+                case NODE_OUTPUT:
+                    generator = new QueryGenerator(NODE_OUTPUT);
+                    generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, nodeInstanceId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            NodeOutput nodeOutput = (NodeOutput) result;
+                            NodeOutputResource nodeOutputResource =
+                                    (NodeOutputResource) Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
+                            resourceList.add(nodeOutputResource);
+                        }
                     }
-                }
-                break;
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.NODE_INSTANCE_ID, nodeInstanceId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Status status = (Status) result;
-                        StatusResource statusResource =
-                                (StatusResource)Utils.getResource(ResourceType.STATUS, status);
-                        resourceList.add(statusResource);
+                    break;
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.NODE_INSTANCE_ID, nodeInstanceId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Status status = (Status) result;
+                            StatusResource statusResource =
+                                    (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+                            resourceList.add(statusResource);
+                        }
                     }
-                }
-                break;
-            default:
-                em.getTransaction().commit();
+                    break;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
+                    throw new UnsupportedOperationException();
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+//            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
-                throw new UnsupportedOperationException();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
         return resourceList;
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        WorkflowNodeDetail existingNode = em.find(WorkflowNodeDetail.class, nodeInstanceId);
-        em.close();
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            WorkflowNodeDetail existingNode = em.find(WorkflowNodeDetail.class, nodeInstanceId);
+            em.close();
 
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        WorkflowNodeDetail workflowNodeDetail = new WorkflowNodeDetail();
-        workflowNodeDetail.setNodeId(nodeInstanceId);
-        Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-        workflowNodeDetail.setExperiment(experiment);
-        workflowNodeDetail.setExpId(experimentResource.getExpID());
-        workflowNodeDetail.setCreationTime(creationTime);
-        workflowNodeDetail.setNodeName(nodeName);
-        if (existingNode != null){
-            existingNode.setExperiment(experiment);
-            existingNode.setExpId(experimentResource.getExpID());
-            existingNode.setCreationTime(creationTime);
-            existingNode.setNodeName(nodeName);
-            workflowNodeDetail = em.merge(existingNode);
-        }else {
-            em.merge(workflowNodeDetail);
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            WorkflowNodeDetail workflowNodeDetail = new WorkflowNodeDetail();
+            workflowNodeDetail.setNodeId(nodeInstanceId);
+            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+            workflowNodeDetail.setExperiment(experiment);
+            workflowNodeDetail.setExpId(experimentResource.getExpID());
+            workflowNodeDetail.setCreationTime(creationTime);
+            workflowNodeDetail.setNodeName(nodeName);
+            if (existingNode != null) {
+                existingNode.setExperiment(experiment);
+                existingNode.setExpId(experimentResource.getExpID());
+                existingNode.setCreationTime(creationTime);
+                existingNode.setNodeName(nodeName);
+                workflowNodeDetail = em.merge(existingNode);
+            } else {
+                em.merge(workflowNodeDetail);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
-    public List<NodeInputResource> getNodeInputs(){
+    public List<NodeInputResource> getNodeInputs() throws RegistryException{
         List<NodeInputResource> nodeInputResourceList = new ArrayList<NodeInputResource>();
         List<Resource> resources = get(ResourceType.NODE_INPUT);
         for (Resource resource : resources) {
@@ -337,7 +369,7 @@ public class WorkflowNodeDetailResource extends AbstractResource {
         return nodeInputResourceList;
     }
 
-    public List<NodeOutputResource> getNodeOutputs(){
+    public List<NodeOutputResource> getNodeOutputs() throws RegistryException{
         List<NodeOutputResource> outputResources = new ArrayList<NodeOutputResource>();
         List<Resource> resources = get(ResourceType.NODE_OUTPUT);
         for (Resource resource : resources) {
@@ -347,7 +379,7 @@ public class WorkflowNodeDetailResource extends AbstractResource {
         return outputResources;
     }
 
-    public StatusResource getWorkflowNodeStatus(){
+    public StatusResource getWorkflowNodeStatus() throws RegistryException{
         List<Resource> resources = get(ResourceType.STATUS);
         for (Resource resource : resources) {
             StatusResource nodeStatus = (StatusResource) resource;
@@ -361,7 +393,7 @@ public class WorkflowNodeDetailResource extends AbstractResource {
         return null;
     }
 
-    public StatusResource getTaskStatus(String taskId){
+    public StatusResource getTaskStatus(String taskId) throws RegistryException{
         List<Resource> resources = get(ResourceType.STATUS);
         for (Resource resource : resources) {
             StatusResource taskStatus = (StatusResource) resource;
@@ -376,7 +408,7 @@ public class WorkflowNodeDetailResource extends AbstractResource {
         return null;
     }
 
-    public List<TaskDetailResource> getTaskDetails(){
+    public List<TaskDetailResource> getTaskDetails() throws RegistryException{
         List<TaskDetailResource> taskDetailResources = new ArrayList<TaskDetailResource>();
         List<Resource> resources = get(ResourceType.TASK_DETAIL);
         for (Resource resource : resources) {
@@ -386,7 +418,7 @@ public class WorkflowNodeDetailResource extends AbstractResource {
         return taskDetailResources;
     }
 
-    public List<ErrorDetailResource> getErrorDetails(){
+    public List<ErrorDetailResource> getErrorDetails() throws RegistryException{
         List<ErrorDetailResource> errorDetails = new ArrayList<ErrorDetailResource>();
         List<Resource> resources = get(ResourceType.ERROR_DETAIL);
         for (Resource resource : resources) {
@@ -396,7 +428,7 @@ public class WorkflowNodeDetailResource extends AbstractResource {
         return errorDetails;
     }
 
-    public TaskDetailResource getTaskDetail(String taskId){
+    public TaskDetailResource getTaskDetail(String taskId) throws RegistryException{
         return (TaskDetailResource)get(ResourceType.TASK_DETAIL, taskId);
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
index 7c4ad7b..a66d743 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
@@ -25,6 +25,7 @@ import org.apache.airavata.model.workspace.Project;
 import org.apache.airavata.model.workspace.experiment.*;
 import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.resources.*;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,7 +35,7 @@ import java.util.List;
 public class ThriftDataModelConversion {
     private final static Logger logger = LoggerFactory.getLogger(ThriftDataModelConversion.class);
 
-    public static Project getProject (ProjectResource pr){
+    public static Project getProject (ProjectResource pr) throws RegistryException {
         if (pr != null) {
             Project project = new Project();
             project.setProjectID(pr.getId());
@@ -58,7 +59,7 @@ public class ThriftDataModelConversion {
     }
 
 
-    public static Experiment getExperiment(ExperimentResource experimentResource){
+    public static Experiment getExperiment(ExperimentResource experimentResource) throws RegistryException {
         if (experimentResource != null){
             Experiment experiment = new Experiment();
             if (experimentResource.getProject()!= null){
@@ -105,7 +106,7 @@ public class ThriftDataModelConversion {
         return null;
     }
 
-    public static ExperimentSummary getExperimentSummary(ExperimentResource experimentResource){
+    public static ExperimentSummary getExperimentSummary(ExperimentResource experimentResource) throws RegistryException {
         if (experimentResource != null){
             ExperimentSummary experimentSummary = new ExperimentSummary();
             if (experimentResource.getProject()!= null){
@@ -336,7 +337,7 @@ public class ThriftDataModelConversion {
         return wfNodeStatuses;
     }
 
-    public static WorkflowNodeDetails getWorkflowNodeDetails(WorkflowNodeDetailResource nodeDetailResource){
+    public static WorkflowNodeDetails getWorkflowNodeDetails(WorkflowNodeDetailResource nodeDetailResource) throws RegistryException {
         if (nodeDetailResource != null){
             WorkflowNodeDetails wfNode = new WorkflowNodeDetails();
             wfNode.setNodeInstanceId(nodeDetailResource.getNodeInstanceId());
@@ -356,7 +357,7 @@ public class ThriftDataModelConversion {
         return null;
     }
 
-    public static List<WorkflowNodeDetails> getWfNodeList (List<WorkflowNodeDetailResource> resources){
+    public static List<WorkflowNodeDetails> getWfNodeList (List<WorkflowNodeDetailResource> resources) throws RegistryException {
         List<WorkflowNodeDetails> workflowNodeDetailsList = new ArrayList<WorkflowNodeDetails>();
         if (resources != null && !resources.isEmpty()){
             for (WorkflowNodeDetailResource resource : resources){
@@ -366,7 +367,7 @@ public class ThriftDataModelConversion {
         return workflowNodeDetailsList;
     }
 
-    public static TaskDetails getTaskDetail (TaskDetailResource taskDetailResource){
+    public static TaskDetails getTaskDetail (TaskDetailResource taskDetailResource) throws RegistryException {
         if (taskDetailResource != null){
             TaskDetails taskDetails = new TaskDetails();
             String taskId = taskDetailResource.getTaskId();
@@ -402,7 +403,7 @@ public class ThriftDataModelConversion {
         return null;
     }
 
-    public static List<TaskDetails> getTaskDetailsList (List<TaskDetailResource> resources){
+    public static List<TaskDetails> getTaskDetailsList (List<TaskDetailResource> resources) throws RegistryException {
         List<TaskDetails> taskDetailsList = new ArrayList<TaskDetails>();
         if (resources != null && !resources.isEmpty()){
             for (TaskDetailResource resource : resources){
@@ -412,7 +413,7 @@ public class ThriftDataModelConversion {
         return taskDetailsList;
     }
 
-    public static List<JobDetails> getJobDetailsList(List<JobDetailResource> jobs){
+    public static List<JobDetails> getJobDetailsList(List<JobDetailResource> jobs) throws RegistryException {
         List<JobDetails> jobDetailsList = new ArrayList<JobDetails>();
         if (jobs != null && !jobs.isEmpty()){
             for (JobDetailResource resource : jobs){
@@ -423,7 +424,7 @@ public class ThriftDataModelConversion {
     }
 
 
-    public static JobDetails getJobDetail(JobDetailResource jobDetailResource){
+    public static JobDetails getJobDetail(JobDetailResource jobDetailResource) throws RegistryException {
         if (jobDetailResource != null){
             JobDetails jobDetails = new JobDetails();
             jobDetails.setJobID(jobDetailResource.getJobId());
@@ -467,7 +468,7 @@ public class ThriftDataModelConversion {
         return errorDetailsList;
     }
 
-    public static DataTransferDetails getDataTransferDetail (DataTransferDetailResource resource){
+    public static DataTransferDetails getDataTransferDetail (DataTransferDetailResource resource) throws RegistryException {
         if (resource != null){
             DataTransferDetails details = new DataTransferDetails();
             details.setTransferID(resource.getTransferId());
@@ -479,7 +480,7 @@ public class ThriftDataModelConversion {
         return null;
     }
 
-    public static List<DataTransferDetails> getDataTransferlList (List<DataTransferDetailResource> resources){
+    public static List<DataTransferDetails> getDataTransferlList (List<DataTransferDetailResource> resources) throws RegistryException {
         List<DataTransferDetails> transferDetailsList = new ArrayList<DataTransferDetails>();
         if (resources != null && !resources.isEmpty()){
             for (DataTransferDetailResource resource : resources){
@@ -490,7 +491,7 @@ public class ThriftDataModelConversion {
     }
 
 
-    public static UserConfigurationData getUserConfigData (ConfigDataResource resource){
+    public static UserConfigurationData getUserConfigData (ConfigDataResource resource) throws RegistryException {
         if (resource != null){
             UserConfigurationData data = new UserConfigurationData();
             data.setAiravataAutoSchedule(resource.isAiravataAutoSchedule());

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/util/Initialize.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/util/Initialize.java b/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/util/Initialize.java
index ec1c3bc..3d1014b 100644
--- a/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/util/Initialize.java
+++ b/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/util/Initialize.java
@@ -29,6 +29,7 @@ import org.apache.airavata.persistance.registry.jpa.resources.Utils;
 import org.apache.airavata.persistance.registry.jpa.resources.WorkerResource;
 import org.apache.airavata.registry.api.exception.RegistrySettingsException;
 import org.apache.airavata.registry.api.util.RegistrySettings;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.apache.derby.drda.NetworkServerControl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -167,6 +168,8 @@ public class Initialize {
           
         } catch (RegistrySettingsException e) {
             logger.error("Unable to read properties", e);
+        } catch (RegistryException e) {
+            logger.error("Error while saving data", e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java
index 7751da3..e93da37 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistry2.java
@@ -21,7 +21,7 @@
 
 package org.apache.airavata.registry.api;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
 import java.net.URI;
 import java.util.Observable;
@@ -42,9 +42,9 @@ public abstract class AiravataRegistry2 extends Observable implements Descriptor
 	
 	/**
 	 * Initialize the Airavata Registry
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
-	protected abstract void initialize() throws RegistryException;
+	protected abstract void initialize() throws RegException;
 	
 	public Gateway getGateway() {
 		return gateway;

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryConnectionDataProvider.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryConnectionDataProvider.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryConnectionDataProvider.java
index 4146c83..0a2f643 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryConnectionDataProvider.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryConnectionDataProvider.java
@@ -22,7 +22,6 @@
 package org.apache.airavata.registry.api;
 
 import org.apache.airavata.registry.api.exception.RegistrySettingsException;
-import org.apache.airavata.registry.api.exception.UnknownRegistryConnectionDataException;
 
 public interface AiravataRegistryConnectionDataProvider {
 	public void setIdentity(Gateway gateway, AiravataUser use);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java
index 5b5147a..e875898 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java
@@ -38,17 +38,17 @@ public class AiravataRegistryFactory {
 	 * @param gateway
 	 * @param user
 	 * @return
-	 * @throws RegistryAccessorNotFoundException
-	 * @throws RegistryAccessorUndefinedException
-	 * @throws RegistryAccessorInstantiateException
+	 * @throws org.apache.airavata.registry.api.exception.RegAccessorNotFoundException
+	 * @throws org.apache.airavata.registry.api.exception.RegAccessorUndefinedException
+	 * @throws org.apache.airavata.registry.api.exception.RegAccessorInstantiateException
 	 * @throws AiravataConfigurationException
-	 * @throws RegistryAccessorInvalidException
+	 * @throws org.apache.airavata.registry.api.exception.RegAccessorInvalidException
 	 */
 	public static AiravataRegistry2 getRegistry(Gateway gateway,
-			AiravataUser user) throws RegistryException,
-            RegistryAccessorUndefinedException,
-            RegistryAccessorInstantiateException,
-            AiravataConfigurationException, RegistryAccessorInvalidException {
+			AiravataUser user) throws RegException,
+            RegAccessorUndefinedException,
+            RegAccessorInstantiateException,
+            AiravataConfigurationException, RegAccessorInvalidException {
 		return getRegistry(null, gateway, user, null);
 	}
 	
@@ -60,17 +60,17 @@ public class AiravataRegistryFactory {
 	 * @param user
 	 * @param callback
 	 * @return
-	 * @throws RegistryAccessorNotFoundException
-	 * @throws RegistryAccessorUndefinedException
-	 * @throws RegistryAccessorInstantiateException
+	 * @throws org.apache.airavata.registry.api.exception.RegAccessorNotFoundException
+	 * @throws org.apache.airavata.registry.api.exception.RegAccessorUndefinedException
+	 * @throws org.apache.airavata.registry.api.exception.RegAccessorInstantiateException
 	 * @throws AiravataConfigurationException
-	 * @throws RegistryAccessorInvalidException
+	 * @throws org.apache.airavata.registry.api.exception.RegAccessorInvalidException
 	 */
 	public static AiravataRegistry2 getRegistry(URI connectionURI, Gateway gateway,
-			AiravataUser user, PasswordCallback callback) throws RegistryException,
-            RegistryAccessorUndefinedException,
-            RegistryAccessorInstantiateException,
-            AiravataConfigurationException, RegistryAccessorInvalidException {
+			AiravataUser user, PasswordCallback callback) throws RegException,
+            RegAccessorUndefinedException,
+            RegAccessorInstantiateException,
+            AiravataConfigurationException, RegAccessorInvalidException {
 		Object registryObj = getRegistryClass(REGISTRY_ACCESSOR_CLASS);
 		if (registryObj instanceof AiravataRegistry2) {
 			AiravataRegistry2 registry = (AiravataRegistry2) registryObj;
@@ -78,7 +78,7 @@ public class AiravataRegistryFactory {
 			registry.initialize();
 			return registry;
 		}
-		throw new RegistryAccessorInvalidException(registryObj.getClass().getName());
+		throw new RegAccessorInvalidException(registryObj.getClass().getName());
 	}
 
 	/***
@@ -87,21 +87,21 @@ public class AiravataRegistryFactory {
 	 *
 	 * @param registryClassKey
 	 * @return
-	 * @throws RegistryAccessorNotFoundException
-	 * @throws RegistryAccessorUndefinedException
-	 * @throws RegistryAccessorInstantiateException
+	 * @throws org.apache.airavata.registry.api.exception.RegAccessorNotFoundException
+	 * @throws org.apache.airavata.registry.api.exception.RegAccessorUndefinedException
+	 * @throws org.apache.airavata.registry.api.exception.RegAccessorInstantiateException
 	 * @throws AiravataConfigurationException
 	 */
 	public static Object getRegistryClass(String registryClassKey)
-			throws RegistryAccessorNotFoundException,
-			RegistryAccessorUndefinedException,
-			RegistryAccessorInstantiateException,
+			throws RegAccessorNotFoundException,
+            RegAccessorUndefinedException,
+            RegAccessorInstantiateException,
 			AiravataConfigurationException {
 
         try {
             String regAccessorClass = RegistrySettings.getSetting(registryClassKey);
             if (regAccessorClass == null) {
-                throw new RegistryAccessorUndefinedException();
+                throw new RegAccessorUndefinedException();
             } else {
                 try {
                     Class<?> classInstance = AiravataRegistryFactory.class
@@ -109,13 +109,13 @@ public class AiravataRegistryFactory {
                                     regAccessorClass);
                     return classInstance.newInstance();
                 } catch (ClassNotFoundException e) {
-                    throw new RegistryAccessorNotFoundException(
+                    throw new RegAccessorNotFoundException(
                             regAccessorClass, e);
                 } catch (InstantiationException e) {
-                    throw new RegistryAccessorInstantiateException(
+                    throw new RegAccessorInstantiateException(
                             regAccessorClass, e);
                 } catch (IllegalAccessException e) {
-                    throw new RegistryAccessorInstantiateException(
+                    throw new RegAccessorInstantiateException(
                             regAccessorClass, e);
                 }
             }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ConfigurationRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ConfigurationRegistry.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ConfigurationRegistry.java
index c560c26..1c1987e 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ConfigurationRegistry.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ConfigurationRegistry.java
@@ -25,35 +25,35 @@ import java.net.URI;
 import java.util.Date;
 import java.util.List;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
 public interface ConfigurationRegistry extends AiravataSubRegistry {
-	public Object getConfiguration(String key) throws RegistryException;
-	public List<Object> getConfigurationList(String key) throws RegistryException;
-	public void setConfiguration(String key, String value, Date expire) throws RegistryException;
-	public void addConfiguration(String key, String value, Date expire) throws RegistryException;
-	public void removeAllConfiguration(String key) throws RegistryException;
-	public void removeConfiguration(String key, String value) throws RegistryException;
+	public Object getConfiguration(String key) throws RegException;
+	public List<Object> getConfigurationList(String key) throws RegException;
+	public void setConfiguration(String key, String value, Date expire) throws RegException;
+	public void addConfiguration(String key, String value, Date expire) throws RegException;
+	public void removeAllConfiguration(String key) throws RegException;
+	public void removeConfiguration(String key, String value) throws RegException;
 	
-	public List<URI> getGFacURIs() throws RegistryException;
-	public List<URI> getWorkflowInterpreterURIs() throws RegistryException;
-	public URI getEventingServiceURI() throws RegistryException;
-	public URI getMessageBoxURI() throws RegistryException;
+	public List<URI> getGFacURIs() throws RegException;
+	public List<URI> getWorkflowInterpreterURIs() throws RegException;
+	public URI getEventingServiceURI() throws RegException;
+	public URI getMessageBoxURI() throws RegException;
 	
-	public void addGFacURI(URI uri) throws RegistryException;
-	public void addWorkflowInterpreterURI(URI uri) throws RegistryException;
-	public void setEventingURI(URI uri) throws RegistryException;
-	public void setMessageBoxURI(URI uri) throws RegistryException;
+	public void addGFacURI(URI uri) throws RegException;
+	public void addWorkflowInterpreterURI(URI uri) throws RegException;
+	public void setEventingURI(URI uri) throws RegException;
+	public void setMessageBoxURI(URI uri) throws RegException;
 
-	public void addGFacURI(URI uri, Date expire) throws RegistryException;
-	public void addWorkflowInterpreterURI(URI uri, Date expire) throws RegistryException;
-	public void setEventingURI(URI uri, Date expire) throws RegistryException;
-	public void setMessageBoxURI(URI uri, Date expire) throws RegistryException;
+	public void addGFacURI(URI uri, Date expire) throws RegException;
+	public void addWorkflowInterpreterURI(URI uri, Date expire) throws RegException;
+	public void setEventingURI(URI uri, Date expire) throws RegException;
+	public void setMessageBoxURI(URI uri, Date expire) throws RegException;
 	
-	public void removeGFacURI(URI uri) throws RegistryException;
-	public void removeAllGFacURI() throws RegistryException;
-	public void removeWorkflowInterpreterURI(URI uri) throws RegistryException;
-	public void removeAllWorkflowInterpreterURI() throws RegistryException;
-	public void unsetEventingURI() throws RegistryException;
-	public void unsetMessageBoxURI() throws RegistryException;
+	public void removeGFacURI(URI uri) throws RegException;
+	public void removeAllGFacURI() throws RegException;
+	public void removeWorkflowInterpreterURI(URI uri) throws RegException;
+	public void removeAllWorkflowInterpreterURI() throws RegException;
+	public void unsetEventingURI() throws RegException;
+	public void unsetMessageBoxURI() throws RegException;
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/CredentialRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/CredentialRegistry.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/CredentialRegistry.java
index 2cf1041..041c9ad 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/CredentialRegistry.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/CredentialRegistry.java
@@ -21,7 +21,7 @@
 
 package org.apache.airavata.registry.api;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
 public interface CredentialRegistry extends AiravataSubRegistry{
 
@@ -31,19 +31,19 @@ public interface CredentialRegistry extends AiravataSubRegistry{
 	 * @param String gatewayId
 	 * @param String tokenId
 	 * @return a boolean (true is credential exists, false if not)
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
 	
-	public boolean isCredentialExist(String gatewayId, String tokenId) throws RegistryException;
+	public boolean isCredentialExist(String gatewayId, String tokenId) throws RegException;
 	
 	/**
 	 * Get the public key for a credential in the credential store for given gateway and token
 	 * @param String gatewayId
 	 * @param String tokenId
 	 * @return String The public key of the credential
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
-	public String getCredentialPublicKey(String gatewayId, String tokenId) throws RegistryException;
+	public String getCredentialPublicKey(String gatewayId, String tokenId) throws RegException;
 	
 	/**
 	 * Creates a new SSH credential for given gateway and token, encrypts it with a randomly 
@@ -51,9 +51,9 @@ public interface CredentialRegistry extends AiravataSubRegistry{
 	 * @param String gatewayId
 	 * @param String tokenId
 	 * @return String The public key of the credential
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
-	public String createCredential(String gatewayId, String tokenId) throws RegistryException;
+	public String createCredential(String gatewayId, String tokenId) throws RegException;
 	
 	/**
 	 * Creates a new SSH credential for given gateway and token, encrypts it with the given password 
@@ -62,8 +62,8 @@ public interface CredentialRegistry extends AiravataSubRegistry{
 	 * @param String tokenId
 	 * @param String username
 	 * @return String The public key of the credential
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
-	public String createCredential(String gatewayId, String tokenId, String username) throws RegistryException;
+	public String createCredential(String gatewayId, String tokenId, String username) throws RegException;
     
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/DataRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/DataRegistry.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/DataRegistry.java
index 96290cd..fa0ed54 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/DataRegistry.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/DataRegistry.java
@@ -23,7 +23,7 @@ package org.apache.airavata.registry.api;
 
 import java.util.List;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.apache.airavata.commons.gfac.type.ActualParameter;
 
 public interface DataRegistry {
@@ -34,17 +34,17 @@ public interface DataRegistry {
      * @param workflowId
      * @param parameters
      * @return
-     * @throws RegistryException 
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public String saveOutput(String workflowId, List<ActualParameter> parameters) throws RegistryException;
+    public String saveOutput(String workflowId, List<ActualParameter> parameters) throws RegException;
 
     /**
      * Load output from workflow execution.
      * 
      * @param workflowId
      * @return List of parameters
-     * @throws RegistryException 
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public List<ActualParameter> loadOutput(String workflowId) throws RegistryException;
+    public List<ActualParameter> loadOutput(String workflowId) throws RegException;
 
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/DescriptorRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/DescriptorRegistry.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/DescriptorRegistry.java
index c3398c5..92bf424 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/DescriptorRegistry.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/DescriptorRegistry.java
@@ -25,7 +25,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.airavata.commons.gfac.type.ApplicationDescription;
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
 import org.apache.airavata.registry.api.exception.gateway.DescriptorAlreadyExistsException;
@@ -39,36 +39,36 @@ public interface DescriptorRegistry extends AiravataSubRegistry {
 	 */
 	
 	//---------Host Descriptor data------------
-	public boolean isHostDescriptorExists(String descriptorName)throws RegistryException;
-	public void addHostDescriptor(HostDescription descriptor) throws DescriptorAlreadyExistsException, RegistryException;
-	public void updateHostDescriptor(HostDescription descriptor)throws DescriptorDoesNotExistsException, RegistryException;
-	public HostDescription getHostDescriptor(String hostName)throws DescriptorDoesNotExistsException,MalformedDescriptorException, RegistryException;
-	public void removeHostDescriptor(String hostName)throws DescriptorDoesNotExistsException, RegistryException;
-	public List<HostDescription> getHostDescriptors()throws MalformedDescriptorException, RegistryException;
-	public ResourceMetadata getHostDescriptorMetadata(String hostName)throws DescriptorDoesNotExistsException, RegistryException;
+	public boolean isHostDescriptorExists(String descriptorName)throws RegException;
+	public void addHostDescriptor(HostDescription descriptor) throws DescriptorAlreadyExistsException, RegException;
+	public void updateHostDescriptor(HostDescription descriptor)throws DescriptorDoesNotExistsException, RegException;
+	public HostDescription getHostDescriptor(String hostName)throws DescriptorDoesNotExistsException,MalformedDescriptorException, RegException;
+	public void removeHostDescriptor(String hostName)throws DescriptorDoesNotExistsException, RegException;
+	public List<HostDescription> getHostDescriptors()throws MalformedDescriptorException, RegException;
+	public ResourceMetadata getHostDescriptorMetadata(String hostName)throws DescriptorDoesNotExistsException, RegException;
 
 	//---------Service Descriptor data------------
-	public boolean isServiceDescriptorExists(String descriptorName)throws RegistryException;
-	public void addServiceDescriptor(ServiceDescription descriptor)throws DescriptorAlreadyExistsException, RegistryException;
-	public void updateServiceDescriptor(ServiceDescription descriptor)throws DescriptorDoesNotExistsException, RegistryException;
-	public ServiceDescription getServiceDescriptor(String serviceName)throws DescriptorDoesNotExistsException,MalformedDescriptorException, RegistryException;
-	public void removeServiceDescriptor(String serviceName)throws DescriptorDoesNotExistsException, RegistryException;
-	public List<ServiceDescription> getServiceDescriptors()throws MalformedDescriptorException, RegistryException;
-	public ResourceMetadata getServiceDescriptorMetadata(String serviceName)throws DescriptorDoesNotExistsException, RegistryException;
+	public boolean isServiceDescriptorExists(String descriptorName)throws RegException;
+	public void addServiceDescriptor(ServiceDescription descriptor)throws DescriptorAlreadyExistsException, RegException;
+	public void updateServiceDescriptor(ServiceDescription descriptor)throws DescriptorDoesNotExistsException, RegException;
+	public ServiceDescription getServiceDescriptor(String serviceName)throws DescriptorDoesNotExistsException,MalformedDescriptorException, RegException;
+	public void removeServiceDescriptor(String serviceName)throws DescriptorDoesNotExistsException, RegException;
+	public List<ServiceDescription> getServiceDescriptors()throws MalformedDescriptorException, RegException;
+	public ResourceMetadata getServiceDescriptorMetadata(String serviceName)throws DescriptorDoesNotExistsException, RegException;
 	
 	//---------Application Descriptor data------------
-	public boolean isApplicationDescriptorExists(String serviceName, String hostName, String descriptorName)throws RegistryException;
-	public void addApplicationDescriptor(ServiceDescription serviceDescription, HostDescription hostDescriptor, ApplicationDescription descriptor)throws DescriptorAlreadyExistsException, RegistryException;
-	public void addApplicationDescriptor(String serviceName, String hostName, ApplicationDescription descriptor)throws DescriptorAlreadyExistsException, RegistryException;
-	public void udpateApplicationDescriptor(ServiceDescription serviceDescription, HostDescription hostDescriptor, ApplicationDescription descriptor)throws DescriptorDoesNotExistsException, RegistryException;
-	public void updateApplicationDescriptor(String serviceName, String hostName, ApplicationDescription descriptor)throws DescriptorDoesNotExistsException, RegistryException;
-	public ApplicationDescription getApplicationDescriptor(String serviceName, String hostname, String applicationName)throws DescriptorDoesNotExistsException, MalformedDescriptorException, RegistryException;
-	public ApplicationDescription getApplicationDescriptors(String serviceName, String hostname)throws MalformedDescriptorException, RegistryException;
-	public Map<String,ApplicationDescription> getApplicationDescriptors(String serviceName)throws MalformedDescriptorException, RegistryException;
+	public boolean isApplicationDescriptorExists(String serviceName, String hostName, String descriptorName)throws RegException;
+	public void addApplicationDescriptor(ServiceDescription serviceDescription, HostDescription hostDescriptor, ApplicationDescription descriptor)throws DescriptorAlreadyExistsException, RegException;
+	public void addApplicationDescriptor(String serviceName, String hostName, ApplicationDescription descriptor)throws DescriptorAlreadyExistsException, RegException;
+	public void udpateApplicationDescriptor(ServiceDescription serviceDescription, HostDescription hostDescriptor, ApplicationDescription descriptor)throws DescriptorDoesNotExistsException, RegException;
+	public void updateApplicationDescriptor(String serviceName, String hostName, ApplicationDescription descriptor)throws DescriptorDoesNotExistsException, RegException;
+	public ApplicationDescription getApplicationDescriptor(String serviceName, String hostname, String applicationName)throws DescriptorDoesNotExistsException, MalformedDescriptorException, RegException;
+	public ApplicationDescription getApplicationDescriptors(String serviceName, String hostname)throws MalformedDescriptorException, RegException;
+	public Map<String,ApplicationDescription> getApplicationDescriptors(String serviceName)throws MalformedDescriptorException, RegException;
 	//public Map<String,ApplicationDescription> getApplicationDescriptorsFromHostName(String hostName)throws MalformedDescriptorException, RegistryException;
-	public Map<String[],ApplicationDescription> getApplicationDescriptors()throws MalformedDescriptorException, RegistryException;
-	public void removeApplicationDescriptor(String serviceName, String hostName, String applicationName)throws DescriptorDoesNotExistsException, RegistryException;
-	public ResourceMetadata getApplicationDescriptorMetadata(String serviceName, String hostName, String applicationName)throws DescriptorDoesNotExistsException, RegistryException;
+	public Map<String[],ApplicationDescription> getApplicationDescriptors()throws MalformedDescriptorException, RegException;
+	public void removeApplicationDescriptor(String serviceName, String hostName, String applicationName)throws DescriptorDoesNotExistsException, RegException;
+	public ResourceMetadata getApplicationDescriptorMetadata(String serviceName, String hostName, String applicationName)throws DescriptorDoesNotExistsException, RegException;
 
 
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/OrchestratorRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/OrchestratorRegistry.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/OrchestratorRegistry.java
index 70cbdda..2d65a22 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/OrchestratorRegistry.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/OrchestratorRegistry.java
@@ -21,7 +21,7 @@
 package org.apache.airavata.registry.api;
 
 import org.apache.airavata.common.utils.AiravataJobState;
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
 import java.util.List;
 import java.util.Map;
@@ -32,9 +32,9 @@ public interface OrchestratorRegistry extends AiravataSubRegistry {
     /**
      * this return information about GFAC instances running in the system.
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    Map<String, Integer> getGFACNodeList() throws RegistryException;
+    Map<String, Integer> getGFACNodeList() throws RegException;
 
     /**
      * This is the method to use to add a GFAC Node to registry,
@@ -42,9 +42,9 @@ public interface OrchestratorRegistry extends AiravataSubRegistry {
      * @param uri
      * @param nodeID
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    boolean addGFACNode(String uri, int nodeID)throws RegistryException;
+    boolean addGFACNode(String uri, int nodeID)throws RegException;
 
 
     /**
@@ -53,27 +53,27 @@ public interface OrchestratorRegistry extends AiravataSubRegistry {
      * @param state
      * @param gfacEPR
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    boolean changeStatus(String experimentID,AiravataJobState.State state, String gfacEPR)throws RegistryException;
+    boolean changeStatus(String experimentID,AiravataJobState.State state, String gfacEPR)throws RegException;
     
     /**
      * This can be used to change the status to any valid status
      * @param experimentID
      * @param state
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    boolean changeStatus(String experimentID,AiravataJobState.State state)throws RegistryException;
+    boolean changeStatus(String experimentID,AiravataJobState.State state)throws RegException;
 
 
     /**
      * This method can be used to seek the status of a given experiment
      * @param experimentID
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    AiravataJobState getState(String experimentID)throws RegistryException;
+    AiravataJobState getState(String experimentID)throws RegException;
 
     /**
      * This returns all the jobs with the given state
@@ -87,34 +87,34 @@ public interface OrchestratorRegistry extends AiravataSubRegistry {
      * This will return list of experimentID of jobs which are in
      * ACCEPTED state
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    List<String> getAllAcceptedJobs()throws RegistryException;
+    List<String> getAllAcceptedJobs()throws RegException;
 
 
     /**
      * This will return all the hanged jobs, the logic to determine
      * whether job is hanged or not is depend on the implementation
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    List<String> getAllHangedJobs()throws RegistryException;
+    List<String> getAllHangedJobs()throws RegException;
 
     /**
      * return the number of jobs hanged, it not normal that jobs are hanged
      * all the time, so users can use this method before try to retrieve
      * list of hanged jobs
      * @return  number of hanged jobs
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    int getHangedJobCount()throws RegistryException;
+    int getHangedJobCount()throws RegException;
 
     /**
      * reset hanged jobs based on previous state
      * @param experimentID
      * @return true if operation is successful
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    boolean resetHangedJob(String experimentID)throws RegistryException;
+    boolean resetHangedJob(String experimentID)throws RegException;
 
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProjectsRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProjectsRegistry.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProjectsRegistry.java
index 2df4e58..ffe905e 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProjectsRegistry.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProjectsRegistry.java
@@ -24,7 +24,7 @@ package org.apache.airavata.registry.api;
 import java.util.Date;
 import java.util.List;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.apache.airavata.registry.api.exception.worker.ExperimentDoesNotExistsException;
 import org.apache.airavata.registry.api.exception.worker.WorkspaceProjectAlreadyExistsException;
 import org.apache.airavata.registry.api.exception.worker.WorkspaceProjectDoesNotExistsException;
@@ -32,19 +32,19 @@ import org.apache.airavata.registry.api.exception.worker.WorkspaceProjectDoesNot
 public interface ProjectsRegistry extends AiravataSubRegistry {
 	
 	//------------Project management
-	public boolean isWorkspaceProjectExists(String projectName) throws RegistryException;
-	public boolean isWorkspaceProjectExists(String projectName, boolean createIfNotExists) throws RegistryException;
-	public void addWorkspaceProject(WorkspaceProject project) throws WorkspaceProjectAlreadyExistsException, RegistryException;
-	public void updateWorkspaceProject(WorkspaceProject project) throws WorkspaceProjectDoesNotExistsException, RegistryException;
-	public void deleteWorkspaceProject(String projectName) throws WorkspaceProjectDoesNotExistsException, RegistryException;
-	public WorkspaceProject getWorkspaceProject(String projectName) throws WorkspaceProjectDoesNotExistsException, RegistryException;
-	public List<WorkspaceProject> getWorkspaceProjects() throws RegistryException;
+	public boolean isWorkspaceProjectExists(String projectName) throws RegException;
+	public boolean isWorkspaceProjectExists(String projectName, boolean createIfNotExists) throws RegException;
+	public void addWorkspaceProject(WorkspaceProject project) throws WorkspaceProjectAlreadyExistsException, RegException;
+	public void updateWorkspaceProject(WorkspaceProject project) throws WorkspaceProjectDoesNotExistsException, RegException;
+	public void deleteWorkspaceProject(String projectName) throws WorkspaceProjectDoesNotExistsException, RegException;
+	public WorkspaceProject getWorkspaceProject(String projectName) throws WorkspaceProjectDoesNotExistsException, RegException;
+	public List<WorkspaceProject> getWorkspaceProjects() throws RegException;
 	
 	//------------Experiment management
-	public void addExperiment(String projectName, AiravataExperiment experiment) throws WorkspaceProjectDoesNotExistsException, ExperimentDoesNotExistsException, RegistryException;
+	public void addExperiment(String projectName, AiravataExperiment experiment) throws WorkspaceProjectDoesNotExistsException, ExperimentDoesNotExistsException, RegException;
 	public void removeExperiment(String experimentId) throws ExperimentDoesNotExistsException;
-	public List<AiravataExperiment> getExperiments() throws RegistryException;
-	public List<AiravataExperiment> getExperiments(String projectName)throws RegistryException;
-	public List<AiravataExperiment> getExperiments(Date from, Date to)throws RegistryException;
-	public List<AiravataExperiment> getExperiments(String projectName, Date from, Date to) throws RegistryException;
+	public List<AiravataExperiment> getExperiments() throws RegException;
+	public List<AiravataExperiment> getExperiments(String projectName)throws RegException;
+	public List<AiravataExperiment> getExperiments(Date from, Date to)throws RegException;
+	public List<AiravataExperiment> getExperiments(String projectName, Date from, Date to) throws RegException;
 }


[02/11] adding proper entity manager closing and exception handling - AIRAVATA-1285

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java
index 145241a..6148399 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/ProvenanceRegistry.java
@@ -25,7 +25,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.apache.airavata.registry.api.workflow.*;
 import org.apache.airavata.registry.api.workflow.ApplicationJob.ApplicationJobStatus;
 import org.apache.airavata.registry.api.workflow.WorkflowExecutionStatus.State;
@@ -38,136 +38,136 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * Returns true if the experiment exists 
      * @param experimentId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public boolean isExperimentExists(String experimentId) throws RegistryException;
+	public boolean isExperimentExists(String experimentId) throws RegException;
 	
-	public boolean isExperimentExists(String experimentId, boolean createIfNotPresent) throws RegistryException;
+	public boolean isExperimentExists(String experimentId, boolean createIfNotPresent) throws RegException;
 	
     /**
      * Save the username of the user who runs this experiment 
      * @param experimentId
      * @param user
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public void updateExperimentExecutionUser(String experimentId, String user) throws RegistryException;
+	public void updateExperimentExecutionUser(String experimentId, String user) throws RegException;
     
     /**
      * Retrieve the user who is runing the experiment
      * @param experimentId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public String getExperimentExecutionUser(String experimentId) throws RegistryException;
+	public String getExperimentExecutionUser(String experimentId) throws RegException;
 
     /**
      * check whether the experiment name exists
      * @param experimentName
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public boolean isExperimentNameExist(String experimentName) throws  RegistryException;
+    public boolean isExperimentNameExist(String experimentName) throws RegException;
     /**
      * Get the name of the workflow intance
      * @param experimentId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public String getExperimentName(String experimentId) throws RegistryException;
+	public String getExperimentName(String experimentId) throws RegException;
     
     /**
      * Save a name for this workflow execution
      * @param experimentId
      * @param experimentName
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public void updateExperimentName(String experimentId,String experimentName)throws RegistryException;
+	public void updateExperimentName(String experimentId,String experimentName)throws RegException;
     
 	/**
      * Return the metadata information saved for the experiment
      * @param experimentId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public String getExperimentMetadata(String experimentId) throws RegistryException;
+    public String getExperimentMetadata(String experimentId) throws RegException;
     
     /**
      * Save the metadata for the experiment
      * @param experimentId
      * @param metadata
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public void updateExperimentMetadata(String experimentId, String metadata) throws RegistryException;
+    public void updateExperimentMetadata(String experimentId, String metadata) throws RegException;
     
     /**
      * Return the template name of the workflow that this intance was created from
      * @param workflowInstanceId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public String getWorkflowExecutionTemplateName(String workflowInstanceId) throws RegistryException;
+    public String getWorkflowExecutionTemplateName(String workflowInstanceId) throws RegException;
     
     /**
      * Save the template name of the workflow that this intance was created from
      * @param workflowInstanceId
      * @param templateName
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public void setWorkflowInstanceTemplateName(String workflowInstanceId, String templateName) throws RegistryException;
+    public void setWorkflowInstanceTemplateName(String workflowInstanceId, String templateName) throws RegException;
     
-    public List<WorkflowExecution> getExperimentWorkflowInstances(String experimentId) throws RegistryException;
+    public List<WorkflowExecution> getExperimentWorkflowInstances(String experimentId) throws RegException;
     
     /*-------------------------------------- Experiment Workflow instance node data ----------------------------------------*/
 
-    public boolean isWorkflowInstanceExists(String instanceId) throws RegistryException;
+    public boolean isWorkflowInstanceExists(String instanceId) throws RegException;
     
-    public boolean isWorkflowInstanceExists(String instanceId, boolean createIfNotPresent) throws RegistryException;
+    public boolean isWorkflowInstanceExists(String instanceId, boolean createIfNotPresent) throws RegException;
     
     /**
      * Save a status for this workflow execution with the current time at the moment
      * @param instanceId
      * @param status - contains the status
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public void updateWorkflowInstanceStatus(String instanceId,State status)throws RegistryException;
+	public void updateWorkflowInstanceStatus(String instanceId,State status)throws RegException;
 
     /**
      * Save a status for this workflow execution
      * @param status - contains the status
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public void updateWorkflowInstanceStatus(WorkflowExecutionStatus status)throws RegistryException;
+	public void updateWorkflowInstanceStatus(WorkflowExecutionStatus status)throws RegException;
 
 	
     /**
      * Return the status of the execution
      * @param instanceId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public WorkflowExecutionStatus getWorkflowInstanceStatus(String instanceId)throws RegistryException;
+	public WorkflowExecutionStatus getWorkflowInstanceStatus(String instanceId)throws RegException;
 
     /**
 	 * Save the input data of a node in the workflow instance of an experiment
 	 * @param node
      * @param data
 	 * @return true if successfully saved
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
-	public void updateWorkflowNodeInput(WorkflowInstanceNode node, String data) throws RegistryException;
+	public void updateWorkflowNodeInput(WorkflowInstanceNode node, String data) throws RegException;
 
     /**
      * Save the output data of a node in the workflow instance of an experiment
      * @param node
      * @return true if successfully saved
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public void updateWorkflowNodeOutput(WorkflowInstanceNode node, String data)throws RegistryException;
+	public void updateWorkflowNodeOutput(WorkflowInstanceNode node, String data)throws RegException;
     
     /**
      * Return a list of data passed as input for service node which regex matched nodeId, workflow template id & experiment id 
@@ -175,9 +175,9 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * @param workflowNameRegEx - this is the workflowName or workflow template Id of an experiment
      * @param nodeNameRegEx - nodeId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public List<WorkflowNodeIOData> searchWorkflowInstanceNodeInput(String experimentIdRegEx, String workflowNameRegEx, String nodeNameRegEx)throws RegistryException;
+	public List<WorkflowNodeIOData> searchWorkflowInstanceNodeInput(String experimentIdRegEx, String workflowNameRegEx, String nodeNameRegEx)throws RegException;
 
 	/**
      * Return a list of data returned as output from service node which regex matched nodeId, workflow template id & experiment id 
@@ -185,13 +185,13 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * @param workflowNameRegEx - this is the workflowName or workflow template Id of an experiment
      * @param nodeNameRegEx - nodeId
 	 * @return
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
-	public List<WorkflowNodeIOData> searchWorkflowInstanceNodeOutput(String experimentIdRegEx, String workflowNameRegEx, String nodeNameRegEx)throws RegistryException;
+	public List<WorkflowNodeIOData> searchWorkflowInstanceNodeOutput(String experimentIdRegEx, String workflowNameRegEx, String nodeNameRegEx)throws RegException;
 	
-	public List<WorkflowNodeIOData> getWorkflowInstanceNodeInput(String workflowInstanceId, String nodeType)throws RegistryException;
+	public List<WorkflowNodeIOData> getWorkflowInstanceNodeInput(String workflowInstanceId, String nodeType)throws RegException;
 	
-	public List<WorkflowNodeIOData> getWorkflowInstanceNodeOutput(String workflowInstanceId, String nodeType)throws RegistryException;
+	public List<WorkflowNodeIOData> getWorkflowInstanceNodeOutput(String workflowInstanceId, String nodeType)throws RegException;
 
     /**
      * Saves the results of output nodes in a workflow
@@ -200,9 +200,9 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * @param outputNodeName
      * @param output
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public void saveWorkflowExecutionOutput(String experimentId,String outputNodeName,String output) throws RegistryException;
+	public void saveWorkflowExecutionOutput(String experimentId,String outputNodeName,String output) throws RegException;
     
     /**
      * Saves the results of output nodes in a workflow
@@ -210,9 +210,9 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * @param experimentId - also the workflow id
      * @param data
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public void saveWorkflowExecutionOutput(String experimentId, WorkflowIOData data) throws RegistryException;
+	public void saveWorkflowExecutionOutput(String experimentId, WorkflowIOData data) throws RegException;
 
     /**
      * Get the output results of a output node of an experiment
@@ -220,67 +220,67 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * @param experimentId - also the workflow id
      * @param outputNodeName
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public WorkflowIOData getWorkflowExecutionOutput(String experimentId,String outputNodeName) throws RegistryException;
+	public WorkflowIOData getWorkflowExecutionOutput(String experimentId,String outputNodeName) throws RegException;
     
     /**
      * Get the list of output node results of an experiment 
      * @deprecated
      * @param experimentId - also the workflow id
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public List<WorkflowIOData> getWorkflowExecutionOutput(String experimentId) throws RegistryException;
+	public List<WorkflowIOData> getWorkflowExecutionOutput(String experimentId) throws RegException;
 
     /**
      * Get the names of the output nodes of a workflow instance run
      * @deprecated
      * @param exeperimentId - also the workflow id
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public String[] getWorkflowExecutionOutputNames(String exeperimentId) throws RegistryException;
+	public String[] getWorkflowExecutionOutputNames(String exeperimentId) throws RegException;
 
 	/*---------------------------------------  Retrieving Experiment ------------------------------------------*/
     /**
      * Return workflow execution object fully populated with data currently avaialble for that experiment
      * @param experimentId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public ExperimentData getExperiment(String experimentId) throws RegistryException;
+	public ExperimentData getExperiment(String experimentId) throws RegException;
 	
-	public ExperimentData getExperimentMetaInformation(String experimentId)throws RegistryException;
+	public ExperimentData getExperimentMetaInformation(String experimentId)throws RegException;
 	
-	public List<ExperimentData> getAllExperimentMetaInformation(String user)throws RegistryException;
+	public List<ExperimentData> getAllExperimentMetaInformation(String user)throws RegException;
 	
 	/**
 	 * Retrieve experiments which their names match the regular expression experimentNameRegex
 	 * @param user
 	 * @param experimentNameRegex
 	 * @return
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
-	public List<ExperimentData> searchExperiments(String user, String experimentNameRegex)throws RegistryException;
+	public List<ExperimentData> searchExperiments(String user, String experimentNameRegex)throws RegException;
     
     /**
      * Return experiment ids of experiments launched by the given user
      * @param user - a regex user id
      * @return - experiment id list
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-	public List<String> getExperimentIdByUser(String user) throws RegistryException;
+	public List<String> getExperimentIdByUser(String user) throws RegException;
 
 	/**
 	 * Return experiments launched by the given user
 	 * @param user
 	 * @return experiment object list each populated by current data of that experiment
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
-    public List<ExperimentData> getExperimentByUser(String user) throws RegistryException;
+    public List<ExperimentData> getExperimentByUser(String user) throws RegException;
     
-	public List<ExperimentData> getExperiments(HashMap<String, String> params) throws RegistryException;
+	public List<ExperimentData> getExperiments(HashMap<String, String> params) throws RegException;
     
     /**
      * Return the pageNo set of experiments launched by the given user if grouped in to pages of size pageSize
@@ -288,26 +288,26 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * @param pageSize
      * @param pageNo
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public List<ExperimentData> getExperimentByUser(String user, int pageSize, int pageNo) throws RegistryException;
+    public List<ExperimentData> getExperimentByUser(String user, int pageSize, int pageNo) throws RegException;
 
     /**
      * This will update the workflowStatus for given experimentID,workflowInstanceID combination.
      * @param workflowStatusNode
      * @return
      */
-    public void updateWorkflowNodeStatus(NodeExecutionStatus workflowStatusNode)throws RegistryException;
+    public void updateWorkflowNodeStatus(NodeExecutionStatus workflowStatusNode)throws RegException;
 
-    public void updateWorkflowNodeStatus(String workflowInstanceId, String nodeId, State status)throws RegistryException;
+    public void updateWorkflowNodeStatus(String workflowInstanceId, String nodeId, State status)throws RegException;
     
-    public void updateWorkflowNodeStatus(WorkflowInstanceNode workflowNode, State status)throws RegistryException;
+    public void updateWorkflowNodeStatus(WorkflowInstanceNode workflowNode, State status)throws RegException;
 
-    public NodeExecutionStatus getWorkflowNodeStatus(WorkflowInstanceNode workflowNode)throws RegistryException;
+    public NodeExecutionStatus getWorkflowNodeStatus(WorkflowInstanceNode workflowNode)throws RegException;
     
-    public Date getWorkflowNodeStartTime(WorkflowInstanceNode workflowNode)throws RegistryException;
+    public Date getWorkflowNodeStartTime(WorkflowInstanceNode workflowNode)throws RegException;
     
-    public Date getWorkflowStartTime(WorkflowExecution workflowInstance)throws RegistryException;
+    public Date getWorkflowStartTime(WorkflowExecution workflowInstance)throws RegException;
     
     /**
      * @deprecated - Will be removed from 0.9 release onwards. Use {@see #addApplicationJob #updateApplicationJob(ApplicationJob) etc.} functions instead.
@@ -315,21 +315,21 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * @param workflowNodeGramData
      * @return
      */
-    public void updateWorkflowNodeGramData(WorkflowNodeGramData workflowNodeGramData)throws RegistryException;
+    public void updateWorkflowNodeGramData(WorkflowNodeGramData workflowNodeGramData)throws RegException;
     
-    public WorkflowExecutionData getWorkflowInstanceData(String workflowInstanceId)throws RegistryException;
+    public WorkflowExecutionData getWorkflowInstanceData(String workflowInstanceId)throws RegException;
     
-    public boolean isWorkflowInstanceNodePresent(String workflowInstanceId, String nodeId)throws RegistryException;
+    public boolean isWorkflowInstanceNodePresent(String workflowInstanceId, String nodeId)throws RegException;
     
-    public boolean isWorkflowInstanceNodePresent(String workflowInstanceId, String nodeId, boolean createIfNotPresent)throws RegistryException;
+    public boolean isWorkflowInstanceNodePresent(String workflowInstanceId, String nodeId, boolean createIfNotPresent)throws RegException;
     
-    public NodeExecutionData getWorkflowInstanceNodeData(String workflowInstanceId, String nodeId)throws RegistryException;
+    public NodeExecutionData getWorkflowInstanceNodeData(String workflowInstanceId, String nodeId)throws RegException;
 
-    public void addWorkflowInstance(String experimentId, String workflowInstanceId, String templateName) throws RegistryException;
+    public void addWorkflowInstance(String experimentId, String workflowInstanceId, String templateName) throws RegException;
     
-    public void updateWorkflowNodeType(WorkflowInstanceNode node, WorkflowNodeType type) throws RegistryException;
+    public void updateWorkflowNodeType(WorkflowInstanceNode node, WorkflowNodeType type) throws RegException;
     
-    public void addWorkflowInstanceNode(String workflowInstance, String nodeId) throws RegistryException;
+    public void addWorkflowInstanceNode(String workflowInstance, String nodeId) throws RegException;
     
     
 	/*---------------------------------------  Errors in experiment executions ------------------------------------------*/
@@ -338,18 +338,18 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * Return errors defined at the experiment level 
      * @param experimentId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public List<ExperimentExecutionError> getExperimentExecutionErrors(String experimentId) throws RegistryException;
+    public List<ExperimentExecutionError> getExperimentExecutionErrors(String experimentId) throws RegException;
     
     /**
      * Return errors defined at the workflow level 
      * @param experimentId
      * @param workflowInstanceId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public List<WorkflowExecutionError> getWorkflowExecutionErrors(String experimentId, String workflowInstanceId) throws RegistryException;
+    public List<WorkflowExecutionError> getWorkflowExecutionErrors(String experimentId, String workflowInstanceId) throws RegException;
 
     /**
      * Return errors defined at the node level 
@@ -357,9 +357,9 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * @param workflowInstanceId
      * @param nodeId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public List<NodeExecutionError> getNodeExecutionErrors(String experimentId, String workflowInstanceId, String nodeId) throws RegistryException;
+    public List<NodeExecutionError> getNodeExecutionErrors(String experimentId, String workflowInstanceId, String nodeId) throws RegException;
     
     /**
      * Return errors defined for a Application job 
@@ -368,17 +368,17 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * @param nodeId
      * @param jobId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public List<ApplicationJobExecutionError> getApplicationJobErrors(String experimentId, String workflowInstanceId, String nodeId, String jobId) throws RegistryException;
+    public List<ApplicationJobExecutionError> getApplicationJobErrors(String experimentId, String workflowInstanceId, String nodeId, String jobId) throws RegException;
 
     /**
      * Return errors defined for a Application job 
      * @param jobId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public List<ApplicationJobExecutionError> getApplicationJobErrors(String jobId) throws RegistryException;
+    public List<ApplicationJobExecutionError> getApplicationJobErrors(String jobId) throws RegException;
 
     /**
      * Return errors filtered by the parameters
@@ -388,40 +388,40 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * @param jobId
      * @param filterBy - what type of source types the results should contain
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public List<ExecutionError> getExecutionErrors(String experimentId, String workflowInstanceId, String nodeId, String jobId, ExecutionErrors.Source...filterBy) throws RegistryException;
+    public List<ExecutionError> getExecutionErrors(String experimentId, String workflowInstanceId, String nodeId, String jobId, ExecutionErrors.Source...filterBy) throws RegException;
     /**
      * Adds an experiment execution error 
      * @param error
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public int addExperimentError(ExperimentExecutionError error) throws RegistryException;
+    public int addExperimentError(ExperimentExecutionError error) throws RegException;
     
     /**
      * Adds an workflow execution error 
      * @param error
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public int addWorkflowExecutionError(WorkflowExecutionError error) throws RegistryException;
+    public int addWorkflowExecutionError(WorkflowExecutionError error) throws RegException;
     
     /**
      * Adds an node execution error 
      * @param error
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public int addNodeExecutionError(NodeExecutionError error) throws RegistryException;
+    public int addNodeExecutionError(NodeExecutionError error) throws RegException;
 
     /**
      * Adds an Application job execution error 
      * @param error
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public int addApplicationJobExecutionError(ApplicationJobExecutionError error) throws RegistryException;
+    public int addApplicationJobExecutionError(ApplicationJobExecutionError error) throws RegException;
     
     
 	/*---------------------------------------  Managing Data for Application Jobs ------------------------------------------*/
@@ -430,73 +430,73 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * Returns <code>true</code> if a Application job data is existing in the registry
      * @param jobId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public boolean isApplicationJobExists(String jobId) throws RegistryException;
+    public boolean isApplicationJobExists(String jobId) throws RegException;
     
     /**
      * Adding data related to a new Application job submission
      * @param job - the <code>jobId</code> cannot be <code>null</code>.
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public void addApplicationJob(ApplicationJob job) throws RegistryException;
+    public void addApplicationJob(ApplicationJob job) throws RegException;
     
     /**
      * update data related to a existing Application job record in the registry
      * @param job - the <code>jobId</code> cannot be <code>null</code> and should already exist in registry
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public void updateApplicationJob(ApplicationJob job) throws RegistryException;
+    public void updateApplicationJob(ApplicationJob job) throws RegException;
     
     /**
      * Update the status of the job
      * @param jobId
      * @param status
      * @param statusUpdateTime
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public void updateApplicationJobStatus(String jobId, ApplicationJobStatus status, Date statusUpdateTime) throws RegistryException;
+    public void updateApplicationJobStatus(String jobId, ApplicationJobStatus status, Date statusUpdateTime) throws RegException;
    
     /**
      * Update the job data. GFacProvider implementation should decide the job data. Typically it'll 
      * be a serialization of the submitted job query (eg: rsl for a GRAM job) 
      * @param jobId
      * @param jobdata
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public void updateApplicationJobData(String jobId, String jobdata) throws RegistryException;
+    public void updateApplicationJobData(String jobId, String jobdata) throws RegException;
     
     /**
      * Update the time of job submission or job started executing
      * @param jobId
      * @param submitted
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public void updateApplicationJobSubmittedTime(String jobId, Date submitted) throws RegistryException;
+    public void updateApplicationJobSubmittedTime(String jobId, Date submitted) throws RegException;
     
     /**
      * Update the time of current job status is valid.
      * @param jobId
      * @param statusUpdateTime
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public void updateApplicationJobStatusUpdateTime(String jobId, Date statusUpdateTime) throws RegistryException;
+    public void updateApplicationJobStatusUpdateTime(String jobId, Date statusUpdateTime) throws RegException;
     
     /**
      * Custom data field for users
      * @param jobId
      * @param metadata
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public void updateApplicationJobMetadata(String jobId, String metadata) throws RegistryException;
+    public void updateApplicationJobMetadata(String jobId, String metadata) throws RegException;
     
     /**
      * Retrieve the Application Job for the given job id
      * @param jobId
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public ApplicationJob getApplicationJob(String jobId) throws RegistryException;
+    public ApplicationJob getApplicationJob(String jobId) throws RegException;
     
     /**
      * Retrieve a list of Application jobs executed for the given descriptors
@@ -504,9 +504,9 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * @param hostDescriptionId - should be <code>null</code> if user does not care what host description the job corresponds to
      * @param applicationDescriptionId - should be <code>null</code> if user does not care what application description the job corresponds to
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public List<ApplicationJob> getApplicationJobsForDescriptors(String serviceDescriptionId, String hostDescriptionId, String applicationDescriptionId) throws RegistryException;
+    public List<ApplicationJob> getApplicationJobsForDescriptors(String serviceDescriptionId, String hostDescriptionId, String applicationDescriptionId) throws RegException;
     
     /**
      * Retrieve a list of Application jobs executed for the given experiment credentials
@@ -514,15 +514,15 @@ public interface ProvenanceRegistry extends AiravataSubRegistry{
      * @param workflowExecutionId -  - should be <code>null</code> if user does not care what workflow execution the job corresponds to
      * @param nodeId  - should be <code>null</code> if user does not care what node id the job corresponds to
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public List<ApplicationJob> getApplicationJobs(String experimentId, String workflowExecutionId, String nodeId) throws RegistryException;
+    public List<ApplicationJob> getApplicationJobs(String experimentId, String workflowExecutionId, String nodeId) throws RegException;
     
     /**
      * Retrieve the list all the status updates for an application job.
      * @param jobId - Application job id
      * @return
-     * @throws RegistryException
+     * @throws org.apache.airavata.registry.api.exception.RegException
      */
-    public List<ApplicationJobStatusData> getApplicationJobStatusHistory(String jobId) throws RegistryException;
+    public List<ApplicationJobStatusData> getApplicationJobStatusHistory(String jobId) throws RegException;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/PublishedWorkflowRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/PublishedWorkflowRegistry.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/PublishedWorkflowRegistry.java
index 9069441..153ccdd 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/PublishedWorkflowRegistry.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/PublishedWorkflowRegistry.java
@@ -24,7 +24,7 @@ package org.apache.airavata.registry.api;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.apache.airavata.registry.api.exception.gateway.PublishedWorkflowAlreadyExistsException;
 import org.apache.airavata.registry.api.exception.gateway.PublishedWorkflowDoesNotExistsException;
 import org.apache.airavata.registry.api.exception.worker.UserWorkflowDoesNotExistsException;
@@ -32,14 +32,14 @@ import org.apache.airavata.registry.api.exception.worker.UserWorkflowDoesNotExis
 
 public interface PublishedWorkflowRegistry extends AiravataSubRegistry {
 	
-	public boolean isPublishedWorkflowExists(String workflowName) throws RegistryException;
-	public void publishWorkflow(String workflowName, String publishWorkflowName) throws PublishedWorkflowAlreadyExistsException, UserWorkflowDoesNotExistsException, RegistryException;
-	public void publishWorkflow(String workflowName) throws PublishedWorkflowAlreadyExistsException, UserWorkflowDoesNotExistsException, RegistryException;
+	public boolean isPublishedWorkflowExists(String workflowName) throws RegException;
+	public void publishWorkflow(String workflowName, String publishWorkflowName) throws PublishedWorkflowAlreadyExistsException, UserWorkflowDoesNotExistsException, RegException;
+	public void publishWorkflow(String workflowName) throws PublishedWorkflowAlreadyExistsException, UserWorkflowDoesNotExistsException, RegException;
 	
-	public String getPublishedWorkflowGraphXML(String workflowName) throws PublishedWorkflowDoesNotExistsException, RegistryException;
-	public List<String> getPublishedWorkflowNames() throws RegistryException;
-	public Map<String,String> getPublishedWorkflows() throws RegistryException;
-	public ResourceMetadata getPublishedWorkflowMetadata(String workflowName) throws RegistryException;
+	public String getPublishedWorkflowGraphXML(String workflowName) throws PublishedWorkflowDoesNotExistsException, RegException;
+	public List<String> getPublishedWorkflowNames() throws RegException;
+	public Map<String,String> getPublishedWorkflows() throws RegException;
+	public ResourceMetadata getPublishedWorkflowMetadata(String workflowName) throws RegException;
 	
-	public void removePublishedWorkflow(String workflowName)throws PublishedWorkflowDoesNotExistsException, RegistryException;
+	public void removePublishedWorkflow(String workflowName)throws PublishedWorkflowDoesNotExistsException, RegException;
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/UserRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/UserRegistry.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/UserRegistry.java
index 9baf7ea..1747458 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/UserRegistry.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/UserRegistry.java
@@ -23,7 +23,7 @@ package org.apache.airavata.registry.api;
 
 import java.util.List;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
 public interface UserRegistry extends AiravataSubRegistry{
 
@@ -31,9 +31,9 @@ public interface UserRegistry extends AiravataSubRegistry{
 	/**
 	 * Retrieve all the users in the registry
 	 * @return a list of airavata users from the registry
-	 * @throws RegistryException
+	 * @throws org.apache.airavata.registry.api.exception.RegException
 	 */
 	
-	public List<AiravataUser> getUsers() throws RegistryException;
+	public List<AiravataUser> getUsers() throws RegException;
     
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/UserWorkflowRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/UserWorkflowRegistry.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/UserWorkflowRegistry.java
index d7f0595..6274125 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/UserWorkflowRegistry.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/UserWorkflowRegistry.java
@@ -23,21 +23,21 @@ package org.apache.airavata.registry.api;
 
 import java.util.Map;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 import org.apache.airavata.registry.api.exception.worker.UserWorkflowAlreadyExistsException;
 import org.apache.airavata.registry.api.exception.worker.UserWorkflowDoesNotExistsException;
 
 
 public interface UserWorkflowRegistry extends AiravataSubRegistry {
 	
-	public boolean isWorkflowExists(String workflowName) throws RegistryException;
-	public void addWorkflow(String workflowName, String workflowGraphXml) throws UserWorkflowAlreadyExistsException, RegistryException;
-	public void updateWorkflow(String workflowName, String workflowGraphXml) throws UserWorkflowDoesNotExistsException, RegistryException;
+	public boolean isWorkflowExists(String workflowName) throws RegException;
+	public void addWorkflow(String workflowName, String workflowGraphXml) throws UserWorkflowAlreadyExistsException, RegException;
+	public void updateWorkflow(String workflowName, String workflowGraphXml) throws UserWorkflowDoesNotExistsException, RegException;
 	
-	public String getWorkflowGraphXML(String workflowName) throws UserWorkflowDoesNotExistsException, RegistryException;
-	public Map<String,String> getWorkflows() throws RegistryException;
+	public String getWorkflowGraphXML(String workflowName) throws UserWorkflowDoesNotExistsException, RegException;
+	public Map<String,String> getWorkflows() throws RegException;
 	
-	public ResourceMetadata getWorkflowMetadata(String workflowName) throws RegistryException;	
+	public ResourceMetadata getWorkflowMetadata(String workflowName) throws RegException;
 	
-	public void removeWorkflow(String workflowName) throws UserWorkflowDoesNotExistsException, RegistryException;
+	public void removeWorkflow(String workflowName) throws UserWorkflowDoesNotExistsException, RegException;
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/WorkspaceProject.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/WorkspaceProject.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/WorkspaceProject.java
index 68a0fc3..f804dfe 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/WorkspaceProject.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/WorkspaceProject.java
@@ -24,7 +24,7 @@ package org.apache.airavata.registry.api;
 import java.util.Date;
 import java.util.List;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
 import javax.xml.bind.annotation.*;
 
@@ -65,15 +65,15 @@ public class WorkspaceProject{
 		this.projectsRegistry = projectsRegistry;
 	}
 	
-	public void createExperiment(AiravataExperiment experiment) throws RegistryException{
+	public void createExperiment(AiravataExperiment experiment) throws RegException {
 		getProjectsRegistry().addExperiment(getProjectName(), experiment);
 	}
 	
-	public List<AiravataExperiment> getExperiments() throws RegistryException{
+	public List<AiravataExperiment> getExperiments() throws RegException {
 		return getProjectsRegistry().getExperiments(getProjectName());
 	}
 	
-	public List<AiravataExperiment> getExperiments(Date from, Date to) throws RegistryException{
+	public List<AiravataExperiment> getExperiments(Date from, Date to) throws RegException {
 		return getProjectsRegistry().getExperiments(getProjectName(),from, to);
 	}
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/AiravataRegUninitializedException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/AiravataRegUninitializedException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/AiravataRegUninitializedException.java
new file mode 100644
index 0000000..e6e44a9
--- /dev/null
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/AiravataRegUninitializedException.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.airavata.registry.api.exception;
+
+public class AiravataRegUninitializedException extends RegException {
+
+	public AiravataRegUninitializedException(String message, Throwable e) {
+		super(message, e);
+	}
+
+	private static final long serialVersionUID = -6873054164386608256L;
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/AiravataRegistryUninitializedException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/AiravataRegistryUninitializedException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/AiravataRegistryUninitializedException.java
deleted file mode 100644
index f211832..0000000
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/AiravataRegistryUninitializedException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * 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.airavata.registry.api.exception;
-
-public class AiravataRegistryUninitializedException extends RegistryException {
-
-	public AiravataRegistryUninitializedException(String message, Throwable e) {
-		super(message, e);
-	}
-
-	private static final long serialVersionUID = -6873054164386608256L;
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/DeploymentDescriptionRetrieveException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/DeploymentDescriptionRetrieveException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/DeploymentDescriptionRetrieveException.java
index 3630bd8..3787a12 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/DeploymentDescriptionRetrieveException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/DeploymentDescriptionRetrieveException.java
@@ -21,7 +21,7 @@
 
 package org.apache.airavata.registry.api.exception;
 
-public class DeploymentDescriptionRetrieveException extends RegistryException {
+public class DeploymentDescriptionRetrieveException extends RegException {
     private final static String ERROR_MESSAGE = "Error occured while attempting to retrieve existing deployment descriptions";
     /**
 	 * 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/GatewayNotRegisteredException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/GatewayNotRegisteredException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/GatewayNotRegisteredException.java
index 6aa7da0..e0750b0 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/GatewayNotRegisteredException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/GatewayNotRegisteredException.java
@@ -21,7 +21,7 @@
 
 package org.apache.airavata.registry.api.exception;
 
-public class GatewayNotRegisteredException extends RegistryException {
+public class GatewayNotRegisteredException extends RegException {
 
 	private static final long serialVersionUID = -139586125325993500L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/HostDescriptionRetrieveException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/HostDescriptionRetrieveException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/HostDescriptionRetrieveException.java
index 9e21063..f03fd03 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/HostDescriptionRetrieveException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/HostDescriptionRetrieveException.java
@@ -21,7 +21,7 @@
 
 package org.apache.airavata.registry.api.exception;
 
-public class HostDescriptionRetrieveException extends RegistryException {
+public class HostDescriptionRetrieveException extends RegException {
     private final static String ERROR_MESSAGE = "Error occured while attempting to retrieve existing hosts";
 
     private static final long serialVersionUID = -2849422320139467602L;

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAPIVersionIncompatibleException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAPIVersionIncompatibleException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAPIVersionIncompatibleException.java
new file mode 100644
index 0000000..3eac400
--- /dev/null
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAPIVersionIncompatibleException.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.airavata.registry.api.exception;
+
+public class RegAPIVersionIncompatibleException extends RegException {
+
+    private static final long serialVersionUID = -2679914107485739141L;
+
+    public RegAPIVersionIncompatibleException() {
+        this("Incompatible versions with Airavata registry and Airavata API");
+    }
+
+    public RegAPIVersionIncompatibleException(String message) {
+        this(message,null);
+    }
+
+    public RegAPIVersionIncompatibleException(String message, Exception e){
+        super(message, e);
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorInstantiateException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorInstantiateException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorInstantiateException.java
new file mode 100644
index 0000000..2214734
--- /dev/null
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorInstantiateException.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.airavata.registry.api.exception;
+
+public class RegAccessorInstantiateException extends RegException {
+
+	private static final long serialVersionUID = -2679914107485739140L;
+	
+	public RegAccessorInstantiateException(String className, Exception e){
+		super("There was an exception instantiating the Registry accessor class '"+className+"'!!!", e);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorInvalidException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorInvalidException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorInvalidException.java
new file mode 100644
index 0000000..0c85b42
--- /dev/null
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorInvalidException.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.airavata.registry.api.exception;
+
+public class RegAccessorInvalidException extends RegException {
+
+	private static final long serialVersionUID = -2679914107485739140L;
+	
+	public RegAccessorInvalidException(String className){
+		super("Registry accessor '"+className+"' is not valid!!!");
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorNotFoundException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorNotFoundException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorNotFoundException.java
new file mode 100644
index 0000000..daad74b
--- /dev/null
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorNotFoundException.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.airavata.registry.api.exception;
+
+public class RegAccessorNotFoundException extends RegException {
+
+	private static final long serialVersionUID = -2679914107485739140L;
+	
+	public RegAccessorNotFoundException(String className, Exception e){
+		super("Registry accessor class '"+className+"'  was not found in classpath!!!", e);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorUndefinedException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorUndefinedException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorUndefinedException.java
new file mode 100644
index 0000000..90ef70d
--- /dev/null
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegAccessorUndefinedException.java
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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.airavata.registry.api.exception;
+
+public class RegAccessorUndefinedException extends RegException {
+
+	private static final long serialVersionUID = -2679914107485739140L;
+
+	public RegAccessorUndefinedException() {
+		this("A registry accessor was not defined in the registry settings");
+	}
+	
+	public RegAccessorUndefinedException(String message) {
+		this(message,null);
+	}
+	
+	public RegAccessorUndefinedException(String message, Exception e){
+		super(message, e);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegException.java
new file mode 100644
index 0000000..c71abdc
--- /dev/null
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegException.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.airavata.registry.api.exception;
+
+public class RegException extends Exception {
+	
+    private static final long serialVersionUID = -2849422320139467602L;
+
+    public RegException(Throwable e) {
+        super(e);
+    }
+    
+    public RegException(String message) {
+        super(message, null);
+    }
+    
+    public RegException(String message, Throwable e) {
+        super(message, e);
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAPIVersionIncompatibleException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAPIVersionIncompatibleException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAPIVersionIncompatibleException.java
deleted file mode 100644
index 76b4ac2..0000000
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAPIVersionIncompatibleException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *
- * 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.airavata.registry.api.exception;
-
-import org.apache.airavata.registry.api.exception.RegistryException;
-
-public class RegistryAPIVersionIncompatibleException extends RegistryException {
-
-    private static final long serialVersionUID = -2679914107485739141L;
-
-    public RegistryAPIVersionIncompatibleException() {
-        this("Incompatible versions with Airavata registry and Airavata API");
-    }
-
-    public RegistryAPIVersionIncompatibleException(String message) {
-        this(message,null);
-    }
-
-    public RegistryAPIVersionIncompatibleException(String message, Exception e){
-        super(message, e);
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInstantiateException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInstantiateException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInstantiateException.java
deleted file mode 100644
index 5c20f36..0000000
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInstantiateException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * 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.airavata.registry.api.exception;
-
-public class RegistryAccessorInstantiateException extends RegistryException {
-
-	private static final long serialVersionUID = -2679914107485739140L;
-	
-	public RegistryAccessorInstantiateException(String className, Exception e){
-		super("There was an exception instantiating the Registry accessor class '"+className+"'!!!", e);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInvalidException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInvalidException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInvalidException.java
deleted file mode 100644
index c5952df..0000000
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorInvalidException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * 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.airavata.registry.api.exception;
-
-public class RegistryAccessorInvalidException extends RegistryException {
-
-	private static final long serialVersionUID = -2679914107485739140L;
-	
-	public RegistryAccessorInvalidException(String className){
-		super("Registry accessor '"+className+"' is not valid!!!");
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java
deleted file mode 100644
index 69344f4..0000000
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * 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.airavata.registry.api.exception;
-
-public class RegistryAccessorNotFoundException extends RegistryException {
-
-	private static final long serialVersionUID = -2679914107485739140L;
-	
-	public RegistryAccessorNotFoundException(String className, Exception e){
-		super("Registry accessor class '"+className+"'  was not found in classpath!!!", e);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorUndefinedException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorUndefinedException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorUndefinedException.java
deleted file mode 100644
index 1c8e566..0000000
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorUndefinedException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * 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.airavata.registry.api.exception;
-
-public class RegistryAccessorUndefinedException extends RegistryException {
-
-	private static final long serialVersionUID = -2679914107485739140L;
-
-	public RegistryAccessorUndefinedException() {
-		this("A registry accessor was not defined in the registry settings");
-	}
-	
-	public RegistryAccessorUndefinedException(String message) {
-		this(message,null);
-	}
-	
-	public RegistryAccessorUndefinedException(String message, Exception e){
-		super(message, e);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryException.java
deleted file mode 100644
index 1bac4ae..0000000
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *
- * 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.airavata.registry.api.exception;
-
-public class RegistryException extends Exception {
-	
-    private static final long serialVersionUID = -2849422320139467602L;
-
-    public RegistryException(Throwable e) {
-        super(e);
-    }
-    
-    public RegistryException(String message) {
-        super(message, null);
-    }
-    
-    public RegistryException(String message, Throwable e) {
-        super(message, e);
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/ServiceDescriptionRetrieveException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/ServiceDescriptionRetrieveException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/ServiceDescriptionRetrieveException.java
index 32a0c61..d05e60a 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/ServiceDescriptionRetrieveException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/ServiceDescriptionRetrieveException.java
@@ -21,7 +21,7 @@
 
 package org.apache.airavata.registry.api.exception;
 
-public class ServiceDescriptionRetrieveException extends RegistryException {
+public class ServiceDescriptionRetrieveException extends RegException {
     private final static String ERROR_MESSAGE = "Error occured while attempting to retrieve existing service descriptions";
     /**
 	 * 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnimplementedRegOperationException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnimplementedRegOperationException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnimplementedRegOperationException.java
new file mode 100644
index 0000000..e6a71f9
--- /dev/null
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnimplementedRegOperationException.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.airavata.registry.api.exception;
+
+public class UnimplementedRegOperationException extends RegException {
+
+	private static final long serialVersionUID = 8565882892195989548L;
+
+	public UnimplementedRegOperationException() {
+		super("This operation is not implemented!!!");
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnimplementedRegistryOperationException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnimplementedRegistryOperationException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnimplementedRegistryOperationException.java
deleted file mode 100644
index 5f6be73..0000000
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnimplementedRegistryOperationException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * 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.airavata.registry.api.exception;
-
-public class UnimplementedRegistryOperationException extends RegistryException {
-
-	private static final long serialVersionUID = 8565882892195989548L;
-
-	public UnimplementedRegistryOperationException() {
-		super("This operation is not implemented!!!");
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnknownRegConnectionDataException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnknownRegConnectionDataException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnknownRegConnectionDataException.java
new file mode 100644
index 0000000..a71e085
--- /dev/null
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnknownRegConnectionDataException.java
@@ -0,0 +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.airavata.registry.api.exception;
+
+public class UnknownRegConnectionDataException extends RegException {
+
+	private static final long serialVersionUID = -6483101227925383562L;
+
+	public UnknownRegConnectionDataException(String message) {
+		super(message);
+	}
+	
+	public UnknownRegConnectionDataException(String message, Throwable e) {
+		super(message, e);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnknownRegistryConnectionDataException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnknownRegistryConnectionDataException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnknownRegistryConnectionDataException.java
deleted file mode 100644
index f732127..0000000
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/UnknownRegistryConnectionDataException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *
- * 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.airavata.registry.api.exception;
-
-public class UnknownRegistryConnectionDataException extends RegistryException {
-
-	private static final long serialVersionUID = -6483101227925383562L;
-
-	public UnknownRegistryConnectionDataException(String message) {
-		super(message);
-	}
-	
-	public UnknownRegistryConnectionDataException(String message, Throwable e) {
-		super(message, e);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/DescriptorAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/DescriptorAlreadyExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/DescriptorAlreadyExistsException.java
index b98d13c..268c1fd 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/DescriptorAlreadyExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/DescriptorAlreadyExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.gateway;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class DescriptorAlreadyExistsException extends RegistryException {
+public class DescriptorAlreadyExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/DescriptorDoesNotExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/DescriptorDoesNotExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/DescriptorDoesNotExistsException.java
index 15ee860..dc77a3b 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/DescriptorDoesNotExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/DescriptorDoesNotExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.gateway;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class DescriptorDoesNotExistsException extends RegistryException {
+public class DescriptorDoesNotExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/InsufficientDataException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/InsufficientDataException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/InsufficientDataException.java
index 652ee01..e495e42 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/InsufficientDataException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/InsufficientDataException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.gateway;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class InsufficientDataException extends RegistryException {
+public class InsufficientDataException extends RegException {
 
     private static final long serialVersionUID = 7706410845538952164L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/MalformedDescriptorException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/MalformedDescriptorException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/MalformedDescriptorException.java
index 8ed3324..232ae9e 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/MalformedDescriptorException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/MalformedDescriptorException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.gateway;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class MalformedDescriptorException extends RegistryException {
+public class MalformedDescriptorException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/PublishedWorkflowAlreadyExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/PublishedWorkflowAlreadyExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/PublishedWorkflowAlreadyExistsException.java
index 9deb677..a0c935d 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/PublishedWorkflowAlreadyExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/PublishedWorkflowAlreadyExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.gateway;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class PublishedWorkflowAlreadyExistsException extends RegistryException {
+public class PublishedWorkflowAlreadyExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/PublishedWorkflowDoesNotExistsException.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/PublishedWorkflowDoesNotExistsException.java b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/PublishedWorkflowDoesNotExistsException.java
index 2c49164..2f32209 100644
--- a/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/PublishedWorkflowDoesNotExistsException.java
+++ b/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/gateway/PublishedWorkflowDoesNotExistsException.java
@@ -21,9 +21,9 @@
 
 package org.apache.airavata.registry.api.exception.gateway;
 
-import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.RegException;
 
-public class PublishedWorkflowDoesNotExistsException extends RegistryException {
+public class PublishedWorkflowDoesNotExistsException extends RegException {
 
 	private static final long serialVersionUID = -8006347245307495767L;
 


[04/11] adding proper entity manager closing and exception handling - AIRAVATA-1285

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
index 1dcec6d..29b45f9 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java
@@ -26,10 +26,11 @@ import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.*;
 import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
-import org.apache.airavata.registry.cpi.utils.Constants;
+import org.apache.airavata.registry.cpi.Registry;
 import org.apache.airavata.registry.cpi.utils.StatusType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.airavata.registry.cpi.RegistryException;
 
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
@@ -85,8 +86,8 @@ public class TaskDetailResource extends AbstractResource {
         this.applicationVersion = applicationVersion;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException{
        switch (type){
            case ERROR_DETAIL:
                ErrorDetailResource errorDetailResource = new ErrorDetailResource();
@@ -134,324 +135,361 @@ public class TaskDetailResource extends AbstractResource {
        }
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-        switch (type){
-            case ERROR_DETAIL:
-                generator = new QueryGenerator(ERROR_DETAIL);
-                generator.setParameter(ErrorDetailConstants.TASK_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case APPLICATION_INPUT:
-                generator = new QueryGenerator(APPLICATION_INPUT);
-                generator.setParameter(ApplicationInputConstants.TASK_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case APPLICATION_OUTPUT:
-                generator = new QueryGenerator(APPLICATION_OUTPUT);
-                generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case JOB_DETAIL:
-                generator = new QueryGenerator(JOB_DETAIL);
-                generator.setParameter(JobDetailConstants.TASK_ID, taskId);
-                generator.setParameter(JobDetailConstants.JOB_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case DATA_TRANSFER_DETAIL:
-                generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
-                generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.TASK_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case COMPUTATIONAL_RESOURCE_SCHEDULING:
-                generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
-                generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case ADVANCE_INPUT_DATA_HANDLING:
-                generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
-                generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case ADVANCE_OUTPUT_DATA_HANDLING:
-                generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
-                generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            case QOS_PARAM:
-                generator = new QueryGenerator(QOS_PARAMS);
-                generator.setParameter(QosParamsConstants.TASK_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            default:
-                logger.error("Unsupported resource type for task detail resource.", new IllegalArgumentException());
-                break;
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            switch (type) {
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.TASK_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case APPLICATION_INPUT:
+                    generator = new QueryGenerator(APPLICATION_INPUT);
+                    generator.setParameter(ApplicationInputConstants.TASK_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case APPLICATION_OUTPUT:
+                    generator = new QueryGenerator(APPLICATION_OUTPUT);
+                    generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case JOB_DETAIL:
+                    generator = new QueryGenerator(JOB_DETAIL);
+                    generator.setParameter(JobDetailConstants.TASK_ID, taskId);
+                    generator.setParameter(JobDetailConstants.JOB_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case DATA_TRANSFER_DETAIL:
+                    generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
+                    generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.TASK_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case COMPUTATIONAL_RESOURCE_SCHEDULING:
+                    generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
+                    generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case ADVANCE_INPUT_DATA_HANDLING:
+                    generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
+                    generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case ADVANCE_OUTPUT_DATA_HANDLING:
+                    generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
+                    generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case QOS_PARAM:
+                    generator = new QueryGenerator(QOS_PARAMS);
+                    generator.setParameter(QosParamsConstants.TASK_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                default:
+                    logger.error("Unsupported resource type for task detail resource.", new IllegalArgumentException());
+                    break;
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator;
-        Query q;
-        switch (type) {
-            case ERROR_DETAIL:
-                generator = new QueryGenerator(ERROR_DETAIL);
-                generator.setParameter(ErrorDetailConstants.TASK_ID, name);
-                q = generator.selectQuery(em);
-                ErrorDetail errorDetail = (ErrorDetail)q.getSingleResult();
-                ErrorDetailResource errorDetailResource = (ErrorDetailResource)Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
-                em.getTransaction().commit();
-                em.close();
-                return errorDetailResource;
-            case APPLICATION_INPUT:
-                generator = new QueryGenerator(APPLICATION_INPUT);
-                generator.setParameter(ApplicationInputConstants.TASK_ID, name);
-                q = generator.selectQuery(em);
-                ApplicationInput applicationInput = (ApplicationInput)q.getSingleResult();
-                ApplicationInputResource inputResource = (ApplicationInputResource)Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
-                em.getTransaction().commit();
-                em.close();
-                return inputResource;
-            case APPLICATION_OUTPUT:
-                generator = new QueryGenerator(APPLICATION_OUTPUT);
-                generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
-                q = generator.selectQuery(em);
-                ApplicationOutput applicationOutput = (ApplicationOutput)q.getSingleResult();
-                ApplicationOutputResource outputResource = (ApplicationOutputResource)Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
-                em.getTransaction().commit();
-                em.close();
-                return outputResource;
-            case JOB_DETAIL:
-                generator = new QueryGenerator(JOB_DETAIL);
-                generator.setParameter(JobDetailConstants.JOB_ID, name);
-                generator.setParameter(JobDetailConstants.TASK_ID, taskId);
-                q = generator.selectQuery(em);
-                JobDetail jobDetail = (JobDetail)q.getSingleResult();
-                JobDetailResource jobDetailResource = (JobDetailResource)Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
-                em.getTransaction().commit();
-                em.close();
-                return jobDetailResource;
-            case DATA_TRANSFER_DETAIL:
-                generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
-                generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
-                q = generator.selectQuery(em);
-                DataTransferDetail transferDetail = (DataTransferDetail)q.getSingleResult();
-                DataTransferDetailResource transferDetailResource = (DataTransferDetailResource)Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
-                em.getTransaction().commit();
-                em.close();
-                return transferDetailResource;
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.TASK_ID, name);
-                q = generator.selectQuery(em);
-                Status status = (Status)q.getSingleResult();
-                StatusResource statusResource = (StatusResource)Utils.getResource(ResourceType.STATUS, status);
-                em.getTransaction().commit();
-                em.close();
-                return statusResource;
-            case COMPUTATIONAL_RESOURCE_SCHEDULING:
-                generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
-                generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
-                q = generator.selectQuery(em);
-                Computational_Resource_Scheduling resourceScheduling = (Computational_Resource_Scheduling)q.getSingleResult();
-                ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource)Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling);
-                em.getTransaction().commit();
-                em.close();
-                return schedulingResource;
-            case ADVANCE_INPUT_DATA_HANDLING:
-                generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
-                generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
-                q = generator.selectQuery(em);
-                AdvancedInputDataHandling dataHandling = (AdvancedInputDataHandling)q.getSingleResult();
-                AdvanceInputDataHandlingResource inputDataHandlingResource = (AdvanceInputDataHandlingResource)Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, dataHandling);
-                em.getTransaction().commit();
-                em.close();
-                return inputDataHandlingResource;
-            case ADVANCE_OUTPUT_DATA_HANDLING:
-                generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
-                generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
-                q = generator.selectQuery(em);
-                AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling)q.getSingleResult();
-                AdvancedOutputDataHandlingResource outputDataHandlingResource = (AdvancedOutputDataHandlingResource)Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
-                em.getTransaction().commit();
-                em.close();
-                return outputDataHandlingResource;
-            case QOS_PARAM:
-                generator = new QueryGenerator(QOS_PARAMS);
-                generator.setParameter(QosParamsConstants.TASK_ID, name);
-                q = generator.selectQuery(em);
-                QosParam qosParam = (QosParam)q.getSingleResult();
-                QosParamResource qosParamResource = (QosParamResource)Utils.getResource(ResourceType.QOS_PARAM, qosParam);
-                em.getTransaction().commit();
-                em.close();
-                return qosParamResource;
-            default:
-                em.getTransaction().commit();
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            QueryGenerator generator;
+            Query q;
+            switch (type) {
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.TASK_ID, name);
+                    q = generator.selectQuery(em);
+                    ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
+                    ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+                    em.getTransaction().commit();
+                    em.close();
+                    return errorDetailResource;
+                case APPLICATION_INPUT:
+                    generator = new QueryGenerator(APPLICATION_INPUT);
+                    generator.setParameter(ApplicationInputConstants.TASK_ID, name);
+                    q = generator.selectQuery(em);
+                    ApplicationInput applicationInput = (ApplicationInput) q.getSingleResult();
+                    ApplicationInputResource inputResource = (ApplicationInputResource) Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
+                    em.getTransaction().commit();
+                    em.close();
+                    return inputResource;
+                case APPLICATION_OUTPUT:
+                    generator = new QueryGenerator(APPLICATION_OUTPUT);
+                    generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
+                    q = generator.selectQuery(em);
+                    ApplicationOutput applicationOutput = (ApplicationOutput) q.getSingleResult();
+                    ApplicationOutputResource outputResource = (ApplicationOutputResource) Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
+                    em.getTransaction().commit();
+                    em.close();
+                    return outputResource;
+                case JOB_DETAIL:
+                    generator = new QueryGenerator(JOB_DETAIL);
+                    generator.setParameter(JobDetailConstants.JOB_ID, name);
+                    generator.setParameter(JobDetailConstants.TASK_ID, taskId);
+                    q = generator.selectQuery(em);
+                    JobDetail jobDetail = (JobDetail) q.getSingleResult();
+                    JobDetailResource jobDetailResource = (JobDetailResource) Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
+                    em.getTransaction().commit();
+                    em.close();
+                    return jobDetailResource;
+                case DATA_TRANSFER_DETAIL:
+                    generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
+                    generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
+                    q = generator.selectQuery(em);
+                    DataTransferDetail transferDetail = (DataTransferDetail) q.getSingleResult();
+                    DataTransferDetailResource transferDetailResource = (DataTransferDetailResource) Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
+                    em.getTransaction().commit();
+                    em.close();
+                    return transferDetailResource;
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.TASK_ID, name);
+                    q = generator.selectQuery(em);
+                    Status status = (Status) q.getSingleResult();
+                    StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+                    em.getTransaction().commit();
+                    em.close();
+                    return statusResource;
+                case COMPUTATIONAL_RESOURCE_SCHEDULING:
+                    generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
+                    generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
+                    q = generator.selectQuery(em);
+                    Computational_Resource_Scheduling resourceScheduling = (Computational_Resource_Scheduling) q.getSingleResult();
+                    ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource) Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling);
+                    em.getTransaction().commit();
+                    em.close();
+                    return schedulingResource;
+                case ADVANCE_INPUT_DATA_HANDLING:
+                    generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
+                    generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
+                    q = generator.selectQuery(em);
+                    AdvancedInputDataHandling dataHandling = (AdvancedInputDataHandling) q.getSingleResult();
+                    AdvanceInputDataHandlingResource inputDataHandlingResource = (AdvanceInputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, dataHandling);
+                    em.getTransaction().commit();
+                    em.close();
+                    return inputDataHandlingResource;
+                case ADVANCE_OUTPUT_DATA_HANDLING:
+                    generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
+                    generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
+                    q = generator.selectQuery(em);
+                    AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling) q.getSingleResult();
+                    AdvancedOutputDataHandlingResource outputDataHandlingResource = (AdvancedOutputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
+                    em.getTransaction().commit();
+                    em.close();
+                    return outputDataHandlingResource;
+                case QOS_PARAM:
+                    generator = new QueryGenerator(QOS_PARAMS);
+                    generator.setParameter(QosParamsConstants.TASK_ID, name);
+                    q = generator.selectQuery(em);
+                    QosParam qosParam = (QosParam) q.getSingleResult();
+                    QosParamResource qosParamResource = (QosParamResource) Utils.getResource(ResourceType.QOS_PARAM, qosParam);
+                    em.getTransaction().commit();
+                    em.close();
+                    return qosParamResource;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
+            }
+        } catch (Exception e) {
+//            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
+            }
         }
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
         List<Resource> resourceList = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-        List results;
-        switch (type){
-            case ERROR_DETAIL:
-                generator = new QueryGenerator(ERROR_DETAIL);
-                generator.setParameter(ErrorDetailConstants.TASK_ID, taskId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        ErrorDetail errorDetail = (ErrorDetail) result;
-                        ErrorDetailResource errorDetailResource =
-                                (ErrorDetailResource)Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
-                        resourceList.add(errorDetailResource);
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            List results;
+            switch (type) {
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.TASK_ID, taskId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            ErrorDetail errorDetail = (ErrorDetail) result;
+                            ErrorDetailResource errorDetailResource =
+                                    (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+                            resourceList.add(errorDetailResource);
+                        }
                     }
-                }
-                break;
-            case APPLICATION_INPUT:
-                generator = new QueryGenerator(APPLICATION_INPUT);
-                generator.setParameter(ApplicationInputConstants.TASK_ID, taskId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        ApplicationInput applicationInput = (ApplicationInput) result;
-                        ApplicationInputResource inputResource =
-                                (ApplicationInputResource)Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
-                        resourceList.add(inputResource);
+                    break;
+                case APPLICATION_INPUT:
+                    generator = new QueryGenerator(APPLICATION_INPUT);
+                    generator.setParameter(ApplicationInputConstants.TASK_ID, taskId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            ApplicationInput applicationInput = (ApplicationInput) result;
+                            ApplicationInputResource inputResource =
+                                    (ApplicationInputResource) Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
+                            resourceList.add(inputResource);
+                        }
                     }
-                }
-                break;
-            case APPLICATION_OUTPUT:
-                generator = new QueryGenerator(APPLICATION_OUTPUT);
-                generator.setParameter(ApplicationOutputConstants.TASK_ID, taskId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        ApplicationOutput applicationOutput = (ApplicationOutput) result;
-                        ApplicationOutputResource outputResource =
-                                (ApplicationOutputResource)Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
-                        resourceList.add(outputResource);
+                    break;
+                case APPLICATION_OUTPUT:
+                    generator = new QueryGenerator(APPLICATION_OUTPUT);
+                    generator.setParameter(ApplicationOutputConstants.TASK_ID, taskId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            ApplicationOutput applicationOutput = (ApplicationOutput) result;
+                            ApplicationOutputResource outputResource =
+                                    (ApplicationOutputResource) Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
+                            resourceList.add(outputResource);
+                        }
                     }
-                }
-                break;
-            case JOB_DETAIL:
-                generator = new QueryGenerator(JOB_DETAIL);
-                generator.setParameter(JobDetailConstants.TASK_ID, taskId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        JobDetail jobDetail = (JobDetail) result;
-                        JobDetailResource jobDetailResource =
-                                (JobDetailResource)Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
-                        resourceList.add(jobDetailResource);
+                    break;
+                case JOB_DETAIL:
+                    generator = new QueryGenerator(JOB_DETAIL);
+                    generator.setParameter(JobDetailConstants.TASK_ID, taskId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            JobDetail jobDetail = (JobDetail) result;
+                            JobDetailResource jobDetailResource =
+                                    (JobDetailResource) Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
+                            resourceList.add(jobDetailResource);
+                        }
                     }
-                }
-                break;
-            case DATA_TRANSFER_DETAIL:
-                generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
-                generator.setParameter(DataTransferDetailConstants.TASK_ID, taskId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        DataTransferDetail transferDetail = (DataTransferDetail) result;
-                        DataTransferDetailResource transferDetailResource =
-                                (DataTransferDetailResource)Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
-                        resourceList.add(transferDetailResource);
+                    break;
+                case DATA_TRANSFER_DETAIL:
+                    generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
+                    generator.setParameter(DataTransferDetailConstants.TASK_ID, taskId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            DataTransferDetail transferDetail = (DataTransferDetail) result;
+                            DataTransferDetailResource transferDetailResource =
+                                    (DataTransferDetailResource) Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
+                            resourceList.add(transferDetailResource);
+                        }
                     }
-                }
-                break;
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.TASK_ID, taskId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Status status = (Status) result;
-                        StatusResource statusResource =
-                                (StatusResource)Utils.getResource(ResourceType.STATUS, status);
-                        resourceList.add(statusResource);
+                    break;
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.TASK_ID, taskId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Status status = (Status) result;
+                            StatusResource statusResource =
+                                    (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+                            resourceList.add(statusResource);
+                        }
                     }
-                }
-                break;
-            default:
-                em.getTransaction().commit();
+                    break;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
+                    throw new UnsupportedOperationException();
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
-                throw new UnsupportedOperationException();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
         return resourceList;
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        TaskDetail existingTaskDetail = em.find(TaskDetail.class, taskId);
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        TaskDetail taskDetail = new TaskDetail();
-        taskDetail.setTaskId(taskId);
-        WorkflowNodeDetail workflowNodeDetail = em.find(WorkflowNodeDetail.class, workflowNodeDetailResource.getNodeInstanceId());
-        taskDetail.setNodeDetail(workflowNodeDetail);
-        taskDetail.setNodeId(workflowNodeDetailResource.getNodeInstanceId());
-        taskDetail.setCreationTime(creationTime);
-        taskDetail.setAppId(applicationId);
-        taskDetail.setAppVersion(applicationVersion);
-        if (existingTaskDetail != null){
-            existingTaskDetail.setTaskId(taskId);
-            existingTaskDetail.setNodeDetail(workflowNodeDetail);
-            existingTaskDetail.setNodeId(workflowNodeDetailResource.getNodeInstanceId());
-            existingTaskDetail.setCreationTime(creationTime);
-            existingTaskDetail.setAppId(applicationId);
-            existingTaskDetail.setAppVersion(applicationVersion);
-            taskDetail = em.merge(existingTaskDetail);
-        }else {
-            em.merge(taskDetail);
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            TaskDetail existingTaskDetail = em.find(TaskDetail.class, taskId);
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            TaskDetail taskDetail = new TaskDetail();
+            taskDetail.setTaskId(taskId);
+            WorkflowNodeDetail workflowNodeDetail = em.find(WorkflowNodeDetail.class, workflowNodeDetailResource.getNodeInstanceId());
+            taskDetail.setNodeDetail(workflowNodeDetail);
+            taskDetail.setNodeId(workflowNodeDetailResource.getNodeInstanceId());
+            taskDetail.setCreationTime(creationTime);
+            taskDetail.setAppId(applicationId);
+            taskDetail.setAppVersion(applicationVersion);
+            if (existingTaskDetail != null) {
+                existingTaskDetail.setTaskId(taskId);
+                existingTaskDetail.setNodeDetail(workflowNodeDetail);
+                existingTaskDetail.setNodeId(workflowNodeDetailResource.getNodeInstanceId());
+                existingTaskDetail.setCreationTime(creationTime);
+                existingTaskDetail.setAppId(applicationId);
+                existingTaskDetail.setAppVersion(applicationVersion);
+                taskDetail = em.merge(existingTaskDetail);
+            } else {
+                em.merge(taskDetail);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
-    public List<ApplicationInputResource> getApplicationInputs() {
+    public List<ApplicationInputResource> getApplicationInputs() throws RegistryException{
         List<ApplicationInputResource> applicationInputResources = new ArrayList<ApplicationInputResource>();
         List<Resource> resources = get(ResourceType.APPLICATION_INPUT);
         for (Resource resource : resources) {
@@ -461,7 +499,7 @@ public class TaskDetailResource extends AbstractResource {
         return applicationInputResources;
     }
 
-    public List<ApplicationOutputResource> getApplicationOutputs(){
+    public List<ApplicationOutputResource> getApplicationOutputs() throws RegistryException{
         List<ApplicationOutputResource> outputResources = new ArrayList<ApplicationOutputResource>();
         List<Resource> resources = get(ResourceType.APPLICATION_OUTPUT);
         for (Resource resource : resources) {
@@ -471,7 +509,7 @@ public class TaskDetailResource extends AbstractResource {
         return outputResources;
     }
 
-    public StatusResource getTaskStatus(){
+    public StatusResource getTaskStatus() throws RegistryException{
         List<Resource> resources = get(ResourceType.STATUS);
         for (Resource resource : resources) {
             StatusResource taskStatus = (StatusResource) resource;
@@ -485,7 +523,7 @@ public class TaskDetailResource extends AbstractResource {
         return null;
     }
 
-    public List<JobDetailResource> getJobDetailList(){
+    public List<JobDetailResource> getJobDetailList() throws RegistryException{
         List<JobDetailResource> jobDetailResources = new ArrayList<JobDetailResource>();
         List<Resource> resources = get(ResourceType.JOB_DETAIL);
         for (Resource resource : resources) {
@@ -495,7 +533,7 @@ public class TaskDetailResource extends AbstractResource {
         return jobDetailResources;
     }
 
-    public List<DataTransferDetailResource> getDataTransferDetailList(){
+    public List<DataTransferDetailResource> getDataTransferDetailList() throws RegistryException{
         List<DataTransferDetailResource> transferDetails = new ArrayList<DataTransferDetailResource>();
         List<Resource> resources = get(ResourceType.DATA_TRANSFER_DETAIL);
         for (Resource resource : resources) {
@@ -505,7 +543,7 @@ public class TaskDetailResource extends AbstractResource {
         return transferDetails;
     }
 
-    public List<ErrorDetailResource> getErrorDetailList(){
+    public List<ErrorDetailResource> getErrorDetailList() throws RegistryException{
         List<ErrorDetailResource> errorDetailResources = new ArrayList<ErrorDetailResource>();
         List<Resource> resources = get(ResourceType.ERROR_DETAIL);
         for (Resource resource : resources) {
@@ -515,33 +553,33 @@ public class TaskDetailResource extends AbstractResource {
         return errorDetailResources;
     }
 
-    public ComputationSchedulingResource getComputationScheduling (String taskId){
+    public ComputationSchedulingResource getComputationScheduling (String taskId) throws RegistryException{
         return  (ComputationSchedulingResource)get(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, taskId);
     }
 
-    public AdvanceInputDataHandlingResource getInputDataHandling (String taskId){
+    public AdvanceInputDataHandlingResource getInputDataHandling (String taskId) throws RegistryException{
         return  (AdvanceInputDataHandlingResource)get(ResourceType.ADVANCE_INPUT_DATA_HANDLING, taskId);
     }
 
-    public AdvancedOutputDataHandlingResource getOutputDataHandling (String taskId){
+    public AdvancedOutputDataHandlingResource getOutputDataHandling (String taskId) throws RegistryException{
         return  (AdvancedOutputDataHandlingResource)get(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, taskId);
     }
 
-    public JobDetailResource createJobDetail (String jobId){
+    public JobDetailResource createJobDetail (String jobId) throws RegistryException{
         JobDetailResource resource = (JobDetailResource)create(ResourceType.JOB_DETAIL);
         resource.setJobId(jobId);
         return resource;
     }
 
-    public JobDetailResource getJobDetail (String jobId){
+    public JobDetailResource getJobDetail (String jobId) throws RegistryException{
         return (JobDetailResource)get(ResourceType.JOB_DETAIL, jobId);
     }
 
-    public DataTransferDetailResource getDataTransferDetail (String dataTransferId){
+    public DataTransferDetailResource getDataTransferDetail (String dataTransferId) throws RegistryException{
         return (DataTransferDetailResource)get(ResourceType.DATA_TRANSFER_DETAIL, dataTransferId);
     }
 
-    public  boolean isTaskStatusExist (String taskId){
+    public  boolean isTaskStatusExist (String taskId) throws RegistryException{
         return isExists(ResourceType.STATUS, taskId);
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserResource.java
index 072abd0..53dd172 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserResource.java
@@ -32,6 +32,7 @@ import org.apache.airavata.registry.api.exception.RegistrySettingsException;
 import org.apache.airavata.registry.api.util.RegistrySettings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.airavata.registry.cpi.RegistryException;
 
 import javax.persistence.EntityManager;
 
@@ -67,7 +68,7 @@ public class UserResource extends AbstractResource {
      * @param type child resource type
      * @return child resource
      */
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
@@ -77,7 +78,7 @@ public class UserResource extends AbstractResource {
      * @param type child resource type
      * @param name child resource name
      */
-    public void remove(ResourceType type, Object name) {
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
@@ -88,7 +89,7 @@ public class UserResource extends AbstractResource {
      * @param name child resource name
      * @return UnsupportedOperationException
      */
-    public Resource get(ResourceType type, Object name) {
+    public Resource get(ResourceType type, Object name) throws RegistryException {
         logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
@@ -98,7 +99,7 @@ public class UserResource extends AbstractResource {
      * @param type child resource type
      * @return UnsupportedOperationException
      */
-    public List<Resource> get(ResourceType type) {
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
@@ -106,29 +107,20 @@ public class UserResource extends AbstractResource {
     /**
      * save user to the database
      */
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        Users existingUser = em.find(Users.class, userName);
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Users user = new Users();
-        user.setUser_name(userName);
-        if (password != null && !password.equals("")){
-            try {
-                user.setPassword(SecurityUtil.digestString(password,
-                        RegistrySettings.getSetting("default.registry.password.hash.method")));
-            } catch (NoSuchAlgorithmException e) {
-                throw new RuntimeException("Error hashing default admin password. Invalid hash algorithm.", e);
-            } catch (RegistrySettingsException e) {
-                throw new RuntimeException("Error reading hash algorithm from configurations", e);
-            }
-        }
-        if(existingUser != null){
-            if (password != null && !password.equals("")){
+    public void save() throws RegistryException {
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            Users existingUser = em.find(Users.class, userName);
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Users user = new Users();
+            user.setUser_name(userName);
+            if (password != null && !password.equals("")) {
                 try {
-                    existingUser.setPassword(SecurityUtil.digestString(password,
+                    user.setPassword(SecurityUtil.digestString(password,
                             RegistrySettings.getSetting("default.registry.password.hash.method")));
                 } catch (NoSuchAlgorithmException e) {
                     throw new RuntimeException("Error hashing default admin password. Invalid hash algorithm.", e);
@@ -136,12 +128,30 @@ public class UserResource extends AbstractResource {
                     throw new RuntimeException("Error reading hash algorithm from configurations", e);
                 }
             }
-            user = em.merge(existingUser);
-        }else {
-            em.persist(user);
+            if (existingUser != null) {
+                if (password != null && !password.equals("")) {
+                    try {
+                        existingUser.setPassword(SecurityUtil.digestString(password,
+                                RegistrySettings.getSetting("default.registry.password.hash.method")));
+                    } catch (NoSuchAlgorithmException e) {
+                        throw new RuntimeException("Error hashing default admin password. Invalid hash algorithm.", e);
+                    } catch (RegistrySettingsException e) {
+                        throw new RuntimeException("Error reading hash algorithm from configurations", e);
+                    }
+                }
+                user = em.merge(existingUser);
+            } else {
+                em.persist(user);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
     /**
@@ -150,7 +160,7 @@ public class UserResource extends AbstractResource {
      * @param name child resource name
      * @return UnsupportedOperationException
      */
-    public boolean isExists(ResourceType type, Object name) {
+    public boolean isExists(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserWorkflowResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserWorkflowResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserWorkflowResource.java
index 0ab78d1..c01aa72 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserWorkflowResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserWorkflowResource.java
@@ -23,18 +23,14 @@ package org.apache.airavata.persistance.registry.jpa.resources;
 import org.apache.airavata.persistance.registry.jpa.Resource;
 import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
-import org.apache.airavata.persistance.registry.jpa.model.Gateway;
 import org.apache.airavata.persistance.registry.jpa.model.User_Workflow;
 import org.apache.airavata.persistance.registry.jpa.model.User_Workflow_PK;
-import org.apache.airavata.persistance.registry.jpa.model.Users;
-import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.persistence.EntityManager;
-import javax.persistence.Query;
 import java.sql.Timestamp;
-import java.util.ArrayList;
 import java.util.List;
 
 public class UserWorkflowResource extends AbstractResource {
@@ -87,84 +83,71 @@ public class UserWorkflowResource extends AbstractResource {
         this.path = path;
     }
 
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for user workflow resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public void remove(ResourceType type, Object name) {
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for user workflow resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public Resource get(ResourceType type, Object name) {
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for user workflow resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    /**
-     *
-     * @param keys should be in the order of gateway_name,user_name and user_workflow_name
-     * @return resource list
-     */
-    public List<Resource> populate(Object[] keys) {
-        List<Resource> list = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator queryGenerator = new QueryGenerator(USER_WORKFLOW);
-        queryGenerator.setParameter(UserWorkflowConstants.GATEWAY_NAME, keys[0]);
-        queryGenerator.setParameter(UserWorkflowConstants.OWNER, keys[1]);
-        queryGenerator.setParameter(UserWorkflowConstants.TEMPLATE_NAME, keys[2]);
-        Query q = queryGenerator.selectQuery(em);
-        User_Workflow userWorkflow = (User_Workflow)q.getSingleResult();
-        UserWorkflowResource userWorkflowResource = (UserWorkflowResource)Utils.getResource(
-                ResourceType.USER_WORKFLOW, userWorkflow);
-        em.getTransaction().commit();
-        em.close();
-        list.add(userWorkflowResource);
-        return list;
-    }
-
-    public List<Resource> get(ResourceType type) {
+
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for user workflow resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        User_Workflow existingWF = em.find(User_Workflow.class, new User_Workflow_PK(name, worker.getUser(), gateway.getGatewayName()));
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        User_Workflow userWorkflow = new User_Workflow();
-        userWorkflow.setTemplate_name(name);
-        if(lastUpdateDate == null){
-            java.util.Date date= new java.util.Date();
-            lastUpdateDate = new Timestamp(date.getTime());
-        }
-        userWorkflow.setLast_updated_date(lastUpdateDate);
-        byte[] bytes = content.getBytes();
-        userWorkflow.setWorkflow_graph(bytes);
-        userWorkflow.setGateway_name(this.gateway.getGatewayName());
-        userWorkflow.setOwner(this.getWorker().getUser());
-        userWorkflow.setPath(path);
-        if(existingWF != null){
-            existingWF.setGateway_name(this.gateway.getGatewayName());
-            existingWF.setOwner(this.getWorker().getUser());
-            existingWF.setTemplate_name(name);
-            existingWF.setLast_updated_date(lastUpdateDate);
-            existingWF.setPath(path);
-            existingWF.setWorkflow_graph(bytes);
-            userWorkflow = em.merge(existingWF);
-        } else {
-            em.persist(userWorkflow);
+    public void save() throws RegistryException {
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            User_Workflow existingWF = em.find(User_Workflow.class, new User_Workflow_PK(name, worker.getUser(), gateway.getGatewayName()));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            User_Workflow userWorkflow = new User_Workflow();
+            userWorkflow.setTemplate_name(name);
+            if (lastUpdateDate == null) {
+                java.util.Date date = new java.util.Date();
+                lastUpdateDate = new Timestamp(date.getTime());
+            }
+            userWorkflow.setLast_updated_date(lastUpdateDate);
+            byte[] bytes = content.getBytes();
+            userWorkflow.setWorkflow_graph(bytes);
+            userWorkflow.setGateway_name(this.gateway.getGatewayName());
+            userWorkflow.setOwner(this.getWorker().getUser());
+            userWorkflow.setPath(path);
+            if (existingWF != null) {
+                existingWF.setGateway_name(this.gateway.getGatewayName());
+                existingWF.setOwner(this.getWorker().getUser());
+                existingWF.setTemplate_name(name);
+                existingWF.setLast_updated_date(lastUpdateDate);
+                existingWF.setPath(path);
+                existingWF.setWorkflow_graph(bytes);
+                userWorkflow = em.merge(existingWF);
+            } else {
+                em.persist(userWorkflow);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
-    public boolean isExists(ResourceType type, Object name) {
+    public boolean isExists(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for user workflow resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
index 0c9b603..a818391 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
@@ -21,24 +21,21 @@
 
 package org.apache.airavata.persistance.registry.jpa.resources;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
 import org.apache.airavata.persistance.registry.jpa.Resource;
 import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.*;
 import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
-import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
-import org.apache.openjpa.persistence.OpenJPAPersistence;
-import org.apache.openjpa.persistence.QueryResultCache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.airavata.registry.cpi.RegistryException;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
 public class WorkerResource extends AbstractResource {
     private final static Logger logger = LoggerFactory.getLogger(WorkerResource.class);
@@ -66,7 +63,7 @@ public class WorkerResource extends AbstractResource {
      * @param type child resource type
      * @return  child resource
      */
-	public Resource create(ResourceType type) {
+	public Resource create(ResourceType type) throws RegistryException{
 		Resource result = null;
 		switch (type) {
 			case PROJECT:
@@ -100,39 +97,48 @@ public class WorkerResource extends AbstractResource {
      * @param type child resource type
      * @param name child resource name
      */
-	public void remove(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-		switch (type) {
-			case PROJECT:
-                generator = new QueryGenerator(PROJECT);
-                generator.setParameter(ProjectConstants.PROJECT_ID, name);
-                q = generator.deleteQuery(em);
-	            q.executeUpdate();
-				break;
-			case USER_WORKFLOW:
-                generator = new QueryGenerator(USER_WORKFLOW);
-                generator.setParameter(UserWorkflowConstants.OWNER, getUser());
-                generator.setParameter(UserWorkflowConstants.TEMPLATE_NAME, name);
-                generator.setParameter(UserWorkflowConstants.GATEWAY_NAME, gateway.getGatewayName());
-                q = generator.deleteQuery(em);
-	            q.executeUpdate();
-	            break;
-            case EXPERIMENT:
-                generator = new QueryGenerator(EXPERIMENT);
-                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-			default:
-                logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
-                break;
-		}
-        em.getTransaction().commit();
-        em.close();
-	}
+	public void remove(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            switch (type) {
+                case PROJECT:
+                    generator = new QueryGenerator(PROJECT);
+                    generator.setParameter(ProjectConstants.PROJECT_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case USER_WORKFLOW:
+                    generator = new QueryGenerator(USER_WORKFLOW);
+                    generator.setParameter(UserWorkflowConstants.OWNER, getUser());
+                    generator.setParameter(UserWorkflowConstants.TEMPLATE_NAME, name);
+                    generator.setParameter(UserWorkflowConstants.GATEWAY_NAME, gateway.getGatewayName());
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case EXPERIMENT:
+                    generator = new QueryGenerator(EXPERIMENT);
+                    generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                default:
+                    logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
+                    break;
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e.getMessage());
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
+        }
+    }
 
     /**
      *
@@ -140,45 +146,53 @@ public class WorkerResource extends AbstractResource {
      * @param name child resource name
      * @return child resource
      */
-	public Resource get(ResourceType type, Object name) {
-		Resource result = null;
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator;
-        Query q;
-		switch (type) {
-			case PROJECT:
-                generator = new QueryGenerator(PROJECT);
-                generator.setParameter(ProjectConstants.PROJECT_ID, name);
-                q = generator.selectQuery(em);
-	            Project project = (Project) q.getSingleResult();
-                result= Utils.getResource(ResourceType.PROJECT, project);
-				break;
-			case USER_WORKFLOW:
-                generator = new QueryGenerator(USER_WORKFLOW);
-                generator.setParameter(UserWorkflowConstants.OWNER, getUser());
-                generator.setParameter(UserWorkflowConstants.TEMPLATE_NAME, name);
-                generator.setParameter(UserWorkflowConstants.GATEWAY_NAME, gateway.getGatewayName());
-                q = generator.selectQuery(em);
-	            User_Workflow userWorkflow = (User_Workflow) q.getSingleResult();
-                result= Utils.getResource(ResourceType.USER_WORKFLOW, userWorkflow);
-	            break;
-            case EXPERIMENT:
-                generator = new QueryGenerator(EXPERIMENT);
-                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
-                q = generator.selectQuery(em);
-                Experiment experiment = (Experiment) q.getSingleResult();
-                result= Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                break;
-			default:
-                logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
-                break;
-		}
-        em.getTransaction().commit();
-        em.close();
-		return result;
-	}
-	
+	public Resource get(ResourceType type, Object name) throws RegistryException{
+        Resource result = null;
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            QueryGenerator generator;
+            Query q;
+            switch (type) {
+                case PROJECT:
+                    generator = new QueryGenerator(PROJECT);
+                    generator.setParameter(ProjectConstants.PROJECT_ID, name);
+                    q = generator.selectQuery(em);
+                    Project project = (Project) q.getSingleResult();
+                    result = Utils.getResource(ResourceType.PROJECT, project);
+                    break;
+                case USER_WORKFLOW:
+                    generator = new QueryGenerator(USER_WORKFLOW);
+                    generator.setParameter(UserWorkflowConstants.OWNER, getUser());
+                    generator.setParameter(UserWorkflowConstants.TEMPLATE_NAME, name);
+                    generator.setParameter(UserWorkflowConstants.GATEWAY_NAME, gateway.getGatewayName());
+                    q = generator.selectQuery(em);
+                    User_Workflow userWorkflow = (User_Workflow) q.getSingleResult();
+                    result = Utils.getResource(ResourceType.USER_WORKFLOW, userWorkflow);
+                    break;
+                case EXPERIMENT:
+                    generator = new QueryGenerator(EXPERIMENT);
+                    generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+                    q = generator.selectQuery(em);
+                    Experiment experiment = (Experiment) q.getSingleResult();
+                    result = Utils.getResource(ResourceType.EXPERIMENT, experiment);
+                    break;
+                default:
+                    logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
+                    break;
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
+        }
+        return result;
+    }
+
 //	public List<GFacJobDataResource> getGFacJobs(String serviceDescriptionId, String hostDescriptionId, String applicationDescriptionId){
 //		List<GFacJobDataResource> result = new ArrayList<GFacJobDataResource>();
 //        EntityManager em = ResourceUtils.getEntityManager();
@@ -222,84 +236,102 @@ public class WorkerResource extends AbstractResource {
      * @param type child resource type
      * @return list of child resources
      */
-    public List<Resource> get(ResourceType type) {
-		List<Resource> result = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator;
-        Query q;
-		switch (type) {
-			case PROJECT:
-                generator = new QueryGenerator(PROJECT);
-                Users users = em.find(Users.class, getUser());
-                Gateway gatewayModel = em.find(Gateway.class, gateway.getGatewayName());
-                generator.setParameter("users", users);
-                generator.setParameter("gateway", gatewayModel);
+    public List<Resource> get(ResourceType type) throws RegistryException{
+        List<Resource> result = new ArrayList<Resource>();
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            QueryGenerator generator;
+            Query q;
+            switch (type) {
+                case PROJECT:
+                    generator = new QueryGenerator(PROJECT);
+                    Users users = em.find(Users.class, getUser());
+                    Gateway gatewayModel = em.find(Gateway.class, gateway.getGatewayName());
+                    generator.setParameter("users", users);
+                    generator.setParameter("gateway", gatewayModel);
 //                generator.setParameter(ProjectConstants.USERNAME, getUser());
 //                generator.setParameter(ProjectConstants.GATEWAY_NAME, gateway.getGatewayName());
-                q = generator.selectQuery(em);
-	            for (Object o : q.getResultList()) {
-	            	Project project = (Project) o;
-		            ProjectResource projectResource = (ProjectResource)Utils.getResource(ResourceType.PROJECT, project);
-		            result.add(projectResource);
-				}
-				break;
-			case USER_WORKFLOW:
-                generator = new QueryGenerator(USER_WORKFLOW);
-                generator.setParameter(UserWorkflowConstants.OWNER, getUser());
-                q = generator.selectQuery(em);
+                    q = generator.selectQuery(em);
+                    for (Object o : q.getResultList()) {
+                        Project project = (Project) o;
+                        ProjectResource projectResource = (ProjectResource) Utils.getResource(ResourceType.PROJECT, project);
+                        result.add(projectResource);
+                    }
+                    break;
+                case USER_WORKFLOW:
+                    generator = new QueryGenerator(USER_WORKFLOW);
+                    generator.setParameter(UserWorkflowConstants.OWNER, getUser());
+                    q = generator.selectQuery(em);
 //	            q.setParameter("usr_name", getUser());
-	            for (Object o : q.getResultList()) {
-		            User_Workflow userWorkflow = (User_Workflow) o;
-		            UserWorkflowResource userWorkflowResource = (UserWorkflowResource)Utils.getResource(ResourceType.USER_WORKFLOW, userWorkflow);
-		            result.add(userWorkflowResource);
-	            }
-	            break;
-            case EXPERIMENT:
-                generator = new QueryGenerator(EXPERIMENT);
-                generator.setParameter(ExperimentConstants.EXECUTION_USER, getUser());
-                q = generator.selectQuery(em);
-                for (Object o : q.getResultList()) {
-                    Experiment experiment = (Experiment) o;
-                    ExperimentResource experimentResource = (ExperimentResource)Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                    result.add(experimentResource);
-                }
-                break;
-			default:
-                logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
-                break;
-		}
-        em.getTransaction().commit();
-        em.close();
-		return result;
-	}
+                    for (Object o : q.getResultList()) {
+                        User_Workflow userWorkflow = (User_Workflow) o;
+                        UserWorkflowResource userWorkflowResource = (UserWorkflowResource) Utils.getResource(ResourceType.USER_WORKFLOW, userWorkflow);
+                        result.add(userWorkflowResource);
+                    }
+                    break;
+                case EXPERIMENT:
+                    generator = new QueryGenerator(EXPERIMENT);
+                    generator.setParameter(ExperimentConstants.EXECUTION_USER, getUser());
+                    q = generator.selectQuery(em);
+                    for (Object o : q.getResultList()) {
+                        Experiment experiment = (Experiment) o;
+                        ExperimentResource experimentResource = (ExperimentResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
+                        result.add(experimentResource);
+                    }
+                    break;
+                default:
+                    logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
+                    break;
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
+        }
+        return result;
+    }
 
     /**
      * save gateway worker to database
      */
-	public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        Gateway_Worker existingWorker = em.find(Gateway_Worker.class, new Gateway_Worker_PK(gateway.getGatewayName(), user));
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Gateway_Worker gatewayWorker = new Gateway_Worker();
-        Users users = new Users();
-        users.setUser_name(user);
-        gatewayWorker.setUser(users);
-        Gateway gatewaymodel = new Gateway();
-        gatewaymodel.setGateway_name(gateway.getGatewayName());
-        gatewaymodel.setOwner(gateway.getOwner());
-        gatewayWorker.setGateway(gatewaymodel);
-        if(existingWorker != null){
-            gatewayWorker = em.merge(existingWorker);
-        }else {
-            em.merge(gatewayWorker);
+	public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            Gateway_Worker existingWorker = em.find(Gateway_Worker.class, new Gateway_Worker_PK(gateway.getGatewayName(), user));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Gateway_Worker gatewayWorker = new Gateway_Worker();
+            Users users = new Users();
+            users.setUser_name(user);
+            gatewayWorker.setUser(users);
+            Gateway gatewaymodel = new Gateway();
+            gatewaymodel.setGateway_name(gateway.getGatewayName());
+            gatewaymodel.setOwner(gateway.getOwner());
+            gatewayWorker.setGateway(gatewaymodel);
+            if (existingWorker != null) {
+                gatewayWorker = em.merge(existingWorker);
+            } else {
+                em.merge(gatewayWorker);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
-	}
+    }
 
     /**
      *
@@ -338,7 +370,7 @@ public class WorkerResource extends AbstractResource {
      * @param id  project id
      * @return whether the project is available under the user
      */
-    public boolean isProjectExists(String id){
+    public boolean isProjectExists(String id) throws RegistryException{
 		return isExists(ResourceType.PROJECT, id);
 	}
 
@@ -347,7 +379,7 @@ public class WorkerResource extends AbstractResource {
      * @param projectId project id
      * @return project resource for the user
      */
-	public ProjectResource createProject(String projectId){
+	public ProjectResource createProject(String projectId) throws RegistryException{
 		ProjectResource project=(ProjectResource)create(ResourceType.PROJECT);
         project.setId(projectId);
 		return project;
@@ -363,7 +395,7 @@ public class WorkerResource extends AbstractResource {
      * @param id project id
      * @return project resource
      */
-	public ProjectResource getProject(String id){
+	public ProjectResource getProject(String id) throws RegistryException{
 		return (ProjectResource)get(ResourceType.PROJECT, id);
 	}
 
@@ -371,7 +403,7 @@ public class WorkerResource extends AbstractResource {
      *
      * @param id project id
      */
-	public void removeProject(String id){
+	public void removeProject(String id) throws RegistryException{
 		remove(ResourceType.PROJECT, id);
 	}
 
@@ -379,7 +411,7 @@ public class WorkerResource extends AbstractResource {
      *
      * @return  list of projects for the user
      */
-    public List<ProjectResource> getProjects(){
+    public List<ProjectResource> getProjects() throws RegistryException{
 		List<ProjectResource> result=new ArrayList<ProjectResource>();
 		List<Resource> list = get(ResourceType.PROJECT);
 		for (Resource resource : list) {
@@ -393,7 +425,7 @@ public class WorkerResource extends AbstractResource {
      * @param templateName user workflow template
      * @return whether the workflow is already exists under the given user
      */
-	public boolean isWorkflowTemplateExists(String templateName){
+	public boolean isWorkflowTemplateExists(String templateName) throws RegistryException{
 		return isExists(ResourceType.USER_WORKFLOW, templateName);
 	}
 
@@ -402,7 +434,7 @@ public class WorkerResource extends AbstractResource {
      * @param templateName user workflow template
      * @return user workflow resource
      */
-	public UserWorkflowResource createWorkflowTemplate(String templateName){
+	public UserWorkflowResource createWorkflowTemplate(String templateName) throws RegistryException{
 		UserWorkflowResource workflow=(UserWorkflowResource)create(ResourceType.USER_WORKFLOW);
 		workflow.setName(templateName);
 		return workflow;
@@ -413,7 +445,7 @@ public class WorkerResource extends AbstractResource {
      * @param templateName user workflow template
      * @return user workflow resource
      */
-	public UserWorkflowResource getWorkflowTemplate(String templateName){
+	public UserWorkflowResource getWorkflowTemplate(String templateName) throws RegistryException{
 		return (UserWorkflowResource)get(ResourceType.USER_WORKFLOW, templateName);
 	}
 
@@ -421,7 +453,7 @@ public class WorkerResource extends AbstractResource {
      *
      * @param templateName user workflow template
      */
-    public void removeWorkflowTemplate(String templateName){
+    public void removeWorkflowTemplate(String templateName) throws RegistryException{
 		remove(ResourceType.USER_WORKFLOW, templateName);
 	}
 
@@ -429,7 +461,7 @@ public class WorkerResource extends AbstractResource {
      *
      * @return list of user workflows for the given user
      */
-    public List<UserWorkflowResource> getWorkflowTemplates(){
+    public List<UserWorkflowResource> getWorkflowTemplates() throws RegistryException{
 		List<UserWorkflowResource> result=new ArrayList<UserWorkflowResource>();
 		List<Resource> list = get(ResourceType.USER_WORKFLOW);
 		for (Resource resource : list) {
@@ -443,7 +475,7 @@ public class WorkerResource extends AbstractResource {
      * @param name experiment name
      * @return whether experiment is already exist for the given user
      */
-	public boolean isExperimentExists(String name){
+	public boolean isExperimentExists(String name) throws RegistryException{
 		return isExists(ResourceType.EXPERIMENT, name);
 	}
 	
@@ -453,7 +485,7 @@ public class WorkerResource extends AbstractResource {
      * @param name experiment name
      * @return experiment resource
      */
-    public ExperimentResource getExperiment(String name){
+    public ExperimentResource getExperiment(String name) throws RegistryException{
 		return (ExperimentResource)get(ResourceType.EXPERIMENT, name);
 	}
 //
@@ -465,7 +497,7 @@ public class WorkerResource extends AbstractResource {
      *
      * @return list of experiments for the user
      */
-	public List<ExperimentResource> getExperiments(){
+	public List<ExperimentResource> getExperiments() throws RegistryException{
 		List<ExperimentResource> result=new ArrayList<ExperimentResource>();
 		List<Resource> list = get(ResourceType.EXPERIMENT);
 		for (Resource resource : list) {
@@ -478,57 +510,75 @@ public class WorkerResource extends AbstractResource {
      *
      * @param experimentId  experiment name
      */
-	public void removeExperiment(String experimentId){
+	public void removeExperiment(String experimentId) throws RegistryException{
 		remove(ResourceType.EXPERIMENT, experimentId);
 	}
 
-    public List<ProjectResource> searchProjects (Map<String, String> filters){
+    public List<ProjectResource> searchProjects (Map<String, String> filters) throws RegistryException{
         List<ProjectResource> result = new ArrayList<ProjectResource>();
-        String query = "SELECT p from Project p WHERE ";
-        if (filters != null && filters.size() != 0) {
-           for (String field : filters.keySet()){
-               query += "p." + field + " LIKE '" + filters.get(field) + "%' AND " ;
-           }
-        }
-        query = query.substring(0, query.length() - 5);
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q = em.createQuery(query);
-        List resultList = q.getResultList();
-        for (Object o : resultList){
-            Project project = (Project) o;
-            ProjectResource projectResource = (ProjectResource)Utils.getResource(ResourceType.PROJECT, project);
-            result.add(projectResource);
+        EntityManager em = null;
+        try {
+            String query = "SELECT p from Project p WHERE ";
+            if (filters != null && filters.size() != 0) {
+                for (String field : filters.keySet()) {
+                    query += "p." + field + " LIKE '" + filters.get(field) + "%' AND ";
+                }
+            }
+            query = query.substring(0, query.length() - 5);
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q = em.createQuery(query);
+            List resultList = q.getResultList();
+            for (Object o : resultList) {
+                Project project = (Project) o;
+                ProjectResource projectResource = (ProjectResource) Utils.getResource(ResourceType.PROJECT, project);
+                result.add(projectResource);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
         return result;
     }
 
-    public List<ExperimentResource> searchExperiments (Map<String, String> filters){
+    public List<ExperimentResource> searchExperiments (Map<String, String> filters) throws RegistryException{
         List<ExperimentResource> result = new ArrayList<ExperimentResource>();
-        String query = "SELECT e from Experiment e WHERE ";
-        if (filters != null && filters.size() != 0) {
-            for (String field : filters.keySet()){
-                if (field.equals(ExperimentConstants.EXECUTION_USER)){
-                    query += "e." + field + "= '" + filters.get(field) + "' AND " ;
-                }else {
-                    query += "e." + field + " LIKE '%" + filters.get(field) + "%' AND " ;
+        EntityManager em = null;
+        try {
+            String query = "SELECT e from Experiment e WHERE ";
+            if (filters != null && filters.size() != 0) {
+                for (String field : filters.keySet()) {
+                    if (field.equals(ExperimentConstants.EXECUTION_USER)) {
+                        query += "e." + field + "= '" + filters.get(field) + "' AND ";
+                    } else {
+                        query += "e." + field + " LIKE '%" + filters.get(field) + "%' AND ";
+                    }
                 }
             }
+            query = query.substring(0, query.length() - 5);
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q = em.createQuery(query);
+            List resultList = q.getResultList();
+            for (Object o : resultList) {
+                Experiment experiment = (Experiment) o;
+                ExperimentResource experimentResource = (ExperimentResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
+                result.add(experimentResource);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        query = query.substring(0, query.length() - 5);
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q = em.createQuery(query);
-        List resultList = q.getResultList();
-        for (Object o : resultList){
-            Experiment experiment = (Experiment) o;
-            ExperimentResource experimentResource = (ExperimentResource)Utils.getResource(ResourceType.EXPERIMENT, experiment);
-            result.add(experimentResource);
-        }
-        em.getTransaction().commit();
-        em.close();
         return result;
     }
 
@@ -536,23 +586,32 @@ public class WorkerResource extends AbstractResource {
      *
      * @return list of experiments for the user
      */
-    public List<ExperimentResource> getExperimentsByCaching(String user){
-        List<ExperimentResource> result=new ArrayList<ExperimentResource>();
-        String query = "SELECT e from Experiment e WHERE e.executionUser = '" + user + "'";
-        EntityManager em = ResourceUtils.getEntityManager();
+    public List<ExperimentResource> getExperimentsByCaching(String user) throws RegistryException{
+        List<ExperimentResource> result = new ArrayList<ExperimentResource>();
+        EntityManager em = null;
+        try {
+            String query = "SELECT e from Experiment e WHERE e.executionUser = '" + user + "'";
+            em = ResourceUtils.getEntityManager();
 //        OpenJPAEntityManagerFactory oemf = OpenJPAPersistence.cast(em.getEntityManagerFactory());
 //        QueryResultCache qcache = oemf.getQueryResultCache();
-        // qcache.evictAll(Experiment.class);
-        em.getTransaction().begin();
-        Query q = em.createQuery(query);
-        List resultList = q.getResultList();
-        for (Object o : resultList){
-            Experiment experiment = (Experiment) o;
-            ExperimentResource experimentResource = (ExperimentResource)Utils.getResource(ResourceType.EXPERIMENT, experiment);
-            result.add(experimentResource);
+            // qcache.evictAll(Experiment.class);
+            em.getTransaction().begin();
+            Query q = em.createQuery(query);
+            List resultList = q.getResultList();
+            for (Object o : resultList) {
+                Experiment experiment = (Experiment) o;
+                ExperimentResource experimentResource = (ExperimentResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
+                result.add(experimentResource);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
         return result;
     }
 }


[08/11] adding proper entity manager closing and exception handling - AIRAVATA-1285

Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
index 8e89fc8..d1eba22 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
@@ -43,7 +43,7 @@ public class RegistryImpl implements Registry {
     private ExperimentRegistry experimentRegistry = null;
     private ProjectRegistry projectRegistry = null;
 
-    public RegistryImpl() {
+    public RegistryImpl() throws RegistryException{
         try {
             if (!ResourceUtils.isGatewayExist(ServerSettings.getSystemUserGateway())){
                 gatewayResource = (GatewayResource) ResourceUtils.createGateway(ServerSettings.getSystemUserGateway());
@@ -65,7 +65,7 @@ public class RegistryImpl implements Registry {
         }
     }
 
-    public RegistryImpl(String gateway, String username, String password) {
+    public RegistryImpl(String gateway, String username, String password) throws RegistryException{
         if (!ResourceUtils.isGatewayExist(gateway)){
             gatewayResource = (GatewayResource) ResourceUtils.createGateway(gateway);
             gatewayResource.save();

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/UserReg.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/UserReg.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/UserReg.java
index 1c8a2c9..5dc2868 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/UserReg.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/UserReg.java
@@ -26,16 +26,15 @@ import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.resources.UserResource;
 import org.apache.airavata.persistance.registry.jpa.resources.WorkerResource;
+import org.apache.airavata.registry.cpi.RegistryException;
 
 public class UserReg {
-    public WorkerResource getSystemUser() throws ApplicationSettingsException {
-        WorkerResource worker = (WorkerResource)ResourceUtils.getWorker(ServerSettings.getSystemUserGateway(), ServerSettings.getSystemUser());
-        return worker;
+    public WorkerResource getSystemUser() throws ApplicationSettingsException, RegistryException {
+        return (WorkerResource)ResourceUtils.getWorker(ServerSettings.getSystemUserGateway(), ServerSettings.getSystemUser());
     }
 
-    public WorkerResource getExistingUser (String gatewayName, String userName) {
-        WorkerResource worker = (WorkerResource)ResourceUtils.getWorker(gatewayName, userName);
-        return worker;
+    public WorkerResource getExistingUser (String gatewayName, String userName) throws RegistryException {
+        return (WorkerResource)ResourceUtils.getWorker(gatewayName, userName);
     }
 
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
index a185560..c16d8a5 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
@@ -25,6 +25,7 @@ import java.util.List;
 
 import org.apache.airavata.persistance.registry.jpa.Resource;
 import org.apache.airavata.persistance.registry.jpa.ResourceType;
+import org.apache.airavata.registry.cpi.RegistryException;
 
 public abstract class AbstractResource implements Resource {
 	// table names
@@ -57,7 +58,7 @@ public abstract class AbstractResource implements Resource {
 	public static final String COMPUTATIONAL_RESOURCE_SCHEDULING = "Computational_Resource_Scheduling";
 	public static final String ADVANCE_INPUT_DATA_HANDLING = "AdvancedInputDataHandling";
 	public static final String ADVANCE_OUTPUT_DATA_HANDLING = "AdvancedOutputDataHandling";
-	public static final String QOS_PARAMS = "QosParams";
+	public static final String QOS_PARAMS = "QosParam";
 
 
 	// Gateway Table
@@ -337,7 +338,7 @@ public abstract class AbstractResource implements Resource {
 	protected AbstractResource() {
 	}
 
-	public boolean isExists(ResourceType type, Object name) {
+	public boolean isExists(ResourceType type, Object name) throws RegistryException {
 		try {
 			return get(type, name) != null;
 		} catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvanceInputDataHandlingResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvanceInputDataHandlingResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvanceInputDataHandlingResource.java
index 642d291..d38768c 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvanceInputDataHandlingResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvanceInputDataHandlingResource.java
@@ -25,9 +25,9 @@ import org.apache.airavata.persistance.registry.jpa.Resource;
 import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.AdvancedInputDataHandling;
-import org.apache.airavata.persistance.registry.jpa.model.AdvancedOutputDataHandling;
 import org.apache.airavata.persistance.registry.jpa.model.Experiment;
 import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -100,56 +100,66 @@ public class AdvanceInputDataHandlingResource extends AbstractResource {
         this.cleanAfterJob = cleanAfterJob;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for input data handling resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
+    
+    public void remove(ResourceType type, Object name) throws RegistryException {
         logger.error("Unsupported resource type for input data handling resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for input data handling resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for input data handling resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        AdvancedInputDataHandling dataHandling;
-        if (dataHandlingId != 0 ){
-            dataHandling = em.find(AdvancedInputDataHandling.class, dataHandlingId);
-            dataHandling.setDataHandlingId(dataHandlingId);
-        }else {
-            dataHandling = new AdvancedInputDataHandling();
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            AdvancedInputDataHandling dataHandling;
+            if (dataHandlingId != 0) {
+                dataHandling = em.find(AdvancedInputDataHandling.class, dataHandlingId);
+                dataHandling.setDataHandlingId(dataHandlingId);
+            } else {
+                dataHandling = new AdvancedInputDataHandling();
+            }
+            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+            if (taskDetailResource != null) {
+                TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+                dataHandling.setTaskId(taskDetailResource.getTaskId());
+                dataHandling.setTask(taskDetail);
+            }
+            dataHandling.setExpId(experimentResource.getExpID());
+            dataHandling.setExperiment(experiment);
+            dataHandling.setWorkingDir(workingDir);
+            dataHandling.setParentWorkingDir(workingDirParent);
+            dataHandling.setStageInputsToWorkingDir(stageInputFiles);
+            dataHandling.setCleanAfterJob(cleanAfterJob);
+            em.persist(dataHandling);
+            dataHandlingId = dataHandling.getDataHandlingId();
+            em.getTransaction().commit();
+
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
         }
-        Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-        if (taskDetailResource !=null){
-            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-            dataHandling.setTaskId(taskDetailResource.getTaskId());
-            dataHandling.setTask(taskDetail);
-        }
-        dataHandling.setExpId(experimentResource.getExpID());
-        dataHandling.setExperiment(experiment);
-        dataHandling.setWorkingDir(workingDir);
-        dataHandling.setParentWorkingDir(workingDirParent);
-        dataHandling.setStageInputsToWorkingDir(stageInputFiles);
-        dataHandling.setCleanAfterJob(cleanAfterJob);
-        em.persist(dataHandling);
-        dataHandlingId = dataHandling.getDataHandlingId();
-        em.getTransaction().commit();
-        em.close();
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvancedOutputDataHandlingResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvancedOutputDataHandlingResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvancedOutputDataHandlingResource.java
index 52105a0..7ff23c6 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvancedOutputDataHandlingResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvancedOutputDataHandlingResource.java
@@ -27,6 +27,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.AdvancedOutputDataHandling;
 import org.apache.airavata.persistance.registry.jpa.model.Experiment;
 import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -90,56 +91,65 @@ public class AdvancedOutputDataHandlingResource extends AbstractResource {
         this.persistOutputData = persistOutputData;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for output data handling resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
+
+    public void remove(ResourceType type, Object name) throws RegistryException {
         logger.error("Unsupported resource type for output data handling resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
+
+    public Resource get(ResourceType type, Object name) throws RegistryException  {
         logger.error("Unsupported resource type for output data handling resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for output data handling resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        AdvancedOutputDataHandling dataHandling;
-        if (outputDataHandlingId != 0 ){
-            dataHandling = em.find(AdvancedOutputDataHandling.class, outputDataHandlingId);
-            dataHandling.setOutputDataHandlingId(outputDataHandlingId);
-        }else {
-            dataHandling = new AdvancedOutputDataHandling();
-        }
-        Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-        if (taskDetailResource !=null){
-            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-            dataHandling.setTaskId(taskDetailResource.getTaskId());
-            dataHandling.setTask(taskDetail);
-        }
 
-        dataHandling.setExpId(experimentResource.getExpID());
-        dataHandling.setExperiment(experiment);
-        dataHandling.setDataRegUrl(dataRegUrl);
-        dataHandling.setOutputDataDir(outputDataDir);
-        dataHandling.setPersistOutputData(persistOutputData);
-        em.persist(dataHandling);
-        outputDataHandlingId = dataHandling.getOutputDataHandlingId();
-        em.getTransaction().commit();
-        em.close();
+    public void save() throws RegistryException {
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            AdvancedOutputDataHandling dataHandling;
+            if (outputDataHandlingId != 0 ){
+                dataHandling = em.find(AdvancedOutputDataHandling.class, outputDataHandlingId);
+                dataHandling.setOutputDataHandlingId(outputDataHandlingId);
+            }else {
+                dataHandling = new AdvancedOutputDataHandling();
+            }
+            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+            if (taskDetailResource !=null){
+                TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+                dataHandling.setTaskId(taskDetailResource.getTaskId());
+                dataHandling.setTask(taskDetail);
+            }
+
+            dataHandling.setExpId(experimentResource.getExpID());
+            dataHandling.setExperiment(experiment);
+            dataHandling.setDataRegUrl(dataRegUrl);
+            dataHandling.setOutputDataDir(outputDataDir);
+            dataHandling.setPersistOutputData(persistOutputData);
+            em.persist(dataHandling);
+            outputDataHandlingId = dataHandling.getOutputDataHandlingId();
+            em.getTransaction().commit();
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AiravataRegistryConnectionDataProviderImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AiravataRegistryConnectionDataProviderImpl.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AiravataRegistryConnectionDataProviderImpl.java
index 1d11e56..8cff3cb 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AiravataRegistryConnectionDataProviderImpl.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AiravataRegistryConnectionDataProviderImpl.java
@@ -25,15 +25,10 @@ import org.apache.airavata.registry.api.AiravataRegistryConnectionDataProvider;
 import org.apache.airavata.registry.api.AiravataUser;
 import org.apache.airavata.registry.api.Gateway;
 import org.apache.airavata.registry.api.exception.RegistrySettingsException;
-import org.apache.airavata.registry.api.exception.UnknownRegistryConnectionDataException;
 import org.apache.airavata.registry.api.util.RegistrySettings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-import java.net.URL;
-import java.util.Properties;
-
 public class AiravataRegistryConnectionDataProviderImpl implements AiravataRegistryConnectionDataProvider {
 
     private final static Logger logger = LoggerFactory.getLogger(AiravataRegistryConnectionDataProviderImpl.class);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java
index 8e8f994..1901172 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java
@@ -24,7 +24,7 @@ import org.apache.airavata.persistance.registry.jpa.Resource;
 import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.*;
-import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -145,7 +145,7 @@ public class ApplicationDescriptorResource extends AbstractResource {
      * @param type  child resource types
      * @return UnsupportedOperationException
      */
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported operation for application descriptor resource " +
                 "since application descriptors could not create child resources.. ", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
@@ -157,7 +157,7 @@ public class ApplicationDescriptorResource extends AbstractResource {
      * @param type child resource types
      * @param name name of the resource
      */
-    public void remove(ResourceType type, Object name) {
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported operation for application descriptor resource " +
                 "since application descriptors could not remove child resources.. ", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
@@ -190,37 +190,12 @@ public class ApplicationDescriptorResource extends AbstractResource {
      * @param name name of the resource
      * @return UnsupportedOperationException
      */
-    public Resource get(ResourceType type, Object name) {
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported operation for application descriptor resource " +
                 "since there are no child resources generated by application descriptors.. ", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    /**
-     * keys should contain gateway_name, application_descriptor_ID, host_descriptor_ID, service_descriptor_ID
-     *
-     * @param keys names
-     * @return list of ApplicationDescriptorResources
-     */
-    public List<Resource> populate(Object[] keys) {
-        List<Resource> list = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator queryGenerator = new QueryGenerator(APPLICATION_DESCRIPTOR);
-        queryGenerator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, keys[0]);
-        queryGenerator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID, keys[1]);
-        queryGenerator.setParameter(ApplicationDescriptorConstants.HOST_DESC_ID, keys[2]);
-        queryGenerator.setParameter(ApplicationDescriptorConstants.SERVICE_DESC_ID, keys[3]);
-        Query q = queryGenerator.selectQuery(em);
-        Application_Descriptor applicationDescriptor = (Application_Descriptor) q.getSingleResult();
-        ApplicationDescriptorResource applicationDescriptorResource =
-                (ApplicationDescriptorResource) Utils.getResource(
-                        ResourceType.APPLICATION_DESCRIPTOR, applicationDescriptor);
-        em.getTransaction().commit();
-        em.close();
-        list.add(applicationDescriptorResource);
-        return list;
-    }
 
     /**
      * Since application descriptors are at the leaf level, this method is not
@@ -228,7 +203,7 @@ public class ApplicationDescriptorResource extends AbstractResource {
      * @param type child resource types
      * @return UnsupportedOperationException
      */
-    public List<Resource> get(ResourceType type) {
+    public List<Resource> get(ResourceType type) throws RegistryException {
         logger.error("Unsupported operation for application descriptor resource " +
                 "since there are no child resources generated by application descriptors.. ", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
@@ -237,9 +212,10 @@ public class ApplicationDescriptorResource extends AbstractResource {
     /**
      *  save application descriptor to database
      */
-    public void save() {
+    public void save() throws RegistryException{
+        EntityManager em = null;
         try{
-            EntityManager em = ResourceUtils.getEntityManager();
+            em = ResourceUtils.getEntityManager();
             Application_Descriptor existingAppDesc = em.find(Application_Descriptor.class, new Application_Descriptor_PK(gatewayName, name));
             em.close();
 
@@ -266,9 +242,13 @@ public class ApplicationDescriptorResource extends AbstractResource {
                 em.persist(applicationDescriptor);
             }
             em.getTransaction().commit();
-            em.close();
         } catch (Exception e){
-            e.printStackTrace();
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                em.close();
+            }
         }
 
     }
@@ -280,7 +260,7 @@ public class ApplicationDescriptorResource extends AbstractResource {
      * @param name name of the resource
      * @return UnsupportedOperationException
      */
-    public boolean isExists(ResourceType type, Object name) {
+    public boolean isExists(ResourceType type, Object name) throws RegistryException {
         logger.error("Unsupported operation for application descriptor resource " +
                 "since there are no child resources generated by application descriptors.. ", new UnsupportedOperationException());
         throw new UnsupportedOperationException();

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java
index 51dd057..9a9786b 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java
@@ -31,6 +31,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.ApplicationInput;
 import org.apache.airavata.persistance.registry.jpa.model.ApplicationInput_PK;
 import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -82,59 +83,67 @@ public class ApplicationInputResource extends AbstractResource {
         this.taskDetailResource = taskDetailResource;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException {
         logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        ApplicationInput existingInput = em.find(ApplicationInput.class, new ApplicationInput_PK(inputKey, taskDetailResource.getTaskId()));
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        ApplicationInput applicationInput = new ApplicationInput();
-        TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-        applicationInput.setTask(taskDetail);
-        applicationInput.setTaskId(taskDetail.getTaskId());
-        applicationInput.setInputKey(inputKey);
-        applicationInput.setInputKeyType(inputType);
-        applicationInput.setValue(value);
-        applicationInput.setMetadata(metadata);
-        
-        if (existingInput != null){
-            existingInput.setTask(taskDetail);
-            existingInput.setTaskId(taskDetail.getTaskId());
-            existingInput.setInputKey(inputKey);
-            existingInput.setInputKeyType(inputType);
-            existingInput.setValue(value);
-            existingInput.setMetadata(metadata);
-            applicationInput = em.merge(existingInput);
-        }else {
-            em.persist(applicationInput);
+    
+    public void save() throws RegistryException {
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            ApplicationInput existingInput = em.find(ApplicationInput.class, new ApplicationInput_PK(inputKey, taskDetailResource.getTaskId()));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            ApplicationInput applicationInput = new ApplicationInput();
+            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+            applicationInput.setTask(taskDetail);
+            applicationInput.setTaskId(taskDetail.getTaskId());
+            applicationInput.setInputKey(inputKey);
+            applicationInput.setInputKeyType(inputType);
+            applicationInput.setValue(value);
+            applicationInput.setMetadata(metadata);
+
+            if (existingInput != null) {
+                existingInput.setTask(taskDetail);
+                existingInput.setTaskId(taskDetail.getTaskId());
+                existingInput.setInputKey(inputKey);
+                existingInput.setInputKeyType(inputType);
+                existingInput.setValue(value);
+                existingInput.setMetadata(metadata);
+                applicationInput = em.merge(existingInput);
+            } else {
+                em.persist(applicationInput);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            throw new RegistryException(e.getMessage());
+        } finally {
+                if (em != null && em.isOpen()) {
+                    em.close();
+                }
+            }
         }
-        em.getTransaction().commit();
-        em.close();
-    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java
index 6a0f43e..1f80629 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java
@@ -31,6 +31,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.ApplicationOutput;
 import org.apache.airavata.persistance.registry.jpa.model.ApplicationOutput_PK;
 import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -82,61 +83,69 @@ public class ApplicationOutputResource extends AbstractResource {
         this.taskDetailResource = taskDetailResource;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        ApplicationOutput existingOutput = em.find(ApplicationOutput.class, new ApplicationOutput_PK(outputKey, taskDetailResource.getTaskId()));
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        ApplicationOutput applicationOutput = new ApplicationOutput();
-        TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-        applicationOutput.setTask(taskDetail);
-        applicationOutput.setTaskId(taskDetail.getTaskId());
-        applicationOutput.setOutputKey(outputKey);
-        applicationOutput.setOutputKeyType(outputType);
-        applicationOutput.setValue(value);
-        applicationOutput.setMetadata(metadata);
-        
-        if (existingOutput != null){
-        	existingOutput.setTask(taskDetail);
-        	existingOutput.setTaskId(taskDetail.getTaskId());
-        	existingOutput.setOutputKey(outputKey);
-        	existingOutput.setOutputKeyType(outputType);
-        	existingOutput.setValue(value);
-        	existingOutput.setMetadata(metadata);
-        	applicationOutput = em.merge(existingOutput);
-        }else {
-            em.persist(applicationOutput);
+    
+    public void save() throws RegistryException {
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            ApplicationOutput existingOutput = em.find(ApplicationOutput.class, new ApplicationOutput_PK(outputKey, taskDetailResource.getTaskId()));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            ApplicationOutput applicationOutput = new ApplicationOutput();
+            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+            applicationOutput.setTask(taskDetail);
+            applicationOutput.setTaskId(taskDetail.getTaskId());
+            applicationOutput.setOutputKey(outputKey);
+            applicationOutput.setOutputKeyType(outputType);
+            applicationOutput.setValue(value);
+            applicationOutput.setMetadata(metadata);
+
+            if (existingOutput != null) {
+                existingOutput.setTask(taskDetail);
+                existingOutput.setTaskId(taskDetail.getTaskId());
+                existingOutput.setOutputKey(outputKey);
+                existingOutput.setOutputKeyType(outputType);
+                existingOutput.setValue(value);
+                existingOutput.setMetadata(metadata);
+                applicationOutput = em.merge(existingOutput);
+            } else {
+                em.persist(applicationOutput);
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e.getMessage());
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
-
-
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ComputationSchedulingResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ComputationSchedulingResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ComputationSchedulingResource.java
index 0479969..97a8a81 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ComputationSchedulingResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ComputationSchedulingResource.java
@@ -27,6 +27,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.Computational_Resource_Scheduling;
 import org.apache.airavata.persistance.registry.jpa.model.Experiment;
 import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -145,61 +146,70 @@ public class ComputationSchedulingResource extends AbstractResource {
         this.projectName = projectName;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Computational_Resource_Scheduling scheduling;
-        if (schedulingId != 0){
-            scheduling = em.find(Computational_Resource_Scheduling.class, schedulingId);
-            scheduling.setSchedulingId(schedulingId);
-        }else {
-            scheduling = new Computational_Resource_Scheduling();
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Computational_Resource_Scheduling scheduling;
+            if (schedulingId != 0) {
+                scheduling = em.find(Computational_Resource_Scheduling.class, schedulingId);
+                scheduling.setSchedulingId(schedulingId);
+            } else {
+                scheduling = new Computational_Resource_Scheduling();
+            }
+            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+            if (taskDetailResource != null) {
+                TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+                scheduling.setTask(taskDetail);
+                scheduling.setTaskId(taskDetailResource.getTaskId());
+            }
+            scheduling.setExpId(experimentResource.getExpID());
+            scheduling.setExperiment(experiment);
+            scheduling.setResourceHostId(resourceHostId);
+            scheduling.setCpuCount(cpuCount);
+            scheduling.setNodeCount(nodeCount);
+            scheduling.setNumberOfThreads(numberOfThreads);
+            scheduling.setQueueName(queueName);
+            scheduling.setWallTimeLimit(walltimeLimit);
+            scheduling.setJobStartTime(jobStartTime);
+            scheduling.setTotalPhysicalmemory(physicalMemory);
+            scheduling.setProjectName(projectName);
+            em.persist(scheduling);
+            schedulingId = scheduling.getSchedulingId();
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-        if (taskDetailResource != null){
-            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-            scheduling.setTask(taskDetail);
-            scheduling.setTaskId(taskDetailResource.getTaskId());
-        }
-        scheduling.setExpId(experimentResource.getExpID());
-        scheduling.setExperiment(experiment);
-        scheduling.setResourceHostId(resourceHostId);
-        scheduling.setCpuCount(cpuCount);
-        scheduling.setNodeCount(nodeCount);
-        scheduling.setNumberOfThreads(numberOfThreads);
-        scheduling.setQueueName(queueName);
-        scheduling.setWallTimeLimit(walltimeLimit);
-        scheduling.setJobStartTime(jobStartTime);
-        scheduling.setTotalPhysicalmemory(physicalMemory);
-        scheduling.setProjectName(projectName);
-        em.persist(scheduling);
-        schedulingId = scheduling.getSchedulingId();
-        em.getTransaction().commit();
-        em.close();
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigDataResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigDataResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigDataResource.java
index 3313f19..b972e4f 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigDataResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigDataResource.java
@@ -26,7 +26,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceType;
 import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.Experiment;
 import org.apache.airavata.persistance.registry.jpa.model.ExperimentConfigData;
-import org.apache.airavata.schemas.gfac.BooleanParameterType;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -72,56 +72,65 @@ public class ConfigDataResource extends AbstractResource {
         this.shareExp = shareExp;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        ExperimentConfigData existingConfig = em.find(ExperimentConfigData.class, experimentResource.getExpID());
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        ExperimentConfigData configData = new ExperimentConfigData();
-        Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-        configData.setExpId(experimentResource.getExpID());
-        configData.setExperiment(experiment);
-        configData.setAiravataAutoSchedule(airavataAutoSchedule);
-        configData.setOverrideManualParams(overrideManualParams);
-        configData.setShareExp(shareExp);
-        if (existingConfig != null){
-            existingConfig.setExpId(experimentResource.getExpID());
-            existingConfig.setExperiment(experiment);
-            existingConfig.setAiravataAutoSchedule(airavataAutoSchedule);
-            existingConfig.setOverrideManualParams(overrideManualParams);
-            existingConfig.setShareExp(shareExp);
-            configData = em.merge(existingConfig);
-        }else {
-            em.merge(configData);
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            ExperimentConfigData existingConfig = em.find(ExperimentConfigData.class, experimentResource.getExpID());
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            ExperimentConfigData configData = new ExperimentConfigData();
+            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+            configData.setExpId(experimentResource.getExpID());
+            configData.setExperiment(experiment);
+            configData.setAiravataAutoSchedule(airavataAutoSchedule);
+            configData.setOverrideManualParams(overrideManualParams);
+            configData.setShareExp(shareExp);
+            if (existingConfig != null) {
+                existingConfig.setExpId(experimentResource.getExpID());
+                existingConfig.setExperiment(experiment);
+                existingConfig.setAiravataAutoSchedule(airavataAutoSchedule);
+                existingConfig.setOverrideManualParams(overrideManualParams);
+                existingConfig.setShareExp(shareExp);
+                configData = em.merge(existingConfig);
+            } else {
+                em.merge(configData);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java
index 8b915f7..8da1089 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java
@@ -34,6 +34,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.Configuration;
 import org.apache.airavata.persistance.registry.jpa.model.Configuration_PK;
 import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -63,7 +64,7 @@ public class ConfigurationResource extends AbstractResource {
      * @param type child resource types
      * @return UnsupportedOperationException
      */
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported operation for configuration resource " +
                 "since there are no child resources generated by configuration resource.. ",
                 new UnsupportedOperationException());
@@ -77,7 +78,7 @@ public class ConfigurationResource extends AbstractResource {
      * @param name  name of the child resource
      * throws UnsupportedOperationException
      */
-    public void remove(ResourceType type, Object name) {
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported operation for configuration resource " +
                 "since there are no child resources generated by configuration resource.. ",
                 new UnsupportedOperationException());
@@ -92,7 +93,7 @@ public class ConfigurationResource extends AbstractResource {
      * @param name  name of the child resource
      * @return UnsupportedOperationException
      */
-    public Resource get(ResourceType type, Object name) {
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported operation for configuration resource " +
                 "since there are no child resources generated by configuration resource.. ",
                 new UnsupportedOperationException());
@@ -104,7 +105,7 @@ public class ConfigurationResource extends AbstractResource {
      * @param keys names
      * @return list of ConfigurationResources
      */
-    public List<Resource> populate(Object[] keys) {
+    public List<Resource> populate(Object[] keys) throws RegistryException{
         List<Resource> list = new ArrayList<Resource>();
         EntityManager em = ResourceUtils.getEntityManager();
         em.getTransaction().begin();
@@ -121,7 +122,16 @@ public class ConfigurationResource extends AbstractResource {
             }
         }
         em.getTransaction().commit();
-        em.close();
+        try {
+            em.close();
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em.isOpen()){
+                em.close();
+            }
+        }
         return list;
 
     }
@@ -133,7 +143,7 @@ public class ConfigurationResource extends AbstractResource {
      * @param type child resource types
      * @return UnsupportedOperationException
      */
-    public List<Resource> get(ResourceType type) {
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported operation for configuration resource " +
                 "since there are no child resources generated by configuration resource.. ",
                 new UnsupportedOperationException());
@@ -151,14 +161,23 @@ public class ConfigurationResource extends AbstractResource {
     /**
      *  save configuration to database
      */
-    public synchronized void save() {
+    public synchronized void save() throws RegistryException{
         Lock lock = ResourceUtils.getLock();
         lock.lock();
         try {
             EntityManager em = ResourceUtils.getEntityManager();
             //whether existing
             Configuration existing = em.find(Configuration.class, new Configuration_PK(configKey, configVal, categoryID));
-            em.close();
+            try {
+                em.close();
+            }catch (Exception e){
+                logger.error(e.getMessage(), e);
+                throw new RegistryException(e);
+            }finally {
+                if (em.isOpen()){
+                    em.close();
+                }
+            }
 
             em = ResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -176,7 +195,16 @@ public class ConfigurationResource extends AbstractResource {
             }
 
             em.getTransaction().commit();
-            em.close();
+            try {
+                em.close();
+            }catch (Exception e){
+                logger.error(e.getMessage(), e);
+                throw new RegistryException(e);
+            }finally {
+                if (em.isOpen()){
+                    em.close();
+                }
+            }
         }
         finally {
             lock.unlock();

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DataTransferDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DataTransferDetailResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DataTransferDetailResource.java
index bd2a5c0..20ded67 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DataTransferDetailResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DataTransferDetailResource.java
@@ -28,6 +28,7 @@ import org.apache.airavata.persistance.registry.jpa.model.DataTransferDetail;
 import org.apache.airavata.persistance.registry.jpa.model.Status;
 import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
 import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.apache.airavata.registry.cpi.utils.StatusType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -77,8 +78,8 @@ public class DataTransferDetailResource extends AbstractResource {
         this.transferDescription = transferDescription;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException {
         switch (type){
             case STATUS:
                 StatusResource statusResource = new StatusResource();
@@ -90,119 +91,155 @@ public class DataTransferDetailResource extends AbstractResource {
         }
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-        switch (type){
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.TRANSFER_ID, name);
-                q = generator.deleteQuery(em);
-                q.executeUpdate();
-                break;
-            default:
-                logger.error("Unsupported resource type for data transfer details resource.", new IllegalArgumentException());
-                break;
+    
+    public void remove(ResourceType type, Object name) throws RegistryException {
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            switch (type) {
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.TRANSFER_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                default:
+                    logger.error("Unsupported resource type for data transfer details resource.", new IllegalArgumentException());
+                    break;
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator generator;
-        Query q;
-        switch (type) {
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.TRANSFER_ID, name);
-                q = generator.selectQuery(em);
-                Status status = (Status)q.getSingleResult();
-                StatusResource statusResource = (StatusResource)Utils.getResource(ResourceType.STATUS, status);
-                em.getTransaction().commit();
-                em.close();
-                return statusResource;
-            default:
-                em.getTransaction().commit();
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            QueryGenerator generator;
+            Query q;
+            switch (type) {
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.TRANSFER_ID, name);
+                    q = generator.selectQuery(em);
+                    Status status = (Status) q.getSingleResult();
+                    StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+                    em.getTransaction().commit();
+                    em.close();
+                    return statusResource;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for data transfer details resource.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Unsupported resource type for data transfer details resource.");
+            }
+        } catch (Exception e) {
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                logger.error("Unsupported resource type for data transfer details resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for data transfer details resource.");
+            }
         }
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
         List<Resource> resourceList = new ArrayList<Resource>();
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Query q;
-        QueryGenerator generator;
-        List results;
-        switch (type){
-            case STATUS:
-                generator = new QueryGenerator(STATUS);
-                generator.setParameter(StatusConstants.TRANSFER_ID, transferId);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        Status status = (Status) result;
-                        StatusResource statusResource =
-                                (StatusResource)Utils.getResource(ResourceType.STATUS, status);
-                        resourceList.add(statusResource);
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            List results;
+            switch (type) {
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.TRANSFER_ID, transferId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Status status = (Status) result;
+                            StatusResource statusResource =
+                                    (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+                            resourceList.add(statusResource);
+                        }
                     }
-                }
-                break;
-            default:
-                em.getTransaction().commit();
+                    break;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
+                    throw new UnsupportedOperationException();
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
                 em.close();
-                logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
-                throw new UnsupportedOperationException();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
         return resourceList;
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        DataTransferDetail existingDF = em.find(DataTransferDetail.class, transferId);
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        DataTransferDetail dataTransferDetail = new DataTransferDetail();
-        TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-        dataTransferDetail.setTransferId(transferId);
-        dataTransferDetail.setTask(taskDetail);
-        dataTransferDetail.setTaskId(taskDetailResource.getTaskId());
-        dataTransferDetail.setCreationTime(creationTime);
-        if (transferDescription != null){
-            dataTransferDetail.setTransferDesc(transferDescription.toCharArray());
-        }
-        if (existingDF != null){
-            existingDF.setTransferId(transferId);
-            existingDF.setTask(taskDetail);
-            existingDF.setTaskId(taskDetailResource.getTaskId());
-            existingDF.setCreationTime(creationTime);
-            if (transferDescription != null){
-                existingDF.setTransferDesc(transferDescription.toCharArray());
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            DataTransferDetail existingDF = em.find(DataTransferDetail.class, transferId);
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            DataTransferDetail dataTransferDetail = new DataTransferDetail();
+            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+            dataTransferDetail.setTransferId(transferId);
+            dataTransferDetail.setTask(taskDetail);
+            dataTransferDetail.setTaskId(taskDetailResource.getTaskId());
+            dataTransferDetail.setCreationTime(creationTime);
+            if (transferDescription != null) {
+                dataTransferDetail.setTransferDesc(transferDescription.toCharArray());
+            }
+            if (existingDF != null) {
+                existingDF.setTransferId(transferId);
+                existingDF.setTask(taskDetail);
+                existingDF.setTaskId(taskDetailResource.getTaskId());
+                existingDF.setCreationTime(creationTime);
+                if (transferDescription != null) {
+                    existingDF.setTransferDesc(transferDescription.toCharArray());
+                }
+                dataTransferDetail = em.merge(existingDF);
+            } else {
+                em.merge(dataTransferDetail);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
             }
-            dataTransferDetail = em.merge(existingDF);
-        }else {
-            em.merge(dataTransferDetail);
         }
-        em.getTransaction().commit();
-        em.close();
     }
 
-    public StatusResource getDataTransferStatus (){
+    public StatusResource getDataTransferStatus () throws RegistryException{
         List<Resource> resources = get(ResourceType.STATUS);
         for (Resource resource : resources) {
             StatusResource dataTransferStatus = (StatusResource) resource;

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ErrorDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ErrorDetailResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ErrorDetailResource.java
index 3a1592d..7407efa 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ErrorDetailResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ErrorDetailResource.java
@@ -28,6 +28,7 @@ import org.apache.airavata.persistance.registry.jpa.model.ErrorDetail;
 import org.apache.airavata.persistance.registry.jpa.model.Experiment;
 import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
 import org.apache.airavata.persistance.registry.jpa.model.WorkflowNodeDetail;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -146,59 +147,68 @@ public class ErrorDetailResource extends AbstractResource {
         this.jobId = jobId;
     }
 
-    @Override
-    public Resource create(ResourceType type) {
+    
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void remove(ResourceType type, Object name) {
+    
+    public void remove(ResourceType type, Object name) throws RegistryException {
         logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Resource get(ResourceType type, Object name) {
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public List<Resource> get(ResourceType type) {
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
         logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        ErrorDetail errorDetail = new ErrorDetail();
-        errorDetail.setErrorID(errorId);
-        Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-        errorDetail.setExperiment(experiment);
-        errorDetail.setExpId(experimentResource.getExpID());
-        if (taskDetailResource != null){
-            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
-            errorDetail.setTask(taskDetail);
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            ErrorDetail errorDetail = new ErrorDetail();
+            errorDetail.setErrorID(errorId);
+            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+            errorDetail.setExperiment(experiment);
+            errorDetail.setExpId(experimentResource.getExpID());
+            if (taskDetailResource != null) {
+                TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+                errorDetail.setTask(taskDetail);
+            }
+
+            if (nodeDetail != null) {
+                WorkflowNodeDetail workflowNodeDetail = em.find(WorkflowNodeDetail.class, nodeDetail.getNodeInstanceId());
+                errorDetail.setNodeDetails(workflowNodeDetail);
+            }
+            errorDetail.setCreationTime(creationTime);
+            errorDetail.setActualErrorMsg(actualErrorMsg.toCharArray());
+            errorDetail.setUserFriendlyErrorMsg(userFriendlyErrorMsg);
+            errorDetail.setTransientPersistent(transientPersistent);
+            errorDetail.setErrorCategory(errorCategory);
+            errorDetail.setCorrectiveAction(correctiveAction);
+            errorDetail.setActionableGroup(actionableGroup);
+            errorDetail.setJobId(jobId);
+            em.persist(errorDetail);
+            errorId = errorDetail.getErrorID();
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-
-        if (nodeDetail != null){
-            WorkflowNodeDetail workflowNodeDetail = em.find(WorkflowNodeDetail.class, nodeDetail.getNodeInstanceId());
-            errorDetail.setNodeDetails(workflowNodeDetail);
-        }
-        errorDetail.setCreationTime(creationTime);
-        errorDetail.setActualErrorMsg(actualErrorMsg.toCharArray());
-        errorDetail.setUserFriendlyErrorMsg(userFriendlyErrorMsg);
-        errorDetail.setTransientPersistent(transientPersistent);
-        errorDetail.setErrorCategory(errorCategory);
-        errorDetail.setCorrectiveAction(correctiveAction);
-        errorDetail.setActionableGroup(actionableGroup);
-        errorDetail.setJobId(jobId);
-        em.persist(errorDetail);
-        errorId = errorDetail.getErrorID();
-        em.getTransaction().commit();
-        em.close();
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentInputResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentInputResource.java
index 25408ac..4c7dd9c 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentInputResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentInputResource.java
@@ -27,6 +27,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.Experiment;
 import org.apache.airavata.persistance.registry.jpa.model.Experiment_Input;
 import org.apache.airavata.persistance.registry.jpa.model.Experiment_Input_PK;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -82,54 +83,63 @@ public class ExperimentInputResource extends AbstractResource {
         this.metadata = metadata;
     }
 
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public void remove(ResourceType type, Object name) {
+    public void remove(ResourceType type, Object name) throws RegistryException{
         logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public Resource get(ResourceType type, Object name) {
+    public Resource get(ResourceType type, Object name) throws RegistryException {
         logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public List<Resource> get(ResourceType type) {
+    public List<Resource> get(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public void save() {
-        EntityManager em = ResourceUtils.getEntityManager();
-        Experiment_Input existingInput = em.find(Experiment_Input.class, new Experiment_Input_PK(experimentResource.getExpID(), experimentKey));
-        em.close();
-
-        em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        Experiment_Input exInput = new Experiment_Input();
-        exInput.setEx_key(experimentKey);
-        Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-        exInput.setExperiment(experiment);
-        exInput.setExperiment_id(experiment.getExpId());
-        exInput.setValue(value);
-        exInput.setInputType(inputType);
-        exInput.setMetadata(metadata);
-
-        if (existingInput != null){
-            existingInput.setEx_key(experimentKey);
-            existingInput.setExperiment(experiment);
-            existingInput.setExperiment_id(experiment.getExpId());
-            existingInput.setValue(value);
-            existingInput.setInputType(inputType);
-            existingInput.setMetadata(metadata);
-            exInput = em.merge(existingInput);
-        }else {
-            em.persist(exInput);
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            Experiment_Input existingInput = em.find(Experiment_Input.class, new Experiment_Input_PK(experimentResource.getExpID(), experimentKey));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Experiment_Input exInput = new Experiment_Input();
+            exInput.setEx_key(experimentKey);
+            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+            exInput.setExperiment(experiment);
+            exInput.setExperiment_id(experiment.getExpId());
+            exInput.setValue(value);
+            exInput.setInputType(inputType);
+            exInput.setMetadata(metadata);
+
+            if (existingInput != null) {
+                existingInput.setEx_key(experimentKey);
+                existingInput.setExperiment(experiment);
+                existingInput.setExperiment_id(experiment.getExpId());
+                existingInput.setValue(value);
+                existingInput.setInputType(inputType);
+                existingInput.setMetadata(metadata);
+                exInput = em.merge(existingInput);
+            } else {
+                em.persist(exInput);
+            }
+            em.getTransaction().commit();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                em.close();
+            }
         }
-        em.getTransaction().commit();
-        em.close();
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/bf5f8c3c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentOutputResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentOutputResource.java
index d5ed2a5..fb40abf 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentOutputResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentOutputResource.java
@@ -27,6 +27,7 @@ import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.model.Experiment;
 import org.apache.airavata.persistance.registry.jpa.model.Experiment_Output;
 import org.apache.airavata.persistance.registry.jpa.model.Experiment_Output_PK;
+import org.apache.airavata.registry.cpi.RegistryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -82,30 +83,39 @@ public class ExperimentOutputResource extends AbstractResource {
         this.metadata = metadata;
     }
 
-    public Resource create(ResourceType type) {
+    public Resource create(ResourceType type)  throws RegistryException {
         logger.error("Unsupported resource type for experiment output data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public void remove(ResourceType type, Object name) {
+    public void remove(ResourceType type, Object name)  throws RegistryException{
         logger.error("Unsupported resource type for experiment output data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public Resource get(ResourceType type, Object name) {
+    public Resource get(ResourceType type, Object name)  throws RegistryException{
         logger.error("Unsupported resource type for experiment output data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public List<Resource> get(ResourceType type) {
+    public List<Resource> get(ResourceType type) throws RegistryException {
         logger.error("Unsupported resource type for experiment output data resource.", new UnsupportedOperationException());
         throw new UnsupportedOperationException();
     }
 
-    public void save() {
+    public void save() throws RegistryException{
         EntityManager em = ResourceUtils.getEntityManager();
         Experiment_Output existingOutput = em.find(Experiment_Output.class, new Experiment_Output_PK(experimentResource.getExpID(), experimentKey));
-        em.close();
+        try {
+            em.close();
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em.isOpen()){
+                em.close();
+            }
+        }
 
         em = ResourceUtils.getEntityManager();
         em.getTransaction().begin();
@@ -130,6 +140,15 @@ public class ExperimentOutputResource extends AbstractResource {
             em.persist(exOutput);
         }
         em.getTransaction().commit();
-        em.close();
+        try {
+            em.close();
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em.isOpen()){
+                em.close();
+            }
+        }
     }
 }