From fa537ea5cb0ec607f91c81179edae74e9328beeb Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sat, 19 Nov 2011 17:16:57 +0100 Subject: [PATCH] added a webservice method to fetch a single repository by its name and type --- .../rest/resources/RepositoryResource.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/scm-webapp/src/main/java/sonia/scm/api/rest/resources/RepositoryResource.java b/scm-webapp/src/main/java/sonia/scm/api/rest/resources/RepositoryResource.java index 15ea897589..2b4c02603a 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/rest/resources/RepositoryResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/rest/resources/RepositoryResource.java @@ -410,6 +410,47 @@ public class RepositoryResource return response; } + /** + * Returns a repository.
+ *
+ * Status codes: + * + * + * @param request the current request + * @param type the type of the repository + * @param name the name of the repository + * + * @return the {@link Repository} with the specified type and name + */ + @GET + @Path("{type}/{name}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @TypeHint(Repository.class) + public Response getByTypeAndName(@Context Request request, + @PathParam("type") String type, + @PathParam("name") String name) + { + Response response = null; + Repository repository = repositoryManager.get(type, name); + + if (repository != null) + { + prepareForReturn(repository); + response = Response.ok(repository).build(); + } + else + { + response = Response.status(Response.Status.NOT_FOUND).build(); + } + + return response; + } + /** * Returns a list of {@link Changeset} for the given repository.
*