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 2012/11/09 22:01:22 UTC

svn commit: r1407632 - in /airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest: client/ resources/ utils/

Author: chathuri
Date: Fri Nov  9 21:01:22 2012
New Revision: 1407632

URL: http://svn.apache.org/viewvc?rev=1407632&view=rev
Log:
adding client methods for descriptor registry

Added:
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/client/DescriptorResourceClient.java
Modified:
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/client/ConfigurationResourceClient.java
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/ResourcePathConstants.java

Modified: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/client/ConfigurationResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/client/ConfigurationResourceClient.java?rev=1407632&r1=1407631&r2=1407632&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/client/ConfigurationResourceClient.java (original)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/client/ConfigurationResourceClient.java Fri Nov  9 21:01:22 2012
@@ -43,15 +43,15 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class ConfigurationResourceClient {
-    private static WebResource webResource;
+    private WebResource webResource;
     private final static Logger logger = LoggerFactory.getLogger(ConfigurationResourceClient.class);
 
-    private static URI getBaseURI() {
+    private URI getBaseURI() {
         logger.info("Creating Base URI");
         return UriBuilder.fromUri("http://localhost:9080/airavata-services/").build();
     }
 
-    private static WebResource getConfigurationBaseResource (){
+    private WebResource getConfigurationBaseResource (){
         ClientConfig config = new DefaultClientConfig();
         config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
                 Boolean.TRUE);
@@ -62,7 +62,7 @@ public class ConfigurationResourceClient
     }
 
 
-    public static Object getConfiguration(String configKey) {
+    public Object getConfiguration(String configKey) {
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.GET_CONFIGURATION);
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("key", configKey);
@@ -78,7 +78,7 @@ public class ConfigurationResourceClient
         return output;
     }
 
-    public static List<Object> getConfigurationList (String configKey) {
+    public List<Object> getConfigurationList (String configKey) {
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.GET_CONFIGURATION_LIST);
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("key", configKey);
@@ -103,7 +103,7 @@ public class ConfigurationResourceClient
         return configurationValueList;
     }
 
-    public static void setConfiguration (String configKey, String configVal, String date){
+    public void setConfiguration (String configKey, String configVal, String date){
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.SAVE_CONFIGURATION);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("key", configKey);
@@ -120,7 +120,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void addConfiguration(String configKey, String configVal, String date){
+    public void addConfiguration(String configKey, String configVal, String date){
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.UPDATE_CONFIGURATION);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("key", configKey);
@@ -137,7 +137,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void removeAllConfiguration(String key){
+    public void removeAllConfiguration(String key){
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_CONFIGURATION);
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("key", key);
@@ -152,7 +152,7 @@ public class ConfigurationResourceClient
 
     }
 
-    public static void removeConfiguration(String key, String value){
+    public void removeConfiguration(String key, String value){
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_CONFIGURATION);
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("key", key);
@@ -167,7 +167,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static List<URI> getGFacURIs(){
+    public List<URI> getGFacURIs(){
         List<URI> uriList = new ArrayList<URI>();
         try{
             webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.GET_GFAC_URI_LIST);
@@ -193,7 +193,7 @@ public class ConfigurationResourceClient
         return uriList;
     }
 
-    public static List<URI> getWorkflowInterpreterURIs(){
+    public List<URI> getWorkflowInterpreterURIs(){
         List<URI> uriList = new ArrayList<URI>();
         try{
             webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.GET_WFINTERPRETER_URI_LIST);
@@ -219,7 +219,7 @@ public class ConfigurationResourceClient
     }
 
 
-    public static URI getEventingURI(){
+    public URI getEventingURI(){
         try{
             webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.GET_EVENTING_URI);
             ClientResponse response = webResource.get(ClientResponse.class);
@@ -239,7 +239,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static URI getMsgBoxURI(){
+    public URI getMsgBoxURI(){
         try{
             webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.GET_MESSAGE_BOX_URI);
             ClientResponse response = webResource.get(ClientResponse.class);
@@ -259,7 +259,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void addGFacURI(String uri) {
+    public void addGFacURI(String uri) {
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.ADD_GFAC_URI);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri);
@@ -274,7 +274,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void addWFInterpreterURI(String uri) {
+    public void addWFInterpreterURI(String uri) {
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.ADD_WFINTERPRETER_URI);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri);
@@ -289,7 +289,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void setEventingURI(String uri) {
+    public void setEventingURI(String uri) {
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.ADD_EVENTING_URI);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri);
@@ -304,7 +304,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void setMessageBoxURI(String uri) {
+    public void setMessageBoxURI(String uri) {
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.ADD_MESSAGE_BOX_URI);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri);
@@ -319,7 +319,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void addGFacURIByDate(String uri, String date) {
+    public void addGFacURIByDate(String uri, String date) {
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.ADD_GFAC_URI_DATE);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri);
@@ -335,7 +335,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void addWorkflowInterpreterURI(String uri, String date) {
+    public void addWorkflowInterpreterURI(String uri, String date) {
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.ADD_WFINTERPRETER_URI_DATE);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri);
@@ -351,7 +351,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void setEventingURIByDate(String uri, String date) {
+    public void setEventingURIByDate(String uri, String date) {
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.ADD_EVENTING_URI_DATE);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri);
@@ -367,7 +367,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void setMessageBoxURIByDate(String uri, String date) {
+    public void setMessageBoxURIByDate(String uri, String date) {
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.ADD_MSG_BOX_URI_DATE);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri);
@@ -383,7 +383,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void removeGFacURI(String uri){
+    public void removeGFacURI(String uri){
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_GFAC_URI);
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("uri", uri);
@@ -397,7 +397,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void removeAllGFacURI(){
+    public void removeAllGFacURI(){
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_GFAC_URIS);
         ClientResponse response = webResource.delete(ClientResponse.class);
         int status = response.getStatus();
@@ -409,7 +409,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void removeWorkflowInterpreterURI(String uri){
+    public void removeWorkflowInterpreterURI(String uri){
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_WFINTERPRETER_URI);
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("uri", uri);
@@ -423,7 +423,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void removeAllWorkflowInterpreterURI(){
+    public void removeAllWorkflowInterpreterURI(){
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_WFINTERPRETER_URIS);
         ClientResponse response = webResource.delete(ClientResponse.class);
         int status = response.getStatus();
@@ -435,7 +435,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void unsetEventingURI(){
+    public void unsetEventingURI(){
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_EVENTING_URI);
         ClientResponse response = webResource.delete(ClientResponse.class);
         int status = response.getStatus();
@@ -447,7 +447,7 @@ public class ConfigurationResourceClient
         }
     }
 
-    public static void unsetMessageBoxURI(){
+    public void unsetMessageBoxURI(){
         webResource = getConfigurationBaseResource().path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_MSG_BOX_URI);
         ClientResponse response = webResource.delete(ClientResponse.class);
         int status = response.getStatus();

Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/client/DescriptorResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/client/DescriptorResourceClient.java?rev=1407632&view=auto
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/client/DescriptorResourceClient.java (added)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/client/DescriptorResourceClient.java Fri Nov  9 21:01:22 2012
@@ -0,0 +1,485 @@
+/*
+ *
+ * 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.services.registry.rest.client;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.api.json.JSONConfiguration;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.services.registry.rest.resourcemappings.*;
+import org.apache.airavata.services.registry.rest.utils.DescriptorUtil;
+import org.apache.airavata.services.registry.rest.utils.ResourcePathConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriBuilder;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DescriptorResourceClient {
+    private WebResource webResource;
+    private final static Logger logger = LoggerFactory.getLogger(DescriptorResourceClient.class);
+
+    private URI getBaseURI() {
+        logger.info("Creating Base URI");
+        return UriBuilder.fromUri("http://localhost:9080/airavata-services/").build();
+    }
+
+    private WebResource getDescriptorRegistryBaseResource (){
+        ClientConfig config = new DefaultClientConfig();
+        config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
+                Boolean.TRUE);
+        Client client = Client.create(config);
+        WebResource baseWebResource = client.resource(getBaseURI());
+        webResource = baseWebResource.path(ResourcePathConstants.DecResourcePathConstants.DESC_RESOURCE_PATH);
+        return webResource;
+    }
+
+    public boolean isHostDescriptorExists(String hostDescriptorName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_EXISTS);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("hostDescriptorName", hostDescriptorName);
+        ClientResponse response = webResource.queryParams(queryParams).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        } else {
+            return true;
+        }
+    }
+
+    public void addHostDescriptor (HostDescription hostDescription){
+        HostDescriptor hostDescriptor = DescriptorUtil.createHostDescriptor(hostDescription);
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_SAVE);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, hostDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void updateHostDescriptor (HostDescription hostDescription){
+        HostDescriptor hostDescriptor = DescriptorUtil.createHostDescriptor(hostDescription);
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_UPDATE);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, hostDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public HostDescription getHostDescriptor (String hostName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("hostName", hostName);
+        ClientResponse response = webResource.queryParams(queryParams).type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        HostDescriptor hostDescriptor = response.getEntity(HostDescriptor.class);
+        HostDescription hostDescription = DescriptorUtil.createHostDescription(hostDescriptor);
+        return hostDescription;
+    }
+
+    public void removeHostDescriptor(String hostName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_DELETE);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("hostName", hostName);
+        ClientResponse response = webResource.queryParams(queryParams).delete(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public List<HostDescription> getHostDescriptors() {
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.GET_HOST_DESCS);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        HostDescriptionList hostDescriptionList = response.getEntity(HostDescriptionList.class);
+        HostDescriptor[] hostDescriptors = hostDescriptionList.getHostDescriptions();
+        List<HostDescription> hostDescriptions = new ArrayList<HostDescription>();
+        for (HostDescriptor hostDescriptor : hostDescriptors){
+           HostDescription hostDescription = DescriptorUtil.createHostDescription(hostDescriptor);
+            hostDescriptions.add(hostDescription);
+        }
+
+        return hostDescriptions;
+    }
+
+    public List<String> getHostDescriptorNames(){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.GET_HOST_DESCS_NAMES);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        DescriptorNameList descriptorNameList = response.getEntity(DescriptorNameList.class);
+        return descriptorNameList.getDescriptorNames();
+    }
+
+    public boolean isServiceDescriptorExists(String serviceDescriptorName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_EXISTS);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceDescriptorName", serviceDescriptorName);
+        ClientResponse response = webResource.queryParams(queryParams).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        } else {
+            return true;
+        }
+    }
+
+    public void saveServiceDescriptor (ServiceDescription serviceDescription){
+        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_SAVE);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, serviceDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void updateServiceDescriptor(ServiceDescription serviceDescription){
+        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_UPDATE);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, serviceDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public ServiceDescription getServiceDescriptor (String serviceName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        ClientResponse response = webResource.queryParams(queryParams).type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ServiceDescriptor serviceDescriptor = response.getEntity(ServiceDescriptor.class);
+        ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(serviceDescriptor);
+        return serviceDescription;
+    }
+
+    public void removeServiceDescriptor(String serviceName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_DELETE);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        ClientResponse response = webResource.queryParams(queryParams).delete(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public List<ServiceDescription> getServiceDescriptors (){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.GET_SERVICE_DESCS);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ServiceDescriptionList serviceDescriptionList = response.getEntity(ServiceDescriptionList.class);
+        ServiceDescriptor[] serviceDescriptors = serviceDescriptionList.getServiceDescriptions();
+        List<ServiceDescription> serviceDescriptions = new ArrayList<ServiceDescription>();
+        for (ServiceDescriptor serviceDescriptor : serviceDescriptors){
+            ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(serviceDescriptor);
+            serviceDescriptions.add(serviceDescription);
+        }
+        return serviceDescriptions;
+    }
+
+    public boolean isApplicationDescriptorExist (String serviceName, String hostName, String appDescriptorName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APPL_DESC_EXIST);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        queryParams.add("hostName", hostName);
+        queryParams.add("appDescName", appDescriptorName);
+        ClientResponse response = webResource.queryParams(queryParams).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        } else {
+            return true;
+        }
+    }
+
+    public void addApplicationDescriptor(ServiceDescription serviceDescription,
+                                         HostDescription hostDescriptor,
+                                         ApplicationDeploymentDescription descriptor){
+        ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(descriptor);
+        applicationDescriptor.setHostdescName(hostDescriptor.getType().getHostName());
+        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
+        applicationDescriptor.setServiceDescriptor(serviceDescriptor);
+
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_BUILD_SAVE);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void addApplicationDescriptor(String serviceName, String hostName, ApplicationDeploymentDescription descriptor){
+        ServiceDescription serviceDescription = getServiceDescriptor(serviceName);
+        ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(descriptor);
+        applicationDescriptor.setHostdescName(hostName);
+        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
+        applicationDescriptor.setServiceDescriptor(serviceDescriptor);
+
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_BUILD_SAVE);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void udpateApplicationDescriptor(ServiceDescription serviceDescription,
+                                            HostDescription hostDescriptor,
+                                            ApplicationDeploymentDescription descriptor){
+        ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(descriptor);
+        applicationDescriptor.setHostdescName(hostDescriptor.getType().getHostName());
+        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
+        applicationDescriptor.setServiceDescriptor(serviceDescriptor);
+
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_UPDATE);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void updateApplicationDescriptor(String serviceName, String hostName, ApplicationDeploymentDescription descriptor){
+        ServiceDescription serviceDescription = getServiceDescriptor(serviceName);
+        ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(descriptor);
+        applicationDescriptor.setHostdescName(hostName);
+        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
+        applicationDescriptor.setServiceDescriptor(serviceDescriptor);
+
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_UPDATE);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public ApplicationDeploymentDescription getApplicationDescriptor(String serviceName,
+                                                                     String hostname,
+                                                                     String applicationName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_DESCRIPTION);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        queryParams.add("hostName", hostname);
+        queryParams.add("applicationName", applicationName);
+
+        ClientResponse response = webResource.queryParams(queryParams).type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ApplicationDescriptor applicationDescriptor = response.getEntity(ApplicationDescriptor.class);
+        ApplicationDeploymentDescription applicationDeploymentDescription = DescriptorUtil.createApplicationDescription(applicationDescriptor);
+        return applicationDeploymentDescription;
+    }
+
+    public ApplicationDeploymentDescription getApplicationDescriptors(String serviceName, String hostname){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_PER_HOST_SERVICE);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        queryParams.add("hostName", hostname);
+
+        ClientResponse response = webResource.queryParams(queryParams).type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ApplicationDescriptor applicationDescriptor = response.getEntity(ApplicationDescriptor.class);
+        ApplicationDeploymentDescription applicationDeploymentDescription = DescriptorUtil.createApplicationDescription(applicationDescriptor);
+        return applicationDeploymentDescription;
+    }
+
+    public Map<String, ApplicationDeploymentDescription> getApplicationDescriptors(String serviceName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCS_SERVICE);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        ClientResponse response = webResource.queryParams(queryParams).type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ApplicationDescriptorList applicationDescriptorList = response.getEntity(ApplicationDescriptorList.class);
+        ApplicationDescriptor[] applicationDescriptors = applicationDescriptorList.getApplicationDescriptors();
+        Map<String, ApplicationDeploymentDescription> applicationDeploymentDescriptionMap = new HashMap<String, ApplicationDeploymentDescription>();
+        for (ApplicationDescriptor applicationDescriptor : applicationDescriptors){
+            ApplicationDeploymentDescription applicationDeploymentDescription = DescriptorUtil.createApplicationDescription(applicationDescriptor);
+            applicationDeploymentDescriptionMap.put(applicationDescriptor.getHostdescName(), applicationDeploymentDescription);
+        }
+        return applicationDeploymentDescriptionMap;
+    }
+
+    public Map<String[], ApplicationDeploymentDescription> getApplicationDescriptors(){
+        Map<String[], ApplicationDeploymentDescription> applicationDeploymentDescriptionMap = new HashMap<String[], ApplicationDeploymentDescription>();
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCRIPTORS);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ApplicationDescriptorList applicationDescriptorList = response.getEntity(ApplicationDescriptorList.class);
+        ApplicationDescriptor[] applicationDescriptors = applicationDescriptorList.getApplicationDescriptors();
+        for (ApplicationDescriptor applicationDescriptor : applicationDescriptors){
+            ApplicationDeploymentDescription applicationDeploymentDescription = DescriptorUtil.createApplicationDescription(applicationDescriptor);
+            String[] descriptors = {applicationDescriptor.getServiceDescriptor().getServiceName(), applicationDescriptor.getHostdescName()};
+            applicationDeploymentDescriptionMap.put(descriptors, applicationDeploymentDescription);
+        }
+        return applicationDeploymentDescriptionMap;
+    }
+
+    private List<String> getApplicationDescriptorNames (){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_NAMES);
+        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error("Failed : HTTP error code : " + status);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        DescriptorNameList descriptorNameList = response.getEntity(DescriptorNameList.class);
+        return descriptorNameList.getDescriptorNames();
+    }
+}

Modified: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java?rev=1407632&r1=1407631&r2=1407632&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java (original)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java Fri Nov  9 21:01:22 2012
@@ -456,7 +456,7 @@ public class DescriptorRegistryResource 
      * @return HTTP response
      */
     @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_SAVE)
+    @Path(ResourcePathConstants.DecResourcePathConstants.APPL_DESC_EXIST)
     @Produces(MediaType.TEXT_PLAIN)
     public Response isApplicationDescriptorExists(@QueryParam("serviceName") String serviceName,
                                                   @QueryParam("hostName") String hostName,
@@ -633,9 +633,9 @@ public class DescriptorRegistryResource 
      * @return HTTP response
      */
     @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCS_HOST_SERVICE)
+    @Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_PER_HOST_SERVICE)
     @Produces("text/xml")
-    public Response getApplicationDescriptors(@QueryParam("serviceName") String serviceName,
+    public Response getApplicationDescriptorPerServiceHost(@QueryParam("serviceName") String serviceName,
                                               @QueryParam("hostName") String hostName) {
         airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
         try {

Modified: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/ResourcePathConstants.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/ResourcePathConstants.java?rev=1407632&r1=1407631&r2=1407632&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/ResourcePathConstants.java (original)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/utils/ResourcePathConstants.java Fri Nov  9 21:01:22 2012
@@ -67,11 +67,11 @@ public class ResourcePathConstants {
         public static final String SERVICE_DESC = "servicedescriptor/description";
         public static final String SERVICE_DESC_DELETE = "servicedescriptor/delete";
         public static final String GET_SERVICE_DESCS = "get/servicedescriptors";
-        public static final String APP_DESC_SAVE = "applicationdescriptor/exist";
+        public static final String APPL_DESC_EXIST = "applicationdescriptor/exist";
         public static final String APP_DESC_BUILD_SAVE = "applicationdescriptor/build/save";
         public static final String APP_DESC_UPDATE = "applicationdescriptor/update";
         public static final String APP_DESC_DESCRIPTION = "applicationdescriptor/description";
-        public static final String APP_DESC_ALL_DESCS_HOST_SERVICE = "applicationdescriptors/alldescriptors/host/service";
+        public static final String APP_DESC_PER_HOST_SERVICE = "applicationdescriptors/alldescriptors/host/service";
         public static final String APP_DESC_ALL_DESCS_SERVICE = "applicationdescriptor/alldescriptors/service";
         public static final String APP_DESC_ALL_DESCRIPTORS = "applicationdescriptor/alldescriptors";
         public static final String APP_DESC_NAMES = "applicationdescriptor/names";