workflow Item - not able to get the map value | Community
Skip to main content
New Participant
April 13, 2016
Solved

workflow Item - not able to get the map value

  • April 13, 2016
  • 7 replies
  • 1433 views

I am trying the keep the inputstream of a file in to the map while instantialting the workflow

but the same inputstream I am not able to get from the process step - it showing null.

please help me !!

Code in Servlet under below--

InputStream isStream = new BufferedInputStream(pArr[0].getInputStream()); // this is stream object getting from the request parameter (pArr[0] is RequestParameter object)

Map<String, Object> map = new HashMap<String, Object>();

 map.put("filetoUpdateStream", isStream);

ResourceResolver resourceResolver = this.resolverFactory.getAdministrativeResourceResolver(null);
            WorkflowSession workflowSession = resourceResolver.adaptTo(WorkflowSession.class);
            if(workflowSession !=null) { 
                WorkflowModel workflowModel = workflowSession.getModel("/etc/workflow/models/document_revision_tool_moderate/jcr:content/model");
                WorkflowData workflowData = workflowSession.newWorkflowData("JCR_PATH", contentType);
                log.debug("workflow payload = "+workflowData.getPayloadType());
                Workflow workflow = workflowSession.startWorkflow(workflowModel, workflowData, map);
                log.debug("workflow is started.."+workflow.getId());
            }else{
                log.error("workflow session is null");
            }

///////////////

code in Process Step under below,

InputStream isStream = null;
        MetaDataMap dataMap = workItem.getWorkflow().getMetaDataMap();

isStream =  (InputStream)dataMap.get("filetoUpdateStream");

isStream  value is null ..

Thanks,

Saleem.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

You cannot place an inputStream into a Map - which confirms what i saw in testing. This is what Will has to say: 

They shouldn’t store binary content inside the workflow metadata, at least not as an inputstream.  They should either store it as a byte[] or just add a real file to the repo.  If the inputstream content is large they would not want to store it as a byte[]

7 replies

smacdonald2008
smacdonald2008Accepted solution
New Participant
April 14, 2016

You cannot place an inputStream into a Map - which confirms what i saw in testing. This is what Will has to say: 

They shouldn’t store binary content inside the workflow metadata, at least not as an inputstream.  They should either store it as a byte[] or just add a real file to the repo.  If the inputstream content is large they would not want to store it as a byte[]

Lokesh_Shivalingaiah
New Participant
April 14, 2016

Hi Saleem,

For your usecase, follow the below steps

1. Upload the file using 'AssetManager' API. Get the link where the file would be uploaded

2. Use the path as the 'Payload' and start the workflow,

This would be enough for to initiate the workflow for the uploaded asset. The approach you are following will not work for your usecase.

 

Regards,

Lokesh

smacdonald2008
New Participant
April 14, 2016

I am making progress on this use case - here is the model I am using for testing: 

I have successfully passed a string value - in step 2 - we set a string: 

 String keyValue ="Walk" ; 
 item.getWorkflowData().getMetaDataMap().put("MyInputStreamKey", keyValue);

In Step 3 - we read the map and write to log: 


    String value = item.getWorkflowData().getMetaDataMap().get("MyInputStreamKey", java.lang.String.class);
    log.info("*** In Step 3 - the Retreieved value is " + value);

The log is: 


14.04.2016 08:11:50.318 *INFO* [JobHandler: /etc/workflow/instances/server0/2016-04-13/model_255570656180357:/content/restfulAEMClient] com.aem.worflow.service.CustomGetDataStep *** In Step 3 - the Retreieved value is Walk

I am askign our Eng Members if we can pass an InputStream or only primitive types work. 

smacdonald2008
New Participant
April 14, 2016

I am testing this as well

New Participant
April 14, 2016

My use case is,

file will be uploaded and that has to be activated based on the approval through workflow

I am capturing the file content in to InputStream and putting in to Map avialable in workflowSession.startWorkflow(workflowModel, workflowData, map); method

the  map values can be retrieved in the workflow process step there I am getting null value for the InputStream.

Lokesh_Shivalingaiah
New Participant
April 13, 2016

What is your usecase ??

why do you need InputStream in a map ? 

smacdonald2008
New Participant
April 13, 2016

Will, an AEM workflow eng member talks about how to get data in this ASK the AEM community experts. See this link. https://helpx.adobe.com/experience-manager/using/Workflows.html. The link to the session is in the table at the start of article.