airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samin...@apache.org
Subject [34/90] [abbrv] [partial] AIRAVATA-1124
Date Mon, 14 Apr 2014 18:30:36 GMT
http://git-wip-us.apache.org/repos/asf/airavata/blob/0e2c10f5/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java
----------------------------------------------------------------------
diff --git a/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java b/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java
deleted file mode 100644
index f111cbe..0000000
--- a/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/DescriptorRegistryResource.java
+++ /dev/null
@@ -1,889 +0,0 @@
-/*
- *
- * 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.commons.gfac.type.ApplicationDescription;
-import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.commons.gfac.type.ServiceDescription;
-import org.apache.airavata.registry.api.AiravataRegistry2;
-import org.apache.airavata.registry.api.exception.gateway.DescriptorAlreadyExistsException;
-import org.apache.airavata.registry.api.exception.gateway.DescriptorDoesNotExistsException;
-import org.apache.airavata.registry.api.exception.gateway.MalformedDescriptorException;
-import org.apache.airavata.rest.mappings.resourcemappings.*;
-import org.apache.airavata.rest.mappings.utils.DescriptorUtil;
-import org.apache.airavata.rest.mappings.utils.ResourcePathConstants;
-import org.apache.airavata.rest.mappings.utils.RegPoolUtils;
-import org.apache.airavata.services.registry.rest.utils.WebAppUtil;
-
-import javax.servlet.ServletContext;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * This class is the REST interface for all the operation regarding descriptors that are
- * exposed from Airavatas Registry API
- */
-@Path(ResourcePathConstants.DecResourcePathConstants.DESC_RESOURCE_PATH)
-public class DescriptorRegistryResource {
-
-    @Context
-    ServletContext context;
-
-    /**
-     * ---------------------------------Descriptor Registry----------------------------------*
-     */
-
-
-    /**
-     * This method will check whether the host descriptor exists
-     *
-     * @param hostDescriptorName host descriptor name
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_EXISTS)
-    @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
-    public Response isHostDescriptorExists(@QueryParam("hostDescriptorName") String hostDescriptorName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        boolean state;
-        try {
-            state = airavataRegistry.isHostDescriptorExists(hostDescriptorName);
-            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);
-                builder.entity("False");
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_EXISTS, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will save the host descriptor
-     *
-     * @param host JSON message send according to HostDescriptor class
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_SAVE)
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response addHostDescriptor(HostDescriptor host) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            HostDescription hostDescription = DescriptorUtil.createHostDescription(host);
-            airavataRegistry.addHostDescriptor(hostDescription);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Host descriptor saved successfully...");
-            return builder.build();
-        } catch (DescriptorAlreadyExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_SAVE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will update the host descriptor
-     *
-     * @param host JSON message send according to HostDescriptor class
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_UPDATE)
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response updateHostDescriptor(HostDescriptor host) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            HostDescription hostDescription = DescriptorUtil.createHostDescription(host);
-            airavataRegistry.updateHostDescriptor(hostDescription);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Host descriptor updated successfully...");
-            return builder.build();
-        } catch (DescriptorDoesNotExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_UPDATE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve host descriptor. Clients will get a JSON message that is generated
-     * according to HostDescriptor class
-     *
-     * @param hostName host name
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC)
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getHostDescriptor(@QueryParam("hostName") String hostName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            HostDescription hostDescription = airavataRegistry.getHostDescriptor(hostName);
-            if (hostDescription != null) {
-                HostDescriptor hostDescriptor = DescriptorUtil.createHostDescriptor(hostDescription);
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(hostDescriptor);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-                builder.entity("Host Descriptor does not exist...");
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.HOST_DESC, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-
-    }
-
-    /**
-     * This method will delete the given host descriptor
-     *
-     * @param hostName host descriptor name
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_DELETE)
-    @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
-    public Response removeHostDescriptor(@QueryParam("hostName") String hostName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.removeHostDescriptor(hostName);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Host descriptor deleted successfully...");
-            return builder.build();
-        } catch (DescriptorDoesNotExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_DELETE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve all the host descriptors available.
-     *
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.GET_HOST_DESCS)
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getHostDescriptors() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            List<HostDescription> hostDescriptionList = airavataRegistry.getHostDescriptors();
-            HostDescriptionList list = new HostDescriptionList();
-            HostDescriptor[] hostDescriptions = new HostDescriptor[hostDescriptionList.size()];
-            for (int i = 0; i < hostDescriptionList.size(); i++) {
-                HostDescriptor hostDescriptor = DescriptorUtil.createHostDescriptor(hostDescriptionList.get(i));
-                hostDescriptions[i] = hostDescriptor;
-            }
-            list.setHostDescriptions(hostDescriptions);
-            if (hostDescriptionList.size() != 0) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(list);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.GET_HOST_DESCS, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will return all the host descriptor names available
-     *
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.GET_HOST_DESCS_NAMES)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getHostDescriptorNames() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            List<HostDescription> hostDescriptionList = airavataRegistry.getHostDescriptors();
-            List<String> hostDescriptorNames = new ArrayList<String>();
-            DescriptorNameList descriptorNameList = new DescriptorNameList();
-            for (HostDescription aHostDescriptionList : hostDescriptionList) {
-                hostDescriptorNames.add(aHostDescriptionList.getType().getHostName());
-            }
-            descriptorNameList.setDescriptorNames(hostDescriptorNames);
-            if (hostDescriptionList.size() != 0) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(descriptorNameList);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.GET_HOST_DESCS_NAMES, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will check whether the service descriptor available
-     *
-     * @param serviceDescriptorName service descriptor name
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_EXISTS)
-    @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
-    public Response isServiceDescriptorExists(@QueryParam("serviceDescriptorName") String serviceDescriptorName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        boolean state;
-        try {
-            state = airavataRegistry.isServiceDescriptorExists(serviceDescriptorName);
-            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);
-                builder.entity("False");
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_EXISTS, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will save the service descriptor
-     *
-     * @param service this is a JSON message created according to ServiceDescriptor class
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_SAVE)
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response addServiceDescriptor(ServiceDescriptor service) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(service);
-            airavataRegistry.addServiceDescriptor(serviceDescription);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Service descriptor saved successfully...");
-            return builder.build();
-        } catch (DescriptorAlreadyExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_SAVE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will update the service descriptor
-     *
-     * @param service this is a JSON message generated according to Service Descriptor class
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_UPDATE)
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response updateServiceDescriptor(ServiceDescriptor service) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(service);
-            airavataRegistry.updateServiceDescriptor(serviceDescription);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Service descriptor updated successfully...");
-            return builder.build();
-        } catch (DescriptorAlreadyExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_UPDATE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve service descriptor for a given service descriptor name. Clients
-     * will get a JSON message that is generated according to Service Descriptor class
-     *
-     * @param serviceName service name
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC)
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getServiceDescriptor(@QueryParam("serviceName") String serviceName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            ServiceDescription serviceDescription = airavataRegistry.getServiceDescriptor(serviceName);
-            if (serviceDescription != null) {
-                ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(serviceDescriptor);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-                builder.entity("No service descriptor available with given service name...");
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will delete a given service descriptor
-     *
-     * @param serviceName service descriptor name
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_DELETE)
-    @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
-    public Response removeServiceDescriptor(@QueryParam("serviceName") String serviceName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.removeServiceDescriptor(serviceName);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Service descriptor deleted successfully...");
-            return builder.build();
-        } catch (DescriptorDoesNotExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_DELETE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve all the service descriptors
-     *
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.GET_SERVICE_DESCS)
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getServiceDescriptors() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            List<ServiceDescription> serviceDescriptors = airavataRegistry.getServiceDescriptors();
-            ServiceDescriptionList list = new ServiceDescriptionList();
-            ServiceDescriptor[] serviceDescriptions = new ServiceDescriptor[serviceDescriptors.size()];
-            for (int i = 0; i < serviceDescriptors.size(); i++) {
-                ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescriptors.get(i));
-                serviceDescriptions[i] = serviceDescriptor;
-            }
-            list.setServiceDescriptions(serviceDescriptions);
-            if (serviceDescriptors.size() != 0) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(list);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.GET_SERVICE_DESCS, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-
-    /**
-     * This method will check whether the given application descriptor exists
-     *
-     * @param serviceName       service descriptor name
-     * @param hostName          host descriptor name
-     * @param appDescriptorName application descriptor name
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.APPL_DESC_EXIST)
-    @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
-    public Response isApplicationDescriptorExists(@QueryParam("serviceName") String serviceName,
-                                                  @QueryParam("hostName") String hostName,
-                                                  @QueryParam("appDescName") String appDescriptorName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        boolean state;
-        try {
-            state = airavataRegistry.isApplicationDescriptorExists(serviceName, hostName, appDescriptorName);
-            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);
-                builder.entity("False");
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.APPL_DESC_EXIST, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will save given application descriptor
-     *
-     * @param applicationDescriptor this is a JSON message created according to
-     *                              ApplicationDescriptor class
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_BUILD_SAVE)
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    public Response addApplicationDescriptor(ApplicationDescriptor applicationDescriptor) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            String hostdescName = applicationDescriptor.getHostdescName();
-            if (!airavataRegistry.isHostDescriptorExists(hostdescName)) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
-                builder.entity("Given host does not exist...");
-                return builder.build();
-            }
-            ApplicationDescription applicationDescription = DescriptorUtil.createApplicationDescription(applicationDescriptor);
-            ServiceDescriptor serviceDescriptor = applicationDescriptor.getServiceDescriptor();
-            String serviceName;
-            if (serviceDescriptor != null) {
-                if (serviceDescriptor.getServiceName() == null) {
-                    serviceName = applicationDescriptor.getName();
-                    serviceDescriptor.setServiceName(serviceName);
-                } else {
-                    serviceName = serviceDescriptor.getServiceName();
-                }
-//                ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(serviceDescriptor);
-//                if (!airavataRegistry.isServiceDescriptorExists(serviceName)) {
-//                    airavataRegistry.addServiceDescriptor(serviceDescription);
-//                }
-            } else {
-                serviceName = applicationDescriptor.getName();
-            }
-            airavataRegistry.addApplicationDescriptor(serviceName, hostdescName, applicationDescription);
-
-
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Application descriptor saved successfully...");
-            return builder.build();
-        } catch (DescriptorAlreadyExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.APP_DESC_BUILD_SAVE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will update the application descriptor
-     *
-     * @param applicationDescriptor JSON message of ApplicationDescriptor class
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_UPDATE)
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    public Response udpateApplicationDescriptor(ApplicationDescriptor applicationDescriptor) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            String hostdescName = applicationDescriptor.getHostdescName();
-            if (!airavataRegistry.isHostDescriptorExists(hostdescName)) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
-                builder.entity("Host does not available...");
-                return builder.build();
-            }
-            ApplicationDescription applicationDescription = DescriptorUtil.createApplicationDescription(applicationDescriptor);
-            ServiceDescriptor serviceDescriptor = applicationDescriptor.getServiceDescriptor();
-            String serviceName;
-            if (serviceDescriptor != null) {
-                if (serviceDescriptor.getServiceName() == null) {
-                    serviceName = applicationDescriptor.getName();
-                    serviceDescriptor.setServiceName(serviceName);
-                } else {
-                    serviceName = serviceDescriptor.getServiceName();
-                }
-//                ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(serviceDescriptor);
-//                if (airavataRegistry.isServiceDescriptorExists(serviceName)) {
-//                    airavataRegistry.updateServiceDescriptor(serviceDescription);
-//                } else {
-//                    airavataRegistry.addServiceDescriptor(serviceDescription);
-//                }
-
-            } else {
-                serviceName = applicationDescriptor.getName();
-            }
-            airavataRegistry.updateApplicationDescriptor(serviceName, hostdescName, applicationDescription);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Application descriptor updated successfully...");
-            return builder.build();
-        } catch (DescriptorAlreadyExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.APP_DESC_UPDATE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve an application descriptor according to given service name, host name
-     * and application name
-     *
-     * @param serviceName     service name
-     * @param hostName        host name
-     * @param applicationName application name
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_DESCRIPTION)
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    public Response getApplicationDescriptor(@QueryParam("serviceName") String serviceName,
-                                             @QueryParam("hostName") String hostName,
-                                             @QueryParam("applicationName") String applicationName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            ApplicationDescription applicationDescription = airavataRegistry.getApplicationDescriptor(serviceName, hostName, applicationName);
-            if (applicationDescription != null) {
-                ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(applicationDescription);
-                applicationDescriptor.setHostdescName(hostName);
-                ServiceDescription serviceDescription = airavataRegistry.getServiceDescriptor(serviceName);
-                ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
-                applicationDescriptor.setServiceDescriptor(serviceDescriptor);
-
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(applicationDescriptor);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-                builder.entity("Application descriptor does not exist...");
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.APP_DESC_DESCRIPTION, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve application descriptors for a given service and host
-     *
-     * @param serviceName service name
-     * @param hostName    host name
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_PER_HOST_SERVICE)
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    public Response getApplicationDescriptorPerServiceHost(@QueryParam("serviceName") String serviceName,
-                                                           @QueryParam("hostName") String hostName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            ApplicationDescription applicationDescription = airavataRegistry.getApplicationDescriptors(serviceName, hostName);
-            ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(applicationDescription);
-            applicationDescriptor.setHostdescName(hostName);
-            ServiceDescription serviceDescription = airavataRegistry.getServiceDescriptor(serviceName);
-            ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
-            applicationDescriptor.setServiceDescriptor(serviceDescriptor);
-
-            if (applicationDescription != null) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(applicationDescriptor);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-                builder.entity("Application descriptor does not exist...");
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.APP_DESC_PER_HOST_SERVICE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will get all the application descriptors for a given service
-     *
-     * @param serviceName service name
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCS_SERVICE)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getApplicationDescriptors(@QueryParam("serviceName") String serviceName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            Map<String, ApplicationDescription> applicationDeploymentDescriptionMap = airavataRegistry.getApplicationDescriptors(serviceName);
-            ApplicationDescriptorList applicationDescriptorList = new ApplicationDescriptorList();
-            ApplicationDescriptor[] applicationDescriptors = new ApplicationDescriptor[applicationDeploymentDescriptionMap.size()];
-            int i = 0;
-            for (String hostName : applicationDeploymentDescriptionMap.keySet()) {
-                ApplicationDescription applicationDescription = applicationDeploymentDescriptionMap.get(hostName);
-                ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(applicationDescription);
-                applicationDescriptor.setHostdescName(hostName);
-
-                ServiceDescription serviceDescription = airavataRegistry.getServiceDescriptor(serviceName);
-                ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
-                applicationDescriptor.setServiceDescriptor(serviceDescriptor);
-
-                applicationDescriptors[i] = applicationDescriptor;
-                i++;
-            }
-            applicationDescriptorList.setApplicationDescriptors(applicationDescriptors);
-            if (applicationDeploymentDescriptionMap.size() != 0) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(applicationDescriptorList);
-                return builder.build();
-            } 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);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCS_SERVICE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve all the application descriptors available
-     *
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCRIPTORS)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getApplicationDescriptors() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            Map<String[], ApplicationDescription> applicationDeploymentDescriptionMap = airavataRegistry.getApplicationDescriptors();
-            ApplicationDescriptorList applicationDescriptorList = new ApplicationDescriptorList();
-            ApplicationDescriptor[] applicationDescriptors = new ApplicationDescriptor[applicationDeploymentDescriptionMap.size()];
-            int i = 0;
-            for (String[] descriptors : applicationDeploymentDescriptionMap.keySet()) {
-                ApplicationDescription applicationDescription = applicationDeploymentDescriptionMap.get(descriptors);
-                ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(applicationDescription);
-                applicationDescriptor.setHostdescName(descriptors[1]);
-                ServiceDescription serviceDescription = airavataRegistry.getServiceDescriptor(descriptors[0]);
-                if (serviceDescription == null) {
-                    Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                    return builder.build();
-                }
-                ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
-                applicationDescriptor.setServiceDescriptor(serviceDescriptor);
-                applicationDescriptors[i] = applicationDescriptor;
-                i++;
-            }
-            applicationDescriptorList.setApplicationDescriptors(applicationDescriptors);
-            if (applicationDeploymentDescriptionMap.size() != 0) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(applicationDescriptorList);
-                return builder.build();
-            } 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);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCRIPTORS, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will return all the application names available
-     *
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_NAMES)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getApplicationDescriptorNames() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            Map<String[], ApplicationDescription> applicationDeploymentDescriptionMap = airavataRegistry.getApplicationDescriptors();
-            DescriptorNameList descriptorNameList = new DescriptorNameList();
-            List<String> appDesNames = new ArrayList<String>();
-            for (String[] descriptors : applicationDeploymentDescriptionMap.keySet()) {
-                ApplicationDescription applicationDescription = applicationDeploymentDescriptionMap.get(descriptors);
-                appDesNames.add(applicationDescription.getType().getApplicationName().getStringValue());
-            }
-            descriptorNameList.setDescriptorNames(appDesNames);
-            if (applicationDeploymentDescriptionMap.size() != 0) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(descriptorNameList);
-                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);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.APP_DESC_NAMES, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method wil remove an application descriptor according to given service name, host name
-     * and application name
-     *
-     * @param serviceName service name
-     * @param hostName    host name
-     * @param appName     application name
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_DELETE)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response removeApplicationDescriptor(@QueryParam("serviceName") String serviceName,
-                                                @QueryParam("hostName") String hostName,
-                                                @QueryParam("appName") String appName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.removeApplicationDescriptor(serviceName, hostName, appName);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Application descriptor deleted successfully...");
-            return builder.build();
-        } catch (DescriptorDoesNotExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.DecResourcePathConstants.APP_DESC_DELETE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/0e2c10f5/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ExperimentRegistryResource.java
----------------------------------------------------------------------
diff --git a/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ExperimentRegistryResource.java b/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ExperimentRegistryResource.java
deleted file mode 100644
index 1b667f1..0000000
--- a/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ExperimentRegistryResource.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.services.registry.rest.resources;
-
-import org.apache.airavata.registry.api.AiravataExperiment;
-import org.apache.airavata.registry.api.AiravataRegistry2;
-import org.apache.airavata.registry.api.AiravataUser;
-import org.apache.airavata.registry.api.Gateway;
-import org.apache.airavata.registry.api.exception.worker.ExperimentDoesNotExistsException;
-import org.apache.airavata.registry.api.exception.worker.WorkspaceProjectDoesNotExistsException;
-import org.apache.airavata.rest.mappings.resourcemappings.ExperimentList;
-import org.apache.airavata.rest.mappings.utils.ResourcePathConstants;
-import org.apache.airavata.rest.mappings.utils.RegPoolUtils;
-import org.apache.airavata.services.registry.rest.utils.WebAppUtil;
-
-import javax.servlet.ServletContext;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-/**
- * This class is a REST interface all the methods related to experiments that are exposed by
- * Airavata Registry API
- */
-@Path(ResourcePathConstants.ExperimentResourcePathConstants.EXP_RESOURCE_PATH)
-public class ExperimentRegistryResource {
-
-    @Context
-    ServletContext context;
-
-    /**
-     * ---------------------------------Experiments----------------------------------*
-     */
-
-    /**
-     * This method will delete an experiment with given experiment ID
-     *
-     * @param experimentId experiment ID
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.ExperimentResourcePathConstants.DELETE_EXP)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response removeExperiment(@QueryParam("experimentId") String experimentId) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.removeExperiment(experimentId);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Experiment removed successfully...");
-            return builder.build();
-        } catch (ExperimentDoesNotExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ExperimentResourcePathConstants.DELETE_EXP, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will return all the experiments available
-     *
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ExperimentResourcePathConstants.GET_ALL_EXPS)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getExperiments() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            List<AiravataExperiment> airavataExperimentList = airavataRegistry.getExperiments();
-            ExperimentList experimentList = new ExperimentList();
-            AiravataExperiment[] experiments = new AiravataExperiment[airavataExperimentList.size()];
-            for (int i = 0; i < airavataExperimentList.size(); i++) {
-                experiments[i] = airavataExperimentList.get(i);
-            }
-            experimentList.setExperiments(experiments);
-            if (airavataExperimentList.size() != 0) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(experimentList);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ExperimentResourcePathConstants.GET_ALL_EXPS, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will return all the experiments for a given project
-     *
-     * @param projectName project name
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ExperimentResourcePathConstants.GET_EXPS_BY_PROJECT)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getExperimentsByProject(@QueryParam("projectName") String projectName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            List<AiravataExperiment> airavataExperimentList = airavataRegistry.getExperiments(projectName);
-            ExperimentList experimentList = new ExperimentList();
-            AiravataExperiment[] experiments = new AiravataExperiment[airavataExperimentList.size()];
-            for (int i = 0; i < airavataExperimentList.size(); i++) {
-                experiments[i] = airavataExperimentList.get(i);
-            }
-            experimentList.setExperiments(experiments);
-            if (airavataExperimentList.size() != 0) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(experimentList);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ExperimentResourcePathConstants.GET_EXPS_BY_PROJECT, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will return all the experiments in a given period of time
-     *
-     * @param fromDate starting date
-     * @param toDate   end date
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ExperimentResourcePathConstants.GET_EXPS_BY_DATE)
-    @Consumes({MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON})
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getExperimentsByDate(@QueryParam("fromDate") String fromDate,
-                                         @QueryParam("toDate") String toDate) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            Date formattedFromDate = dateFormat.parse(fromDate);
-            Date formattedToDate = dateFormat.parse(toDate);
-            List<AiravataExperiment> airavataExperimentList = airavataRegistry.getExperiments(formattedFromDate, formattedToDate);
-            ExperimentList experimentList = new ExperimentList();
-            AiravataExperiment[] experiments = new AiravataExperiment[airavataExperimentList.size()];
-            for (int i = 0; i < airavataExperimentList.size(); i++) {
-                experiments[i] = airavataExperimentList.get(i);
-            }
-            experimentList.setExperiments(experiments);
-            if (airavataExperimentList.size() != 0) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(experimentList);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (ParseException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ExperimentResourcePathConstants.GET_EXPS_BY_DATE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will return all the experiments for a given project in a given period of time
-     *
-     * @param projectName project name
-     * @param fromDate    starting date
-     * @param toDate      end date
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ExperimentResourcePathConstants.GET_EXPS_PER_PROJECT_BY_DATE)
-    @Consumes({MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON})
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getExperimentsByProjectDate(@QueryParam("projectName") String projectName,
-                                                @QueryParam("fromDate") String fromDate,
-                                                @QueryParam("toDate") String toDate) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            Date formattedFromDate = dateFormat.parse(fromDate);
-            Date formattedToDate = dateFormat.parse(toDate);
-            List<AiravataExperiment> airavataExperimentList = airavataRegistry.getExperiments(projectName, formattedFromDate, formattedToDate);
-            ExperimentList experimentList = new ExperimentList();
-            AiravataExperiment[] experiments = new AiravataExperiment[airavataExperimentList.size()];
-            for (int i = 0; i < airavataExperimentList.size(); i++) {
-                experiments[i] = airavataExperimentList.get(i);
-            }
-            experimentList.setExperiments(experiments);
-            if (airavataExperimentList.size() != 0) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(experimentList);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (ParseException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ExperimentResourcePathConstants.GET_EXPS_PER_PROJECT_BY_DATE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will add a new experiment
-     *
-     * @param projectName   project name
-     * @param experimentID  experiment ID
-     * @param submittedDate submitted date
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ExperimentResourcePathConstants.ADD_EXP)
-    @Consumes({MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON})
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response addExperiment(@FormParam("projectName") String projectName,
-                                  @FormParam("experimentID") String experimentID,
-                                  @FormParam("submittedDate") String submittedDate) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            AiravataExperiment experiment = new AiravataExperiment();
-            experiment.setExperimentId(experimentID);
-            Gateway gateway = airavataRegistry.getGateway();
-            AiravataUser airavataUser = airavataRegistry.getAiravataUser();
-            experiment.setGateway(gateway);
-            experiment.setUser(airavataUser);
-            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            Date formattedDate = dateFormat.parse(submittedDate);
-            experiment.setSubmittedDate(formattedDate);
-            airavataRegistry.addExperiment(projectName, experiment);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Experiment added successfully...");
-            return builder.build();
-        } catch (ExperimentDoesNotExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (WorkspaceProjectDoesNotExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (ParseException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ExperimentResourcePathConstants.ADD_EXP, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-
-    }
-
-    /**
-     * This method will check whether the given experiment ID exists
-     *
-     * @param experimentId experiment ID
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ExperimentResourcePathConstants.EXP_EXISTS)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response isExperimentExists(@QueryParam("experimentId") String experimentId) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.isExperimentExists(experimentId);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("True");
-            return builder.build();
-        } catch (ExperimentDoesNotExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
-            builder.entity("False");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ExperimentResourcePathConstants.EXP_EXISTS, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will check whether an experiment exist and create if not exists according to the
-     * createIfNotPresent flag
-     *
-     * @param experimentId       experiment ID
-     * @param createIfNotPresent flag to check whether to create a new experiment or not
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ExperimentResourcePathConstants.EXP_EXISTS_CREATE)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response isExperimentExistsThenCreate(@FormParam("experimentId") String experimentId,
-                                                 @FormParam("createIfNotPresent") String createIfNotPresent) {
-        boolean createIfNotPresentStatus = Boolean.valueOf(createIfNotPresent);
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.isExperimentExists(experimentId, createIfNotPresentStatus);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("New experiment created...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ExperimentResourcePathConstants.EXP_EXISTS_CREATE, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/0e2c10f5/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ProjectRegistryResource.java
----------------------------------------------------------------------
diff --git a/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ProjectRegistryResource.java b/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ProjectRegistryResource.java
deleted file mode 100644
index 3a64fe2..0000000
--- a/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ProjectRegistryResource.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-package org.apache.airavata.services.registry.rest.resources;
-
-import org.apache.airavata.registry.api.AiravataRegistry2;
-import org.apache.airavata.registry.api.WorkspaceProject;
-import org.apache.airavata.registry.api.exception.worker.WorkspaceProjectAlreadyExistsException;
-import org.apache.airavata.registry.api.exception.worker.WorkspaceProjectDoesNotExistsException;
-import org.apache.airavata.rest.mappings.resourcemappings.WorkspaceProjectList;
-import org.apache.airavata.rest.mappings.utils.ResourcePathConstants;
-import org.apache.airavata.rest.mappings.utils.RegPoolUtils;
-import org.apache.airavata.services.registry.rest.utils.WebAppUtil;
-
-import javax.servlet.ServletContext;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.List;
-
-/**
- * This class is a REST interface for all the operations related to Project that are exposed in
- * Airavata Registry API
- */
-@Path(ResourcePathConstants.ProjectResourcePathConstants.REGISTRY_API_PROJECTREGISTRY)
-public class ProjectRegistryResource {
-
-    @Context
-    ServletContext context;
-
-    /**
-     * ---------------------------------Project Registry----------------------------------*
-     */
-
-    /**
-     * This method will check whether a given project name exists
-     * @param projectName project name
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ProjectResourcePathConstants.PROJECT_EXIST)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response isWorkspaceProjectExists(@QueryParam("projectName") String projectName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            boolean result = airavataRegistry.isWorkspaceProjectExists(projectName);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity("True");
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity("False");
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ProjectResourcePathConstants.PROJECT_EXIST, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will check whether a project exists and create according to the createIfNotExists
-     * flag
-     * @param projectName project name
-     * @param createIfNotExists  flag to check whether a new project should be created or not
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ProjectResourcePathConstants.PROJECT_EXIST_CREATE)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response isWorkspaceProjectExistsCreate(@FormParam("projectName") String projectName,
-                                             @FormParam("createIfNotExists") String createIfNotExists) {
-        boolean createIfNotExistStatus = Boolean.valueOf(createIfNotExists);
-
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            boolean result = airavataRegistry.isWorkspaceProjectExists(projectName, createIfNotExistStatus);
-            if (result) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity("True");
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity("False");
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ProjectResourcePathConstants.PROJECT_EXIST_CREATE, e);
-        }finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will add new workspace project
-     * @param projectName project name
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ProjectResourcePathConstants.ADD_PROJECT)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response addWorkspaceProject(@FormParam("projectName") String projectName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            WorkspaceProject workspaceProject = new WorkspaceProject(projectName, airavataRegistry);
-            airavataRegistry.addWorkspaceProject(workspaceProject);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Workspace project added successfully...");
-            return builder.build();
-        } catch (WorkspaceProjectAlreadyExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ProjectResourcePathConstants.ADD_PROJECT, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will update the workspace project
-     * @param projectName project name
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ProjectResourcePathConstants.UPDATE_PROJECT)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response updateWorkspaceProject(@FormParam("projectName") String projectName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            WorkspaceProject workspaceProject = new WorkspaceProject(projectName, airavataRegistry);
-            airavataRegistry.updateWorkspaceProject(workspaceProject);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Workspace project updated successfully...");
-            return builder.build();
-        } catch (WorkspaceProjectDoesNotExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ProjectResourcePathConstants.UPDATE_PROJECT, e);
-        }  finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will delete workspace project
-     * @param projectName project name
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.ProjectResourcePathConstants.DELETE_PROJECT)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response deleteWorkspaceProject(@QueryParam("projectName") String projectName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.deleteWorkspaceProject(projectName);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Workspace project deleted successfully...");
-            return builder.build();
-        } catch (WorkspaceProjectDoesNotExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ProjectResourcePathConstants.DELETE_PROJECT, e);
-        }  finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve the workspace project
-     * @param projectName project name
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ProjectResourcePathConstants.GET_PROJECT)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getWorkspaceProject(@QueryParam("projectName") String projectName) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            WorkspaceProject workspaceProject = airavataRegistry.getWorkspaceProject(projectName);
-            if (workspaceProject != null) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(workspaceProject);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
-                return builder.build();
-            }
-        } catch (WorkspaceProjectDoesNotExistsException e) {
-            Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-            builder.entity(e.getMessage());
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ProjectResourcePathConstants.GET_PROJECT, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve all the workspace projects
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ProjectResourcePathConstants.GET_PROJECTS)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getWorkspaceProjects() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            List<WorkspaceProject> workspaceProjects = airavataRegistry.getWorkspaceProjects();
-            WorkspaceProjectList workspaceProjectList = new WorkspaceProjectList();
-            WorkspaceProject[] workspaceProjectSet = new WorkspaceProject[workspaceProjects.size()];
-            for (int i = 0; i < workspaceProjects.size(); i++) {
-                workspaceProjectSet[i] = workspaceProjects.get(i);
-            }
-            workspaceProjectList.setWorkspaceProjects(workspaceProjectSet);
-            if (workspaceProjects.size() != 0) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(workspaceProjectList);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ProjectResourcePathConstants.GET_PROJECTS, e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-}


Mime
View raw message