Search in sources :

Example 6 with AttachmentEntity

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;
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) AttachmentEntity(org.camunda.bpm.engine.impl.persistence.entity.AttachmentEntity)

Aggregations

AttachmentEntity (org.camunda.bpm.engine.impl.persistence.entity.AttachmentEntity)6 ByteArrayEntity (org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity)3 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 DbEntityManager (org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)2 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)1