summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk
diff options
context:
space:
mode:
authorManoop Talasila <talasila@research.att.com>2019-12-06 16:21:41 +0000
committerGerrit Code Review <gerrit@onap.org>2019-12-06 16:21:41 +0000
commitb51640fc222a61869c26c9fc9a5fe5034f6f39b4 (patch)
tree1661fa9f27dbc908be395ec8f5616f216f9fff9a /ecomp-sdk
parent738fe125d60639c4b83a4e9cb020c85f4ec9e6e9 (diff)
parent61c4bdc5146977b79fb09457672c5a915adfe64b (diff)
Merge "Fix NPE & other sonar in epsdk-analytics"
Diffstat (limited to 'ecomp-sdk')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PdfReportHandler.java160
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValues.java4
2 files changed, 87 insertions, 77 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PdfReportHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PdfReportHandler.java
index 3a50a99c..b42bdf9c 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PdfReportHandler.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PdfReportHandler.java
@@ -236,8 +236,12 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{
}
}
- } catch (DocumentException dex) {dex.printStackTrace();}
- catch (RaptorException rex) {rex.printStackTrace();}
+ } catch (DocumentException dex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "DocumentException in createPdfFileContent", dex);
+ }
+ catch (RaptorException rex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "RaptorException in createPdfFileContent", rex);
+ }
} else {
//ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
@@ -322,8 +326,7 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{
} catch (DocumentException de) {
- de.printStackTrace();
- //System.err.println("document: " + de.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger, "DocumentException in createPdfFileContent", de);
}
}
@@ -574,18 +577,17 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{
}
catch (MalformedURLException e) {
isGenerateNewImage = true;
- //e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger, "MalformedURLException in getImage", e);
}
catch (BadElementException e) {
isGenerateNewImage = true;
- //e.printStackTrace();
-
+ logger.error(EELFLoggerDelegate.errorLogger, "BadElementException in getImage", e);
} catch (FileNotFoundException e) {
isGenerateNewImage = true;
- //e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger, "FileNotFoundException in getImage", e);
} catch (IOException e) {
isGenerateNewImage = true;
- //e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger, "IOException in getImage", e);
}
}
@@ -601,6 +603,10 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{
private ArrayList generateNewImage(HttpServletRequest request, ReportRuntime rr) {
ArrayList images = new ArrayList();
+ final String MALFORMEDURLEXCEPTION_MSG = "MalformedURLException in generateNewImage";
+ final String BADELEMENTEXCEPTION_MSG = "BadElementException in generateNewImage";
+ final String FILENOTFOUNDEXCEPTION_MSG = "FileNotFoundException in generateNewImage";
+ final String IOEXCEPTION_MSG = "IOException in generateNewImage";
try {
//ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME);
DataSet ds = null;
@@ -706,20 +712,21 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{
additionalChartOptionsMap,
true
);*/
- try {
- Image image = Image.getInstance(downloadFileName);
- images.add(image);
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- catch (BadElementException e) {
- e.printStackTrace();
-
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ try {
+ Image image = Image.getInstance(downloadFileName);
+ images.add(image);
+ } catch (MalformedURLException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, MALFORMEDURLEXCEPTION_MSG,
+ e);
+ } catch (BadElementException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, BADELEMENTEXCEPTION_MSG,
+ e);
+ } catch (FileNotFoundException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, FILENOTFOUNDEXCEPTION_MSG,
+ e);
+ } catch (IOException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, IOEXCEPTION_MSG, e);
+ }
}
} else { /** first check the columns to be opened in new charts and loop around in ChartGen generate chart function - sundar**/
@@ -780,20 +787,21 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{
additionalChartOptionsMap,
true
);*/
- try {
- Image image = Image.getInstance(downloadFileName);
- images.add(image);
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- catch (BadElementException e) {
- e.printStackTrace();
-
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ try {
+ Image image = Image.getInstance(downloadFileName);
+ images.add(image);
+ } catch (MalformedURLException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, MALFORMEDURLEXCEPTION_MSG,
+ e);
+ } catch (BadElementException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, BADELEMENTEXCEPTION_MSG,
+ e);
+ } catch (FileNotFoundException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, FILENOTFOUNDEXCEPTION_MSG,
+ e);
+ } catch (IOException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, IOEXCEPTION_MSG, e);
+ }
}
if(!chartType.equals(AppConstants.GT_PIE_MULTIPLE)) {
@@ -831,21 +839,22 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{
additionalChartOptionsMap,
true
);*/
- try {
- Image image = Image.getInstance(downloadFileName);
- images.add(image);
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- catch (BadElementException e) {
- e.printStackTrace();
-
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ try {
+ Image image = Image.getInstance(downloadFileName);
+ images.add(image);
+ } catch (MalformedURLException e) {
+ logger.error(EELFLoggerDelegate.errorLogger,
+ MALFORMEDURLEXCEPTION_MSG, e);
+ } catch (BadElementException e) {
+ logger.error(EELFLoggerDelegate.errorLogger,
+ BADELEMENTEXCEPTION_MSG, e);
+ } catch (FileNotFoundException e) {
+ logger.error(EELFLoggerDelegate.errorLogger,
+ FILENOTFOUNDEXCEPTION_MSG, e);
+ } catch (IOException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, IOEXCEPTION_MSG, e);
+ }
+ }
}
/** second rest of the columns are merged to one single chart - sundar**/
// System.out.println(" rr.getChartDisplayNamesList(AppConstants.CHART_WITHOUT_NEWCHART_COLUMNS) " + rr.getChartDisplayNamesList(AppConstants.CHART_WITHOUT_NEWCHART_COLUMNS));
@@ -884,29 +893,30 @@ public class PdfReportHandler extends org.onap.portalsdk.analytics.RaptorObject{
additionalChartOptionsMap,
true
);*/
- try {
- Image image = Image.getInstance(downloadFileName);
- images.add(image);
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- catch (BadElementException e) {
- e.printStackTrace();
-
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- } // Stacked Chart Check
- } // else no Series Column
-
- }// if(ds!=null)
-
- }catch (Exception e) {
- e.printStackTrace();
- }
+ try {
+ Image image = Image.getInstance(downloadFileName);
+ images.add(image);
+ } catch (MalformedURLException e) {
+ logger.error(EELFLoggerDelegate.errorLogger,
+ MALFORMEDURLEXCEPTION_MSG, e);
+ } catch (BadElementException e) {
+ logger.error(EELFLoggerDelegate.errorLogger,
+ BADELEMENTEXCEPTION_MSG, e);
+ } catch (FileNotFoundException e) {
+ logger.error(EELFLoggerDelegate.errorLogger,
+ FILENOTFOUNDEXCEPTION_MSG, e);
+ } catch (IOException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, IOEXCEPTION_MSG, e);
+ }
+ }
+ } // Stacked Chart Check
+ } // else no Series Column
+
+ } // if(ds!=null)
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Exception in generateNewImage", e);
+ }
// System.out.println("Total Images " + images.size());
return images.size()>0?images:null;
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValues.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValues.java
index d36de7e9..2d46326b 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValues.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValues.java
@@ -234,7 +234,7 @@ public class ReportParamValues extends Hashtable {
value = Utils.oracleSafe(nvl(value));
value = value.replaceAll(",","|");
if(nvl(value).length()>0) {
- if(value.indexOf("|")!= -1) { // Need option to support "|"
+ if(nvl(value).indexOf("|")!= -1) { // Need option to support "|"
value = Utils.replaceInString(value,"\r\n","~");
}
value = Utils.replaceInString(value, "~", "' , '");
@@ -379,7 +379,7 @@ public class ReportParamValues extends Hashtable {
else
return "";
} catch (RaptorException ex) {
- ex.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger, "RaptorException in getDateAsString", ex);
//throw ex;
}
return "";