Sasi R [
http://community.jboss.org/people/sasir] created the discussion
"Re: jbpm 3.x to 5 migration path"
To view the discussion, visit:
http://community.jboss.org/message/593832#593832
--------------------------------------------------------------
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(" mailto:user.admin@company.com
user.admin(a)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;
}
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/593832#593832]
Start a new discussion in jBPM Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]