airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject svn commit: r1411652 - in /airavata/trunk/modules/rest: client/src/main/java/org/apache/airavata/rest/client/ mappings/src/main/java/org/apache/airavata/rest/mappings/utils/ service/src/main/java/org/apache/airavata/services/registry/rest/resources/
Date Tue, 20 Nov 2012 13:11:34 GMT
Author: chathuri
Date: Tue Nov 20 13:11:34 2012
New Revision: 1411652

URL: http://svn.apache.org/viewvc?rev=1411652&view=rev
Log:
adding get service version

Modified:
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/RegistryClient.java
    airavata/trunk/modules/rest/mappings/src/main/java/org/apache/airavata/rest/mappings/utils/ResourcePathConstants.java
    airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java

Modified: airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java?rev=1411652&r1=1411651&r2=1411652&view=diff
==============================================================================
--- airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java
(original)
+++ airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java
Tue Nov 20 13:11:34 2012
@@ -27,6 +27,7 @@ import com.sun.jersey.api.client.WebReso
 import com.sun.jersey.api.client.config.ClientConfig;
 import com.sun.jersey.api.client.config.DefaultClientConfig;
 import com.sun.jersey.api.json.JSONConfiguration;
+import org.apache.airavata.common.utils.Version;
 import org.apache.airavata.registry.api.AiravataUser;
 import org.apache.airavata.registry.api.Gateway;
 import org.apache.airavata.rest.mappings.utils.ResourcePathConstants;
@@ -160,4 +161,29 @@ public class BasicRegistryResourceClient
             }
         }
     }
+
+    public Version getVersion() {
+        webResource = getBasicRegistryBaseResource().path(ResourcePathConstants.BasicRegistryConstants.VERSION);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED)
{
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        } else if (status == ClientConstant.HTTP_UNAUTHORIZED){
+            webResource.header("Authorization", BasicAuthHeaderUtil.getBasicAuthHeader(userName,
callback.getPassword(userName)));
+            response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+            status = response.getStatus();
+
+            if (status != ClientConstant.HTTP_OK ) {
+                logger.error(response.getEntity(String.class));
+                throw new RuntimeException("Failed : HTTP error code : "
+                        + status);
+            }
+        }
+
+        Version airavataVersion = response.getEntity(Version.class);
+        return airavataVersion;
+    }
 }

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=1411652&r1=1411651&r2=1411652&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
Tue Nov 20 13:11:34 2012
@@ -759,7 +759,6 @@ public class RegistryClient extends Aira
 
     @Override
     public void setAiravataRegistry(AiravataRegistry2 registry) {
-        //To change body of implemented methods use File | Settings | File Templates.
     }
 
     @Override
@@ -774,11 +773,11 @@ public class RegistryClient extends Aira
 
     @Override
     public boolean isActive() {
-        return false;  //To change body of implemented methods use File | Settings | File
Templates.
+        return false;
     }
 
     @Override
     public Version getVersion() {
-        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+        return getBasicRegistryResourceClient().getVersion();
     }
 }

Modified: airavata/trunk/modules/rest/mappings/src/main/java/org/apache/airavata/rest/mappings/utils/ResourcePathConstants.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/mappings/src/main/java/org/apache/airavata/rest/mappings/utils/ResourcePathConstants.java?rev=1411652&r1=1411651&r2=1411652&view=diff
==============================================================================
--- airavata/trunk/modules/rest/mappings/src/main/java/org/apache/airavata/rest/mappings/utils/ResourcePathConstants.java
(original)
+++ airavata/trunk/modules/rest/mappings/src/main/java/org/apache/airavata/rest/mappings/utils/ResourcePathConstants.java
Tue Nov 20 13:11:34 2012
@@ -173,6 +173,7 @@ public class ResourcePathConstants {
         public static final String GET_USER = "get/user";
         public static final String SET_GATEWAY = "set/gateway";
         public static final String SET_USER = "set/user";
+        public static final String VERSION = "get/version";
     }
 
     }

Modified: airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java?rev=1411652&r1=1411651&r2=1411652&view=diff
==============================================================================
--- airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java
(original)
+++ airavata/trunk/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java
Tue Nov 20 13:11:34 2012
@@ -21,6 +21,7 @@
 
 package org.apache.airavata.services.registry.rest.resources;
 
+import org.apache.airavata.common.utils.Version;
 import org.apache.airavata.registry.api.AiravataRegistry2;
 import org.apache.airavata.registry.api.AiravataUser;
 import org.apache.airavata.registry.api.Gateway;
@@ -121,4 +122,27 @@ public class BasicRegistryResouce {
             return builder.build();
         }
     }
+
+    @GET
+    @Path(ResourcePathConstants.BasicRegistryConstants.VERSION)
+    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public Response getVersion (){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            Version version = airavataRegistry.getVersion();
+            if (version != null){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(version);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                builder.entity("Cannot retrieve Airavata version...");
+                return builder.build();
+            }
+        } catch (Exception e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
 }



Mime
View raw message