aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/music/main/CachingUtil.java
diff options
context:
space:
mode:
authorThomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com>2018-06-05 14:09:02 -0400
committerThomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com>2018-06-05 14:09:02 -0400
commit03ade18ac83ab02ee1ce0d6d43725b96513b4577 (patch)
tree79ccb24c5599169ba3ac764b1ede71fb42c3069e /src/main/java/org/onap/music/main/CachingUtil.java
parent932c9e80911645798712a77e4cee9230a4b59408 (diff)
Update Master to include jar folder.
This will put jar folder form separate branch into this where it belongs and we can build properly for beijing. Cassablanca will have a parent pom approach. Change-Id: Ieae3fce5ab42faddf4964285533fdc59d8b963de Issue-ID: MUSIC-79 Signed-off-by: Thomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com>
Diffstat (limited to 'src/main/java/org/onap/music/main/CachingUtil.java')
-rwxr-xr-xsrc/main/java/org/onap/music/main/CachingUtil.java27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/main/java/org/onap/music/main/CachingUtil.java b/src/main/java/org/onap/music/main/CachingUtil.java
index b59e81b3..26491302 100755
--- a/src/main/java/org/onap/music/main/CachingUtil.java
+++ b/src/main/java/org/onap/music/main/CachingUtil.java
@@ -101,8 +101,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 aafRresponse = triggerAAF(nameSpace, userId, password);
+ if (aafRresponse) {
map = new HashMap<>();
map.put(userId, password);
aafCache.put(nameSpace, map);
@@ -163,20 +163,21 @@ public class CachingUtil implements Runnable {
}
}
- AAFResponse responseObj = triggerAAF(nameSpace, userId, password);
- if (responseObj.getNs().size() > 0) {
- if (responseObj.getNs().get(0).getAdmin().contains(userId)) {
+ boolean aafRresponse = triggerAAF(nameSpace, userId, password);
+ if (aafRresponse) {
+ //TODO
+ //if (responseObj.getNs().get(0).getAdmin().contains(userId)) {
//Map<String, String> map = new HashMap<>();
//map.put(userId, password);
//aafCache.put(nameSpace, map);
return true;
- }
+ //}
}
logger.info(EELFLoggerDelegate.applicationLogger,"Invalid user. Cache not updated");
- return false;
+ return aafRresponse;
}
- 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);
@@ -194,7 +195,9 @@ public class CachingUtil implements Runnable {
ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON)
.header("Authorization", "Basic " + base64Creds)
.header("content-type", "application/json").get(ClientResponse.class);
- if (response.getStatus() != 200) {
+ if(response.getStatus() == 200)
+ return true;
+ else if (response.getStatus() != 200) {
if (userAttempts.get(nameSpace) == null)
userAttempts.put(nameSpace, 0);
if ((Integer) userAttempts.get(nameSpace) >= 2) {
@@ -209,14 +212,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 false;
}
public static void updateMusicCache(String keyspace, String nameSpace) {