From 3a2b5c60384feb490e878020bdb9c01f514d7856 Mon Sep 17 00:00:00 2001 From: "Christopher Lott (cl778h)" Date: Mon, 25 Sep 2017 15:52:24 -0400 Subject: Sonar Scans and Role Centralization; clean nl PORTAL-21: centralized user role management PORTAL-72: Address Sonar Scan code issues for ONAP - mostly on raptor PORTAL-86: ONAP - Remove internal att.com usages from tests and otherfiles PORTAL-90: Add debug statements to demo app's class; no functional change Issue: PORTAL-21 PORTAL-72 PORTAL-86 PORTAL-90 Change-Id: I72a6c812009f51446330bf42bab6d3338d053805 Signed-off-by: Christopher Lott (cl778h) --- .../portalsdk/analytics/model/ReportHandler.java | 85 ++++++++++++---------- .../portalsdk/analytics/model/ReportLoader.java | 6 +- .../analytics/model/base/ReportSecurity.java | 4 +- .../analytics/model/base/ReportWrapper.java | 4 +- .../analytics/model/runtime/FormField.java | 8 +- .../analytics/model/runtime/ReportRuntime.java | 4 +- 6 files changed, 64 insertions(+), 47 deletions(-) (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model') diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportHandler.java index c81ac0cd..8a5e7e3c 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportHandler.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportHandler.java @@ -321,7 +321,7 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject { cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); hashMapStyles.put(fmt.getFormatId(), cellStyle); } else { - hashMapStyles.put(fmt.getFormatId(), styleDefault); + // hashMapStyles.put(fmt.getFormatId(), styleDefault); //fmt is null here hashMapStyles.put("default", styleDefault); } } @@ -2783,9 +2783,11 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject { AppConstants.SI_REPORT_RUNTIME); HSSFWorkbook wb = new HSSFWorkbook(); HashMap styles = new HashMap(); - if (rr != null) + String xlsFName=""; + if (rr != null){ styles = loadStyles(rr, wb); - String xlsFName = AppUtils.generateUniqueFileName(request, rr.getReportName(), AppConstants.FT_XLS); + xlsFName = AppUtils.generateUniqueFileName(request, rr.getReportName(), AppConstants.FT_XLS); + } logger.debug(EELFLoggerDelegate.debugLogger, ("Xls File name " + AppUtils.getTempFolderPath() + xlsFName)); @@ -3354,11 +3356,13 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject { readTemplate = new FileInputStream(AppUtils.getTempFolderPath()+ filename+"."+ nvls(extension, "xlsx")); wb=new XSSFWorkbook(readTemplate); } - if(rrDashRep!=null) - styles = loadXSSFStyles(rrDashRep, wb, styles); - String reportSheetName = new HtmlStripper().stripSpecialCharacters(rrDashRep.getReportName()); - if(nvl(reportSheetName).length()>28) - reportSheetName = reportSheetName.substring(0, 28); + String reportSheetName = ""; + if(rrDashRep!=null){ + styles = loadXSSFStyles(rrDashRep, wb, styles); + reportSheetName = new HtmlStripper().stripSpecialCharacters(rrDashRep.getReportName()); + } + if(nvl(reportSheetName).length()>28) + reportSheetName = reportSheetName.substring(0, 28); sheet = wb.createSheet(count+"-"+reportSheetName); if(!Globals.printExcelInLandscapeMode()) sheet.getPrintSetup().setLandscape(false); @@ -4051,22 +4055,24 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject { buf.available(); sos.write (bOut, 0, readBytes); } - - } catch (IOException ex) { - ex.printStackTrace(); - } - catch(Exception e) { + + } catch (IOException ex) { + ex.printStackTrace(); + } catch (Exception e) { e.printStackTrace(); - } finally { - try { - if (sos != null) - sos.close(); - if (buf != null) - buf.close(); - } catch (Exception e1) { - e1.printStackTrace(); + } finally { + try { + if (sos != null) + sos.close(); + if (buf != null) + buf.close(); + if (fileIn!=null) { + fileIn.close(); } - } + } catch (Exception e1) { + e1.printStackTrace(); + } + } File f = new File (AppUtils.getTempFolderPath() + fName); @@ -6460,15 +6466,17 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject { for (rd.reportColumnHeaderRows.resetNext(); rd.reportColumnHeaderRows.hasNext();) { chr = rd.reportColumnHeaderRows.getNext(); csvOut.println(""); - for (chr.resetNext(); chr.hasNext();) { - ColumnHeader ch = chr.getNext(); - if(ch.isVisible()) { - csvOut.print("" + ch.getColumnTitle() + ""); - //for (int i = 1; i < ch.getColSpan(); i++) - // csvOut.print(","); - - } - } // for + if(chr!=null){ + for (chr.resetNext(); chr.hasNext();) { + ColumnHeader ch = chr.getNext(); + if(ch.isVisible()) { + csvOut.print("" + ch.getColumnTitle() + ""); + //for (int i = 1; i < ch.getColSpan(); i++) + // csvOut.print(","); + + } + } // for + } csvOut.println(""); } // for @@ -6606,15 +6614,18 @@ public class ReportHandler extends org.onap.portalsdk.analytics.RaptorObject { if(row==null){ sheet.createRow(rowNum); } - for(int colNum=region.getFirstColumn();colNum<=region.getLastColumn();colNum++){ - XSSFCell currentCell = row.getCell(colNum); - if(currentCell==null){ - currentCell = row.createCell(colNum); - } + if(row!=null){ + for(int colNum=region.getFirstColumn();colNum<=region.getLastColumn();colNum++){ + XSSFCell currentCell = row.getCell(colNum); + if(currentCell==null){ + currentCell = row.createCell(colNum); + } - currentCell.setCellStyle(cellStyle); + currentCell.setCellStyle(cellStyle); + } } + } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportLoader.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportLoader.java index c772d308..0d416ae2 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportLoader.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/ReportLoader.java @@ -927,8 +927,10 @@ public class ReportLoader extends org.onap.portalsdk.analytics.RaptorObject { throw new ReportSQLException (ex.getMessage(), ex.getCause()); } finally { try { - stmt.close(); - connection.close(); + if(stmt!=null) + stmt.close(); + if(connection!=null) + connection.close(); DbUtils.clearConnection(connection); } catch (SQLException ex) { throw new ReportSQLException (ex.getMessage(), ex.getCause()); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportSecurity.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportSecurity.java index a9abd558..ecfd40a7 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportSecurity.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportSecurity.java @@ -328,8 +328,8 @@ public class ReportSecurity extends org.onap.portalsdk.analytics.RaptorObject { if (nvl(reportID).equals("-1")) return; - if (true) //todo: replace with proper check isPublic - return; + /*if (true) //todo: replace with proper check isPublic + return;*/ if (userID.equals(ownerID)) return; diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java index a17e411a..0ba8d4c7 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/base/ReportWrapper.java @@ -1887,7 +1887,9 @@ public class ReportWrapper extends org.onap.portalsdk.analytics.RaptorObject { for (Iterator iter1 = getFormFieldList().getFormField().iterator(); iter1.hasNext();) { FormFieldType fft = (FormFieldType) iter1.next(); String fieldDisplay = getFormFieldDisplayName(fft); - String fieldId = fft.getFieldId(); + String fieldId = ""; + if(fft!=null) + fieldId = fft.getFieldId(); if(!fft.getFieldType().equals(FormField.FFT_BLANK) && !fft.getFieldType().equals(FormField.FFT_LIST_MULTI) && !fft.getFieldType().equals(FormField.FFT_TEXTAREA)) { String paramValue = Utils.oracleSafe(nvl(reportParamValues.getParamValue(fieldId))); chartYAxis = Utils.replaceInString(chartYAxis, fieldDisplay, nvl( diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java index b8c681a8..7884e61f 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java @@ -675,8 +675,10 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme break; } - fieldDefValue = nvl(idNamevalue.getId()); - fieldDefDisplay = nvl(idNamevalue.getName()); + if(idNamevalue!=null){ + fieldDefValue = nvl(idNamevalue.getId()); + fieldDefDisplay = nvl(idNamevalue.getName()); + } } else { try { // -2 indicates to run the whole sql for matching value @@ -700,7 +702,7 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme fieldDefDisplay = nvl(fieldDefValue); } - if(oldSQL != null && !oldSQL.equals("")) { + if(oldSQL != null && !oldSQL.equals("") && lookup!=null) { ((IdNameSql)lookup).setSQL(oldSQL); } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java index 2b01821e..f9d58fee 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java @@ -2815,7 +2815,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep } } if(!ff.hasPredefinedList) { - if(oldSQL != null && !oldSQL.equals("")) { + if(oldSQL != null && !oldSQL.equals("") && lookup!=null) { ((IdNameSql)lookup).setSQL(oldSQL); } } @@ -2970,7 +2970,7 @@ public List getMapMarkers(ReportData rd, org.onap.portalsdk.analytics.xmlobj.Rep } } if(!ff.hasPredefinedList) { - if(oldSQL != null && !oldSQL.equals("")) { + if(oldSQL != null && !oldSQL.equals("") && lookup!=null) { ((IdNameSql)lookup).setSQL(oldSQL); } } -- cgit 1.2.3-korg