aboutsummaryrefslogtreecommitdiffstats
path: root/gson/src/main/java/org/onap/policy/common/gson/GsonMessageBodyHandler.java
AgeCommit message (Collapse)AuthorFilesLines
2023-09-21Java 17 Upgradeadheli.tavares1-7/+8
Issue-ID: POLICY-4668 Change-Id: If4e79224de61d66d7514f3abbd7b8bee1c3d5681 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
2021-05-06Fix sonars in policy-commonJim Hahn1-2/+2
Fixed sonars: - use "var" instead of actual type name - re-interrupt threads - use rej2 split() instead of String split() Issue-ID: POLICY-3285 Change-Id: I82261e0b8a53ee5c5264556fbf5cec37454f014e Signed-off-by: Jim Hahn <jrh3@att.com>
2021-02-18Add more java.time adaptersPamela Dragosh1-2/+10
The time extensions require these adapters for anyone using our gson adapter to serialize/deserialize the DecisionRequest. Issue-ID: POLICY-2810 Change-Id: I64a7e4a5a256c77bd67dab867664e41b61cd0050 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-03Add gson adapters for special field typesJim Hahn1-2/+8
Added type adapters for Instant, LocalDateTime, and ZonedDateTime. UUID seems to work already. Added new Coder that offers an alternative encoding for Instant. Issue-ID: POLICY-1625 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I5230fa7fe955d78c5f2da1316cb1504b5875ea84
2019-10-29Disable HTML escaping in gson codersJim Hahn1-1/+1
Issue-ID: POLICY-1869 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: Ic757d3a8e7e0e3537ecba979a919b9ea3c1aa797 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-09-16Eliminate constructors with side-effectsJim Hahn1-12/+14
Several of the Gson and Jackson handlers take a GsonBuilder, which they then configure with additional adapters prior to create a Gson object that they subsequently use. The code has been modified so that the constructors no longer take a GsonBuilder, thus eliminating the side-effects that they had on the builders. Instead, a configBuilder() method has been added to the handler classes that makes it clear tht they modify the GsonBuilder. This also has the advantage that classes that want a Gson object configured per a given handler need only call that handler's configBuilder() method; previously, they had to constructor the handler and then retrieve its gson object. Also updated a few tests to specify the HTTP "Accept" header to ensure that return results are in yaml format. Change-Id: I2ef98198041ff9f73913d01ee6ee14ecf20ba617 Issue-ID: POLICY-2081 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-09-13Extract YamlJsonTranslator from StandardYamlCoderJim Hahn1-2/+12
Refactored StandardYamlCoder, extracting a new class, YamlJsonTranslator, from it. This facilitates performing yaml translation when not using a standard "gson" coder. Added YamlJacksonHandler which supports YAML translation layered on top of a JacksonHandler instead of a GsonMessageBodyHandler. Also added junit tests to complete coverage of StandardCoder. Also added public APPLICATION_YAML to YamlMessageBodyHandler. Change-Id: Ia470fa194661fbf1aebeaf0f18b57f2a984cb64b Issue-ID: POLICY-2081 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-11Don't map JSON values to DoubleJim Hahn1-9/+6
By default, gson treats all numbers as Double when placed into a generic Map. This is not backward compatible with existing policy APIs. Added a type adapter that walks Map objects and converts the Double values to Integer or Long, where possible. Made this the default behavior in the GsonMessageBodyHandler, the JacksonHandler, and the StandardCoder. Also fixed a couple of checkstyle errors in the gson project. Change-Id: I9ac0c77e6592d1c039646f0662c077b77a1e9aaf Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-14Add support for TOSCA JSON Parsingliamfallon1-1/+6
Added a getter to allow the Gson object to be retrieved from a GSON message body handler, useful for testing. Moved the TextFileUtils utility class from APEX utilites to policy common utils Issue-ID: POLICY-1195 Change-Id: I7c8074e8177a90b292c6dfd6e7f0d352063818e7 Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-02-22Log which gson style is being usedJim Hahn1-0/+6
Different gson providers may be used for REST APIs. Updated the code to identify which was being used. Change-Id: I8ffbda7409142ec728e217a87c9bcba3c34b814b Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-13Refactor common class from gson codeJim Hahn1-2/+1
The TypeAdapters in the gson-jackson code were nearly identical, so a common class was factored out. This also enabled junit tests to attain 100% coverage on that code, whereas there were a couple of branches that could not be tested previously. Addressed new sonar issues. Removed unused import. Change-Id: Id8e6460c881c6ce0239768f182e4e652cd10645f Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-12Fix sonar issues in gson superclassesJim Hahn1-3/+6
Fixing some of the issues necessitated the use of generic/raw types. Removed version from assertj in pom. Removed trailing spaces. Change-Id: I76e0a05ca06c103ccc876675be04a4ab5e4de5ea Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-08Add superclasses for gson-jackson migrationJim Hahn1-0/+124
Added common classes needed by other gson-jackson code. Modified some logic to make it more maintainable or perform better. Updated comments and spacing. Fix another comment. Moved gson classes from utils to a separate gson project. Added GsonXxx annotations to mirror jackson annotations. Removed unneeded dependencies from gson pom. Removed old GsonMessage class from policy-endpoints. Removed trailing spaces. Updated licenses. Removed more trailing spaces. Removed unneeded checkstyle suppression file from utils. Change-Id: I1a285500faeb0a0b6a1467d09b92ecd3cded713e Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn <jrh3@att.com>