cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sw...@apache.org
Subject [1/2] git commit: updated refs/heads/master to 688522e
Date Thu, 12 May 2016 15:12:02 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master c79affaef -> 688522ecd


CLOUDSTACK-9265 cleanup around httpclient versions

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/cb85b7e8
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/cb85b7e8
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/cb85b7e8

Branch: refs/heads/master
Commit: cb85b7e8beeedd338676fedead3249f27759fa40
Parents: e762e27
Author: Daan Hoogland <daan@onecht.net>
Authored: Sat Jan 30 00:15:24 2016 +0100
Committer: Daan Hoogland <daan@onecht.net>
Committed: Mon May 2 16:25:01 2016 +0200

----------------------------------------------------------------------
 .../cloudstack/storage/test/TestHttp.java       |  27 ++---
 .../ClusterServiceServletHttpHandler.java       |  56 ++++-----
 .../cloud/network/brocade/BrocadeVcsApi.java    | 117 +++++++++----------
 .../network/brocade/BrocadeVcsApiTest.java      |   6 +-
 .../cloud/network/nicira/NiciraNvpApiTest.java  |   2 +-
 5 files changed, 103 insertions(+), 105 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb85b7e8/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestHttp.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestHttp.java
b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestHttp.java
index b1524f3..43a2476 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestHttp.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TestHttp.java
@@ -24,11 +24,9 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 
-import junit.framework.Assert;
-
-import org.apache.commons.httpclient.HttpException;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
+import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpHead;
 import org.apache.http.impl.client.DefaultHttpClient;
@@ -37,13 +35,15 @@ import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
 import org.testng.annotations.Parameters;
 
+import junit.framework.Assert;
+
 @ContextConfiguration(locations = "classpath:/storageContext.xml")
 public class TestHttp extends AbstractTestNGSpringContextTests {
     @Test
     @Parameters("template-url")
     public void testHttpclient(String templateUrl) {
-        HttpHead method = new HttpHead(templateUrl);
-        DefaultHttpClient client = new DefaultHttpClient();
+        final HttpHead method = new HttpHead(templateUrl);
+        final DefaultHttpClient client = new DefaultHttpClient();
 
         OutputStream output = null;
         long length = 0;
@@ -51,34 +51,35 @@ public class TestHttp extends AbstractTestNGSpringContextTests {
             HttpResponse response = client.execute(method);
             length = Long.parseLong(response.getFirstHeader("Content-Length").getValue());
             System.out.println(response.getFirstHeader("Content-Length").getValue());
-            File localFile = new File("/tmp/test");
+            final File localFile = new File("/tmp/test");
             if (!localFile.exists()) {
                 localFile.createNewFile();
             }
 
-            HttpGet getMethod = new HttpGet(templateUrl);
+            final HttpGet getMethod = new HttpGet(templateUrl);
             response = client.execute(getMethod);
-            HttpEntity entity = response.getEntity();
+            final HttpEntity entity = response.getEntity();
 
             output = new BufferedOutputStream(new FileOutputStream(localFile));
             entity.writeTo(output);
-        } catch (HttpException e) {
+        } catch (final ClientProtocolException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
-        } catch (IOException e) {
+        } catch (final IOException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         } finally {
             try {
-                if (output != null)
+                if (output != null) {
                     output.close();
-            } catch (IOException e) {
+                }
+            } catch (final IOException e) {
                 // TODO Auto-generated catch block
                 e.printStackTrace();
             }
         }
 
-        File f = new File("/tmp/test");
+        final File f = new File("/tmp/test");
         Assert.assertEquals(f.length(), length);
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb85b7e8/framework/cluster/src/com/cloud/cluster/ClusterServiceServletHttpHandler.java
----------------------------------------------------------------------
diff --git a/framework/cluster/src/com/cloud/cluster/ClusterServiceServletHttpHandler.java
b/framework/cluster/src/com/cloud/cluster/ClusterServiceServletHttpHandler.java
index 3a85302..e12e0fe 100644
--- a/framework/cluster/src/com/cloud/cluster/ClusterServiceServletHttpHandler.java
+++ b/framework/cluster/src/com/cloud/cluster/ClusterServiceServletHttpHandler.java
@@ -20,11 +20,11 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.net.URLDecoder;
 
-import org.apache.commons.httpclient.HttpStatus;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
 import org.apache.http.entity.BasicHttpEntity;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
@@ -55,14 +55,14 @@ public class ClusterServiceServletHttpHandler implements HttpRequestHandler
{
                 s_logger.trace("Handle cluster HTTP request done");
             }
 
-        } catch (Throwable e) {
+        } catch (final Throwable e) {
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("Exception " + e.toString());
             }
 
             try {
                 writeResponse(response, HttpStatus.SC_INTERNAL_SERVER_ERROR, null);
-            } catch (Throwable e2) {
+            } catch (final Throwable e2) {
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug("Exception " + e2.toString());
                 }
@@ -73,20 +73,20 @@ public class ClusterServiceServletHttpHandler implements HttpRequestHandler
{
     @SuppressWarnings("deprecation")
     private void parseRequest(HttpRequest request) throws IOException {
         if (request instanceof HttpEntityEnclosingRequest) {
-            HttpEntityEnclosingRequest entityRequest = (HttpEntityEnclosingRequest)request;
+            final HttpEntityEnclosingRequest entityRequest = (HttpEntityEnclosingRequest)request;
 
-            String body = EntityUtils.toString(entityRequest.getEntity());
+            final String body = EntityUtils.toString(entityRequest.getEntity());
             if (body != null) {
-                String[] paramArray = body.split("&");
+                final String[] paramArray = body.split("&");
                 if (paramArray != null) {
-                    for (String paramEntry : paramArray) {
-                        String[] paramValue = paramEntry.split("=");
+                    for (final String paramEntry : paramArray) {
+                        final String[] paramValue = paramEntry.split("=");
                         if (paramValue.length != 2) {
                             continue;
                         }
 
-                        String name = URLDecoder.decode(paramValue[0]);
-                        String value = URLDecoder.decode(paramValue[1]);
+                        final String name = URLDecoder.decode(paramValue[0]);
+                        final String value = URLDecoder.decode(paramValue[1]);
 
                         if (s_logger.isTraceEnabled()) {
                             s_logger.trace("Parsed request parameter " + name + "=" + value);
@@ -103,17 +103,17 @@ public class ClusterServiceServletHttpHandler implements HttpRequestHandler
{
             content = "";
         }
         response.setStatusCode(statusCode);
-        BasicHttpEntity body = new BasicHttpEntity();
+        final BasicHttpEntity body = new BasicHttpEntity();
         body.setContentType("text/html; charset=UTF-8");
 
-        byte[] bodyData = content.getBytes();
+        final byte[] bodyData = content.getBytes();
         body.setContent(new ByteArrayInputStream(bodyData));
         body.setContentLength(bodyData.length);
         response.setEntity(body);
     }
 
     protected void handleRequest(HttpRequest req, HttpResponse response) {
-        String method = (String)req.getParams().getParameter("method");
+        final String method = (String)req.getParams().getParameter("method");
 
         int nMethod = RemoteMethodConstants.METHOD_UNKNOWN;
         String responseContent = null;
@@ -133,22 +133,24 @@ public class ClusterServiceServletHttpHandler implements HttpRequestHandler
{
 
                 case RemoteMethodConstants.METHOD_UNKNOWN:
                 default:
-                    assert (false);
+                    assert false;
                     s_logger.error("unrecognized method " + nMethod);
                     break;
             }
-        } catch (Throwable e) {
+        } catch (final Throwable e) {
             s_logger.error("Unexpected exception when processing cluster service request
: ", e);
         }
 
         if (responseContent != null) {
-            if (s_logger.isTraceEnabled())
+            if (s_logger.isTraceEnabled()) {
                 s_logger.trace("Write reponse with HTTP OK " + responseContent);
+            }
 
             writeResponse(response, HttpStatus.SC_OK, responseContent);
         } else {
-            if (s_logger.isTraceEnabled())
+            if (s_logger.isTraceEnabled()) {
                 s_logger.trace("Write reponse with HTTP Bad request");
+            }
 
             writeResponse(response, HttpStatus.SC_BAD_REQUEST, null);
         }
@@ -156,16 +158,16 @@ public class ClusterServiceServletHttpHandler implements HttpRequestHandler
{
 
     private String handleDeliverPduMethodCall(HttpRequest req) {
 
-        String pduSeq = (String)req.getParams().getParameter("pduSeq");
-        String pduAckSeq = (String)req.getParams().getParameter("pduAckSeq");
-        String sourcePeer = (String)req.getParams().getParameter("sourcePeer");
-        String destPeer = (String)req.getParams().getParameter("destPeer");
-        String agentId = (String)req.getParams().getParameter("agentId");
-        String gsonPackage = (String)req.getParams().getParameter("gsonPackage");
-        String stopOnError = (String)req.getParams().getParameter("stopOnError");
-        String pduType = (String)req.getParams().getParameter("pduType");
+        final String pduSeq = (String)req.getParams().getParameter("pduSeq");
+        final String pduAckSeq = (String)req.getParams().getParameter("pduAckSeq");
+        final String sourcePeer = (String)req.getParams().getParameter("sourcePeer");
+        final String destPeer = (String)req.getParams().getParameter("destPeer");
+        final String agentId = (String)req.getParams().getParameter("agentId");
+        final String gsonPackage = (String)req.getParams().getParameter("gsonPackage");
+        final String stopOnError = (String)req.getParams().getParameter("stopOnError");
+        final String pduType = (String)req.getParams().getParameter("pduType");
 
-        ClusterServicePdu pdu = new ClusterServicePdu();
+        final ClusterServicePdu pdu = new ClusterServicePdu();
         pdu.setSourcePeer(sourcePeer);
         pdu.setDestPeer(destPeer);
         pdu.setAgentId(Long.parseLong(agentId));
@@ -180,7 +182,7 @@ public class ClusterServiceServletHttpHandler implements HttpRequestHandler
{
     }
 
     private String handlePingMethodCall(HttpRequest req) {
-        String callingPeer = (String)req.getParams().getParameter("callingPeer");
+        final String callingPeer = (String)req.getParams().getParameter("callingPeer");
 
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Handle ping request from " + callingPeer);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb85b7e8/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
b/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
index dc111fd..eb03515 100644
--- a/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
+++ b/plugins/network-elements/brocade-vcs/src/com/cloud/network/brocade/BrocadeVcsApi.java
@@ -30,9 +30,8 @@ import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpStatus;
 import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.methods.HttpDelete;
@@ -64,9 +63,9 @@ import com.cloud.network.schema.showvcs.Output;
 public class BrocadeVcsApi {
     private static final Logger s_logger = Logger.getLogger(BrocadeVcsApi.class);
 
-    private String _host;
-    private String _adminuser;
-    private String _adminpass;
+    private final String _host;
+    private final String _adminuser;
+    private final String _adminpass;
 
     protected DefaultHttpClient _client;
 
@@ -74,7 +73,7 @@ public class BrocadeVcsApi {
         String url;
         try {
             url = new URL(Constants.PROTOCOL, _host, Constants.PORT, uri).toString();
-        } catch (MalformedURLException e) {
+        } catch (final MalformedURLException e) {
             s_logger.error("Unable to build Brocade Switch API URL", e);
             throw new BrocadeVcsApiException("Unable to build Brocade Switch API URL", e);
         }
@@ -116,7 +115,7 @@ public class BrocadeVcsApi {
 
         if (createInterfaceVlan(vlanId)) {
 
-            PortProfile portProfile = createPortProfile(vlanId, networkId);
+            final PortProfile portProfile = createPortProfile(vlanId, networkId);
 
             if (portProfile != null) {
                 return activatePortProfile(portProfile);
@@ -129,9 +128,9 @@ public class BrocadeVcsApi {
      * Activates a port-profile.
      */
     private boolean activatePortProfile(PortProfile portProfile) throws BrocadeVcsApiException
{
-        PortProfileGlobal portProfileGlobal = new PortProfileGlobal();
+        final PortProfileGlobal portProfileGlobal = new PortProfileGlobal();
         portProfile.setVlanProfile(null);
-        Activate activate = new Activate();
+        final Activate activate = new Activate();
         portProfile.setActivate(activate);
         portProfileGlobal.setPortProfile(portProfile);
 
@@ -144,7 +143,7 @@ public class BrocadeVcsApi {
      */
     private PortProfile createPortProfile(int vlanId, long networkId) throws BrocadeVcsApiException
{
 
-        PortProfile portProfile = new PortProfile();
+        final PortProfile portProfile = new PortProfile();
         portProfile.setName(Constants.PORT_PROFILE_NAME_PREFIX + networkId);
         if (executeCreateObject(portProfile, Constants.URI)) {
             if (createVlanSubProfile(vlanId, portProfile)) {
@@ -158,7 +157,7 @@ public class BrocadeVcsApi {
      * Create vlan sub-profile for port-profile
      */
     private boolean createVlanSubProfile(int vlanId, PortProfile portProfile) throws BrocadeVcsApiException
{
-        VlanProfile vlanProfile = new VlanProfile();
+        final VlanProfile vlanProfile = new VlanProfile();
         portProfile.setVlanProfile(vlanProfile);
         if (executeUpdateObject(portProfile, Constants.URI)) {
             return configureVlanSubProfile(vlanId, portProfile);
@@ -173,15 +172,15 @@ public class BrocadeVcsApi {
      * - configure allowed VLANs for vlan sub-profile
      */
     private boolean configureVlanSubProfile(int vlanId, PortProfile portProfile) throws BrocadeVcsApiException
{
-        SwitchportBasic switchPortBasic = new SwitchportBasic();
-        Basic basic = new Basic();
+        final SwitchportBasic switchPortBasic = new SwitchportBasic();
+        final Basic basic = new Basic();
         switchPortBasic.setBasic(basic);
         portProfile.getVlanProfile().setSwitchportBasic(switchPortBasic);
         // configure L2 mode for vlan sub-profile
         if (executeUpdateObject(portProfile, Constants.URI)) {
             VlanProfile vlanProfile = new VlanProfile();
             Switchport switchPort = new Switchport();
-            Mode mode = new Mode();
+            final Mode mode = new Mode();
             mode.setVlanMode("trunk");
             switchPort.setMode(mode);
             vlanProfile.setSwitchport(switchPort);
@@ -191,9 +190,9 @@ public class BrocadeVcsApi {
             if (executeUpdateObject(portProfile, Constants.URI)) {
                 vlanProfile = new VlanProfile();
                 switchPort = new Switchport();
-                Trunk trunk = new Trunk();
-                Allowed allowed = new Allowed();
-                Allowed.Vlan allowedVlan = new Allowed.Vlan();
+                final Trunk trunk = new Trunk();
+                final Allowed allowed = new Allowed();
+                final Allowed.Vlan allowedVlan = new Allowed.Vlan();
                 allowedVlan.setAdd(vlanId);
                 allowed.setVlan(allowedVlan);
                 trunk.setAllowed(allowed);
@@ -214,9 +213,9 @@ public class BrocadeVcsApi {
      * Creates a vlan interface.
      */
     private boolean createInterfaceVlan(int vlanId) throws BrocadeVcsApiException {
-        InterfaceVlan interfaceVlan = new InterfaceVlan();
-        Interface interfaceObj = new Interface();
-        Vlan vlan = new Vlan();
+        final InterfaceVlan interfaceVlan = new InterfaceVlan();
+        final Interface interfaceObj = new Interface();
+        final Vlan vlan = new Vlan();
         vlan.setName(vlanId);
         interfaceObj.setVlan(vlan);
         interfaceVlan.setInterface(interfaceObj);
@@ -230,10 +229,10 @@ public class BrocadeVcsApi {
      */
     public boolean associateMacToNetwork(long networkId, String macAddress) throws BrocadeVcsApiException
{
 
-        PortProfileGlobal portProfileGlobal = new PortProfileGlobal();
-        PortProfile portProfile = new PortProfile();
+        final PortProfileGlobal portProfileGlobal = new PortProfileGlobal();
+        final PortProfile portProfile = new PortProfile();
         portProfile.setName(Constants.PORT_PROFILE_NAME_PREFIX + networkId);
-        Static staticObj = new Static();
+        final Static staticObj = new Static();
         staticObj.setMacAddress(macAddress);
         portProfile.setStatic(staticObj);
         portProfileGlobal.setPortProfile(portProfile);
@@ -247,10 +246,10 @@ public class BrocadeVcsApi {
      */
     public boolean disassociateMacFromNetwork(long networkId, String macAddress) throws BrocadeVcsApiException
{
 
-        PortProfileGlobal portProfileGlobal = new PortProfileGlobal();
-        PortProfile portProfile = new PortProfile();
+        final PortProfileGlobal portProfileGlobal = new PortProfileGlobal();
+        final PortProfile portProfile = new PortProfile();
         portProfile.setName(Constants.PORT_PROFILE_NAME_PREFIX + networkId);
-        Static staticObj = new Static();
+        final Static staticObj = new Static();
         staticObj.setOperation("delete");
         staticObj.setMacAddress(macAddress);
         portProfile.setStatic(staticObj);
@@ -278,9 +277,9 @@ public class BrocadeVcsApi {
      * Deletes a vlan interface.
      */
     private boolean deleteInterfaceVlan(int vlanId) throws BrocadeVcsApiException {
-        InterfaceVlan interfaceVlan = new InterfaceVlan();
-        Interface interfaceObj = new Interface();
-        Vlan vlan = new Vlan();
+        final InterfaceVlan interfaceVlan = new InterfaceVlan();
+        final Interface interfaceObj = new Interface();
+        final Vlan vlan = new Vlan();
         vlan.setOperation("delete");
         vlan.setName(vlanId);
         interfaceObj.setVlan(vlan);
@@ -294,10 +293,10 @@ public class BrocadeVcsApi {
      * Deactivates a port-profile.
      */
     private boolean deactivatePortProfile(long networkId) throws BrocadeVcsApiException {
-        PortProfileGlobal portProfileGlobal = new PortProfileGlobal();
-        PortProfile portProfile = new PortProfile();
+        final PortProfileGlobal portProfileGlobal = new PortProfileGlobal();
+        final PortProfile portProfile = new PortProfile();
         portProfile.setName(Constants.PORT_PROFILE_NAME_PREFIX + networkId);
-        Activate activate = new Activate();
+        final Activate activate = new Activate();
         activate.setOperation("delete");
         portProfile.setActivate(activate);
         portProfileGlobal.setPortProfile(portProfile);
@@ -311,7 +310,7 @@ public class BrocadeVcsApi {
      */
     private boolean deletePortProfile(long networkId) throws BrocadeVcsApiException {
 
-        PortProfile portProfile = new PortProfile();
+        final PortProfile portProfile = new PortProfile();
         portProfile.setName(Constants.PORT_PROFILE_NAME_PREFIX + networkId);
         portProfile.setOperation("delete");
         //deletes port-profile
@@ -320,25 +319,25 @@ public class BrocadeVcsApi {
 
     protected <T> boolean executeUpdateObject(T newObject, String uri) throws BrocadeVcsApiException
{
 
-        boolean result = true;
+        final boolean result = true;
 
         if (_host == null || _host.isEmpty() || _adminuser == null || _adminuser.isEmpty()
|| _adminpass == null || _adminpass.isEmpty()) {
             throw new BrocadeVcsApiException("Hostname/credentials are null or empty");
         }
 
-        HttpPatch pm = (HttpPatch)createMethod("patch", uri);
+        final HttpPatch pm = (HttpPatch)createMethod("patch", uri);
         pm.setHeader("Accept", "application/vnd.configuration.resource+xml");
 
         pm.setEntity(new StringEntity(convertToString(newObject), ContentType.APPLICATION_XML));
 
-        HttpResponse response = executeMethod(pm);
+        final HttpResponse response = executeMethod(pm);
 
         if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NO_CONTENT) {
 
             String errorMessage;
             try {
                 errorMessage = responseToErrorMessage(response);
-            } catch (IOException e) {
+            } catch (final IOException e) {
                 s_logger.error("Failed to update object : " + e.getMessage());
                 throw new BrocadeVcsApiException("Failed to update object : " + e.getMessage());
             }
@@ -363,12 +362,12 @@ public class BrocadeVcsApi {
 
             marshaller.marshal(object, stringWriter);
 
-        } catch (JAXBException e) {
+        } catch (final JAXBException e) {
             s_logger.error("Failed to convert object to string : " + e.getMessage());
             throw new BrocadeVcsApiException("Failed to convert object to string : " + e.getMessage());
         }
 
-        String str = stringWriter.toString();
+        final String str = stringWriter.toString();
         s_logger.info(str);
 
         return str;
@@ -379,19 +378,19 @@ public class BrocadeVcsApi {
 
         Output output = null;
         try {
-            JAXBContext context = JAXBContext.newInstance(Output.class);
+            final JAXBContext context = JAXBContext.newInstance(Output.class);
 
-            StringReader reader = new StringReader(object);
+            final StringReader reader = new StringReader(object);
 
             final Unmarshaller unmarshaller = context.createUnmarshaller();
-            Object result = unmarshaller.unmarshal(reader);
+            final Object result = unmarshaller.unmarshal(reader);
 
             if (result instanceof Output) {
                 output = (Output)result;
                 s_logger.info(output);
             }
 
-        } catch (JAXBException e) {
+        } catch (final JAXBException e) {
             s_logger.error("Failed to convert string to object : " + e.getMessage());
             throw new BrocadeVcsApiException("Failed to convert string to object : " + e.getMessage());
         }
@@ -405,19 +404,19 @@ public class BrocadeVcsApi {
             throw new BrocadeVcsApiException("Hostname/credentials are null or empty");
         }
 
-        boolean result = true;
-        HttpPost pm = (HttpPost)createMethod("post", uri);
+        final boolean result = true;
+        final HttpPost pm = (HttpPost)createMethod("post", uri);
         pm.setHeader("Accept", "application/vnd.configuration.resource+xml");
         pm.setEntity(new StringEntity(convertToString(newObject), ContentType.APPLICATION_XML));
 
-        HttpResponse response = executeMethod(pm);
+        final HttpResponse response = executeMethod(pm);
 
         if (response.getStatusLine().getStatusCode() != HttpStatus.SC_CREATED) {
 
             String errorMessage;
             try {
                 errorMessage = responseToErrorMessage(response);
-            } catch (IOException e) {
+            } catch (final IOException e) {
                 s_logger.error("Failed to create object : " + e.getMessage());
                 throw new BrocadeVcsApiException("Failed to create object : " + e.getMessage());
             }
@@ -440,18 +439,18 @@ public class BrocadeVcsApi {
         String readLine = null;
         StringBuffer sb = null;
 
-        HttpPost pm = (HttpPost)createMethod("post", uri);
+        final HttpPost pm = (HttpPost)createMethod("post", uri);
         pm.setHeader("Accept", "application/vnd.operational-state.resource+xml");
         pm.setEntity(new StringEntity("<show-vcs></show-vcs>", ContentType.APPLICATION_XML));
 
-        HttpResponse response = executeMethod(pm);
+        final HttpResponse response = executeMethod(pm);
 
         if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
 
             String errorMessage;
             try {
                 errorMessage = responseToErrorMessage(response);
-            } catch (IOException e) {
+            } catch (final IOException e) {
                 s_logger.error("Failed to retreive status : " + e.getMessage());
                 throw new BrocadeVcsApiException("Failed to retreive status : " + e.getMessage());
             }
@@ -464,12 +463,12 @@ public class BrocadeVcsApi {
         try (BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(),
Charset.forName("UTF-8")))) {
             sb = new StringBuffer();
 
-            while (((readLine = br.readLine()) != null)) {
+            while ((readLine = br.readLine()) != null) {
                 s_logger.debug(readLine);
                 sb.append(readLine);
 
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.error("Failed to retreive status : " + e.getMessage());
             throw new BrocadeVcsApiException("Failed to retreive status : " + e.getMessage());
         }
@@ -484,17 +483,17 @@ public class BrocadeVcsApi {
             throw new BrocadeVcsApiException("Hostname/credentials are null or empty");
         }
 
-        HttpDelete dm = (HttpDelete)createMethod("delete", uri);
+        final HttpDelete dm = (HttpDelete)createMethod("delete", uri);
         dm.setHeader("Accept", "application/vnd.configuration.resource+xml");
 
-        HttpResponse response = executeMethod(dm);
+        final HttpResponse response = executeMethod(dm);
 
         if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NO_CONTENT) {
 
             String errorMessage;
             try {
                 errorMessage = responseToErrorMessage(response);
-            } catch (IOException e) {
+            } catch (final IOException e) {
                 s_logger.error("Failed to delete object : " + e.getMessage());
                 throw new BrocadeVcsApiException("Failed to delete object : " + e.getMessage());
             }
@@ -514,11 +513,7 @@ public class BrocadeVcsApi {
                 method.releaseConnection();
                 response = _client.execute(method);
             }
-        } catch (HttpException e) {
-            s_logger.error("HttpException caught while trying to connect to the Brocade Switch",
e);
-            method.releaseConnection();
-            throw new BrocadeVcsApiException("API call to Brocade Switch Failed", e);
-        } catch (IOException e) {
+        } catch (final IOException e) {
             s_logger.error("IOException caught while trying to connect to the Brocade Switch",
e);
             method.releaseConnection();
             throw new BrocadeVcsApiException("API call to Brocade Switch Failed", e);
@@ -533,7 +528,7 @@ public class BrocadeVcsApi {
 
             try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(),
Charset.forName("UTF-8")))) {
 
-                StringBuffer result = new StringBuffer();
+                final StringBuffer result = new StringBuffer();
                 String line = "";
                 while ((line = rd.readLine()) != null) {
                     result.append(line);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb85b7e8/plugins/network-elements/brocade-vcs/test/com/cloud/network/brocade/BrocadeVcsApiTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/brocade-vcs/test/com/cloud/network/brocade/BrocadeVcsApiTest.java
b/plugins/network-elements/brocade-vcs/test/com/cloud/network/brocade/BrocadeVcsApiTest.java
index 4223d4c..e84b7ca 100644
--- a/plugins/network-elements/brocade-vcs/test/com/cloud/network/brocade/BrocadeVcsApiTest.java
+++ b/plugins/network-elements/brocade-vcs/test/com/cloud/network/brocade/BrocadeVcsApiTest.java
@@ -26,9 +26,9 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import java.io.IOException;
 
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.http.StatusLine;
 import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.StatusLine;
 import org.apache.http.client.methods.HttpPatch;
 import org.apache.http.client.methods.HttpPost;
 
@@ -93,7 +93,7 @@ public class BrocadeVcsApiTest {
         when(response.getEntity()).thenReturn(new StringEntity(OUTPUT_XML_RESPONSE));
 
         // Execute
-        Output result = api.getSwitchStatus();
+        final Output result = api.getSwitchStatus();
 
         // Assert
         verify(method, times(1)).releaseConnection();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cb85b7e8/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraNvpApiTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraNvpApiTest.java
b/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraNvpApiTest.java
index 79546a6..34518ce 100644
--- a/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraNvpApiTest.java
+++ b/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraNvpApiTest.java
@@ -33,9 +33,9 @@ import static org.mockito.Mockito.when;
 
 import java.util.List;
 
-import org.apache.commons.httpclient.HttpStatus;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
+import org.apache.http.HttpStatus;
 import org.apache.http.ProtocolVersion;
 import org.apache.http.StatusLine;
 import org.apache.http.client.methods.CloseableHttpResponse;


Mime
View raw message