aboutsummaryrefslogtreecommitdiffstats
path: root/utils/src/main/java/org/onap/policy/common/utils/coder
AgeCommit message (Collapse)AuthorFilesLines
2019-10-29Fix new sonar issues in commonJim Hahn1-3/+3
Issue-ID: POLICY-2204 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: If0a11913f614e038ecd3e8c3f0b56d3ac78b03ec Signed-off-by: Jim Hahn <jrh3@att.com>
2019-10-29Merge "Cleanup eclipse warnings in common"Jorge Hernandez1-4/+0
2019-10-29Cleanup eclipse warnings in commonJim Hahn1-4/+0
Issue-ID: POLICY-2204 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: If55ea1a804997ab751f15813e6b643572d4f189f
2019-10-29Disable HTML escaping in gson codersJim Hahn1-4/+4
Issue-ID: POLICY-1869 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: Ic757d3a8e7e0e3537ecba979a919b9ea3c1aa797 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-10-24Integrate CryptoUtils into ONAP commonChou, Joseph (jc2555)1-0/+139
Update junit to add test cases Change-Id: If3236853138a05faac5f51a859b935265c14f0d6 Issue-ID: POLICY-1945 Signed-off-by: Chou, Joseph (jc2555) <jc2555@att.com>
2019-09-13Extract YamlJsonTranslator from StandardYamlCoderJim Hahn3-211/+330
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-09-12Remove YamlException classJim Hahn1-63/+0
After the implementation was finalized, it turned out that YamlException was no longer needed, so it has been deleted. Change-Id: Ie895fc096787f05eff36a6127b08247a7664ff8d Issue-ID: POLICY-2065 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-09-11Create StandardYamlCoderJim Hahn3-0/+348
Created StandardYamlCoder which is like a StandardCoder, except that the original converts to/from JSON, while the new class converts to/from YAML. Also added YamlMessageBodyHandler and incorporated it into the http server so that it supports a media type of */yaml. Change-Id: Ibd83a9f6d355a330f63e435f2bb41affcf1947c2 Issue-ID: POLICY-2065 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-17Convert double to int when decoding via gsonJim Hahn1-2/+20
Refactored MapDoubleAdapterFactory, extracting DoubleConverter to be used by code needing to convert Double to Integer/Long after being decoded by GSON. Enhanced StandardCoder to automatically use the above converter if the desired class is a generic Object. Change-Id: I1d4e83910de41ceda383f257bfea706db2b8fbbe Issue-ID: POLICY-1919 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-11Don't map JSON values to DoubleJim Hahn1-2/+4
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-01Add StandardCoderObject to hide GSON internalsJim Hahn3-1/+166
Added StandardCoderObject to hide GSON's JsonElement so that classes are not dependent on the use of JsonElement, making it easier to switch out serialization mechanisms in the future. Added a test for field-not-found. Converted tabs to spaces in json test file. Simplified StandardCoderObject and added methods to Coder for translating to and from StandardCoderObject. Removed a test for a method that no longer exists. Added more tests to a test case. Change-Id: I5123dc3f17c940ded431ef7f9ccd8c4bff6b1c5f Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-27Add additional encode and decode methods to CoderJim Hahn2-1/+206
Also: Updated some comments and renamed a few parameters. Removed a "throws" for a RuntimeException. Short-circuit some calls. Typo in comment. Let gson create the JsonWriter. Renamed a few more parameters. Change-Id: I22e48c2191820c2a3d0743200edca79bd74353e7 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-27Add common coder classesJim Hahn3-0/+174
Added coder classes as a common utility that can be used to encode and decode json data. Currently, it uses gson, but that can be changed. Separated the Coder interface from implementation. Used assertSame to compare references. Used numbers instead of strings so don't have to deal with escaping quotes in the test cases. Change-Id: Iea9001d2adc5a3150b3367619b5f43e96b5f8b41 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>