airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samin...@apache.org
Subject [35/90] [abbrv] [partial] AIRAVATA-1124
Date Mon, 14 Apr 2014 18:30:37 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/BasicRegistryResouce.java
----------------------------------------------------------------------
diff --git a/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java
b/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java
deleted file mode 100644
index 81db28e..0000000
--- a/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/BasicRegistryResouce.java
+++ /dev/null
@@ -1,199 +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.common.utils.Version;
-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.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.net.URI;
-
-@Path(ResourcePathConstants.BasicRegistryConstants.REGISTRY_API_BASICREGISTRY)
-public class BasicRegistryResouce {
-    @Context
-    ServletContext context;
-
-    @GET
-    @Path(ResourcePathConstants.BasicRegistryConstants.GET_GATEWAY)
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    public Response getGateway() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            Gateway gateway = airavataRegistry.getGateway();
-            if (gateway != null) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(gateway);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.BasicRegistryConstants.GET_GATEWAY,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    @GET
-    @Path(ResourcePathConstants.BasicRegistryConstants.GET_USER)
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    public Response getAiravataUser() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            AiravataUser airavataUser = airavataRegistry.getAiravataUser();
-            if (airavataUser != null) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(airavataUser);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.BasicRegistryConstants.GET_USER,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    @POST
-    @Path(ResourcePathConstants.BasicRegistryConstants.SET_GATEWAY)
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response setGateway(Gateway gateway) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.setGateway(gateway);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Gateway added successfully");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.BasicRegistryConstants.SET_GATEWAY,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    @POST
-    @Path(ResourcePathConstants.BasicRegistryConstants.SET_USER)
-    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response setAiravataUser(AiravataUser user) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.setAiravataUser(user);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Airavata user added successfully");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.BasicRegistryConstants.SET_USER,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    @GET
-    @Path(ResourcePathConstants.BasicRegistryConstants.VERSION)
-    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-    public Response getVersion() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            Version version = airavataRegistry.getVersion();
-            if (version != null) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(version);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.BasicRegistryConstants.VERSION,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    @GET
-    @Path(ResourcePathConstants.BasicRegistryConstants.GET_SERVICE_URL)
-    @Produces({MediaType.TEXT_PLAIN,MediaType.APPLICATION_JSON})
-    public Response getConnectionURL (){
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try{
-            String connectionURL = airavataRegistry.getConnectionURI().toString();
-            if (connectionURL != null) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(connectionURL);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.BasicRegistryConstants.GET_SERVICE_URL,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    @POST
-    @Path(ResourcePathConstants.BasicRegistryConstants.SET_SERVICE_URL)
-    @Produces({MediaType.TEXT_PLAIN,MediaType.APPLICATION_JSON})
-    public Response setConnectionURL (@FormParam("connectionurl") String connectionURL){
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try{
-            URI uri = new URI(connectionURL);
-            airavataRegistry.setConnectionURI(uri);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Connection URL updated successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.BasicRegistryConstants.SET_SERVICE_URL,
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/ConfigurationRegistryResource.java
----------------------------------------------------------------------
diff --git a/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ConfigurationRegistryResource.java
b/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ConfigurationRegistryResource.java
deleted file mode 100644
index bd1f8c0..0000000
--- a/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/ConfigurationRegistryResource.java
+++ /dev/null
@@ -1,732 +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.rest.mappings.resourcemappings.ConfigurationList;
-import org.apache.airavata.rest.mappings.resourcemappings.URLList;
-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.net.URI;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-/**
- * This class is a REST interface to all the methods related to Configuration which are exposed
by
- * Airavata Registry API
- */
-@Path(ResourcePathConstants.ConfigResourcePathConstants.CONFIGURATION_REGISTRY_RESOURCE)
-public class ConfigurationRegistryResource {
-
-    @Context
-    ServletContext context;
-
-    /**
-     * This method will return the configuration value corrosponding to given config key
-     *
-     * @param key configuration key
-     * @return HTTP Response
-     */
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.GET_CONFIGURATION)
-    @GET
-    @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
-    public Response getConfiguration(@QueryParam("key") String key) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            Object configuration = airavataRegistry.getConfiguration(key);
-            if (configuration != null) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(configuration);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.GET_CONFIGURATION,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-
-    }
-
-    /**
-     * This method will return configuration list for given configuration key
-     *
-     * @param key configuration key
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.GET_CONFIGURATION_LIST)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getConfigurationList(@QueryParam("key") String key) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-
-            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(list);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.GET_CONFIGURATION_LIST,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will add a configuration with given config key, config value and expiration
date
-     *
-     * @param key   configuration key
-     * @param value configuration value
-     * @param date  configuration expire data
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.SAVE_CONFIGURATION)
-    @Produces(MediaType.TEXT_PLAIN)
-    @Consumes({MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON})
-    public Response setConfiguration(@FormParam("key") String key,
-                                     @FormParam("value") String value,
-                                     @FormParam("date") String date) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            Date formattedDate = dateFormat.parse(date);
-            airavataRegistry.setConfiguration(key, value, formattedDate);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Configuration saved successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.SAVE_CONFIGURATION,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will update the configuration according to the given config value and
expire
-     * date
-     *
-     * @param key   config key
-     * @param value config value
-     * @param date  expiration date
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.UPDATE_CONFIGURATION)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response addConfiguration(@FormParam("key") String key,
-                                     @FormParam("value") String value,
-                                     @FormParam("date") String date) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            Date formattedDate = dateFormat.parse(date);
-            airavataRegistry.addConfiguration(key, value, formattedDate);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Configuration updated successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.UPDATE_CONFIGURATION,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will delete all configuration of the given config key
-     *
-     * @param key configuration key
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_CONFIGURATION)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response removeAllConfiguration(@QueryParam("key") String key) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.removeAllConfiguration(key);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("All configurations with given config key removed successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_CONFIGURATION,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will delete the configuration with the given config key and config value
-     *
-     * @param key   configuration key
-     * @param value configuration value
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_CONFIGURATION)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response removeConfiguration(@QueryParam("key") String key, @QueryParam("value")
String value) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.removeConfiguration(key, value);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Configuration removed successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.DELETE_CONFIGURATION,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve all the GFac URIs
-     *
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.GET_GFAC_URI_LIST)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getGFacURIs() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            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(list);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.GET_GFAC_URI_LIST,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve all the workflow interpreter URIs
-     *
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.GET_WFINTERPRETER_URI_LIST)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getWorkflowInterpreterURIs() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            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(list);
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.GET_WFINTERPRETER_URI_LIST,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve eventing URI
-     *
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.GET_EVENTING_URI)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response getEventingServiceURI() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            URI eventingServiceURI = airavataRegistry.getEventingServiceURI();
-            if (eventingServiceURI != null) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(eventingServiceURI.toString());
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.GET_EVENTING_URI,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will retrieve messagebox URI
-     *
-     * @return HTTP response
-     */
-    @GET
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.GET_MESSAGE_BOX_URI)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response getMessageBoxURI() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            URI eventingServiceURI = airavataRegistry.getMessageBoxURI();
-            if (eventingServiceURI != null) {
-                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-                builder.entity(eventingServiceURI.toString());
-                return builder.build();
-            } else {
-                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
-                return builder.build();
-            }
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.GET_MESSAGE_BOX_URI,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will add new GFac URI
-     *
-     * @param uri gfac URI
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_GFAC_URI)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response addGFacURI(@FormParam("uri") String uri) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            URI gfacURI = new URI(uri);
-            airavataRegistry.addGFacURI(gfacURI);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("GFac URI added successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.ADD_GFAC_URI,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will add new workflow interpreter URI
-     *
-     * @param uri workflow interpreter URI
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_WFINTERPRETER_URI)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response addWorkflowInterpreterURI(@FormParam("uri") String uri) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            URI interpreterURI = new URI(uri);
-            airavataRegistry.addWorkflowInterpreterURI(interpreterURI);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Workflow interpreter URI added successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.ADD_WFINTERPRETER_URI,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will set a new eventing URI
-     *
-     * @param uri eventing URI
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_EVENTING_URI)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response setEventingURI(@FormParam("uri") String uri) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            URI eventingURI = new URI(uri);
-            airavataRegistry.setEventingURI(eventingURI);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Eventing URI set successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.ADD_EVENTING_URI,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will set message box URI
-     *
-     * @param uri message box URI
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_MESSAGE_BOX_URI)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response setMessageBoxURI(@FormParam("uri") String uri) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            URI msgBoxURI = new URI(uri);
-            airavataRegistry.setMessageBoxURI(msgBoxURI);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("MessageBox URI set successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.ADD_MESSAGE_BOX_URI,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will update GFac URI expiring date
-     *
-     * @param uri  GFac URI
-     * @param date Expiration date
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_GFAC_URI_DATE)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response addGFacURIByDate(@FormParam("uri") String uri, @FormParam("date") String
date) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            Date formattedDate = dateFormat.parse(date);
-            URI gfacURI = new URI(uri);
-            airavataRegistry.addGFacURI(gfacURI, formattedDate);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("GFac URI added successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.ADD_GFAC_URI_DATE,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will update workflow interpreter URI expiration date
-     *
-     * @param uri  workflow interpreter URI
-     * @param date workflow interpreter expiration date
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_WFINTERPRETER_URI_DATE)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response addWorkflowInterpreterURI(@FormParam("uri") String uri, @FormParam("date")
String date) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            Date formattedDate = dateFormat.parse(date);
-            URI interpreterURI = new URI(uri);
-            airavataRegistry.addWorkflowInterpreterURI(interpreterURI, formattedDate);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Workflow interpreter URI added successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.ADD_WFINTERPRETER_URI_DATE,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will update Eventing URI expiration date
-     *
-     * @param uri  eventing URI
-     * @param date eventing URI expiration date
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_EVENTING_URI_DATE)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response setEventingURIByDate(@FormParam("uri") String uri, @FormParam("date")
String date) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            Date formattedDate = dateFormat.parse(date);
-            URI eventingURI = new URI(uri);
-            airavataRegistry.setEventingURI(eventingURI, formattedDate);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Eventing URI added successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.ADD_EVENTING_URI_DATE,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will update expiration date of Message box URI
-     *
-     * @param uri  message box URI
-     * @param date message box expiration date
-     * @return HTTP response
-     */
-    @POST
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.ADD_MSG_BOX_URI_DATE)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response setMessageBoxURIByDate(@FormParam("uri") String uri, @FormParam("date")
String date) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            Date formattedDate = dateFormat.parse(date);
-            URI msgBoxURI = new URI(uri);
-            airavataRegistry.setMessageBoxURI(msgBoxURI, formattedDate);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Message box URI retrieved successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.ADD_MSG_BOX_URI_DATE,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will remove GFac URI
-     *
-     * @param uri GFac URI
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_GFAC_URI)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response removeGFacURI(@QueryParam("uri") String uri) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            URI gfacURI = new URI(uri);
-            airavataRegistry.removeGFacURI(gfacURI);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("GFac URI deleted successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.DELETE_GFAC_URI,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will remove all the GFac URIs
-     *
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_GFAC_URIS)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response removeAllGFacURI() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.removeAllGFacURI();
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("All GFac URIs deleted successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_GFAC_URIS,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will remove workflow interpreter URI
-     *
-     * @param uri workflow interpreter URI
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_WFINTERPRETER_URI)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response removeWorkflowInterpreterURI(@QueryParam("uri") String uri) {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            URI intURI = new URI(uri);
-            airavataRegistry.removeWorkflowInterpreterURI(intURI);
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Workflow Interpreter URI deleted successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.DELETE_WFINTERPRETER_URI,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will remove all the workflow interpreter URIs
-     *
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_WFINTERPRETER_URIS)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response removeAllWorkflowInterpreterURI() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.removeAllWorkflowInterpreterURI();
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("All workflow interpreter URIs deleted successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_WFINTERPRETER_URIS,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will remove eventing URI
-     *
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_EVENTING_URI)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response unsetEventingURI() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.unsetEventingURI();
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("Eventing URI deleted successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.DELETE_EVENTING_URI,
e);
-        } finally {
-            if (airavataRegistry != null) {
-                RegPoolUtils.releaseRegistry(context, airavataRegistry);
-            }
-        }
-    }
-
-    /**
-     * This method will remove message box URI
-     *
-     * @return HTTP response
-     */
-    @DELETE
-    @Path(ResourcePathConstants.ConfigResourcePathConstants.DELETE_MSG_BOX_URI)
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response unsetMessageBoxURI() {
-        AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-        try {
-            airavataRegistry.unsetMessageBoxURI();
-            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-            builder.entity("MessageBox URI deleted successfully...");
-            return builder.build();
-        } catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.ConfigResourcePathConstants.DELETE_MSG_BOX_URI,
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/CredentialRegistryResource.java
----------------------------------------------------------------------
diff --git a/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/CredentialRegistryResource.java
b/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/CredentialRegistryResource.java
deleted file mode 100644
index a149cc0..0000000
--- a/modules/rest/service/src/main/java/org/apache/airavata/services/registry/rest/resources/CredentialRegistryResource.java
+++ /dev/null
@@ -1,152 +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 javax.servlet.ServletContext;
-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 org.apache.airavata.registry.api.AiravataRegistry2;
-import org.apache.airavata.rest.mappings.utils.RegPoolUtils;
-import org.apache.airavata.rest.mappings.utils.ResourcePathConstants;
-import org.apache.airavata.services.registry.rest.utils.WebAppUtil;
-
-/**
- * This class provides a REST interface to all the operations related to credential store
- */
-@Path(ResourcePathConstants.CredentialResourceConstants.REGISTRY_API_CREDENTIALREGISTRY)
-public class CredentialRegistryResource {
-    
-	@Context
-    ServletContext context;
-
-    /**
-     * This method will check whether a credential exists for a given tokenId and gateway
-     *
-     * @param String gatewayId
-     * @param String tokenId
-     * @return HTTP response boolean
-     */
-    @GET
-    @Path(ResourcePathConstants.CredentialResourceConstants.SSH_CREDENTIAL_EXIST)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response isCredentialExist(@QueryParam("gatewayId") String gatewayId, @QueryParam("tokenId")
String tokenId) {
-    	if(gatewayId==null || gatewayId.isEmpty() || tokenId == null || tokenId.isEmpty()) {
-    		Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-    		builder.entity("gatewayId or username can't be null");
-    		return builder.build();
-    	}
-    	
-    	AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-    	try {
-         	String publicKey = airavataRegistry.getCredentialPublicKey(gatewayId,tokenId);
-	    	if (publicKey!=null && publicKey.isEmpty()) {
-	    		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.CredentialResourceConstants.SSH_CREDENTIAL,
e);
-    	}
-    }
-    
-    
-    /**
-     * This method will get the public key of the ssh credential exists for a given user
and gateway
-     *
-     * @param String gatewayId
-     * @param String tokenId
-     * @return HTTP response - The public key of the credential 
-     */
-    @GET
-    @Path(ResourcePathConstants.CredentialResourceConstants.SSH_CREDENTIAL)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response getCredentialPublicKey(@QueryParam("gatewayId") String gatewayId, @QueryParam("tokenId")
String tokenId) {
-    	if(gatewayId==null || gatewayId.isEmpty() || tokenId == null || tokenId.isEmpty()) {
-    		Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-    		builder.entity("gatewayId or username can't be null");
-    		return builder.build();
-    	}
-    	
-    	AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-    	try {
-         	String publicKey = airavataRegistry.getCredentialPublicKey(gatewayId,tokenId);
-	    	if (publicKey!=null && publicKey.isEmpty()) {
-	    		Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-	    		builder.entity(publicKey);
-	    		return builder.build();
-	    	} else {
-	    		Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
-	    		return builder.build();
-	    	}
-		} catch (Throwable e) {
-			return WebAppUtil.reportInternalServerError(ResourcePathConstants.CredentialResourceConstants.SSH_CREDENTIAL,
e);
-		}
-    }
-    
-    
-    /**
-     * This method will create a new ssh credential for a given user, gateway and return
the public key of the keypair
-     *
-     * @param String gatewayId
-     * @param String tokenId
-     * @return HTTP response - The public key of the credential 
-     */
-    @POST
-    @Path(ResourcePathConstants.CredentialResourceConstants.SSH_CREDENTIAL)
-    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
-    public Response createCredential(@QueryParam("gatewayId") String gatewayId, @QueryParam("tokenId")
String tokenId) {
-    	if(gatewayId==null || gatewayId.isEmpty() || tokenId == null || tokenId.isEmpty()) {
-    		Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
-    		builder.entity("gatewayId or username can't be null");
-    		return builder.build();
-    	}
-    	AiravataRegistry2 airavataRegistry = RegPoolUtils.acquireRegistry(context);
-    	try {
-         	String publicKey = airavataRegistry.createCredential(gatewayId, tokenId);
-	    	if (publicKey!=null && publicKey.isEmpty()) {
-	    		Response.ResponseBuilder builder = Response.status(Response.Status.OK);
-	    		builder.entity(publicKey);
-	    		return builder.build();
-	    	} else {
-	    		Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
-	    		builder.entity("Error creating credential");
-	    		return builder.build();
-	    	}
-    	} catch (Throwable e) {
-            return WebAppUtil.reportInternalServerError(ResourcePathConstants.CredentialResourceConstants.SSH_CREDENTIAL,
e);
-        }
-    }
-    
-    
-
-}


Mime
View raw message