String msg = "cannot delete field: " + eH.getMessage(); LOG.error(msg);
String msg = E.GROUPTYPE_FIELDDEL + eH.getMessage(); ErrorLog.error(GroupType.class, msg);
  public void deleteField(GrouperSession s, String name)    throws  InsufficientPrivilegeException,            SchemaException  {    // TODO I should still move more of this to _Validator_    StopWatch sw  = new StopWatch();    sw.start();    Field     f   = FieldFinder.find(name);      Validator.canDeleteFieldFromType(s, this, f);    // Now see if the field is in use    Session hs = null;    try {      int size  = 0;      hs        = HibernateHelper.getSession();      if      (f.getType().equals(FieldType.ATTRIBUTE)) {        Query qry = hs.createQuery(          "from Attribute as a where a.field.name = :name"        );        qry.setCacheable(false);        qry.setString("name", name);        size = qry.list().size();      }      else if (f.getType().equals(FieldType.LIST))      {        Query qry = hs.createQuery(          "from Membership as ms where ms.field.name = :name"        );        qry.setCacheable(false);        qry.setString("name", name);        size = qry.list().size();      }      else {        String msg = "cannot delete field of type: " + f.getType().toString();        LOG.error(msg);        throw new SchemaException(msg);      }      if (size > 0) {        String msg = "cannot field that is in use";        LOG.error(msg);        throw new SchemaException(msg);      }      // And now all validation complete, delete the field      Set fields = this.getFields();      if (fields.remove(f)) {        this.setFields(fields);        HibernateHelper.save(this);        sw.stop();        EL.groupTypeDelField(s, this.getName(), name, sw);      }      else {        String msg = "type unexpectedly does not have field";        LOG.error(msg);        throw new SchemaException(msg);      }    }    catch (HibernateException eH) {      String msg = "cannot delete field: " + eH.getMessage();      LOG.error(msg);      throw new SchemaException(msg, eH);    }    finally {      try {        if (hs != null) { hs.close(); }      }      catch (HibernateException eH) {        throw new SchemaException(eH.getMessage(), eH);      }    }  } // public void addField(s, name, type, read, write, required)