Search in sources :

Example 21 with ByteArrayEntity

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

the class ByteArrayField method setByteArrayValue.

public void setByteArrayValue(byte[] bytes) {
    if (bytes != null) {
        // 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);
            Context.getCommandContext().getDbEntityManager().insert(byteArrayValue);
            byteArrayId = byteArrayValue.getId();
        }
    } else {
        deleteByteArrayValue();
    }
}
Also used : ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity)

Example 22 with ByteArrayEntity

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

the class DeleteHistoricDecisionInstancesJobHandler method execute.

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

Example 23 with ByteArrayEntity

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

the class SetJobRetriesJobHandler method execute.

@Override
public void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) {
    ByteArrayEntity configurationEntity = commandContext.getDbEntityManager().selectById(ByteArrayEntity.class, configuration.getConfigurationByteArrayId());
    SetRetriesBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.getBytes());
    boolean initialLegacyRestrictions = commandContext.isRestrictUserOperationLogToAuthenticatedUsers();
    commandContext.disableUserOperationLog();
    commandContext.setRestrictUserOperationLogToAuthenticatedUsers(true);
    try {
        commandContext.getProcessEngineConfiguration().getManagementService().setJobRetries(batchConfiguration.getIds(), batchConfiguration.getRetries());
    } finally {
        commandContext.enableUserOperationLog();
        commandContext.setRestrictUserOperationLogToAuthenticatedUsers(initialLegacyRestrictions);
    }
    commandContext.getByteArrayManager().delete(configurationEntity);
}
Also used : SetRetriesBatchConfiguration(org.camunda.bpm.engine.impl.batch.SetRetriesBatchConfiguration) ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity)

Example 24 with ByteArrayEntity

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

the class ExceptionUtil method createExceptionByteArray.

/**
 * 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
 * @return persisted entity
 */
public static ByteArrayEntity createExceptionByteArray(String name, byte[] byteArray) {
    ByteArrayEntity result = null;
    if (byteArray != null) {
        result = new ByteArrayEntity(name, byteArray);
        Context.getCommandContext().getDbEntityManager().insert(result);
    }
    return result;
}
Also used : ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity)

Aggregations

ByteArrayEntity (org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity)24 DbEntityManager (org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)3 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)3 AttachmentEntity (org.camunda.bpm.engine.impl.persistence.entity.AttachmentEntity)3 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 BatchConfiguration (org.camunda.bpm.engine.impl.batch.BatchConfiguration)2 SetRetriesBatchConfiguration (org.camunda.bpm.engine.impl.batch.SetRetriesBatchConfiguration)2 ByteArrayManager (org.camunda.bpm.engine.impl.persistence.entity.ByteArrayManager)2 HistoricJobLogEventEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity)2 IdentityInfoEntity (org.camunda.bpm.engine.impl.persistence.entity.IdentityInfoEntity)2 JobManager (org.camunda.bpm.engine.impl.persistence.entity.JobManager)2 Date (java.util.Date)1 Batch (org.camunda.bpm.engine.batch.Batch)1 Picture (org.camunda.bpm.engine.identity.Picture)1 MigrationPlanExecutionBuilderImpl (org.camunda.bpm.engine.impl.migration.MigrationPlanExecutionBuilderImpl)1 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)1 HistoricVariableInstanceEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity)1 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)1 MigrationPlanExecutionBuilder (org.camunda.bpm.engine.migration.MigrationPlanExecutionBuilder)1