@Test public void testUser() throws Exception { String url = "/users"; String xml = sendRequest(GET, url, 200); assertTrue(xml.contains("admin")); OnmsUserList list = JaxbUtils.unmarshal(OnmsUserList.class, xml); assertEquals(1, list.getUsers().size()); assertEquals(xml, "admin", list.getUsers().get(0).getUsername()); xml = sendRequest(GET, url + "/admin", 200); assertTrue(xml.contains(">admin<")); sendRequest(GET, url + "/idontexist", 404); }
@GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) public OnmsUserList getUsers() { readLock(); try { return filterUserPasswords(m_userManager.getOnmsUserList()); } catch (final Throwable t) { throw getException(Status.BAD_REQUEST, t); } finally { readUnlock(); } }
UserRestService extends OnmsRestService { @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) public OnmsUserList getUsers() { readLock(); try { return filterUserPasswords(m_userManager.getOnmsUserList()); } catch (final Throwable t) { throw getException(Status.BAD_REQUEST, t); } finally { readUnlock(); } } }
UserRestService extends OnmsRestService { @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) public OnmsUserList getUsers() { readLock(); try { return filterUserPasswords(m_userManager.getOnmsUserList()); } catch (final Throwable t) { throw getException(Status.BAD_REQUEST, t); } finally { readUnlock(); } }  }
UserRestService extends OnmsRestService { @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) public OnmsUserList getUsers() { readLock(); try { return filterUserPasswords(m_userManager.getOnmsUserList()); } catch (final Throwable t) { throw getException(Status.BAD_REQUEST, t); } finally { readUnlock(); } }  @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) OnmsUserList getUsers(); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) @Path("{username}") OnmsUser getUser(@PathParam("username") final String username); @POST @Consumes(MediaType.APPLICATION_XML) Response addUser(final OnmsUser user); @PUT @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Path("{userCriteria}") Response updateUser(@PathParam("userCriteria") final String userCriteria, final MultivaluedMapImpl params); @DELETE @Path("{userCriteria}") Response deleteUser(@PathParam("userCriteria") final String userCriteria); boolean hasEditRights(); }
UserRestService extends OnmsRestService { @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) public OnmsUserList getUsers() { readLock(); try { return filterUserPasswords(m_userManager.getOnmsUserList()); } catch (final Throwable t) { throw getException(Status.BAD_REQUEST, t); } finally { readUnlock(); } }  @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) OnmsUserList getUsers(); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML}) @Path("{username}") OnmsUser getUser(@PathParam("username") final String username); @POST @Consumes(MediaType.APPLICATION_XML) Response addUser(final OnmsUser user); @PUT @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Path("{userCriteria}") Response updateUser(@PathParam("userCriteria") final String userCriteria, final MultivaluedMapImpl params); @DELETE @Path("{userCriteria}") Response deleteUser(@PathParam("userCriteria") final String userCriteria); boolean hasEditRights();  }