Bug 1252049 - REST API does not support Map / Set
REST API does not support Map / Set
Status: VERIFIED
Product: JBoss BPMS Platform 6
Classification: JBoss
Component: Business Central (Show other bugs)
6.1.0
Unspecified Unspecified
high Severity high
: ER3
: 6.2.0
Assigned To: Shelly McGowan
Lukáš Petrovický
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-10 10:39 EDT by Anton Giertli
Modified: 2018-01-30 23:41 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
[0] remote client (15.61 KB, application/zip)
2015-08-10 10:39 EDT, Anton Giertli
no flags Details
[1] process which can be used for testing (10.46 KB, application/xml)
2015-08-10 10:40 EDT, Anton Giertli
no flags Details

  None (edit)
Description Anton Giertli 2015-08-10 10:39:12 EDT
Created attachment 1061117 [details]
[0] remote client

Description of problem:
It is not possible to use Map or Set as a variable data type in a REST API.

The client or server won't raise any exception but the actual data are lost during the serialization.

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

BPMS 6.1.2
How reproducible:
always

Steps to Reproduce:
1. Run the attached client against the attached process deployed in the business-central
OR
Create a process which has Human or Custom Task with the output variable of type Map or Set. Then try to complete this task with the REST Client. If some logging implementation (i.e. slf4j-simple) is on the classpath and log level is set to trace it is clear that the actual data from the Set or Map are lost during the serialization.

Actual results:
Data from the Set or Map are lost during the serialization when using REST Client

Expected results:
Data from the Set or Map are *not* lost during the serialization when using REST Client

Additional info:
See this snippet which shows the data loss
http://pastebin.com/w6TaZicn
Comment 1 Anton Giertli 2015-08-10 10:40:00 EDT
Created attachment 1061118 [details]
[1] process which can be used for testing
Comment 3 Anton Giertli 2015-08-10 10:42:03 EDT
Forgot to add - HashSet and HashMap were added into the kie-deployment-descriptor on the server side.

Customer suggested that this may be solved by adding the support for the mentioned classes into org.kie.services.client.api.command.AbstractRemoteCommandObject
Comment 4 Anton Giertli 2015-08-11 09:31:00 EDT
Also, both 

Set<PrimitiveType>  + Map<PrimitiveType><PrimitiveType>
and
Set<CustomDataType> + Map<CustomDataType><CustomDataType>

should be supported once the implementation/fix is in place.
Comment 5 Anton Giertli 2015-08-11 11:12:40 EDT
I made a typo in the comment #3, this is what Customer originally suggested:

===

Bug fix changes:
- Create the JAXB wrapper for the Set and Map.
- Change the org.kie.remote.jaxb.gen.util.JaxbUnknownAdapter 

 @Override
    public Object marshal(Object o) throws Exception {
        if ( o instanceof List ) {
            List v = ( List ) o;
            return new JaxbListWrapper( v.toArray( new Object[v.size()]) );
       } else if (o instanceof Set) {
       // do magic
       } else if (o instanceof Map) {
       // do magic
        } else {
            return o;
        }
    }

    @Override
    public Object unmarshal(Object o) throws Exception {
        if ( o instanceof JaxbListWrapper ) {
            JaxbListWrapper v = ( JaxbListWrapper ) o;
            return Arrays.asList( v.getElements() );
       } else if (o instanceof JaxbSetWrapper) {
       // do magic
       } else if (o instanceof JaxbMapWrapper) {
       // do magic
        } else {
            return o;
        }
    }
===
Comment 7 Marco Rietveld 2015-09-15 07:37:11 EDT
Fixed. Commits: 

master:
https://github.com/droolsjbpm/drools/commit/c8fff9e69
https://github.com/droolsjbpm/droolsjbpm-integration/commit/7da9f9b4 

6.3.x: 
https://github.com/droolsjbpm/drools/commit/d0a55b8e
https://github.com/droolsjbpm/droolsjbpm-integration/commit/dbd8748b

These commits also contain updates to the REST operation that allows users to retrieve process instance variables from the process instance itself: 

../rest/{deploymentId}/process/instance/{procInstId}/variable/{varName}

Deserialization of results from this operation for map, set, list and in particular, nested map or set or list variables (for example: Map<String, Map<String, Object>>) is non-trivial and should be approached with care.  

Support for java.util.Queue instances will *not* be provided, because there is support for java.util.List instances. Support for Queue instances would only place more emphasis on the script and non-BPM code, which is contrary to the vision behind jBPM.
Comment 8 Tomas Livora 2015-11-06 09:36:51 EST
Verified on BPMS 6.2.0 ER5

Map and Set variables work well with REST and JMS client. However, it is not possible to use them with REST or SOAP APIs. Since this bug was reported just for REST client, I am closing it and I have created a new one (bug 1278844) targeting REST and SOAP APIs.

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