Ejemplo n.º 1
0
  @Override
  public void SetDefaultGroup(PDPGroup group) throws PAPException {

    boolean changesMade = false;
    for (PDPGroup aGroup : groups) {
      if (aGroup.getId().equals(group.getId())) {
        if (!aGroup.isDefaultGroup()) {
          // TODO - since the original code checked for type we do also.
          if (aGroup instanceof StdPDPGroup) {
            ((StdPDPGroup) aGroup).setDefault(true);
            changesMade = true;
          } else {
            throw new IllegalArgumentException(
                "Group in groups of unknown type '" + aGroup.getClass().getName() + "'");
          }
        }
      } else {
        // not the new default group
        if (aGroup.isDefaultGroup()) {
          // TODO - since the original code checked for type we do also.
          if (aGroup instanceof StdPDPGroup) {
            ((StdPDPGroup) aGroup).setDefault(false);
            changesMade = true;
          } else {
            throw new IllegalArgumentException(
                "Group in groups of unknown type '" + aGroup.getClass().getName() + "'");
          }
        }
      }
    }
    if (changesMade) {
      this.doSave();
    }
  }