This discussion is archived
9 Replies Latest reply: Apr 20, 2013 10:48 AM by 681829 RSS

Role Updation-FDI api

694425 Newbie
Currently Being Moderated
Hi all,
i am trying to update the existing role through Java FDI api(albpmfdi.jar) .I use FuegoFDIAdmin.admin.addRolesToUser(soeId, roles, fuegoParameter, 95) to addroles to user.I dont find any similar utilities to update the existing role.I want to update the permission alone in the existing role.

DirHumanParticipant.getRolesAssignment() returns a string array which comprises of permission value.But it is a final variable so no new assignment could not be made.

I tried FuegoFDIAdmin.admin.addRolesToUser(soeId, roles[i], fuegoParameter, 255) again to see if that updates the existing role.But that throws exception since role already exists.

can anybody find a way out and can explain me what DirHumanParticipant.addpermission(int) will do .I tried this also but it doesnt have any impact.What is a user permission and permission added to a person with role ,How these both various.I will be grateful if somebody explains the user permission since i know what the later is meant for("XSARFGP")

Thanks,
Madhanagopal Kumar
  • 1. Re: Role Updation-FDI api
    703965 Newbie
    Currently Being Moderated
    Go to

    http://download.oracle.com/docs/cd/E13154_01/bpm/docs65/standard_components/index.html

    then navigate to Fuego.Fdi.DirHumanParticipant.getPermissionValue.

    You'll se this table:

    "X"      Execute      1
    "R"      Route      2
    "S"      Suspend      4
    "A"      Abort      8
    "D"      Delegate      16
    "G"      Grab (re-assign)      32
    "E"      Escalate      64
    "P"      Peer assign      128

    Permissions are a binary mask. If you have XEP, for example, then the integer value would be 1 + 64 + 128 = 193, and then all values are XRSADGEP = 255.

    I'm not sure, but I think that DirHumanParticipant.addpermission(int) is useless. It must be something from a very prior version where permission were set "by participant" instead of "by role" as they're set now. So don't use it.

    To assign a new role to a participant, do the following (the example uses a parametric role):

    //Get session
    DirectorySession dirSession = DirectorySession.currentEngineSession;

    // Get participant
    DirHumanParticipant participante = DirHumanParticipant.fetch(session : dirSession, id : p_id);
    rolesAssignment = participante.rolesAssignment;

    //Get role to assign
    DirOrganizationalRole resolutor = DirOrganizationalRole.fetch(session : dirSession, id : "Resolutor");
    //159 = All permissions but Reassign and Escalate
    RoleAssignment newRole = RoleAssignment.create(role : resolutor, parametricValue : p_roleParameter, permissions : 159);
    for(int i=0; i<rolesAssignment.length;i++){
         newRolesAssignment[i] = rolesAssignment;
    }

    newRolesAssignment.insert(@int : newRolesAssignment.length, value : newRole);
    //note that adding it at position newRolesAssignment.length is actually augmenting the array size, as arrays go from 0 to length-1


    // Set new assignments
    participante.rolesAssignment = newRolesAssignment;
    participante.update();

    Maybe the for loop is not really necessary, I'm not sure. But this way it works.
  • 2. Re: Role Updation-FDI api
    694425 Newbie
    Currently Being Moderated
    Rubén,
    Thanks for ur timely reply.But i couldnt replicate the same stuff whatever u did in ALBPM with the FDI Java api's or papi.My code look like this.
    We tried the insert and other stuffs which u proposed(see the commented lines below),But unfortunately those utilities are not available in any of the jars like fuegofdi.jar,fuego-papi client.jar ect.can u please help in finding the exact jar where all such stuffs are available to update the permission alone in the existing role and its implementation if possible.Once again my overwhelming thanks for the post.

    admin = new FuegoFDIAdmin();
                   admin.createFdiSession(adminUser, adminPassword, directoryFile,     directoryID);
    DirHumanParticipant usrDetails = null;

    DirectorySession dirSession=admin.getFdiSession().getDirectorySession();
                        usrDetails=DirHumanParticipant.fetch(dirSession, soeId);
                        DirHumanParticipant.RoleAssignment []definedRoles = usrDetails.getRolesAssignment();
                        
                        LOG.debug("No. of pre-defined roles [currently assigned] to the user ["+soeId+"] ="+ usrDetails.getRolesAssignment().length);
                        LOG.debug("Fuego parameter "+fuegoParameter);
                        LOG.debug("Fuego business parameter "+businessParameter);
                   
                        for (int i = 0; i < roles.length; i++) {                 
                             roleFound = false;
                             for (int k=0;k<definedRoles.length;k++) {
                                  if((definedRoles[k].role).equals(roles)){
                                       try {          
                                            if(isParametric(roles[i])){
                                                 LOG.debug("The role "+roles[i]+" is parametric");                                                                                
                                                 if (null!=fuegoParameter && usrDetails.hasRoleAssigned(roles[i], fuegoParameter)){
                                                      roleFound = true;
                                                      break;
                                                 }else{
                                                      roleFound = false;
                                                      break;
                                                 }
                                            }else{
                                                 LOG.debug("The role "+roles[i]+" is not parametric");
                                                 int category=5;
                                                 *if(usrDetails.hasRoleAssigned(roles[i])){*
    *//                                                  fuego.papi.Participant.RoleAssignment roleass=new fuego.papi.Participant.RoleAssignment(roles[i],category,"XRSADE");*
    *                                                  *
    *//                                                  DirOrganizationalRole dRole=DirOrganizationalRole.fetch(dirSession, definedRoles[k].role);*
                                                      //definedRolesnew[k].insert(definedRoles.length, roleass);
                                                      dirSession.startTransaction();
                                                      RoleAssignmentImpl rImpl=new RoleAssignmentImpl(definedRoles[k]);
                                                      rImpl.addPermissions(255);
                                                      
                                                      System.out.println("Two ::"+dirSession.isTransactionStarted());
                                                      usrDetails.update();
                                                      dirSession.commitTransaction();
                                                      
                                            
                                                      
                                                      roleFound = true;
                                                      break;
                                                 }else{
                                                      roleFound = false;
                                                      break;
                                                 }
                                            }
                                       }catch(Exception ex){
                                            LOG.debug("Exception while looking up for the role (Skipping role addition/verification of role) "+roles[i]);     
                                       }
                                       //roleFound = true;
                                       //break;           
                                  }     
                             }
                             try {                                 
                                  if (!roleFound){
                                       LOG.debug("Updating user role "+roles[i]);
                                       admin.addRolesToUser(soeId, roles[i], fuegoParameter, permission);           
                                  }          
                             }catch(Exception fnd){
                                  LOG.debug("Role already exists:- "+fnd.getMessage());
                                  fnd=null;
                             }
  • 3. Re: Role Updation-FDI api
    703965 Newbie
    Currently Being Moderated
    Sorry, I didn't make myself clear.

    FDI is NOT a public API, as the kind folks at Oracle support told me (I opened a Service Request for this issue some months ago). It's not designed nor prepared to be used outside ALBPM. You must do that kind of things inside an activity of BPM process. I have Studio set to "style=Java" so that's way my code looks like Java.

    Why is the FDI not public? Good question. But nowadays that's the way it is done.

    For doing that kind of operations from outside BPM, I'm using the following workaround:

    -Create a process with a conditional activity and just an automatic activity for each branch of the conditional. Each activity performs one of the operations you need (create new role, assign role to participant, whatever)
    -Add a bunch of arguments to the Begin activity, all that you need for your operations.
    -Use PAPI or PAPI-WS to create an instance of said process, passing the required arguments in the 'create' method/ws-operation.

    It's cumbersome and a PITA, but AFAIK the only way to do it. Well, I guess you could reverse engineer some jars and use FDI directly, but I don't think that would be a good idea (you'd lose support and such, and any version change may cause your modified jars to stop working).

    Hope it helps.

    Oh, if any reader knows a faster/simpler/better way to do this, I'd love to hear it as well :)
  • 4. Re: Role Updation-FDI api
    677481 Journeyer
    Currently Being Moderated
    Hi,
    I did not know that the FDI API was not public,in fact I have the Javadoc and a customer that is using it in production since two years ago and nobody has told me that can not be used....
    Regards
  • 5. Re: Role Updation-FDI api
    703965 Newbie
    Currently Being Moderated
    All I can say is that is what the Support guys told me, and it actually makes some sense as if you try to use it outside a BPM process, like in a webapp, you have the kind of problems the original poster talks about: missing methods/classes in the jars, no easy way to open a connection to the Directory...

    But if you can post a basic example of how to open a connection and do a simple operation (like assigning a role to a participant), it'd be greatly appreciated.

    EDIT: After reading your post I made a search and found this thread were you helped some guys to do this kind of things.

    Re: Create a Participant and assign roles using API (outside the process)

    Would you be so kind to send me the FDI javadoc to 'rnleon' at 'indra.es'?? It also would help if you told us what jars are needed besides fuego.fdi.jar.


    EDIT2: Some more search yields this short thread when another guy also says FDI is not public. ¿¿??

    Re: RoleAssingment.create() in PAPI -------URGENT PlZ Help

    Edited by: Rubén on Jun 3, 2009 9:55 AM
  • 6. Re: Role Updation-FDI api
    703965 Newbie
    Currently Being Moderated
    Public or not, it works. Here's my test class.


    What I'm not sure is what jars it actually needs. I've places a ton of jars in the build path, basically all I jars I could find.

    What I'm sure is that it needs the BPM jars for database connection:

    b1base.jar
    b1db2.jar
    b1oracle.jar
    b1informix.jar
    b1resource.jar
    b1sqlserver.jar
    b1sybase.jar
    b1util.jar

    -----

    package es.indra.bpm.fdi;
    import fuego.directory.AuthenticationException;
    import fuego.directory.DirHumanParticipant;
    import fuego.directory.Directory;
    import fuego.directory.DirectoryConfigurationManager;
    import fuego.directory.DirectoryException;
    import fuego.directory.DirectoryPassport;
    import fuego.directory.DirectorySession;
    import fuego.directory.exception.ProtocolNotSupportedException;
    import fuego.util.Properties;


    public class FdiTest {

         private static DirectorySession dirSession;
         /**
         * @param args
         */
         public static void main(String[] args) {
              dirSession = null;
              try {
                   openSesionFDI();
              } catch (Exception e) {
                   e.printStackTrace();
              }
         }

         private static void openSesionFDI() throws ProtocolNotSupportedException, AuthenticationException, DirectoryException {
              if (dirSession==null){
                   System.out.println("entering...");

                   Properties properties = new Properties();
                   properties.put("fuego.custom.replication.config.directoryId", "default");
                   properties.put("fuego.custom.replication.config.directoryFile", "D:\\eclipse-europa\\workspace\\Pruebas\\conf\\directory.xml");
                   properties.put("fuego.custom.replication.config.preset", "engine");
                   
                   DirectoryConfigurationManager.getRuntime().setPropertiesFileName(properties.getProperty("fuego.custom.replication.config.directoryFile").trim());
                   DirectoryPassport directoryPassport = DirectoryPassport.createWithIDAndPreset(properties.getProperty("fuego.custom.replication.config.directoryId").trim(), properties.getProperty("fuego.custom.replication.config.preset").trim());

                   if (directoryPassport==null){
                        throw new RuntimeException("Invalid directory passport for FDI");
                   }
                   
                   System.out.println("directoryPassport ID= " +directoryPassport.getId());
                   directoryPassport.fillPassport();
                   dirSession = Directory.startAdminSession(directoryPassport);
                   
                   DirHumanParticipant participant = DirHumanParticipant.fetch(dirSession, "ruben");
                   System.out.println("DisplayName= "+participant.getDisplayName());
                   

              }
              System.out.println("Disconnecting session... ");
              dirSession.disconnect();
              System.out.println("Session disconnected!");
         }

    }
  • 7. Re: Role Updation-FDI api
    694425 Newbie
    Currently Being Moderated
    Ruben,
    Thanks for it .We also were using the same way ur test class behaves.Now coming to my exact expectation, i dont find any api methods to update te existing role to a partcular particpant. Say a participant "ABC" is having Manager role with 127 permisiion i want to change it to max 255 without deleting or recreatin the existing role ...Can u find a way out...?


    Thnks for ur efforts

    Madhan
  • 8. Re: Role Updation-FDI api
    710394 Newbie
    Currently Being Moderated
    Hi, I am facing the same issue, I am able to create a parametric role programmatically and also able to attach a participant with same role but here I didn’t get any API to set category value. Kindly please suggest me the right approach for same….

    My Code:

    l_role = Role.find(name : role);
    Fuego.Fdi.RoleAssignment roleAssignment=null;
    if (l_role != null) {
    logMessage("## Found role ContractAdjuster ##");
    }

    l_role.addParameter(parameter : workGroup);
    l_role = Role.findParametric(name : role, parameter : workGroup);

    if (l_role != null) {
    logMessage("Found parametric role ContractAdjuster with new workGroup parameter: " + workGroup);
    }
    l_role = Role.findParametric(name : role, parameter : workGroup);
    l_role.addParticipant(participant : user, permission : "XRSADGEP");

    How I can assign category No. 9 to same user?
  • 9. Re: Role Updation-FDI api
    681829 Newbie
    Currently Being Moderated
    DirHumanParticipant usrDetails = admin.getUser(soeId);
    if (null != usrDetails) {

    DirHumanParticipant.RoleAssignment[] roles = usrDetails.getRolesAssignment();
    for (int i=0;i<roles.length;i++)
    {

    if(roles.role.equalsIgnoreCase("ISA Manager"))
    {
    RoleAssignmentImpl role = new RoleAssignmentImpl((DirHumanParticipant.RoleAssignment)roles[i]);


    role.intPermissions=5;

    roles[i]=role.getDirRoleAssignment();

    usrDetails.update();

    }
    }
    }

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points