@Override public void onDelete(BatchJobConfiguration configuration, JobEntity jobEntity) { String byteArrayId = configuration.getConfigurationByteArrayId(); if (byteArrayId != null) { Context.getCommandContext().getByteArrayManager() .deleteByteArrayById(byteArrayId); } }
protected ByteArrayEntity saveConfiguration(ByteArrayManager byteArrayManager, T jobConfiguration) { ByteArrayEntity configurationEntity = new ByteArrayEntity(); configurationEntity.setBytes(writeConfiguration(jobConfiguration)); byteArrayManager.insert(configurationEntity); return configurationEntity; }
.deleteByteArraysByRemovalTime(removalTime, minuteFrom, minuteTo, batchSize);
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; }
@Override public void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) { ByteArrayEntity configurationEntity = commandContext .getDbEntityManager() .selectById(ByteArrayEntity.class, configuration.getConfigurationByteArrayId()); BatchConfiguration batchConfiguration = readConfiguration(configurationEntity.getBytes()); boolean initialLegacyRestrictions = commandContext.isRestrictUserOperationLogToAuthenticatedUsers(); commandContext.disableUserOperationLog(); commandContext.setRestrictUserOperationLogToAuthenticatedUsers(true); try { commandContext.getProcessEngineConfiguration() .getHistoryService() .deleteHistoricProcessInstances(batchConfiguration.getIds()); } finally { commandContext.enableUserOperationLog(); commandContext.setRestrictUserOperationLogToAuthenticatedUsers(initialLegacyRestrictions); } commandContext.getByteArrayManager().delete(configurationEntity); }
/** * Deletes the {@link ByteArrayEntity} with the given id from the database. * Important: this operation will NOT do any optimistic locking, to avoid loading the * bytes in memory. So use this method only in conjunction with an entity that has * optimistic locking!. */ public void deleteByteArrayById(String byteArrayEntityId) { getDbEntityManager().delete(ByteArrayEntity.class, "deleteByteArrayNoRevisionCheck", byteArrayEntityId); }
/** * 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; }
.addRemovalTimeToByteArraysByRootProcessInstanceId(rootProcessInstanceId, removalTime);
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; }
@Override public void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) { ByteArrayEntity configurationEntity = commandContext .getDbEntityManager() .selectById(ByteArrayEntity.class, configuration.getConfigurationByteArrayId()); BatchConfiguration batchConfiguration = readConfiguration(configurationEntity.getBytes()); boolean initialLegacyRestrictions = commandContext.isRestrictUserOperationLogToAuthenticatedUsers(); commandContext.disableUserOperationLog(); commandContext.setRestrictUserOperationLogToAuthenticatedUsers(true); try { commandContext.getProcessEngineConfiguration() .getHistoryService() .deleteHistoricDecisionInstancesBulk(batchConfiguration.getIds()); } finally { commandContext.enableUserOperationLog(); commandContext.setRestrictUserOperationLogToAuthenticatedUsers(initialLegacyRestrictions); } commandContext.getByteArrayManager().delete(configurationEntity); }
public void addRemovalTimeToByteArraysByRootProcessInstanceId(String rootProcessInstanceId, Date removalTime) { Map<String, Object> parameters = new HashMap<>(); parameters.put("rootProcessInstanceId", rootProcessInstanceId); parameters.put("removalTime", removalTime); getDbEntityManager() .updatePreserveOrder(ByteArrayEntity.class, "updateByteArraysByRootProcessInstanceId", parameters); }
/** * 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; }
.addRemovalTimeToByteArraysByRootProcessInstanceId(rootProcessInstanceId, removalTime);
@Override public void onDelete(BatchJobConfiguration configuration, JobEntity jobEntity) { String byteArrayId = configuration.getConfigurationByteArrayId(); if (byteArrayId != null) { Context.getCommandContext().getByteArrayManager() .deleteByteArrayById(byteArrayId); } }
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; }
@Override public void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) { ByteArrayEntity configurationEntity = commandContext .getDbEntityManager() .selectById(ByteArrayEntity.class, configuration.getConfigurationByteArrayId()); BatchConfiguration batchConfiguration = readConfiguration(configurationEntity.getBytes()); boolean initialLegacyRestrictions = commandContext.isRestrictUserOperationLogToAuthenticatedUsers(); commandContext.disableUserOperationLog(); commandContext.setRestrictUserOperationLogToAuthenticatedUsers(true); try { commandContext.getProcessEngineConfiguration() .getHistoryService() .deleteHistoricProcessInstances(batchConfiguration.getIds()); } finally { commandContext.enableUserOperationLog(); commandContext.setRestrictUserOperationLogToAuthenticatedUsers(initialLegacyRestrictions); } commandContext.getByteArrayManager().delete(configurationEntity); }
/** * Deletes the {@link ByteArrayEntity} with the given id from the database. * Important: this operation will NOT do any optimistic locking, to avoid loading the * bytes in memory. So use this method only in conjunction with an entity that has * optimistic locking!. */ public void deleteByteArrayById(String byteArrayEntityId) { getDbEntityManager().delete(ByteArrayEntity.class, "deleteByteArrayNoRevisionCheck", byteArrayEntityId); }
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(); } }
protected ByteArrayEntity saveConfiguration(ByteArrayManager byteArrayManager, T jobConfiguration) { ByteArrayEntity configurationEntity = new ByteArrayEntity(); configurationEntity.setBytes(writeConfiguration(jobConfiguration)); byteArrayManager.insert(configurationEntity); return configurationEntity; }
.addRemovalTimeToByteArraysByRootProcessInstanceId(rootProcessInstanceId, removalTime);