10-09-2017 04:51 PM
I have been researching and found out that this is the best way to current usr info from activiti DB. However, it comes out to be null.
This is my code..
First, I get userID
List<IdentityLink> identityLink = processEngine.getRuntimeService().getIdentityLinksForProcessInstance(processID);
Iterating through this I get userID
if (identityLink != null){
for (IdentityLink link : identityLink){
userID = link.getUserId();
logger.info("getProjectID: userID ==== is " + userID);
}
}else{
logger.info("getProjectID: userID is NULL ");
}
Now I try to get userinfo, this is null.. Can someone help?
User user = processEngine.getIdentityService().createUserQuery().userId(userID).singleResult();
if (user !=null){
logger.info("FirstName ======= " + user.getFirstName() );
logger.info("LastName ======= " + user.getLastName() );
logger.info("Email ======= " + user.getEmail() );
logger.info("Password ======= " + user.getPassword() );
}else{
logger.info("user is ......................... NULL ");
}
10-11-2017 08:09 PM
Yeah, now it makes sense. When you add an attach file option in the form, the next task will turn async. That means it is no longer executed under the logged in user context! Hence you get null. Try executing your logic from an execution listener attached to the start activity or on the sequence flow if you really need the user context. It is not a bug, it is working as designed.
10-09-2017 05:04 PM
btw,
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
10-09-2017 05:17 PM
This returns null as well..
List<String> userInfos = processEngine.getIdentityService().getUserInfoKeys(userID);
10-10-2017 05:57 PM
which version are you using? The Community version or the Enterprise version (Alfresco Process Services)?
10-11-2017 02:20 PM
Thanks for the response.
I was developing on community but server is enterprise. I have now switched development to Enterprise and using this command to retrieve userinfo but it still throws null pointer.. I have following in my file
import com.activiti.service.api.UserService;
@Autowired
static UserService userService;
User user = userService.findUser(Long.parseLong(userID)); (Getting UserID from IdentityLink code above.
10-11-2017 02:22 PM
import com.activiti.domain.idm.User;
10-11-2017 02:45 PM
yeah, if server is enterprise, you need to use the enterprise apis. The identity implementation in Alfresco Process Services is different from what is available in the core engine. Hence it is returning null (as per your original post) when you try to use the core engine apis
10-11-2017 02:59 PM
I am now using enterprise .. do you know which API can give me userinfo
I saw similar post ..
How to get user firstname and lastname in a generated document
but haven't had any luck yet
10-11-2017 03:07 PM
Are you looking to get a user who is currently logged id? If yes, you can use the following.
com.activiti.domain.idm.User currentUser = SecurityUtils.getCurrentUserObject(); This page has an example - Custom REST endpoints | Alfresco Documentation
10-11-2017 03:20 PM
Yes, I am looking for current logged in user.. Thanks ! . Let me try this
Explore our Alfresco products with the links below. Use labels to filter content by product module.