use of org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity in project camunda-bpm-platform by camunda.
the class GetTaskAttachmentContentCmd method execute.
public InputStream execute(CommandContext commandContext) {
AttachmentEntity attachment = (AttachmentEntity) commandContext.getAttachmentManager().findAttachmentByTaskIdAndAttachmentId(taskId, attachmentId);
if (attachment == null) {
return null;
}
String contentId = attachment.getContentId();
if (contentId == null) {
return null;
}
ByteArrayEntity byteArray = commandContext.getDbEntityManager().selectById(ByteArrayEntity.class, contentId);
byte[] bytes = byteArray.getBytes();
return new ByteArrayInputStream(bytes);
}
use of org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity in project camunda-bpm-platform by camunda.
the class CreateAttachmentCmd method execute.
@Override
public Attachment execute(CommandContext commandContext) {
if (taskId != null) {
task = commandContext.getTaskManager().findTaskById(taskId);
} else {
ensureNotNull("taskId or processInstanceId has to be provided", this.processInstanceId);
List<ExecutionEntity> executionsByProcessInstanceId = commandContext.getExecutionManager().findExecutionsByProcessInstanceId(processInstanceId);
ensureNumberOfElements("processInstances", executionsByProcessInstanceId, 1);
processInstance = executionsByProcessInstanceId.get(0);
}
AttachmentEntity attachment = new AttachmentEntity();
attachment.setName(attachmentName);
attachment.setDescription(attachmentDescription);
attachment.setType(attachmentType);
attachment.setTaskId(taskId);
attachment.setProcessInstanceId(processInstanceId);
attachment.setUrl(url);
DbEntityManager dbEntityManger = commandContext.getDbEntityManager();
dbEntityManger.insert(attachment);
if (content != null) {
byte[] bytes = IoUtil.readInputStream(content, attachmentName);
ByteArrayEntity byteArray = new ByteArrayEntity(bytes);
dbEntityManger.insert(byteArray);
attachment.setContentId(byteArray.getId());
}
PropertyChange propertyChange = new PropertyChange("name", null, attachmentName);
if (task != null) {
commandContext.getOperationLogManager().logAttachmentOperation(UserOperationLogEntry.OPERATION_TYPE_ADD_ATTACHMENT, task, propertyChange);
} else if (processInstance != null) {
commandContext.getOperationLogManager().logAttachmentOperation(UserOperationLogEntry.OPERATION_TYPE_ADD_ATTACHMENT, processInstance, propertyChange);
}
return attachment;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity in project camunda-bpm-platform by camunda.
the class DeleteProcessInstancesJobHandler method execute.
@Override
public void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) {
ByteArrayEntity configurationEntity = commandContext.getDbEntityManager().selectById(ByteArrayEntity.class, configuration.getConfigurationByteArrayId());
DeleteProcessInstanceBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.getBytes());
boolean initialLegacyRestrictions = commandContext.isRestrictUserOperationLogToAuthenticatedUsers();
commandContext.disableUserOperationLog();
commandContext.setRestrictUserOperationLogToAuthenticatedUsers(true);
try {
commandContext.getProcessEngineConfiguration().getRuntimeService().deleteProcessInstances(batchConfiguration.getIds(), batchConfiguration.deleteReason, batchConfiguration.isSkipCustomListeners(), true, batchConfiguration.isSkipSubprocesses());
} finally {
commandContext.enableUserOperationLog();
commandContext.setRestrictUserOperationLogToAuthenticatedUsers(initialLegacyRestrictions);
}
commandContext.getByteArrayManager().delete(configurationEntity);
}
use of org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity in project camunda-bpm-platform by camunda.
the class SetExternalTaskRetriesJobHandler 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().getExternalTaskService().setRetries(batchConfiguration.getIds(), batchConfiguration.getRetries());
} finally {
commandContext.enableUserOperationLog();
commandContext.setRestrictUserOperationLogToAuthenticatedUsers(initialLegacyRestrictions);
}
commandContext.getByteArrayManager().delete(configurationEntity);
}
use of org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity in project camunda-bpm-platform by camunda.
the class DeleteHistoricProcessInstancesJobHandler 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().deleteHistoricProcessInstances(batchConfiguration.getIds());
} finally {
commandContext.enableUserOperationLog();
commandContext.setRestrictUserOperationLogToAuthenticatedUsers(initialLegacyRestrictions);
}
commandContext.getByteArrayManager().delete(configurationEntity);
}
Aggregations