}
public Void execute(CommandContext commandContext) {
ensureNotNull("userId", userId);
IdentityInfoEntity pictureInfo = commandContext.getIdentityInfoManager()
.findUserInfoByUserIdAndKey(userId, "picture");
if (pictureInfo != null) {
String byteArrayId = pictureInfo.getValue();
if (byteArrayId != null) {
commandContext.getByteArrayManager()
.deleteByteArrayById(byteArrayId);
}
} else {
pictureInfo = new IdentityInfoEntity();
pictureInfo.setUserId(userId);
pictureInfo.setKey("picture");
commandContext.getDbEntityManager().insert(pictureInfo);
}
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(picture.getMimeType(), picture.getBytes());
commandContext.getDbEntityManager()
.insert(byteArrayEntity);
pictureInfo.setValue(byteArrayEntity.getId());
return null;
}