I am trying to iterate workflow metadatamap and convert all items into string. I found then metadatamap.get(key) returns an object of javax.jcr.Value. So I have written a code to get values and check the type and convert accordingly.
It was working fine until I put one string value to Metadata Map in one process step using MetadataMap.put("somekey","some string value").So in next process step while iteration it is directly returning string instead of javax.jcr.Value. But in between these two step if I add one participant step or task , it's returning Value object.
Why is this behaviour?
Views
Replies
Total Likes
Show your code - it will help the community to know exactly what you are trying to do.
Views
Replies
Total Likes
This is in a process Step
workitem.getWorkflowData().getMetadataMap().put("someKey", "Some sample value");
Next Process Step has below :
for(Map.Entry<String, Object> entry : metadatamap.entrySet()){
String key = entry.getKey();
Object value = entry.getValue();
int type = ((javax.jcr.Value)value).getType();
switch (type){
case PropertyType.String:
//Do something like someothermap.put(key, metadatamap.get(key, String.class));
case PropertyType.Date:
//Do something
//And so on like that
}
}
Now issue is if these process steps are one after another, I get a class cast exception that String can not be type cast to Value. And the workflow fails.
But it works in two scenario:
1. If I introduce a participant step in between these two process step.
2. Once its failed. If I go to AEM inbox and click retry this step.
In both scenario I get the value of "someKey" as a object of javax.jcr.Value.
NOTE: I need to write a generic method to traverse MetadataMap and put all its value to an another map with specific String representation. Any alternative would be helpful as well.
Views
Replies
Total Likes
Hi,
Please check, how to pass String value between steps.
Adobe Experience Manager Help | Passing Values between Adobe Experience Manager Workflow Steps
Views
Replies
Total Likes
Similar way I am passing String value between steps. But retrieval is different. If I want to retrieve specific value with keys its working but I want to retrieve all value and convert into a map of String representation of all values. So sometime metadataMap.get(key) returns String sometime it returns javax.jcr.Value object.
Views
Replies
Total Likes
In each step, are you working with a different map?
Views
Replies
Total Likes
No. Same map
Views
Replies
Total Likes
If using the same map - and you iterate through it within a custom step - are you using issues in a single Java class (which represents the step)
Views
Replies
Total Likes
map is updated in one process step and retrieval is done in another process step. It works fine if there is a participant step or create task step. But it gives type cast exception when there is no such step which halts the workflow.
If there is no such participant step, map.get() returns String object instead of Value object.
Additionally I am facing another issue, i.e. I have a process step which moves the dam asset to another folder. After that in next process step sometime payload path is updated with new path, sometime its not. Not sure if root cause for both issues are same. But similarly adding participant step after asset movement step always returns updated payload path.
Views
Replies
Total Likes
In you process step that moves the DAM Asset - how are you implementing it - are you using the AssetManager API - as shown here --
Moving Digital Assets using Adobe Experience Manager Workflows
I found best way to move asset is to invoke the copyAsset().
Views
Replies
Total Likes
Yes, we are using AssetManager api but not copyAsset() and removeAsset(). We are using moveAsset(oldPath, newPath).
Views
Replies
Total Likes
To get the Map - are you reading the assets metadata. That should return a map.
However (regardless of how you get the Map) - what sounds strange to me is the fact that you need a part step to properly read the map in subsequent steps.
Views
Replies
Total Likes
Its not asset metadata. Asset metadata returns ValueMap and I am able to iterate complete valueMap. I am trying to iterate Workflow metadata i.e. com.adobe.granite.workflow.metadata.MetaDataMap
As MetaDataMap implementation is not public, it is very difficult to understand what is happening inside.
Views
Replies
Total Likes
I am gonig to setup this up and see if i can reproduce your results. This is interesting.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Like
Replies
Views
Likes
Replies
Views
Likes
Replies