From 03ade18ac83ab02ee1ce0d6d43725b96513b4577 Mon Sep 17 00:00:00 2001 From: "Thomas Nelson Jr (arthurdent3) tn1381@att.com" Date: Tue, 5 Jun 2018 14:09:02 -0400 Subject: 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 --- src/main/java/org/onap/music/main/CachingUtil.java | 27 ++++++++++++---------- src/main/java/org/onap/music/main/MusicCore.java | 2 ++ src/main/java/org/onap/music/main/MusicUtil.java | 16 +++++++++---- 3 files changed, 29 insertions(+), 16 deletions(-) (limited to 'src/main/java/org/onap/music/main') 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 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 otMap = (Map) valueObj; + @SuppressWarnings("unchecked") + Map otMap = (Map) 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) valueObj; + case LIST: + return (List)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; -- cgit 1.2.3-korg