Search in sources :

Example 16 with ByteArrayEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity 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)

Example 17 with ByteArrayEntity

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

the class DefaultHistoryEventProducer method createHistoricJobLogFailedEvt.

public HistoryEvent createHistoricJobLogFailedEvt(Job job, Throwable exception) {
    HistoricJobLogEventEntity event = (HistoricJobLogEventEntity) createHistoricJobLogEvt(job, HistoryEventTypes.JOB_FAIL);
    if (exception != null) {
        // exception message
        event.setJobExceptionMessage(exception.getMessage());
        // stacktrace
        String exceptionStacktrace = getExceptionStacktrace(exception);
        byte[] exceptionBytes = toByteArray(exceptionStacktrace);
        ByteArrayEntity byteArray = createJobExceptionByteArray(exceptionBytes);
        event.setExceptionByteArrayId(byteArray.getId());
    }
    return event;
}
Also used : ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity) HistoricJobLogEventEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity)

Example 18 with ByteArrayEntity

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

the class HistoricExternalTaskLogEntity method setErrorDetails.

public void setErrorDetails(String exception) {
    EnsureUtil.ensureNotNull("exception", exception);
    byte[] exceptionBytes = toByteArray(exception);
    ByteArrayEntity byteArray = createExceptionByteArray(EXCEPTION_NAME, exceptionBytes);
    errorDetailsByteArrayId = byteArray.getId();
}
Also used : ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity)

Example 19 with ByteArrayEntity

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

the class MigrationBatchJobHandler method execute.

@Override
public void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) {
    ByteArrayEntity configurationEntity = commandContext.getDbEntityManager().selectById(ByteArrayEntity.class, configuration.getConfigurationByteArrayId());
    MigrationBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.getBytes());
    MigrationPlanExecutionBuilder executionBuilder = commandContext.getProcessEngineConfiguration().getRuntimeService().newMigration(batchConfiguration.getMigrationPlan()).processInstanceIds(batchConfiguration.getIds());
    if (batchConfiguration.isSkipCustomListeners()) {
        executionBuilder.skipCustomListeners();
    }
    if (batchConfiguration.isSkipIoMappings()) {
        executionBuilder.skipIoMappings();
    }
    // uses internal API in order to skip writing user operation log (CommandContext#disableUserOperationLog
    // is not sufficient with legacy engine config setting "restrictUserOperationLogToAuthenticatedUsers" = false)
    ((MigrationPlanExecutionBuilderImpl) executionBuilder).execute(false);
    commandContext.getByteArrayManager().delete(configurationEntity);
}
Also used : MigrationPlanExecutionBuilderImpl(org.camunda.bpm.engine.impl.migration.MigrationPlanExecutionBuilderImpl) ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity) MigrationPlanExecutionBuilder(org.camunda.bpm.engine.migration.MigrationPlanExecutionBuilder)

Example 20 with ByteArrayEntity

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

the class BatchMigrationTest method testDeleteBatchJobManually.

@Test
public void testDeleteBatchJobManually() {
    // given
    Batch batch = helper.createMigrationBatchWithSize(1);
    helper.executeSeedJob(batch);
    JobEntity migrationJob = (JobEntity) helper.getExecutionJobs(batch).get(0);
    String byteArrayId = migrationJob.getJobHandlerConfigurationRaw();
    ByteArrayEntity byteArrayEntity = engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequired().execute(new GetByteArrayCommand(byteArrayId));
    assertNotNull(byteArrayEntity);
    // when
    managementService.deleteJob(migrationJob.getId());
    // then
    byteArrayEntity = engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequired().execute(new GetByteArrayCommand(byteArrayId));
    assertNull(byteArrayEntity);
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) ByteArrayEntity(org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity) Batch(org.camunda.bpm.engine.batch.Batch) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

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