From cf52d77279f8d5a70429d45abad0ef3d1135070c Mon Sep 17 00:00:00 2001 From: Instrumental Date: Sun, 22 Jul 2018 07:49:16 -0500 Subject: Finish RESTful Client API Issue-ID: AAF-361 Change-Id: I999cb419a79c5995baf3757fdbbe047528901597 Signed-off-by: Instrumental --- .../main/java/org/onap/aaf/cadi/client/Rcli.java | 33 ++++++++++++++++++++++ .../aaf/cadi/locator/SingleEndpointLocator.java | 12 +++++++- 2 files changed, 44 insertions(+), 1 deletion(-) (limited to 'cadi/client') diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java index 058bbd38..04075f29 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java @@ -217,6 +217,20 @@ public abstract class Rcli { return client.futureCreate(Void.class); } + public Future create(String pathinfo, String contentType, EClient.Transfer content) throws APIException, CadiException { + final ParsePath pp = new ParsePath(pathinfo); + + EClient client = client(); + client.setMethod(POST); + client.addHeader(CONTENT_TYPE,contentType); + client.setPathInfo(pp.path()); + client.setQueryParams(pp.query()); + client.setFragment(pp.frag()); + client.setPayload(content); + client.send(); + return client.futureCreate(Void.class); + } + /** * Post Data in WWW expected format, with the format tag1=value1&tag2=value2, etc @@ -462,6 +476,22 @@ public abstract class Rcli { client.send(); return client.futureReadString(); } + + public Future update(String pathinfo, String contentType, EClient.Transfer content) throws APIException, CadiException { + final ParsePath pp = new ParsePath(pathinfo); + + EClient client = client(); + client.setMethod(PUT); + client.addHeader(CONTENT_TYPE,contentType); + client.setPathInfo(pp.path()); + client.setQueryParams(pp.query()); + client.setFragment(pp.frag()); + client.setPayload(content); + client.send(); + return client.futureReadString(); + } + + public Future update(String pathinfo, final RosettaDF df, final T t) throws APIException, CadiException { @@ -503,6 +533,8 @@ public abstract class Rcli { client.send(); return client.future(t); } + + /** * A method to update with a VOID @@ -531,6 +563,7 @@ public abstract class Rcli { client.send(); return client.future(null); } + public Future delete(String pathinfo, String contentType, final RosettaDF df, final T t) throws APIException, CadiException { final ParsePath pp = new ParsePath(pathinfo); diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java index b0c830f6..23bcd4ad 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java @@ -22,6 +22,7 @@ package org.onap.aaf.cadi.locator; import java.net.URI; import java.net.URISyntaxException; +import java.util.Date; import org.onap.aaf.cadi.Locator; import org.onap.aaf.cadi.LocatorException; @@ -29,6 +30,7 @@ import org.onap.aaf.cadi.LocatorException; public class SingleEndpointLocator implements Locator { private final URI uri; private final static Item item = new Item() {}; + private Date noRetryUntil; public SingleEndpointLocator(final URI uri) { this.uri = uri; @@ -45,12 +47,20 @@ public class SingleEndpointLocator implements Locator { @Override public boolean hasItems() { + if(noRetryUntil!=null) { + if(new Date().after(noRetryUntil)) { + noRetryUntil = null; + } else { + return false; + } + } return true; } @Override public void invalidate(Item item) throws LocatorException { - // Endpoints cannot be invalidated + // one minute timeout, because there is no other item + noRetryUntil = new Date(System.currentTimeMillis()+60000); } @Override -- cgit 1.2.3-korg