diff options
author | 2022-02-14 11:11:11 +0000 | |
---|---|---|
committer | 2022-03-01 11:05:24 +0000 | |
commit | 411a7aa191a48170336dfa0fc5c44a17f99fd186 (patch) | |
tree | d2ffd185a75768b1ef5f2b2cda0e58015a76053c /main/src/main/java/org/onap/policy/pap/main/PolicyPapApplication.java | |
parent | 98aed0d3f60be26df2cc0dc86d368a615df59978 (diff) |
Fix swagger and improve exception handling
1) Swagger was getting generated in a different format
due to a serialization isue. It is fixed.
2) Improved exception handling by taking care of any exceptions
that could occur in and around database operations.
3) AAF enabling/disabling was done using spring profiles.
This is changed to using parameters, as it is more easier to configure
in an OOM helm chart deployment
Change-Id: If1bee01379ba5c4efac29822662896d8aa883fc8
Issue-ID: POLICY-3975
Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'main/src/main/java/org/onap/policy/pap/main/PolicyPapApplication.java')
-rw-r--r-- | main/src/main/java/org/onap/policy/pap/main/PolicyPapApplication.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/PolicyPapApplication.java b/main/src/main/java/org/onap/policy/pap/main/PolicyPapApplication.java index ede40126..edb6ff6d 100644 --- a/main/src/main/java/org/onap/policy/pap/main/PolicyPapApplication.java +++ b/main/src/main/java/org/onap/policy/pap/main/PolicyPapApplication.java @@ -22,12 +22,15 @@ package org.onap.policy.pap.main; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonParser; +import com.google.gson.JsonSerializer; import org.onap.policy.common.gson.GsonMessageBodyHandler; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.context.annotation.Bean; +import springfox.documentation.spring.web.json.Json; @SpringBootApplication(exclude = {JacksonAutoConfiguration.class}) @EntityScan( @@ -39,8 +42,17 @@ public class PolicyPapApplication { SpringApplication.run(PolicyPapApplication.class, args); } + /** + * Configure gson with the required adapters to be used in the application. + * + * @return the gson bean + */ @Bean public Gson gson() { - return GsonMessageBodyHandler.configBuilder(new GsonBuilder()).create(); + GsonBuilder gsonBuilder = GsonMessageBodyHandler.configBuilder(new GsonBuilder()); + JsonSerializer<Json> serializer = + (json, type, jsonSerializationContext) -> JsonParser.parseString(json.value()); + gsonBuilder.registerTypeAdapter(Json.class, serializer); + return gsonBuilder.create(); } } |