From 7a0ec93c1cba6785284fb1397819a2d0c2b5aaa6 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Tue, 10 Jul 2012 20:56:03 +0200 Subject: [PATCH] added webservice method for branches command --- .../rest/resources/RepositoryResource.java | 63 ++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) 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 6835953bea..2dfb40709e 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 @@ -49,6 +49,7 @@ import org.slf4j.LoggerFactory; import sonia.scm.config.ScmConfiguration; import sonia.scm.repository.BlameResult; +import sonia.scm.repository.Branches; import sonia.scm.repository.BrowserResult; import sonia.scm.repository.Changeset; import sonia.scm.repository.ChangesetPagingResult; @@ -393,6 +394,66 @@ public class RepositoryResource return response; } + /** + * Returns all {@link Branches} of a repository.
+ *
+ * Status codes: + * + * + * @param id the id of the repository + * + * @return all {@link Branches} of a repository + * + * @throws IOException + * @throws RepositoryException + * + * @since 1.18 + */ + @GET + @Path("{id}/branches") + public Response getBranches(@PathParam("id") String id) + throws RepositoryException, IOException + { + Response response = null; + RepositoryService service = null; + + try + { + service = servicefactory.create(id); + + Branches branches = service.getBranchesCommand().getBranches(); + + if (branches != null) + { + response = Response.ok(branches).build(); + } + else + { + response = Response.status(Status.NOT_FOUND).build(); + } + } + catch (RepositoryNotFoundException ex) + { + response = Response.status(Response.Status.NOT_FOUND).build(); + } + catch (CommandNotSupportedException ex) + { + response = Response.status(Response.Status.BAD_REQUEST).build(); + } + finally + { + Closeables.closeQuietly(service); + } + + return response; + } + /** * Returns a list of folders and files for the given folder.
*
@@ -830,7 +891,7 @@ public class RepositoryResource * * @throws IOException * @throws RepositoryException - * + * * @since 1.18 */ @GET