Commits

Sebastian Sdorra committed f988a3b

added update method

Comments (0)

Files changed (2)

scm-webapp/src/main/java/sonia/scm/Group.java

     return name;
   }
 
+  //~--- set methods ----------------------------------------------------------
+
+  /**
+   * Method description
+   *
+   *
+   * @param members
+   */
+  public void setMembers(List<String> members)
+  {
+    this.members = members;
+  }
+
+  /**
+   * Method description
+   *
+   *
+   * @param name
+   */
+  public void setName(String name)
+  {
+    this.name = name;
+  }
+
   //~--- fields ---------------------------------------------------------------
 
   /** Field description */

scm-webapp/src/main/java/sonia/scm/api/rest/resources/GroupsResource.java

 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
           "groups/".concat(group.getName()))).build();
   }
 
+  /**
+   * Method description
+   *
+   *
+   *
+   * @param name
+   * @param group
+   *
+   * @return
+   */
+  @PUT
+  @Path("{name}")
+  @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+  public Response update(@PathParam("name") String name, Group group)
+  {
+    Group updateGroup = groupStore.get(name);
+
+    if (updateGroup == null)
+    {
+      throw new WebApplicationException(Status.NOT_FOUND);
+    }
+
+    updateGroup.setName(name);
+    updateGroup.setMembers(group.getMembers());
+
+    return Response.created(
+        uriInfo.getAbsolutePath().resolve(group.getName())).build();
+  }
+
   //~--- get methods ----------------------------------------------------------
 
   /**