From ed47d0c5d004b1ce099090100dda6dc1d963782c Mon Sep 17 00:00:00 2001 From: "Thomas Nelson Jr (arthurdent3) tn1381@att.com" Date: Thu, 8 Mar 2018 01:55:21 -0500 Subject: Docker Updates for CSIT Udates fro Docker and also a few bug fixes. Change-Id: I48d8ee81412c7ce664e6b3e33c06e952afad734e Issue-ID: MUSIC-32, MUSIC-51 Signed-off-by: Thomas Nelson Jr (arthurdent3) tn1381@att.com --- src/main/java/org/onap/music/main/CachingUtil.java | 18 ++++++++++-------- src/main/java/org/onap/music/main/MusicCore.java | 7 ++++++- src/main/java/org/onap/music/main/MusicUtil.java | 4 ++-- 3 files changed, 18 insertions(+), 11 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 40dffa2d..aee3abbf 100755 --- a/src/main/java/org/onap/music/main/CachingUtil.java +++ b/src/main/java/org/onap/music/main/CachingUtil.java @@ -392,11 +392,9 @@ public class CachingUtil implements Runnable { } PreparedQueryObject queryObject = new PreparedQueryObject(); queryObject.appendQueryString( - "select * from admin.keyspace_master where application_name = ? and username = ? and password = ? allow filtering"); + "select * from admin.keyspace_master where application_name = ? allow filtering"); try { queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), ns)); - queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId)); - queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), password)); } catch(Exception e) { resultMap.put("Exception", "Unable to process input data. Invalid input data type. Please check ns, userId and password values. "+e.getMessage()); @@ -412,16 +410,20 @@ public class CachingUtil implements Runnable { return resultMap; } if (rs == null) { - logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.AUTHENTICATIONERROR, ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR); - logger.error(EELFLoggerDelegate.errorLogger,"Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId); - - resultMap.put("Exception", "Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId); + logger.error(EELFLoggerDelegate.errorLogger,"Application is not onboarded. Please contact admin."); + resultMap.put("Exception", "Application is not onboarded. Please contact admin."); } else { + if(!(rs.getString("username").equals(userId)) && !(rs.getString("password").equals("password"))) { + logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.AUTHENTICATIONERROR, ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR); + logger.error(EELFLoggerDelegate.errorLogger,"Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId); + resultMap.put("Exception", "Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId); + return resultMap; + } boolean is_aaf = rs.getBool("is_aaf"); String keyspace = rs.getString("keyspace_name"); if (!is_aaf) { if (!keyspace.equals(MusicUtil.DEFAULTKEYSPACENAME)) { - logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.DATAERROR); + logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.DATAERROR); logger.error(EELFLoggerDelegate.errorLogger,"Non AAF applications are allowed to have only one keyspace per application."); resultMap.put("Exception", "Non AAF applications are allowed to have only one keyspace per application."); diff --git a/src/main/java/org/onap/music/main/MusicCore.java b/src/main/java/org/onap/music/main/MusicCore.java index fdf43a45..73a6ee55 100644 --- a/src/main/java/org/onap/music/main/MusicCore.java +++ b/src/main/java/org/onap/music/main/MusicCore.java @@ -119,7 +119,12 @@ public class MusicCore { logger.info(EELFLoggerDelegate.applicationLogger,"Acquiring data store handle"); long start = System.currentTimeMillis(); if (mDstoreHandle == null) { - mDstoreHandle = new MusicDataStore(); + // Quick Fix - Best to put this into every call to getDSHandle? + if (! MusicUtil.getMyCassaHost().equals("localhost") ) { + mDstoreHandle = new MusicDataStore(MusicUtil.getMyCassaHost()); + } else { + mDstoreHandle = new MusicDataStore(); + } } if(mDstoreHandle.getSession() == null) { String message = "Connection to Cassandra has not been enstablished." diff --git a/src/main/java/org/onap/music/main/MusicUtil.java b/src/main/java/org/onap/music/main/MusicUtil.java index 5bc9f94f..0f77614e 100755 --- a/src/main/java/org/onap/music/main/MusicUtil.java +++ b/src/main/java/org/onap/music/main/MusicUtil.java @@ -394,7 +394,7 @@ public class MusicUtil { MusicUtil.cassPwd = cassPwd; } - public static String convertToCQLDataType(DataType type, Object valueObj) { + public static String convertToCQLDataType(DataType type, Object valueObj) throws Exception { String value = ""; switch (type.getName()) { @@ -459,7 +459,7 @@ public class MusicUtil { * @return */ - public static String jsonMaptoSqlString(Map jMap, String lineDelimiter) { + public static String jsonMaptoSqlString(Map jMap, String lineDelimiter) throws Exception{ StringBuilder sqlString = new StringBuilder(); int counter = 0; for (Map.Entry entry : jMap.entrySet()) { -- cgit 1.2.3-korg