Expand my Community achievements bar.

SOLVED

Document is in disposed state! - setting a Document workflow variable

Avatar

Level 7

We have written a custom workflow step.  It has the following code.  The idea is to set a Document variable to the value of a file from the filesystem.

 

Path filePath = Paths.get(path);
com.adobe.aemfd.docmanager.Document doc = new com.adobe.aemfd.docmanager.Document(Files.readAllBytes(filePath));
wfd.getMetaDataMap().put(documentVariableName, doc);

 

This succeeds however, we we attempt to use the Document variable, we get the error "Document is in a disposed state!".  

 

How do I properly set a Document variable with the contents of a file on the filesystem?

 

Thanks,

1 Accepted Solution

Avatar

Correct answer by
Level 7

@Mayank_Tiwari I logged a support case and it was reported that this is a known bug.  My case number is 000538536  - check with Manish Pandey if interested.

View solution in original post

4 Replies

Avatar

Employee

Can you try the following code. This has been used in this sample code as well.

 

import java.io.File;
import com.adobe.aemfd.docmanager.Document;

String inputFile = "<path to a pdf document stored at disk>"
File inFile = new File(inputFile);
Document inDoc = new Document(inFile);

 

Avatar

Employee

This should work. not sure why it is not working for you. 

As an alternative can you try with this:

 

 

byte[] bytes = <create byte[] from file>
Document inDoc = new Document(bytes);

 

 

Avatar

Correct answer by
Level 7

@Mayank_Tiwari I logged a support case and it was reported that this is a known bug.  My case number is 000538536  - check with Manish Pandey if interested.