@Test public void deleteFamilyIgnoresMissingFamily() { when(this.familyRepository.get(FAMILY_ID)).thenReturn(null); Response response = this.resource.deleteFamily(FAMILY_ID, false); Assert.assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); }
@Override public Response deleteFamily(String id, Boolean deleteMembers) { this.logger.warn("Deleting family record [{}] via REST, deleteAllMembers = [{}]", id, deleteMembers); Family family = this.repository.get(id); if (family == null) { this.logger.warn(NO_SUCH_FAMILY_ERROR_MESSAGE, id); return Response.status(Status.NOT_FOUND).build(); } if (!this.familyTools.currentUserCanDeleteFamily(id, deleteMembers)) { this.logger.error("Delete access denied to user [{}] for family record [{}] with deleteMemebers=[{}]", this.users.getCurrentUser(), id, deleteMembers); return Response.status(Status.FORBIDDEN).build(); } if (!this.familyTools.deleteFamily(id, deleteMembers)) { return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } this.logger.warn("Deleted family record [{}]", id); return Response.noContent().build(); }
DefaultFamilyResourceImpl extends XWikiResource implements FamilyResource { @Override public Response deleteFamily(String id, Boolean deleteMembers) { this.logger.warn("Deleting family record [{}] via REST, deleteAllMembers = [{}]", id, deleteMembers); Family family = this.repository.get(id); if (family == null) { this.logger.warn(NO_SUCH_FAMILY_ERROR_MESSAGE, id); return Response.status(Status.NOT_FOUND).build(); } if (!this.familyTools.currentUserCanDeleteFamily(id, deleteMembers)) { this.logger.error("Delete access denied to user [{}] for family record [{}] with deleteMemebers=[{}]", this.users.getCurrentUser(), id, deleteMembers); return Response.status(Status.FORBIDDEN).build(); } if (!this.familyTools.deleteFamily(id, deleteMembers)) { return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } this.logger.warn("Deleted family record [{}]", id); return Response.noContent().build(); } }
DefaultFamilyResourceImpl extends XWikiResource implements FamilyResource { @Override public Response deleteFamily(String id, Boolean deleteMembers) { this.logger.warn("Deleting family record [{}] via REST, deleteAllMembers = [{}]", id, deleteMembers); Family family = this.repository.get(id); if (family == null) { this.logger.warn(NO_SUCH_FAMILY_ERROR_MESSAGE, id); return Response.status(Status.NOT_FOUND).build(); } if (!this.familyTools.currentUserCanDeleteFamily(id, deleteMembers)) { this.logger.error("Delete access denied to user [{}] for family record [{}] with deleteMemebers=[{}]", this.users.getCurrentUser(), id, deleteMembers); return Response.status(Status.FORBIDDEN).build(); } if (!this.familyTools.deleteFamily(id, deleteMembers)) { return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } this.logger.warn("Deleted family record [{}]", id); return Response.noContent().build(); }  }
DefaultFamilyResourceImpl extends XWikiResource implements FamilyResource { @Override public Response deleteFamily(String id, Boolean deleteMembers) { this.logger.warn("Deleting family record [{}] via REST, deleteAllMembers = [{}]", id, deleteMembers); Family family = this.repository.get(id); if (family == null) { this.logger.warn(NO_SUCH_FAMILY_ERROR_MESSAGE, id); return Response.status(Status.NOT_FOUND).build(); } if (!this.familyTools.currentUserCanDeleteFamily(id, deleteMembers)) { this.logger.error("Delete access denied to user [{}] for family record [{}] with deleteMemebers=[{}]", this.users.getCurrentUser(), id, deleteMembers); return Response.status(Status.FORBIDDEN).build(); } if (!this.familyTools.deleteFamily(id, deleteMembers)) { return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } this.logger.warn("Deleted family record [{}]", id); return Response.noContent().build(); }  @Override Response getFamily(String id); @Override Response deleteFamily(String id, Boolean deleteMembers); }
DefaultFamilyResourceImpl extends XWikiResource implements FamilyResource { @Override public Response deleteFamily(String id, Boolean deleteMembers) { this.logger.warn("Deleting family record [{}] via REST, deleteAllMembers = [{}]", id, deleteMembers); Family family = this.repository.get(id); if (family == null) { this.logger.warn(NO_SUCH_FAMILY_ERROR_MESSAGE, id); return Response.status(Status.NOT_FOUND).build(); } if (!this.familyTools.currentUserCanDeleteFamily(id, deleteMembers)) { this.logger.error("Delete access denied to user [{}] for family record [{}] with deleteMemebers=[{}]", this.users.getCurrentUser(), id, deleteMembers); return Response.status(Status.FORBIDDEN).build(); } if (!this.familyTools.deleteFamily(id, deleteMembers)) { return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } this.logger.warn("Deleted family record [{}]", id); return Response.noContent().build(); }  @Override Response getFamily(String id); @Override Response deleteFamily(String id, Boolean deleteMembers);  }