/**
   * Handle most user interactions
   *
   * @param custId The id of the customer. Can be null, which is why we don't bind it
   * @param verb What to do, can be insert, update or delete
   * @param type The type on which to act, can be Customer, Order or LineItem
   * @param id The id of the object on which to act
   * @param att The attribute on which to act
   * @param value The value to which to set it
   */
  public static void index(
      String custId, String verb, String type, String id, String att, String value) {

    if (verb == null || verb.trim().length() == 0) {
      showPage(custId, null);
      return;
    }

    if ("update".equals(verb)) processUpdate(type, id, att, value);
    else if ("insert".equals(verb)) processInsert(custId, type, id, att, value);
    else if ("delete".equals(verb)) processDelete(type, id);

    // We want to know if there is a constraint violation on commit, that's why we commit here
    // rather than let Play do it for us. There may be a better way of doing this, but I don't know
    // Play well enough to determine that.
    String errMsg = null;
    try {
      JPA.em().getTransaction().commit();
    } catch (RollbackException ex) {
      if (ex.getCause() != null
          && ex.getCause().getCause() != null
          && (ex.getCause().getCause() instanceof ConstraintException)) {
        ConstraintException cex = (ConstraintException) ex.getCause().getCause();
        errMsg = cex.getMessage() + " - your last change has been rolled back.";
      }
    }

    showPage(custId, errMsg);
  }