public void setByteArrayValue(byte[] bytes, boolean isTransient) { if (bytes != null) { // note: there can be cases where byteArrayId is not null // but the corresponding byte array entity has been removed in parallel; // thus we also need to check if the actual byte array entity still exists if (this.byteArrayId != null && getByteArrayEntity() != null) { byteArrayValue.setBytes(bytes); } else { deleteByteArrayValue(); byteArrayValue = new ByteArrayEntity(nameProvider.getName(), bytes, type, rootProcessInstanceId, removalTime); // avoid insert of byte array value for a transient variable if (!isTransient) { Context. getCommandContext() .getByteArrayManager() .insertByteArray(byteArrayValue); byteArrayId = byteArrayValue.getId(); } } } else { deleteByteArrayValue(); } }
public static String getExceptionStacktrace(ByteArrayEntity byteArray) { String result = null; if(byteArray != null) { result = StringUtil.fromBytes(byteArray.getBytes()); } return result; }
protected void checkBinary(ByteArrayEntity byteArrayEntity) { assertNotNull(byteArrayEntity); assertNotNull(byteArrayEntity.getCreateTime()); assertEquals(RUNTIME.getValue(), byteArrayEntity.getType()); }
public void setErrorDetails(String exception) { EnsureUtil.ensureNotNull("exception", exception); byte[] exceptionBytes = toByteArray(exception); ByteArrayEntity byteArray = createExceptionByteArray(EXCEPTION_NAME, exceptionBytes, ResourceTypes.HISTORY); byteArray.setRootProcessInstanceId(rootProcessInstanceId); byteArray.setRemovalTime(removalTime); errorDetailsByteArrayId = byteArray.getId(); }
protected ByteArrayEntity saveConfiguration(ByteArrayManager byteArrayManager, T jobConfiguration) { ByteArrayEntity configurationEntity = new ByteArrayEntity(); configurationEntity.setBytes(writeConfiguration(jobConfiguration)); byteArrayManager.insert(configurationEntity); return configurationEntity; }
public void setExceptionStacktrace(String exception) { byte[] exceptionBytes = toByteArray(exception); ByteArrayEntity byteArray = getExceptionByteArray(); if(byteArray == null) { byteArray = createJobExceptionByteArray(exceptionBytes, ResourceTypes.RUNTIME); exceptionByteArrayId = byteArray.getId(); exceptionByteArray = byteArray; } else { byteArray.setBytes(exceptionBytes); } }
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(historyEvent.getVariableName(), byteValue, ResourceTypes.HISTORY); byteArrayEntity.setRootProcessInstanceId(historyEvent.getRootProcessInstanceId()); byteArrayEntity.setRemovalTime(historyEvent.getRemovalTime()); .getByteArrayManager() .insertByteArray(byteArrayEntity); historyEvent.setByteArrayId(byteArrayEntity.getId());
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(), ResourceTypes.REPOSITORY); commandContext.getByteArrayManager() .insertByteArray(byteArrayEntity); pictureInfo.setValue(byteArrayEntity.getId()); return null; }
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; }
@Override protected JobHandlerConfiguration resolveJobHandlerConfiguration(BatchJobContext context) { return new BatchJobConfiguration(context.getConfiguration().getId()); }
protected boolean isHistoricByteArray(DbEntity dbEntity) { if (dbEntity instanceof ByteArrayEntity) { ByteArrayEntity byteArrayEntity = (ByteArrayEntity) dbEntity; return byteArrayEntity.getType().equals(ResourceTypes.HISTORY.getValue()); } else { return false; } }
/** * create ByteArrayEntity with specified name and payload and make sure it's * persisted * * used in Jobs and ExternalTasks * * @param name - type\source of the exception * @param byteArray - payload of the exception * @param type - resource type of the exception * @return persisted entity */ public static ByteArrayEntity createExceptionByteArray(String name, byte[] byteArray, ResourceType type) { ByteArrayEntity result = null; if (byteArray != null) { result = new ByteArrayEntity(name, byteArray, type); Context.getCommandContext() .getByteArrayManager() .insertByteArray(result); } return result; }
public void insertByteArray(ByteArrayEntity arr) { arr.setCreateTime(ClockUtil.getCurrentTime()); getDbEntityManager().insert(arr); }
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(historyEvent.getVariableName(), byteValue, ResourceTypes.HISTORY); byteArrayEntity.setRootProcessInstanceId(historyEvent.getRootProcessInstanceId()); byteArrayEntity.setRemovalTime(historyEvent.getRemovalTime()); .getByteArrayManager() .insertByteArray(byteArrayEntity); historyEvent.setByteArrayId(byteArrayEntity.getId());
public void setErrorDetails(String exception) { EnsureUtil.ensureNotNull("exception", exception); byte[] exceptionBytes = toByteArray(exception); ByteArrayEntity byteArray = createExceptionByteArray(EXCEPTION_NAME, exceptionBytes, ResourceTypes.HISTORY); byteArray.setRootProcessInstanceId(rootProcessInstanceId); byteArray.setRemovalTime(removalTime); errorDetailsByteArrayId = byteArray.getId(); }
public void setExceptionStacktrace(String exception) { byte[] exceptionBytes = toByteArray(exception); ByteArrayEntity byteArray = getExceptionByteArray(); if(byteArray == null) { byteArray = createJobExceptionByteArray(exceptionBytes, ResourceTypes.RUNTIME); exceptionByteArrayId = byteArray.getId(); exceptionByteArray = byteArray; } else { byteArray.setBytes(exceptionBytes); } }
protected ByteArrayEntity saveConfiguration(ByteArrayManager byteArrayManager, T jobConfiguration) { ByteArrayEntity configurationEntity = new ByteArrayEntity(); configurationEntity.setBytes(writeConfiguration(jobConfiguration)); byteArrayManager.insert(configurationEntity); return configurationEntity; }
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(), ResourceTypes.REPOSITORY); commandContext.getByteArrayManager() .insertByteArray(byteArrayEntity); pictureInfo.setValue(byteArrayEntity.getId()); return null; }
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; }
@Override protected JobHandlerConfiguration resolveJobHandlerConfiguration(BatchJobContext context) { return new BatchJobConfiguration(context.getConfiguration().getId()); }