aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/music/main
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
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')
-rwxr-xr-xsrc/main/java/org/onap/music/main/CachingUtil.java27
-rw-r--r--src/main/java/org/onap/music/main/MusicCore.java2
-rwxr-xr-xsrc/main/java/org/onap/music/main/MusicUtil.java16
3 files changed, 29 insertions, 16 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) {
diff --git a/src/main/java/org/onap/music/main/MusicCore.java b/src/main/java/org/onap/music/main/MusicCore.java
index dfc93ccc..cc147d57 100644
--- a/src/main/java/org/onap/music/main/MusicCore.java
+++ b/src/main/java/org/onap/music/main/MusicCore.java
@@ -22,6 +22,7 @@
package org.onap.music.main;
+import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
@@ -664,6 +665,7 @@ public class MusicCore {
"Exception thrown while doing the critical put, check sanctity of the row/conditions:\n"
+ e.getMessage());
}catch(MusicLockingException ex){
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage());
return new ReturnType(ResultType.FAILURE,ex.getMessage());
}
diff --git a/src/main/java/org/onap/music/main/MusicUtil.java b/src/main/java/org/onap/music/main/MusicUtil.java
index 5b442a79..20bb0a48 100755
--- a/src/main/java/org/onap/music/main/MusicUtil.java
+++ b/src/main/java/org/onap/music/main/MusicUtil.java
@@ -54,6 +54,10 @@ public class MusicUtil {
private static final String XLATESTVERSION = "X-latestVersion";
private static final String XMINORVERSION = "X-minorVersion";
private static final String XPATCHVERSION = "X-patchVersion";
+ public static final String SELECT = "select";
+ public static final String INSERT = "insert";
+ public static final String UPDATE = "update";
+ public static final String UPSERT = "upsert";
private static final String LOCALHOST = "localhost";
private static final String PROPERTIES_FILE = "/opt/app/music/etc/music.properties";
@@ -343,7 +347,8 @@ public class MusicUtil {
try {
Scanner fileScanner = new Scanner(new File(""));
testType = fileScanner.next();// ignore the my id line
- String batchSize = fileScanner.next();// ignore the my public ip
+ @SuppressWarnings("unused")
+ String batchSize = fileScanner.next();// ignore the my public ip
// line
fileScanner.close();
} catch (FileNotFoundException e) {
@@ -411,7 +416,8 @@ public class MusicUtil {
value = "'" + valueString + "'";
break;
case MAP: {
- Map<String, Object> otMap = (Map<String, Object>) valueObj;
+ @SuppressWarnings("unchecked")
+ Map<String, Object> otMap = (Map<String, Object>) valueObj;
value = "{" + jsonMaptoSqlString(otMap, ",") + "}";
break;
}
@@ -430,7 +436,8 @@ public class MusicUtil {
* @throws MusicTypeConversionException
* @throws Exception
*/
- public static Object convertToActualDataType(DataType colType, Object valueObj) throws Exception {
+ @SuppressWarnings("unchecked")
+ public static Object convertToActualDataType(DataType colType, Object valueObj) throws Exception {
String valueObjString = valueObj + "";
switch (colType.getName()) {
case UUID:
@@ -449,6 +456,8 @@ public class MusicUtil {
return Boolean.parseBoolean(valueObjString);
case MAP:
return (Map<String, Object>) valueObj;
+ case LIST:
+ return (List<String>)valueObj;
default:
return valueObjString;
}
@@ -480,7 +489,6 @@ public class MusicUtil {
return sqlString.toString();
}
- @SuppressWarnings("unused")
public static String buildVersion(String major, String minor, String patch) {
if (minor != null) {
major += "." + minor;