diff options
author | Manjunath Ranganathaiah <manjunath.ranganathaiah@intel.com> | 2018-03-15 14:41:12 -0700 |
---|---|---|
committer | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2018-03-16 17:15:46 +0000 |
commit | 8b58db1c4ce07f4ee093079d8fa5310b4d06cb17 (patch) | |
tree | 3de1a74dec780704c16c78fac785177584b43620 /sms-client | |
parent | 9b16de820c0bef5643746bdeb3186714a85281f1 (diff) |
Return only values to the caller of getSecret
Use returned values of map for datatype variables.
Change-Id: I3829eab81e5e573505efff68970bd3495b7a92f0
Issue-ID: AAF-98
Signed-off-by: Manjunath Ranganathaiah <manjunath.ranganathaiah@intel.com>
Diffstat (limited to 'sms-client')
-rw-r--r-- | sms-client/src/java/example/SmsClientExample.java | 3 | ||||
-rw-r--r-- | sms-client/src/java/main/SmsClient.java | 26 |
2 files changed, 26 insertions, 3 deletions
diff --git a/sms-client/src/java/example/SmsClientExample.java b/sms-client/src/java/example/SmsClientExample.java index 7bbaa90..dc0e776 100644 --- a/sms-client/src/java/example/SmsClientExample.java +++ b/sms-client/src/java/example/SmsClientExample.java @@ -103,6 +103,9 @@ public class SmsClientExample { } SmsResponse resp6= sms.getSecret("onap.new.test.sms0", "credentials"); if ( resp6.getSuccess() ) { + Boolean b = (Boolean)resp6.getResponse().get("isadmin"); + if ( b ) + System.out.println("Age=" + (Integer)resp6.getResponse().get("age")); System.out.println(resp6.getResponse()); System.out.println(resp6.getResponseCode()); } diff --git a/sms-client/src/java/main/SmsClient.java b/sms-client/src/java/main/SmsClient.java index 69d81e4..ce48f72 100644 --- a/sms-client/src/java/main/SmsClient.java +++ b/sms-client/src/java/main/SmsClient.java @@ -48,6 +48,17 @@ public class SmsClient implements SmsInterface { ssf = s; } + private Map<String, Object> getSubmap(Map<String, Object> raw, String k) { + Object v = raw.get(k); + if ( v != null ) { + Map<String, Object> r = (Map<String, Object>)v; + return(r); + } + else { + return(null); + } + } + private List<Object> jsontolist(JSONArray a) throws JSONException { List<Object> l = new ArrayList<Object>(); for(int i=0;i<a.length();i++) { @@ -210,10 +221,19 @@ public class SmsClient implements SmsInterface { SmsResponse resp = execute("GET", t, null, false, true); int errcode = resp.getResponseCode(); - if ( errcode > 0 && errcode/100 == 2 ) - resp.setSuccess(true); - else + if ( errcode > 0 && errcode/100 == 2 ) { + Map<String, Object> m = getSubmap(resp.getResponse(), "values"); + if ( m != null ) { + resp.setSuccess(true); + resp.setResponse(m); + } + else { + resp.setSuccess(false); + } + } + else { resp.setSuccess(false); + } return(resp); |