mirror of https://github.com/apache/archiva.git
fix exception mapping
This commit is contained in:
parent
8753e05338
commit
29faf4ed88
|
@ -45,13 +45,13 @@ public class ArchivaRestServiceExceptionMapper
|
||||||
@Override
|
@Override
|
||||||
public int getStatusCode()
|
public int getStatusCode()
|
||||||
{
|
{
|
||||||
return Response.Status.INTERNAL_SERVER_ERROR.getStatusCode();
|
return e.getHttpErrorCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response.Status.Family getFamily()
|
public Response.Status.Family getFamily()
|
||||||
{
|
{
|
||||||
return Response.Status.Family.SERVER_ERROR;
|
return Response.Status.Family.familyOf( e.getHttpErrorCode() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,7 +59,9 @@ public class ArchivaRestServiceExceptionMapper
|
||||||
{
|
{
|
||||||
return e.getMessage();
|
return e.getMessage();
|
||||||
}
|
}
|
||||||
} ).build();
|
} )//
|
||||||
|
.entity( restError ) //
|
||||||
|
.build();
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,9 @@ import org.apache.archiva.rest.api.services.RepositoriesService;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import javax.ws.rs.BadRequestException;
|
||||||
import javax.ws.rs.ForbiddenException;
|
import javax.ws.rs.ForbiddenException;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -105,7 +107,7 @@ public class RepositoriesServiceTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test( expected = ForbiddenException.class )
|
@Test( expected = BadRequestException.class )
|
||||||
public void deleteWithRepoNull()
|
public void deleteWithRepoNull()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -122,9 +124,10 @@ public class RepositoriesServiceTest
|
||||||
|
|
||||||
repositoriesService.deleteArtifact( artifact );
|
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;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue