cancel
Showing results for 
Search instead for 
Did you mean: 

NullPointerException trying to set UserEntity Picture

discolo
Champ in-the-making
Champ in-the-making
Hi all,
This is my first question, so I'm very new with Activiti, hope somebody could help me.

I'm developing some LDAP identity management integration for Activiti, starting from some examples (blogs and book). I've implemented the UserEntityManager class in order to retrieve and validate users from my LDAP.

All this is being tested using JUnit and an Inmemory LDAP with an Spring context configured (activiti 5.12). The problem comes when I try to retrieve the user's picture, like follows:
UserEntity user = new UserEntity(userId);
user.setEmail(entry.get("mail").getString());
user.setLastName(entry.get("sn").getString());
user.setFirstName(entry.get("givenName").getString());
Attribute photoAttr = entry.get("jpegPhoto");
if(photoAttr != null) {
   user.setPicture(new Picture(photoAttr.getBytes(), "image/jpeg"));
}
The UserEntity.setPicture method has the following code (lines 83 to 90)
    if (picture!=null) {
      pictureByteArray = new ByteArrayEntity(picture.getMimeType(), picture.getBytes());
      Context
        .getCommandContext()
        .getDbSqlSession()
        .insert(pictureByteArray);
      pictureByteArrayId = pictureByteArray.getId();
    } else {
When Context.getCommandContext() is executed null is returned with the consequent Nullpointerexception.

My questions are:
- Would it be a good idea to prevent this nullpointerexception raising some exception or performing null check?
- Why the getStack(commandContextThreadLocal) method returns an empty Stack?

If some extra information is needed just ask.

Thanks in advance and kind regards,
Rubén.
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
The picture need to be set through the identityService:

  void setUserPicture(String userId, Picture picture);


That is also why the setPicture method is not exposed on the org.activiti.engine.identity.User class.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.