/**
   * @param isInterchange
   * @param id
   * @return if the rule was successfully removed from the store, a response of status 204, else, a
   *     response of status 404.
   */
  @Path("{rule-id}")
  @DELETE
  @Produces(MediaType.TEXT_PLAIN)
  public Response deleteRule(
      @HeaderParam(X_VISION_INTERCHANGE_HEADER) final boolean isInterchange,
      @PathParam("rule-id") final String id) {

    if (store.remove(id)) {
      update.notifyDeletion(isInterchange, id);
      return Response.noContent().build();
    }

    return Response.status(Status.NOT_FOUND).build();
  }
  /** @return a response of status 200. */
  @GET
  @Produces("application/json; qs=0.9")
  public Response listRulesAsJSON() {
    final ArrayList<RuleIdBean> rules = new ArrayList<RuleIdBean>();

    store.forEach(
        new RuleOperation() {
          @Override
          public void run(final VismoRule rule) {
            rules.add(new RuleIdBean(rule.id(), rule.getClass().getSimpleName()));
          }
        });

    return toCORS(Response.ok().entity(rules));
  }
  /**
   * @param isInterchange
   * @param id
   * @param fieldName
   * @param value
   * @return 201 when the update was successful, 404, when no rule corresponds to given id or 400
   *     when the update cannot be performed.
   */
  @PUT
  @Path("{rule-id}/{field}/{value}")
  public Response updateRule(
      @HeaderParam(X_VISION_INTERCHANGE_HEADER) final boolean isInterchange,
      @PathParam("rule-id") final String id,
      @PathParam("field") final String fieldName,
      @PathParam("value") final String value) {
    try {
      store.update(id, fieldName, value);
      update.notifyUpdate(isInterchange, id, fieldName, value);
    } catch (final NoSuchElementException e) {
      return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build();
    } catch (final IllegalArgumentException e) {
      return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
    }

    return toCORS(Response.ok());
  }
  /** @return a response of status 200. */
  @GET
  @Produces(MediaType.TEXT_PLAIN)
  public Response listRulesAsText() {
    final StringBuilder buf = new StringBuilder();

    store.forEach(
        new RuleOperation() {
          @Override
          public void run(final VismoRule rule) {
            buf.append(rule.toString());
            buf.append(": ");
            buf.append(rule.id());
            buf.append("\n");
          }
        });

    return Response.ok(buf.toString()).build();
  }