Search in sources :

Example 1 with JaxbAttachment

use of org.jbpm.services.task.impl.model.xml.JaxbAttachment in project jbpm by kiegroup.

the class AddAttachmentCommand method execute.

public Long execute(Context cntxt) {
    TaskContext context = (TaskContext) cntxt;
    Attachment attachmentImpl = attachment;
    if (attachmentImpl == null) {
        attachmentImpl = jaxbAttachment;
    }
    Content contentImpl = content;
    if (contentImpl == null) {
        contentImpl = jaxbContent;
    }
    if (rawContent != null && contentImpl == null) {
        Task task = context.getPersistenceContext().findTask(taskId);
        contentImpl = TaskModelProvider.getFactory().newContent();
        ContentMarshallerContext ctx = TaskContentRegistry.get().getMarshallerContext(task.getTaskData().getDeploymentId());
        ((InternalContent) contentImpl).setContent(ContentMarshallerHelper.marshallContent(task, rawContent, ctx.getEnvironment()));
        ((InternalAttachment) attachmentImpl).setSize(contentImpl.getContent().length);
    }
    doCallbackOperationForAttachment(attachmentImpl, context);
    return context.getTaskAttachmentService().addAttachment(taskId, attachmentImpl, contentImpl);
}
Also used : Task(org.kie.api.task.model.Task) InternalAttachment(org.kie.internal.task.api.model.InternalAttachment) Content(org.kie.api.task.model.Content) InternalContent(org.kie.internal.task.api.model.InternalContent) JaxbContent(org.jbpm.services.task.impl.model.xml.JaxbContent) JaxbAttachment(org.jbpm.services.task.impl.model.xml.JaxbAttachment) Attachment(org.kie.api.task.model.Attachment) InternalAttachment(org.kie.internal.task.api.model.InternalAttachment) InternalContent(org.kie.internal.task.api.model.InternalContent) ContentMarshallerContext(org.kie.internal.task.api.ContentMarshallerContext)

Aggregations

JaxbAttachment (org.jbpm.services.task.impl.model.xml.JaxbAttachment)1 JaxbContent (org.jbpm.services.task.impl.model.xml.JaxbContent)1 Attachment (org.kie.api.task.model.Attachment)1 Content (org.kie.api.task.model.Content)1 Task (org.kie.api.task.model.Task)1 ContentMarshallerContext (org.kie.internal.task.api.ContentMarshallerContext)1 InternalAttachment (org.kie.internal.task.api.model.InternalAttachment)1 InternalContent (org.kie.internal.task.api.model.InternalContent)1