maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r389165 - in /maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src: main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
Date Mon, 27 Mar 2006 15:26:55 GMT
Author: brett
Date: Mon Mar 27 07:26:53 2006
New Revision: 389165

URL: http://svn.apache.org/viewcvs?rev=389165&view=rev
Log:
[WAGONHTTP-9] correct PUT handling
Submitted by: ysoonleo

Modified:
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java

Modified: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java?rev=389165&r1=389164&r2=389165&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
Mon Mar 27 07:26:53 2006
@@ -138,11 +138,30 @@
 
         try
         {
-            if ( putConnection.getResponseCode() != HttpURLConnection.HTTP_OK )
+            String url = getRepository().getUrl() + "/" + resourceName;
+            int statusCode = putConnection.getResponseCode();
+
+            switch ( statusCode )
             {
-                throw new TransferFailedException(
-                    "Unable to transfer file. HttpURLConnection returned the response code:
" +
-                        putConnection.getResponseCode() );
+                case HttpURLConnection.HTTP_OK:
+                    break;
+
+                case HttpURLConnection.HTTP_CREATED:
+                    break;
+
+                case HttpURLConnection.HTTP_NO_CONTENT:
+                    break;
+
+                case HttpURLConnection.HTTP_FORBIDDEN:
+                    throw new AuthorizationException( "Access denided to: " + url );
+
+                case HttpURLConnection.HTTP_NOT_FOUND:
+                    throw new ResourceDoesNotExistException( "File: " + url + " does not
exist" );
+
+                //add more entries here
+                default :
+                    throw new TransferFailedException(
+                        "Failed to transfer file: " + url + ". Return code is: " + statusCode
);
             }
         }
         catch ( IOException e )

Modified: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java?rev=389165&r1=389164&r2=389165&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
Mon Mar 27 07:26:53 2006
@@ -44,10 +44,6 @@
     protected void setupWagonTestingFixtures()
         throws Exception
     {
-        // For a PUT the artifact must exist already which is how a PUT works by
-        // default so we must place a dummy artifact in the http repo first before
-        // the actual PUT operation.
-
         // File round trip testing
         
         File file = FileTestUtils.createUniqueFile( "local-repository", "test-resource" );
@@ -56,19 +52,11 @@
 
         file.getParentFile().mkdirs();
 
-        FileTestUtils.generateFile( file.getAbsolutePath(), "file-dummy" );
-
-        // For a PUT the artifact must exist already which is how a PUT works by
-        // default so we must place a dummy artifact in the http repo first before
-        // the actual PUT operation.
-
         File f = new File( FileTestUtils.createDir( "http-repository" ), "test-resource"
);
 
         f.delete();
 
         f.getParentFile().mkdirs();
-
-        FileTestUtils.generateFile( f.getAbsolutePath(), "artifact-dummy" );
 
         httpd = (Httpd) lookup( Httpd.ROLE );
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org


Mime
View raw message