summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorburdziak <olaf.burdziakowski@nokia.com>2019-04-19 12:02:07 +0200
committerburdziak <olaf.burdziakowski@nokia.com>2019-04-19 12:02:07 +0200
commitac601e0a3093360e6e9765f6f2538ecbf863b1dd (patch)
treebab8918d300d5f7c1cf2b314226cfaa3e7640f0c
parentb3ced8c4eb98a152076b3f0a05ba601bce7f8d2a (diff)
Fix sonar issues in ErrorHandler
Change-Id: I7824b6bb52b4e3f8b205cdfa3a56281bf5423b50 Issue-ID: PORTAL-523 Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ErrorHandler.java20
1 files changed, 7 insertions, 13 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ErrorHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ErrorHandler.java
index 403c6b6b..1a31e604 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ErrorHandler.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ErrorHandler.java
@@ -68,13 +68,12 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject {
}
public void processError(HttpServletRequest request, String errorMsg) {
- //Log.write(errorMsg, 2);
logger.error(EELFLoggerDelegate.debugLogger, (errorMsg));
- ArrayList error_list = (ArrayList) request.getAttribute(AppConstants.RI_ERROR_LIST);
- if (error_list == null)
- error_list = new ArrayList(1);
- error_list.add(errorMsg);
- request.setAttribute(AppConstants.RI_ERROR_LIST, error_list);
+ ArrayList errorList = (ArrayList) request.getAttribute(AppConstants.RI_ERROR_LIST);
+ if (errorList == null)
+ errorList = new ArrayList(1);
+ errorList.add(errorMsg);
+ request.setAttribute(AppConstants.RI_ERROR_LIST, errorList);
} // processError
public void processError(HttpServletRequest request, RaptorException e) {
@@ -83,7 +82,7 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject {
private String getSessionLog(HttpServletRequest request) {
String[] sessionVariablesToLog = Globals.getLogVariablesInSession().split(",");
- StringBuffer sessionLogStrBuf = new StringBuffer("\n");
+ StringBuilder sessionLogStrBuf = new StringBuilder("\n");
sessionLogStrBuf.append("***** ADDITIONAL INFORMATION ******");
HttpSession session = request.getSession();
ReportRuntime rr = (ReportRuntime) session.getAttribute(AppConstants.SI_REPORT_RUNTIME);
@@ -106,7 +105,6 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject {
return sessionLogStrBuf.toString();
}
public String processFatalError(HttpServletRequest request, RaptorException e) {
- //Log.write("Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage()), 1);
logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage())+" "+ getSessionLog(request) + e.getMessage()),AlarmSeverityEnum.MAJOR);
if (e instanceof ReportSQLException) {
String errorSQL = ((ReportSQLException) e).getReportSQL();
@@ -120,28 +118,25 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject {
} // processFatalError
public String processFatalErrorJSON(HttpServletRequest request, RaptorException e) {
- //Log.write("Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage()), 1);
logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage())+" "+ getSessionLog(request) + e.getMessage()),AlarmSeverityEnum.MAJOR);
if (e instanceof ReportSQLException) {
String errorSQL = ((ReportSQLException) e).getReportSQL();
if (nvl(errorSQL).length() > 0)
request.setAttribute("c_error_sql", errorSQL);
} // if
- //AppUtils.processErrorNotification(request, e);
request.setAttribute(AppConstants.RI_EXCEPTION, e);
ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
errorJSONRuntime.setErrormessage(e.toString());
errorJSONRuntime.setStacktrace(getStackTrace(e));
ObjectMapper mapper = new ObjectMapper();
- //mapper.setVisibility(JsonMethod.FIELD, Visibility.ANY);
- //mapper.setVisibilityChecker(mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE));
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
String jsonInString = "";
try {
jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
} catch (Exception ex) {
+ logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] Fatal error [" + ex.getClass().getName() + "]: " + nvl(ex.getMessage())+" "+ getSessionLog(request) + ex.getMessage()),AlarmSeverityEnum.MAJOR);
ex.printStackTrace();
}
@@ -155,7 +150,6 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject {
return result.toString();
}
public String processFatalErrorWMenu(HttpServletRequest request, RaptorException e) {
- //Log.write("Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage()), 1);
logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage())+" "+ getSessionLog(request) + e.getMessage()),AlarmSeverityEnum.MAJOR);
if (e instanceof ReportSQLException) {
String errorSQL = ((ReportSQLException) e).getReportSQL();