You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2014/04/14 20:30:43 UTC

[41/90] [abbrv] [partial] AIRAVATA-1124

http://git-wip-us.apache.org/repos/asf/airavata/blob/0e2c10f5/modules/rest/client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java
----------------------------------------------------------------------
diff --git a/modules/rest/client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java b/modules/rest/client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java
deleted file mode 100644
index 8252244..0000000
--- a/modules/rest/client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java
+++ /dev/null
@@ -1,1278 +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.rest.client;
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
-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.PasswordCallback;
-import org.apache.airavata.registry.api.exception.gateway.DescriptorAlreadyExistsException;
-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.utils.BasicAuthHeaderUtil;
-import org.apache.airavata.rest.utils.ClientConstant;
-import org.apache.airavata.rest.utils.CookieManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.core.Cookie;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriBuilder;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class DescriptorResourceClient {
-    private WebResource webResource;
-    private final static Logger logger = LoggerFactory.getLogger(DescriptorResourceClient.class);
-    private String userName;
-    private PasswordCallback callback;
-    private String baseURI;
-    private Cookie cookie;
-    private WebResource.Builder builder;
-    private String gateway;
-//    private CookieManager cookieManager = new CookieManager();
-
-    public DescriptorResourceClient(String userName,
-                                    String gateway,
-                                    String serviceURI,
-                                    PasswordCallback callback,
-                                    Cookie cookie) {
-        this.userName = userName;
-        this.callback = callback;
-        this.baseURI = serviceURI;
-        this.gateway = gateway;
-        this.cookie = cookie;
-    }
-
-    private URI getBaseURI() {
-        logger.debug("Creating Base URI");
-        return UriBuilder.fromUri(baseURI).build();
-    }
-
-    private WebResource getDescriptorRegistryBaseResource() {
-        ClientConfig config = new DefaultClientConfig();
-        config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
-                Boolean.TRUE);
-        Client client = Client.create(config);
-        WebResource baseWebResource = client.resource(getBaseURI());
-        webResource = baseWebResource.path(
-                ResourcePathConstants.DecResourcePathConstants.DESC_RESOURCE_PATH);
-        return webResource;
-    }
-
-    public boolean isHostDescriptorExists(String hostDescriptorName) {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.HOST_DESC_EXISTS);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("hostDescriptorName", hostDescriptorName);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.get(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-            String exists = response.getEntity(String.class);
-            if (exists.equals("True")) {
-                return true;
-            } else {
-                return false;
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.get(ClientResponse.class);
-            status = response.getStatus();
-            if (status == ClientConstant.HTTP_OK) {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-
-            String exists = response.getEntity(String.class);
-            if (exists.equals("True")) {
-                return true;
-            } else {
-                return false;
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-
-    public void addHostDescriptor(HostDescription hostDescription) throws DescriptorAlreadyExistsException {
-        HostDescriptor hostDescriptor = DescriptorUtil.createHostDescriptor(hostDescription);
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.HOST_DESC_SAVE);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).post(ClientResponse.class, hostDescriptor);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(
-                    MediaType.APPLICATION_JSON).post(ClientResponse.class, hostDescriptor);
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_OK) {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }else if (status == ClientConstant.HTTP_BAD_REQUEST){
-                logger.debug("Descriptor already exists...");
-                throw new DescriptorAlreadyExistsException(hostDescription.getType().getHostName());
-            } else {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-
-            }
-        }else if (status == ClientConstant.HTTP_BAD_REQUEST){
-            logger.debug("Descriptor already exists...");
-            throw new DescriptorAlreadyExistsException(hostDescription.getType().getHostName());
-        }
-        else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public void updateHostDescriptor(HostDescription hostDescription) {
-        HostDescriptor hostDescriptor = DescriptorUtil.createHostDescriptor(hostDescription);
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.HOST_DESC_UPDATE);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).post(ClientResponse.class, hostDescriptor);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(
-                    MediaType.APPLICATION_JSON).post(ClientResponse.class, hostDescriptor);
-
-            status = response.getStatus();
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public HostDescription getHostDescriptor(String hostName) {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.HOST_DESC);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("hostName", hostName);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).type(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(
-                    MediaType.APPLICATION_JSON).type(
-                    MediaType.APPLICATION_JSON).get(ClientResponse.class);
-
-            status = response.getStatus();
-
-            if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_BAD_REQUEST) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else if (status == ClientConstant.HTTP_BAD_REQUEST) {
-                return null;
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_BAD_REQUEST) {
-            return null;
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        HostDescriptor hostDescriptor = response.getEntity(HostDescriptor.class);
-        HostDescription hostDescription = DescriptorUtil.createHostDescription(hostDescriptor);
-        return hostDescription;
-    }
-
-    public void removeHostDescriptor(String hostName) {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.HOST_DESC_DELETE);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("hostName", hostName);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.delete(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.delete(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public List<HostDescription> getHostDescriptors() {
-        List<HostDescription> hostDescriptions = new ArrayList<HostDescription>();
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.GET_HOST_DESCS);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(
-                    MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_NO_CONTENT) {
-                return hostDescriptions;
-            }
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_NO_CONTENT) {
-            return hostDescriptions;
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        HostDescriptionList hostDescriptionList = response.getEntity(HostDescriptionList.class);
-        HostDescriptor[] hostDescriptors = hostDescriptionList.getHostDescriptions();
-
-        for (HostDescriptor hostDescriptor : hostDescriptors) {
-            HostDescription hostDescription = DescriptorUtil.createHostDescription(hostDescriptor);
-            hostDescriptions.add(hostDescription);
-        }
-
-        return hostDescriptions;
-    }
-
-    public List<String> getHostDescriptorNames() {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.GET_HOST_DESCS_NAMES);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-            if (status == ClientConstant.HTTP_NO_CONTENT) {
-                return new ArrayList<String>();
-            }
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_NO_CONTENT) {
-            return new ArrayList<String>();
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        DescriptorNameList descriptorNameList = response.getEntity(DescriptorNameList.class);
-        return descriptorNameList.getDescriptorNames();
-    }
-
-    public boolean isServiceDescriptorExists(String serviceDescriptorName) {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_EXISTS);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("serviceDescriptorName", serviceDescriptorName);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.get(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-            String exists = response.getEntity(String.class);
-            if (exists.equals("True")) {
-                return true;
-            } else {
-                return false;
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.get(ClientResponse.class);
-            status = response.getStatus();
-            if (status == ClientConstant.HTTP_OK) {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-            String exists = response.getEntity(String.class);
-            if (exists.equals("True")) {
-                return true;
-            } else {
-                return false;
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public void addServiceDescriptor(ServiceDescription serviceDescription) throws DescriptorAlreadyExistsException {
-        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_SAVE);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).post(ClientResponse.class, serviceDescriptor);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(
-                    MediaType.APPLICATION_JSON).post(ClientResponse.class, serviceDescriptor);
-
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_BAD_REQUEST){
-                logger.debug("Descriptor already exists...");
-                throw new DescriptorAlreadyExistsException(serviceDescriptor.getServiceName());
-            } else if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_BAD_REQUEST){
-            logger.debug("Descriptor already exists...");
-            throw new DescriptorAlreadyExistsException(serviceDescriptor.getServiceName());
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public void updateServiceDescriptor(ServiceDescription serviceDescription) {
-        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_UPDATE);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).post(ClientResponse.class, serviceDescriptor);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(
-                    MediaType.APPLICATION_JSON).post(ClientResponse.class, serviceDescriptor);
-            status = response.getStatus();
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public ServiceDescription getServiceDescriptor(String serviceName) {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("serviceName", serviceName);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_BAD_REQUEST) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else if (status == ClientConstant.HTTP_BAD_REQUEST) {
-                return null;
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_BAD_REQUEST) {
-            return null;
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        ServiceDescriptor serviceDescriptor = response.getEntity(ServiceDescriptor.class);
-        ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(serviceDescriptor);
-        return serviceDescription;
-    }
-
-    public void removeServiceDescriptor(String serviceName) {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_DELETE);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("serviceName", serviceName);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.delete(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.delete(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public List<ServiceDescription> getServiceDescriptors() {
-        List<ServiceDescription> serviceDescriptions = new ArrayList<ServiceDescription>();
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.GET_SERVICE_DESCS);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_NO_CONTENT) {
-                return serviceDescriptions;
-            }
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_NO_CONTENT) {
-            return serviceDescriptions;
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        ServiceDescriptionList serviceDescriptionList = response.getEntity(ServiceDescriptionList.class);
-        ServiceDescriptor[] serviceDescriptors = serviceDescriptionList.getServiceDescriptions();
-
-        for (ServiceDescriptor serviceDescriptor : serviceDescriptors) {
-            ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(serviceDescriptor);
-            serviceDescriptions.add(serviceDescription);
-        }
-        return serviceDescriptions;
-    }
-
-    public boolean isApplicationDescriptorExists(String serviceName,
-                                                 String hostName,
-                                                 String appDescriptorName) {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.APPL_DESC_EXIST);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("serviceName", serviceName);
-        queryParams.add("hostName", hostName);
-        queryParams.add("appDescName", appDescriptorName);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.get(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-            String exists = response.getEntity(String.class);
-            if (exists.equals("True")) {
-                return true;
-            } else {
-                return false;
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.get(ClientResponse.class);
-            status = response.getStatus();
-            if (status == ClientConstant.HTTP_OK) {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-            String exists = response.getEntity(String.class);
-            if (exists.equals("True")) {
-                return true;
-            } else {
-                return false;
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public void addApplicationDescriptor(ServiceDescription serviceDescription,
-                                         HostDescription hostDescriptor,
-                                         ApplicationDescription descriptor) throws DescriptorAlreadyExistsException {
-        ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(descriptor);
-        applicationDescriptor.setHostdescName(hostDescriptor.getType().getHostName());
-        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
-        applicationDescriptor.setServiceDescriptor(serviceDescriptor);
-
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.APP_DESC_BUILD_SAVE);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(
-                    MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_BAD_REQUEST){
-                logger.debug("Descriptor already exists...");
-                throw new DescriptorAlreadyExistsException(applicationDescriptor.getName());
-            } else if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_BAD_REQUEST){
-            logger.debug("Descriptor already exists...");
-            throw new DescriptorAlreadyExistsException(applicationDescriptor.getName());
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public void addApplicationDescriptor(String serviceName,
-                                         String hostName,
-                                         ApplicationDescription descriptor) throws DescriptorAlreadyExistsException {
-        ServiceDescription serviceDescription = getServiceDescriptor(serviceName);
-        ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(descriptor);
-        applicationDescriptor.setHostdescName(hostName);
-        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
-        applicationDescriptor.setServiceDescriptor(serviceDescriptor);
-
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.APP_DESC_BUILD_SAVE);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(
-                    MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_BAD_REQUEST){
-                logger.debug("Descriptor already exists...");
-                throw new DescriptorAlreadyExistsException(applicationDescriptor.getName());
-            } else if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_BAD_REQUEST){
-            logger.debug("Descriptor already exists...");
-            throw new DescriptorAlreadyExistsException(applicationDescriptor.getName());
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public void udpateApplicationDescriptor(ServiceDescription serviceDescription,
-                                            HostDescription hostDescriptor,
-                                            ApplicationDescription descriptor) {
-        ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(descriptor);
-        applicationDescriptor.setHostdescName(hostDescriptor.getType().getHostName());
-        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
-        applicationDescriptor.setServiceDescriptor(serviceDescriptor);
-
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.APP_DESC_UPDATE);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(
-                    MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
-            status = response.getStatus();
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public void updateApplicationDescriptor(String serviceName,
-                                            String hostName,
-                                            ApplicationDescription descriptor) {
-        ServiceDescription serviceDescription = getServiceDescriptor(serviceName);
-        ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(descriptor);
-        applicationDescriptor.setHostdescName(hostName);
-        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
-        applicationDescriptor.setServiceDescriptor(serviceDescriptor);
-
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.APP_DESC_UPDATE);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(
-                    MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
-            status = response.getStatus();
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public ApplicationDescription getApplicationDescriptor(String serviceName,
-                                                                     String hostname,
-                                                                     String applicationName) {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.APP_DESC_DESCRIPTION);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("serviceName", serviceName);
-        queryParams.add("hostName", hostname);
-        queryParams.add("applicationName", applicationName);
-
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(
-                    MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_BAD_REQUEST) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else if (status == ClientConstant.HTTP_BAD_REQUEST) {
-                return null;
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_BAD_REQUEST) {
-            return null;
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        ApplicationDescriptor applicationDescriptor = response.getEntity(ApplicationDescriptor.class);
-        ApplicationDescription applicationDescription =
-                DescriptorUtil.createApplicationDescription(applicationDescriptor);
-        return applicationDescription;
-    }
-
-    public ApplicationDescription getApplicationDescriptors(String serviceName,
-                                                                      String hostname) {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.APP_DESC_PER_HOST_SERVICE);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("serviceName", serviceName);
-        queryParams.add("hostName", hostname);
-
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_NO_CONTENT) {
-                return null;
-            }
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_NO_CONTENT) {
-            return null;
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        ApplicationDescriptor applicationDescriptor = response.getEntity(ApplicationDescriptor.class);
-        ApplicationDescription applicationDescription =
-                DescriptorUtil.createApplicationDescription(applicationDescriptor);
-        return applicationDescription;
-    }
-
-    public Map<String, ApplicationDescription> getApplicationDescriptors(String serviceName) {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCS_SERVICE);
-        Map<String, ApplicationDescription> applicationDeploymentDescriptionMap = new HashMap<String, ApplicationDescription>();
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("serviceName", serviceName);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_NO_CONTENT) {
-                return applicationDeploymentDescriptionMap;
-            }
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_NO_CONTENT) {
-            return applicationDeploymentDescriptionMap;
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        ApplicationDescriptorList applicationDescriptorList =
-                response.getEntity(ApplicationDescriptorList.class);
-        ApplicationDescriptor[] applicationDescriptors =
-                applicationDescriptorList.getApplicationDescriptors();
-
-        for (ApplicationDescriptor applicationDescriptor : applicationDescriptors) {
-            ApplicationDescription applicationDescription =
-                    DescriptorUtil.createApplicationDescription(applicationDescriptor);
-            applicationDeploymentDescriptionMap.put(
-                    applicationDescriptor.getHostdescName(), applicationDescription);
-        }
-        return applicationDeploymentDescriptionMap;
-    }
-
-    public Map<String[], ApplicationDescription> getApplicationDescriptors() {
-        Map<String[], ApplicationDescription> applicationDeploymentDescriptionMap = new HashMap<String[], ApplicationDescription>();
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCRIPTORS);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_NO_CONTENT) {
-                return null;
-            }
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_NO_CONTENT) {
-            return null;
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        ApplicationDescriptorList applicationDescriptorList =
-                response.getEntity(ApplicationDescriptorList.class);
-        ApplicationDescriptor[] applicationDescriptors =
-                applicationDescriptorList.getApplicationDescriptors();
-        for (ApplicationDescriptor applicationDescriptor : applicationDescriptors) {
-            ApplicationDescription applicationDescription =
-                    DescriptorUtil.createApplicationDescription(applicationDescriptor);
-            String[] descriptors =
-                    {applicationDescriptor.getServiceDescriptor().getServiceName(),
-                            applicationDescriptor.getHostdescName()};
-            applicationDeploymentDescriptionMap.put(descriptors, applicationDescription);
-        }
-        return applicationDeploymentDescriptionMap;
-    }
-
-    public List<String> getApplicationDescriptorNames() {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.APP_DESC_NAMES);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_NO_CONTENT) {
-                return new ArrayList<String>();
-            }
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_NO_CONTENT) {
-            return new ArrayList<String>();
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        DescriptorNameList descriptorNameList = response.getEntity(DescriptorNameList.class);
-        return descriptorNameList.getDescriptorNames();
-    }
-
-    public void removeApplicationDescriptor(String serviceName,
-                                            String hostName,
-                                            String applicationName) {
-        webResource = getDescriptorRegistryBaseResource().path(
-                ResourcePathConstants.DecResourcePathConstants.APP_DESC_DELETE);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("serviceName", serviceName);
-        queryParams.add("hostName", hostName);
-        queryParams.add("appName", applicationName);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.TEXT_PLAIN).delete(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(MediaType.TEXT_PLAIN).delete(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/0e2c10f5/modules/rest/client/src/main/java/org/apache/airavata/rest/client/ExperimentResourceClient.java
----------------------------------------------------------------------
diff --git a/modules/rest/client/src/main/java/org/apache/airavata/rest/client/ExperimentResourceClient.java b/modules/rest/client/src/main/java/org/apache/airavata/rest/client/ExperimentResourceClient.java
deleted file mode 100644
index 2c74f00..0000000
--- a/modules/rest/client/src/main/java/org/apache/airavata/rest/client/ExperimentResourceClient.java
+++ /dev/null
@@ -1,498 +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.rest.client;
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
-import org.apache.airavata.registry.api.AiravataExperiment;
-import org.apache.airavata.registry.api.PasswordCallback;
-import org.apache.airavata.rest.mappings.resourcemappings.ExperimentList;
-import org.apache.airavata.rest.mappings.utils.ResourcePathConstants;
-import org.apache.airavata.rest.utils.BasicAuthHeaderUtil;
-import org.apache.airavata.rest.utils.ClientConstant;
-import org.apache.airavata.rest.utils.CookieManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.core.Cookie;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriBuilder;
-import java.net.URI;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-public class ExperimentResourceClient {
-    private WebResource webResource;
-    private final static Logger logger = LoggerFactory.getLogger(ExperimentResourceClient.class);
-    private String userName;
-    private PasswordCallback callback;
-    private String baseURI;
-    private Cookie cookie;
-    private WebResource.Builder builder;
-    private String gateway;
-//    private CookieManager cookieManager = new CookieManager();
-
-    public ExperimentResourceClient(String userName,
-                                    String gateway,
-                                    String serviceURI,
-                                    PasswordCallback callback,
-                                    Cookie cookie) {
-        this.userName = userName;
-        this.callback = callback;
-        this.baseURI = serviceURI;
-        this.gateway = gateway;
-        this.cookie = cookie;
-    }
-
-    private URI getBaseURI() {
-        logger.debug("Creating Base URI");
-        return UriBuilder.fromUri(baseURI).build();
-    }
-
-    private WebResource getExperimentRegistryBaseResource() {
-        ClientConfig config = new DefaultClientConfig();
-        config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
-                Boolean.TRUE);
-        Client client = Client.create(config);
-        WebResource baseWebResource = client.resource(getBaseURI());
-        webResource = baseWebResource.path(
-                ResourcePathConstants.ExperimentResourcePathConstants.EXP_RESOURCE_PATH);
-        return webResource;
-    }
-
-    public void addExperiment(String projectName, AiravataExperiment experiment) {
-        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        String date = dateFormat.format(experiment.getSubmittedDate());
-        webResource = getExperimentRegistryBaseResource().path(
-                ResourcePathConstants.ExperimentResourcePathConstants.ADD_EXP);
-        MultivaluedMap formParams = new MultivaluedMapImpl();
-        formParams.add("projectName", projectName);
-        formParams.add("experimentID", experiment.getExperimentId());
-        formParams.add("submittedDate", date);
-
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-        ClientResponse response = builder.accept(
-                MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(
-                    MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
-            status = response.getStatus();
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public void removeExperiment(String experimentId) {
-        webResource = getExperimentRegistryBaseResource().path(
-                ResourcePathConstants.ExperimentResourcePathConstants.DELETE_EXP);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("experimentId", experimentId);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-        ClientResponse response = builder.delete(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.delete(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public List<AiravataExperiment> getExperiments() {
-        List<AiravataExperiment> airavataExperiments = new ArrayList<AiravataExperiment>();
-        webResource = getExperimentRegistryBaseResource().path(
-                ResourcePathConstants.ExperimentResourcePathConstants.GET_ALL_EXPS);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, null, cookie, gateway);
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, null, cookie, gateway);
-            response = builder.accept(
-                    MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_NO_CONTENT) {
-                return airavataExperiments;
-            }
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_NO_CONTENT) {
-            return airavataExperiments;
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        ExperimentList experimentList = response.getEntity(ExperimentList.class);
-        AiravataExperiment[] experiments = experimentList.getExperiments();
-        for (AiravataExperiment airavataExperiment : experiments) {
-            airavataExperiments.add(airavataExperiment);
-        }
-        return airavataExperiments;
-    }
-
-    public List<AiravataExperiment> getExperiments(String projectName) {
-        webResource = getExperimentRegistryBaseResource().path(
-                ResourcePathConstants.ExperimentResourcePathConstants.GET_EXPS_BY_PROJECT);
-        List<AiravataExperiment> airavataExperiments = new ArrayList<AiravataExperiment>();
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("projectName", projectName);
-
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_NO_CONTENT) {
-                return airavataExperiments;
-            }
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_NO_CONTENT) {
-            return airavataExperiments;
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        ExperimentList experimentList = response.getEntity(ExperimentList.class);
-        AiravataExperiment[] experiments = experimentList.getExperiments();
-
-        for (AiravataExperiment airavataExperiment : experiments) {
-            airavataExperiments.add(airavataExperiment);
-        }
-        return airavataExperiments;
-    }
-
-    public List<AiravataExperiment> getExperiments(Date from, Date to) {
-        List<AiravataExperiment> airavataExperiments = new ArrayList<AiravataExperiment>();
-        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        String fromDate = dateFormat.format(from);
-        String toDate = dateFormat.format(to);
-        webResource = getExperimentRegistryBaseResource().path(
-                ResourcePathConstants.ExperimentResourcePathConstants.GET_EXPS_BY_DATE);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("fromDate", fromDate);
-        queryParams.add("toDate", toDate);
-
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-            if (status == ClientConstant.HTTP_NO_CONTENT) {
-                return airavataExperiments;
-            }
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else if (status == ClientConstant.HTTP_NO_CONTENT) {
-                return airavataExperiments;
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        ExperimentList experimentList = response.getEntity(ExperimentList.class);
-        AiravataExperiment[] experiments = experimentList.getExperiments();
-
-        for (AiravataExperiment airavataExperiment : experiments) {
-            airavataExperiments.add(airavataExperiment);
-        }
-        return airavataExperiments;
-    }
-
-    public List<AiravataExperiment> getExperiments(String projectName, Date from, Date to) {
-        List<AiravataExperiment> airavataExperiments = new ArrayList<AiravataExperiment>();
-        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        String fromDate = dateFormat.format(from);
-        String toDate = dateFormat.format(to);
-        webResource = getExperimentRegistryBaseResource().path(
-                ResourcePathConstants.ExperimentResourcePathConstants.GET_EXPS_PER_PROJECT_BY_DATE);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("projectName", projectName);
-        queryParams.add("fromDate", fromDate);
-        queryParams.add("toDate", toDate);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-
-        ClientResponse response = builder.accept(
-                MediaType.APPLICATION_JSON).get(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            status = response.getStatus();
-
-            if (status == ClientConstant.HTTP_NO_CONTENT) {
-                return airavataExperiments;
-            }
-
-            if (status != ClientConstant.HTTP_OK) {
-                logger.error(response.getEntity(String.class));
-                throw new RuntimeException("Failed : HTTP error code : "
-                        + status);
-            } else {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-        } else if (status == ClientConstant.HTTP_NO_CONTENT) {
-            return airavataExperiments;
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-
-        ExperimentList experimentList = response.getEntity(ExperimentList.class);
-        AiravataExperiment[] experiments = experimentList.getExperiments();
-
-
-        for (AiravataExperiment airavataExperiment : experiments) {
-            airavataExperiments.add(airavataExperiment);
-        }
-        return airavataExperiments;
-    }
-
-    public boolean isExperimentExists(String experimentId) {
-        webResource = getExperimentRegistryBaseResource().path(
-                ResourcePathConstants.ExperimentResourcePathConstants.EXP_EXISTS);
-        MultivaluedMap queryParams = new MultivaluedMapImpl();
-        queryParams.add("experimentId", experimentId);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, queryParams, userName, null, cookie, gateway);
-        ClientResponse response = builder.get(ClientResponse.class);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-            String exists = response.getEntity(String.class);
-            if (exists.equals("True")) {
-                return true;
-            } else {
-                return false;
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
-            response = builder.get(ClientResponse.class);
-            status = response.getStatus();
-            if (status == ClientConstant.HTTP_OK) {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-            String exists = response.getEntity(String.class);
-            if (exists.equals("True")) {
-                return true;
-            } else {
-                return false;
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-    public boolean isExperimentExists(String experimentId, boolean createIfNotPresent) {
-        String createStatus = "false";
-        webResource = getExperimentRegistryBaseResource().path(
-                ResourcePathConstants.ExperimentResourcePathConstants.EXP_EXISTS_CREATE);
-        if (createIfNotPresent) {
-            createStatus = "true";
-        }
-        MultivaluedMap formParams = new MultivaluedMapImpl();
-        formParams.add("experimentId", experimentId);
-        formParams.add("createIfNotPresent", createStatus);
-        builder = BasicAuthHeaderUtil.getBuilder(
-                webResource, null, userName, callback.getPassword(userName), null, gateway);
-        ClientResponse response = builder.accept(
-                MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
-        int status = response.getStatus();
-
-        if (status == ClientConstant.HTTP_OK) {
-            if (response.getCookies().size() > 0) {
-                cookie = response.getCookies().get(0).toCookie();
-                CookieManager.setCookie(cookie);
-            }
-            String exists = response.getEntity(String.class);
-            if (exists.equals("True")) {
-                return true;
-            } else {
-                return false;
-            }
-        } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            builder = BasicAuthHeaderUtil.getBuilder(
-                    webResource, null, userName, null, cookie, gateway);
-            response = builder.accept(
-                    MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
-            status = response.getStatus();
-            if (status == ClientConstant.HTTP_OK) {
-                if (response.getCookies().size() > 0) {
-                    cookie = response.getCookies().get(0).toCookie();
-                    CookieManager.setCookie(cookie);
-                }
-            }
-            String exists = response.getEntity(String.class);
-            if (exists.equals("True")) {
-                return true;
-            } else {
-                return false;
-            }
-        } else {
-            logger.error(response.getEntity(String.class));
-            throw new RuntimeException("Failed : HTTP error code : "
-                    + status);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/0e2c10f5/modules/rest/client/src/main/java/org/apache/airavata/rest/client/PasswordCallbackImpl.java
----------------------------------------------------------------------
diff --git a/modules/rest/client/src/main/java/org/apache/airavata/rest/client/PasswordCallbackImpl.java b/modules/rest/client/src/main/java/org/apache/airavata/rest/client/PasswordCallbackImpl.java
deleted file mode 100644
index 8c2c8d1..0000000
--- a/modules/rest/client/src/main/java/org/apache/airavata/rest/client/PasswordCallbackImpl.java
+++ /dev/null
@@ -1,40 +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.rest.client;
-
-import org.apache.airavata.registry.api.PasswordCallback;
-
-public class PasswordCallbackImpl implements PasswordCallback {
-
-    private String username;
-    private String password;
-
-    public PasswordCallbackImpl(String password, String username) {
-        this.password = password;
-        this.username = username;
-    }
-
-    @Override
-    public String getPassword(String username) {
-        return password;
-    }
-}