Search in sources :

Example 1 with IdentityInfoEntity

use of org.camunda.bpm.engine.impl.persistence.entity.IdentityInfoEntity in project camunda-bpm-platform by camunda.

the class DeleteUserPictureCmd method execute.

public Void execute(CommandContext commandContext) {
    ensureNotNull("UserId", userId);
    IdentityInfoEntity infoEntity = commandContext.getIdentityInfoManager().findUserInfoByUserIdAndKey(userId, "picture");
    if (infoEntity != null) {
        String byteArrayId = infoEntity.getValue();
        if (byteArrayId != null) {
            commandContext.getByteArrayManager().deleteByteArrayById(byteArrayId);
        }
        commandContext.getIdentityInfoManager().delete(infoEntity);
    }
    return null;
}
Also used : IdentityInfoEntity(org.camunda.bpm.engine.impl.persistence.entity.IdentityInfoEntity)

Example 2 with IdentityInfoEntity

use of org.camunda.bpm.engine.impl.persistence.entity.IdentityInfoEntity in project camunda-bpm-platform by camunda.

the class SetUserPictureCmd method execute.

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;
}
Also used : ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity) IdentityInfoEntity(org.camunda.bpm.engine.impl.persistence.entity.IdentityInfoEntity)

Example 3 with IdentityInfoEntity

use of org.camunda.bpm.engine.impl.persistence.entity.IdentityInfoEntity 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;
}
Also used : ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity) Picture(org.camunda.bpm.engine.identity.Picture) IdentityInfoEntity(org.camunda.bpm.engine.impl.persistence.entity.IdentityInfoEntity)

Aggregations

IdentityInfoEntity (org.camunda.bpm.engine.impl.persistence.entity.IdentityInfoEntity)3 ByteArrayEntity (org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity)2 Picture (org.camunda.bpm.engine.identity.Picture)1