Author: chathuri
Date: Mon May 20 19:52:26 2013
New Revision: 1484573

URL: http://svn.apache.org/r1484573
Log:
adding incompatible version exception and update registry API impl

Added:
    
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAPIVersionIncompatibleException.java
   (contents, props changed)
      - copied, changed from r1484566, 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java
Modified:
    
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
    
airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/RegistryClient.java

Modified: 
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java?rev=1484573&r1=1484572&r2=1484573&view=diff
==============================================================================
--- 
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
 (original)
+++ 
airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
 Mon May 20 19:52:26 2013
@@ -23,12 +23,7 @@ package org.apache.airavata.persistance.
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.regex.Pattern;
 
 import org.apache.airavata.common.exception.AiravataConfigurationException;
@@ -86,6 +81,8 @@ public class AiravataJPARegistry extends
     private ProvenanceRegistry provenanceRegistry;
     private UserWorkflowRegistry userWorkflowRegistry;
     private PublishedWorkflowRegistry publishedWorkflowRegistry;
+    private static Map<String, String[]> compatibleVersionMap;
+
 
 
     private PasswordCallback callback;
@@ -98,6 +95,28 @@ public class AiravataJPARegistry extends
        active=true;
 
         initializeCustomRegistries();
+        String apiVersion = getVersion().toString();
+        String registryVersion = 
getConfiguration("registry.version").toString();
+        if (!apiVersion.equals(registryVersion)){
+           throw new RegistryAPIVersionIncompatibleException("Incompatible 
registry versions. Please check whether you updated the API and Registry " +
+                   "versions.");
+        }
+        String[] list = compatibleVersionMap.get(apiVersion);
+        if (list == null){
+            throw new RegistryAPIVersionIncompatibleException("Incompatible 
registry versions. Please check whether you updated the API and Registry " +
+                    "versions.");
+        }
+        if (!Arrays.asList(list).contains(registryVersion)){
+            throw new RegistryAPIVersionIncompatibleException("Incompatible 
registry versions. Please check whether you updated the API and Registry " +
+                    "versions.");
+        }
+    }
+
+    static {
+        compatibleVersionMap = new HashMap<String, String[]>();
+        compatibleVersionMap.put("0.6", new String[]{"0.6"});
+        compatibleVersionMap.put("0.7", new String[]{"0.6", "0.7"});
+        compatibleVersionMap.put("0.8", new String[]{"0.8"});
     }
 
     /**

Copied: 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAPIVersionIncompatibleException.java
 (from r1484566, 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java)
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAPIVersionIncompatibleException.java?p2=airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAPIVersionIncompatibleException.java&p1=airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java&r1=1484566&r2=1484573&rev=1484573&view=diff
==============================================================================
--- 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAccessorNotFoundException.java
 (original)
+++ 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAPIVersionIncompatibleException.java
 Mon May 20 19:52:26 2013
@@ -21,12 +21,21 @@
 
 package org.apache.airavata.registry.api.exception;
 
-public class RegistryAccessorNotFoundException extends RegistryException {
+import org.apache.airavata.registry.api.exception.RegistryException;
 
-       private static final long serialVersionUID = -2679914107485739140L;
-       
-       public RegistryAccessorNotFoundException(String className, Exception e){
-               super("Registry accessor class '"+className+"'  was not found 
in classpath!!!", e);
-       }
+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);
+    }
 }

Propchange: 
airavata/trunk/modules/registry/registry-api/src/main/java/org/apache/airavata/registry/api/exception/RegistryAPIVersionIncompatibleException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/RegistryClient.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/RegistryClient.java?rev=1484573&r1=1484572&r2=1484573&view=diff
==============================================================================
--- 
airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/RegistryClient.java
 (original)
+++ 
airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/RegistryClient.java
 Mon May 20 19:52:26 2013
@@ -840,73 +840,63 @@ public class RegistryClient extends Aira
        @Override
        public List<ExperimentExecutionError> getExperimentExecutionErrors(
                        String experimentId) throws RegistryException {
-               // TODO Auto-generated method stub
-               return null;
+               return 
provenanceResourceClient.getExperimentExecutionErrors(experimentId);
        }
 
        @Override
        public List<WorkflowExecutionError> getWorkflowExecutionErrors(
                        String experimentId, String workflowInstanceId)
                        throws RegistryException {
-               // TODO Auto-generated method stub
-               return null;
+               return 
provenanceResourceClient.getWorkflowExecutionErrors(experimentId, 
workflowInstanceId);
        }
 
        @Override
        public List<NodeExecutionError> getNodeExecutionErrors(String 
experimentId,
                        String workflowInstanceId, String nodeId) throws 
RegistryException {
-               // TODO Auto-generated method stub
-               return null;
+               return 
getProvenanceResourceClient().getNodeExecutionErrors(experimentId, 
workflowInstanceId, nodeId);
        }
 
        @Override
        public List<GFacJobExecutionError> getGFacJobErrors(String experimentId,
                        String workflowInstanceId, String nodeId, String 
gfacJobId)
                        throws RegistryException {
-               // TODO Auto-generated method stub
-               return null;
+               return 
getProvenanceResourceClient().getGFacJobErrors(experimentId, 
workflowInstanceId, nodeId, gfacJobId);
        }
 
        @Override
        public List<GFacJobExecutionError> getGFacJobErrors(String gfacJobId)
                        throws RegistryException {
-               // TODO Auto-generated method stub
-               return null;
+               return 
getProvenanceResourceClient().getGFacJobErrors(gfacJobId);
        }
 
        @Override
        public List<ExecutionError> getExecutionErrors(String experimentId,
                        String workflowInstanceId, String nodeId, String 
gfacJobId,
                        Source... filterBy) throws RegistryException {
-               // TODO Auto-generated method stub
-               return null;
+               return 
getProvenanceResourceClient().getExecutionErrors(experimentId, 
workflowInstanceId, nodeId, gfacJobId, filterBy);
        }
 
        @Override
        public int addExperimentError(ExperimentExecutionError error)
                        throws RegistryException {
-               // TODO Auto-generated method stub
-               return 0;
+               return getProvenanceResourceClient().addExperimentError(error);
        }
 
        @Override
        public int addWorkflowExecutionError(WorkflowExecutionError error)
                        throws RegistryException {
-               // TODO Auto-generated method stub
-               return 0;
+               return 
getProvenanceResourceClient().addWorkflowExecutionError(error);
        }
 
        @Override
        public int addNodeExecutionError(NodeExecutionError error)
                        throws RegistryException {
-               // TODO Auto-generated method stub
-               return 0;
+               return 
getProvenanceResourceClient().addNodeExecutionError(error);
        }
 
        @Override
        public int addGFacJobExecutionError(GFacJobExecutionError error)
                        throws RegistryException {
-               // TODO Auto-generated method stub
-               return 0;
+               return 
getProvenanceResourceClient().addGFacJobExecutionError(error);
        }
 }


Reply via email to