code: @SuppressWarnings("unchecked")
      public ModelAndView postNewRule(HttpServletRequest request)
              throws IOException {
          Object data = view.deserializeRequest(request);
          
          Collection<Rule> rules;
          if (data instanceof Collection) {
              rules = (Collection<Rule>) data;
          } else if (data instanceof Rule) {
              rules = new LinkedList<Rule>();
              rules.add((Rule)data);
          } else {
              return new ModelAndView(view, "object", new SimpleError(
                      "Expected a rule or collection of rules.", 400));
          }
  
          long id = 0;
          for (Rule rule : rules) {
              rule.setId(null);
  
              String comment = "Created by REST client: "
                      + request.getHeader("User-agent");
              if (request.getHeader("Comment") != null) {
                  comment = request.getHeader("Comment");
              }
  
              String user = "" + request.getRemoteUser() + "@"
                      + request.getRemoteAddr();
              if (request.getHeader("User") != null) {
                  user = request.getHeader("User") + " via " + user;
              }
  
              RuleChange change = new RuleChange(rule, RuleChange.CREATED,
                      new Date(), user, comment);
  
              ruleDao.saveRule(rule, change);
              id = rule.getId();
          }
          return new ModelAndView(new CreatedView("/rules/" + id));
      }
docs: POST /rules
  
  Creates a new rule. The URL of the new rule will be returned in the
  Location header.
  
  You can also POST a list of rules to do batch creation.
  
  Optional extra headers: Comment - A comment that will appear in the
  change log. User - End-user who requested the change.
  
  @param request
  @return
  @throws IOException