Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Proper way of iteration of MetadataMap and convert all values to Aem

Avatar

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
DIPEN1
Level 2

09-01-2019

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?

Replies

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

09-01-2019

Show your code - it will help the community to know exactly what you are trying to do.

Avatar

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
DIPEN1
Level 2

10-01-2019

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.

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,348 likes

Total Posts

3,226 posts

Correct Reply

916 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,348 likes

Total Posts

3,226 posts

Correct Reply

916 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

10-01-2019

Avatar

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
DIPEN1
Level 2

10-01-2019

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.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

10-01-2019

In each step, are you working with a different map?

Avatar

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
DIPEN1
Level 2

10-01-2019

No. Same map

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

10-01-2019

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)

Avatar

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
DIPEN1
Level 2

10-01-2019

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.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

10-01-2019

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().