From cb9bd650a1ba6c1c2f5c7dd410f640b9b6f876c7 Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Fri, 20 Oct 2023 13:23:33 +0530 Subject: Extend user settings API Extend user settings API Issue-ID: CCSDK-3947 Change-Id: Ic0e7783abb2b084142c5bc2d36dc31810f6ca9cf Signed-off-by: Ravi Pendurty --- .../database/sqldb/data/HtUserdataManagerBase.java | 101 ++++++++++++++++++++- 1 file changed, 96 insertions(+), 5 deletions(-) (limited to 'sdnr/wt/data-provider/dblib/src/main/java/org') diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java index e015dd29f..d6ad35488 100644 --- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java +++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java @@ -24,6 +24,7 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data; import java.io.File; import java.io.IOException; import java.nio.file.Files; +import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager; @@ -68,25 +69,115 @@ public abstract class HtUserdataManagerBase implements HtUserdataManager { @Override public String getUserdata(String username, String key) { + final String EMPTY_JSON_OBJECT = "{}"; JSONObject o = new JSONObject(this.getUserdata(username)); - return o.has(key) ? o.get(key).toString() : "{}"; + if(key==null || !key.contains(".")) + return o.has(key) ? o.get(key).toString() : EMPTY_JSON_OBJECT; + final String[] keys = key.split("\\."); + Object tmp; + for (int i=0;i