airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramin...@apache.org
Subject svn commit: r1402556 - /airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/ApplicationRegistration.java
Date Fri, 26 Oct 2012 15:56:14 GMT
Author: raminder
Date: Fri Oct 26 15:56:13 2012
New Revision: 1402556

URL: http://svn.apache.org/viewvc?rev=1402556&view=rev
Log:
To get and save application description

Added:
    airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/ApplicationRegistration.java

Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/ApplicationRegistration.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/ApplicationRegistration.java?rev=1402556&view=auto
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/ApplicationRegistration.java
(added)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/ApplicationRegistration.java
Fri Oct 26 15:56:13 2012
@@ -0,0 +1,59 @@
+package org.apache.airavata.services.registry.rest.resources;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.airavata.registry.api.AiravataRegistry2;
+import org.apache.airavata.services.registry.rest.resourcemappings.ApplicationDescriptor;
+import org.apache.airavata.services.registry.rest.utils.RestServicesConstants;
+
+@Path("/api/application")
+public class ApplicationRegistration {
+
+    protected static AiravataRegistry2 airavataRegistry;
+
+    @Context
+    ServletContext context;
+
+    public ApplicationRegistration() {
+//        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+    }
+    // Sample JSON is : {"applicationName":"Testing","cpuCount":"12","maxMemory":"0","maxWallTime":"0","minMemory":"0","nodeCount":"0","processorsPerNode":"0"}
+	@POST
+    @Path("save")
+    @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
+    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public Response addServiceDescriptor(ApplicationDescriptor application){
+        try{
+        	application.getApplicationName();
+        	Response.ResponseBuilder builder = Response.status(Response.Status.ACCEPTED);
+            return builder.build();
+        } catch (Exception e) {
+        	throw new WebApplicationException(e,Response.Status.INTERNAL_SERVER_ERROR);
+        }
+    }
+
+	@GET
+    @Path("get")
+    @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
+    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public ApplicationDescriptor getServiceDescriptor(String applicationName){
+        try{
+        	ApplicationDescriptor application = new ApplicationDescriptor();
+        	application.setApplicationName(applicationName);
+            return application;
+        } catch (Exception e) {
+        	throw new WebApplicationException(e,Response.Status.INTERNAL_SERVER_ERROR);
+        }
+    }
+
+
+}



Mime
View raw message