use of org.camunda.bpm.engine.impl.persistence.entity.AttachmentEntity in project camunda-bpm-platform by camunda.
the class DeleteTaskAttachmentCmd method execute.
public Object execute(CommandContext commandContext) {
AttachmentEntity attachment = (AttachmentEntity) commandContext.getAttachmentManager().findAttachmentByTaskIdAndAttachmentId(taskId, attachmentId);
ensureNotNull("No attachment exist for task id '" + taskId + " and attachmentId '" + attachmentId + "'.", "attachment", attachment);
commandContext.getDbEntityManager().delete(attachment);
if (attachment.getContentId() != null) {
commandContext.getByteArrayManager().deleteByteArrayById(attachment.getContentId());
}
if (attachment.getTaskId() != null) {
TaskEntity task = commandContext.getTaskManager().findTaskById(attachment.getTaskId());
PropertyChange propertyChange = new PropertyChange("name", null, attachment.getName());
commandContext.getOperationLogManager().logAttachmentOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE_ATTACHMENT, task, propertyChange);
}
return null;
}
Aggregations