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:
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.
Ivo, please see the JaxbContent.getContentMap() method. Would that be sufficient?
Also, this code might help explain some of your questions: https://github.com/droolsjbpm/jbpm/blob/6.0.x/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/impl/model/xml/JaxbContent.java#L56
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?
Good idea, Ivo. I'll see what I can do to acheive this (readable map-values in xml).
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.
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.
Ok lets leave it as it is
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days