this.attachmentId = attachmentId;
this.taskId = taskId;
}
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);
}