@Test public void delReferenceBook() throws IOException { String container = "someContainer"; Main.getWorkMgr().initNetwork(container, null); Main.getWorkMgr() .putReferenceLibrary( new ReferenceLibrary(ImmutableList.of(ReferenceBook.builder("book1").build())), container); try (Response response = getReferenceBookTarget(container, "book1").delete()) { assertThat(response.getStatus(), equalTo(OK.getStatusCode())); } assertThat( Main.getWorkMgr().getReferenceLibrary(container).getReferenceBook("book1").isPresent(), equalTo(false)); try (Response response2 = getReferenceBookTarget(container, "book1").delete()) { assertThat(response2.getStatus(), equalTo(NOT_FOUND.getStatusCode())); } }
@DELETE public Response delReferenceBook() { _logger.infof("WMS2: delReferenceBook '%s' '%s'\n", _network, _bookName); try { ReferenceLibrary library = Main.getWorkMgr().getReferenceLibrary(_network); library.delAddressBook(_bookName); Main.getWorkMgr().putReferenceLibrary(library, _network); return Response.ok().build(); } catch (IOException e) { throw new InternalServerErrorException("Reference library is corrupted"); } catch (NoSuchElementException e) { throw new NotFoundException("Book not found: " + _bookName); } }
ReferenceBookResource { @DELETE public Response delReferenceBook() { _logger.infof("WMS2: delReferenceBook '%s' '%s'\n", _network, _bookName); try { ReferenceLibrary library = Main.getWorkMgr().getReferenceLibrary(_network); library.delAddressBook(_bookName); Main.getWorkMgr().putReferenceLibrary(library, _network); return Response.ok().build(); } catch (IOException e) { throw new InternalServerErrorException("Reference library is corrupted"); } catch (NoSuchElementException e) { throw new NotFoundException("Book not found: " + _bookName); } } }
ReferenceBookResource { @DELETE public Response delReferenceBook() { _logger.infof("WMS2: delReferenceBook '%s' '%s'\n", _network, _bookName); try { ReferenceLibrary library = Main.getWorkMgr().getReferenceLibrary(_network); library.delAddressBook(_bookName); Main.getWorkMgr().putReferenceLibrary(library, _network); return Response.ok().build(); } catch (IOException e) { throw new InternalServerErrorException("Reference library is corrupted"); } catch (NoSuchElementException e) { throw new NotFoundException("Book not found: " + _bookName); } } ReferenceBookResource(String network, String book); }
ReferenceBookResource { @DELETE public Response delReferenceBook() { _logger.infof("WMS2: delReferenceBook '%s' '%s'\n", _network, _bookName); try { ReferenceLibrary library = Main.getWorkMgr().getReferenceLibrary(_network); library.delAddressBook(_bookName); Main.getWorkMgr().putReferenceLibrary(library, _network); return Response.ok().build(); } catch (IOException e) { throw new InternalServerErrorException("Reference library is corrupted"); } catch (NoSuchElementException e) { throw new NotFoundException("Book not found: " + _bookName); } } ReferenceBookResource(String network, String book); @DELETE Response delReferenceBook(); @GET ReferenceBookBean getReferenceBook(); @PUT Response putReferenceBook(ReferenceBookBean referenceBookBean); }
ReferenceBookResource { @DELETE public Response delReferenceBook() { _logger.infof("WMS2: delReferenceBook '%s' '%s'\n", _network, _bookName); try { ReferenceLibrary library = Main.getWorkMgr().getReferenceLibrary(_network); library.delAddressBook(_bookName); Main.getWorkMgr().putReferenceLibrary(library, _network); return Response.ok().build(); } catch (IOException e) { throw new InternalServerErrorException("Reference library is corrupted"); } catch (NoSuchElementException e) { throw new NotFoundException("Book not found: " + _bookName); } } ReferenceBookResource(String network, String book); @DELETE Response delReferenceBook(); @GET ReferenceBookBean getReferenceBook(); @PUT Response putReferenceBook(ReferenceBookBean referenceBookBean);  }