Bug 1252049 - REST API does not support Map / Set
Summary: REST API does not support Map / Set
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: Business Central
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ER3
: 6.2.0
Assignee: Shelly McGowan
QA Contact: Lukáš Petrovický
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-08-10 14:39 UTC by Anton Giertli
Modified: 2020-03-27 19:40 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-03-27 19:40:48 UTC
Type: Bug
Embargoed:


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

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.


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