Bug 1085458 - A task content requested via REST API cannot be used outside Java
Summary: A task content requested via REST API cannot be used outside Java
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: Business Central
Version: 6.0.1
Hardware: Unspecified
OS: Unspecified
medium
high
Target Milestone: ER3
: 6.1.0
Assignee: Marco Rietveld
QA Contact: Ivo Bek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-04-08 16:08 UTC by Ivo Bek
Modified: 2023-09-14 02:06 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-12-07 13:03:44 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 887653 0 None None None Never

Description Ivo Bek 2014-04-08 16:08:08 UTC
Description of problem:

When I request for a task content (http://localhost:8080/business-central/rest/task/content/2), I will get something like:

XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><content><id>2</id><class-name>java.util.HashMap</class-name><content-map><entry key="ActorId" class-name="java.lang.String">rO0ABXQABGliZWs=</entry><entry key="TaskName" class-name="java.lang.String">rO0ABXQACUhlbGxvVGFzaw==</entry><entry key="NodeName" class-name="java.lang.String">rO0ABXQABUhlbGxv</entry></content-map></content>

JSON:

{"id":2,"serializedContent":null,"contentMap":{"ActorId":"ibek","TaskName":"HelloTask","NodeName":"Hello"},"content":"rO0ABXoAAAJcCgYIBRAEGABKuQQIABJIb3JnLmRyb29scy5jb3JlLm1hcnNoYWxsaW5nLmltcGwuU2VyaWFsaXphYmxlUGxhY2Vob2xkZXJSZXNvbHZlclN0cmF0ZWd5GuoDrO0ABXNyABNqYXZhLnV0aWwuQXJyYXlMaXN0eIHSHZnHYZ0DAAFJAARzaXpleHAAAAAEdwQAAAAEdAAEaWJla3QACUhlbGxvVGFza3QABUhlbGxvc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA/QAAAAAAADHcIAAAAEAAAAAN0AAdBY3Rvcklkc3IAN2NvbS5nb29nbGUucHJvdG9idWYuR2VuZXJhdGVkTWVzc2FnZUxpdGUkU2VyaWFsaXplZEZvcm0AAAAAAAAAAAIAAlsAB2FzQnl0ZXN0AAJbQkwAEG1lc3NhZ2VDbGFzc05hbWV0ABJMamF2YS9sYW5nL1N0cmluZzt4cHVyAAJbQqzzF/gGCFTgAgAAeHAAAAARCgdBY3RvcklkEAAaBAAAAAB0AC9vcmcuamJwbS5tYXJzaGFsbGluZy5pbXBsLkpCUE1NZXNzYWdlcyRWYXJpYWJsZXQACFRhc2tOYW1lc3EAfgAIdXEAfgAMAAAAEgoIVGFza05hbWUQABoEAAAAAXEAfgAOdAAITm9kZU5hbWVzcQB+AAh1cQB+AAwAAAASCghOb2RlTmFtZRAAGgQAAAACcQB+AA54eFIWCgx2YXJpYWJsZXNNYXAQABoEAAAAAw=="}

Notice that the values of entries contain humanly unreadable content. I believe that the values are always strings, aren't they? So, it might be enough to change the return type from Map<String, Object> to Map<String, String>. If it is not possible to change the type, then it could be done by marshalling the content as it must be of type of class known for JAXB context.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Kris Verlaenen 2014-04-09 11:28:56 UTC
The task content can in theory be any binary content, although in practice for Task created through the processes it's usually a Map<String, Object>.  Can't you use something like ContentMarshallerHelper to deserialize this content?  

Marco, do you filter out anything that is not String?  I assume support for primitive data types and custom types that can be transformed (for example using jaxb) is considered, if not now possibly in the future, so not sure transforming the output to something human readable by assuming it's <String,String> is a good longer-term strategy.

Comment 2 Marco Rietveld 2014-04-09 13:58:55 UTC
Ivo, please see the JaxbContent.getContentMap() method. Would that be sufficient?

Comment 4 Ivo Bek 2014-04-09 15:14:32 UTC
Ok I didn't realize that the content can be anything, including binary data. The idea of content map might be sufficient but I don't understand why XML content map against JSON contains values encoded in base64.

There is no problem in using the content in java. The title of BZ is not perfect because I didn't know that the values are encoded in base64, so I worried if anybody is able to use the content in another (python, ruby, ...) scripts/applications.

I would like to see both results (in XML and JSON) to look similar in the matter of structure and to see the content of map as I do in JSON ("contentMap":{"ActorId":"ibek","TaskName":"HelloTask","NodeName":"Hello"}). Is it possible? I believe that data of any request or response should be readable as much as possible because it is the meaning of these remote APIs, isn't it?

Comment 5 Marco Rietveld 2014-04-15 07:38:45 UTC
Good idea, Ivo. I'll see what I can do to acheive this (readable map-values in xml).

Comment 6 Marco Rietveld 2014-11-25 22:05:13 UTC
At the moment, serializing a JaxbContent instance with both the content and contentMap fields filled, results in the following: 


JSON:
--------- 
{"id":23,"content":"rO0ABXoAAAE2CgYIBhADGABKiQIIABJIb3JnLmRyb29scy5jb3JlLm1hcnNoYWxsaW5nLmltcGwuU2VyaWFsaXphYmxlUGxhY2Vob2xkZXJSZXNvbHZlclN0cmF0ZWd5GroBrO0ABXNyABNqYXZhLnV0aWwuQXJyYXlMaXN0eIHSHZnHYZ0DAAFJAARzaXpleHAAAAACdwQAAAAKc3IAEWphdmEubGFuZy5JbnRlZ2VyEuKgpPeBhzgCAAFJAAV2YWx1ZXhyABBqYXZhLmxhbmcuTnVtYmVyhqyVHQuU4IsCAAB4cAAAABdzcgAOamF2YS5sYW5nLkxvbmc7i+SQzI8j3wIAAUoABXZhbHVleHEAfgADAAAAAAAAAC14UiAKDgoEbGlmZRAAGgQAAAAACg4KBHNpY2sQABoEAAAAAQ==","contentMap":{"life":23,"sick":45}}
---------

JAXB/XML:
---------
<content>
    <id>23</id>
    <content>rO0ABXoAAAE2CgYIBhADGABKiQIIABJIb3JnLmRyb29scy5jb3JlLm1hcnNoYWxsaW5nLmltcGwuU2VyaWFsaXphYmxlUGxhY2Vob2xkZXJSZXNvbHZlclN0cmF0ZWd5GroBrO0ABXNyABNqYXZhLnV0aWwuQXJyYXlMaXN0eIHSHZnHYZ0DAAFJAARzaXpleHAAAAACdwQAAAAKc3IAEWphdmEubGFuZy5JbnRlZ2VyEuKgpPeBhzgCAAFJAAV2YWx1ZXhyABBqYXZhLmxhbmcuTnVtYmVyhqyVHQuU4IsCAAB4cAAAABdzcgAOamF2YS5sYW5nLkxvbmc7i+SQzI8j3wIAAUoABXZhbHVleHEAfgADAAAAAAAAAC14UiAKDgoEbGlmZRAAGgQAAAAACg4KBHNpY2sQABoEAAAAAQ==</content>
    <content-map>
        <entry class-name="java.lang.Integer" key="life">rO0ABXNyABFqYXZhLmxhbmcuSW50ZWdlchLioKT3gYc4AgABSQAFdmFsdWV4cgAQamF2YS5sYW5nLk51bWJlcoaslR0LlOCLAgAAeHAAAAAX</entry>
        <entry class-name="java.lang.Long" key="sick">rO0ABXNyAA5qYXZhLmxhbmcuTG9uZzuL5JDMjyPfAgABSgAFdmFsdWV4cgAQamF2YS5sYW5nLk51bWJlcoaslR0LlOCLAgAAeHAAAAAAAAAALQ==</entry>
    </content-map>
</content>
-----------

This behaviour fulfills the issue, as far as I can tell.

If this is not the case, please reopen the bugzilla and let me know what you think needs to be changed.

Comment 7 Ivo Bek 2015-01-05 17:13:35 UTC
Hi Marco,

I am glad the both messages have the same structure containing id, content, and content-map. Could not you make the map-values readable in xml according to Comment 5 https://bugzilla.redhat.com/show_bug.cgi?id=1085458#c5? I thought that the xml might look like:

<content>
    <id>23</id>
<content>rO0ABXoAAAE2CgYIBhADGABKiQIIABJIb3JnLmRyb29scy5jb3JlLm1hcnNoYWxsaW5nLmltcGwuU2VyaWFsaXphYmxlUGxhY2Vob2xkZXJSZXNvbHZlclN0cmF0ZWd5GroBrO0ABXNyABNqYXZhLnV0aWwuQXJyYXlMaXN0eIHSHZnHYZ0DAAFJAARzaXpleHAAAAACdwQAAAAKc3IAEWphdmEubGFuZy5JbnRlZ2VyEuKgpPeBhzgCAAFJAAV2YWx1ZXhyABBqYXZhLmxhbmcuTnVtYmVyhqyVHQuU4IsCAAB4cAAAABdzcgAOamF2YS5sYW5nLkxvbmc7i+SQzI8j3wIAAUoABXZhbHVleHEAfgADAAAAAAAAAC14UiAKDgoEbGlmZRAAGgQAAAAACg4KBHNpY2sQABoEAAAAAQ==</content>
    <content-map>
        <entry class-name="java.lang.Integer" key="life">23</entry>
        <entry class-name="java.lang.Long" key="sick">45</entry>
    </content-map>
</content>

If it is complicated and it might cause other problems, we can leave it as it is.

Comment 8 Ivo Bek 2015-12-07 13:03:44 UTC
Ok lets leave it as it is

Comment 9 Red Hat Bugzilla 2023-09-14 02:06:02 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days


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