airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject svn commit: r1424180 [1/5] - in /airavata/trunk/modules/rest: client/src/main/java/org/apache/airavata/rest/ client/src/main/java/org/apache/airavata/rest/client/ client/src/main/java/org/apache/airavata/rest/utils/ webapp/src/main/webapp/WEB-INF/
Date Wed, 19 Dec 2012 22:35:19 GMT
Author: chathuri
Date: Wed Dec 19 22:35:18 2012
New Revision: 1424180

URL: http://svn.apache.org/viewvc?rev=1424180&view=rev
Log:
adding gateway to request

Modified:
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/ConfigurationResourceClient.java
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/ExperimentResourceClient.java
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/ProjectResourceClient.java
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/ProvenanceResourceClient.java
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/PublishedWorkflowResourceClient.java
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/RegistryClient.java
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/UserWorkflowResourceClient.java
    airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/utils/BasicAuthHeaderUtil.java
    airavata/trunk/modules/rest/webapp/src/main/webapp/WEB-INF/web.xml

Modified: airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java?rev=1424180&r1=1424179&r2=1424180&view=diff
==============================================================================
--- airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java (original)
+++ airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/Test.java Wed Dec 19 22:35:18 2012
@@ -43,8 +43,8 @@ public class Test {
 
     public static void configurationResourceClientTest(){
         //configuration resource test
-        ConfigurationResourceClient configurationResourceClient = new ConfigurationResourceClient("admin",
-                "http://localhost:8080/airavata-registry/", new PasswordCallbackImpl("admin", "admin"));
+//        ConfigurationResourceClient configurationResourceClient = new ConfigurationResourceClient("admin",
+//                "http://localhost:8080/airavata-registry/", new PasswordCallbackImpl("admin", "admin"));
 
 //        System.out.println("###############getConfiguration###############");
 //        Object configuration = configurationResourceClient.getConfiguration("gfac.url");
@@ -56,11 +56,11 @@ public class Test {
 //        System.out.println(configuration.toString());
 //
 //        System.out.println("###############getConfigurationList###############");
-        try {
-            configurationResourceClient.addWFInterpreterURI(new URI("http://192.168.17.1:8080/axis2/services/WorkflowInterpretor2"));
-        } catch (URISyntaxException e) {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        }
+//        try {
+//            configurationResourceClient.addWFInterpreterURI(new URI("http://192.168.17.1:8080/axis2/services/WorkflowInterpretor2"));
+//        } catch (URISyntaxException e) {
+//            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+//        }
 //        List<Object> configurationList = configurationResourceClient.getConfigurationList("testKey1");
 //        for(Object object : configurationList){
 //            System.out.println(object.toString());
@@ -169,11 +169,11 @@ public class Test {
 
     public static void serviceDescriptorClientTest (){
 
-        DescriptorResourceClient descriptorResourceClient = new DescriptorResourceClient("admin",
-                "http://localhost:9080/airavata-services/api", new PasswordCallbackImpl("admin", "admin"));
-        //service descriptor exists
-        boolean exists = descriptorResourceClient.isServiceDescriptorExists("echo");
-        System.out.println(exists);
+//        DescriptorResourceClient descriptorResourceClient = new DescriptorResourceClient("admin",
+//                "http://localhost:9080/airavata-services/api", new PasswordCallbackImpl("admin", "admin"));
+//        //service descriptor exists
+//        boolean exists = descriptorResourceClient.isServiceDescriptorExists("echo");
+//        System.out.println(exists);
 
         //service descriptor save
 //        ServiceDescription serviceDescription = new ServiceDescription();

Modified: airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java?rev=1424180&r1=1424179&r2=1424180&view=diff
==============================================================================
--- airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java (original)
+++ airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/BasicRegistryResourceClient.java Wed Dec 19 22:35:18 2012
@@ -58,23 +58,28 @@ public class BasicRegistryResourceClient
     private String baseURI;
     private Cookie cookie;
     private WebResource.Builder builder;
+    private String gatewayName;
 
     /**
      * Creates a BasicRegistryResourceClient
-     * @param userName registry user
+     *
+     * @param userName  registry user
      * @param seriveURI REST service URL
-     * @param callback implementation of the <code>PasswordCallback</code>
+     * @param callback  implementation of the <code>PasswordCallback</code>
      */
     public BasicRegistryResourceClient(String userName,
+                                       String gateway,
                                        String seriveURI,
                                        PasswordCallback callback) {
         this.userName = userName;
         this.callback = callback;
         this.baseURI = seriveURI;
+        this.gatewayName = gateway;
     }
 
     /**
      * Get base URL of the REST service
+     *
      * @return REST url
      */
     private URI getBaseURI() {
@@ -84,6 +89,7 @@ public class BasicRegistryResourceClient
 
     /**
      * Creating the web resource for base url
+     *
      * @return web resource related to the base url
      */
     private WebResource getBasicRegistryBaseResource() {
@@ -99,12 +105,16 @@ public class BasicRegistryResourceClient
 
     /**
      * Get gateway related to the instance
+     *
      * @return gateway
      */
     public Gateway getGateway() {
         webResource = getBasicRegistryBaseResource().path(
                 ResourcePathConstants.BasicRegistryConstants.GET_GATEWAY);
-        ClientResponse response = webResource.accept(
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gatewayName);
+
+        ClientResponse response = builder.accept(
                 MediaType.APPLICATION_JSON).get(ClientResponse.class);
         int status = response.getStatus();
 
@@ -113,22 +123,24 @@ public class BasicRegistryResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gatewayName);
+            response = builder.accept(MediaType.APPLICATION_JSON).get(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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
         return response.getEntity(Gateway.class);
@@ -136,12 +148,16 @@ public class BasicRegistryResourceClient
 
     /**
      * Get executing user for the instance
+     *
      * @return airavata user
      */
     public AiravataUser getUser() {
         webResource = getBasicRegistryBaseResource().path(
                 ResourcePathConstants.BasicRegistryConstants.GET_USER);
-        ClientResponse response = webResource.accept(
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gatewayName);
+
+        ClientResponse response = builder.accept(
                 MediaType.APPLICATION_JSON).get(ClientResponse.class);
         int status = response.getStatus();
 
@@ -150,22 +166,23 @@ public class BasicRegistryResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gatewayName);
+            response = builder.accept(MediaType.APPLICATION_JSON).get(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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
         return response.getEntity(AiravataUser.class);
@@ -173,12 +190,16 @@ public class BasicRegistryResourceClient
 
     /**
      * setting the gateway
+     *
      * @param gateway gateway
      */
     public void setGateway(Gateway gateway) {
         webResource = getBasicRegistryBaseResource().path(
                 ResourcePathConstants.BasicRegistryConstants.SET_GATEWAY);
-        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).type(
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gatewayName);
+
+        ClientResponse response = builder.accept(MediaType.TEXT_PLAIN).type(
                 MediaType.APPLICATION_JSON).post(ClientResponse.class, gateway);
         int status = response.getStatus();
 
@@ -187,37 +208,40 @@ public class BasicRegistryResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(MediaType.TEXT_PLAIN).type(
-                        MediaType.APPLICATION_JSON).post(ClientResponse.class, gateway);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.TEXT_PLAIN).type(
-                        MediaType.APPLICATION_JSON).post(ClientResponse.class, gateway);
-                cookie = response.getCookies().get(0).toCookie();
-            }
-
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gatewayName);
+            response = builder.accept(MediaType.TEXT_PLAIN).type(
+                    MediaType.APPLICATION_JSON).post(ClientResponse.class, gateway);
             status = response.getStatus();
 
             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 (status == ClientConstant.HTTP_OK) {
+                if(response.getCookies().size() > 0){
+                    cookie = response.getCookies().get(0).toCookie();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
 
     /**
      * Setting the airavata user
+     *
      * @param user airavata user
      */
     public void setUser(AiravataUser user) {
         webResource = getBasicRegistryBaseResource().path(
                 ResourcePathConstants.BasicRegistryConstants.SET_USER);
-        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).type(
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gatewayName);
+
+        ClientResponse response = builder.accept(MediaType.TEXT_PLAIN).type(
                 MediaType.APPLICATION_JSON).post(ClientResponse.class, user);
         int status = response.getStatus();
 
@@ -226,37 +250,40 @@ public class BasicRegistryResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(MediaType.TEXT_PLAIN).type(
-                        MediaType.APPLICATION_JSON).post(ClientResponse.class, user);
-                status = response.getStatus();
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.TEXT_PLAIN).type(
-                        MediaType.APPLICATION_JSON).post(ClientResponse.class, user);
-                status = response.getStatus();
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gatewayName);
+            response = builder.accept(MediaType.TEXT_PLAIN).type(
+                    MediaType.APPLICATION_JSON).post(ClientResponse.class, user);
+            status = response.getStatus();
 
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
 
     /**
      * Get service API version
+     *
      * @return API version
      */
     public Version getVersion() {
         webResource = getBasicRegistryBaseResource().path(
                 ResourcePathConstants.BasicRegistryConstants.VERSION);
-        ClientResponse response = webResource.accept(
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gatewayName);
+
+        ClientResponse response = builder.accept(
                 MediaType.APPLICATION_JSON).get(ClientResponse.class);
         int status = response.getStatus();
 
@@ -265,22 +292,24 @@ public class BasicRegistryResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gatewayName);
+            response = builder.accept(MediaType.APPLICATION_JSON).get(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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
 
@@ -289,13 +318,17 @@ public class BasicRegistryResourceClient
 
     /**
      * Get registry REST service connection URL
+     *
      * @return service URL
      */
     public URI getConnectionURI() {
         try {
             webResource = getBasicRegistryBaseResource().path(
                     ResourcePathConstants.BasicRegistryConstants.GET_SERVICE_URL);
-            ClientResponse response = webResource.accept(
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, null, cookie, gatewayName);
+
+            ClientResponse response = builder.accept(
                     MediaType.TEXT_PLAIN).get(ClientResponse.class);
             int status = response.getStatus();
 
@@ -304,22 +337,24 @@ public class BasicRegistryResourceClient
                 throw new RuntimeException("Failed : HTTP error code : "
                         + status);
             } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-                if (cookie != null){
-                    builder = BasicAuthHeaderUtil.getBuilder(
-                            webResource, null, userName, callback.getPassword(userName), cookie);
-                    response = builder.accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
-                } else {
-                    builder = BasicAuthHeaderUtil.getBuilder(
-                            webResource, null, userName, callback.getPassword(userName), null);
-                    response = builder.accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
-                    cookie = response.getCookies().get(0).toCookie();
-                }
+                builder = BasicAuthHeaderUtil.getBuilder(
+                        webResource, null, userName, callback.getPassword(userName), null, gatewayName);
+                response = builder.accept(MediaType.TEXT_PLAIN).get(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();
+                    }
+                }
+            } else {
+                if(response.getCookies().size() > 0){
+                    cookie = response.getCookies().get(0).toCookie();
                 }
             }
             String uri = response.getEntity(String.class);
@@ -332,6 +367,7 @@ public class BasicRegistryResourceClient
 
     /**
      * set service connection URL
+     *
      * @param connectionURI service connection URL
      */
     public void setConnectionURI(URI connectionURI) {
@@ -339,7 +375,10 @@ public class BasicRegistryResourceClient
                 ResourcePathConstants.BasicRegistryConstants.SET_SERVICE_URL);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("connectionurl", connectionURI.toString());
-        ClientResponse response = webResource.type(
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gatewayName);
+
+        ClientResponse response = builder.type(
                 MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
         int status = response.getStatus();
 
@@ -348,22 +387,24 @@ public class BasicRegistryResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.type(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.type(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gatewayName);
+            response = builder.type(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
+
             status = response.getStatus();
 
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }

Modified: airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/ConfigurationResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/ConfigurationResourceClient.java?rev=1424180&r1=1424179&r2=1424180&view=diff
==============================================================================
--- airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/ConfigurationResourceClient.java (original)
+++ airavata/trunk/modules/rest/client/src/main/java/org/apache/airavata/rest/client/ConfigurationResourceClient.java Wed Dec 19 22:35:18 2012
@@ -55,11 +55,13 @@ public class ConfigurationResourceClient
     private Cookie cookie;
     private WebResource.Builder builder;
     private ClientResponse response;
+    private String gateway;
 
-    public ConfigurationResourceClient(String userName, String seriveURI, PasswordCallback callback) {
+    public ConfigurationResourceClient(String userName, String gateway, String seriveURI, PasswordCallback callback) {
         this.userName = userName;
         this.callback = callback;
         this.baseURI = seriveURI;
+        this.gateway = gateway;
     }
 
     private URI getBaseURI() {
@@ -84,28 +86,26 @@ public class ConfigurationResourceClient
                 ResourcePathConstants.ConfigResourcePathConstants.GET_CONFIGURATION);
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("key", configKey);
-        response = webResource.queryParams(queryParams).get(ClientResponse.class);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, queryParams, userName, null, cookie, gateway);
+
+        response = builder.get(ClientResponse.class);
         int status = response.getStatus();
 
-        if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
+        if (status != ClientConstant.HTTP_OK &&
+                status != ClientConstant.HTTP_UNAUTHORIZED &&
+                status != ClientConstant.HTTP_NO_CONTENT) {
             logger.error(response.getEntity(String.class));
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (null != cookie){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, queryParams,userName, callback.getPassword(userName), cookie);
-                response = builder.get(ClientResponse.class);
-            }else{
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, queryParams,userName, callback.getPassword(userName), null);
-                response = builder.get(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
+            response = builder.get(ClientResponse.class);
 
             status = response.getStatus();
 
-            if(status == ClientConstant.HTTP_NO_CONTENT){
+            if (status == ClientConstant.HTTP_NO_CONTENT) {
                 return null;
             }
 
@@ -113,6 +113,14 @@ public class ConfigurationResourceClient
                 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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
         String output = response.getEntity(String.class);
@@ -125,37 +133,43 @@ public class ConfigurationResourceClient
                 ResourcePathConstants.ConfigResourcePathConstants.GET_CONFIGURATION_LIST);
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("key", configKey);
-        response = webResource.queryParams(queryParams).accept(
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, queryParams, userName, null, cookie, gateway);
+
+        response = builder.accept(
                 MediaType.APPLICATION_JSON).get(ClientResponse.class);
         int status = response.getStatus();
 
-        if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
+        if (status != ClientConstant.HTTP_OK &&
+                status != ClientConstant.HTTP_UNAUTHORIZED &&
+                status != ClientConstant.HTTP_NO_CONTENT ) {
             logger.error(response.getEntity(String.class));
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, queryParams,userName, callback.getPassword(userName), cookie);
-                response = webResource.queryParams(queryParams).accept(
-                        MediaType.APPLICATION_JSON).get(ClientResponse.class);
-            }else{
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, queryParams, userName, callback.getPassword(userName), null);
-                response = webResource.queryParams(queryParams).accept(
-                        MediaType.APPLICATION_JSON).get(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
+            response = webResource.queryParams(queryParams).accept(
+                    MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
 
             status = response.getStatus();
 
-            if(status == ClientConstant.HTTP_NO_CONTENT){
+            if (status == ClientConstant.HTTP_NO_CONTENT) {
                 return configurationValueList;
             }
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
         ConfigurationList configurationList = response.getEntity(ConfigurationList.class);
@@ -176,8 +190,10 @@ public class ConfigurationResourceClient
         formData.add("key", configKey);
         formData.add("value", configVal);
         formData.add("date", formattedDate);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gateway);
 
-        response = webResource.type(MediaType.APPLICATION_FORM_URLENCODED).post(
+        response = builder.type(MediaType.APPLICATION_FORM_URLENCODED).post(
                 ClientResponse.class, formData);
         int status = response.getStatus();
 
@@ -186,18 +202,10 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder =  BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName,callback.getPassword(userName), cookie);
-                response = builder.type(MediaType.APPLICATION_FORM_URLENCODED).post(
-                        ClientResponse.class, formData);
-            } else {
-                builder =  BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.type(MediaType.APPLICATION_FORM_URLENCODED).post(
-                        ClientResponse.class, formData);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gateway);
+            response = builder.type(MediaType.APPLICATION_FORM_URLENCODED).post(
+                    ClientResponse.class, formData);
 
             status = response.getStatus();
 
@@ -205,6 +213,14 @@ public class ConfigurationResourceClient
                 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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -218,8 +234,10 @@ public class ConfigurationResourceClient
         formData.add("key", configKey);
         formData.add("value", configVal);
         formData.add("date", formattedDate);
+        builder = BasicAuthHeaderUtil.getBuilder(webResource, null,
+                userName, null, cookie, gateway);
 
-        response = webResource.type(MediaType.APPLICATION_FORM_URLENCODED).
+        response = builder.type(MediaType.APPLICATION_FORM_URLENCODED).
                 post(ClientResponse.class, formData);
         int status = response.getStatus();
 
@@ -228,24 +246,24 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null,userName, callback.getPassword(userName), cookie);
-                response = builder.type(MediaType.APPLICATION_FORM_URLENCODED).
-                        post(ClientResponse.class, formData);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(webResource, null,
-                        userName, callback.getPassword(userName), null);
-                response = builder.type(MediaType.APPLICATION_FORM_URLENCODED).
-                        post(ClientResponse.class, formData);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(webResource, null,
+                    userName, callback.getPassword(userName), null, gateway);
+            response = builder.type(MediaType.APPLICATION_FORM_URLENCODED).
+                    post(ClientResponse.class, formData);
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -255,7 +273,10 @@ public class ConfigurationResourceClient
                 ConfigResourcePathConstants.DELETE_ALL_CONFIGURATION);
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("key", key);
-        response = webResource.queryParams(queryParams).delete(ClientResponse.class);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, queryParams, userName, null, cookie, gateway);
+
+        response = builder.delete(ClientResponse.class);
         int status = response.getStatus();
 
         if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
@@ -263,22 +284,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, queryParams, userName,callback.getPassword(userName), cookie);
-                response = builder.delete(ClientResponse.class);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, queryParams, userName,callback.getPassword(userName), null);
-                response = builder.delete(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
 
@@ -290,7 +312,10 @@ public class ConfigurationResourceClient
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("key", key);
         queryParams.add("value", value);
-        response = webResource.queryParams(queryParams).delete(ClientResponse.class);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, queryParams, userName, null, cookie, gateway);
+
+        response = builder.delete(ClientResponse.class);
         int status = response.getStatus();
 
         if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
@@ -298,22 +323,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, queryParams, userName,callback.getPassword(userName), cookie);
-                response = builder.delete(ClientResponse.class);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, queryParams, userName,callback.getPassword(userName), null);
-                response = builder.delete(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -323,27 +349,25 @@ public class ConfigurationResourceClient
         try {
             webResource = getConfigurationBaseResource().path(ResourcePathConstants.
                     ConfigResourcePathConstants.GET_GFAC_URI_LIST);
-            response = webResource.get(ClientResponse.class);
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, null, cookie, gateway);
+
+            response = builder.get(ClientResponse.class);
             int status = response.getStatus();
 
-            if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
+            if (status != ClientConstant.HTTP_OK &&
+                    status != ClientConstant.HTTP_UNAUTHORIZED &&
+                    status != ClientConstant.HTTP_NO_CONTENT) {
                 logger.error(response.getEntity(String.class));
                 throw new RuntimeException("Failed : HTTP error code : "
                         + status);
             } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-                if (cookie != null){
-                    builder = BasicAuthHeaderUtil.getBuilder(
-                            webResource, null, userName,callback.getPassword(userName), cookie);
-                    response = builder.get(ClientResponse.class);
-                } else {
-                    builder = BasicAuthHeaderUtil.getBuilder(
-                            webResource, null, userName,callback.getPassword(userName), null);
-                    response = builder.get(ClientResponse.class);
-                    cookie = response.getCookies().get(0).toCookie();
-                }
+                builder = BasicAuthHeaderUtil.getBuilder(
+                        webResource, null, userName, callback.getPassword(userName), null, gateway);
+                response = builder.get(ClientResponse.class);
                 status = response.getStatus();
 
-                if(status == ClientConstant.HTTP_NO_CONTENT){
+                if (status == ClientConstant.HTTP_NO_CONTENT) {
                     return uriList;
                 }
 
@@ -351,6 +375,14 @@ public class ConfigurationResourceClient
                     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();
+                    }
+                }
+            } else {
+                if(response.getCookies().size() > 0){
+                    cookie = response.getCookies().get(0).toCookie();
                 }
             }
 
@@ -372,27 +404,25 @@ public class ConfigurationResourceClient
         try {
             webResource = getConfigurationBaseResource().path(ResourcePathConstants.
                     ConfigResourcePathConstants.GET_WFINTERPRETER_URI_LIST);
-            response = webResource.get(ClientResponse.class);
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, null, cookie, gateway);
+
+            response = builder.get(ClientResponse.class);
             int status = response.getStatus();
 
-            if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
+            if (status != ClientConstant.HTTP_OK &&
+                    status != ClientConstant.HTTP_UNAUTHORIZED &&
+                    status != ClientConstant.HTTP_NO_CONTENT) {
                 logger.error(response.getEntity(String.class));
                 throw new RuntimeException("Failed : HTTP error code : "
                         + status);
             } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-                if (cookie != null){
-                    builder = BasicAuthHeaderUtil.getBuilder(
-                            webResource, null, userName,callback.getPassword(userName), cookie);
-                    response = builder.get(ClientResponse.class);
-                } else {
-                    builder = BasicAuthHeaderUtil.getBuilder(
-                            webResource, null, userName,callback.getPassword(userName), null);
-                    response = builder.get(ClientResponse.class);
-                    cookie = response.getCookies().get(0).toCookie();
-                }
+                builder = BasicAuthHeaderUtil.getBuilder(
+                        webResource, null, userName, callback.getPassword(userName), null, gateway);
+                response = builder.get(ClientResponse.class);
                 status = response.getStatus();
 
-                if(status == ClientConstant.HTTP_NO_CONTENT){
+                if (status == ClientConstant.HTTP_NO_CONTENT) {
                     return uriList;
                 }
 
@@ -400,6 +430,14 @@ public class ConfigurationResourceClient
                     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();
+                    }
+                }
+            } else {
+                if(response.getCookies().size() > 0){
+                    cookie = response.getCookies().get(0).toCookie();
                 }
             }
             URLList urlList = response.getEntity(URLList.class);
@@ -419,27 +457,25 @@ public class ConfigurationResourceClient
         try {
             webResource = getConfigurationBaseResource().path(ResourcePathConstants.
                     ConfigResourcePathConstants.GET_EVENTING_URI);
-            response = webResource.get(ClientResponse.class);
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, null, cookie, gateway);
+
+            response = builder.get(ClientResponse.class);
             int status = response.getStatus();
 
-            if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
+            if (status != ClientConstant.HTTP_OK &&
+                    status != ClientConstant.HTTP_UNAUTHORIZED &&
+                    status != ClientConstant.HTTP_NO_CONTENT) {
                 logger.error(response.getEntity(String.class));
                 throw new RuntimeException("Failed : HTTP error code : "
                         + status);
             } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-                if (cookie != null){
-                    builder = BasicAuthHeaderUtil.getBuilder(
-                            webResource, null, userName,callback.getPassword(userName), cookie);
-                    response = builder.get(ClientResponse.class);
-                } else {
-                    builder = BasicAuthHeaderUtil.getBuilder(
-                            webResource, null, userName, callback.getPassword(userName), null);
-                    response = builder.get(ClientResponse.class);
-                    cookie = response.getCookies().get(0).toCookie();
-                }
+                builder = BasicAuthHeaderUtil.getBuilder(
+                        webResource, null, userName, callback.getPassword(userName), null, gateway);
+                response = builder.get(ClientResponse.class);
                 status = response.getStatus();
 
-                if(status == ClientConstant.HTTP_NO_CONTENT){
+                if (status == ClientConstant.HTTP_NO_CONTENT) {
                     return null;
                 }
 
@@ -447,6 +483,14 @@ public class ConfigurationResourceClient
                     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();
+                    }
+                }
+            } else {
+                if(response.getCookies().size() > 0){
+                    cookie = response.getCookies().get(0).toCookie();
                 }
             }
 
@@ -462,27 +506,25 @@ public class ConfigurationResourceClient
         try {
             webResource = getConfigurationBaseResource().path(ResourcePathConstants.
                     ConfigResourcePathConstants.GET_MESSAGE_BOX_URI);
-            response = webResource.get(ClientResponse.class);
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, null, cookie, gateway);
+
+            response = builder.get(ClientResponse.class);
             int status = response.getStatus();
 
-            if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
+            if (status != ClientConstant.HTTP_OK &&
+                    status != ClientConstant.HTTP_UNAUTHORIZED &&
+                    status != ClientConstant.HTTP_NO_CONTENT) {
                 logger.error(response.getEntity(String.class));
                 throw new RuntimeException("Failed : HTTP error code : "
                         + status);
             } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-                if (cookie != null){
-                    builder = BasicAuthHeaderUtil.getBuilder(
-                            webResource, null, userName,callback.getPassword(userName), cookie);
-                    response = builder.get(ClientResponse.class);
-                } else {
-                    builder = BasicAuthHeaderUtil.getBuilder(
-                            webResource, null, userName,callback.getPassword(userName), null);
-                    response = builder.get(ClientResponse.class);
-                    cookie = response.getCookies().get(0).toCookie();
-                }
+                builder = BasicAuthHeaderUtil.getBuilder(
+                        webResource, null, userName, callback.getPassword(userName), null, gateway);
+                response = builder.get(ClientResponse.class);
                 status = response.getStatus();
 
-                if(status == ClientConstant.HTTP_NO_CONTENT){
+                if (status == ClientConstant.HTTP_NO_CONTENT) {
                     return null;
                 }
 
@@ -490,7 +532,18 @@ public class ConfigurationResourceClient
                     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();
+                    }
+                }
+            } else {
+                if(response.getCookies().size() > 0){
+                    if(response.getCookies().size() > 0){
+                        cookie = response.getCookies().get(0).toCookie();
+                    }
                 }
+
             }
 
             String uri = response.getEntity(String.class);
@@ -506,8 +559,10 @@ public class ConfigurationResourceClient
                 ConfigResourcePathConstants.ADD_GFAC_URI);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri.toString());
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gateway);
 
-        response = webResource.accept(MediaType.TEXT_PLAIN).
+        response = builder.accept(MediaType.TEXT_PLAIN).
                 post(ClientResponse.class, formData);
         int status = response.getStatus();
 
@@ -516,22 +571,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gateway);
+            response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -541,8 +597,10 @@ public class ConfigurationResourceClient
                 ResourcePathConstants.ConfigResourcePathConstants.ADD_WFINTERPRETER_URI);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri.toString());
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, callback.getPassword(userName), null, gateway);
 
-        response = webResource.accept(MediaType.TEXT_PLAIN).post(
+        response = builder.accept(MediaType.TEXT_PLAIN).post(
                 ClientResponse.class, formData);
         int status = response.getStatus();
 
@@ -551,23 +609,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(
-                        ClientResponse.class, formData);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gateway);
+            response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -577,8 +635,10 @@ public class ConfigurationResourceClient
                 ResourcePathConstants.ConfigResourcePathConstants.ADD_EVENTING_URI);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri.toString());
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gateway);
 
-        response = webResource.accept(
+        response = builder.accept(
                 MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
         int status = response.getStatus();
 
@@ -587,23 +647,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(
-                        MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gateway);
+            response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -613,8 +673,10 @@ public class ConfigurationResourceClient
                 ResourcePathConstants.ConfigResourcePathConstants.ADD_MESSAGE_BOX_URI);
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri.toString());
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gateway);
 
-        response = webResource.accept(
+        response = builder.accept(
                 MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
         int status = response.getStatus();
 
@@ -623,22 +685,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder =BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-            } else {
-                builder =BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gateway);
+            response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -651,8 +714,10 @@ public class ConfigurationResourceClient
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri.toString());
         formData.add("date", formattedDate);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gateway);
 
-        response = webResource.accept(
+        response = builder.accept(
                 MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
         int status = response.getStatus();
 
@@ -661,22 +726,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder  = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-            } else {
-                builder  = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gateway);
+            response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -689,8 +755,10 @@ public class ConfigurationResourceClient
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri.toString());
         formData.add("date", formattedDate);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gateway);
 
-        response = webResource.accept(
+        response = builder.accept(
                 MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
         int status = response.getStatus();
 
@@ -699,22 +767,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder =BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-            } else {
-                builder =BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gateway);
+            response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -727,8 +796,10 @@ public class ConfigurationResourceClient
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri.toString());
         formData.add("date", formattedDate);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gateway);
 
-        response = webResource.accept(
+        response = builder.accept(
                 MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
         int status = response.getStatus();
 
@@ -737,22 +808,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gateway);
+            response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -765,8 +837,10 @@ public class ConfigurationResourceClient
         MultivaluedMap formData = new MultivaluedMapImpl();
         formData.add("uri", uri.toString());
         formData.add("date", formattedDate);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gateway);
 
-        response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
+        response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
         int status = response.getStatus();
 
         if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
@@ -774,22 +848,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, userName, callback.getPassword(userName), null, gateway);
+            response = builder.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formData);
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -799,7 +874,10 @@ public class ConfigurationResourceClient
                 ResourcePathConstants.ConfigResourcePathConstants.DELETE_GFAC_URI);
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("uri", uri.toString());
-        response = webResource.queryParams(queryParams).delete(ClientResponse.class);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, queryParams, userName, null, cookie, gateway);
+
+        response = builder.delete(ClientResponse.class);
         int status = response.getStatus();
 
         if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
@@ -807,22 +885,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, queryParams, userName, callback.getPassword(userName), cookie);
-                response = builder.delete(ClientResponse.class);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, queryParams, userName, callback.getPassword(userName), null);
-                response = builder.delete(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -830,7 +909,10 @@ public class ConfigurationResourceClient
     public void removeAllGFacURI() {
         webResource = getConfigurationBaseResource().path(
                 ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_GFAC_URIS);
-        response = webResource.delete(ClientResponse.class);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gateway);
+
+        response = builder.delete(ClientResponse.class);
         int status = response.getStatus();
 
         if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
@@ -838,22 +920,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if(cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.delete(ClientResponse.class);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.delete(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, 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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -863,7 +946,10 @@ public class ConfigurationResourceClient
                 ResourcePathConstants.ConfigResourcePathConstants.DELETE_WFINTERPRETER_URI);
         MultivaluedMap queryParams = new MultivaluedMapImpl();
         queryParams.add("uri", uri.toString());
-        response = webResource.queryParams(queryParams).delete(ClientResponse.class);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, queryParams, userName, null, cookie, gateway);
+
+        response = builder.delete(ClientResponse.class);
         int status = response.getStatus();
 
         if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
@@ -871,22 +957,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder =BasicAuthHeaderUtil.getBuilder(
-                        webResource, queryParams, userName, callback.getPassword(userName), cookie);
-                response = builder.delete(ClientResponse.class);
-            } else {
-                builder =BasicAuthHeaderUtil.getBuilder(
-                        webResource, queryParams, userName, callback.getPassword(userName), null);
-                response = builder.delete(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, queryParams, userName, callback.getPassword(userName), null, gateway);
+            response = builder.delete(ClientResponse.class);
             status = response.getStatus();
 
             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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -894,7 +981,10 @@ public class ConfigurationResourceClient
     public void removeAllWorkflowInterpreterURI() {
         webResource = getConfigurationBaseResource().path(
                 ResourcePathConstants.ConfigResourcePathConstants.DELETE_ALL_WFINTERPRETER_URIS);
-        response = webResource.delete(ClientResponse.class);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gateway);
+
+        response = builder.delete(ClientResponse.class);
         int status = response.getStatus();
 
         if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
@@ -902,22 +992,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder =BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.delete(ClientResponse.class);
-            } else {
-                builder =BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.delete(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, 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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -925,7 +1016,10 @@ public class ConfigurationResourceClient
     public void unsetEventingURI() {
         webResource = getConfigurationBaseResource().path(
                 ResourcePathConstants.ConfigResourcePathConstants.DELETE_EVENTING_URI);
-        response = webResource.delete(ClientResponse.class);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gateway);
+
+        response = builder.delete(ClientResponse.class);
         int status = response.getStatus();
 
         if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
@@ -933,22 +1027,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.delete(ClientResponse.class);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.delete(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, 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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }
@@ -956,7 +1051,10 @@ public class ConfigurationResourceClient
     public void unsetMessageBoxURI() {
         webResource = getConfigurationBaseResource().path(
                 ResourcePathConstants.ConfigResourcePathConstants.DELETE_MSG_BOX_URI);
-        response = webResource.delete(ClientResponse.class);
+        builder = BasicAuthHeaderUtil.getBuilder(
+                webResource, null, userName, null, cookie, gateway);
+
+        response = builder.delete(ClientResponse.class);
         int status = response.getStatus();
 
         if (status != ClientConstant.HTTP_OK && status != ClientConstant.HTTP_UNAUTHORIZED) {
@@ -964,22 +1062,23 @@ public class ConfigurationResourceClient
             throw new RuntimeException("Failed : HTTP error code : "
                     + status);
         } else if (status == ClientConstant.HTTP_UNAUTHORIZED) {
-            if (cookie != null){
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), cookie);
-                response = builder.delete(ClientResponse.class);
-            } else {
-                builder = BasicAuthHeaderUtil.getBuilder(
-                        webResource, null, userName, callback.getPassword(userName), null);
-                response = builder.delete(ClientResponse.class);
-                cookie = response.getCookies().get(0).toCookie();
-            }
+            builder = BasicAuthHeaderUtil.getBuilder(
+                    webResource, null, 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();
+                }
+            }
+        } else {
+            if(response.getCookies().size() > 0){
+                cookie = response.getCookies().get(0).toCookie();
             }
         }
     }



Mime
View raw message