Package org.openiam.srvc.am
Class ResourceDataServiceImpl
- java.lang.Object
-
- org.openiam.srvc.AbstractApiService
-
- org.openiam.srvc.am.ResourceDataServiceImpl
-
- All Implemented Interfaces:
ResourceDataService
@Service("resourceDataService") public class ResourceDataServiceImpl extends AbstractApiService implements ResourceDataService
-
-
Field Summary
-
Fields inherited from class org.openiam.srvc.AbstractApiService
applicationContext, log, rabbitMQSender
-
-
Constructor Summary
Constructors Constructor Description ResourceDataServiceImpl(ResourceQueue queue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResponseaddChildResource(String resourceId, String childResourceId, Set<String> rights, Date startDate, Date endDate)add a child resource to a parentResponseaddGroupToResource(String resourceId, String groupId, Set<String> rightIds, Date startDate, Date endDate)Entitles a Group to a ResourceResponseaddRoleToResource(String resourceId, String roleId, Set<String> rightIds, Date startDate, Date endDate)entitle a Role to a ResourceResponsebulkEntitlementsRequest(MembershipsRequest request)entitle a Groups / Roles / Child resources to a ResourceResponsecanAddUserToResource(String userId, String resourceId)Tells the caller if the user can be entitled to this resourceResponsecanRemoveUserFromResource(String userId, String resourceId)Tells the caller if the user can be disentitled from this resourceintcount(ResourceSearchBean searchBean)count the number of resources based on the searchBeanintcountResourceTypes(ResourceTypeSearchBean searchBean)ResponsedeleteChildResource(String resourceId, String memberResourceId)Removes a child resource from a parentResponsedeleteQuestionnaire(String questionnaireId)ResponsedeleteResource(String resourceId)Deletes a ResoruceResponsedeleteResourceType(String resourceTypeId)ResourceListResponsefindBeans(ResourceSearchBean searchBean, EntitlementsCollection[] dependants, int from, int size)Search a ResourceList<ResourceProp>findResourceProps(ResourceAttributeSearchBean sb, int from, int size)List<ResourceType>findResourceTypes(ResourceTypeSearchBean searchBean, int from, int size)List<String>getAllResourceIds()Method to get all Resource IDs This method should not be called at run-time.List<ResourceType>getAllResourceTypes()Find all resource types.ResourceEntitlementsListResponsegetBulkUsersCommonOneLevelAccess(List<String> userIds, String resourceSearchQuery, UserCollection[] accessTypes, int from, int size)Retrieves the common one-level access for a bulk list of users based on the provided search query and access types.ResourceEntitlementsListResponsegetOneLevelAccess(String userId, String resourceSearchQuery, UserCollection[] accessTypes, int from, int size)Method is used to retrieve all user's applications (content provider, managed systems, manual managed systems, auth providers) with User's roles/groups/organizations (based on accessTypes param)ResourceEntitlementsListResponsegetOneLevelAccessWithResourceTypes(String userId, String resourceSearchQuery, UserCollection[] accessTypes, Set<String> includeResourceTypeIds, Set<String> excludeResourceTypeIds, int from, int size)Method is used to retrieve all user's resources based on resource types defined as #includeResourceTypes and #excludeResourceTypes with User's roles/groups/organizations/resources (based on accessTypes param)QuestionnairesResponsegetQuestionnaireForResource(String questionnaireId)QuestionnairesResponsegetQuestionnairesForResources(List<String> resourceIdList, boolean deepCopy)Search for questionnaires by using resources Ids list.ResourcegetResource(String resourceId)Find a resource.List<Resource>getUserApplicationCategories(String userId, String rootResourceId)Method is user to get Application categories for given user id. since v4.1.8 users should be authorized to see categories.booleanisIndexed(String resourceId)Checks if a Reource has been indexed in the search engine (currently ElasticSearch)booleanisMemberOfAnyEntity(String resourceId)ResponsereindexResource(String id)ResponseremoveGroupToResource(String resourceId, String groupId)Disentitles a Group from a ResourceResponseremoveRoleToResource(String resourceId, String roleId)Disentitles a Resource from a RoleResponsesaveQuestionnaire(Questionnaire questionnaire)ResponsesaveResource(Resource resource)Add a new resource from a transient resource object and sets resourceId in the returned object.ResponsesaveResourceType(ResourceType resourceType)ResourceSelectAccessselectAccess(Set<String> resourceIds, String searchFilter, int size)Method will return the list of resource for given resource ids.ResourcesuggestById(String resourceId)Find a resource in Elasticsearch.ResponsevalidateAddChildResource(String resourceId, String childResourceId, Set<String> rights, Date startDate, Date endDate)ResponsevalidateDelete(String resourceId)ResponsevalidateEdit(Resource resource)Validate if the resource can be created-
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
-
ResourceDataServiceImpl
@Autowired public ResourceDataServiceImpl(ResourceQueue queue)
-
-
Method Detail
-
findResourceProps
public List<ResourceProp> findResourceProps(ResourceAttributeSearchBean sb, int from, int size)
- Specified by:
findResourcePropsin interfaceResourceDataService
-
getResource
public Resource getResource(String resourceId)
Description copied from interface:ResourceDataServiceFind a resource.- Specified by:
getResourcein interfaceResourceDataService- Parameters:
resourceId- the resource id- Returns:
- resource
-
suggestById
public Resource suggestById(String resourceId)
Description copied from interface:ResourceDataServiceFind a resource 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:
suggestByIdin interfaceResourceDataService- Parameters:
resourceId- the resource id- Returns:
- resource
-
count
public int count(ResourceSearchBean searchBean)
Description copied from interface:ResourceDataServicecount the number of resources based on the searchBean- Specified by:
countin interfaceResourceDataService- Returns:
-
findBeans
public ResourceListResponse findBeans(ResourceSearchBean searchBean, EntitlementsCollection[] dependants, int from, int size)
Description copied from interface:ResourceDataServiceSearch a Resource- Specified by:
findBeansin interfaceResourceDataService- Parameters:
searchBean- - search bean, containing search parametersdependants- - collection instead of deep copy flagfrom- - where to startsize- - how many to return- Returns:
- - the search results
-
getUserApplicationCategories
public List<Resource> getUserApplicationCategories(String userId, String rootResourceId)
Description copied from interface:ResourceDataServiceMethod is user to get Application categories for given user id. since v4.1.8 users should be authorized to see categories. If in PROPERTY_FILE_VALUES PROPERTY 'org.openiam.authorization.create.request.disabled' is set to 'true' (default) the old behavior should be expected. All categories will be visible. otherwise User will see categories that he is authorized to. The common OpenIAM RBAC approach is used.- Specified by:
getUserApplicationCategoriesin interfaceResourceDataService- Parameters:
userId- - User Id- Returns:
- List Of resouces with type "APPLICATION CATEGORY";
-
validateEdit
public Response validateEdit(Resource resource)
Description copied from interface:ResourceDataServiceValidate if the resource can be created- Specified by:
validateEditin interfaceResourceDataService- Parameters:
resource- - the Resource- Returns:
-
saveResource
public Response saveResource(Resource resource)
Description copied from interface:ResourceDataServiceAdd a new resource from a transient resource object and sets resourceId in the returned object.- Specified by:
saveResourcein interfaceResourceDataService- Returns:
-
saveResourceType
public Response saveResourceType(ResourceType resourceType)
- Specified by:
saveResourceTypein interfaceResourceDataService
-
getAllResourceTypes
public List<ResourceType> getAllResourceTypes()
Description copied from interface:ResourceDataServiceFind all resource types.- Specified by:
getAllResourceTypesin interfaceResourceDataService- Returns:
- the all resource types
-
validateDelete
public Response validateDelete(String resourceId)
- Specified by:
validateDeletein interfaceResourceDataService
-
deleteResource
public Response deleteResource(String resourceId)
Description copied from interface:ResourceDataServiceDeletes a Resoruce- Specified by:
deleteResourcein interfaceResourceDataService- Parameters:
resourceId- - the resource id- Returns:
-
deleteResourceType
public Response deleteResourceType(String resourceTypeId)
- Specified by:
deleteResourceTypein interfaceResourceDataService
-
addChildResource
public Response addChildResource(String resourceId, String childResourceId, Set<String> rights, Date startDate, Date endDate)
Description copied from interface:ResourceDataServiceadd a child resource to a parent- Specified by:
addChildResourcein interfaceResourceDataService- Parameters:
resourceId- - the parent resource IDchildResourceId- - the child resource ID- Returns:
- a Response Object, with details about the result of the operation
-
deleteChildResource
public Response deleteChildResource(String resourceId, String memberResourceId)
Description copied from interface:ResourceDataServiceRemoves a child resource from a parent- Specified by:
deleteChildResourcein interfaceResourceDataService- Parameters:
resourceId- - the parent resource ID- Returns:
- a Response Object, with details about the result of the operation
-
addGroupToResource
public Response addGroupToResource(String resourceId, String groupId, Set<String> rightIds, Date startDate, Date endDate)
Description copied from interface:ResourceDataServiceEntitles a Group to a Resource- Specified by:
addGroupToResourcein interfaceResourceDataService- Parameters:
resourceId- - the resource IDgroupId- - the group ID- Returns:
- a Response Object, with details about the result of the operation
-
removeGroupToResource
public Response removeGroupToResource(String resourceId, String groupId)
Description copied from interface:ResourceDataServiceDisentitles a Group from a Resource- Specified by:
removeGroupToResourcein interfaceResourceDataService- Parameters:
resourceId- - the resource IDgroupId- - the group ID- Returns:
- a Response Object, with details about the result of the operation
-
addRoleToResource
public Response addRoleToResource(String resourceId, String roleId, Set<String> rightIds, Date startDate, Date endDate)
Description copied from interface:ResourceDataServiceentitle a Role to a Resource- Specified by:
addRoleToResourcein interfaceResourceDataService- Parameters:
resourceId- - the resource IDroleId- - the role ID- Returns:
- a Response Object, with details about the result of the operation
-
bulkEntitlementsRequest
public Response bulkEntitlementsRequest(MembershipsRequest request)
Description copied from interface:ResourceDataServiceentitle a Groups / Roles / Child resources to a Resource- Specified by:
bulkEntitlementsRequestin interfaceResourceDataService- Parameters:
request- - the MembershipsRequest object with resource and group/roles/childs ids- Returns:
- a Response Object, with details about the result of the operation
-
removeRoleToResource
public Response removeRoleToResource(String resourceId, String roleId)
Description copied from interface:ResourceDataServiceDisentitles a Resource from a Role- Specified by:
removeRoleToResourcein interfaceResourceDataService- Parameters:
resourceId- - the Resource IDroleId- - the Role ID- Returns:
- a Response Object, with details about the result of the operation
-
canAddUserToResource
public Response canAddUserToResource(String userId, String resourceId)
Description copied from interface:ResourceDataServiceTells the caller if the user can be entitled to this resource- Specified by:
canAddUserToResourcein interfaceResourceDataService- Parameters:
userId- - the User IDresourceId- - the Resource ID- Returns:
- a Response Object, with details about the result of the operation
-
canRemoveUserFromResource
public Response canRemoveUserFromResource(String userId, String resourceId)
Description copied from interface:ResourceDataServiceTells the caller if the user can be disentitled from this resource- Specified by:
canRemoveUserFromResourcein interfaceResourceDataService- Parameters:
userId- - the User IDresourceId- - the Resource ID- Returns:
- a Response Object, with details about the result of the operation
-
findResourceTypes
public List<ResourceType> findResourceTypes(ResourceTypeSearchBean searchBean, int from, int size)
- Specified by:
findResourceTypesin interfaceResourceDataService
-
countResourceTypes
public int countResourceTypes(ResourceTypeSearchBean searchBean)
- Specified by:
countResourceTypesin interfaceResourceDataService
-
validateAddChildResource
public Response validateAddChildResource(String resourceId, String childResourceId, Set<String> rights, Date startDate, Date endDate)
- Specified by:
validateAddChildResourcein interfaceResourceDataService
-
isMemberOfAnyEntity
public boolean isMemberOfAnyEntity(String resourceId)
- Specified by:
isMemberOfAnyEntityin interfaceResourceDataService
-
isIndexed
public boolean isIndexed(String resourceId)
Description copied from interface:ResourceDataServiceChecks if a Reource has been indexed in the search engine (currently ElasticSearch)- Specified by:
isIndexedin interfaceResourceDataService- Returns:
-
saveQuestionnaire
public Response saveQuestionnaire(Questionnaire questionnaire)
- Specified by:
saveQuestionnairein interfaceResourceDataService
-
deleteQuestionnaire
public Response deleteQuestionnaire(String questionnaireId)
- Specified by:
deleteQuestionnairein interfaceResourceDataService
-
getQuestionnaireForResource
public QuestionnairesResponse getQuestionnaireForResource(String questionnaireId)
- Specified by:
getQuestionnaireForResourcein interfaceResourceDataService
-
getQuestionnairesForResources
public QuestionnairesResponse getQuestionnairesForResources(List<String> resourceIdList, boolean deepCopy)
Description copied from interface:ResourceDataServiceSearch for questionnaires by using resources Ids list.- Specified by:
getQuestionnairesForResourcesin interfaceResourceDataService- Parameters:
resourceIdList- Id list of resourcesdeepCopy- if true answers are fetched- Returns:
- Response with questionnaires that related to given resources
-
reindexResource
public Response reindexResource(String id)
- Specified by:
reindexResourcein interfaceResourceDataService- Parameters:
id- - Resource id for reindex- Returns:
-
selectAccess
public ResourceSelectAccess selectAccess(Set<String> resourceIds, String searchFilter, int size)
Description copied from interface:ResourceDataServiceMethod will return the list of resource for given resource ids. as a separate objects it will return roles mapped by role id and groups mapped by group id. roles and groups are filtered by entitlementsSearchFilter, if it not empty.- Specified by:
selectAccessin interfaceResourceDataService- Parameters:
resourceIds- - set if requested resource idssearchFilter- - filter roles and groups by name (contains match type)- Returns:
- ResourceSelectAccess
-
getOneLevelAccess
public ResourceEntitlementsListResponse getOneLevelAccess(String userId, String resourceSearchQuery, UserCollection[] accessTypes, int from, int size)
Description copied from interface:ResourceDataServiceMethod is used to retrieve all user's applications (content provider, managed systems, manual managed systems, auth providers) with User's roles/groups/organizations (based on accessTypes param)- Specified by:
getOneLevelAccessin interfaceResourceDataService- Parameters:
userId- - userId of user for whom we are looking the appsresourceSearchQuery- - search byKeyNameDTO.getName(), IMPORTANT, notResource#getCoorelatedName()accessTypes- - arrays of entitlement types that bring access to enduser (so if ROLES are set that it will return all apps that are linked to user only based on user's roles). Values that are lister: ROLES,GROUPS,ORGANIZATINSfrom- - paging - index of 1st resultsize- - max results size- Returns:
ResourceEntitlementsListResponseresponse withResourceEntitlementsListResponse#getList()where all apps are listed usingResourceAccessobject.
-
getOneLevelAccessWithResourceTypes
public ResourceEntitlementsListResponse getOneLevelAccessWithResourceTypes(String userId, String resourceSearchQuery, UserCollection[] accessTypes, Set<String> includeResourceTypeIds, Set<String> excludeResourceTypeIds, int from, int size)
Description copied from interface:ResourceDataServiceMethod is used to retrieve all user's resources based on resource types defined as #includeResourceTypes and #excludeResourceTypes with User's roles/groups/organizations/resources (based on accessTypes param)- Specified by:
getOneLevelAccessWithResourceTypesin interfaceResourceDataService- Parameters:
userId- - userId of user for whom we are looking the appsresourceSearchQuery- - filter for resources (MatchType is Contains)accessTypes- - arrays of entitlement types that bring access to enduser (so if ROLES are set that it will return all apps that are linked to user only based on user's roles). Values that are lister:UserCollection.ROLES,UserCollection.GROUPS,UserCollection.ORGANIZATIONS,UserCollection.RESOURCES(UserCollection.RESOURCES- is used to show Direct User's resources)includeResourceTypeIds- - resource Types that have to be included in the searchexcludeResourceTypeIds- - resource Types that have to be excluded from the searchfrom- - paging - index of 1st resultsize- - max results size- Returns:
ResourceEntitlementsListResponseresponse withResourceEntitlementsListResponse#getList()where all apps are listed usingResourceAccessobject.
-
getAllResourceIds
public List<String> getAllResourceIds()
Description copied from interface:ResourceDataServiceMethod to get all Resource 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:
getAllResourceIdsin interfaceResourceDataService- Returns:
-
getBulkUsersCommonOneLevelAccess
public ResourceEntitlementsListResponse getBulkUsersCommonOneLevelAccess(List<String> userIds, String resourceSearchQuery, UserCollection[] accessTypes, int from, int size)
Retrieves the common one-level access for a bulk list of users based on the provided search query and access types.- Specified by:
getBulkUsersCommonOneLevelAccessin interfaceResourceDataService- Parameters:
userIds- the list of user IDs for which to retrieve the accessresourceSearchQuery- the search query for filtering the resourcesaccessTypes- the types of access to retrievefrom- the starting index of the search resultssize- the maximum number of results to retrieve- Returns:
- a ResourceEntitlementsListResponse object containing the list of resources and response status
-
-