Do not handle standard exceptions in resource

This commit is contained in:
René Pfeuffer
2018-08-31 08:39:58 +02:00
parent a326737f9e
commit a02dbf5fed

View File

@@ -32,25 +32,25 @@ public class SourceRootResource {
@GET @GET
@Produces(VndMediaType.SOURCE) @Produces(VndMediaType.SOURCE)
@Path("") @Path("")
public Response getAllWithoutRevision(@PathParam("namespace") String namespace, @PathParam("name") String name) { public Response getAllWithoutRevision(@PathParam("namespace") String namespace, @PathParam("name") String name) throws RevisionNotFoundException, RepositoryNotFoundException, IOException {
return getSource(namespace, name, "/", null); return getSource(namespace, name, "/", null);
} }
@GET @GET
@Produces(VndMediaType.SOURCE) @Produces(VndMediaType.SOURCE)
@Path("{revision}") @Path("{revision}")
public Response getAll(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("revision") String revision) { public Response getAll(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("revision") String revision) throws RevisionNotFoundException, RepositoryNotFoundException, IOException {
return getSource(namespace, name, "/", revision); return getSource(namespace, name, "/", revision);
} }
@GET @GET
@Produces(VndMediaType.SOURCE) @Produces(VndMediaType.SOURCE)
@Path("{revision}/{path: .*}") @Path("{revision}/{path: .*}")
public Response get(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("revision") String revision, @PathParam("path") String path) { public Response get(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("revision") String revision, @PathParam("path") String path) throws RevisionNotFoundException, RepositoryNotFoundException, IOException {
return getSource(namespace, name, path, revision); return getSource(namespace, name, path, revision);
} }
private Response getSource(String namespace, String repoName, String path, String revision) { private Response getSource(String namespace, String repoName, String path, String revision) throws IOException, RevisionNotFoundException, RepositoryNotFoundException {
NamespaceAndName namespaceAndName = new NamespaceAndName(namespace, repoName); NamespaceAndName namespaceAndName = new NamespaceAndName(namespace, repoName);
try (RepositoryService repositoryService = serviceFactory.create(namespaceAndName)) { try (RepositoryService repositoryService = serviceFactory.create(namespaceAndName)) {
BrowseCommandBuilder browseCommand = repositoryService.getBrowseCommand(); BrowseCommandBuilder browseCommand = repositoryService.getBrowseCommand();
@@ -65,11 +65,6 @@ public class SourceRootResource {
} else { } else {
return Response.status(Response.Status.NOT_FOUND).build(); return Response.status(Response.Status.NOT_FOUND).build();
} }
} catch (RepositoryNotFoundException | RevisionNotFoundException e) {
return Response.status(Response.Status.NOT_FOUND).build();
} catch (IOException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} }
} }
} }