FROM THE BLOG

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.

opss_adf_all_roles

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;

opss_adf_myRole

`Exposing now the service method in our wrapper;

opss_adf_service_wrapper

And with the help of our ConvertingTool to convert idm Role to MyRole;

opss_adf_converting_tool

We finally can consume it through our Pojo Datacontrol in our adf application.

opss_adf_all_users_and_roles

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;

opss_adf_roles_for_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;

opss_adf_myuser

We also created another util class which holds the pair Idm User and its Roles together;

opss_adf_users_roles

After, we implemented our new method in the service class that retrieves all users and their roles;

opss_adf_users_and_roles_retrieval

And exposed it in our wrapper;

opss_adf_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;

opss_adf_data_control

We consume our new DC in our adf application and we are able now to get all users their roles.

opss_adf_run_app

Which, obviously, matches with our Weblogic.

opss_adf_weblogic_user_roles

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.

One comment

  1. Caroline

    on

    Reply

    could you please post the code for convertIdmUserAndRolesList?

Leave a comment

Your email address will not be published. Required fields are marked *