summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.so
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-05-15 14:46:15 -0400
committerJim Hahn <jrh3@att.com>2020-05-15 14:52:15 -0400
commit5210055db2f00f42fea4717b2726dda52e1c1a59 (patch)
tree435bf700d4f5096b23126f899ab36fe3cc0de888 /models-interactions/model-actors/actor.so
parentafe5abed95c6cbfe239066e267d9c10a71f20623 (diff)
Cannot parse finishTime in legacy SO responses
Adding the actual sample responses to the SO simulator broke the drools-apps junit for usecases. Fixed (in theory) by updating the legacy SO actor to properly decode the finishTime. Refactored the new SO actor, extracting the type adapter into its own class file so it could be shared between the new and legacy actors. Issue-ID: POLICY-2570 Change-Id: I061b603172440b1a91da16d09b4f2a0d289dfc41 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.so')
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java47
1 files changed, 1 insertions, 46 deletions
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
index 2a00edda4..a26f6a77f 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
@@ -22,15 +22,7 @@ package org.onap.policy.controlloop.actor.so;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonParseException;
-import com.google.gson.TypeAdapter;
-import com.google.gson.stream.JsonReader;
-import com.google.gson.stream.JsonToken;
-import com.google.gson.stream.JsonWriter;
-import java.io.IOException;
import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -68,6 +60,7 @@ import org.onap.policy.so.SoRequestInfo;
import org.onap.policy.so.SoRequestParameters;
import org.onap.policy.so.SoRequestStatus;
import org.onap.policy.so.SoResponse;
+import org.onap.policy.so.util.SoLocalDateTimeTypeAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -498,44 +491,6 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
return coder;
}
- /*
- * TODO: combine this adapter with existing LocalDateTimeTypeAdapter and eliminate the
- * following two classes.
- */
-
- /**
- * GSON Type Adapter for "LocalDateTime" fields, that uses the standard
- * RFC_1123_DATE_TIME formatter.
- */
- private static class SoLocalDateTimeTypeAdapter extends TypeAdapter<LocalDateTime> {
- private static final DateTimeFormatter FORMATTER = DateTimeFormatter.RFC_1123_DATE_TIME;
-
- @Override
- public LocalDateTime read(JsonReader in) throws IOException {
- try {
- if (in.peek() == JsonToken.NULL) {
- in.nextNull();
- return null;
- } else {
- return LocalDateTime.parse(in.nextString(), FORMATTER);
- }
-
- } catch (DateTimeParseException e) {
- throw new JsonParseException("invalid date", e);
- }
- }
-
- @Override
- public void write(JsonWriter out, LocalDateTime value) throws IOException {
- if (value == null) {
- out.nullValue();
- } else {
- String text = value.format(FORMATTER);
- out.value(text);
- }
- }
- }
-
private static class SoCoder extends StandardCoder {
/**