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;
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<>();
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...");
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);
}
}
- 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);
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);
// 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) {
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();
+ }
+ }
}