Class GroupDataWebServiceImpl

  • All Implemented Interfaces:
    GroupDataWebService

    @Service("groupWS")
    public class GroupDataWebServiceImpl
    extends AbstractApiService
    implements GroupDataWebService
    GroupDataServiceImpl provides a service to manage groups as well as related objects such as Users. Groups are stored in an hierarchical relationship. A user belongs to one or more groups.
    Groups are often modeled after an organizations structure.
    Version:
    2.0
    Author:
    Suneet Shah
    • Constructor Detail

      • GroupDataWebServiceImpl

        @Autowired
        public GroupDataWebServiceImpl​(GroupQueue queue)
    • Method Detail

      • saveGroup

        public Response saveGroup​(Group group)
        Description copied from interface: GroupDataWebService
        This method creates a new group or update existed one. For example:

        Group grp = new Group(); grp.setGrpId(groupId); grp.setGrpName("Test Group");

        grpManager.addGroup(grpValue);

        Specified by:
        saveGroup in interface GroupDataWebService
        Parameters:
        group - - the Group object, which should be created or updated
        Returns:
        - a Response Object. If operation succeed then Response object contains the primary key of saved group otherwise it contains error code.
      • getGroup

        public Group getGroup​(String groupId)
        Description copied from interface: GroupDataWebService
        This method retrieves an existing group object. Dependent objects such as users are not retrieved. Null is returned if the groupId is not found.
        Specified by:
        getGroup in interface GroupDataWebService
        Parameters:
        groupId - - the Group ID
        Returns:
        - a Group Object if it is found, otherwise null will be returned.
      • suggestById

        public Group suggestById​(String id)
        Description copied from interface: GroupDataWebService
        Find a group in Elasticsearch. Significantly faster than going to the database. Use this method when performance is important and/or data integrity is not 100% required, as the database and ES may be out of sync for a period of time
        Specified by:
        suggestById in interface GroupDataWebService
        Parameters:
        id - the role id
        Returns:
        group
      • deleteGroup

        public Response deleteGroup​(String groupId)
        Description copied from interface: GroupDataWebService
        This method removes group from openIAM database for a particular groupId.
        Specified by:
        deleteGroup in interface GroupDataWebService
        Parameters:
        groupId - The id to be removed.
        Returns:
        - a Response Object which contains operation status.
      • findBeans

        public GroupListResponse findBeans​(GroupSearchBean searchBean,
                                           EntitlementsCollection[] dependants,
                                           int from,
                                           int size)
        Description copied from interface: GroupDataWebService
        Return a paged List of Groups based on parameters, which are specified in GroupSearchBean object
        Specified by:
        findBeans in interface GroupDataWebService
        Parameters:
        searchBean - - GroupSearchBean object
        dependants - - collection instead of deep copy flag for AccessRights processor
        from - - where to start in the list
        size - - how many to return
        Returns:
        List of Group objects. Returns null if no groups are found.
      • countBeans

        public int countBeans​(GroupSearchBean searchBean)
        Description copied from interface: GroupDataWebService
        Returns total number of Groups based on parameters, which are specified in GroupSearchBean object
        Specified by:
        countBeans in interface GroupDataWebService
        Parameters:
        searchBean - - GroupSearchBean object
        Returns:
        - Integer, total number of groups based on parameters, which are specified in GroupSearchBean object
      • findGroupsForOwner

        public List<Group> findGroupsForOwner​(GroupSearchBean searchBean,
                                              String ownerId,
                                              int from,
                                              int size)
        Description copied from interface: GroupDataWebService
        Return a paged List of Groups for given groupOwner based on parameters, which are specified in GroupSearchBean object
        Specified by:
        findGroupsForOwner in interface GroupDataWebService
        Parameters:
        searchBean - - GroupSearchBean object
        ownerId - - the User ID who is the owner for the searching groups
        from - - where to start in the list
        size - - how many to return
        Returns:
        List of Group objects. Returns null if no groups are found.
      • countGroupsForOwner

        public int countGroupsForOwner​(GroupSearchBean searchBean,
                                       String ownerId)
        Description copied from interface: GroupDataWebService
        Returns total number of Groups for given groupOwner based on parameters, which are specified in GroupSearchBean object
        Specified by:
        countGroupsForOwner in interface GroupDataWebService
        Parameters:
        searchBean - - GroupSearchBean object
        ownerId - - the User ID who is the owner for the searching groups
        Returns:
        - Integer, total number of groups based on parameters, which are specified in GroupSearchBean object
      • addChildGroup

        public Response addChildGroup​(String groupId,
                                      String childGroupId,
                                      Set<String> rights,
                                      Date startDate,
                                      Date endDate)
        Description copied from interface: GroupDataWebService
        Makes Group specified by childGroupId a child of Group specified by groupId
        Specified by:
        addChildGroup in interface GroupDataWebService
        Parameters:
        groupId - - the Group ID to which another group specified by childGroupId will be added
        childGroupId - - the Group ID which will be added to the group specified by groupId
        Returns:
        a Response Object, containing the status of this operation.
      • removeChildGroup

        public Response removeChildGroup​(String groupId,
                                         String childGroupId)
        Description copied from interface: GroupDataWebService
        Remove Group specified by childGroupId from the membership list of Group specified by groupId
        Specified by:
        removeChildGroup in interface GroupDataWebService
        Parameters:
        groupId - - the Group ID from which another group specified by childGroupId will be deleted
        childGroupId - - the Group ID which will be deleted from the group specified by groupId
        Returns:
        a Response Object, containing the status of this operation.
      • canAddUserToGroup

        public Response canAddUserToGroup​(String userId,
                                          String groupId)
        Description copied from interface: GroupDataWebService
        Checks if User specified by userId can be added to the Group specified by groupId as a member
        Specified by:
        canAddUserToGroup in interface GroupDataWebService
        Parameters:
        userId - - the User ID
        groupId - - the Group ID
        Returns:
        a Response Object, containing the status of this operation. if status is SUCCESS then the User can be added to this Croup
      • canRemoveUserFromGroup

        public Response canRemoveUserFromGroup​(String userId,
                                               String groupId)
        Description copied from interface: GroupDataWebService
        Checks if User specified by userId can be removed from the Group specified by groupId as a member
        Specified by:
        canRemoveUserFromGroup in interface GroupDataWebService
        Parameters:
        userId - - the User ID
        groupId - - the Group ID
        Returns:
        a Response Object, containing the status of this operation. if status is SUCCESS then the User can be removed from this Group
      • getAllGroupIds

        public List<String> getAllGroupIds()
        Description copied from interface: GroupDataWebService
        Method to get all Group IDs This method should not be called at run-time. It is here only for testing purpose.

        At the time of writing, this method is called by the ui-test/stress-test module.

        Specified by:
        getAllGroupIds in interface GroupDataWebService
        Returns:
      • getDetachedForUser

        public GroupListResponse getDetachedForUser​(String userId,
                                                    String name,
                                                    int from,
                                                    int size)
        Description copied from interface: GroupDataWebService
        method is used to detect all user's groups that are not linked with any resources.
        Specified by:
        getDetachedForUser in interface GroupDataWebService
        Parameters:
        userId - - id of User to check detached groups
        name - - name for case INSENSITIVE CONTAINS match search.
        from - - zero based very first result
        Returns:
        - GroupListResponse
      • getWithResources

        public GroupListResponse getWithResources​(String userId,
                                                  GroupSearchBean searchBean,
                                                  Set<String> resourceTypeIds,
                                                  int from,
                                                  int size)
        Description copied from interface: GroupDataWebService
        method is used to get user's groups with entitled resources, filtered by #resourceTypeIds. Resources are returned in Group#getResources() container (only ids).
        Specified by:
        getWithResources in interface GroupDataWebService
        Parameters:
        userId - - user id
        searchBean - - searchBean for objects
        resourceTypeIds - - types of resources to fetch
        from - - zero based very first result
        size - - total size of page.
        Returns:
        GroupListResponse with requested objects