code: private URI getHasMemberFromPatch(final HttpServletRequest request) throws IOException {
          final String sparqlString = IOUtils.toString(request.getInputStream(), UTF_8);
          final String baseURI = request.getRequestURL().toString().replace(request.getContextPath(), "").replaceAll(
                  request.getPathInfo(), "").replaceAll("rest$", "");
          final UpdateRequest sparqlUpdate = UpdateFactory.create(sparqlString);
          // The INSERT|DELETE DATA quads
          final Stream<Quad> insertDeleteData = sparqlUpdate.getOperations().stream()
                  .filter(update -> update instanceof UpdateData)
                  .map(update -> (UpdateData) update)
                  .flatMap(update -> update.getQuads().stream());
          // Get the UpdateModify instance to re-use below.
          final List<UpdateModify> updateModifyStream = sparqlUpdate.getOperations().stream()
                  .filter(update -> (update instanceof UpdateModify))
                  .peek(update -> log.debug("Inspecting update statement for DELETE clause: {}", update.toString()))
                  .map(update -> (UpdateModify) update)
                  .collect(toList());
          // The INSERT {} WHERE {} quads
          final Stream<Quad> insertQuadData = updateModifyStream.stream()
                  .flatMap(update -> update.getInsertQuads().stream());
          // The DELETE {} WHERE {} quads
          final Stream<Quad> deleteQuadData = updateModifyStream.stream()
                  .flatMap(update -> update.getDeleteQuads().stream());
          // The ldp:membershipResource triples.
          return Stream.concat(Stream.concat(insertDeleteData, insertQuadData), deleteQuadData)
                  .filter(update -> update.getPredicate().equals(MEMBERSHIP_RESOURCE.asNode()) && update.getObject()
                          .isURI())
                  .map(update -> update.getObject().getURI())
                  .map(update -> update.replace("file:///", baseURI))
                  .findFirst().map(URI::create).orElse(null);
      }
docs: Get the membershipRelation from a PATCH request
  
  @param request the http request
  @return URI of the first ldp:membershipRelation object.
  @throws IOException converting the request body to a string.