diff options
-rw-r--r-- | aai-core/src/main/java/org/onap/aai/util/PojoUtils.java | 84 | ||||
-rw-r--r-- | aai-parent/pom.xml | 37 |
2 files changed, 60 insertions, 61 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java b/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java index 83dc4698..d83c9ec3 100644 --- a/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java +++ b/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.nio.charset.Charset; import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collection; @@ -50,6 +51,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; import com.google.common.base.CaseFormat; import com.google.common.collect.Multimap; @@ -59,12 +61,12 @@ public class PojoUtils { /** * Gets the key value list. * - * @param <T> the generic type - * @param e the e + * @param <T> the generic type + * @param e the e * @param clazz the clazz * @return the key value list - * @throws IllegalAccessException the illegal access exception - * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws IllegalArgumentException the illegal argument exception * @throws InvocationTargetException the invocation target exception */ public <T> List<KeyValueList> getKeyValueList(Entity e, T clazz) @@ -97,12 +99,12 @@ public class PojoUtils { /** * Gets the json from object. * - * @param <T> the generic type + * @param <T> the generic type * @param clazz the clazz * @return the json from object * @throws JsonGenerationException the json generation exception - * @throws JsonMappingException the json mapping exception - * @throws IOException Signals that an I/O exception has occurred. + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. */ public <T> String getJsonFromObject(T clazz) throws JsonGenerationException, JsonMappingException, IOException { return getJsonFromObject(clazz, false, true); @@ -111,29 +113,26 @@ public class PojoUtils { /** * Gets the json from object. * - * @param <T> the generic type - * @param clazz the clazz + * @param <T> the generic type + * @param clazz the clazz * @param wrapRoot the wrap root - * @param indent the indent + * @param indent the indent * @return the json from object * @throws JsonGenerationException the json generation exception - * @throws JsonMappingException the json mapping exception - * @throws IOException Signals that an I/O exception has occurred. + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. */ public <T> String getJsonFromObject(T clazz, boolean wrapRoot, boolean indent) throws JsonGenerationException, JsonMappingException, IOException { - ObjectMapper mapper = new ObjectMapper(); - - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - - mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); - mapper.configure(SerializationFeature.INDENT_OUTPUT, indent); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, wrapRoot); - - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, wrapRoot); - - mapper.registerModule(new JaxbAnnotationModule()); + ObjectMapper mapper = JsonMapper.builder() + .serializationInclusion(JsonInclude.Include.NON_NULL) + .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) + .configure(SerializationFeature.INDENT_OUTPUT, indent) + .configure(SerializationFeature.WRAP_ROOT_VALUE, wrapRoot) + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(DeserializationFeature.UNWRAP_ROOT_VALUE, wrapRoot) + .addModule(new JaxbAnnotationModule()) + .build(); return mapper.writeValueAsString(clazz); } @@ -141,14 +140,14 @@ public class PojoUtils { /** * Gets the json from dynamic object. * - * @param ent the ent + * @param ent the ent * @param jaxbContext the jaxb context * @param includeRoot the include root * @return the json from dynamic object * @throws JsonGenerationException the json generation exception - * @throws JsonMappingException the json mapping exception - * @throws IOException Signals that an I/O exception has occurred. - * @throws JAXBException the JAXB exception + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. + * @throws JAXBException the JAXB exception */ public String getJsonFromDynamicObject(DynamicEntity ent, org.eclipse.persistence.jaxb.JAXBContext jaxbContext, boolean includeRoot) throws JsonGenerationException, JsonMappingException, IOException, JAXBException { @@ -167,7 +166,7 @@ public class PojoUtils { /** * Gets the xml from object. * - * @param <T> the generic type + * @param <T> the generic type * @param clazz the clazz * @return the xml from object * @throws JAXBException the JAXB exception @@ -180,16 +179,17 @@ public class PojoUtils { Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(clazz, baos); - return baos.toString(); + + return baos.toString(Charset.defaultCharset()); } } /** * Gets the lookup key. * - * @param baseKey the base key + * @param baseKey the base key * @param lookupHash the lookup hash - * @param keyProps the key props + * @param keyProps the key props * @return the lookup key */ public String getLookupKey(String baseKey, HashMap<String, Object> lookupHash, Collection<String> keyProps) { @@ -213,7 +213,7 @@ public class PojoUtils { /** * Gets the lookup keys. * - * @param lookupHashes the lookup hashes + * @param lookupHashes the lookup hashes * @param _dbRulesNodeKeyProps the db rules node key props * @return the lookup keys */ @@ -237,16 +237,16 @@ public class PojoUtils { /** * Gets the example object. * - * @param <T> the generic type - * @param clazz the clazz + * @param <T> the generic type + * @param clazz the clazz * @param singleton the singleton * @return the example object - * @throws IllegalAccessException the illegal access exception - * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws IllegalArgumentException the illegal argument exception * @throws InvocationTargetException the invocation target exception - * @throws NoSuchMethodException the no such method exception - * @throws SecurityException the security exception - * @throws AAIException the AAI exception + * @throws NoSuchMethodException the no such method exception + * @throws SecurityException the security exception + * @throws AAIException the AAI exception */ public <T> void getExampleObject(T clazz, boolean singleton) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, @@ -304,8 +304,8 @@ public class PojoUtils { * Gets the dynamic example object. * * @param childObject the child object - * @param aaiRes the aai res - * @param singleton the singleton + * @param aaiRes the aai res + * @param singleton the singleton * @return the dynamic example object */ public void getDynamicExampleObject(DynamicEntity childObject, AAIResource aaiRes, boolean singleton) { diff --git a/aai-parent/pom.xml b/aai-parent/pom.xml index c19a1e06..ed402912 100644 --- a/aai-parent/pom.xml +++ b/aai-parent/pom.xml @@ -40,47 +40,46 @@ limitations under the License. <properties> <!-- update this just prior to release or figure out something with version.properties --> <aai.release.version>${aai.common.version}</aai.release.version> - <aai.common.logging.version>1.5.1</aai.common.logging.version> - <aai.rest.client.version>1.5.1</aai.rest.client.version> - <aai.schema.service.version>1.7.3</aai.schema.service.version> + <aai.common.logging.version>1.8.0</aai.common.logging.version> + <aai.rest.client.version>1.6.4</aai.rest.client.version> + <aai.schema.service.version>1.9.6</aai.schema.service.version> <aaf.version>2.1.15</aaf.version> - <antlr.version>4.7.2</antlr.version> + <antlr.version>4.11.1</antlr.version> <activemq.version>5.16.1</activemq.version> <codehaus.jackson.version>1.9.13</codehaus.jackson.version> <commons.beanutils.version>1.9.4</commons.beanutils.version> - <commons.cli.version>1.4</commons.cli.version> + <commons.cli.version>1.5.0</commons.cli.version> <commons.compress.version>1.21</commons.compress.version> <commons.configuration.version>1.10</commons.configuration.version> - <commons.io.version>2.8.0</commons.io.version> - <commons.lang.version>2.6</commons.lang.version> + <commons.io.version>2.11.0</commons.io.version> <commons.lang3.version>3.9</commons.lang3.version> - <commons.net.version>3.6</commons.net.version> - <commons.text.version>1.8</commons.text.version> - <docker.fabric.version>0.31.0</docker.fabric.version> - <dmaap.client.version>1.1.9</dmaap.client.version> - <easy.mock.version>4.0.2</easy.mock.version> + <commons.net.version>3.8.0</commons.net.version> + <commons.text.version>1.10.0</commons.text.version> + <docker.fabric.version>0.40.2</docker.fabric.version> + <dmaap.client.version>1.1.12</dmaap.client.version> + <easy.mock.version>5.0.0</easy.mock.version> <eclipse.persistence.version>2.7.11</eclipse.persistence.version> <eelf.core.version>2.0.0-oss</eelf.core.version> <freemarker.version>2.3.31</freemarker.version> - <google.guava.version>19.0</google.guava.version> + <google.guava.version>31.1-jre</google.guava.version> <gremlin.version>3.2.3</gremlin.version> <groovy.version>2.5.15</groovy.version> - <gson.version>2.8.6</gson.version> + <gson.version>2.9.1</gson.version> <hamcrest.junit.version>2.0.0.0</hamcrest.junit.version> <hamcrest.core.version>2.2</hamcrest.core.version> - <jackson.bom.version>2.10.1</jackson.bom.version> + <jackson.bom.version>2.11.4</jackson.bom.version> <janusgraph.version>0.2.3</janusgraph.version> <javatuples.version>1.2</javatuples.version> <jaxb.version>2.3.1</jaxb.version> <old.jaxb.version>2.3.0.1</old.jaxb.version> - <jaxrs.version>2.0.1</jaxrs.version> + <jaxrs.version>2.1.1</jaxrs.version> <jcommander.version>1.78</jcommander.version> <jersey.version>1.19.4</jersey.version> - <jnr.ffi.version>2.1.11</jnr.ffi.version> - <jolt.version>0.0.24</jolt.version> + <jnr.ffi.version>2.2.12</jnr.ffi.version> + <jolt.version>0.1.7</jolt.version> <jopt.simple.version>5.0.4</jopt.simple.version> - <jsonassert.version>1.5.0</jsonassert.version> + <jsonassert.version>1.5.1</jsonassert.version> <json.patch.version>1.9</json.patch.version> <!-- JSONPath has an bug when it tries to parse an expression |