X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-interactions%2Fmodel-simulators%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fsimulators%2FSoSimulatorJaxRs.java;h=a1456c15e79420821d7066c4bd465ee8806a7266;hb=HEAD;hp=ed6bce9e090db0c24616ea218556fd909fb53c93;hpb=b2e61a292bc8a9edbed1569ab5655e2ee17a8f3b;p=policy%2Fmodels.git
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 ed6bce9e0..a1456c15e 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
@@ -2,8 +2,10 @@
* ============LICENSE_START=======================================================
* simulators
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Wipro Limited.
+ * Modifications Copyright (C) 2022 CTC, Inc. and others.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,30 +23,52 @@
package org.onap.policy.simulators;
-import com.google.gson.Gson;
-
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.DELETE;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.PUT;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
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;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
+import java.util.concurrent.ConcurrentHashMap;
+import lombok.Setter;
+import org.onap.policy.common.utils.resources.ResourceUtils;
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 org.onap.policy.so.SoRequest3gpp;
@Path("/")
public class SoSimulatorJaxRs {
+ private static final String REPLACE_ME = "${replaceMe}";
+ /**
+ * Set of incomplete request IDs. When a POST or DELETE is performed, the new request
+ * ID is added to the set. When the request is polled, the ID is removed and a "still
+ * running" response is returned. When the request is polled again, it sees that there
+ * is no entry and returns a completion indication.
+ *
+ *
+ * This is static so request IDs are retained across servlets.
+ */
+ private static final Set incomplete = ConcurrentHashMap.newKeySet();
+
+ /**
+ * {@code True} if requests should require polling, {@code false}
+ * otherwise. This is used when junit testing the SO actor.
+ */
+ @Setter
+ private static boolean requirePolling = false;
+
/**
* SO post query.
*
- * @param serviceInstanceId the service instance Id
- * @param vnfInstanceId the VNF Id
+ * @param serviceInstanceId the service instance ID
+ * @param vnfInstanceId the VNF ID
* @return the response
*/
@POST
@@ -52,15 +76,23 @@ public class SoSimulatorJaxRs {
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String soPostQuery(@PathParam("serviceInstanceId") final String serviceInstanceId,
- @PathParam("vnfInstanceId") final String vnfInstanceId) {
- return makeCompleteSuccess();
+ @PathParam("vnfInstanceId") final String vnfInstanceId,
+ SoRequest request) {
+
+ List