diff options
author | Jorge Hernandez <jh1730@att.com> | 2018-03-27 00:06:19 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-03-27 00:06:19 +0000 |
commit | a84f47325effa7baffb0f8fed2de1fc49ec733e1 (patch) | |
tree | 3219dfac46feac0f28c72e26e253c58e2b0ec6e7 /controlloop/common/simulators/src/main/java | |
parent | f6a81de0fd84186d499c39fe5f2d75c20cb0e301 (diff) | |
parent | 7150a5f7027725b5eed9c723c6224c8b3d5307dd (diff) |
Merge "Add timeout to SO to wait for success"
Diffstat (limited to 'controlloop/common/simulators/src/main/java')
-rw-r--r-- | controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java index 1547fd41f..9b623a646 100644 --- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java +++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java @@ -20,6 +20,8 @@ package org.onap.policy.simulators; +import java.util.UUID; + import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -27,10 +29,17 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import org.onap.policy.so.SORequest; +import org.onap.policy.so.SORequestReferences; +import org.onap.policy.so.SORequestStatus; +import org.onap.policy.so.SOResponse; + +import com.att.aft.dme2.internal.gson.Gson; + @Path("/serviceInstances") public class SoSimulatorJaxRs { - - /** + + /** * SO post query. * * @param serviceInstanceId the service instance Id @@ -41,14 +50,23 @@ public class SoSimulatorJaxRs { @Path("/v5/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules") @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") - public String soPostQuery(@PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId) { - - // the requestID contained in the SO Response is a newly generated requestID - // with no relation to the requestID in Policy controlLoopEvent - return "{\"requestReferences\": {\"instanceId\": \"ff305d54-75b4-ff1b-bdb2-eb6b9e5460ff\", \"requestId\": \"" - + "rq1234d1-5a33-ffdf-23ab-12abad84e331\" }}"; + public String soPostQuery(@PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId) + { + SORequest request = new SORequest(); + SORequestStatus requestStatus = new SORequestStatus(); + requestStatus.setRequestState("COMPLETE"); + request.setRequestStatus(requestStatus); + request.setRequestId(UUID.randomUUID()); + + SOResponse response = new SOResponse(); + + SORequestReferences requestReferences = new SORequestReferences(); + String requestId = UUID.randomUUID().toString(); + requestReferences.setRequestId(requestId); + response.setRequestReferences(requestReferences); + + response.setRequest(request); + return new Gson().toJson(response); } - } |