From 03248c4de4197dac33c156e6a7a6538c9943305c Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Tue, 3 Mar 2020 21:02:13 -0500 Subject: Add SO VF Module Delete Operation Redesigned the SO Operation classes; moved some code from the subclass to the superclass so it could be reused by the VF Module Delete Operation. JerseyClient does not support DELETE with a request body, so had to implement a delete() method using java11 HttpClient. Fix some issues found while testing with drools-apps. Added "delete" operation to SO simulator. Issue-ID: POLICY-2371 Signed-off-by: Jim Hahn Change-Id: I269fe13cf90c295ec2bbac92bc5a59b3820ea265 --- .../onap/policy/simulators/SoSimulatorJaxRs.java | 37 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'models-interactions/model-simulators/src/main/java') diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java index 1af0b767c..b06a66f41 100644 --- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java +++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java @@ -25,6 +25,7 @@ import com.google.gson.Gson; import java.util.UUID; import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -36,7 +37,7 @@ import org.onap.policy.so.SoRequestStatus; import org.onap.policy.so.SoResponse; -@Path("/serviceInstantiation") +@Path("/") public class SoSimulatorJaxRs { /** @@ -47,7 +48,7 @@ public class SoSimulatorJaxRs { * @return the response */ @POST - @Path("/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut") + @Path("/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut") @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") public String soPostQuery(@PathParam("serviceInstanceId") final String serviceInstanceId, @@ -69,4 +70,36 @@ public class SoSimulatorJaxRs { return new Gson().toJson(response); } + + /** + * SO Delete. + * + * @param serviceInstanceId the service instance Id + * @param vnfInstanceId the VNF Id + * @return the response + */ + @DELETE + @Path("/serviceInstances/v7/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces("application/json") + public String soDelete(@PathParam("serviceInstanceId") final String serviceInstanceId, + @PathParam("vnfInstanceId") final String vnfInstanceId, + @PathParam("vfModuleInstanceId") final String vfModuleInstanceId) { + final SoRequest request = new SoRequest(); + final SoRequestStatus requestStatus = new SoRequestStatus(); + requestStatus.setRequestState("COMPLETE"); + request.setRequestStatus(requestStatus); + request.setRequestId(UUID.randomUUID()); + + final SoResponse response = new SoResponse(); + + final SoRequestReferences requestReferences = new SoRequestReferences(); + final String requestId = UUID.randomUUID().toString(); + requestReferences.setRequestId(requestId); + response.setRequestReferences(requestReferences); + + response.setRequest(request); + + return new Gson().toJson(response); + } } -- cgit 1.2.3-korg