You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2019/10/27 16:45:35 UTC

[maven-wagon] 04/05: WAGON-541 code simplification

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch WAGON-541
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git

commit 003c1f692f64fa39f307ff2dc1268b17341249fb
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Mon Oct 21 11:59:04 2019 -0300

    WAGON-541 code simplification
---
 .../maven/wagon/shared/http/HttpMessageUtils.java  | 41 +++++++++++++++-------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HttpMessageUtils.java b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HttpMessageUtils.java
index 398636d..daad3bb 100644
--- a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HttpMessageUtils.java
+++ b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HttpMessageUtils.java
@@ -129,17 +129,15 @@ public class HttpMessageUtils
         switch ( statusCode )
         {
             case SC_UNAUTHORIZED: // no credentials or auth was not valid
-                return "Authentication failed for " + url + " " + statusCode
-                        + ( StringUtils.isEmpty( reasonPhrase ) ? " Unauthorized" : " " + reasonPhrase );
+                return formatMessage( "Authentication failed for ", url, statusCode, reasonPhrase, null );
 
             case SC_FORBIDDEN: // forbidden based on permissions usually
-                return "Authorization failed for " + url + " " + statusCode
-                        + ( StringUtils.isEmpty( reasonPhrase ) ? " Forbidden" : " " + reasonPhrase );
+                return formatMessage( "Authorization failed for ", url, statusCode, reasonPhrase, null );
 
             case SC_PROXY_AUTH_REQUIRED:
-                return "HTTP proxy server authentication failed for " + url + " " + statusCode
-                        + ( StringUtils.isEmpty( reasonPhrase ) ? " Proxy Authentication Required"
-                        : " " + reasonPhrase );
+                return formatMessage( "HTTP proxy server authentication failed for ", url, statusCode,
+                        reasonPhrase, null );
+
             default:
                 break;
         }
@@ -179,13 +177,30 @@ public class HttpMessageUtils
             }
             else
             {
-                if ( statusCode == SC_NOT_FOUND )
-                {
-                    msg += " Not Found";
-                }
-                else if ( statusCode == SC_GONE )
+                switch ( statusCode )
                 {
-                    msg += " Gone";
+                    case SC_UNAUTHORIZED:
+                        msg += " Unauthorized";
+                        break;
+
+                    case SC_FORBIDDEN:
+                        msg += " Forbidden";
+                        break;
+
+                    case SC_NOT_FOUND:
+                        msg += " Not Found";
+                        break;
+
+                    case SC_PROXY_AUTH_REQUIRED:
+                        msg += " Proxy Authentication Required";
+                        break;
+
+                    case SC_GONE:
+                        msg += " Gone";
+                        break;
+
+                    default:
+                        break;
                 }
             }
         }