diff options
author | Nelson, Thomas (tn1381) <tn1381@att.com> | 2018-08-20 04:45:13 +0000 |
---|---|---|
committer | Nelson, Thomas (tn1381) <tn1381@att.com> | 2018-08-20 04:45:13 +0000 |
commit | 0d2f003049e562354fda88729dbab70f46daa25f (patch) | |
tree | 886cceb97a030a13d6d5fe586cb80dca377443cf /src/main/java/org/onap/music/main/CachingUtil.java | |
parent | 1dbff4199663796788e5658c0eec33b2faade59d (diff) |
Update swagger.json and other updates.
Change-Id: I84753300e64ba82072e65ef1bde2cb76771ee046
Issue-ID: MUSIC-97
Signed-off-by: Nelson, Thomas (tn1381) <tn1381@att.com>
Diffstat (limited to 'src/main/java/org/onap/music/main/CachingUtil.java')
-rwxr-xr-x | src/main/java/org/onap/music/main/CachingUtil.java | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/src/main/java/org/onap/music/main/CachingUtil.java b/src/main/java/org/onap/music/main/CachingUtil.java index d3654118..83b5158f 100755 --- a/src/main/java/org/onap/music/main/CachingUtil.java +++ b/src/main/java/org/onap/music/main/CachingUtil.java @@ -41,7 +41,8 @@ import org.onap.music.eelf.logging.format.AppMessages; import org.onap.music.eelf.logging.format.ErrorSeverity; import org.onap.music.eelf.logging.format.ErrorTypes; import org.onap.music.exceptions.MusicServiceException; - +import org.onap.music.datastore.jsonobjects.JsonNotification; +import org.onap.music.datastore.jsonobjects.JsonCallback; import com.att.eelf.configuration.EELFLogger; import com.datastax.driver.core.DataType; import com.datastax.driver.core.ResultSet; @@ -65,6 +66,7 @@ public class CachingUtil implements Runnable { private static CacheAccess<String, Map<String, String>> aafCache = JCS.getInstance("aafCache"); private static CacheAccess<String, String> appNameCache = JCS.getInstance("appNameCache"); private static CacheAccess<String, Map<String, String>> musicValidateCache = JCS.getInstance("musicValidateCache"); + private static CacheAccess<String, JsonCallback> callBackCache = JCS.getInstance("callBackCache"); private static Map<String, Number> userAttempts = new HashMap<>(); private static Map<String, Calendar> lastFailedTime = new HashMap<>(); @@ -73,6 +75,14 @@ public class CachingUtil implements Runnable { return true; return false; } + + public static void updateCallBackCache(String appName, JsonCallback jsonCallBack) { + callBackCache.put(appName, jsonCallBack); + } + + public static JsonCallback getCallBackCache(String appName) { + return callBackCache.get(appName); + } public void initializeMusicCache() { logger.info(EELFLoggerDelegate.applicationLogger,"Initializing Music Cache..."); @@ -102,8 +112,8 @@ public class CachingUtil implements Runnable { String keySpace = row.getString("application_name"); try { userAttempts.put(nameSpace, 0); - AAFResponse responseObj = triggerAAF(nameSpace, userId, password); - if (responseObj.getNs().size() > 0) { + boolean responseObj = triggerAAF(nameSpace, userId, password); + if (responseObj) { map = new HashMap<>(); map.put(userId, password); aafCache.put(nameSpace, map); @@ -164,8 +174,8 @@ public class CachingUtil implements Runnable { } } - AAFResponse responseObj = triggerAAF(nameSpace, userId, password); - if (responseObj.getNs().size() > 0) { + boolean responseObj = triggerAAF(nameSpace, userId, password); + if (responseObj) { //if (responseObj.getNs().get(0).getAdmin().contains(userId)) { //Map<String, String> map = new HashMap<>(); //map.put(userId, password); @@ -177,7 +187,7 @@ public class CachingUtil implements Runnable { return false; } - private static AAFResponse triggerAAF(String nameSpace, String userId, String password) + private static boolean triggerAAF(String nameSpace, String userId, String password) throws Exception { if (MusicUtil.getAafEndpointUrl() == null) { logger.error(EELFLoggerDelegate.errorLogger,"",AppMessages.UNKNOWNERROR,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR); @@ -210,14 +220,14 @@ public class CachingUtil implements Runnable { // TODO Allow for 2-3 times and forbid any attempt to trigger AAF with invalid values // for specific time. } - response.getHeaders().put(HttpHeaders.CONTENT_TYPE, + /*response.getHeaders().put(HttpHeaders.CONTENT_TYPE, Arrays.asList(MediaType.APPLICATION_JSON)); // AAFResponse output = response.getEntity(AAFResponse.class); response.bufferEntity(); String x = response.getEntity(String.class); - AAFResponse responseObj = new ObjectMapper().readValue(x, AAFResponse.class); + AAFResponse responseObj = new ObjectMapper().readValue(x, AAFResponse.class);*/ - return responseObj; + return true; } public static void updateMusicCache(String keyspace, String nameSpace) { @@ -417,4 +427,15 @@ public class CachingUtil implements Runnable { CachingUtil.updateMusicValidateCache(nameSpace, userId, pwd); return resultMap; } + + public static void deleteKeysFromDB(String deleteKeys) { + PreparedQueryObject pQuery = new PreparedQueryObject(); + pQuery.appendQueryString( + "DELETE FROM admin.locks WHERE lock_id IN ("+deleteKeys+")"); + try { + MusicCore.nonKeyRelatedPut(pQuery, "eventual"); + } catch (Exception e) { + e.printStackTrace(); + } + } } |