airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject svn commit: r1409963 - in /airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest: client/ resources/ utils/
Date Thu, 15 Nov 2012 20:10:00 GMT
Author: chathuri
Date: Thu Nov 15 20:09:58 2012
New Revision: 1409963

URL: http://svn.apache.org/viewvc?rev=1409963&view=rev
Log:
adding basic methods to getGateway, getAiravataUser

Added:
    airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/BasicRegistryResourceClient.java
    airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java
Modified:
    airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/DescriptorResourceClient.java
    airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/ProvenanceResourceClient.java
    airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/UserWorkflowResourceClient.java
    airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/utils/ResourcePathConstants.java

Added: airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/BasicRegistryResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/BasicRegistryResourceClient.java?rev=1409963&view=auto
==============================================================================
--- airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/BasicRegistryResourceClient.java
(added)
+++ airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/BasicRegistryResourceClient.java
Thu Nov 15 20:09:58 2012
@@ -0,0 +1,112 @@
+/*
+ *
+ * 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 org.apache.airavata.registry.api.AiravataUser;
+import org.apache.airavata.registry.api.Gateway;
+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.UriBuilder;
+import java.net.URI;
+
+public class BasicRegistryResourceClient {
+    private WebResource webResource;
+    private final static Logger logger = LoggerFactory.getLogger(BasicRegistryResourceClient.class);
+
+    private URI getBaseURI() {
+        logger.info("Creating Base URI");
+        return UriBuilder.fromUri("http://localhost:9080/airavata-services/").build();
+    }
+
+    private WebResource getBasicRegistryBaseResource (){
+        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.BasicRegistryConstants.REGISTRY_API_BASICREGISTRY);
+        return webResource;
+    }
+
+    public Gateway getGateway (){
+        webResource = getBasicRegistryBaseResource().path(ResourcePathConstants.BasicRegistryConstants.GET_GATEWAY);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        Gateway gateway = response.getEntity(Gateway.class);
+        return gateway;
+    }
+
+    public AiravataUser getUser (){
+        webResource = getBasicRegistryBaseResource().path(ResourcePathConstants.BasicRegistryConstants.GET_USER);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        AiravataUser airavataUser = response.getEntity(AiravataUser.class);
+        return airavataUser;
+    }
+
+    public void setGateway (Gateway gateway){
+        webResource = getBasicRegistryBaseResource().path(ResourcePathConstants.BasicRegistryConstants.SET_GATEWAY);
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).type(MediaType.APPLICATION_JSON).post(ClientResponse.class,
gateway);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void setUser (AiravataUser user){
+        webResource = getBasicRegistryBaseResource().path(ResourcePathConstants.BasicRegistryConstants.SET_USER);
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).type(MediaType.APPLICATION_JSON).post(ClientResponse.class,
user);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+}

Modified: airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/DescriptorResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/DescriptorResourceClient.java?rev=1409963&r1=1409962&r2=1409963&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/DescriptorResourceClient.java
(original)
+++ airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/DescriptorResourceClient.java
Thu Nov 15 20:09:58 2012
@@ -200,7 +200,7 @@ public class DescriptorResourceClient {
         }
     }
 
-    public void saveServiceDescriptor (ServiceDescription serviceDescription){
+    public void addServiceDescriptor (ServiceDescription serviceDescription){
         ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
         webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_SAVE);
         ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class,
serviceDescriptor);
@@ -283,7 +283,7 @@ public class DescriptorResourceClient {
         return serviceDescriptions;
     }
 
-    public boolean isApplicationDescriptorExist (String serviceName, String hostName, String
appDescriptorName){
+    public boolean isApplicationDescriptorExists (String serviceName, String hostName, String
appDescriptorName){
         webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APPL_DESC_EXIST);
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("serviceName", serviceName);
@@ -485,4 +485,20 @@ public class DescriptorResourceClient {
         DescriptorNameList descriptorNameList = response.getEntity(DescriptorNameList.class);
         return descriptorNameList.getDescriptorNames();
     }
+
+    public void removeApplicationDescriptor (String serviceName, String hostName, String
applicationName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_DELETE);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        queryParams.add("hostName", hostName);
+        queryParams.add("appName", applicationName);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.TEXT_PLAIN).delete(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
 }

Modified: airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/ProvenanceResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/ProvenanceResourceClient.java?rev=1409963&r1=1409962&r2=1409963&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/ProvenanceResourceClient.java
(original)
+++ airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/ProvenanceResourceClient.java
Thu Nov 15 20:09:58 2012
@@ -28,6 +28,7 @@ import com.sun.jersey.api.client.config.
 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.registry.api.exception.RegistryException;
 import org.apache.airavata.registry.api.impl.ExperimentDataImpl;
 import org.apache.airavata.registry.api.workflow.*;
 import org.apache.airavata.services.registry.rest.resourcemappings.ExperimentDataList;
@@ -687,4 +688,21 @@ public class ProvenanceResourceClient {
         }
     }
 
+    public List<WorkflowNodeIOData> searchWorkflowInstanceNodeInput(String experimentIdRegEx,
String workflowNameRegEx, String nodeNameRegEx)  {
+        //not implemented in Registry API
+        return null;
+    }
+
+    public List<WorkflowNodeIOData> searchWorkflowInstanceNodeOutput(String experimentIdRegEx,
String workflowNameRegEx, String nodeNameRegEx)  {
+        //not implemented in Registry API
+        return null;
+    }
+
+    public List<ExperimentData> getExperimentByUser(String user, int pageSize, int
pageNo) {
+        //not implemented in Registry API
+        return null;
+    }
+
+
+
 }

Modified: airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/UserWorkflowResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/UserWorkflowResourceClient.java?rev=1409963&r1=1409962&r2=1409963&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/UserWorkflowResourceClient.java
(original)
+++ airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/client/UserWorkflowResourceClient.java
Thu Nov 15 20:09:58 2012
@@ -51,7 +51,7 @@ public class UserWorkflowResourceClient 
         return UriBuilder.fromUri("http://localhost:9080/airavata-services/").build();
     }
 
-    private com.sun.jersey.api.client.WebResource getUserWFRegistryBaseResource (){
+    private WebResource getUserWFRegistryBaseResource (){
         ClientConfig config = new DefaultClientConfig();
         config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
                 Boolean.TRUE);

Added: airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java?rev=1409963&view=auto
==============================================================================
--- airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java
(added)
+++ airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java
Thu Nov 15 20:09:58 2012
@@ -0,0 +1,124 @@
+/*
+ *
+ * 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.resources;
+
+import org.apache.airavata.registry.api.AiravataRegistry2;
+import org.apache.airavata.registry.api.AiravataUser;
+import org.apache.airavata.registry.api.Gateway;
+import org.apache.airavata.services.registry.rest.utils.ResourcePathConstants;
+import org.apache.airavata.services.registry.rest.utils.RestServicesConstants;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+@Path(ResourcePathConstants.BasicRegistryConstants.REGISTRY_API_BASICREGISTRY)
+public class BasicRegistryResouce {
+    protected static AiravataRegistry2 airavataRegistry;
+
+    @Context
+    ServletContext context;
+
+    @GET
+    @Path(ResourcePathConstants.BasicRegistryConstants.GET_GATEWAY)
+    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public Response getGateway (){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            Gateway gateway = airavataRegistry.getGateway();
+            if (gateway != null){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(gateway);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                builder.entity("Gateway does not exist...");
+                return builder.build();
+            }
+        } catch (Exception e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path(ResourcePathConstants.BasicRegistryConstants.GET_USER)
+    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public Response getAiravataUser (){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            AiravataUser airavataUser = airavataRegistry.getAiravataUser();
+            if (airavataUser != null){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(airavataUser);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                builder.entity("Airavata User does not exist...");
+                return builder.build();
+            }
+        } catch (Exception e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path(ResourcePathConstants.BasicRegistryConstants.SET_GATEWAY)
+    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response setGateway (Gateway gateway){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            airavataRegistry.setGateway(gateway);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            builder.entity("Gateway added successfully");
+            return builder.build();
+        } catch (Exception e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path(ResourcePathConstants.BasicRegistryConstants.SET_USER)
+    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response setAiravataUser (AiravataUser user){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            airavataRegistry.setAiravataUser(user);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            builder.entity("Airavata user added successfully");
+            return builder.build();
+        } catch (Exception e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+}

Modified: airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/utils/ResourcePathConstants.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/utils/ResourcePathConstants.java?rev=1409963&r1=1409962&r2=1409963&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/utils/ResourcePathConstants.java
(original)
+++ airavata/trunk/modules/airavata-rest-services/src/main/java/org/apache/airavata/services/registry/rest/utils/ResourcePathConstants.java
Thu Nov 15 20:09:58 2012
@@ -165,4 +165,13 @@ public class ResourcePathConstants {
         public static final String REMOVE_WORKFLOW = "remove/workflow";
     }
 
+    public final class BasicRegistryConstants {
+
+        public static final String REGISTRY_API_BASICREGISTRY = "/registry/api/basicregistry/";
+        public static final String GET_GATEWAY = "get/gateway";
+        public static final String GET_USER = "get/user";
+        public static final String SET_GATEWAY = "set/gateway";
+        public static final String SET_USER = "set/user";
+    }
+
     }



Mime
View raw message