/** Convert Group to GroupRow */ private GroupRow group2GroupRow(Group group) { GroupRow gr = new GroupRow(); gr.id = idAsInt(group.getId()); gr.specificId = group.getSpecificId(); gr.domainId = idAsInt(group.getDomainId()); gr.superGroupId = idAsInt(group.getSuperGroupId()); gr.name = group.getName(); gr.description = group.getDescription(); gr.rule = group.getRule(); return gr; }
public String[] searchGroupsIds( DomainDriverManager ddManager, boolean isRootGroup, String componentId, String[] aProfileId, Group modelGroup) throws AdminException { try { // Get organization ddManager.getOrganizationSchema(); GroupRow model = group2GroupRow(modelGroup); // The Ids could be equal to -1 !!!! Put it to -2 if null if (!StringUtil.isDefined(modelGroup.getId())) { model.id = -2; } if (!StringUtil.isDefined(modelGroup.getDomainId())) { model.domainId = -2; } if (!StringUtil.isDefined(modelGroup.getSuperGroupId())) { model.superGroupId = -2; } int[] aRoleId = null; if (aProfileId != null) { aRoleId = new int[aProfileId.length]; for (int i = 0; i < aProfileId.length; i++) { aRoleId[i] = idAsInt(aProfileId[i]); } } // Get groups return ddManager .getOrganization() .group .searchGroupsIds(isRootGroup, idAsInt(componentId), aRoleId, model); } catch (Exception e) { throw new AdminException( "GroupManager.searchGroupsIdsInGroup", SilverpeasException.ERROR, "admin.EX_ERR_GET_GROUPS_OF_DOMAIN", e); } finally { ddManager.releaseOrganizationSchema(); } }
/** * @param ddManager * @param modelGroup * @param isAnd * @return * @throws AdminException */ public Group[] searchGroups(DomainDriverManager ddManager, Group modelGroup, boolean isAnd) throws AdminException { try { // Get organization ddManager.getOrganizationSchema(); GroupRow model = group2GroupRow(modelGroup); // The Ids could be equal to -1 !!!! Put it to -2 if null if (!StringUtil.isDefined((modelGroup.getId()))) { model.id = -2; } if (!StringUtil.isDefined(modelGroup.getDomainId())) { model.domainId = -2; } if (!StringUtil.isDefined(modelGroup.getSuperGroupId())) { model.superGroupId = -2; } // Get groups GroupRow[] grs = ddManager.getOrganization().group.searchGroups(model, isAnd); // Convert GroupRow objects in Group Object Group[] groups = new Group[grs.length]; for (int nI = 0; nI < grs.length; nI++) { groups[nI] = groupRow2Group(grs[nI]); // Get the selected users for this group setDirectUsersOfGroup(ddManager, groups[nI]); } return groups; } catch (Exception e) { throw new AdminException( "GroupManager.searchGroups", SilverpeasException.ERROR, "admin.EX_ERR_GET_GROUPS_OF_DOMAIN", e); } finally { ddManager.releaseOrganizationSchema(); } }