ADF Tips: OPSS User and Role API – Part 2; Retrieving all roles + all user roles
Last week, we wrote the first part of OPSS User and Role API which was basically, a short introduction and a short demo of how to use the API within an ADF Application by retrieving all users from the Weblogic Authenticator. This post will continue the demonstration by retrieving all roles and furthermore, all roles assigned to each user.
To retrieve all roles, we followed the same strategy and almost the same code used to retrieve all users.
Because for the purposes of this demo we are just interested in the role name and description, we created a new business object called MyRole, having only those 2 attributes;
`Exposing now the service method in our wrapper;
And with the help of our ConvertingTool to convert idm Role to MyRole;
We finally can consume it through our Pojo Datacontrol in our adf application.
Now, in order to get all roles assigned to an user in we added a new method in our service class that retrieves all the roles for a given user;
Because we were interested to have a master detail relationship User-Roles we added a new field to our business object MyUser which is a list of MyRole;
We also created another util class which holds the pair Idm User and its Roles together;
After, we implemented our new method in the service class that retrieves all users and their roles;
And exposed it in our wrapper;
Ideally, we would just get rid of the previous getAllUsers implementation but for the sake of the demo, we just left it as a different collection in our DC;
We consume our new DC in our adf application and we are able now to get all users their roles.
Which, obviously, matches with our Weblogic.
Again, apologies if some parts are not detailed explained but as stated before, the whole idea is to illustrate what the API can do for you.
Caroline
oncould you please post the code for convertIdmUserAndRolesList?