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 Response
addChildResource(String resourceId, String childResourceId, Set<String> rights, Date startDate, Date endDate)
add a child resource to a parentResponse
addGroupToResource(String resourceId, String groupId, Set<String> rightIds, Date startDate, Date endDate)
Entitles a Group to a ResourceResponse
addRoleToResource(String resourceId, String roleId, Set<String> rightIds, Date startDate, Date endDate)
entitle a Role to a ResourceResponse
bulkEntitlementsRequest(MembershipsRequest request)
entitle a Groups / Roles / Child resources to a ResourceResponse
canAddUserToResource(String userId, String resourceId)
Tells the caller if the user can be entitled to this resourceResponse
canRemoveUserFromResource(String userId, String resourceId)
Tells the caller if the user can be disentitled from this resourceint
count(ResourceSearchBean searchBean)
count the number of resources based on the searchBeanint
countResourceTypes(ResourceTypeSearchBean searchBean)
Response
deleteChildResource(String resourceId, String memberResourceId)
Removes a child resource from a parentResponse
deleteQuestionnaire(String questionnaireId)
Response
deleteResource(String resourceId)
Deletes a ResoruceResponse
deleteResourceType(String resourceTypeId)
ResourceListResponse
findBeans(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.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.ResourceEntitlementsListResponse
getOneLevelAccess(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)ResourceEntitlementsListResponse
getOneLevelAccessWithResourceTypes(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)QuestionnairesResponse
getQuestionnaireForResource(String questionnaireId)
QuestionnairesResponse
getQuestionnairesForResources(List<String> resourceIdList, boolean deepCopy)
Search for questionnaires by using resources Ids list.Resource
getResource(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.boolean
isIndexed(String resourceId)
Checks if a Reource has been indexed in the search engine (currently ElasticSearch)boolean
isMemberOfAnyEntity(String resourceId)
Response
reindexResource(String id)
Response
removeGroupToResource(String resourceId, String groupId)
Disentitles a Group from a ResourceResponse
removeRoleToResource(String resourceId, String roleId)
Disentitles a Resource from a RoleResponse
saveQuestionnaire(Questionnaire questionnaire)
Response
saveResource(Resource resource)
Add a new resource from a transient resource object and sets resourceId in the returned object.Response
saveResourceType(ResourceType resourceType)
ResourceSelectAccess
selectAccess(Set<String> resourceIds, String searchFilter, int size)
Method will return the list of resource for given resource ids.Resource
suggestById(String resourceId)
Find a resource in Elasticsearch.Response
validateAddChildResource(String resourceId, String childResourceId, Set<String> rights, Date startDate, Date endDate)
Response
validateDelete(String resourceId)
Response
validateEdit(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:
findResourceProps
in interfaceResourceDataService
-
getResource
public Resource getResource(String resourceId)
Description copied from interface:ResourceDataService
Find a resource.- Specified by:
getResource
in interfaceResourceDataService
- Parameters:
resourceId
- the resource id- Returns:
- resource
-
suggestById
public Resource suggestById(String resourceId)
Description copied from interface:ResourceDataService
Find 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:
suggestById
in interfaceResourceDataService
- Parameters:
resourceId
- the resource id- Returns:
- resource
-
count
public int count(ResourceSearchBean searchBean)
Description copied from interface:ResourceDataService
count the number of resources based on the searchBean- Specified by:
count
in interfaceResourceDataService
- Returns:
-
findBeans
public ResourceListResponse findBeans(ResourceSearchBean searchBean, EntitlementsCollection[] dependants, int from, int size)
Description copied from interface:ResourceDataService
Search a Resource- Specified by:
findBeans
in 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:ResourceDataService
Method 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:
getUserApplicationCategories
in interfaceResourceDataService
- Parameters:
userId
- - User Id- Returns:
- List Of resouces with type "APPLICATION CATEGORY";
-
validateEdit
public Response validateEdit(Resource resource)
Description copied from interface:ResourceDataService
Validate if the resource can be created- Specified by:
validateEdit
in interfaceResourceDataService
- Parameters:
resource
- - the Resource- Returns:
-
saveResource
public Response saveResource(Resource resource)
Description copied from interface:ResourceDataService
Add a new resource from a transient resource object and sets resourceId in the returned object.- Specified by:
saveResource
in interfaceResourceDataService
- Returns:
-
saveResourceType
public Response saveResourceType(ResourceType resourceType)
- Specified by:
saveResourceType
in interfaceResourceDataService
-
getAllResourceTypes
public List<ResourceType> getAllResourceTypes()
Description copied from interface:ResourceDataService
Find all resource types.- Specified by:
getAllResourceTypes
in interfaceResourceDataService
- Returns:
- the all resource types
-
validateDelete
public Response validateDelete(String resourceId)
- Specified by:
validateDelete
in interfaceResourceDataService
-
deleteResource
public Response deleteResource(String resourceId)
Description copied from interface:ResourceDataService
Deletes a Resoruce- Specified by:
deleteResource
in interfaceResourceDataService
- Parameters:
resourceId
- - the resource id- Returns:
-
deleteResourceType
public Response deleteResourceType(String resourceTypeId)
- Specified by:
deleteResourceType
in interfaceResourceDataService
-
addChildResource
public Response addChildResource(String resourceId, String childResourceId, Set<String> rights, Date startDate, Date endDate)
Description copied from interface:ResourceDataService
add a child resource to a parent- Specified by:
addChildResource
in 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:ResourceDataService
Removes a child resource from a parent- Specified by:
deleteChildResource
in 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:ResourceDataService
Entitles a Group to a Resource- Specified by:
addGroupToResource
in 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:ResourceDataService
Disentitles a Group from a Resource- Specified by:
removeGroupToResource
in 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:ResourceDataService
entitle a Role to a Resource- Specified by:
addRoleToResource
in 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:ResourceDataService
entitle a Groups / Roles / Child resources to a Resource- Specified by:
bulkEntitlementsRequest
in 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:ResourceDataService
Disentitles a Resource from a Role- Specified by:
removeRoleToResource
in 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:ResourceDataService
Tells the caller if the user can be entitled to this resource- Specified by:
canAddUserToResource
in 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:ResourceDataService
Tells the caller if the user can be disentitled from this resource- Specified by:
canRemoveUserFromResource
in 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:
findResourceTypes
in interfaceResourceDataService
-
countResourceTypes
public int countResourceTypes(ResourceTypeSearchBean searchBean)
- Specified by:
countResourceTypes
in interfaceResourceDataService
-
validateAddChildResource
public Response validateAddChildResource(String resourceId, String childResourceId, Set<String> rights, Date startDate, Date endDate)
- Specified by:
validateAddChildResource
in interfaceResourceDataService
-
isMemberOfAnyEntity
public boolean isMemberOfAnyEntity(String resourceId)
- Specified by:
isMemberOfAnyEntity
in interfaceResourceDataService
-
isIndexed
public boolean isIndexed(String resourceId)
Description copied from interface:ResourceDataService
Checks if a Reource has been indexed in the search engine (currently ElasticSearch)- Specified by:
isIndexed
in interfaceResourceDataService
- Returns:
-
saveQuestionnaire
public Response saveQuestionnaire(Questionnaire questionnaire)
- Specified by:
saveQuestionnaire
in interfaceResourceDataService
-
deleteQuestionnaire
public Response deleteQuestionnaire(String questionnaireId)
- Specified by:
deleteQuestionnaire
in interfaceResourceDataService
-
getQuestionnaireForResource
public QuestionnairesResponse getQuestionnaireForResource(String questionnaireId)
- Specified by:
getQuestionnaireForResource
in interfaceResourceDataService
-
getQuestionnairesForResources
public QuestionnairesResponse getQuestionnairesForResources(List<String> resourceIdList, boolean deepCopy)
Description copied from interface:ResourceDataService
Search for questionnaires by using resources Ids list.- Specified by:
getQuestionnairesForResources
in 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:
reindexResource
in interfaceResourceDataService
- Parameters:
id
- - Resource id for reindex- Returns:
-
selectAccess
public ResourceSelectAccess selectAccess(Set<String> resourceIds, String searchFilter, int size)
Description copied from interface:ResourceDataService
Method 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:
selectAccess
in 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:ResourceDataService
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)- Specified by:
getOneLevelAccess
in 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:
ResourceEntitlementsListResponse
response withResourceEntitlementsListResponse#getList()
where all apps are listed usingResourceAccess
object.
-
getOneLevelAccessWithResourceTypes
public ResourceEntitlementsListResponse getOneLevelAccessWithResourceTypes(String userId, String resourceSearchQuery, UserCollection[] accessTypes, Set<String> includeResourceTypeIds, Set<String> excludeResourceTypeIds, int from, int size)
Description copied from interface:ResourceDataService
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)- Specified by:
getOneLevelAccessWithResourceTypes
in 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:
ResourceEntitlementsListResponse
response withResourceEntitlementsListResponse#getList()
where all apps are listed usingResourceAccess
object.
-
getAllResourceIds
public List<String> getAllResourceIds()
Description copied from interface:ResourceDataService
Method 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:
getAllResourceIds
in 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:
getBulkUsersCommonOneLevelAccess
in 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
-
-