コード例 #1
0
  /**
   * /** Check if the given group exists
   *
   * @param ddManager
   * @param sName
   * @return true if a group with the given name
   * @throws AdminException
   */
  public boolean isGroupExist(DomainDriverManager ddManager, String sName) throws AdminException {
    try {
      ddManager.getOrganizationSchema();

      // build GroupRow to search
      GroupRow searchedGroup = new GroupRow();
      searchedGroup.specificId = null;
      searchedGroup.name = sName;
      searchedGroup.description = null;

      // search for group
      GroupRow[] group = ddManager.getOrganization().group.getAllMatchingGroups(searchedGroup);

      return (group.length > 0);
    } catch (Exception e) {
      throw new AdminException(
          "GroupManager.isGroupExist",
          SilverpeasException.ERROR,
          "admin.EX_ERR_IS_GROUP_EXIST",
          "group name: '" + sName + "'",
          e);
    } finally {
      ddManager.releaseOrganizationSchema();
    }
  }
コード例 #2
0
  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();
    }
  }
コード例 #3
0
  /** 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;
  }
コード例 #4
0
 /**
  * @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();
   }
 }