Petals BC REST

Move from Jettison to Staxon for JSON<->XML conversion, customization via SU parameters

Details

  • Type: Improvement Request Improvement Request
  • Status: In Progress In Progress
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.0.1-BC
  • Fix Version/s: 1.1.0-BC, 1.2.0-BC
  • Security Level: Public
  • Description:
    Hide

    Jettison is quite limited in the way it can be customized and its badgerfish conversion implementation is missing some important features (in particular to handle JSON document that would be converted to XML documents with multiple roots, something forbidden in XML).

    Staxon is an alternative implementation that supports an improved badgerfish conversion that is customizable.
    It is also more efficient in terms of memory usage and can use gson, jackson or jsr353 as the JSON reader/writer.

    Moving to Staxon introduces the following SU parameters (both for provides and consumes):

    http-body-to-json-multiple-pi default to false
    http-body-from-json-multiple-pi default to false
    
    http-body-to-json-virtual-root default to null
    http-body-from-json-virtual-root default to null
    
    http-body-to-json-auto-array default to false
    
    http-body-to-json-auto-primitive default to false
    
    http-body-to-json-pretty-print default to false
    
    http-body-to-json-ns-declarations default to false
    
    namespace-mapping/@prefix (value is the namespace URI, no mapping by default)

    See https://github.com/beckchr/staxon/wiki/Factory-Configuration for details.

    We could also introduce options to exploit XMLMultipleStreamWriter (see https://github.com/beckchr/staxon/wiki/Mastering-Arrays).

    Show
    Jettison is quite limited in the way it can be customized and its badgerfish conversion implementation is missing some important features (in particular to handle JSON document that would be converted to XML documents with multiple roots, something forbidden in XML). Staxon is an alternative implementation that supports an improved badgerfish conversion that is customizable. It is also more efficient in terms of memory usage and can use gson, jackson or jsr353 as the JSON reader/writer. Moving to Staxon introduces the following SU parameters (both for provides and consumes):
    http-body-to-json-multiple-pi default to false
    http-body-from-json-multiple-pi default to false
    
    http-body-to-json-virtual-root default to null
    http-body-from-json-virtual-root default to null
    
    http-body-to-json-auto-array default to false
    
    http-body-to-json-auto-primitive default to false
    
    http-body-to-json-pretty-print default to false
    
    http-body-to-json-ns-declarations default to false
    
    namespace-mapping/@prefix (value is the namespace URI, no mapping by default)
    See https://github.com/beckchr/staxon/wiki/Factory-Configuration for details. We could also introduce options to exploit XMLMultipleStreamWriter (see https://github.com/beckchr/staxon/wiki/Mastering-Arrays).
  • Environment:
    -

Activity

Hide
Christophe DENEUX added a comment - Wed, 18 Jan 2017 - 09:44:24 +0100 - edited

Perhaps following parameter names should be more human readable as following:

<rest:operation name="edm:archiver">
   ...
   <rest:xml-payload-to-json-conversion>
      <rest:multiple-pi enable="true/false">
      <rest:virtual-root>metadatas</rest:virtual-root>
      <rest:auto-array enable="true/false">
      <rest:ns-declarations enable="true/false">
   </rest:xml-payload-to-json-conversion>
   ...
</rest:operation>

Why don't you provide a parameter to configure namespace mapping ?

In my mind, the parameter 'pretty-print' is not needed. I think that a JSON or XML payload formatted for better readability is not needed by service consumer or provider. Perhaps can we enable it if the log level is set to FINE.

Show
Christophe DENEUX added a comment - Wed, 18 Jan 2017 - 09:44:24 +0100 - edited Perhaps following parameter names should be more human readable as following:
<rest:operation name="edm:archiver">
   ...
   <rest:xml-payload-to-json-conversion>
      <rest:multiple-pi enable="true/false">
      <rest:virtual-root>metadatas</rest:virtual-root>
      <rest:auto-array enable="true/false">
      <rest:ns-declarations enable="true/false">
   </rest:xml-payload-to-json-conversion>
   ...
</rest:operation>
Why don't you provide a parameter to configure namespace mapping ? In my mind, the parameter 'pretty-print' is not needed. I think that a JSON or XML payload formatted for better readability is not needed by service consumer or provider. Perhaps can we enable it if the log level is set to FINE.
Hide
Christophe DENEUX added a comment - Wed, 18 Jan 2017 - 11:28:47 +0100 - edited

About default values, they should be:

  • multiple-pi: true, to manage easily empty array
  • auto-array: false,
  • ns-declarations: false
Show
Christophe DENEUX added a comment - Wed, 18 Jan 2017 - 11:28:47 +0100 - edited About default values, they should be:
  • multiple-pi: true, to manage easily empty array
  • auto-array: false,
  • ns-declarations: false
Hide
Victor NOËL added a comment - Fri, 16 Jun 2017 - 10:09:23 +0200

This is kept open until we decide if we change the default values and parameters names.
Also once it's done, it must be documented!

Show
Victor NOËL added a comment - Fri, 16 Jun 2017 - 10:09:23 +0200 This is kept open until we decide if we change the default values and parameters names. Also once it's done, it must be documented!
Hide
Christophe DENEUX added a comment - Tue, 5 Dec 2017 - 12:00:52 +0100

Add support of namespace mapping when receiving a JSON HTTP response:

<rest:operation name="xxx:yyy">
   ...
   <rest:namespace-mapping prefix="prefix-one">http://petals.org/namespace-1</rest:namespace-mapping>
   <rest:namespace-mapping prefix="prefix-two">http://petals.org/namespace-2</rest:namespace-mapping>
   ...
</rest:operation>
Show
Christophe DENEUX added a comment - Tue, 5 Dec 2017 - 12:00:52 +0100 Add support of namespace mapping when receiving a JSON HTTP response:
<rest:operation name="xxx:yyy">
   ...
   <rest:namespace-mapping prefix="prefix-one">http://petals.org/namespace-1</rest:namespace-mapping>
   <rest:namespace-mapping prefix="prefix-two">http://petals.org/namespace-2</rest:namespace-mapping>
   ...
</rest:operation>
Hide
Christophe DENEUX added a comment - Thu, 4 Jan 2018 - 11:21:36 +0100

Parameter naming rework is postponed to version 1.1.1 or upper

Show
Christophe DENEUX added a comment - Thu, 4 Jan 2018 - 11:21:36 +0100 Parameter naming rework is postponed to version 1.1.1 or upper

People

Dates

  • Created:
    Tue, 17 Jan 2017 - 14:33:13 +0100
    Updated:
    Thu, 15 Feb 2018 - 14:48:35 +0100