@DELETE @Path("{sourceObj}/{source}/{rel}/{targetObj}") @Consumes({BASE_XML_MEDIA_TYPE, BASE_JSON_MEDIA_TYPE}) @Produces({BASE_XML_MEDIA_TYPE, BASE_JSON_MEDIA_TYPE}) public Response remove( @PathParam("sourceObj") String sourceDescription, @PathParam("source") String sourceId, @PathParam("rel") String relationship, @PathParam("targetObj") String targetDescription, ResourceLink link) { Repository<? extends Identifiable> sourceRepo = locateRepository(repositories, sourceDescription); Repository<? extends Identifiable> targetRepo = locateRepository(repositories, targetDescription); if(sourceRepo == null || targetRepo == null) { return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } // TODO: quick and dirty String targetId = findLastId(link.getHref()); Identifiable source = sourceRepo.get(sourceId); Identifiable target = targetRepo.get(targetId); if(source == null || target == null) { return Response.status(Status.NOT_FOUND).build(); } repositry.remove(source, relationship, target); return Response.noContent().build(); }
@PATCH @Path("{sourceObj}/{source}/{rel}/{targetObj}") @Consumes({BASE_XML_MEDIA_TYPE, BASE_JSON_MEDIA_TYPE}) @Produces({BASE_XML_MEDIA_TYPE, BASE_JSON_MEDIA_TYPE}) public Response add( @PathParam("sourceObj") String sourceDescription, @PathParam("source") String sourceId, @PathParam("rel") String relationship, @PathParam("targetObj") String targetDescription, ResourceLink link) { Repository<? extends Identifiable> sourceRepo = locateRepository(repositories, sourceDescription); Repository<? extends Identifiable> targetRepo = locateRepository(repositories, targetDescription); if(sourceRepo == null || targetRepo == null) { return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } // TODO: quick and dirty String targetId = findLastId(link.getHref()); Identifiable source = sourceRepo.get(sourceId); Identifiable target = targetRepo.get(targetId); if(source == null || target == null) { return Response.status(Status.NOT_FOUND).build(); } Relation relation = repositry.add(source, relationship, target); return Response.ok(relation).build(); }