11 Replies Latest reply on Mar 21, 2011 2:08 PM by Mauricio Salatino

    jbpm 3.x to 5 migration path

    Sasi R Newbie

      We have existing jbpm 3.2 project which uses class liek IdentitySession, User, Group for mainitnign users and groups. But soem of the classes are missing in 5 and is there any docuemnt which specifies the recommendations. I saw the project eschabell-jbpmmigration but it doesnt say about that path

       

      Is there any code snippet which implemented the logic around users, groups management in 5.0?

        • 1. jbpm 3.x to 5 migration path
          Mauricio Salatino Master

          Hi Sasi,

          Yes Eric was working on that.. I think that we will be able to answer your question better.

          As far as I know you can plug in jBPM5 you identity module, obviously not using the same classes that were used in jBPM3 but using the new ones you should be able to do the same work. If you already have your process defined  you should use expressions to resolve your users assignments.

          Can you share with us what kind of logic do you have implemented? so we can create an example about how to do it in jBPM5.

          Greetings.

          • 2. jbpm 3.x to 5 migration path
            Sasi R Newbie

            Thanks Salatino for replying. We have a web application and in the startup we are laoding  the users and groups mappings from external source and are using that information while getting the groups related to users, and the specific roles, etc

             

            I see that we have classes under org.jbpm.userprofile package but they look into the underlying task server DB as per my understanding.

             

            How can the case be implemented where in we create the user mappings from external source data

             

             

            *****************Sampel code***************************

             

            JbpmConfiguration jbpmConfiguration = null;
            JbpmContext jbpmContext = null;
             
              try{
              jbpmConfiguration = JbpmConfiguration.parseResource("jbpm.cfg.xml");
              jbpmContext = jbpmConfiguration.createJbpmContext();
             
             
              /*
                    Creating groups and users 
                 */
                    IdentitySession identitySession = new IdentitySession(jbpmContext.getSession());
                    java.util.List userList = new java.util.ArrayList();
                    java.util.List userListIs = identitySession.getUsers();
                    for (int i=0;i<userListIs.size(); i++) {
                       User user = (User)userListIs.get(i);
                       userList.add(user.getName());
                    }
                   
                         
                    jbpmContext.getSession().flush();
                    //Transaction transaction = jbpmContext.getSession().beginTransaction();
                   
                    System.out.println("################## Loading Test users and Groups #################");
                  
                   
                    Group  CA_ANALYST = identitySession.getGroupByName("CA_ANALYST");
                    if(CA_ANALYST == null){       
                     identitySession.saveEntity(new Group("CA_ANALYST"));  

                     transactionCommit = true;
                    }

             

            if(!userList.contains("analyst1")){
                     User analystUser = new  User("analyst");
                     adminUser.setEmail("user.admin@company.com");
                     adminUser.setPassword("analyst");
                     identitySession.saveEntity(analystUser);
                     identitySession.saveEntity(Membership.create(identitySession.getUserByName("analyst"),identitySession.getGroupByName("CA_ANALYST")));
                     transactionCommit = true;
              }

             

             

             

             

            System.

            out.println("################## Done Loading Test users and Groups! #################"

            );

             

             

            }

            catch

            (Exception e) {

            e.printStackTrace();

            Throwable t = e;

             

            while (t.getCause() != null

            ) {

            t = t.getCause();

            }

             

            }

            finally

            {

            jbpmContext.close();

            }

             


                         

             

            public static List getRolesUserBelongingTo(String userName,JbpmContext jbpmContext){
              List rolesList = new ArrayList();
             
              try{
               IdentitySession identitySession = new IdentitySession(jbpmContext.getSession());
               User user = identitySession.getUserByName(userName);
               Set roleSet = user.getMemberships();
               if(roleSet != null){
                Iterator iter = roleSet.iterator();
                   while (iter.hasNext()) {
                    Membership membership = (Membership) iter.next();
                    String role = membership.getRole();
                    if(role != null){
                     rolesList.add(role);
                    }
                   }
               }
               //identitySession.close();
              }catch(Exception ex){
               ex.printStackTrace();
              }
              return rolesList;
             
            }

            • 4. jbpm 3.x to 5 migration path
              Sasi R Newbie

              Thanks for the link. I am looking for something similar which can be used with external data sources. Are you suggesting to use these or do we have any other usage examples

              • 5. jbpm 3.x to 5 migration path
                Mauricio Salatino Master

                That's right. Depending on where do you have your user/identity information is how you can implement a similar mechanism to the one showed in the test case.

                Greetings

                • 6. jbpm 3.x to 5 migration path
                  Sasi R Newbie

                  Definitely it will help in implementation but it is file based and dont want to go taht route. If i want to use in a j2ee application and want to load the data only in startup, whats the suggested way if i dont want to rely on DB/file

                  ?

                  • 7. jbpm 3.x to 5 migration path
                    Mauricio Salatino Master

                    The implementation in the test is a simple implementation to show how to do the work, but you must implement it using the mechanisms that you trust, just implementing the interfaces there.

                    If you want to code a J2EE solution you can do it if you know how to configure users and identity components in those environments. That topic is not related with jBPM and it's mostly about the technology that you want to use to manage identities. After that you can integrate the solution that you choose with jbpm very quickly.

                    Greetings.

                    • 8. jbpm 3.x to 5 migration path
                      Sasi R Newbie

                      one quick question..I see that we are stroing details of entities in ORGANIZATIONALENTITY table whether its a user or group. Where do we store additioanl details of the user/group like email details and other id's. Are we expected to manage them using our own tables or Does JBPM schema supports it?

                      • 9. jbpm 3.x to 5 migration path
                        Mauricio Salatino Master

                        jBPM should handle just and ID. In theory you already have all the user information in a different storage: LDAP, Service Directory, your own database. Unless you start a project from the scratch and the company don't have a user identity storage you can create your own tables and handle them there. jBPM will just persist an ID in order to delegate the identity management.

                        Greetings.

                        • 10. jbpm 3.x to 5 migration path
                          Sasi R Newbie

                          But how does jBPM engine gets all the info of users/groups/roles while delegating tasks? Does it cache the information while start up?  Can you please point me to the right location in the code on where it is happening