diff --git a/build.gradle b/build.gradle index b0f73e8130d5fc8e1d6a1587145ed74316dd5b8e..c4358a0c9775af41ce7b1ab19ce7ecc2207cfda3 100644 --- a/build.gradle +++ b/build.gradle @@ -327,6 +327,7 @@ dependencies { compile "com.fasterxml.jackson.core:jackson-core:${vJackson}" compile "com.fasterxml.jackson.core:jackson-databind:${vJackson}" compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${vJackson}" + compile "com.fasterxml.jackson.datatype:jackson-datatype-hibernate4:${vJackson}" compile "org.json:json:20151123" compile "xerces:xercesImpl:2.11.0" diff --git a/src/main/java/org/nrg/xnat/configuration/WebConfig.java b/src/main/java/org/nrg/xnat/configuration/WebConfig.java index ae542c22c86fd8b025e3e341fbbc85011b0e770a..bf51d79008c082c52f1cc775269666d324232665 100644 --- a/src/main/java/org/nrg/xnat/configuration/WebConfig.java +++ b/src/main/java/org/nrg/xnat/configuration/WebConfig.java @@ -1,6 +1,9 @@ package org.nrg.xnat.configuration; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; import org.nrg.framework.annotations.XapiRestController; import org.nrg.xnat.spawner.configuration.SpawnerConfig; import org.slf4j.Logger; @@ -35,9 +38,12 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; public class WebConfig extends WebMvcConfigurerAdapter { @Bean public Jackson2ObjectMapperBuilder objectMapperBuilder() { - Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder(); - builder.serializationInclusion(JsonInclude.Include.NON_NULL); - return builder; + return new Jackson2ObjectMapperBuilder() + .serializationInclusion(JsonInclude.Include.NON_NULL) + .failOnEmptyBeans(false) + .featuresToEnable(JsonParser.Feature.ALLOW_SINGLE_QUOTES, JsonParser.Feature.ALLOW_YAML_COMMENTS) + .featuresToDisable(SerializationFeature.FAIL_ON_EMPTY_BEANS, SerializationFeature.WRITE_NULL_MAP_VALUES) + .modules(new Hibernate4Module()); } @Override diff --git a/src/main/java/org/nrg/xnat/initialization/RootConfig.java b/src/main/java/org/nrg/xnat/initialization/RootConfig.java index a7cb0e5034139610dd9f2b79065124aa3da65108..c29194b18cc66e240773edbe058154159cb84b36 100644 --- a/src/main/java/org/nrg/xnat/initialization/RootConfig.java +++ b/src/main/java/org/nrg/xnat/initialization/RootConfig.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; import org.nrg.framework.datacache.SerializerRegistry; import org.nrg.framework.exceptions.NrgServiceException; import org.nrg.framework.services.ContextService; @@ -72,6 +73,7 @@ public class RootConfig { mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); mapper.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true); + mapper.registerModule(new Hibernate4Module()); return mapper; } @@ -83,6 +85,7 @@ public class RootConfig { mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); mapper.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true); + mapper.registerModule(new Hibernate4Module()); return mapper; }