Package org.openiam.srvc.am
Class GroupDataWebServiceImpl
- java.lang.Object
-
- org.openiam.srvc.AbstractApiService
-
- org.openiam.srvc.am.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
-
-
Field Summary
-
Fields inherited from class org.openiam.srvc.AbstractApiService
applicationContext, log, rabbitMQSender
-
-
Constructor Summary
Constructors Constructor Description GroupDataWebServiceImpl(GroupQueue queue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Response
addChildGroup(String groupId, String childGroupId, Set<String> rights, Date startDate, Date endDate)
Makes Group specified by childGroupId a child of Group specified by groupIdResponse
canAddUserToGroup(String userId, String groupId)
Checks if User specified by userId can be added to the Group specified by groupId as a memberResponse
canRemoveUserFromGroup(String userId, String groupId)
Checks if User specified by userId can be removed from the Group specified by groupId as a memberint
countBeans(GroupSearchBean searchBean)
Returns total number of Groups based on parameters, which are specified in GroupSearchBean objectint
countGroupsForOwner(GroupSearchBean searchBean, String ownerId)
Returns total number of Groups for given groupOwner based on parameters, which are specified in GroupSearchBean objectResponse
deleteGroup(String groupId)
This method removes group from openIAM database for a particular groupId.GroupListResponse
findBeans(GroupSearchBean searchBean, EntitlementsCollection[] dependants, int from, int size)
Return a paged List of Groups based on parameters, which are specified in GroupSearchBean objectList<Group>
findGroupsForOwner(GroupSearchBean searchBean, String ownerId, int from, int size)
Return a paged List of Groups for given groupOwner based on parameters, which are specified in GroupSearchBean objectvoid
forceSweepUserCountCache()
force refresh cache which holds count of users assigned to groups and max number limitList<String>
getAllGroupIds()
Method to get all Group IDs This method should not be called at run-time.GroupListResponse
getDetachedForUser(String userId, String name, int from, int size)
method is used to detect all user's groups that are not linked with any resources.Group
getGroup(String groupId)
This method retrieves an existing group object.List<String>
getPossibleAttributeNames()
GroupListResponse
getWithResources(String userId, GroupSearchBean searchBean, Set<String> resourceTypeIds, int from, int size)
method is used to get user's groups with entitled resources, filtered by #resourceTypeIds.boolean
hasAttachedEntities(String groupId)
Does this group have any children?Response
reindexGroup(String id)
Response
removeChildGroup(String groupId, String childGroupId)
Remove Group specified by childGroupId from the membership list of Group specified by groupIdResponse
removeRoleFromGroup(String roleId, String groupId)
Response
saveBulkGroup(EntitlementBulkRequest entitlementBulkRequest)
Bulk operation on Group objects, this method with save groups in bulkResponse
saveGroup(Group group)
This method creates a new group or update existed one.SaveTemplateProfileResponse
saveGroupRequest(GroupRequestModel request)
Group
suggestById(String id)
Find a group in Elasticsearch.Response
validateDelete(String groupId)
Response
validateEdit(Group group)
SaveTemplateProfileResponse
validateGroupRequest(GroupRequestModel request)
Response
validateGroupToGroupAddition(String groupId, String childGroupId, Set<String> rights, Date startDate, Date endDate)
-
Methods inherited from class org.openiam.srvc.AbstractApiService
broadcast, crudRequest, getBooleanValue, getIntValue, getIntValue, getRabbitMqQueue, getResponse, getResponse, getValue, getValue, getValueList, getValueList, idRequest, manageApiRequest, manageApiRequest, manageCrudApiRequest, manageCrudApiRequest, manageCrudApiRequest, manageCrudApiRequest, membershipRequestProcessing, membershipRequestProcessing, publish, publish, sendAsync, sendAsync
-
-
-
-
Constructor Detail
-
GroupDataWebServiceImpl
@Autowired public GroupDataWebServiceImpl(GroupQueue queue)
-
-
Method Detail
-
validateEdit
public Response validateEdit(Group group)
- Specified by:
validateEdit
in interfaceGroupDataWebService
-
validateDelete
public Response validateDelete(String groupId)
- Specified by:
validateDelete
in interfaceGroupDataWebService
-
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 interfaceGroupDataWebService
- 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 interfaceGroupDataWebService
- 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 interfaceGroupDataWebService
- 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 interfaceGroupDataWebService
- 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 interfaceGroupDataWebService
- Parameters:
searchBean
- - GroupSearchBean objectdependants
- - collection instead of deep copy flag for AccessRights processorfrom
- - where to start in the listsize
- - 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 interfaceGroupDataWebService
- 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 interfaceGroupDataWebService
- Parameters:
searchBean
- - GroupSearchBean objectownerId
- - the User ID who is the owner for the searching groupsfrom
- - where to start in the listsize
- - 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 interfaceGroupDataWebService
- Parameters:
searchBean
- - GroupSearchBean objectownerId
- - 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 interfaceGroupDataWebService
- Parameters:
groupId
- - the Group ID to which another group specified by childGroupId will be addedchildGroupId
- - 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 interfaceGroupDataWebService
- Parameters:
groupId
- - the Group ID from which another group specified by childGroupId will be deletedchildGroupId
- - 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 interfaceGroupDataWebService
- Parameters:
userId
- - the User IDgroupId
- - 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 interfaceGroupDataWebService
- Parameters:
userId
- - the User IDgroupId
- - 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
-
validateGroupToGroupAddition
public Response validateGroupToGroupAddition(String groupId, String childGroupId, Set<String> rights, Date startDate, Date endDate)
- Specified by:
validateGroupToGroupAddition
in interfaceGroupDataWebService
-
hasAttachedEntities
public boolean hasAttachedEntities(String groupId)
Description copied from interface:GroupDataWebService
Does this group have any children?- Specified by:
hasAttachedEntities
in interfaceGroupDataWebService
- Returns:
-
removeRoleFromGroup
public Response removeRoleFromGroup(String roleId, String groupId)
- Specified by:
removeRoleFromGroup
in interfaceGroupDataWebService
-
saveGroupRequest
public SaveTemplateProfileResponse saveGroupRequest(GroupRequestModel request)
- Specified by:
saveGroupRequest
in interfaceGroupDataWebService
-
validateGroupRequest
public SaveTemplateProfileResponse validateGroupRequest(GroupRequestModel request)
- Specified by:
validateGroupRequest
in interfaceGroupDataWebService
-
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 interfaceGroupDataWebService
- Returns:
-
reindexGroup
public Response reindexGroup(String id)
- Specified by:
reindexGroup
in interfaceGroupDataWebService
- Parameters:
id
- - Group id for reindex- 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 interfaceGroupDataWebService
- Parameters:
userId
- - id of User to check detached groupsname
- - 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 inGroup#getResources()
container (only ids).- Specified by:
getWithResources
in interfaceGroupDataWebService
- Parameters:
userId
- - user idsearchBean
- - searchBean for objectsresourceTypeIds
- - types of resources to fetchfrom
- - zero based very first resultsize
- - total size of page.- Returns:
GroupListResponse
with requested objects
-
getPossibleAttributeNames
public List<String> getPossibleAttributeNames()
- Specified by:
getPossibleAttributeNames
in interfaceGroupDataWebService
-
saveBulkGroup
public Response saveBulkGroup(EntitlementBulkRequest entitlementBulkRequest)
Description copied from interface:GroupDataWebService
Bulk operation on Group objects, this method with save groups in bulk- Specified by:
saveBulkGroup
in interfaceGroupDataWebService
- Parameters:
entitlementBulkRequest
- - EntitlementBulkRequest object that will be processed.
-
forceSweepUserCountCache
public void forceSweepUserCountCache()
Description copied from interface:GroupDataWebService
force refresh cache which holds count of users assigned to groups and max number limit- Specified by:
forceSweepUserCountCache
in interfaceGroupDataWebService
-
-