aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/music/datastore/MusicDataStore.java
diff options
context:
space:
mode:
authorThomas Nelson arthudent3 <nelson24@att.com>2019-06-19 22:19:10 +0000
committerThomas Nelson arthudent3 <nelson24@att.com>2019-06-25 13:20:59 +0000
commit881f14bc8676cedd68e17bd007a869fa85578fa1 (patch)
tree0dc37c36af2483d5d0925dd84993f93f344688f8 /src/main/java/org/onap/music/datastore/MusicDataStore.java
parent078f69315e4b4faffc50e1c7dfde717396e48194 (diff)
Some bug fixes and Minor Chages.
Remove some Commented out code. Cleaned up Variables. Encryption of passwords added Updated Test Cases Fixed some errors in how they were reported. Reduced Logging clutter Some Vulnerability fixes. Change-Id: I64c7935d167d4a976681b5a18fd51aa667d0cd95 Issue-ID: MUSIC-413 Signed-off-by: Thomas Nelson arthudent3 <nelson24@att.com>
Diffstat (limited to 'src/main/java/org/onap/music/datastore/MusicDataStore.java')
-rwxr-xr-xsrc/main/java/org/onap/music/datastore/MusicDataStore.java40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/main/java/org/onap/music/datastore/MusicDataStore.java b/src/main/java/org/onap/music/datastore/MusicDataStore.java
index c771d80a..6195dbef 100755
--- a/src/main/java/org/onap/music/datastore/MusicDataStore.java
+++ b/src/main/java/org/onap/music/datastore/MusicDataStore.java
@@ -35,15 +35,14 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import org.apache.commons.jcs.access.CacheAccess;
import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.onap.music.eelf.logging.format.AppMessages;
import org.onap.music.eelf.logging.format.ErrorSeverity;
import org.onap.music.eelf.logging.format.ErrorTypes;
import org.onap.music.exceptions.MusicQueryException;
import org.onap.music.exceptions.MusicServiceException;
+import org.onap.music.main.CipherUtil;
import org.onap.music.main.MusicUtil;
-import com.codahale.metrics.JmxReporter;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ColumnDefinitions;
import com.datastax.driver.core.ColumnDefinitions.Definition;
@@ -53,7 +52,6 @@ import com.datastax.driver.core.HostDistance;
import com.datastax.driver.core.KeyspaceMetadata;
import com.datastax.driver.core.Metadata;
import com.datastax.driver.core.PoolingOptions;
-import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
@@ -62,7 +60,6 @@ import com.datastax.driver.core.TableMetadata;
import com.datastax.driver.core.exceptions.AlreadyExistsException;
import com.datastax.driver.core.exceptions.InvalidQueryException;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
-import com.sun.jersey.core.util.Base64;
/**
* @author nelson24
@@ -177,10 +174,11 @@ public class MusicDataStore {
while (it.hasNext()) {
try {
if(MusicUtil.getCassName() != null && MusicUtil.getCassPwd() != null) {
+ String cassPwd = CipherUtil.decryptPKC(MusicUtil.getCassPwd());
logger.info(EELFLoggerDelegate.applicationLogger,
"Building with credentials "+MusicUtil.getCassName()+" & "+MusicUtil.getCassPwd());
cluster = Cluster.builder().withPort(MusicUtil.getCassandraPort())
- .withCredentials(MusicUtil.getCassName(), MusicUtil.getCassPwd())
+ .withCredentials(MusicUtil.getCassName(), cassPwd)
//.withLoadBalancingPolicy(new RoundRobinPolicy())
.withoutJMXReporting()
.withPoolingOptions(poolingOptions)
@@ -225,10 +223,11 @@ public class MusicDataStore {
.setConnectionsPerHost(HostDistance.LOCAL, 4, 10)
.setConnectionsPerHost(HostDistance.REMOTE, 2, 4);
if(MusicUtil.getCassName() != null && MusicUtil.getCassPwd() != null) {
+ String cassPwd = CipherUtil.decryptPKC(MusicUtil.getCassPwd());
logger.info(EELFLoggerDelegate.applicationLogger,
- "Building with credentials "+MusicUtil.getCassName()+" & "+MusicUtil.getCassPwd());
+ "Building with credentials "+MusicUtil.getCassName()+" & "+ MusicUtil.getCassPwd());
cluster = Cluster.builder().withPort(MusicUtil.getCassandraPort())
- .withCredentials(MusicUtil.getCassName(), MusicUtil.getCassPwd())
+ .withCredentials(MusicUtil.getCassName(), cassPwd)
//.withLoadBalancingPolicy(new RoundRobinPolicy())
.withoutJMXReporting()
.withPoolingOptions(poolingOptions)
@@ -410,7 +409,7 @@ public class MusicDataStore {
throw new MusicQueryException("Ill formed queryObject for the request = " + "["
+ queryObject.getQuery() + "]");
}
- logger.info(EELFLoggerDelegate.applicationLogger,
+ logger.debug(EELFLoggerDelegate.applicationLogger,
"In preprared Execute Put: the actual insert query:"
+ queryObject.getQuery() + "; the values"
+ queryObject.getValues());
@@ -442,18 +441,19 @@ public class MusicDataStore {
}
catch (AlreadyExistsException ae) {
- logger.error(EELFLoggerDelegate.errorLogger, ae.getMessage(),AppMessages.SESSIONFAILED+ " [" +
- queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR, ae);
- throw new MusicServiceException(ae.getMessage());
- }
- catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.SESSIONFAILED + " ["
- + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR, e);
+ // logger.error(EELFLoggerDelegate.errorLogger,"AlreadExistsException: " + ae.getMessage(),AppMessages.QUERYERROR,
+ // ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
+ throw new MusicQueryException("AlreadyExistsException: " + ae.getMessage(),ae);
+ } catch ( InvalidQueryException e ) {
+ // logger.error(EELFLoggerDelegate.errorLogger,"InvalidQueryException: " + e.getMessage(),AppMessages.SESSIONFAILED + " ["
+ // + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
+ throw new MusicQueryException("InvalidQueryException: " + e.getMessage(),e);
+ } catch (Exception e) {
+ // logger.error(EELFLoggerDelegate.errorLogger,e.getClass().toString() + ":" + e.getMessage(),AppMessages.SESSIONFAILED + " ["
+ // + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR, e);
throw new MusicServiceException("Executing Session Failure for Request = " + "["
- + queryObject.getQuery() + "]" + " Reason = " + e.getMessage());
+ + queryObject.getQuery() + "]" + " Reason = " + e.getMessage(),e);
}
-
-
return result;
}
@@ -556,9 +556,9 @@ public class MusicDataStore {
results = session.execute(statement);
} catch (Exception ex) {
- logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.UNKNOWNERROR+ "[" + queryObject
+ logger.error(EELFLoggerDelegate.errorLogger, "Execute Get Error" + ex.getMessage(),AppMessages.UNKNOWNERROR+ "[" + queryObject
.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR, ex);
- throw new MusicServiceException(ex.getMessage());
+ throw new MusicServiceException("Execute Get Error" + ex.getMessage());
}
return results;