directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject directory-fortress-core git commit: convert to switch statement
Date Sat, 12 Sep 2015 01:42:27 GMT
Repository: directory-fortress-core
Updated Branches:
  refs/heads/master 6bcbc8be3 -> 7a6674bb3


convert to switch statement


Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/7a6674bb
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/7a6674bb
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/7a6674bb

Branch: refs/heads/master
Commit: 7a6674bb38c19b4e5452ff6555089a3bc67f3074
Parents: 6bcbc8b
Author: Shawn McKinney <smckinney@apache.org>
Authored: Thu Sep 10 11:51:22 2015 -0500
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Thu Sep 10 11:51:22 2015 -0500

----------------------------------------------------------------------
 .../directory/fortress/core/rest/RestUtils.java | 56 +++++++++-----------
 1 file changed, 26 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/7a6674bb/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java b/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
index c6c60e7..95ce399 100644
--- a/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
+++ b/src/main/java/org/apache/directory/fortress/core/rest/RestUtils.java
@@ -295,37 +295,33 @@ public class RestUtils
             post.setRequestEntity( entity );
             HttpClient httpclient = new HttpClient();
             int result = httpclient.executeMethod( post );
-            if ( result == HTTP_OK )
-            {
-                szResponse = IOUtils.toString( post.getResponseBodyAsStream(), "UTF-8" );
-                LOG.debug( "post URI=[{}], function=[{}], response=[{}]", URI, function,
szResponse );
-            }
-            else if ( result == HTTP_401_UNAUTHORIZED )
-            {
-                String error = "post URI=[" + URI + "], function=[" + function
-                    + "], 401 function unauthorized on host";
-                LOG.error( error );
-                throw new RestException( GlobalErrIds.REST_UNAUTHORIZED_ERR, error );
-            }
-            else if ( result == HTTP_403_FORBIDDEN )
-            {
-                String error = "post URI=[" + URI + "], function=[" + function
-                    + "], 403 function forbidden on host";
-                LOG.error( error );
-                throw new RestException( GlobalErrIds.REST_FORBIDDEN_ERR, error );
-            }
-            else if ( result == HTTP_404_NOT_FOUND )
-            {
-                String error = "post URI=[" + URI + "], function=[" + function + "], 404
not found from host";
-                LOG.error( error );
-                throw new RestException( GlobalErrIds.REST_NOT_FOUND_ERR, error );
-            }
-            else
+            String error;
+
+            switch ( result )
             {
-                String error = "post URI=[" + URI + "], function=[" + function
-                    + "], error received from host: " + result;
-                LOG.error( error );
-                throw new RestException( GlobalErrIds.REST_UNKNOWN_ERR, error );
+                case HTTP_OK :
+                    szResponse = IOUtils.toString( post.getResponseBodyAsStream(), "UTF-8"
);
+                    LOG.debug( "post URI=[{}], function=[{}], response=[{}]", URI, function,
szResponse );
+                    break;
+                case HTTP_401_UNAUTHORIZED :
+                    error = "post URI=[" + URI + "], function=[" + function
+                        + "], 401 function unauthorized on host";
+                    LOG.error( error );
+                    throw new RestException( GlobalErrIds.REST_UNAUTHORIZED_ERR, error );
+                case HTTP_403_FORBIDDEN :
+                    error = "post URI=[" + URI + "], function=[" + function
+                        + "], 403 function forbidden on host";
+                    LOG.error( error );
+                    throw new RestException( GlobalErrIds.REST_FORBIDDEN_ERR, error );
+                case HTTP_404_NOT_FOUND :
+                    error = "post URI=[" + URI + "], function=[" + function + "], 404 not
found from host";
+                    LOG.error( error );
+                    throw new RestException( GlobalErrIds.REST_NOT_FOUND_ERR, error );
+                default :
+                    error = "post URI=[" + URI + "], function=[" + function
+                        + "], error received from host: " + result;
+                    LOG.error( error );
+                    throw new RestException( GlobalErrIds.REST_UNKNOWN_ERR, error );
             }
         }
         catch ( IOException ioe )


Mime
View raw message