summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorr.bogacki <r.bogacki@samsung.com>2019-03-19 14:27:16 +0100
committerRobert Bogacki <r.bogacki@samsung.com>2019-03-28 06:56:23 +0000
commit0a358ea9fd56796d7dcf9c2a50df82a4f05b9738 (patch)
tree8236f863b96b429e109d398d992782b48c803104 /src
parentcf8096a9fe50de511d5864032ed4825a2a314fa5 (diff)
Log stack traces with logger
Fixed critical sonar issues: -"Either log or rethrow this exception" Change-Id: I99a550f2cf40bd6c34a0f8ca1893c964669c76de Issue-ID: MUSIC-367 Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/music/authentication/MusicAAFAuthentication.java6
-rw-r--r--src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java13
-rwxr-xr-xsrc/main/java/org/onap/music/datastore/MusicDataStore.java24
-rw-r--r--src/main/java/org/onap/music/lockingservice/cassandra/MusicLockState.java8
-rwxr-xr-xsrc/main/java/org/onap/music/main/MusicUtil.java9
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicAdminAPI.java2
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicDataAPI.java56
-rw-r--r--src/main/java/org/onap/music/rest/RestMusicLocksAPI.java6
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicQAPI.java6
-rw-r--r--src/main/java/org/onap/music/service/impl/MusicCassaCore.java35
10 files changed, 112 insertions, 53 deletions
diff --git a/src/main/java/org/onap/music/authentication/MusicAAFAuthentication.java b/src/main/java/org/onap/music/authentication/MusicAAFAuthentication.java
index 2d0d4e59..0fd6c0e2 100644
--- a/src/main/java/org/onap/music/authentication/MusicAAFAuthentication.java
+++ b/src/main/java/org/onap/music/authentication/MusicAAFAuthentication.java
@@ -4,6 +4,8 @@
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -134,7 +136,7 @@ public class MusicAAFAuthentication implements MusicAuthenticator {
isValid = CachingUtil.authenticateAAFUser(namespace, userId, password, keyspace);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger,"Error while aaf authentication for user:" + userId);
- logger.error(EELFLoggerDelegate.errorLogger,"Error: "+ e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,"Error: "+ e.getMessage(), e);
logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.AUTHENTICATIONERROR ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR);
logger.error(EELFLoggerDelegate.errorLogger,"Got exception while AAF authentication for namespace " + namespace);
resultMap.put("Exception", e.getMessage());
@@ -170,7 +172,7 @@ public class MusicAAFAuthentication implements MusicAuthenticator {
uuid = rs.getUUID("uuid").toString();
resultMap.put("uuid", "existing");
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.applicationLogger,"No UUID found in DB. So creating new UUID.");
+ logger.error(EELFLoggerDelegate.applicationLogger,"No UUID found in DB. So creating new UUID.", e);
uuid = MusicUtil.generateUUID();
resultMap.put("uuid", "new");
}
diff --git a/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java b/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
index 045abd98..69ccd104 100644
--- a/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
+++ b/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
@@ -3,7 +3,9 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
* Modifications Copyright (C) 2019 IBM.
+ * Modifications Copyright (c) 2019 Samsung
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -112,6 +114,7 @@ public class MusicConditional {
return lockAcqResult;
}
} catch (Exception e) {
+ logger.error(EELFLoggerDelegate.applicationLogger, e);
MusicCore.destroyLockRef(lockId);
return new ReturnType(ResultType.FAILURE, e.getMessage());
}
@@ -130,6 +133,7 @@ public class MusicConditional {
try {
results = MusicDataStoreHandle.getDSHandle().executeQuorumConsistencyGet(queryBank.get(MusicUtil.SELECT));
} catch (Exception e) {
+ logger.error(EELFLoggerDelegate.applicationLogger, e);
return new ReturnType(ResultType.FAILURE, e.getMessage());
}
if (results.all().isEmpty()) {
@@ -148,6 +152,7 @@ public class MusicConditional {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String exceptionAsString = sw.toString();
+ logger.error(EELFLoggerDelegate.applicationLogger, e);
return new ReturnType(ResultType.FAILURE,
"Exception thrown while doing the critical put, check sanctity of the row/conditions:\n"
+ exceptionAsString);
@@ -175,6 +180,7 @@ public class MusicConditional {
} catch (Exception e) {
MusicCore.destroyLockRef(lockId);
+ logger.error(EELFLoggerDelegate.applicationLogger, e);
return new ReturnType(ResultType.FAILURE, e.getMessage());
}
@@ -202,6 +208,7 @@ public class MusicConditional {
try {
MusicDataStoreHandle.getDSHandle().executePut(update, "critical");
} catch (Exception ex) {
+ logger.error(EELFLoggerDelegate.applicationLogger, ex);
return new ReturnType(ResultType.FAILURE, ex.getMessage());
}
}else {
@@ -219,6 +226,7 @@ public class MusicConditional {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String exceptionAsString = sw.toString();
+ logger.error(EELFLoggerDelegate.applicationLogger, e);
return new ReturnType(ResultType.FAILURE,
"Exception thrown while doing the critical put, check sanctity of the row/conditions:\n"
+ exceptionAsString);
@@ -275,7 +283,8 @@ public class MusicConditional {
try {
colType = tableInfo.getColumn(entry.getKey()).getType();
} catch(NullPointerException ex) {
- logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage() +" Invalid column name : "+entry.getKey(), AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage() +" Invalid column name : "+entry.getKey
+ (), AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR, ex);
}
@@ -283,7 +292,7 @@ public class MusicConditional {
try {
formattedValue = MusicUtil.convertToActualDataType(colType, valueObj);
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), e);
}
valueString.append("?");
diff --git a/src/main/java/org/onap/music/datastore/MusicDataStore.java b/src/main/java/org/onap/music/datastore/MusicDataStore.java
index f58bd831..1260efa0 100755
--- a/src/main/java/org/onap/music/datastore/MusicDataStore.java
+++ b/src/main/java/org/onap/music/datastore/MusicDataStore.java
@@ -5,6 +5,7 @@
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
* Modifications Copyright (c) 2018-2019 IBM
+ * Modifications Copyright (c) 2019 Samsung
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -127,7 +128,7 @@ public class MusicDataStore {
try {
connectToCassaCluster(remoteIp);
} catch (MusicServiceException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), e);
}
}
@@ -148,9 +149,11 @@ public class MusicDataStore {
}
}
} catch (SocketException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), AppMessages.CONNCECTIVITYERROR, ErrorSeverity.ERROR, ErrorTypes.CONNECTIONERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), AppMessages.CONNCECTIVITYERROR,
+ ErrorSeverity.ERROR, ErrorTypes.CONNECTIONERROR, e);
}catch(Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), ErrorSeverity.ERROR, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), ErrorSeverity.ERROR, ErrorTypes
+ .GENERALSERVICEERROR, e);
}
return allPossibleIps;
}
@@ -198,7 +201,8 @@ public class MusicDataStore {
break;
} catch (NoHostAvailableException e) {
address = it.next();
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.HOSTUNAVAILABLE, ErrorSeverity.ERROR, ErrorTypes.CONNECTIONERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.HOSTUNAVAILABLE,
+ ErrorSeverity.ERROR, ErrorTypes.CONNECTIONERROR, e);
}
}
}
@@ -253,7 +257,8 @@ public class MusicDataStore {
try {
session = cluster.connect();
} catch (Exception ex) {
- logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.CASSANDRACONNECTIVITY, ErrorSeverity.ERROR, ErrorTypes.SERVICEUNAVAILABLE);
+ logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.CASSANDRACONNECTIVITY,
+ ErrorSeverity.ERROR, ErrorTypes.SERVICEUNAVAILABLE, ex);
throw new MusicServiceException(
"Error while connecting to Cassandra cluster.. " + ex.getMessage());
}
@@ -446,11 +451,13 @@ public class MusicDataStore {
}
catch (AlreadyExistsException ae) {
- logger.error(EELFLoggerDelegate.errorLogger, ae.getMessage(),AppMessages.SESSIONFAILED+ " [" + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
+ 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);
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.SESSIONFAILED+ " [" +
+ queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR, e);
throw new MusicQueryException("Executing Session Failure for Request = " + "["
+ queryObject.getQuery() + "]" + " Reason = " + e.getMessage());
}
@@ -560,7 +567,8 @@ public class MusicDataStore {
results = session.execute(statement);
} catch (Exception ex) {
- logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.UNKNOWNERROR+ "[" + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.UNKNOWNERROR+ "[" + queryObject
+ .getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR, ex);
throw new MusicServiceException(ex.getMessage());
}
diff --git a/src/main/java/org/onap/music/lockingservice/cassandra/MusicLockState.java b/src/main/java/org/onap/music/lockingservice/cassandra/MusicLockState.java
index 5128e2cd..8f3c0d6d 100644
--- a/src/main/java/org/onap/music/lockingservice/cassandra/MusicLockState.java
+++ b/src/main/java/org/onap/music/lockingservice/cassandra/MusicLockState.java
@@ -4,6 +4,8 @@
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -118,7 +120,8 @@ public class MusicLockState implements Serializable {
out = new ObjectOutputStream(bos);
out.writeObject(this);
} catch (IOException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.IOERROR, ErrorSeverity.ERROR, ErrorTypes.CONNECTIONERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.IOERROR, ErrorSeverity.ERROR,
+ ErrorTypes.CONNECTIONERROR, e);
}
return bos.toByteArray();
}
@@ -131,7 +134,8 @@ public class MusicLockState implements Serializable {
in = new ObjectInputStream(bis);
o = in.readObject();
} catch (ClassNotFoundException | IOException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity.ERROR, ErrorTypes.UNKNOWN);
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity
+ .ERROR, ErrorTypes.UNKNOWN, e);
}
return (MusicLockState) o;
}
diff --git a/src/main/java/org/onap/music/main/MusicUtil.java b/src/main/java/org/onap/music/main/MusicUtil.java
index b737377d..07612aa0 100755
--- a/src/main/java/org/onap/music/main/MusicUtil.java
+++ b/src/main/java/org/onap/music/main/MusicUtil.java
@@ -478,7 +478,7 @@ public class MusicUtil {
// line
fileScanner.close();
} catch (FileNotFoundException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), e);
}
return testType;
@@ -492,7 +492,7 @@ public class MusicUtil {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), e);
Thread.currentThread().interrupt();
}
}
@@ -702,7 +702,7 @@ public class MusicUtil {
input = MusicUtil.class.getClassLoader().getResourceAsStream("music.properties");
prop.load(input);
} catch (Exception ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "Unable to find properties file.");
+ logger.error(EELFLoggerDelegate.errorLogger, "Unable to find properties file.", ex);
throw new Exception();
} finally {
if (input != null) {
@@ -710,6 +710,7 @@ public class MusicUtil {
input.close();
} catch (IOException e) {
e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger, e);
}
}
}
@@ -824,7 +825,7 @@ public class MusicUtil {
MusicDataStoreHandle.getDSHandle().executePut(updateQuery, "critical");
} catch (MusicServiceException | MusicQueryException e) {
logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.QUERYERROR +""+updateQuery ,
- ErrorSeverity.MAJOR, ErrorTypes.QUERYERROR);
+ ErrorSeverity.MAJOR, ErrorTypes.QUERYERROR, e);
}
}
diff --git a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
index adcb6584..fddeebff 100755
--- a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java
@@ -5,6 +5,7 @@
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
* Modifications Copyright (C) 2018 IBM.
+ * Modifications Copyright (c) 2019 Samsung
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -489,6 +490,7 @@ public class RestMusicAdminAPI {
try {
result = MusicCore.nonKeyRelatedPut(queryObject, "eventual");
}catch(Exception ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, ex);
return false;
}
return true;
diff --git a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
index dfcf0bdb..8500298b 100755
--- a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
@@ -202,7 +202,8 @@ public class RestMusicDataAPI {
try {
repString = "{" + MusicUtil.jsonMaptoSqlString(replicationInfo, ",") + "}";
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.MISSINGDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.MISSINGDATA ,ErrorSeverity
+ .CRITICAL, ErrorTypes.DATAERROR, e);
}
queryObject.appendQueryString(
@@ -222,7 +223,8 @@ public class RestMusicDataAPI {
result = MusicCore.nonKeyRelatedPut(queryObject, consistency);
logger.info(EELFLoggerDelegate.applicationLogger, "result = " + result);
} catch ( MusicServiceException ex) {
- logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity
+ .WARN, ErrorTypes.MUSICSERVICEERROR, ex);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("err:" + ex.getMessage()).toMap()).build();
}
@@ -237,7 +239,8 @@ public class RestMusicDataAPI {
queryObject.appendQueryString(";");
MusicCore.nonKeyRelatedPut(queryObject, consistency);
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR,ErrorSeverity
+ .WARN, ErrorTypes.MUSICSERVICEERROR, e);
}
try {
@@ -258,7 +261,8 @@ public class RestMusicDataAPI {
CachingUtil.updateMusicValidateCache(ns, userId, hashedpwd);
MusicCore.eventualPut(queryObject);
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR,ErrorSeverity
+ .WARN, ErrorTypes.MUSICSERVICEERROR, e);
return response.status(Response.Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap()).build();
}
@@ -576,7 +580,8 @@ public class RestMusicDataAPI {
try {
result = MusicCore.createTable(keyspace, tablename, queryObject, consistency);
} catch (MusicServiceException ex) {
- logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.CRITICAL, ErrorTypes.MUSICSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity
+ .CRITICAL, ErrorTypes.MUSICSERVICEERROR, ex);
response.status(Status.BAD_REQUEST);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()).build();
}
@@ -639,7 +644,8 @@ public class RestMusicDataAPI {
try {
result = MusicCore.nonKeyRelatedPut(query, "eventual");
} catch (MusicServiceException ex) {
- logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.CRITICAL, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity
+ .CRITICAL, ErrorTypes.GENERALSERVICEERROR, ex);
response.status(Status.BAD_REQUEST);
return response.entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()).build();
}
@@ -725,7 +731,8 @@ public class RestMusicDataAPI {
try {
colType = tableInfo.getColumn(entry.getKey()).getType();
} catch(NullPointerException ex) {
- logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage() +" Invalid column name : "+entry.getKey(), AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage() +" Invalid column name : "+entry.getKey
+ (), AppMessages.INCORRECTDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR, ex);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("Invalid column name : "+entry.getKey()).toMap()).build();
}
@@ -845,7 +852,8 @@ public class RestMusicDataAPI {
}
} catch (Exception ex) {
- logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity
+ .WARN, ErrorTypes.MUSICSERVICEERROR, ex);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()).build();
}
@@ -925,7 +933,8 @@ public class RestMusicDataAPI {
try {
tableInfo = MusicDataStoreHandle.returnColumnMetadata(keyspace, tablename);
} catch (MusicServiceException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes
+ .GENERALSERVICEERROR, e);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap()).build();
}
if (tableInfo == null) {
@@ -945,7 +954,7 @@ public class RestMusicDataAPI {
try {
colType = tableInfo.getColumn(entry.getKey()).getType();
} catch(NullPointerException ex) {
- logger.error(EELFLoggerDelegate.errorLogger, ex, "Invalid column name : "+entry.getKey());
+ logger.error(EELFLoggerDelegate.errorLogger, ex, "Invalid column name : "+entry.getKey(), ex);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("Invalid column name : "+entry.getKey()).toMap()).build();
}
Object valueString = null;
@@ -992,7 +1001,8 @@ public class RestMusicDataAPI {
.setError("Mandatory WHERE clause is missing. Please check the input request.").toMap()).build();
}
} catch (MusicServiceException ex) {
- logger.error(EELFLoggerDelegate.errorLogger,ex, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,ex, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes
+ .GENERALSERVICEERROR, ex);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()).build();
}
@@ -1040,7 +1050,8 @@ public class RestMusicDataAPI {
operationResult = MusicCore.atomicPutWithDeleteLock(keyspace, tablename,
rowId.primarKeyValue, queryObject, conditionInfo);
} catch (MusicLockingException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN,
+ ErrorTypes.GENERALSERVICEERROR, e);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap()).build();
}
} else if (consistency.equalsIgnoreCase(MusicUtil.ATOMIC)) {
@@ -1048,7 +1059,8 @@ public class RestMusicDataAPI {
operationResult = MusicCore.atomicPut(keyspace, tablename, rowId.primarKeyValue,
queryObject, conditionInfo);
} catch (MusicLockingException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN,
+ ErrorTypes.GENERALSERVICEERROR, e);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap()).build();
}
}else if(consistency.equalsIgnoreCase(MusicUtil.EVENTUAL_NB)) {
@@ -1155,7 +1167,8 @@ public class RestMusicDataAPI {
try {
rowId = getRowIdentifier(keyspace, tablename, info.getQueryParameters(), queryObject);
} catch (MusicServiceException ex) {
- logger.error(EELFLoggerDelegate.errorLogger,ex, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,ex, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes
+ .GENERALSERVICEERROR, ex);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()).build();
}
String rowSpec = rowId.rowIdString.toString();
@@ -1221,7 +1234,8 @@ public class RestMusicDataAPI {
operationResult = MusicCore.eventualPut_nb(queryObject, keyspace, tablename, rowId.primarKeyValue);
}
} catch (MusicLockingException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes
+ .GENERALSERVICEERROR, e);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
.setError("Unable to perform Delete operation. Exception from music").toMap()).build();
}
@@ -1288,7 +1302,8 @@ public class RestMusicDataAPI {
try {
return response.status(Status.OK).entity(new JsonResponse(MusicCore.nonKeyRelatedPut(query, consistency)).toMap()).build();
} catch (MusicServiceException ex) {
- logger.error(EELFLoggerDelegate.errorLogger,ex, AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, ex, AppMessages.MISSINGINFO ,ErrorSeverity.WARN, ErrorTypes
+ .GENERALSERVICEERROR);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()).build();
}
} finally {
@@ -1349,7 +1364,8 @@ public class RestMusicDataAPI {
try {
rowId = getRowIdentifier(keyspace, tablename, info.getQueryParameters(), queryObject);
} catch (MusicServiceException ex) {
- logger.error(EELFLoggerDelegate.errorLogger,ex, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,ex, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes
+ .GENERALSERVICEERROR, ex);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()).build();
}
queryObject.appendQueryString(
@@ -1433,7 +1449,8 @@ public class RestMusicDataAPI {
try {
queryObject = selectSpecificQuery(keyspace, tablename, info, limit);
} catch (MusicServiceException ex) {
- logger.error(EELFLoggerDelegate.errorLogger, ex, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, ex, AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN,
+ ErrorTypes.GENERALSERVICEERROR, ex);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()).build();
}
}
@@ -1445,7 +1462,8 @@ public class RestMusicDataAPI {
}
return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS).setDataResult(MusicDataStoreHandle.marshallResults(results)).setError("No data found").toMap()).build();
} catch (MusicServiceException ex) {
- logger.error(EELFLoggerDelegate.errorLogger, ex, AppMessages.UNKNOWNERROR ,ErrorSeverity.ERROR, ErrorTypes.MUSICSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, ex, AppMessages.UNKNOWNERROR ,ErrorSeverity.ERROR,
+ ErrorTypes.MUSICSERVICEERROR, ex);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()).build();
}
} finally {
diff --git a/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java b/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
index 943f4ca8..77c6ef1f 100644
--- a/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java
@@ -4,6 +4,8 @@
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -175,7 +177,8 @@ public class RestMusicLocksAPI {
}
return response.entity(new JsonResponse(lockStatus.getResult()).setLock(lockId).setMessage(lockStatus.getMessage()).toMap()).build();
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger,AppMessages.INVALIDLOCK + lockId, ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,AppMessages.INVALIDLOCK + lockId, ErrorSeverity.CRITICAL,
+ ErrorTypes.LOCKINGERROR, e);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("Unable to aquire lock").toMap()).build();
}
} finally {
@@ -446,6 +449,7 @@ public class RestMusicLocksAPI {
try{
MusicCore.deleteLock(lockName);
}catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, e);
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap()).build();
}
return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS).toMap()).build();
diff --git a/src/main/java/org/onap/music/rest/RestMusicQAPI.java b/src/main/java/org/onap/music/rest/RestMusicQAPI.java
index 676730e0..f3df9350 100755
--- a/src/main/java/org/onap/music/rest/RestMusicQAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicQAPI.java
@@ -3,7 +3,9 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
* Modifications Copyright (C) 2019 IBM.
+ * Modifications Copyright (c) 2019 Samsung
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -376,7 +378,7 @@ public class RestMusicQAPI {
queryObject = new RestMusicDataAPI().selectSpecificQuery(keyspace, tablename, info, limit);
} catch (MusicServiceException ex) {
logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.UNKNOWNERROR,
- ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
+ ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR, ex);
return response.status(Status.BAD_REQUEST)
.entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap())
.build();
@@ -389,7 +391,7 @@ public class RestMusicQAPI {
.setDataResult(MusicDataStoreHandle.marshallResults(results)).toMap()).build();
} catch (MusicServiceException ex) {
logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.UNKNOWNERROR,
- ErrorSeverity.ERROR, ErrorTypes.MUSICSERVICEERROR);
+ ErrorSeverity.ERROR, ErrorTypes.MUSICSERVICEERROR, ex);
return response.status(Status.BAD_REQUEST)
.entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap())
.build();
diff --git a/src/main/java/org/onap/music/service/impl/MusicCassaCore.java b/src/main/java/org/onap/music/service/impl/MusicCassaCore.java
index cb6e1ce4..2c10c91a 100644
--- a/src/main/java/org/onap/music/service/impl/MusicCassaCore.java
+++ b/src/main/java/org/onap/music/service/impl/MusicCassaCore.java
@@ -106,6 +106,7 @@ public class MusicCassaCore implements MusicCoreService {
lockReference = "" + getLockingServiceHandle().genLockRefandEnQueue(keyspace, table, lockName);
} catch (MusicLockingException | MusicServiceException | MusicQueryException e) {
e.printStackTrace();
+ logger.error(EELFLoggerDelegate.applicationLogger, e);
}
long end = System.currentTimeMillis();
logger.info(EELFLoggerDelegate.applicationLogger,"Time taken to create lock reference:" + (end - start) + " ms");
@@ -184,7 +185,8 @@ public class MusicCassaCore implements MusicCoreService {
syncQuorum(keyspace, table, primaryKeyValue);
} catch (Exception e) {
StringWriter sw = new StringWriter();
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), "[ERR506E] Failed to aquire lock ",ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), "[ERR506E] Failed to aquire lock ",
+ ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR, e);
String exceptionAsString = sw.toString();
return new ReturnType(ResultType.FAILURE, "Exception thrown while syncing key:\n" + exceptionAsString);
}
@@ -236,7 +238,8 @@ public class MusicCassaCore implements MusicCoreService {
//create actual table
result = MusicDataStoreHandle.getDSHandle().executePut(tableQueryObject, consistency);
} catch (MusicQueryException | MusicServiceException | MusicLockingException ex) {
- logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity
+ .WARN, ErrorTypes.MUSICSERVICEERROR, ex);
throw new MusicServiceException(ex.getMessage());
}
return result?ResultType.SUCCESS:ResultType.FAILURE;
@@ -274,7 +277,8 @@ public class MusicCassaCore implements MusicCoreService {
try {
results = MusicDataStoreHandle.getDSHandle().executeQuorumConsistencyGet(query);
} catch (MusicServiceException | MusicQueryException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.MAJOR, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity
+ .MAJOR, ErrorTypes.GENERALSERVICEERROR, e);
}
return results;
@@ -295,7 +299,8 @@ public class MusicCassaCore implements MusicCoreService {
return "$" + fullyQualifiedKey + "$"
+ getLockingServiceHandle().peekLockQueue(keyspace, table, primaryKeyValue).lockRef;
} catch (MusicLockingException | MusicServiceException | MusicQueryException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.LOCKINGERROR+fullyQualifiedKey ,ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.LOCKINGERROR+fullyQualifiedKey
+ ,ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR, e);
}
return null;
}
@@ -322,7 +327,8 @@ public class MusicCassaCore implements MusicCoreService {
try {
getLockingServiceHandle().deQueueLockRef(keyspace, table, primaryKeyValue, lockRef);
} catch (MusicLockingException | MusicServiceException | MusicQueryException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.DESTROYLOCK+lockRef ,ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.DESTROYLOCK+lockRef ,
+ ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR, e);
}
long end = System.currentTimeMillis();
logger.info(EELFLoggerDelegate.applicationLogger,"Time taken to destroy lock reference:" + (end - start) + " ms");
@@ -337,7 +343,8 @@ public class MusicCassaCore implements MusicCoreService {
try {
getLockingServiceHandle().deQueueLockRef(keyspace, table, primaryKeyValue, lockReference);
} catch (MusicLockingException | MusicServiceException | MusicQueryException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.DESTROYLOCK+lockReference ,ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.DESTROYLOCK+lockReference ,
+ ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR, e);
}
long end = System.currentTimeMillis();
logger.info(EELFLoggerDelegate.applicationLogger,"Time taken to destroy lock reference:" + (end - start) + " ms");
@@ -375,7 +382,7 @@ public class MusicCassaCore implements MusicCoreService {
MusicDataStoreHandle.getDSHandle().executePut(queryObject, "critical");
} catch (Exception e) {
logger.error("Cannot forcibly release lock: " + fullyQualifiedKey + " " + lockReference + ". "
- + e.getMessage());
+ + e.getMessage(), e);
}
//now release the lock
@@ -445,13 +452,13 @@ public class MusicCassaCore implements MusicCoreService {
}
} catch (MusicServiceException | MusicQueryException e) {
- logger.error(EELFLoggerDelegate.applicationLogger,e.getMessage());
+ logger.error(EELFLoggerDelegate.applicationLogger,e.getMessage(), e);
}
try {
result = MusicDataStoreHandle.getDSHandle().executePut(queryObject, MusicUtil.EVENTUAL);
} catch (MusicServiceException | MusicQueryException ex) {
logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), "[ERR512E] Failed to get ZK Lock Handle " ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
- logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage() + " " + ex.getCause() + " " + ex);
+ logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage() + " " + ex.getCause(), ex);
return new ReturnType(ResultType.FAILURE, ex.getMessage());
}
if (result) {
@@ -485,6 +492,7 @@ public class MusicCassaCore implements MusicCoreService {
return new ReturnType(ResultType.FAILURE,
"Lock acquired but the condition is not true");
} catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, e);
return new ReturnType(ResultType.FAILURE,
"Exception thrown while checking the condition, check its sanctity:\n"
+ e.getMessage());
@@ -509,7 +517,7 @@ public class MusicCassaCore implements MusicCoreService {
long end = System.currentTimeMillis();
logger.info(EELFLoggerDelegate.applicationLogger,"Time taken for the critical put:" + (end - start) + " ms");
}catch (MusicQueryException | MusicServiceException | MusicLockingException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), e);
return new ReturnType(ResultType.FAILURE,
"Exception thrown while doing the critical put\n"
+ e.getMessage());
@@ -535,7 +543,7 @@ public class MusicCassaCore implements MusicCoreService {
result = MusicDataStoreHandle.getDSHandle().executePut(queryObject, consistency);
} catch (MusicQueryException | MusicServiceException ex) {
logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(), AppMessages.UNKNOWNERROR,
- ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
+ ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR, ex);
throw new MusicServiceException(ex.getMessage());
}
return result ? ResultType.SUCCESS : ResultType.FAILURE;
@@ -553,7 +561,7 @@ public class MusicCassaCore implements MusicCoreService {
try {
results = MusicDataStoreHandle.getDSHandle().executeOneConsistencyGet(queryObject);
} catch (MusicQueryException | MusicServiceException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), e);
throw new MusicServiceException(e.getMessage());
}
return results;
@@ -581,7 +589,8 @@ public class MusicCassaCore implements MusicCoreService {
return null;//not top of the lock store q
results = MusicDataStoreHandle.getDSHandle().executeQuorumConsistencyGet(queryObject);
} catch (MusicQueryException | MusicServiceException | MusicLockingException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity
+ .WARN, ErrorTypes.MUSICSERVICEERROR, e);
}
return results;
}