private void addConnectionGroupDescendants(Collection<ConnectionGroup> parents,List<ObjectPermission.Type> permissions) throws GuacamoleException {
  if (parents.isEmpty())   return;
  Collection<String> childConnectionIdentifiers=new ArrayList<String>();
  Collection<String> childConnectionGroupIdentifiers=new ArrayList<String>();
  for (  ConnectionGroup parent : parents) {
    childConnectionIdentifiers.addAll(parent.getConnectionIdentifiers());
    childConnectionGroupIdentifiers.addAll(parent.getConnectionGroupIdentifiers());
  }
  if (permissions != null && !permissions.isEmpty())   childConnectionIdentifiers=connectionPermissions.getAccessibleObjects(permissions,childConnectionIdentifiers);
  if (!childConnectionIdentifiers.isEmpty()) {
    Collection<Connection> childConnections=connectionDirectory.getAll(childConnectionIdentifiers);
    addConnections(childConnections);
    addConnectionDescendants(childConnections,permissions);
  }
  if (!childConnectionGroupIdentifiers.isEmpty()) {
    Collection<ConnectionGroup> childConnectionGroups=connectionGroupDirectory.getAll(childConnectionGroupIdentifiers);
    addConnectionGroups(childConnectionGroups);
    addConnectionGroupDescendants(childConnectionGroups,permissions);
  }
}

private void addConnectionGroupDescendants ( Collection < ConnectionGroup > parents , List < ObjectPermission . Type > permissions ) throws GuacamoleException { if ( parents . isEmpty ( ) ) return ; Collection < String > childConnectionIdentifiers = new ArrayList < String > ( ) ; Collection < String > childConnectionGroupIdentifiers = new ArrayList < String > ( ) ; for ( ConnectionGroup parent : parents ) { childConnectionIdentifiers . addAll ( parent . getConnectionIdentifiers ( ) ) ; childConnectionGroupIdentifiers . addAll ( parent . getConnectionGroupIdentifiers ( ) ) ; } if ( permissions != null && ! permissions . isEmpty ( ) ) childConnectionIdentifiers = connectionPermissions . getAccessibleObjects ( permissions , childConnectionIdentifiers ) ; if ( ! childConnectionIdentifiers . isEmpty ( ) ) { Collection < Connection > childConnections = connectionDirectory . getAll ( childConnectionIdentifiers ) ; addConnections ( childConnections ) ; addConnectionDescendants ( childConnections , permissions ) ; } if ( ! childConnectionGroupIdentifiers . isEmpty ( ) ) { Collection < ConnectionGroup > childConnectionGroups = connectionGroupDirectory . getAll ( childConnectionGroupIdentifiers ) ; addConnectionGroups ( childConnectionGroups ) ; addConnectionGroupDescendants ( childConnectionGroups , permissions ) ; } }
adds all descendants of the given parent groups to their corresponding parents already stored under root .
