Bug 1140881 - Field 'contentMap' from a task content accessed using REST is not being filled(or coming null)
Summary: Field 'contentMap' from a task content accessed using REST is not being fille...
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: Business Central
Version: 6.0.2
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: ER5
: 6.1.0
Assignee: Marco Rietveld
QA Contact: Lukáš Petrovický
Dawn Eisner
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-11 23:07 UTC by William Antônio
Modified: 2020-03-27 20:03 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
When trying to access the node (task) content through the REST API, the contentMap is missing in case of the contentMap being a map. To work around the issue, implement the following code: Map<String, Object> ret = content.getContentMap(); if (ret == null) { ret = (Map<String, Object>) ContentMarshallerHelper.unmarshall(content.getSerializedContent(), null); }
Clone Of:
Environment:
Last Closed: 2020-03-27 20:03:07 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
ClassNotFoundException (13.27 KB, text/plain)
2016-03-16 14:29 UTC, Tomas Livora
no flags Details

Description William Antônio 2014-09-11 23:07:24 UTC
Description of problem:

When accessing a Task Content, the contentMap is null;

How reproducible:

Always.

Steps to Reproduce:

Basically you can follow the steps from this article: https://access.redhat.com/solutions/887653

You need to access an User task content using the URL: /task/{taskId}/content/

Actual results:

Content Map is missing:

{"id":1,"serializedContent":"SERIALIZED CONTENT"}

Expected results:

It should come with values, for example:

{"id":1,"serializedContent":null,"contentMap":{"GroupId":"adm","NodeName":"Aprovar!"},"content":"SERIALIZED CONTENT"}

Comment 2 Marco Rietveld 2014-09-15 14:36:24 UTC
This is primarily a doc fix.

Comment 3 Kris Verlaenen 2014-11-27 14:56:31 UTC
Marco, could you clarify?  What is the way to get the content of a task through the remote API correctly?

Comment 4 Marco Rietveld 2015-01-20 14:50:44 UTC
Fixed (with caveat, see below). Commits: 

6.2.x: 
https://github.com/droolsjbpm/jbpm/commit/8922b2bc

master: 
https://github.com/droolsjbpm/jbpm/commit/a324d8f4

-- 
Caveat:

The operation shown above is the correct way to get the task content. 

The reporter (and many others) are mistakenly assuming that the task content is always a map, which is it is often, but not always: task content can sometimes simply be a different object as a map. 

The REST operation (or any other operation!) can't "know" what sort of content the user has decided to associate with the task -- that kind of information would have to be added with a new feature (and a thorough refactoring of how we now associate information with tasks!). 

However, I can understand the mistake: the documentation does not explain this, not to mention that the task content API is neither clear nor easy-to-use. The documentation for this has to be improved. 

The fix here was that I had created a 'contentMap' field, but that I was never filling it: William, thank you for catching this!

Comment 5 Ivo Bek 2015-02-17 15:57:02 UTC
Hi Marco and William,

I am not sure what is wrong in this BZ because we have the task content REST operation covered since BZ 1057749 and the tests passed in the last recent builds too (we check that the contentMap contains the fields), hence I cannot use them to verify this issue. Is it any specific content that was not filled?

Comment 6 Marco Rietveld 2015-02-18 12:21:41 UTC
Hi Ivo, 

The only specific issue here is that the contentMap field in the org.kie.remote.jaxb.gen.Content instance returned to the client was not being filled when the content was a map. 

Does that make sense?

Comment 7 Ivo Bek 2015-02-18 12:30:29 UTC
Oh, map in a map, I see :) ... thank you Marco

Comment 8 Ivo Bek 2015-02-26 15:23:29 UTC
Verification failed in BPMS 6.1.0.ER5

I noticed that I had an unintentional workaround:

[X] Map<String, Object> ret = content.getContentMap();
if (ret == null) {
  ret = (Map<String, Object>) ContentMarshallerHelper.unmarshall(content.getSerializedContent(), null);
}

However, when I remove it so it uses just the line [X], the map is null:

Notice that the returned content is still without the contentMap element:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><content><id>14</id><content>rO0ABXoAAAF4CgYIBhACGABKlwIIABJIb3JnLmRyb29scy5jb3JlLm1hcnNoYWxsaW5nLmltcGwuU2VyaWFsaXphYmxlUGxhY2Vob2xkZXJSZXNvbHZlclN0cmF0ZWd5GsgBrO0ABXNyABNqYXZhLnV0aWwuQXJyYXlMaXN0eIHSHZnHYZ0DAAFJAARzaXpleHAAAAAEdwQAAAAEdAAEaWJla3QADE15T2JqZWN0VGFza3QADk15IE9iamVjdCBUYXNrc3IAKW9yZy5qYm9zcy5xYS5icG1zLmpicG0uaW50ZWdyYXRpb24uTXlUeXBlAAAAAAAAAAECAAFMAAR0ZXh0dAASTGphdmEvbGFuZy9TdHJpbmc7eHB0AA5teSBvYmplY3QgdGV4dHhSVAoRCgdBY3RvcklkEAAaBAAAAAAKEgoIVGFza05hbWUQABoEAAAAAQoSCghOb2RlTmFtZRAAGgQAAAACChcKDWlucHV0TXlPYmplY3QQABoEAAAAAw==</content></content>

Comment 10 Marco Rietveld 2015-03-09 08:58:16 UTC
Note to myself: since there is a workaround, engineering is currently recommending this *not* be a blocker.

Comment 13 Maciej Swiderski 2016-03-15 18:17:25 UTC
As much as I could test this works properly. When issuing GET request for this endpoint:http://localhost:8080/kie-wb/rest/task/2/content

I received following response content:
<content>

<id>2</id>

<content>rO0ABXoAAAFyCgYIBxAAGABK8AEIABJIb3JnLmRyb29scy5jb3JlLm1hcnNoYWxsaW5nLmltcGwuU2VyaWFsaXphYmxlUGxhY2Vob2xkZXJSZXNvbHZlclN0cmF0ZWd5GqEBrO0ABXNyABNqYXZhLnV0aWwuQXJyYXlMaXN0eIHSHZnHYZ0DAAFJAARzaXpleHAAAAAGdwQAAAAGdAAiUGxlYXNlIHBlcmZvcm0gYSBzZWxmLWV2YWx1dGF0aW9uLnQABHRlc3R0ABVQZXJmb3JtYW5jZUV2YWx1YXRpb250AA9TZWxmIEV2YWx1YXRpb250AAVmYWxzZXQABm1hY2lla3hSdQoRCgdDb21tZW50EAAaBAAAAAAKEAoGcmVhc29uEAAaBAAAAAEKEgoIVGFza05hbWUQABoEAAAAAgoSCghOb2RlTmFtZRAAGgQAAAADChMKCVNraXBwYWJsZRAAGgQAAAAEChEKB0FjdG9ySWQQABoEAAAABQ==</content>

<contentMap>
<entry key="Comment" class-name="java.lang.String">rO0ABXQAIlBsZWFzZSBwZXJmb3JtIGEgc2VsZi1ldmFsdXRhdGlvbi4=</entry>
<entry key="reason" class-name="java.lang.String">rO0ABXQABHRlc3Q=</entry>
<entry key="TaskName" class-name="java.lang.String">rO0ABXQAFVBlcmZvcm1hbmNlRXZhbHVhdGlvbg==</entry>
<entry key="NodeName" class-name="java.lang.String">rO0ABXQAD1NlbGYgRXZhbHVhdGlvbg==</entry>
<entry key="Skippable" class-name="java.lang.String">rO0ABXQABWZhbHNl</entry>
<entry key="ActorId" class-name="java.lang.String">rO0ABXQABm1hY2llaw==</entry></contentMap>

</content>

as you can see the contentMap is filled in. It still has serialized value but this is intended as the marshaling framework uses StringKeyObjectValueMapXmlAdapter that is responsible for round tripping of the values.

@Ivo,

would it be possible to test this on latest build with your test cases?

Comment 14 Tomas Livora 2016-03-16 14:28:50 UTC
Maciej,
it works unless you use an object of your own type. In that case you get ClassNotFoundException and a response without contentMap:

<content>

<id>9</id>

<content>rO0ABXoAAAF4CgYIBhAEGABKlwIIABJIb3JnLmRyb29scy5jb3JlLm1hcnNoYWxsaW5nLmltcGwuU2VyaWFsaXphYmxlUGxhY2Vob2xkZXJSZXNvbHZlclN0cmF0ZWd5GsgBrO0ABXNyABNqYXZhLnV0aWwuQXJyYXlMaXN0eIHSHZnHYZ0DAAFJAARzaXpleHAAAAAEdwQAAAAEc3IAKW9yZy5qYm9zcy5xYS5icG1zLmpicG0uaW50ZWdyYXRpb24uTXlUeXBlAAAAAAAAAAECAAFMAAR0ZXh0dAASTGphdmEvbGFuZy9TdHJpbmc7eHB0AA5teSBvYmplY3QgdGV4dHQABGliZWt0AAxNeU9iamVjdFRhc2t0AA5NeSBPYmplY3QgVGFza3hSVAoXCg1pbnB1dE15T2JqZWN0EAAaBAAAAAAKEQoHQWN0b3JJZBAAGgQAAAABChIKCFRhc2tOYW1lEAAaBAAAAAIKEgoITm9kZU5hbWUQABoEAAAAAw==</content>

</content>

It seems that there is some problem with class loading. Because the class is present on both server and client side and is used in other tests without any problems.

Comment 15 Tomas Livora 2016-03-16 14:29:39 UTC
Created attachment 1137058 [details]
ClassNotFoundException


Note You need to log in before you can comment on or make changes to this bug.