/** * Returns all child groups of a group.<p> * * @param dbc the current database context * @param group the group to get the child for * @param includeSubChildren if set also returns all sub-child groups of the given group * * @return a list of all child <code>{@link CmsGroup}</code> objects * * @throws CmsException if operation was not successful */ public List getChildren(CmsDbContext dbc, CmsGroup group, boolean includeSubChildren) throws CmsException { if (!includeSubChildren) { return m_userDriver.readChildGroups(dbc, group.getName()); } Set allChildren = new TreeSet(); // iterate all child groups Iterator it = m_userDriver.readChildGroups(dbc, group.getName()).iterator(); while (it.hasNext()) { CmsGroup child = (CmsGroup)it.next(); // add the group itself allChildren.add(child); // now get all sub-children for each group allChildren.addAll(getChildren(dbc, child, true)); } return new ArrayList(allChildren); }
/** * Returns all child groups of a group.<p> * * @param dbc the current database context * @param group the group to get the child for * @param includeSubChildren if set also returns all sub-child groups of the given group * * @return a list of all child <code>{@link CmsGroup}</code> objects * * @throws CmsException if operation was not successful */ public List<CmsGroup> getChildren(CmsDbContext dbc, CmsGroup group, boolean includeSubChildren) throws CmsException { if (!includeSubChildren) { return getUserDriver(dbc).readChildGroups(dbc, group.getName()); } Set<CmsGroup> allChildren = new TreeSet<CmsGroup>(); // iterate all child groups Iterator<CmsGroup> it = getUserDriver(dbc).readChildGroups(dbc, group.getName()).iterator(); while (it.hasNext()) { CmsGroup child = it.next(); // add the group itself allChildren.add(child); // now get all sub-children for each group allChildren.addAll(getChildren(dbc, child, true)); } return new ArrayList<CmsGroup>(allChildren); }
List<CmsGroup> groups = getChildren(dbc, group, false); for (CmsGroup parentGroup : groups) { try {
List<CmsGroup> groups = getChildren(dbc, group, false); for (CmsGroup parentGroup : groups) { try {
/** * Returns all child groups of a group.<p> * * This method also returns all sub-child groups of the current group.<p> * * @param context the current request context * @param groupname the name of the group * @param includeSubChildren if set also returns all sub-child groups of the given group * * @return a list of all child <code>{@link CmsGroup}</code> objects or <code>null</code> * * @throws CmsException if operation was not successful */ public List getChildren(CmsRequestContext context, String groupname, boolean includeSubChildren) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); List result = null; try { result = m_driverManager.getChildren(dbc, m_driverManager.readGroup( dbc, CmsOrganizationalUnit.removeLeadingSeparator(groupname)), includeSubChildren); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_GET_CHILD_GROUPS_TRANSITIVE_1, groupname), e); } finally { dbc.clear(); } return result; }
/** * Returns all child groups of a group.<p> * * This method also returns all sub-child groups of the current group.<p> * * @param context the current request context * @param groupname the name of the group * @param includeSubChildren if set also returns all sub-child groups of the given group * * @return a list of all child <code>{@link CmsGroup}</code> objects or <code>null</code> * * @throws CmsException if operation was not successful */ public List<CmsGroup> getChildren(CmsRequestContext context, String groupname, boolean includeSubChildren) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); List<CmsGroup> result = null; try { result = m_driverManager.getChildren( dbc, m_driverManager.readGroup(dbc, CmsOrganizationalUnit.removeLeadingSeparator(groupname)), includeSubChildren); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_GET_CHILD_GROUPS_TRANSITIVE_1, groupname), e); } finally { dbc.clear(); } return result; }
List children = getChildren(dbc, group, false);
List<CmsGroup> children = getChildren(dbc, group, false);