/** * Get group information with the given id from Silverpeas * * @param ddManager * @param sGroupId * @return * @throws AdminException */ public Group getGroup(DomainDriverManager ddManager, String sGroupId) throws AdminException { try { ddManager.getOrganizationSchema(); GroupRow gr = ddManager.getOrganization().group.getGroup(idAsInt(sGroupId)); Group group = new Group(); if (gr != null) { group.setId(idAsString(gr.id)); group.setSpecificId(gr.specificId); group.setDomainId(idAsString(gr.domainId)); group.setSuperGroupId(idAsString(gr.superGroupId)); group.setName(gr.name); group.setDescription(gr.description); group.setRule(gr.rule); } // Get the selected users for this group setDirectUsersOfGroup(ddManager, group); return group; } catch (Exception e) { throw new AdminException( "GroupManager.getGroup", SilverpeasException.ERROR, "admin.EX_ERR_GET_GROUP", "group Id: '" + sGroupId + "'", e); } finally { ddManager.releaseOrganizationSchema(); } }
/** Convert GroupRow to Group */ private Group groupRow2Group(GroupRow gr) { Group group = new Group(); if (gr != null) { group.setId(idAsString(gr.id)); group.setSpecificId(gr.specificId); group.setDomainId(idAsString(gr.domainId)); group.setSuperGroupId(idAsString(gr.superGroupId)); group.setName(gr.name); group.setDescription(gr.description); group.setRule(gr.rule); } return group; }
/** * return group with given id (contains list of user ids for this group) * * @param groupId * @return Group */ @Override public Group getGroup(String groupId) throws Exception { Group group = null; try { // Set the OrganizationSchema (if not already done) getOrganizationSchema(); // Get the user information GroupRow gr = getOrganization().group.getGroup(idAsInt(groupId)); if (gr == null) { throw new AdminException( "DomainDriverManager.getGroup", SilverpeasException.ERROR, "admin.EX_ERR_GROUP_NOT_FOUND", "group Id: '" + groupId + "'"); } // Get a DomainDriver instance DomainDriver domainDriver = this.getDomainDriver(gr.domainId); // Get Group detail from specific domain group = domainDriver.getGroup(gr.specificId); // Fill silverpeas info of group details group.setId(groupId); group.setSpecificId(gr.specificId); group.setDomainId(idAsString(gr.domainId)); } catch (AdminException e) { throw new AdminException( "DomainDriverManager.getGroup", SilverpeasException.ERROR, "admin.EX_ERR_GET_GROUP", "group Id: '" + groupId + "'", e); } finally { releaseOrganizationSchema(); } return group; }