airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1390647 [2/3] - in /airavata/sandbox/airavata-registry-rest: ./ src/main/java/org/apache/airavata/services/registry/rest/ src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ src/main/java/org/apache/airavata/services...
Date Wed, 26 Sep 2012 18:35:15 GMT
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=1390647&r1=1390646&r2=1390647&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 Sep 26 18:35:14 2012
@@ -4,77 +4,69 @@ import org.apache.airavata.common.regist
 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.registry.api.AiravataRegistry;
-import org.apache.airavata.registry.api.Axis2Registry;
-import org.apache.airavata.registry.api.DataRegistry;
-import org.apache.airavata.registry.api.workflow.WorkflowExecution;
-import org.apache.airavata.registry.api.workflow.WorkflowIOData;
-import org.apache.airavata.registry.api.workflow.WorkflowInstanceStatus;
-import org.apache.airavata.registry.api.workflow.WorkflowServiceIOData;
+import org.apache.airavata.persistance.registry.jpa.JPAResourceAccessor;
+import org.apache.airavata.registry.api.*;
+import org.apache.airavata.registry.api.exception.gateway.*;
+import org.apache.airavata.registry.api.exception.worker.*;
+import org.apache.airavata.registry.api.workflow.*;
+import org.apache.airavata.services.registry.rest.resourcemappings.*;
 import org.apache.xmlbeans.XmlException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import javax.jcr.Node;
 import javax.servlet.ServletContext;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
+import javax.ws.rs.*;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-import javax.xml.namespace.QName;
 import java.net.URI;
-import java.net.URISyntaxException;
-import java.sql.Timestamp;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
-@Path("/airavataRegistry/api")
-public class RegistryResource {
-    private AiravataRegistry airavataRegistry;
-    private Axis2Registry axis2Registry;
-    private DataRegistry dataRegistry;
+
+/**
+*  RegistryResource for REST interface of Registry API
+*  Three objects will be retrieved from the servelet context as
+*  airavataRegistry, axis2Registry, dataRegistry which are
+*  analogues to main API interfaces of Airavata
+*/
+@Path("/registry/api")
+public class RegistryResource implements ConfigurationRegistryService,
+        ProjectsRegistryService, ProvenanceRegistryService, UserWorkflowRegistryService,
+        PublishedWorkflowRegistryService, DescriptorRegistryService{
+    private final static Logger logger = LoggerFactory.getLogger(RegistryResource.class);
+    private JPAResourceAccessor jpa;
+    private boolean active=false;
+    private static final String DEFAULT_PROJECT_NAME = "default";
+    private AiravataRegistry2 airavataRegistry;
+    public static final String AIRAVATA_CONTEXT = "airavataRegistry";
 
     @Context
     ServletContext context;
 
-    @Path("/userName")
-    @GET
-    @Produces("text/plain")
-    public String getUserName() {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        return airavataRegistry.getUsername();
-    //    return "Amila Jayasekara";
+    public String getVersion(){
+        return  null;
     }
 
-    @Path("/repositoryUrl")
-    @GET
-    @Produces("text/plain")
-    public String getRepositoryURI() {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        return airavataRegistry.getRepositoryURI().toString();
+    protected void initialize() {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        jpa = new JPAResourceAccessor(airavataRegistry);
+        active=true;
     }
 
-    @Path("/repositoryName")
-    @GET
-    @Produces("text/plain")
-    public String getName() {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        return airavataRegistry.getName();
-    }
+    /**---------------------------------Configuration Registry----------------------------------**/
 
-    @Path("/service/wsdl")
+    @Path("/configuration")
     @GET
-    @Produces("text/xml")
-    public Response getWSDL(@QueryParam("serviceName") String serviceName) {
-        axis2Registry = (Axis2Registry) context.getAttribute("axis2Registry");
-        try {
-            String result = axis2Registry.getWSDL(serviceName);
-            if (result != null) {
+    @Produces("text/plain")
+    public Response getConfiguration(@QueryParam("key") String key) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            Object configuration = airavataRegistry.getConfiguration(key);
+            if (configuration != null) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(result);
+                builder.entity(configuration);
                 return builder.build();
             } else {
                 Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
@@ -84,21 +76,25 @@ public class RegistryResource {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
         }
-    }
 
+    }
 
-    //need to check the name
-    /*@Path("/service/description/wsdl")
     @GET
-    @Produces("text/xml")
-    public Response getWSDLFromServiceDescription(@FormParam("service") String service) {
-        axis2Registry = (Axis2Registry) context.getAttribute("axis2Registry");
-        try {
-            ServiceDescription serviceDescription = ServiceDescription.fromXML(service);
-            String result = axis2Registry.getWSDL(serviceDescription);
-            if (result != null) {
+    @Path("/configurationlist")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response getConfigurationList(@QueryParam("key") String key) {
+        try{
+            airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+            List<Object> configurationList = airavataRegistry.getConfigurationList(key);
+            ConfigurationList list = new ConfigurationList();
+            Object[] configValList = new Object[configurationList.size()];
+            for (int i = 0; i < configurationList.size(); i++) {
+                configValList[i] = configurationList.get(i);
+            }
+            list.setConfigValList(configValList);
+            if (configurationList.size() != 0) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(result);
+                builder.entity(list);
                 return builder.build();
             } else {
                 Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
@@ -108,686 +104,671 @@ public class RegistryResource {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
         }
-    } */
-
-
-
-    @Path("/service/description")
-    @GET
-    @Produces("text/xml")
-    public String getServiceDescription(@QueryParam("serviceID") String serviceId) throws RegistryException {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        return airavataRegistry.getServiceDescription(serviceId).toXML();
     }
 
-    @Path("/service/deploymentDescription")
-    @GET
-    @Produces("text/xml")
-    public String getDeploymentDescription(@QueryParam("serviceID") String serviceId,
-                                           @QueryParam("hostId") String hostId)
-            throws RegistryException {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        return airavataRegistry.getDeploymentDescription(serviceId, hostId).toXML();
+    @POST
+    @Path("save/configuration")
+    @Produces("text/plain")
+    public Response setConfiguration(@FormParam("key") String key,
+                                     @FormParam("value") String value,
+                                     @FormParam("date") Date date) {
+        try{
+            airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+            airavataRegistry.setConfiguration(key, value, date);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        }catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    @Path("host/description")
-    @GET
-    @Produces("text/xml")
-    public String getHostDescription(@QueryParam("hostId") String hostId) throws RegistryException {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        return airavataRegistry.getHostDescription(hostId).toXML();
+    @POST
+    @Path("update/configuration")
+    @Produces("text/plain")
+    public Response addConfiguration(@FormParam("key") String key,
+                                     @FormParam("value") String value,
+                                     @FormParam("date") Date date) {
+        try{
+            airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+            airavataRegistry.addConfiguration(key, value, date);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        }catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
+    @DELETE
+    @Path("delete/allconfiguration")
+    @Produces("text/plain")
+    public Response removeAllConfiguration(@QueryParam("key") String key) {
+        try{
+            airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+            airavataRegistry.removeAllConfiguration(key);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        }catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
 
-    @POST
-    @Path("save/hostDescription")
+    @DELETE
+    @Path("delete/configuration")
     @Produces("text/plain")
-    public Response saveHostDescription(@FormParam("host") String host) {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
+    public Response removeConfiguration(@QueryParam("key") String key, @QueryParam("value") String value) {
+        try{
+            airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+            airavataRegistry.removeConfiguration(key, value);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        }catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("gfac/urilist")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response getGFacURIs() {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
         try {
-            HostDescription hostDescription = HostDescription.fromXML(host);
-            String result = airavataRegistry.saveHostDescription(hostDescription);
-            if (result != null) {
+            List<URI> uris = airavataRegistry.getGFacURIs();
+            URLList list = new URLList();
+            String[] urs = new String[uris.size()];
+            for (int i = 0; i < uris.size(); i++) {
+                urs[i] = uris.get(i).toString();
+            }
+            list.setUris(urs);
+            if (urs.length != 0) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(result);
+                builder.entity(list);
                 return builder.build();
             } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
                 return builder.build();
             }
-        } catch (RegistryException e) {
+        } catch (Exception e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
-        } catch (XmlException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity("Invalid XML");
-            return builder.build();
         }
     }
 
-    @POST
-    @Path("save/serviceDescription")
-    @Produces("text/plain")
-    public Response saveServiceDescription(@FormParam("service") String service) {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
+    @GET
+    @Path("workflowinterpreter/urilist")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response getWorkflowInterpreterURIs() {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
         try {
-            ServiceDescription serviceDescription = ServiceDescription.fromXML(service);
-            String result = airavataRegistry.saveServiceDescription(serviceDescription);
-            if (result != null) {
+            List<URI> uris = airavataRegistry.getWorkflowInterpreterURIs();
+            URLList list = new URLList();
+            String[] urs = new String[uris.size()];
+            for (int i = 0; i < uris.size(); i++) {
+                urs[i] = uris.get(i).toString();
+            }
+            list.setUris(urs);
+            if (urs.length != 0) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(result);
+                builder.entity(list);
                 return builder.build();
             } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
                 return builder.build();
             }
-        } catch (RegistryException e) {
+        } catch (Exception e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
-        } catch (XmlException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity("Invalid XML");
-            return builder.build();
         }
     }
 
-    @POST
-    @Path("save/deploymentDescription")
+    @GET
+    @Path("eventingservice/uri")
     @Produces("text/plain")
-    public Response saveDeploymentDescription(@FormParam("serviceId") String serviceId,
-                                              @FormParam("hostId") String hostId,
-                                              @FormParam("app") String app) {
-
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        try {
-            ApplicationDeploymentDescription deploymentDescription =
-                    ApplicationDeploymentDescription.fromXML(app);
-
-            String result = airavataRegistry.saveDeploymentDescription(serviceId, hostId, deploymentDescription);
-            if (result != null) {
+    public Response getEventingServiceURI() {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            URI eventingServiceURI = airavataRegistry.getEventingServiceURI();
+            if (eventingServiceURI != null) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(result);
+                builder.entity(eventingServiceURI);
                 return builder.build();
             } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
                 return builder.build();
             }
-        } catch (RegistryException e) {
+        } catch (Exception e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
-        } catch (XmlException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            return builder.build();
         }
     }
 
-    @POST
-    @Path("service/deployOnHost")
+    @GET
+    @Path("messagebox/uri")
     @Produces("text/plain")
-    public Response deployServiceOnHost(@FormParam("serviceName") String serviceName,
-                                        @FormParam("hostName") String hostName) {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-
-        boolean state;
-        try {
-            state = airavataRegistry.deployServiceOnHost(serviceName, hostName);
-            if (state) {
+    public Response getMessageBoxURI() {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            URI eventingServiceURI = airavataRegistry.getMessageBoxURI();
+            if (eventingServiceURI != null) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity("True");
+                builder.entity(eventingServiceURI);
                 return builder.build();
             } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
                 return builder.build();
             }
-        } catch (RegistryException e) {
+        } catch (Exception e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
         }
     }
 
-    public List<HostDescription> searchHostDescription(String name) throws RegistryException {
-        return null;
+    @POST
+    @Path("add/gfacuri")
+    @Produces("text/plain")
+    public Response addGFacURI(@FormParam("uri") URI uri) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.addGFacURI(uri);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public List<ServiceDescription> searchServiceDescription(String nameRegEx) throws RegistryException {
-        return null;
+    @POST
+    @Path("add/workflowinterpreteruri")
+    @Produces("text/plain")
+    public Response addWorkflowInterpreterURI(@FormParam("uri") URI uri) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.addWorkflowInterpreterURI(uri);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName, String hostName)
-            throws RegistryException {
-        return null;
+    @POST
+    @Path("add/eventinguri")
+    @Produces("text/plain")
+    public Response setEventingURI(@FormParam("uri") URI uri) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.setEventingURI(uri);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public Map<HostDescription, List<ApplicationDeploymentDescription>> searchDeploymentDescription(String serviceName)
-            throws RegistryException {
-        return null;
+    @POST
+    @Path("add/msgboxuri")
+    @Produces("text/plain")
+    public Response setMessageBoxURI(@FormParam("uri") URI uri) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.setMessageBoxURI(uri);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName, String hostName,
-                                                                              String applicationName) throws RegistryException {
-        return null;
+    @POST
+    @Path("add/gfacuri")
+    @Produces("text/plain")
+    public Response addGFacURI(@FormParam("uri") URI uri, @FormParam("date") Date date) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.addGFacURI(uri, date);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public Map<ApplicationDeploymentDescription, String> searchDeploymentDescription() throws RegistryException {
-        return null;
+    @POST
+    @Path("add/workflowinterpreteruri")
+    @Produces("text/plain")
+    public Response addWorkflowInterpreterURI(@FormParam("uri") URI uri, @FormParam("date") Date date) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.addWorkflowInterpreterURI(uri, date);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
     @POST
-    @Path("save/gfacDescriptor")
+    @Path("add/eventinguri")
     @Produces("text/plain")
-    public Response saveGFacDescriptor(@FormParam("gfacURL") String gfacURL) {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        try {
-            Boolean result = airavataRegistry.saveGFacDescriptor(gfacURL);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity("true");
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
-                return builder.build();
-            }
-        } catch (RegistryException e) {
+    public Response setEventingURI(@FormParam("uri") URI uri, @FormParam("date") Date date) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.setEventingURI(uri, date);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
         }
     }
 
+    @POST
+    @Path("add/msgboxuri")
+    @Produces("text/plain")
+    public Response setMessageBoxURI(@FormParam("uri") URI uri, @FormParam("date") Date date) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.setMessageBoxURI(uri, date);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
 
     @DELETE
-    @Path("delete/gfacDescriptor")
+    @Path("delete/gfacuri")
     @Produces("text/plain")
-    public Response deleteGFacDescriptor(@QueryParam("gfacURL") String gfacURL) throws RegistryException {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        try {
-            Boolean result = airavataRegistry.deleteGFacDescriptor(gfacURL);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity("true");
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
-                return builder.build();
-            }
-        } catch (RegistryException e) {
+    public Response removeGFacURI(@QueryParam("uri") URI uri) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.removeGFacURI(uri);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
         }
     }
 
-    public List<URI> getInterpreterServiceURLList() throws RegistryException {
-        return null;
+    @DELETE
+    @Path("delete/allgfacuris")
+    @Produces("text/plain")
+    public Response removeAllGFacURI() {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.removeAllGFacURI();
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-
-    @POST
-    @Path("save/interpreterServiceUrl")
+    @DELETE
+    @Path("delete/workflowinterpreteruri")
     @Produces("text/plain")
-    public Response saveInterpreterServiceURL(@QueryParam("gfacURL") String gfacURL) {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        try {
-            URI gfacURI = new URI(gfacURL);
-            Boolean result = airavataRegistry.saveInterpreterServiceURL(gfacURI);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity("true");
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
-                return builder.build();
-            }
-        } catch (RegistryException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+    public Response removeWorkflowInterpreterURI(@QueryParam("uri") URI uri) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.removeWorkflowInterpreterURI(uri);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
             return builder.build();
-        } catch (URISyntaxException e) {
-             Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+        }catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
         }
     }
 
-
     @DELETE
-    @Path("delete/interpreterServiceURL")
+    @Path("delete/allworkflowinterpreteruris")
     @Produces("text/plain")
-    public Response deleteInterpreterServiceURL(URI gfacURL) throws RegistryException {
-        return null;
+    public Response removeAllWorkflowInterpreterURI() {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.removeAllWorkflowInterpreterURI();
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public List<URI> getMessageBoxServiceURLList() throws RegistryException {
-        return null;
+    @DELETE
+    @Path("delete/eventinguri")
+    @Produces("text/plain")
+    public Response unsetEventingURI() {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.unsetEventingURI();
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public boolean saveMessageBoxServiceURL(URI gfacURL) throws RegistryException {
-        return true;
+    @DELETE
+    @Path("delete/msgboxuri")
+    @Produces("text/plain")
+    public Response unsetMessageBoxURI() {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.unsetMessageBoxURI();
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (Exception e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public boolean deleteMessageBoxServiceURL(URI gfacURL) throws RegistryException {
-        return true;
-    }
 
-    public List<URI> getEventingServiceURLList() throws RegistryException {
-        return null;
-    }
-
-    public boolean saveEventingServiceURL(URI gfacURL) throws RegistryException {
-        return true;
-    }
-
-    public boolean deleteEventingServiceURL(URI gfacURL) throws RegistryException {
-        return true;
-    }
-
-    public List<String> getGFacDescriptorList() throws RegistryException {
-        return null;
-    }
-
-    public boolean saveWorkflow(QName ResourceID, String workflowName, String resourceDesc, String workflowAsaString,
-                                String owner, boolean isMakePublic) throws RegistryException {
-        return true;
-    }
-
-    public Map<QName, Node> getWorkflows(String userName) throws RegistryException {
-        return null;
-    }
-
-    public Node getWorkflow(QName templateID, String userName) throws RegistryException {
-        return null;
-    }
-
-    public boolean deleteWorkflow(QName resourceID, String userName) throws RegistryException {
-        return true;
-    }
-
-    public void deleteServiceDescription(String serviceId) throws RegistryException {
-
-    }
-
-    public void deleteDeploymentDescription(String serviceName, String hostName, String applicationName)
-            throws RegistryException {
-
-    }
-
-    public void deleteHostDescription(String hostId) throws RegistryException {
-
-    }
-
-    public boolean saveWorkflowExecutionServiceInput(WorkflowServiceIOData workflowInputData) throws RegistryException {
-        return true;
-    }
-
-    public boolean saveWorkflowExecutionServiceOutput(WorkflowServiceIOData workflowOutputData) throws RegistryException {
-        return true;
-    }
-
-    public List<WorkflowServiceIOData> searchWorkflowExecutionServiceInput(String experimentIdRegEx, String workflowNameRegEx, String nodeNameRegEx) throws RegistryException {
-        return null;
-    }
-
-    public String getWorkflowExecutionTemplateName(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public List<WorkflowServiceIOData> searchWorkflowExecutionServiceOutput(String experimentIdRegEx, String workflowNameRegEx, String nodeNameRegEx) throws RegistryException {
-        return null;
-    }
-
-    public boolean saveWorkflowExecutionName(String experimentId, String workflowIntanceName) throws RegistryException {
-        return true;
-    }
-
-    public boolean saveWorkflowExecutionStatus(String experimentId, WorkflowInstanceStatus status) throws RegistryException {
-        return true;
-    }
-
-    public boolean saveWorkflowExecutionStatus(String experimentId, WorkflowInstanceStatus.ExecutionStatus status) throws RegistryException {
-        return true;
-    }
-
-    public WorkflowInstanceStatus getWorkflowExecutionStatus(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public boolean saveWorkflowExecutionOutput(String experimentId, String outputNodeName, String output) throws RegistryException {
-        return true;
-    }
-
-    public boolean saveWorkflowExecutionOutput(String experimentId, WorkflowIOData data) throws RegistryException {
-        return true;
-    }
-
-    public WorkflowIOData getWorkflowExecutionOutput(String experimentId, String outputNodeName) throws RegistryException {
-        return null;
-    }
-
-    public List<WorkflowIOData> getWorkflowExecutionOutput(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public String[] getWorkflowExecutionOutputNames(String exeperimentId) throws RegistryException {
-        return null;
-    }
-
-    public boolean saveWorkflowExecutionUser(String experimentId, String user) throws RegistryException {
-        return true;
-    }
-
-    public String getWorkflowExecutionUser(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public String getWorkflowExecutionName(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public WorkflowExecution getWorkflowExecution(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public List<String> getWorkflowExecutionIdByUser(String user) throws RegistryException {
-        return null;
-    }
-
-    public List<WorkflowExecution> getWorkflowExecutionByUser(String user) throws RegistryException {
-        return null;
-    }
-
-    public List<WorkflowExecution> getWorkflowExecutionByUser(String user, int pageSize, int pageNo) throws RegistryException {
-        return null;
-    }
-
-    public String getWorkflowExecutionMetadata(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public boolean saveWorkflowExecutionMetadata(String experimentId, String metadata) throws RegistryException {
-        return true;
-    }
-
-//    public boolean saveWorkflowData(WorkflowRunTimeData workflowData)throws RegistryException{
-//        return true;
-//    }
-
-    public boolean saveWorkflowLastUpdateTime(String experimentId, Timestamp timestamp) throws RegistryException {
-        return true;
-    }
-
-    public boolean saveWorkflowNodeStatus(String workflowInstanceID, String workflowNodeID, WorkflowInstanceStatus.ExecutionStatus status) throws RegistryException {
-        return true;
-    }
-
-    public boolean saveWorkflowNodeLastUpdateTime(String workflowInstanceID, String workflowNodeID, Timestamp lastUpdateTime) throws RegistryException {
-        return true;
-    }
-
-//    public boolean saveWorkflowNodeGramData(WorkflowNodeGramData workflowNodeGramData)throws RegistryException{
-//        return true;
-//    }
-
-    public boolean saveWorkflowNodeGramLocalJobID(String workflowInstanceID, String workflowNodeID, String localJobID) throws RegistryException {
-        return true;
-    }
-
-
-}
-
-/*
- *
- * 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.common.registry.api.exception.RegistryException;
-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.registry.api.AiravataRegistry;
-import org.apache.airavata.registry.api.Axis2Registry;
-import org.apache.airavata.registry.api.DataRegistry;
-import org.apache.airavata.registry.api.workflow.WorkflowExecution;
-import org.apache.airavata.registry.api.workflow.WorkflowIOData;
-import org.apache.airavata.registry.api.workflow.WorkflowInstanceStatus;
-import org.apache.airavata.registry.api.workflow.WorkflowServiceIOData;
-import org.apache.xmlbeans.XmlException;
-
-import javax.jcr.Node;
-import javax.servlet.ServletContext;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.xml.namespace.QName;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.sql.Timestamp;
-import java.util.List;
-import java.util.Map;
-
-@Path("/airavataRegistry/api")
-public class RegistryResource {
-    private AiravataRegistry airavataRegistry;
-    private Axis2Registry axis2Registry;
-    private DataRegistry dataRegistry;
-
-    @Context
-    ServletContext context;
+    /**---------------------------------Descriptor Registry----------------------------------**/
 
-    @Path("/userName")
     @GET
+    @Path("hostdescriptor/exist")
     @Produces("text/plain")
-    public String getUserName() {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        return airavataRegistry.getUsername();
+    public Response isHostDescriptorExists(@QueryParam("descriptorName") String descriptorName){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        boolean state;
+        try{
+            state = airavataRegistry.isHostDescriptorExists(descriptorName);
+            if (state) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity("True");
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    @Path("/repositoryUrl")
-    @GET
+    @POST
+    @Path("hostdescriptor/save")
     @Produces("text/plain")
-    public String getRepositoryURI() {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        return airavataRegistry.getRepositoryURI().toString();
+    public Response addHostDescriptor(@FormParam("host") String host) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            HostDescription hostDescription = HostDescription.fromXML(host);
+            airavataRegistry.addHostDescriptor(hostDescription);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (DescriptorAlreadyExistsException e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (XmlException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    @Path("/repositoryName")
-    @GET
+    @POST
+    @Path("hostdescriptor/update")
     @Produces("text/plain")
-    public String getName() {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        return airavataRegistry.getName();
+    public Response updateHostDescriptor(@FormParam("host") String host) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            HostDescription hostDescription = HostDescription.fromXML(host);
+            airavataRegistry.updateHostDescriptor(hostDescription);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        }catch (XmlException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (DescriptorDoesNotExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    @Path("/service/wsdl")
     @GET
+    @Path("host/description")
     @Produces("text/xml")
-    public Response getWSDL(@QueryParam("serviceName") String serviceName) {
-        axis2Registry = (Axis2Registry) context.getAttribute("axis2Registry");
-        try {
-            String result = axis2Registry.getWSDL(serviceName);
+    public Response getHostDescriptor(@QueryParam("hostName") String hostName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            String result = airavataRegistry.getHostDescriptor(hostName).toXML();
             if (result != null) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
                 builder.entity(result);
                 return builder.build();
             } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
                 return builder.build();
             }
-        } catch (Exception e) {
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+
+    }
+
+    @DELETE
+    @Path("hostdescriptor/delete")
+    @Produces("text/plain")
+    public Response removeHostDescriptor(@QueryParam("hostName") String hostName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.removeHostDescriptor(hostName);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        }catch (DescriptorDoesNotExistsException e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
         }
     }
 
 
-    //need to check the name
-    @Path("/service/description/wsdl")
     @GET
-    @Produces("text/xml")
-    public Response getWSDLFromServiceDescription(@FormParam("service") String service) {
-        axis2Registry = (Axis2Registry) context.getAttribute("axis2Registry");
+    @Path("get/hostdescriptors")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response getHostDescriptors(){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
         try {
-            ServiceDescription serviceDescription = ServiceDescription.fromXML(service);
-            String result = axis2Registry.getWSDL(serviceDescription);
-            if (result != null) {
+            List<HostDescription> hostDescriptionList = airavataRegistry.getHostDescriptors();
+            HostDescriptionList list = new HostDescriptionList();
+            HostDescription[] hostDescriptions = new HostDescription[hostDescriptionList.size()];
+            for (int i = 0; i < hostDescriptionList.size(); i++) {
+                hostDescriptions[i] = hostDescriptionList.get(i);
+            }
+            list.setHostDescriptions(hostDescriptions);
+            if (hostDescriptionList.size() != 0) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(result);
+                builder.entity(list);
                 return builder.build();
             } else {
                 Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
                 return builder.build();
             }
-        } catch (Exception e) {
+        } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
         }
     }
 
-
-
-    @Path("/service/description")
-    @GET
-    @Produces("text/xml")
-    public String getServiceDescription(@QueryParam("serviceID") String serviceId) throws RegistryException {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        return airavataRegistry.getServiceDescription(serviceId).toXML();
-    }
-
-    @Path("/service/deploymentDescription")
-    @GET
-    @Produces("text/xml")
-    public String getDeploymentDescription(@QueryParam("serviceID") String serviceId,
-                                           @QueryParam("hostId") String hostId)
-            throws RegistryException {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        return airavataRegistry.getDeploymentDescription(serviceId, hostId).toXML();
+    public Response getHostDescriptorMetadata(String s) {
+        return null;
     }
 
-    @Path("host/description")
     @GET
-    @Produces("text/xml")
-    public String getHostDescription(@QueryParam("hostId") String hostId) throws RegistryException {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        return airavataRegistry.getHostDescription(hostId).toXML();
-    }
-
-
-    @POST
-    @Path("save/hostDescription")
+    @Path("servicedescriptor/exist")
     @Produces("text/plain")
-    public Response saveHostDescription(@FormParam("host") String host) {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        try {
-            HostDescription hostDescription = HostDescription.fromXML(host);
-            String result = airavataRegistry.saveHostDescription(hostDescription);
-            if (result != null) {
+    public Response isServiceDescriptorExists(@QueryParam("descriptorName") String descriptorName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        boolean state;
+        try{
+            state = airavataRegistry.isServiceDescriptorExists(descriptorName);
+            if (state) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(result);
+                builder.entity("True");
                 return builder.build();
             } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
                 return builder.build();
             }
         } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
+        }
+    }
+
+    @POST
+    @Path("servicedescriptor/save")
+    @Produces("text/xml")
+    public Response addServiceDescriptor(@FormParam("service") String service){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            ServiceDescription serviceDescription = ServiceDescription.fromXML(service);
+            airavataRegistry.addServiceDescriptor(serviceDescription);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (DescriptorAlreadyExistsException e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
         } catch (XmlException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity("Invalid XML");
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
         }
     }
 
     @POST
-    @Path("save/serviceDescription")
-    @Produces("text/plain")
-    public Response saveServiceDescription(@FormParam("service") String service) {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        try {
+    @Path("servicedescriptor/update")
+    @Produces("text/xml")
+    public Response updateServiceDescriptor(@FormParam("service") String service) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
             ServiceDescription serviceDescription = ServiceDescription.fromXML(service);
-            String result = airavataRegistry.saveServiceDescription(serviceDescription);
+            airavataRegistry.updateServiceDescriptor(serviceDescription);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (DescriptorAlreadyExistsException e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (XmlException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("service/description")
+    @Produces("text/xml")
+    public Response getServiceDescriptor(@QueryParam("serviceName") String serviceName){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            String result = airavataRegistry.getHostDescriptor(serviceName).toXML();
             if (result != null) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
                 builder.entity(result);
                 return builder.build();
             } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
                 return builder.build();
             }
         } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
-        } catch (XmlException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity("Invalid XML");
-            return builder.build();
         }
     }
 
-    @POST
-    @Path("save/deploymentDescription")
+    @DELETE
+    @Path("servicedescriptor/delete")
     @Produces("text/plain")
-    public Response saveDeploymentDescription(@FormParam("serviceId") String serviceId,
-                                              @FormParam("hostId") String hostId,
-                                              @FormParam("app") String app) {
+    public Response removeServiceDescriptor(@QueryParam("serviceName") String serviceName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.removeServiceDescriptor(serviceName);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        }catch (DescriptorDoesNotExistsException e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
 
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
+    @GET
+    @Path("get/servicedescriptors")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response getServiceDescriptors(){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
         try {
-            ApplicationDeploymentDescription deploymentDescription =
-                    ApplicationDeploymentDescription.fromXML(app);
-
-            String result = airavataRegistry.saveDeploymentDescription(serviceId, hostId, deploymentDescription);
-            if (result != null) {
+            List<ServiceDescription> serviceDescriptors = airavataRegistry.getServiceDescriptors();
+            ServiceDescriptionList list = new ServiceDescriptionList();
+            ServiceDescription[] serviceDescriptions = new ServiceDescription[serviceDescriptors.size()];
+            for (int i = 0; i < serviceDescriptors.size(); i++) {
+                serviceDescriptions[i] = serviceDescriptors.get(i);
+            }
+            list.setServiceDescriptions(serviceDescriptions);
+            if (serviceDescriptors.size() != 0) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(result);
+                builder.entity(list);
                 return builder.build();
             } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
                 return builder.build();
             }
         } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
-        } catch (XmlException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            return builder.build();
-        }
+        }    }
+
+    public Response getServiceDescriptorMetadata(String s){
+        return null;
     }
 
-    @POST
-    @Path("service/deployOnHost")
-    @Produces("text/plain")
-    public Response deployServiceOnHost(@FormParam("serviceName") String serviceName,
-                                        @FormParam("hostName") String hostName) {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
 
+    @GET
+    @Path("applicationdescriptor/exist")
+    @Produces("text/plain")
+    public Response isApplicationDescriptorExists(@QueryParam("serviceName")String serviceName,
+                                                  @QueryParam("hostName")String hostName,
+                                                  @QueryParam("descriptorName")String descriptorName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
         boolean state;
-        try {
-            state = airavataRegistry.deployServiceOnHost(serviceName, hostName);
+        try{
+            state = airavataRegistry.isApplicationDescriptorExists(serviceName, hostName, descriptorName);
             if (state) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
                 builder.entity("True");
                 return builder.build();
             } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
                 return builder.build();
             }
         } catch (RegistryException e) {
@@ -796,68 +777,125 @@ public class RegistryResource {
         }
     }
 
-    public List<HostDescription> searchHostDescription(String name) throws RegistryException {
-        return null;
-    }
-
-    public List<ServiceDescription> searchServiceDescription(String nameRegEx) throws RegistryException {
-        return null;
+    @POST
+    @Path("applicationdescriptor/save")
+    @Produces("text/xml")
+    public Response addApplicationDescriptor(@FormParam("service") String service,
+                                         @FormParam("host") String host,
+                                         @FormParam("application") String application){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            ServiceDescription serviceDescription = ServiceDescription.fromXML(service);
+            String serviceName = serviceDescription.getType().getName();
+            HostDescription hostDescription = HostDescription.fromXML(host);
+            String hostName = hostDescription.getType().getHostName();
+            ApplicationDeploymentDescription applicationDeploymentDescription = ApplicationDeploymentDescription.fromXML(application);
+            airavataRegistry.addApplicationDescriptor(serviceName, hostName, applicationDeploymentDescription);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (DescriptorAlreadyExistsException e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (XmlException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName, String hostName)
-            throws RegistryException {
-        return null;
-    }
+    @POST
+    @Path("applicationdescriptor/save")
+    @Produces("text/xml")
+    public Response addApplicationDesc(@FormParam("serviceName") String serviceName,
+                                       @FormParam("hostName") String hostName,
+                                       @FormParam("application") String application) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            ApplicationDeploymentDescription applicationDeploymentDescription = ApplicationDeploymentDescription.fromXML(application);
+            airavataRegistry.addApplicationDescriptor(serviceName, hostName, applicationDeploymentDescription);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (DescriptorAlreadyExistsException e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (XmlException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
 
-    public Map<HostDescription, List<ApplicationDeploymentDescription>> searchDeploymentDescription(String serviceName)
-            throws RegistryException {
-        return null;
     }
 
-    public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName, String hostName,
-                                                                              String applicationName) throws RegistryException {
-        return null;
-    }
+    @POST
+    @Path("servicedescriptor/update")
+    @Produces("text/xml")
+    public Response udpateApplicationDescriptor(@FormParam("service") String service,
+                                                @FormParam("host") String host,
+                                                @FormParam("application") String application) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            ServiceDescription serviceDescription = ServiceDescription.fromXML(service);
+            HostDescription hostDescription = HostDescription.fromXML(host);
+            ApplicationDeploymentDescription applicationDeploymentDescription = ApplicationDeploymentDescription.fromXML(application);
+            airavataRegistry.udpateApplicationDescriptor(serviceDescription, hostDescription, applicationDeploymentDescription);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (DescriptorAlreadyExistsException e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (XmlException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
 
-    public Map<ApplicationDeploymentDescription, String> searchDeploymentDescription() throws RegistryException {
-        return null;
     }
 
     @POST
-    @Path("save/gfacDescriptor")
-    @Produces("text/plain")
-    public Response saveGFacDescriptor(@FormParam("gfacURL") String gfacURL) {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        try {
-            Boolean result = airavataRegistry.saveGFacDescriptor(gfacURL);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity("true");
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
-                return builder.build();
-            }
+    @Path("servicedesc/update")
+    @Produces("text/xml")
+    public Response updateApplicationDescriptor(@FormParam("serviceName") String serviceName,
+                                            @FormParam("hostName")String hostName,
+                                            @FormParam("application") String application){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            ApplicationDeploymentDescription applicationDeploymentDescription = ApplicationDeploymentDescription.fromXML(application);
+            airavataRegistry.updateApplicationDescriptor(serviceName, hostName, applicationDeploymentDescription);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (DescriptorAlreadyExistsException e){
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
+        } catch (XmlException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            return builder.build();
         } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
         }
     }
 
-
-    @DELETE
-    @Path("delete/gfacDescriptor")
-    @Produces("text/plain")
-    public Response deleteGFacDescriptor(@QueryParam("gfacURL") String gfacURL) throws RegistryException {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        try {
-            Boolean result = airavataRegistry.deleteGFacDescriptor(gfacURL);
-            if (result) {
+    @GET
+    @Path("application/description")
+    @Produces("text/xml")
+    public Response getApplicationDescriptor(@QueryParam("serviceName") String serviceName,
+                                             @QueryParam("hostName") String hostName,
+                                             @QueryParam("applicationName") String applicationName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            String result = airavataRegistry.getApplicationDescriptor(serviceName, hostName, applicationName).toXML();
+            if (result != null) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity("true");
+                builder.entity(result);
                 return builder.build();
             } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
                 return builder.build();
             }
         } catch (RegistryException e) {
@@ -866,428 +904,375 @@ public class RegistryResource {
         }
     }
 
-    public List<URI> getInterpreterServiceURLList() throws RegistryException {
-        return null;
-    }
-
-
-    @POST
-    @Path("save/interpreterServiceUrl")
-    @Produces("text/plain")
-    public Response saveInterpreterServiceURL(@QueryParam("gfacURL") String gfacURL) {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        try {
-            URI gfacURI = new URI(gfacURL);
-            Boolean result = airavataRegistry.saveInterpreterServiceURL(gfacURI);
-            if (result) {
+    @GET
+    @Path("application/descriptors")
+    @Produces("text/xml")
+    public Response getApplicationDescriptors(@QueryParam("serviceName")String serviceName,
+                                             @QueryParam("hostName") String hostName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            String result = airavataRegistry.getApplicationDescriptors(serviceName, hostName).toXML();
+            if (result != null) {
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity("true");
+                builder.entity(result);
                 return builder.build();
             } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
                 return builder.build();
             }
         } catch (RegistryException e) {
             Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
             return builder.build();
-        } catch (URISyntaxException e) {
-             Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            return builder.build();
         }
     }
 
-
-    @DELETE
-    @Path("delete/interpreterServiceURL")
-    @Produces("text/plain")
-    public Response deleteInterpreterServiceURL(URI gfacURL) throws RegistryException {
-        return null;
-    }
-
-    public List<URI> getMessageBoxServiceURLList() throws RegistryException {
-        return null;
-    }
-
-    public boolean saveMessageBoxServiceURL(URI gfacURL) throws RegistryException {
-        return true;
-    }
-
-    public boolean deleteMessageBoxServiceURL(URI gfacURL) throws RegistryException {
-        return true;
-    }
-
-    public List<URI> getEventingServiceURLList() throws RegistryException {
-        return null;
-    }
-
-    public boolean saveEventingServiceURL(URI gfacURL) throws RegistryException {
-        return true;
-    }
-
-    public boolean deleteEventingServiceURL(URI gfacURL) throws RegistryException {
-        return true;
-    }
-
-    public List<String> getGFacDescriptorList() throws RegistryException {
-        return null;
-    }
-
-    public boolean saveWorkflow(QName ResourceID, String workflowName, String resourceDesc, String workflowAsaString,
-                                String owner, boolean isMakePublic) throws RegistryException {
-        return true;
-    }
-
-    public Map<QName, Node> getWorkflows(String userName) throws RegistryException {
-        return null;
-    }
-
-    public Node getWorkflow(QName templateID, String userName) throws RegistryException {
-        return null;
-    }
-
-    public boolean deleteWorkflow(QName resourceID, String userName) throws RegistryException {
-        return true;
-    }
-
-    public void deleteServiceDescription(String serviceId) throws RegistryException {
-
-    }
-
-    public void deleteDeploymentDescription(String serviceName, String hostName, String applicationName)
-            throws RegistryException {
-
-    }
-
-    public void deleteHostDescription(String hostId) throws RegistryException {
-
-    }
-
-    public boolean saveWorkflowExecutionServiceInput(WorkflowServiceIOData workflowInputData) throws RegistryException {
-        return true;
-    }
-
-    public boolean saveWorkflowExecutionServiceOutput(WorkflowServiceIOData workflowOutputData) throws RegistryException {
-        return true;
-    }
-
-    public List<WorkflowServiceIOData> searchWorkflowExecutionServiceInput(String experimentIdRegEx, String workflowNameRegEx, String nodeNameRegEx) throws RegistryException {
-        return null;
-    }
-
-    public String getWorkflowExecutionTemplateName(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public List<WorkflowServiceIOData> searchWorkflowExecutionServiceOutput(String experimentIdRegEx, String workflowNameRegEx, String nodeNameRegEx) throws RegistryException {
-        return null;
-    }
-
-    public boolean saveWorkflowExecutionName(String experimentId, String workflowIntanceName) throws RegistryException {
-        return true;
-    }
-
-    public boolean saveWorkflowExecutionStatus(String experimentId, WorkflowInstanceStatus status) throws RegistryException {
-        return true;
-    }
-
-    public boolean saveWorkflowExecutionStatus(String experimentId, WorkflowInstanceStatus.ExecutionStatus status) throws RegistryException {
-        return true;
-    }
-
-    public WorkflowInstanceStatus getWorkflowExecutionStatus(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public boolean saveWorkflowExecutionOutput(String experimentId, String outputNodeName, String output) throws RegistryException {
-        return true;
-    }
-
-    public boolean saveWorkflowExecutionOutput(String experimentId, WorkflowIOData data) throws RegistryException {
-        return true;
-    }
-
-    public WorkflowIOData getWorkflowExecutionOutput(String experimentId, String outputNodeName) throws RegistryException {
-        return null;
-    }
-
-    public List<WorkflowIOData> getWorkflowExecutionOutput(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public String[] getWorkflowExecutionOutputNames(String exeperimentId) throws RegistryException {
-        return null;
-    }
-
-    public boolean saveWorkflowExecutionUser(String experimentId, String user) throws RegistryException {
-        return true;
-    }
-
-    public String getWorkflowExecutionUser(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public String getWorkflowExecutionName(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public WorkflowExecution getWorkflowExecution(String experimentId) throws RegistryException {
-        return null;
-    }
-
-    public List<String> getWorkflowExecutionIdByUser(String user) throws RegistryException {
-        return null;
+    @GET
+    @Path("application/descriptors")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response getApplicationDescriptors(@QueryParam("serviceName") String serviceName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            Map<String, ApplicationDeploymentDescription> applicationDescriptors = airavataRegistry.getApplicationDescriptors(serviceName);
+            ApplicationDescriptorList applicationDescriptorList = new ApplicationDescriptorList();
+            applicationDescriptorList.setMap(applicationDescriptors);
+            if(applicationDescriptors.size() != 0){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(applicationDescriptorList);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (MalformedDescriptorException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public List<WorkflowExecution> getWorkflowExecutionByUser(String user) throws RegistryException {
-        return null;
+    @GET
+    @Path("application/descriptors")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response getApplicationDescriptors(){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            Map<String[], ApplicationDeploymentDescription> applicationDescriptors = airavataRegistry.getApplicationDescriptors();
+            ApplicationDescriptorList applicationDescriptorList = new ApplicationDescriptorList();
+            applicationDescriptorList.setApplicationDeploymentDescriptionMap(applicationDescriptors);
+            if(applicationDescriptors.size() != 0){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(applicationDescriptorList);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (MalformedDescriptorException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public List<WorkflowExecution> getWorkflowExecutionByUser(String user, int pageSize, int pageNo) throws RegistryException {
-        return null;
+    @DELETE
+    @Path("applicationdescriptor/delete")
+    @Produces("text/plain")
+    public Response removeApplicationDescriptor(@QueryParam("serviceName") String serviceName,
+                                                @QueryParam("hostName") String hostName,
+                                                @QueryParam("appName") String appName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.removeApplicationDescriptor(serviceName, hostName, appName);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (DescriptorDoesNotExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public String getWorkflowExecutionMetadata(String experimentId) throws RegistryException {
+    public Response getApplicationDescriptorMetadata(String s, String s1, String s2) {
         return null;
     }
 
-    public boolean saveWorkflowExecutionMetadata(String experimentId, String metadata) throws RegistryException {
-        return true;
+    /**---------------------------------Project Registry----------------------------------**/
+    @GET
+    @Path("project/exist")
+    @Produces("text/plain")
+    public Response isWorkspaceProjectExists(@QueryParam("projectName") String projectName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            boolean result = airavataRegistry.isWorkspaceProjectExists(projectName);
+            if (result) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-//    public boolean saveWorkflowData(WorkflowRunTimeData workflowData)throws RegistryException{
-//        return true;
-//    }
-
-    public boolean saveWorkflowLastUpdateTime(String experimentId, Timestamp timestamp) throws RegistryException {
-        return true;
+    @POST
+    @Path("project/exist")
+    @Produces("text/plain")
+    public Response isWorkspaceProjectExists(@FormParam("projectName") String projectName,
+                                             @FormParam("createIfNotExists") String createIfNotExists) {
+        boolean createIfNotExistStatus = false;
+        if(createIfNotExists.equals("true")){
+            createIfNotExistStatus = true;
+        }
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            boolean result = airavataRegistry.isWorkspaceProjectExists(projectName, createIfNotExistStatus);
+            if (result) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public boolean saveWorkflowNodeStatus(String workflowInstanceID, String workflowNodeID, WorkflowInstanceStatus.ExecutionStatus status) throws RegistryException {
-        return true;
+    @POST
+    @Path("add/project")
+    @Produces("text/plain")
+    public Response addWorkspaceProject(@FormParam("projectName") String projectName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            WorkspaceProject workspaceProject = new WorkspaceProject(projectName, airavataRegistry);
+            airavataRegistry.addWorkspaceProject(workspaceProject);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (WorkspaceProjectAlreadyExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-    public boolean saveWorkflowNodeLastUpdateTime(String workflowInstanceID, String workflowNodeID, Timestamp lastUpdateTime) throws RegistryException {
-        return true;
+    @POST
+    @Path("update/project")
+    @Produces("text/plain")
+    public Response updateWorkspaceProject(@FormParam("projectName") String projectName){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            WorkspaceProject workspaceProject = new WorkspaceProject(projectName, airavataRegistry);
+            airavataRegistry.updateWorkspaceProject(workspaceProject);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (WorkspaceProjectDoesNotExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-//    public boolean saveWorkflowNodeGramData(WorkflowNodeGramData workflowNodeGramData)throws RegistryException{
-//        return true;
-//    }
-
-    public boolean saveWorkflowNodeGramLocalJobID(String workflowInstanceID, String workflowNodeID, String localJobID) throws RegistryException {
-        return true;
+    @DELETE
+    @Path("delete/project")
+    @Produces("text/plain")
+    public Response deleteWorkspaceProject(@QueryParam("projectName") String projectName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            airavataRegistry.deleteWorkspaceProject(projectName);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (WorkspaceProjectDoesNotExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
     }
 
-
-}
-
-package org.apache.airavata.services.registry.rest.resources;
-
-import org.apache.airavata.common.registry.api.exception.RegistryException;
-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.registry.api.AiravataRegistry;
-import org.apache.airavata.registry.api.Axis2Registry;
-import org.apache.airavata.registry.api.DataRegistry;
-import org.apache.airavata.registry.api.workflow.WorkflowExecution;
-import org.apache.airavata.registry.api.workflow.WorkflowIOData;
-import org.apache.airavata.registry.api.workflow.WorkflowInstanceStatus;
-import org.apache.airavata.registry.api.workflow.WorkflowServiceIOData;
-import org.apache.airavata.services.registry.rest.resourcemappings.HostDescriptionList;
-import org.apache.airavata.services.registry.rest.resourcemappings.ServiceURLList;
-import org.apache.xmlbeans.XmlException;
-
-import javax.jcr.Node;
-import javax.servlet.ServletContext;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.namespace.QName;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.sql.Timestamp;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- *  RegistryResource for REST interface of Registry API
- *  Three objects will be retrieved from the servelet context as
- *  airavataRegistry, axis2Registry, dataRegistry which are
- *  analogues to main API interfaces of Airavata
- */
-@Path("/registry/api")
-public class RegistryResource {
-    private AiravataRegistry airavataRegistry;
-    private Axis2Registry axis2Registry;
-    private DataRegistry dataRegistry;
-
-    @Context
-    ServletContext context;
-
-
-    /**
-     *
-     * @return usename of the JCR registry
-     * at the moment, admin username is set
-     * TO-DO - get the user from a configuration file
-     */
-    @Path("/username")
     @GET
+    @Path("get/project")
     @Produces("text/plain")
-    public Response getUserName() {
-        airavataRegistry = (AiravataRegistry) context.getAttribute("airavataRegistry");
-        try {
-            String result = airavataRegistry.getUsername();
-            if (result != null) {
+    public Response getWorkspaceProject(@QueryParam("projectName") String projectName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(AIRAVATA_CONTEXT);
+        try{
+            WorkspaceProject workspaceProject = airavataRegistry.getWorkspaceProject(projectName);
+            if(workspaceProject != null){
                 Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(result);
+                builder.entity(workspaceProject);
                 return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
+            } else{
+                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
                 return builder.build();
             }
-        } catch (Exception e) {
+        } catch (WorkspaceProjectDoesNotExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();

[... 1657 lines stripped ...]


Mime
View raw message