Add YAML support to drools-pdp rest servlets 83/95683/4
authorJim Hahn <jrh3@att.com>
Fri, 13 Sep 2019 21:31:46 +0000 (17:31 -0400)
committerJim Hahn <jrh3@att.com>
Mon, 16 Sep 2019 22:24:42 +0000 (18:24 -0400)
Drools-pdp depends on some of the GsonJackson annotations that cannot
be easily worked around via standard gson.  Consequently, this continues
to use the JacksonHandler for json-encoding, thus it uses the
YamlJacksonHandler for yaml-encoding.
Added YAML to swagger "consumes" list.

Change-Id: Ic70c68bb274222db571b3515cbf1ab22d9ff2366
Issue-ID: POLICY-2081
Signed-off-by: Jim Hahn <jrh3@att.com>
feature-healthcheck/src/main/feature/config/feature-healthcheck.properties
feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/RestHealthCheck.java
feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestMockHealthCheck.java
feature-lifecycle/pom.xml
feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java
feature-state-management/src/main/feature/config/feature-state-management.properties
policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
policy-management/src/main/server/config/engine.properties
pom.xml

index fc03841..70a010c 100644 (file)
@@ -28,4 +28,4 @@ http.server.services.HEALTHCHECK.userName=${env:HEALTHCHECK_USER}
 http.server.services.HEALTHCHECK.password=${env:HEALTHCHECK_PASSWORD}
 http.server.services.HEALTHCHECK.https=true
 http.server.services.HEALTHCHECK.aaf=${env:AAF}
-http.server.services.HEALTHCHECK.serialization.provider=org.onap.policy.common.gson.JacksonHandler
+http.server.services.HEALTHCHECK.serialization.provider=org.onap.policy.common.gson.JacksonHandler,org.onap.policy.common.endpoints.http.server.YamlJacksonHandler
index 954a2c5..5d9d67e 100644 (file)
@@ -31,20 +31,20 @@ import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-
+import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
 import org.onap.policy.drools.healthcheck.HealthCheck.Reports;
 
 @Path("/")
 @Api
-@Produces(MediaType.APPLICATION_JSON)
+@Produces({MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML})
 @SwaggerDefinition(
     info = @Info(
         description = "PDP-D Healthcheck Service",
         version = "v1.0",
         title = "PDP-D Healthcheck"
     ),
-    consumes = {MediaType.APPLICATION_JSON},
-    produces = {MediaType.APPLICATION_JSON},
+    consumes = {MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML},
+    produces = {MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML},
     schemes = {SwaggerDefinition.Scheme.HTTP},
     tags = {
         @Tag(name = "pdp-d-healthcheck", description = "Drools PDP Healthcheck Operations")
@@ -54,7 +54,6 @@ public class RestHealthCheck {
 
     @GET
     @Path("healthcheck")
-    @Produces(MediaType.APPLICATION_JSON)
     @ApiOperation(
             value = "Perform a system healthcheck",
             notes = "Provides healthy status of the PDP-D plus the components defined in its "
@@ -67,7 +66,6 @@ public class RestHealthCheck {
 
     @GET
     @Path("healthcheck/configuration")
-    @Produces(MediaType.APPLICATION_JSON)
     @ApiOperation(
             value = "Configuration",
             notes = "Provides the Healthcheck server configuration and monitored REST clients",
index 8bdad5b..8cbe1fb 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,14 +26,15 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
+import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
 
 @Path("/")
 public class RestMockHealthCheck {
-    
+
     @GET
     @Path("healthcheck/test")
-    @Produces(MediaType.APPLICATION_JSON)
-    public Response papHealthCheck() {   
+    @Produces({MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML})
+    public Response papHealthCheck() {
         return Response.status(Status.OK).entity("All Alive").build();
     }
 
index 18831b5..66da461 100644 (file)
@@ -7,9 +7,9 @@
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
-  
+
        http://www.apache.org/licenses/LICENSE-2.0
-  
+
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
             <scope>test</scope>
         </dependency>
 
+        <dependency>
+            <groupId>org.onap.policy.common</groupId>
+            <artifactId>policy-endpoints</artifactId>
+            <version>${policy.common.version}</version>
+            <scope>provided</scope>
+        </dependency>
+
         <dependency>
             <groupId>org.onap.policy.common</groupId>
             <artifactId>utils-test</artifactId>
index e4a9331..9aea045 100644 (file)
@@ -26,6 +26,7 @@ import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
 import org.onap.policy.drools.lifecycle.LifecycleFeature;
 import org.onap.policy.drools.lifecycle.LifecycleFsm;
 
@@ -34,8 +35,8 @@ import org.onap.policy.drools.lifecycle.LifecycleFsm;
  */
 
 @Path("/policy/pdp")
-@Produces(MediaType.APPLICATION_JSON)
-@Consumes(MediaType.APPLICATION_JSON)
+@Produces({MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML})
+@Consumes({MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML})
 @Api
 public class RestLifecycleManager {
 
index 9ab53d3..d2df6c5 100644 (file)
@@ -28,7 +28,7 @@ javax.persistence.jdbc.password=${env:SQL_PASSWORD}
 # Test interface host and port defaults may be overwritten here
 http.server.services.TEST.host=0.0.0.0
 http.server.services.TEST.port=9981
-http.server.services.TEST.serialization.provider=org.onap.policy.common.gson.JacksonHandler
+http.server.services.TEST.serialization.provider=org.onap.policy.common.gson.JacksonHandler,org.onap.policy.common.endpoints.http.server.YamlJacksonHandler
 #These properties will default to the following if no other values are provided:
 # http.server.services.TEST.restClasses=org.onap.policy.drools.statemanagement.IntegrityMonitorRestManager
 # http.server.services.TEST.managed=false
index 2d40a1f..c5841b0 100644 (file)
@@ -55,6 +55,7 @@ import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.TopicSource;
+import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
 import org.onap.policy.drools.controller.DroolsController;
 import org.onap.policy.drools.features.PolicyControllerFeatureApi;
 import org.onap.policy.drools.features.PolicyEngineFeatureApi;
@@ -78,11 +79,12 @@ import org.slf4j.LoggerFactory;
  */
 
 @Path("/policy/pdp")
-@Produces(MediaType.APPLICATION_JSON)
-@Consumes(MediaType.APPLICATION_JSON)
+@Produces({MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML})
+@Consumes({MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML})
 @Api
 @SwaggerDefinition(info = @Info(description = "PDP-D Telemetry Services", version = "v1.0", title = "PDP-D Telemetry"),
-        consumes = {MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}, produces = {MediaType.APPLICATION_JSON},
+        consumes = {MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML, MediaType.TEXT_PLAIN},
+        produces = {MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML},
         schemes = {SwaggerDefinition.Scheme.HTTP},
         tags = {@Tag(name = "pdp-d-telemetry", description = "Drools PDP Telemetry Operations")})
 public class RestManager {
index 05f682e..aa9b6d8 100644 (file)
@@ -42,7 +42,7 @@ http.server.services.SECURED-CONFIG.managed=false
 http.server.services.SECURED-CONFIG.swagger=true
 http.server.services.SECURED-CONFIG.https=true
 http.server.services.SECURED-CONFIG.aaf=${env:AAF}
-http.server.services.SECURED-CONFIG.serialization.provider=org.onap.policy.common.gson.JacksonHandler
+http.server.services.SECURED-CONFIG.serialization.provider=org.onap.policy.common.gson.JacksonHandler,org.onap.policy.common.endpoints.http.server.YamlJacksonHandler
 
 aaf.namespace=${env:AAF_NAMESPACE}
 aaf.root.permission=${env:AAF_NAMESPACE}.pdpd
diff --git a/pom.xml b/pom.xml
index 4a44f13..87a0696 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -62,8 +62,8 @@
         <hibernate.commons.annotations.version>5.0.1.Final</hibernate.commons.annotations.version>
         <commons.io.version>2.5</commons.io.version>
         <xml.apis.version>1.4.01</xml.apis.version>
-        <policy.common.version>1.5.2</policy.common.version>
-        <policy.models.version>2.1.3</policy.models.version>
+        <policy.common.version>1.6.0-SNAPSHOT</policy.common.version>
+        <policy.models.version>2.2.0-SNAPSHOT</policy.models.version>
     </properties>
 
     <modules>