aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/main
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-05-22 11:08:32 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-05-22 12:11:24 -0400
commit65d71e97406a9a9b1c56475855f1d2e59adeec81 (patch)
treeb87977e0cb9321bcd7dee47d508003741a204a81 /common/src/main
parent8e8476033905ac1e07e5cb22e7fe193bcc8ae903 (diff)
HttpLookupUri is now serializable again
cachedValue is now transient added custom serialization created serialization unit test for ServiceInstancesUri Change-Id: Idbc414a8483a4eae9c93ae8b06a1e77cbe683ca8 Issue-ID: SO-1906 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'common/src/main')
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/uri/HttpLookupUri.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/HttpLookupUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/HttpLookupUri.java
index f086a6abcf..37d21b375e 100644
--- a/common/src/main/java/org/onap/so/client/aai/entities/uri/HttpLookupUri.java
+++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/HttpLookupUri.java
@@ -21,6 +21,8 @@
package org.onap.so.client.aai.entities.uri;
import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.net.URI;
import java.util.Map;
import java.util.Optional;
@@ -42,7 +44,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public abstract class HttpLookupUri extends AAISimpleUri implements HttpAwareUri {
- private Optional<String> cachedValue = Optional.empty();
+ private transient Optional<String> cachedValue = Optional.empty();
private final AAIObjectType aaiType;
protected HttpLookupUri(AAIObjectType type, Object... values) {
@@ -78,8 +80,7 @@ public abstract class HttpLookupUri extends AAISimpleUri implements HttpAwareUri
throw new GraphInventoryPayloadException("could not map payload: " + resultJson, e);
}
}
- Optional<String> cachedValueOpt = this.getCachedValue();
- return cachedValueOpt.isPresent() ? cachedValueOpt.get() : "";
+ return cachedValue.get();
}
protected Optional<String> extractRelatedLink(String jsonString) throws IOException {
@@ -139,6 +140,22 @@ public abstract class HttpLookupUri extends AAISimpleUri implements HttpAwareUri
return new AAIResourcesClient();
}
+ private void writeObject(ObjectOutputStream oos) throws IOException {
+
+ oos.writeUTF(this.cachedValue.orElse(""));
+ }
+
+ private void readObject(ObjectInputStream ois) throws IOException {
+
+ String value = ois.readUTF();
+ if ("".equals(value)) {
+ this.cachedValue = Optional.empty();
+ } else {
+ this.cachedValue = Optional.ofNullable(value);
+ }
+
+ }
+
@Override
public abstract URI buildNoNetwork();
}