@Test public void testGroup() throws Exception { String xml = sendRequest(GET, "/groups", 200); assertTrue(xml.contains("Admin")); OnmsGroupList list = JaxbUtils.unmarshal(OnmsGroupList.class, xml); assertEquals(1, list.getGroups().size()); assertEquals(xml, "Admin", list.getGroups().get(0).getName()); xml = sendRequest(GET, "/groups/Admin", 200); assertTrue(xml.contains(">Admin<")); sendRequest(GET, "/groups/idontexist", 404); }
@GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) public OnmsGroupList getGroups() { readLock(); try { final OnmsGroupList list; list = m_groupManager.getOnmsGroupList(); Collections.sort(list, new Comparator<OnmsGroup>() { @Override public int compare(final OnmsGroup a, final OnmsGroup b) { return a.getName().compareTo(b.getName()); } }); return list; } catch (final Throwable t) { throw getException(Status.BAD_REQUEST, t); } finally { readUnlock(); } }
GroupRestService extends OnmsRestService { @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) public OnmsGroupList getGroups() { readLock(); try { final OnmsGroupList list; list = m_groupManager.getOnmsGroupList(); Collections.sort(list, new Comparator<OnmsGroup>() { @Override public int compare(final OnmsGroup a, final OnmsGroup b) { return a.getName().compareTo(b.getName()); } }); return list; } catch (final Throwable t) { throw getException(Status.BAD_REQUEST, t); } finally { readUnlock(); } } }
GroupRestService extends OnmsRestService { @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) public OnmsGroupList getGroups() { readLock(); try { final OnmsGroupList list; list = m_groupManager.getOnmsGroupList(); Collections.sort(list, new Comparator<OnmsGroup>() { @Override public int compare(final OnmsGroup a, final OnmsGroup b) { return a.getName().compareTo(b.getName()); } }); return list; } catch (final Throwable t) { throw getException(Status.BAD_REQUEST, t); } finally { readUnlock(); } }  }
GroupRestService extends OnmsRestService { @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) public OnmsGroupList getGroups() { readLock(); try { final OnmsGroupList list; list = m_groupManager.getOnmsGroupList(); Collections.sort(list, new Comparator<OnmsGroup>() { @Override public int compare(final OnmsGroup a, final OnmsGroup b) { return a.getName().compareTo(b.getName()); } }); return list; } catch (final Throwable t) { throw getException(Status.BAD_REQUEST, t); } finally { readUnlock(); } }  @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) OnmsGroupList getGroups(); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) @Path("{groupName}") OnmsGroup getGroup(@PathParam("groupName") final String groupName); @POST @Consumes(MediaType.APPLICATION_XML) Response addGroup(final OnmsGroup group); @PUT @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Path("{groupName}") Response updateGroup(@PathParam("groupName") final String groupName, final MultivaluedMapImpl params); @DELETE @Path("{groupName}") Response deleteGroup(@PathParam("groupName") final String groupName); @PUT @Path("{groupName}/users/{userName}") Response addUser(@PathParam("groupName") final String groupName, @PathParam("userName") final String userName); @DELETE @Path("{groupName}/users/{userName}") Response removeUser(@PathParam("groupName") final String groupName, @PathParam("userName") final String userName); }
GroupRestService extends OnmsRestService { @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) public OnmsGroupList getGroups() { readLock(); try { final OnmsGroupList list; list = m_groupManager.getOnmsGroupList(); Collections.sort(list, new Comparator<OnmsGroup>() { @Override public int compare(final OnmsGroup a, final OnmsGroup b) { return a.getName().compareTo(b.getName()); } }); return list; } catch (final Throwable t) { throw getException(Status.BAD_REQUEST, t); } finally { readUnlock(); } }  @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) OnmsGroupList getGroups(); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) @Path("{groupName}") OnmsGroup getGroup(@PathParam("groupName") final String groupName); @POST @Consumes(MediaType.APPLICATION_XML) Response addGroup(final OnmsGroup group); @PUT @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Path("{groupName}") Response updateGroup(@PathParam("groupName") final String groupName, final MultivaluedMapImpl params); @DELETE @Path("{groupName}") Response deleteGroup(@PathParam("groupName") final String groupName); @PUT @Path("{groupName}/users/{userName}") Response addUser(@PathParam("groupName") final String groupName, @PathParam("userName") final String userName); @DELETE @Path("{groupName}/users/{userName}") Response removeUser(@PathParam("groupName") final String groupName, @PathParam("userName") final String userName);  }