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/10/24 16:27:50 UTC

svn commit: r1401707 - in /airavata/sandbox/airavata-registry-rest: ./ src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ src/main/java/org/apache/airavata/services/registry/rest/resources/

Author: chathuri
Date: Wed Oct 24 14:27:49 2012
New Revision: 1401707

URL: http://svn.apache.org/viewvc?rev=1401707&view=rev
Log:
updating descriptors methods and adding necessary pojo classes

Added:
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ApplicationDescriptor.java
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ServiceDescriptor.java
Modified:
    airavata/sandbox/airavata-registry-rest/README.txt
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ApplicationDescriptorList.java
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ServiceDescriptionList.java
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java

Modified: airavata/sandbox/airavata-registry-rest/README.txt
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/README.txt?rev=1401707&r1=1401706&r2=1401707&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/README.txt (original)
+++ airavata/sandbox/airavata-registry-rest/README.txt Wed Oct 24 14:27:49 2012
@@ -41,7 +41,6 @@ To test
     curl -H "Accept: text/plain" -X POST -d 'host=<type:hostDescription xmlns:type="http://schemas.airavata.apache.org/gfac/type"><type:hostName>testHost1</type:hostName><type:hostAddress>aaaabbbbbbb</type:hostAddress></type:hostDescription>' http://localhost:9080/airavata-services/registry/api/hostdescriptor/update
     curl --request GET http://localhost:9080/airavata-services/registry/api/host/description?hostName=testHost1
     curl --request DELETE http://localhost:9080/airavata-services/registry/api/hostdescriptor/delete?hostName=testHost1
-    //need to test this
     curl --request GET http://localhost:9080/airavata-services/registry/api/get/hostdescriptors
 
     ############## Service descriptrors ##########################
@@ -50,7 +49,6 @@ To test
     curl -H "Accept: text/plain" -X POST -d 'service=<type:serviceDescription xmlns:type="http://schemas.airavata.apache.org/gfac/type"><type:name>echo1</type:name><type:inputParameters><type:parameterName>echo11_input</type:parameterName><type:parameterDescription xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><type:parameterType type="String"><name>String</name></type:parameterType></type:inputParameters><type:outputParameters><type:parameterName>echo11_output</type:parameterName><type:parameterDescription xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><type:parameterType type="String"><name>String</name></type:parameterType></type:outputParameters></type:serviceDescription>' http://localhost:9080/airavata-services/registry/api/servicedescriptor/update
     curl --request GET http://localhost:9080/airavata-services/registry/api/servicedescriptor/description?serviceName=echo1
     curl --request DELETE http://localhost:9080/airavata-services/registry/api/servicedescriptor/delete?serviceName=echo1
-    //need to test
     curl --request GET http://localhost:9080/airavata-services/registry/api/get/servicedescriptors
 
     ############## Application descriptrors ##########################
@@ -61,7 +59,6 @@ To test
     curl -H "Accept: text/plain" -X POST -d 'serviceName=echo&hostName=LocalHost&application=<type:applicationDeploymentDescription xmlns:type="http://schemas.airavata.apache.org/gfac/type"><type:applicationName>LocalHost_application2</type:applicationName><type:executableLocation>xccccccccxc11111</type:executableLocation><type:scratchWorkingDirectory>/sdddsdsds1111</type:scratchWorkingDirectory></type:applicationDeploymentDescription>' http://localhost:9080/airavata-services/registry/api/applicationdescriptor/update
     curl --request GET 'http://localhost:9080/airavata-services/registry/api/applicationdescriptor/description?serviceName=echo&hostName=LocalHost&applicationName=LocalHost_application2'
     curl --request GET 'http://localhost:9080/airavata-services/registry/api/applicationdescriptors/alldescriptors/host/service?serviceName=echo&hostName=LocalHost'
-    //need to find why object is not populated
     curl --request GET 'http://localhost:9080/airavata-services/registry/api/applicationdescriptor/alldescriptors/service?serviceName=echo'
     curl --request GET 'http://localhost:9080/airavata-services/registry/api/applicationdescriptor/alldescriptors'
     curl --request DELETE 'http://localhost:9080/airavata-services/registry/api/applicationdescriptor/delete?serviceName=echo&hostName=LocalHost&appName=LocalHost_application2'

Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ApplicationDescriptor.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ApplicationDescriptor.java?rev=1401707&view=auto
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ApplicationDescriptor.java (added)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ApplicationDescriptor.java Wed Oct 24 14:27:49 2012
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.resourcemappings;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class ApplicationDescriptor {
+    private String appDocument;
+    private String hostdescName;
+    private String serviceDescName;
+
+    public ApplicationDescriptor() {
+    }
+
+    public String getAppDocument() {
+        return appDocument;
+    }
+
+    public void setAppDocument(String appDocument) {
+        this.appDocument = appDocument;
+    }
+
+    public String getHostdescName() {
+        return hostdescName;
+    }
+
+    public void setHostdescName(String hostdescName) {
+        this.hostdescName = hostdescName;
+    }
+
+    public String getServiceDescName() {
+        return serviceDescName;
+    }
+
+    public void setServiceDescName(String serviceDescName) {
+        this.serviceDescName = serviceDescName;
+    }
+}

Modified: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ApplicationDescriptorList.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ApplicationDescriptorList.java?rev=1401707&r1=1401706&r2=1401707&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ApplicationDescriptorList.java (original)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ApplicationDescriptorList.java Wed Oct 24 14:27:49 2012
@@ -1,30 +1,20 @@
 package org.apache.airavata.services.registry.rest.resourcemappings;
 
-import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
-
 import javax.xml.bind.annotation.XmlRootElement;
-import java.util.HashMap;
-import java.util.Map;
 
 @XmlRootElement
 public class ApplicationDescriptorList {
-    private Map<String, ApplicationDeploymentDescription> map = new HashMap<String, ApplicationDeploymentDescription>();
-    private Map<String[], ApplicationDeploymentDescription> applicationDeploymentDescriptionMap = new HashMap<String[], ApplicationDeploymentDescription>();
-
-    public Map<String[], ApplicationDeploymentDescription> getApplicationDeploymentDescriptionMap() {
-        return applicationDeploymentDescriptionMap;
-    }
+    private ApplicationDescriptor[] applicationDescriptors;
 
-    public void setApplicationDeploymentDescriptionMap(Map<String[], ApplicationDeploymentDescription> applicationDeploymentDescriptionMap) {
-        this.applicationDeploymentDescriptionMap = applicationDeploymentDescriptionMap;
+    public ApplicationDescriptorList() {
     }
 
-    public Map<String, ApplicationDeploymentDescription> getMap() {
-        return map;
+    public ApplicationDescriptor[] getApplicationDescriptors() {
+        return applicationDescriptors;
     }
 
-    public void setMap(Map<String, ApplicationDeploymentDescription> map) {
-        this.map = map;
+    public void setApplicationDescriptors(ApplicationDescriptor[] applicationDescriptors) {
+        this.applicationDescriptors = applicationDescriptors;
     }
 }
 

Modified: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ServiceDescriptionList.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ServiceDescriptionList.java?rev=1401707&r1=1401706&r2=1401707&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ServiceDescriptionList.java (original)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ServiceDescriptionList.java Wed Oct 24 14:27:49 2012
@@ -1,18 +1,16 @@
 package org.apache.airavata.services.registry.rest.resourcemappings;
 
-import org.apache.airavata.commons.gfac.type.ServiceDescription;
-
 import javax.xml.bind.annotation.XmlRootElement;
 
 @XmlRootElement
 public class ServiceDescriptionList {
-    private ServiceDescription[] serviceDescriptions = null;
+    private ServiceDescriptor[] serviceDescriptions = null;
 
-    public ServiceDescription[] getServiceDescriptions() {
+    public ServiceDescriptor[] getServiceDescriptions() {
         return serviceDescriptions;
     }
 
-    public void setServiceDescriptions(ServiceDescription[] serviceDescriptions) {
+    public void setServiceDescriptions(ServiceDescriptor[] serviceDescriptions) {
         this.serviceDescriptions = serviceDescriptions;
     }
 }

Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ServiceDescriptor.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ServiceDescriptor.java?rev=1401707&view=auto
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ServiceDescriptor.java (added)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ServiceDescriptor.java Wed Oct 24 14:27:49 2012
@@ -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.services.registry.rest.resourcemappings;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class ServiceDescriptor {
+    private String serviceDocument;
+
+    public ServiceDescriptor() {
+    }
+
+    public String getServiceDocument() {
+        return serviceDocument;
+    }
+
+    public void setServiceDocument(String serviceDocument) {
+        this.serviceDocument = serviceDocument;
+    }
+}

Modified: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java?rev=1401707&r1=1401706&r2=1401707&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java (original)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java Wed Oct 24 14:27:49 2012
@@ -770,9 +770,11 @@ import java.util.Map;
         try {
             List<ServiceDescription> serviceDescriptors = airavataRegistry.getServiceDescriptors();
             ServiceDescriptionList list = new ServiceDescriptionList();
-            ServiceDescription[] serviceDescriptions = new ServiceDescription[serviceDescriptors.size()];
+            ServiceDescriptor[] serviceDescriptions = new ServiceDescriptor[serviceDescriptors.size()];
             for (int i = 0; i < serviceDescriptors.size(); i++) {
-                serviceDescriptions[i] = serviceDescriptors.get(i);
+                ServiceDescriptor serviceDescriptor = new ServiceDescriptor();
+                serviceDescriptor.setServiceDocument(serviceDescriptors.get(i).toXML());
+                serviceDescriptions[i] = serviceDescriptor;
             }
             list.setServiceDescriptions(serviceDescriptions);
             if (serviceDescriptors.size() != 0) {
@@ -976,10 +978,20 @@ import java.util.Map;
     public Response getApplicationDescriptors(@QueryParam("serviceName") String serviceName) {
         airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
         try{
-            Map<String, ApplicationDeploymentDescription> applicationDescriptors = airavataRegistry.getApplicationDescriptors(serviceName);
+            Map<String, ApplicationDeploymentDescription> applicationDeploymentDescriptionMap = airavataRegistry.getApplicationDescriptors(serviceName);
             ApplicationDescriptorList applicationDescriptorList = new ApplicationDescriptorList();
-            applicationDescriptorList.setMap(applicationDescriptors);
-            if(applicationDescriptors.size() != 0){
+            ApplicationDescriptor[] applicationDescriptors = new ApplicationDescriptor[applicationDeploymentDescriptionMap.size()];
+            int i = 0;
+            for(String hostName : applicationDeploymentDescriptionMap.keySet()){
+                ApplicationDeploymentDescription applicationDeploymentDescription = applicationDeploymentDescriptionMap.get(hostName);
+                ApplicationDescriptor applicationDescriptor = new ApplicationDescriptor();
+                applicationDescriptor.setHostdescName(hostName);
+                applicationDescriptor.setAppDocument(applicationDeploymentDescription.toXML());
+                applicationDescriptors[i] = applicationDescriptor;
+                i++;
+            }
+            applicationDescriptorList.setApplicationDescriptors(applicationDescriptors);
+            if(applicationDeploymentDescriptionMap.size() != 0){
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
                 builder.entity(applicationDescriptorList);
                 return builder.build();
@@ -1002,10 +1014,21 @@ import java.util.Map;
     public Response getApplicationDescriptors(){
         airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
         try{
-            Map<String[], ApplicationDeploymentDescription> applicationDescriptors = airavataRegistry.getApplicationDescriptors();
+            Map<String[], ApplicationDeploymentDescription> applicationDeploymentDescriptionMap = airavataRegistry.getApplicationDescriptors();
             ApplicationDescriptorList applicationDescriptorList = new ApplicationDescriptorList();
-            applicationDescriptorList.setApplicationDeploymentDescriptionMap(applicationDescriptors);
-            if(applicationDescriptors.size() != 0){
+            ApplicationDescriptor[] applicationDescriptors = new ApplicationDescriptor[applicationDeploymentDescriptionMap.size()];
+            int i = 0;
+            for (String[] descriptors : applicationDeploymentDescriptionMap.keySet()){
+                ApplicationDescriptor applicationDescriptor = new ApplicationDescriptor();
+                ApplicationDeploymentDescription applicationDeploymentDescription = applicationDeploymentDescriptionMap.get(descriptors);
+                applicationDescriptor.setServiceDescName(descriptors[0]);
+                applicationDescriptor.setHostdescName(descriptors[1]);
+                applicationDescriptor.setAppDocument(applicationDeploymentDescription.toXML());
+                applicationDescriptors[i] = applicationDescriptor;
+                i++;
+            }
+            applicationDescriptorList.setApplicationDescriptors(applicationDescriptors);
+            if(applicationDeploymentDescriptionMap.size() != 0){
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
                 builder.entity(applicationDescriptorList);
                 return builder.build();