Code Review
/
music.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Update Master to include jar folder.
[music.git]
/
src
/
main
/
java
/
org
/
onap
/
music
/
main
/
CachingUtil.java
diff --git
a/src/main/java/org/onap/music/main/CachingUtil.java
b/src/main/java/org/onap/music/main/CachingUtil.java
index
b59e81b
..
2649130
100755
(executable)
--- 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);
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);
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;
//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");
}
logger.info(EELFLoggerDelegate.applicationLogger,"Invalid user. Cache not updated");
- return
fal
se;
+ return
aafRrespon
se;
}
}
- 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);
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);
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) {
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.
}
// 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);
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) {
}
public static void updateMusicCache(String keyspace, String nameSpace) {