use of org.camunda.bpm.engine.identity.Picture in project camunda-bpm-platform by camunda.
the class GetUserPictureCmd method execute.
public Picture execute(CommandContext commandContext) {
ensureNotNull("userId", userId);
IdentityInfoEntity pictureInfo = commandContext.getIdentityInfoManager().findUserInfoByUserIdAndKey(userId, "picture");
if (pictureInfo != null) {
String pictureByteArrayId = pictureInfo.getValue();
if (pictureByteArrayId != null) {
ByteArrayEntity byteArray = commandContext.getDbEntityManager().selectById(ByteArrayEntity.class, pictureByteArrayId);
return new Picture(byteArray.getBytes(), byteArray.getName());
}
}
return null;
}
use of org.camunda.bpm.engine.identity.Picture in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testUserPicture.
@Test
public void testUserPicture() {
// First, create a new user
User user = identityService.newUser("johndoe");
identityService.saveUser(user);
String userId = user.getId();
Picture picture = new Picture("niceface".getBytes(), "image/string");
identityService.setUserPicture(userId, picture);
picture = identityService.getUserPicture(userId);
// Fetch and update the user
user = identityService.createUserQuery().userId("johndoe").singleResult();
assertTrue("byte arrays differ", Arrays.equals("niceface".getBytes(), picture.getBytes()));
assertEquals("image/string", picture.getMimeType());
identityService.deleteUserPicture("johndoe");
// this is ignored
identityService.deleteUserPicture("someone-else-we-dont-know");
// picture does not exist
picture = identityService.getUserPicture("johndoe");
assertNull(picture);
// add new picture
picture = new Picture("niceface".getBytes(), "image/string");
identityService.setUserPicture(userId, picture);
// makes the picture go away
identityService.deleteUser(user.getId());
}
Aggregations