summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2015-02-10 22:10:09 +1100
committerOlivier Lamy <olamy@apache.org>2015-02-10 22:10:09 +1100
commit29faf4ed88c9c4d16fc75a210105335a78177344 (patch)
tree4cd6fd183047805837b1e8a4e1e31858beaad5f4
parent8753e0533870bf74307374eb287bdf8c2f165ee7 (diff)
downloadarchiva-29faf4ed88c9c4d16fc75a210105335a78177344.tar.gz
archiva-29faf4ed88c9c4d16fc75a210105335a78177344.zip
fix exception mapping
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/interceptors/ArchivaRestServiceExceptionMapper.java8
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java9
2 files changed, 11 insertions, 6 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/interceptors/ArchivaRestServiceExceptionMapper.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/interceptors/ArchivaRestServiceExceptionMapper.java
index e5e98d21d..5a6660160 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/interceptors/ArchivaRestServiceExceptionMapper.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/interceptors/ArchivaRestServiceExceptionMapper.java
@@ -45,13 +45,13 @@ public class ArchivaRestServiceExceptionMapper
@Override
public int getStatusCode()
{
- return Response.Status.INTERNAL_SERVER_ERROR.getStatusCode();
+ return e.getHttpErrorCode();
}
@Override
public Response.Status.Family getFamily()
{
- return Response.Status.Family.SERVER_ERROR;
+ return Response.Status.Family.familyOf( e.getHttpErrorCode() );
}
@Override
@@ -59,7 +59,9 @@ public class ArchivaRestServiceExceptionMapper
{
return e.getMessage();
}
- } ).build();
+ } )//
+ .entity( restError ) //
+ .build();
return response;
}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
index 51c1bff85..f745c043d 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
@@ -31,7 +31,9 @@ import org.apache.archiva.rest.api.services.RepositoriesService;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
+import javax.ws.rs.BadRequestException;
import javax.ws.rs.ForbiddenException;
+import javax.ws.rs.core.Response;
import java.io.File;
import java.util.List;
@@ -105,7 +107,7 @@ public class RepositoriesServiceTest
}
}
- @Test( expected = ForbiddenException.class )
+ @Test( expected = BadRequestException.class )
public void deleteWithRepoNull()
throws Exception
{
@@ -122,9 +124,10 @@ public class RepositoriesServiceTest
repositoriesService.deleteArtifact( artifact );
}
- catch ( ForbiddenException e )
+ catch ( BadRequestException e )
{
- assertEquals( "not http 400 status", 400, e.getResponse().getStatus() );
+ assertEquals( "not http " + Response.Status.BAD_REQUEST.getStatusCode() + " status",
+ Response.Status.BAD_REQUEST.getStatusCode(), e.getResponse().getStatus() );
throw e;
}
}