Bug 1252049

Summary: REST API does not support Map / Set
Product: [Retired] JBoss BPMS Platform 6 Reporter: Anton Giertli <agiertli>
Component: Business CentralAssignee: Shelly McGowan <smcgowan>
Status: CLOSED EOL QA Contact: Lukáš Petrovický <lpetrovi>
Severity: high Docs Contact:
Priority: high    
Version: 6.1.0CC: kverlaen
Target Milestone: ER3   
Target Release: 6.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-27 19:40:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
[0] remote client
none
[1] process which can be used for testing none

Description Anton Giertli 2015-08-10 14:39:12 UTC
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 14:40:00 UTC
Created attachment 1061118 [details]
[1] process which can be used for testing

Comment 3 Anton Giertli 2015-08-10 14:42:03 UTC
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 13:31:00 UTC
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 15:12:40 UTC
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 11:37:11 UTC
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 14:36:51 UTC
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.