diff options
Diffstat (limited to 'ecomp-sdk')
23 files changed, 586 insertions, 639 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java index 1eea72e1..d6ae3e2d 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java @@ -140,6 +140,13 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { private static final String PARENT = "parent_"; private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ActionHandler.class); + private static final String REPORT_DOWNLOAD_PDF = "report.download.pdf"; + private static final String REPORT_TEXT_DOWNLOAD = "report.text.download"; + private static final String REPORT_CSV_DOWNLOAD = "report.csv.download"; + private static final String REPORT_DOWNLOAD_EXCEL2007 = "report.download.excel2007"; + private static final String REPORT_DOWNLOAD = "report.download"; + private static final String REPORT_DOWNLOAD_PAGE = "report.download.page"; + private void preserveReportRuntimeAsBackup(HttpServletRequest request) { HttpSession session = request.getSession(); ArrayList repAl = null; @@ -188,6 +195,13 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { return false; } + private boolean isReportActionKey(String actionKey) + { + return REPORT_DOWNLOAD_PAGE.equals(actionKey) || REPORT_DOWNLOAD.equals(actionKey) || + REPORT_DOWNLOAD_PDF.equals(actionKey) || REPORT_DOWNLOAD_EXCEL2007.equals(actionKey) || + REPORT_CSV_DOWNLOAD.equals(actionKey) || REPORT_TEXT_DOWNLOAD.equals(actionKey); + } + public String reportRun(HttpServletRequest request, String nextPage) { String action = nvl(request.getParameter(AppConstants.RI_ACTION), request.getParameter("action")); ReportRuntime rr = null; @@ -224,18 +238,18 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { parentFlag = 1; } - if (pdfAttachmentKey.length()<=0) { - if(actionKey.equals("report.download.page") || actionKey.equals("report.download") || actionKey.equals("report.download.pdf") || actionKey.equals("report.download.excel2007") || actionKey.equals("report.csv.download") || actionKey.equals("report.text.download")) { - if(parentFlag == 1) rr = (ReportRuntime) request.getSession().getAttribute(parent+"_rr"); + if((pdfAttachmentKey.length()<=0) && isReportActionKey(actionKey)) { + if(parentFlag == 1) + rr = (ReportRuntime) request.getSession().getAttribute(parent+"_rr"); if(rr==null) - rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME); //changing session to request + rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME); //changing session to request if(!(rr!=null && fromDashboard)) { userId = AppUtils.getUserID(request); boolean isFromReportLog = AppUtils.getRequestFlag(request, "fromReportLog"); int downloadLimit = 0; if(rr!=null) downloadLimit = (rr.getMaxRowsInExcelDownload()>0)?rr.getMaxRowsInExcelDownload():Globals.getDownloadLimit(); - if(actionKey.equals("report.csv.download")) + if(REPORT_CSV_DOWNLOAD.equals(actionKey)) downloadLimit = Globals.getCSVDownloadLimit(); if(rr!=null && rr.getReportType().equals(AppConstants.RT_LINEAR)) { @@ -247,25 +261,25 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } if(!isFromReportLog) { if(pdfAttachmentKey!=null && pdfAttachmentKey.length()>0) { - if(actionKey.equals("report.download")) { + if(REPORT_DOWNLOAD.equals(actionKey)) { rr.logReportExecutionTime(userId, "",AppConstants.RLA_SCHEDULED_DOWNLOAD_EXCEL, formFields); - } else if (actionKey.equals("report.download.pdf")) { + } else if (REPORT_DOWNLOAD_PDF.equals(actionKey)) { rr.logReportExecutionTime(userId, "",AppConstants.RLA_SCHEDULED_DOWNLOAD_PDF, formFields); - } else if (actionKey.equals("report.download.excel2007")) { + } else if (REPORT_DOWNLOAD_EXCEL2007.equals(actionKey)) { rr.logReportExecutionTime(userId, "",AppConstants.RLA_SCHEDULED_DOWNLOAD_EXCELX, formFields); } } else { - if(actionKey.equals("report.download") ) { + if(REPORT_DOWNLOAD.equals(actionKey) ) { rr.logReportExecutionTime(userId, "",AppConstants.RLA_DOWNLOAD_EXCEL, formFields); - } else if (actionKey.equals("report.download.pdf")) { + } else if (REPORT_DOWNLOAD_PDF.equals(actionKey)) { rr.logReportExecutionTime(userId, "",AppConstants.RLA_DOWNLOAD_PDF, formFields); - } else if (actionKey.equals("report.csv.download")) { + } else if (REPORT_CSV_DOWNLOAD.equals(actionKey)) { rr.logReportExecutionTime(userId, "",AppConstants.RLA_DOWNLOAD_CSV, formFields); - } else if (actionKey.equals("report.text.download")) { + } else if (REPORT_TEXT_DOWNLOAD.equals(actionKey)) { rr.logReportExecutionTime(userId, "",AppConstants.RLA_DOWNLOAD_TEXT, formFields); - } else if (actionKey.equals("report.download.page")) { + } else if (REPORT_DOWNLOAD_PAGE.equals(actionKey)) { rr.logReportExecutionTime(userId, "",AppConstants.RLA_DOWNLOAD_PAGE_EXCEL, formFields); - } else if (actionKey.equals("report.download.excel2007")) { + } else if (REPORT_DOWNLOAD_EXCEL2007.equals(actionKey)) { rr.logReportExecutionTime(userId, "",AppConstants.RLA_DOWNLOAD_EXCELX, formFields); } } @@ -273,43 +287,29 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { return nextPage; } - } + }// pdfAttachmentKey String reportID = AppUtils.getRequestValue(request, AppConstants.RI_REPORT_ID); rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME); //changing session to request String reportIDFromSession = (rr!=null)?rr.getReportID():""; logger.debug(EELFLoggerDelegate.debugLogger, ("in Action Handler ********** " + reportID + " " + reportIDFromSession + " "+ actionKey)); -// ReportRuntime rr = (ReportRuntime) request.getAttribute(AppConstants.SI_REPORT_RUNTIME); + logger.debug(EELFLoggerDelegate.debugLogger, ("^^^^^^^^^^^^^^report ID from session " + ((rr!=null)?rr.getReportID():"no report id in session"))); - // if(rr!=null && !(rr.getReportID().equals(reportID))) { -// rr = null; -// request.getSession().setAttribute(AppConstants.SI_REPORT_RUNTIME, null); -// } + ReportHandler rh1 = new ReportHandler(); ReportRuntime rr1 = null; - - //debugLogger.debug("Report ID B4 rr1 in ActionHandler " - // + ( request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)!=null?((ReportRuntime)request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).getReportID():"Not in session")); - - //try { boolean isGoBackAction = AppUtils.getRequestFlag(request, AppConstants.RI_GO_BACK); if (AppUtils.getRequestFlag(request, AppConstants.RI_SHOW_BACK_BTN) && !isGoBackAction) { - // debugLogger.debug("Preserving report"); if(!reportID.equals(reportIDFromSession)) preserveReportRuntimeAsBackup(request); } if(reportID !=null) rr1 = rh1.loadReportRuntime(request, reportID, true, 1); - //} catch(Exception e) { - - // } -// debugLogger.debug("Report ID After rr1 in ActionHandler " -// + ( request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)!=null?((ReportRuntime)request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).getReportID():"Not in session")); if(rr1!=null && rr1.getReportType().equals(AppConstants.RT_DASHBOARD)) { int DASH=7; int requestFlag = DASH; @@ -319,12 +319,9 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { //rr = null; // get dashboard HTML from report runtime. getListOfReportsFromDashBoardHTML String strHTML = rr1.getDashboardLayoutHTML(); - - //System.out.println("StrHTML " + strHTML); - // call getListOfReportsFromDashBoardHTML returns HashMap - + TreeMap treeMap = getListOfReportsFromDashBoardHTML(strHTML); - //System.out.println("Size " + hashMap.size()); + Set set = treeMap.entrySet(); String value = ""; @@ -337,7 +334,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { userId = null; userId = AppUtils.getUserID(request); int pageNo = -1; - //int downloadLimit = (rr1.getMaxRowsInExcelDownload()>0)?rr1.getMaxRowsInExcelDownload():Globals.getDownloadLimit(); int downloadLimit = 0; int rep_idx = 0; int widthFlag = 0; @@ -354,8 +350,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { for(Iterator iter = set.iterator(); iter.hasNext(); ) { record++; Map.Entry entry = (Entry) iter.next(); - //System.out.println("Key "+ entry.getKey()); - //System.out.println("Value "+ entry.getValue()); reportIDFromMap = entry.getValue().toString().substring(1); // The below line is used to optimize, so that if there is already same report id it wouldn't go through the whole process similiarReportRuntime = getSimiliarReportRuntime(reportsRuntimeMap, reportIDFromMap); @@ -403,11 +397,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { rrDashboardReports.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_EXECUTION_TIME, formFields); } - /*reportsRuntimeMap.put(new Integer(entry.getKey().toString()), rrDashboardReports); - reportDataMap.put(new Integer(entry.getKey().toString()), rd); - reportChartDataMap.put(new Integer(entry.getKey().toString()), ds); - reportDisplayTypeMap.put(new Integer(entry.getKey().toString()), entry.getValue().toString().substring(0,1));*/ - reportsRuntimeMap.put(new Integer(entry.getKey().toString())+"_"+rrDashboardReports.getReportID(), rrDashboardReports); reportDisplayTypeMap.put(new Integer(entry.getKey().toString())+"_"+rrDashboardReports.getReportID(), entry.getValue().toString().substring(0,1)); if(buildReportdata) { @@ -416,21 +405,16 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } } - - /*if(widthFlag ==1) request.getSession().setAttribute("extendedWidth", "Y"); - else request.getSession().removeAttribute("extendedWidth"); - if(heightFlag ==1) request.getSession().setAttribute("extendedHeight", "Y"); - else request.getSession().removeAttribute("extendedHeight"); - */ + request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP, new TreeMap(reportsRuntimeMap)); request.getSession().setAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP, new TreeMap(reportDisplayTypeMap)); if(buildReportdata) { request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP, new TreeMap(reportDataMap)); request.getSession().setAttribute(AppConstants.SI_DASHBOARD_CHARTDATA_MAP, new TreeMap(reportChartDataMap)); } -// debugLogger.debug("I am inside this if " + rr1.getReportType() + " "+rr1.getReportID()); + request.getSession().setAttribute(AppConstants.SI_REPORT_RUNTIME, rr1); //changing session to request - //request.setAttribute(AppConstants.SI_REPORT_RUNTIME, rr1); + if((String) request.getSession().getAttribute(AppConstants.SI_DASHBOARD_REP_ID)!= null || rr1.getReportType().equals(AppConstants.RT_DASHBOARD)) { request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME, rr1); } @@ -704,16 +688,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { String sql_whole = rr.getReportSQL(); request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sql_whole); } - //} - //request.setAttribute(AppConstants.RI_REPORT_DATA_WHOLE, rd_whole); - // if(rr.getReportDataSize() > Globals.getFlatFileLowerLimit() && rr.getReportDataSize() <= Globals.getFlatFileUpperLimit() ) { - // rr.setFlatFileName(rh.saveFlatFile(request, rd, rr - // .getParamNameValuePairs(), rr.getReportName(), rr.getReportDescr())); - // } - //if(actionKey!=null && actionKey.equals("report.download")) { -// rr.setExcelPageFileName(rh.saveAsExcelFile(request, rd, rr -// .getParamNameValuePairs(), rr.getReportName(), rr.getReportDescr())); - //} if (!rr.getReportType().equals(AppConstants.RT_HIVE)) { long currentChartTime = System.currentTimeMillis(); DataSet chartDS = rr.loadChartData(userId,request); @@ -723,11 +697,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { request.getSession().removeAttribute(AppConstants.RI_CHART_DATA); logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] ------->Time Taken for the loading chart data --- " + (System.currentTimeMillis() - currentChartTime))); } - -/* if((String) request.getSession().getAttribute(AppConstants.SI_DASHBOARD_REP_ID)!=null) { - request.getSession().setAttribute("FirstDashReport", rr); - } -*/ } request.getSession().setAttribute(AppConstants.SI_REPORT_RUNTIME, rr); //changing session to request request.getSession().setAttribute(AppConstants.RI_REPORT_DATA, rd); @@ -740,19 +709,19 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { boolean isFromReportLog = AppUtils.getRequestFlag(request, "fromReportLog"); if(!isFromReportLog) { if(pdfAttachmentKey!=null && pdfAttachmentKey.length()>0) { - if(actionKey.equals("report.download")) { + if(actionKey.equals(REPORT_DOWNLOAD)) { rr.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_SCHEDULED_DOWNLOAD_EXCEL, formFields); - } else if (actionKey.equals("report.download.pdf")) { + } else if (actionKey.equals(REPORT_DOWNLOAD_PDF)) { rr.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_SCHEDULED_DOWNLOAD_PDF, formFields); } } else { - if(actionKey.equals("report.download") ) { + if(actionKey.equals(REPORT_DOWNLOAD) ) { rr.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_DOWNLOAD_EXCEL, formFields); - } else if (actionKey.equals("report.download.pdf")) { + } else if (actionKey.equals(REPORT_DOWNLOAD_PDF)) { rr.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_DOWNLOAD_PDF, formFields); - } else if (actionKey.equals("report.csv.download")) { + } else if (actionKey.equals(REPORT_CSV_DOWNLOAD)) { rr.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_DOWNLOAD_CSV, formFields); - } else if (actionKey.equals("report.text.download")) { + } else if (actionKey.equals(REPORT_TEXT_DOWNLOAD)) { rr.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_DOWNLOAD_TEXT, formFields); } else { 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 1a31e604..30ec7b15 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 @@ -63,6 +63,9 @@ import com.fasterxml.jackson.databind.SerializationFeature; public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ErrorHandler.class); + + private static final String EXCEPTION_FATAL_ERROR = "[EXCEPTION ENCOUNTERED IN RAPTOR] Fatal error ["; + private static final String C_ERROR_SQL = "c_error_sql"; public ErrorHandler() { } @@ -105,11 +108,11 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { return sessionLogStrBuf.toString(); } public String processFatalError(HttpServletRequest request, RaptorException e) { - logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage())+" "+ getSessionLog(request) + e.getMessage()),AlarmSeverityEnum.MAJOR); + logger.error(EELFLoggerDelegate.debugLogger, (EXCEPTION_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); + request.setAttribute(C_ERROR_SQL, errorSQL); } // if AppUtils.processErrorNotification(request, e); @@ -118,11 +121,11 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { } // processFatalError public String processFatalErrorJSON(HttpServletRequest request, RaptorException e) { - logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage())+" "+ getSessionLog(request) + e.getMessage()),AlarmSeverityEnum.MAJOR); + logger.error(EELFLoggerDelegate.debugLogger, (EXCEPTION_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); + request.setAttribute(C_ERROR_SQL, errorSQL); } // if request.setAttribute(AppConstants.RI_EXCEPTION, e); @@ -136,7 +139,7 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { 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); + logger.error(EELFLoggerDelegate.debugLogger, (EXCEPTION_FATAL_ERROR + ex.getClass().getName() + "]: " + nvl(ex.getMessage())+" "+ getSessionLog(request) + ex.getMessage()),AlarmSeverityEnum.MAJOR); ex.printStackTrace(); } @@ -150,11 +153,11 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { return result.toString(); } public String processFatalErrorWMenu(HttpServletRequest request, RaptorException e) { - logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage())+" "+ getSessionLog(request) + e.getMessage()),AlarmSeverityEnum.MAJOR); + logger.error(EELFLoggerDelegate.debugLogger, (EXCEPTION_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); + request.setAttribute(C_ERROR_SQL, errorSQL); } // if AppUtils.processErrorNotification(request, e); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/WizardProcessor.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/WizardProcessor.java index f0829d29..bd8d778e 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/WizardProcessor.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/WizardProcessor.java @@ -376,12 +376,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setDataContainerWidth(dataContainerWidth); rdef.setAllowSchedule(isAllowSchedule?"Y":"N"); - - reportUpdated = true; - - - if (rdef.getWizardSequence() instanceof WizardSequence) - rdef.generateWizardSequence(request); + rdef.generateWizardSequence(request); } else { @@ -412,22 +407,17 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { else rdef.setEmptyMessage(""); String formHelp = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "formHelp")); - //String rDashboardType = nvl(AppUtils.getRequestValue(request, "showDashboardOptions"), "N"); - //rdef.setDashboardType(rDashboardType.equals("Y")); - int excelDownloadSize = 500; - try { - excelDownloadSize = Integer.parseInt(AppUtils.getRequestValue(request, "excelDownloadSize")); - } catch (NumberFormatException ex) {} + if(AppUtils.getRequestNvlValue(request, "excelDownloadSize").length()>0) rdef.setMaxRowsInExcelDownload(Integer.parseInt(AppUtils.getRequestValue(request, "excelDownloadSize"))); if(AppUtils.getRequestNvlValue(request, "reportInNewWindow").length()>0) - reportsInNewWindow = AppUtils.getRequestNvlValue(request,"reportInNewWindow").equals("Y"); + reportsInNewWindow = "Y".equals(AppUtils.getRequestNvlValue(request,"reportInNewWindow")); if(AppUtils.getRequestNvlValue(request, "hideFormFieldsAfterRun").length()>0) - hideFormFieldAfterRun = AppUtils.getRequestNvlValue(request,"hideFormFieldsAfterRun").equals("Y"); + hideFormFieldAfterRun = "Y".equals(AppUtils.getRequestNvlValue(request,"hideFormFieldsAfterRun")); if(AppUtils.getRequestNvlValue(request, "displayFolderTree").length()>0) - rdef.setDisplayFolderTree(AppUtils.getRequestNvlValue(request,"displayFolderTree").equals("Y")); + rdef.setDisplayFolderTree("Y".equals(AppUtils.getRequestNvlValue(request,"displayFolderTree"))); else rdef.setDisplayFolderTree(false); String dataSource = AppUtils.getRequestNvlValue(request, "dataSource"); @@ -457,11 +447,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { if (menuIDs != null) for (int i = 0; i < menuIDs.length; i++) menuID += (menuID.length() == 0 ? "" : "|") + menuIDs[i]; - /* else - menuID = "";*/ -// boolean additionalFieldsShown = AppUtils.getRequestNvlValue(request, -// "additionalFieldsShown").equals("Y"); boolean rRCSDisabled = AppUtils.getRequestNvlValue(request, "runtimeColSortDisabled").equals("Y"); String reportDefType = AppUtils.getRequestNvlValue(request, "reportDefType"); String dataContainerHeight = nvl(AppUtils.getRequestValue(request, "heightContainer"), "auto"); @@ -474,10 +460,6 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { + nvl(AppUtils.getRequestValue(request, "hideMap"), "N") + nvl(AppUtils.getRequestValue(request, "hideExcelIcons"), "N") + nvl(AppUtils.getRequestValue(request, "hidePDFIcons"), "N"); -/* StringBuffer dashboardOptions = new StringBuffer(""); - dashboardOptions.append((nvl(AppUtils.getRequestValue(request, "hide"),"chart").equals("chart"))?"Y":"N"); - dashboardOptions.append((nvl(AppUtils.getRequestValue(request, "hide"),"").equals("data"))?"Y":"N"); - dashboardOptions.append((nvl(AppUtils.getRequestValue(request, "hideBtns"),"").equals("Y"))?"Y":"N");*/ String numFormCols = nvl(AppUtils.getRequestValue(request, "numFormCols"), "1"); String reportTitle = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "reportTitle")); @@ -492,64 +474,6 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { } -/* reportUpdated = (!(reportName.equals(nvl(rdef.getReportName())))) - && (!(reportDescr.equals(nvl(rdef.getReportDescr())))) - && (!(formHelp.equals(nvl(rdef.getFormHelpText())))) - && (!(reportType.equals(nvl(rdef.getReportType())))) - && (pageSize != rdef.getPageSize()) && - // rPublic.equals(rdef.isPublic()?"Y":"N")&& - (!(menuID.equals(nvl(rdef.getMenuID())))) - && (!(rApproved.equals(rdef.isMenuApproved()))) && (additionalFieldsShown ? ((!(rRCSDisabled - .equals(rdef.isRuntimeColSortDisabled()))) - && (!(displayOptions.equals(nvl(rdef.getDisplayOptions())))) - && (!(dashboardOptions.equals(nvl(rdef.getDashboardOptions())))) - && (!(numFormCols.equals(nvl(rdef.getNumFormCols())))) - && (!(reportTitle.equals(nvl(rdef.getReportTitle())))) - && (!(reportSubTitle.equals(nvl(rdef.getReportSubTitle())))) - && (!(reportHeader.equals(nvl(rdef.getReportHeader())))) && (!(reportFooter - .equals(nvl(rdef.getReportFooter()))))&& (reportsInNewWindow != rdef.isReportInNewWindow())):true); -*/ -/* reportUpdated = rRCSDisabled ==(rdef.isRuntimeColSortDisabled() - && displayOptions.equals(nvl(rdef.getDisplayOptions())) - //&& dashboardOptions.equals(nvl(rdef.getDashboardOptions())) - && numFormCols.equals(nvl(rdef.getNumFormCols())) - && reportTitle.equals(nvl(rdef.getReportTitle())) - && reportSubTitle.equals(nvl(rdef.getReportSubTitle())) - && reportHeader.equals(nvl(rdef.getReportHeader())) - && reportsInNewWindow == rdef.isReportInNewWindow() - && reportFooter.equals(nvl(rdef.getReportFooter()))) - ;*/ - - - /*reportUpdated = (!(reportName.equals(nvl(rdef.getReportName())) - && reportDescr.equals(nvl(rdef.getReportDescr())) - && formHelp.equals(nvl(rdef.getFormHelpText())) - && reportType.equals(nvl(rdef.getReportType())) - && (pageSize == rdef.getPageSize()) - && excelDownloadSize == rdef.getMaxRowsInExcelDownload() - && reportsInNewWindow == rdef.isReportInNewWindow() - && displayOptions.equals(rdef.getDisplayOptions()) - && dataContainerHeight.equals(rdef.getDataContainerHeight()) - && dataContainerWidth.equals(rdef.getDataContainerWidth()) - && (isAllowSchedule ==(rdef.isAllowSchedule())) - // rPublic.equals(rdef.isPublic()?"Y":"N")&& - && menuID.equals(nvl(rdef.getMenuID())) - && rApproved.equals(rdef.isMenuApproved() ? "Y" : "N") && (rRCSDisabled - == ((rdef.isRuntimeColSortDisabled()) - && displayOptions.equals(nvl(rdef.getDisplayOptions())) - //&& dashboardOptions.equals(nvl(rdef.getDashboardOptions())) - && numFormCols.equals(nvl(rdef.getNumFormCols())) - && reportTitle.equals(nvl(rdef.getReportTitle())) - && reportSubTitle.equals(nvl(rdef.getReportSubTitle())) - && isOneTimeScheduleAllowed.equals(nvl(rdef.getIsOneTimeScheduleAllowed())) - && isHourlyScheduleAllowed.equals(nvl(rdef.getIsHourlyScheduleAllowed())) - && isDailyScheduleAllowed.equals(nvl(rdef.getIsDailyScheduleAllowed())) - && isDailyMFScheduleAllowed.equals(nvl(rdef.getIsDailyMFScheduleAllowed())) - && isWeeklyScheduleAllowed.equals(nvl(rdef.getIsWeeklyScheduleAllowed())) - && isMonthlyScheduleAllowed.equals(nvl(rdef.getIsMonthlyScheduleAllowed())) - && reportHeader.equals(nvl(rdef.getReportHeader())) && reportFooter - .equals(nvl(rdef.getReportFooter())))) - )); */ rdef.setReportName(reportName); rdef.setReportDescr(reportDescr); rdef.setFormHelpText(formHelp); @@ -564,14 +488,11 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setMultiGroupColumn(isColumnGroup?"Y":"N"); rdef.setTopDown(isTopDown?"Y":"N"); rdef.setSizedByContent(isSizedByContent?"Y":"N"); - // rdef.setPublic(rPublic.equals("Y")); rdef.setMenuID(menuID); rdef.setMenuApproved(rApproved.equals("Y")); if (reportDefType.length() > 0) rdef.setReportDefType(reportDefType); -/* if(rdef.isDashboardType()) { - rdef.setDashboardOptions(dashboardOptions.toString()); - }*/ + rdef.setHideFormFieldAfterRun(hideFormFieldAfterRun); rdef.setReportInNewWindow(reportsInNewWindow); rdef.setRuntimeColSortDisabled(rRCSDisabled); @@ -594,18 +515,6 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.generateWizardSequence(request); - /* - * if(formHelp.length()>255) formHelp = formHelp.substring(0, 255); - */ - - - // String rPublic = nvl(AppUtils.getRequestValue(request, "public"), - // "N"); - // String menuID = AppUtils.getRequestNvlValue(request, "menuID"); - -// boolean dashboardOptionsShown = AppUtils.getRequestNvlValue(request, -// "dashboardOptionsShown").equals("Y"); - reportUpdated = true; if (rdef.getReportID().equals("-1")) diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java index 0e36dd0f..29cbca18 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java @@ -80,10 +80,10 @@ public class ChartJSONHelper { private ReportRuntime reportRuntime; private String chartType; - public static final long HOUR = 3600*1000; - public static final long DAY = 3600*1000*24; - public static final long MONTH = 3600*1000*24*31; - public static final long YEAR = 3600*1000*24*365; + public static final long HOUR = 3600L * 1000L; + public static final long DAY = 3600L * 1000L * 24L; + public static final long MONTH = 3600L * 1000L * 24L * 31L; + public static final long YEAR = 3600L * 1000L * 24L * 365L; public ChartJSONHelper() { @@ -108,138 +108,191 @@ public class ChartJSONHelper { this.reportRuntime = rr; } - public String generateJSON(String reportID, HttpServletRequest request, boolean showData) throws RaptorException { - //From annotations chart - clearReportRuntimeBackup(request); - - //HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest(); - final Long user_id = new Long((long) UserUtils.getUserId(request)); - //String action = request.getParameter(AppConstants.RI_ACTION); - //String reportID = AppUtils.getRequestValue(request, AppConstants.RI_REPORT_ID); + public String generateJSON(String reportID, HttpServletRequest request, boolean showData) + throws RaptorException { + // From annotations chart + clearReportRuntimeBackup(request); - ReportHandler rh = new ReportHandler(); - //ReportData reportData = null; - HashMap<String, String> chartOptionsMap = new HashMap<String, String>(); - try { - if(reportID !=null) { - reportRuntime = rh.loadReportRuntime(request, reportID, true, 1); - setChartType(reportRuntime.getChartType()); - //reportData = reportRuntime.loadReportData(0, user_id.toString(), 10000,request, false); - } - - - - String rotateLabelsStr = ""; - rotateLabelsStr = AppUtils.nvl(reportRuntime.getLegendLabelAngle()); - if(rotateLabelsStr.toLowerCase().equals("standard")) { - rotateLabelsStr = "0"; - } else if (rotateLabelsStr.toLowerCase().equals("up45")) { - rotateLabelsStr = "45"; - } else if (rotateLabelsStr.toLowerCase().equals("down45")) { - rotateLabelsStr = "-45"; - } else if (rotateLabelsStr.toLowerCase().equals("up90")) { - rotateLabelsStr = "90"; - } else if (rotateLabelsStr.toLowerCase().equals("down90")) { - rotateLabelsStr = "-90"; - } else - rotateLabelsStr = "0"; - - String width = (AppUtils.getRequestNvlValue(request, "width").length()>0?AppUtils.getRequestNvlValue(request, "width"):(AppUtils.nvl(reportRuntime.getChartWidth()).length()>0?reportRuntime.getChartWidth():"700")); - String height = (AppUtils.getRequestNvlValue(request, "height").length()>0?AppUtils.getRequestNvlValue(request, "height"):(AppUtils.nvl(reportRuntime.getChartHeight()).length()>0?reportRuntime.getChartHeight():"300")); - String animationStr = (AppUtils.getRequestNvlValue(request, "animation").length()>0?AppUtils.getRequestNvlValue(request, "animation"):new Boolean(reportRuntime.isAnimateAnimatedChart()).toString()); - - String rotateLabels = (AppUtils.getRequestNvlValue(request, "rotateLabels").length()>0?AppUtils.getRequestNvlValue(request, "rotateLabels"):(rotateLabelsStr.length()>0?rotateLabelsStr:"0")); - String staggerLabelsStr = (AppUtils.getRequestNvlValue(request, "staggerLabels").length()>0?AppUtils.getRequestNvlValue(request, "staggerLabels"):"false"); - String showMaxMinStr = (AppUtils.getRequestNvlValue(request, "showMaxMin").length()>0?AppUtils.getRequestNvlValue(request, "showMaxMin"):"false"); - String showControlsStr = (AppUtils.getRequestNvlValue(request, "showControls").length()>0?AppUtils.getRequestNvlValue(request, "showControls"):new Boolean(reportRuntime.displayBarControls()).toString()); - String showLegendStr = (AppUtils.getRequestNvlValue(request, "showLegend").length()>0?AppUtils.getRequestNvlValue(request, "showLegend"):new Boolean(!new Boolean(reportRuntime.hideChartLegend())).toString()); - String topMarginStr = AppUtils.getRequestNvlValue(request, "topMargin"); - String topMargin = (AppUtils.nvl(topMarginStr).length()<=0)?(reportRuntime.getTopMargin()!=null?reportRuntime.getTopMargin().toString():"30"):topMarginStr; - String bottomMarginStr = AppUtils.getRequestNvlValue(request, "bottomMargin"); - String bottomMargin = (AppUtils.nvl(bottomMarginStr).length()<=0)?(reportRuntime.getBottomMargin()!=null?reportRuntime.getBottomMargin().toString():"50"):bottomMarginStr; - String leftMarginStr = AppUtils.getRequestNvlValue(request, "leftMargin"); - String leftMargin = (AppUtils.nvl(leftMarginStr).length()<=0)?(reportRuntime.getLeftMargin()!=null?reportRuntime.getLeftMargin().toString():"100"):leftMarginStr; - String rightMarginStr = AppUtils.getRequestNvlValue(request, "rightMargin"); - String rightMargin = (AppUtils.nvl(rightMarginStr).length()<=0)?(reportRuntime.getRightMargin()!=null?reportRuntime.getRightMargin().toString():"160"):rightMarginStr; - String showTitleStr = (AppUtils.getRequestNvlValue(request, "showTitle").length()>0?AppUtils.getRequestNvlValue(request, "showTitle"):new Boolean(reportRuntime.displayChartTitle()).toString()); - String subType = AppUtils.getRequestNvlValue(request, "subType").length()>0?AppUtils.getRequestNvlValue(request, "subType"):(AppUtils.nvl(reportRuntime.getTimeSeriesRender()).equals("area")?reportRuntime.getTimeSeriesRender():""); - String stackedStr = AppUtils.getRequestNvlValue(request, "stacked").length()>0?AppUtils.getRequestNvlValue(request, "stacked"):new Boolean(reportRuntime.isChartStacked()).toString(); - String horizontalBar = AppUtils.getRequestNvlValue(request, "horizontalBar").length()>0?AppUtils.getRequestNvlValue(request, "horizontalBar"):new Boolean(reportRuntime.isHorizontalOrientation()).toString(); - String barRealTimeAxis = AppUtils.getRequestNvlValue(request, "barRealTimeAxis"); - String barReduceXAxisLabels = AppUtils.getRequestNvlValue(request, "barReduceXAxisLabels").length()>0?AppUtils.getRequestNvlValue(request, "barReduceXAxisLabels"):new Boolean(reportRuntime.isLessXaxisTickers()).toString();; - String timeAxis = AppUtils.getRequestNvlValue(request, "timeAxis").length()>0?AppUtils.getRequestNvlValue(request, "timeAxis"):new Boolean(reportRuntime.isTimeAxis()).toString(); - String logScale = AppUtils.getRequestNvlValue(request, "logScale").length()>0?AppUtils.getRequestNvlValue(request, "logScale"):new Boolean(reportRuntime.isLogScale()).toString(); - String precision = AppUtils.getRequestNvlValue(request, "precision").length()>0?AppUtils.getRequestNvlValue(request, "precision"):"2"; - + ReportHandler rh = new ReportHandler(); - chartOptionsMap.put("width", width); - chartOptionsMap.put("height", height); - chartOptionsMap.put("animation", animationStr); - chartOptionsMap.put("rotateLabels", rotateLabels); - chartOptionsMap.put("staggerLabels", staggerLabelsStr); - chartOptionsMap.put("showMaxMin", showMaxMinStr); - chartOptionsMap.put("showControls", showControlsStr); - chartOptionsMap.put("showLegend", showLegendStr); - chartOptionsMap.put("topMargin", topMargin); - chartOptionsMap.put("bottomMargin", bottomMargin); - chartOptionsMap.put("leftMargin", leftMargin); - chartOptionsMap.put("rightMargin", rightMargin); - chartOptionsMap.put("showTitle", showTitleStr); - chartOptionsMap.put("subType", subType); - chartOptionsMap.put("stacked", stackedStr); - chartOptionsMap.put("horizontalBar", horizontalBar); - chartOptionsMap.put("timeAxis", timeAxis); - chartOptionsMap.put("barRealTimeAxis", barRealTimeAxis); - chartOptionsMap.put("barReduceXAxisLabels", barReduceXAxisLabels); - - chartOptionsMap.put("logScale", logScale); - chartOptionsMap.put("precision", precision); - - - } catch (RaptorException ex) { - ex.printStackTrace(); - } - return generateJSON(reportRuntime, chartOptionsMap, request, showData); - } + HashMap<String, String> chartOptionsMap = new HashMap<>(); + + try { + if (reportID != null) { + reportRuntime = rh.loadReportRuntime(request, reportID, true, 1); + setChartType(reportRuntime.getChartType()); + } + + String rotateLabelsStr = ""; + rotateLabelsStr = AppUtils.nvl(reportRuntime.getLegendLabelAngle()); + if (rotateLabelsStr.equalsIgnoreCase("standard")) { + rotateLabelsStr = "0"; + } else if (rotateLabelsStr.equalsIgnoreCase("up45")) { + rotateLabelsStr = "45"; + } else if (rotateLabelsStr.equalsIgnoreCase("down45")) { + rotateLabelsStr = "-45"; + } else if (rotateLabelsStr.equalsIgnoreCase("up90")) { + rotateLabelsStr = "90"; + } else if (rotateLabelsStr.equalsIgnoreCase("down90")) { + rotateLabelsStr = "-90"; + } else + rotateLabelsStr = "0"; + + String width = (AppUtils.getRequestNvlValue(request, "width").length() > 0 + ? AppUtils.getRequestNvlValue(request, "width") + : (AppUtils.nvl(reportRuntime.getChartWidth()).length() > 0 + ? reportRuntime.getChartWidth() + : "700")); + String height = (AppUtils.getRequestNvlValue(request, "height").length() > 0 + ? AppUtils.getRequestNvlValue(request, "height") + : (AppUtils.nvl(reportRuntime.getChartHeight()).length() > 0 + ? reportRuntime.getChartHeight() + : "300")); + String animationStr = (AppUtils.getRequestNvlValue(request, "animation").length() > 0 + ? AppUtils.getRequestNvlValue(request, "animation") + : new Boolean(reportRuntime.isAnimateAnimatedChart()).toString()); + + String rotateLabels = (AppUtils.getRequestNvlValue(request, "rotateLabels").length() > 0 + ? AppUtils.getRequestNvlValue(request, "rotateLabels") + : (rotateLabelsStr.length() > 0 ? rotateLabelsStr : "0")); + String staggerLabelsStr = + (AppUtils.getRequestNvlValue(request, "staggerLabels").length() > 0 + ? AppUtils.getRequestNvlValue(request, "staggerLabels") + : "false"); + String showMaxMinStr = (AppUtils.getRequestNvlValue(request, "showMaxMin").length() > 0 + ? AppUtils.getRequestNvlValue(request, "showMaxMin") + : "false"); + String showControlsStr = + (AppUtils.getRequestNvlValue(request, "showControls").length() > 0 + ? AppUtils.getRequestNvlValue(request, "showControls") + : new Boolean(reportRuntime.displayBarControls()).toString()); + String showLegendStr = (AppUtils.getRequestNvlValue(request, "showLegend").length() > 0 + ? AppUtils.getRequestNvlValue(request, "showLegend") + : new Boolean(!new Boolean(reportRuntime.hideChartLegend())).toString()); + String topMarginStr = AppUtils.getRequestNvlValue(request, "topMargin"); + String topMargin = (AppUtils.nvl(topMarginStr).length() <= 0) + ? (reportRuntime.getTopMargin() != null + ? reportRuntime.getTopMargin().toString() + : "30") + : topMarginStr; + String bottomMarginStr = AppUtils.getRequestNvlValue(request, "bottomMargin"); + String bottomMargin = (AppUtils.nvl(bottomMarginStr).length() <= 0) + ? (reportRuntime.getBottomMargin() != null + ? reportRuntime.getBottomMargin().toString() + : "50") + : bottomMarginStr; + String leftMarginStr = AppUtils.getRequestNvlValue(request, "leftMargin"); + String leftMargin = (AppUtils.nvl(leftMarginStr).length() <= 0) + ? (reportRuntime.getLeftMargin() != null + ? reportRuntime.getLeftMargin().toString() + : "100") + : leftMarginStr; + String rightMarginStr = AppUtils.getRequestNvlValue(request, "rightMargin"); + String rightMargin = (AppUtils.nvl(rightMarginStr).length() <= 0) + ? (reportRuntime.getRightMargin() != null + ? reportRuntime.getRightMargin().toString() + : "160") + : rightMarginStr; + String showTitleStr = (AppUtils.getRequestNvlValue(request, "showTitle").length() > 0 + ? AppUtils.getRequestNvlValue(request, "showTitle") + : new Boolean(reportRuntime.displayChartTitle()).toString()); + String subType = AppUtils.getRequestNvlValue(request, "subType").length() > 0 + ? AppUtils.getRequestNvlValue(request, "subType") + : (AppUtils.nvl(reportRuntime.getTimeSeriesRender()).equals("area") + ? reportRuntime.getTimeSeriesRender() + : ""); + String stackedStr = AppUtils.getRequestNvlValue(request, "stacked").length() > 0 + ? AppUtils.getRequestNvlValue(request, "stacked") + : new Boolean(reportRuntime.isChartStacked()).toString(); + String horizontalBar = + AppUtils.getRequestNvlValue(request, "horizontalBar").length() > 0 + ? AppUtils.getRequestNvlValue(request, "horizontalBar") + : new Boolean(reportRuntime.isHorizontalOrientation()).toString(); + String barRealTimeAxis = AppUtils.getRequestNvlValue(request, "barRealTimeAxis"); + String barReduceXAxisLabels = + AppUtils.getRequestNvlValue(request, "barReduceXAxisLabels").length() > 0 + ? AppUtils.getRequestNvlValue(request, "barReduceXAxisLabels") + : new Boolean(reportRuntime.isLessXaxisTickers()).toString();; + String timeAxis = AppUtils.getRequestNvlValue(request, "timeAxis").length() > 0 + ? AppUtils.getRequestNvlValue(request, "timeAxis") + : new Boolean(reportRuntime.isTimeAxis()).toString(); + String logScale = AppUtils.getRequestNvlValue(request, "logScale").length() > 0 + ? AppUtils.getRequestNvlValue(request, "logScale") + : new Boolean(reportRuntime.isLogScale()).toString(); + String precision = AppUtils.getRequestNvlValue(request, "precision").length() > 0 + ? AppUtils.getRequestNvlValue(request, "precision") + : "2"; + + + chartOptionsMap.put("width", width); + chartOptionsMap.put("height", height); + chartOptionsMap.put("animation", animationStr); + chartOptionsMap.put("rotateLabels", rotateLabels); + chartOptionsMap.put("staggerLabels", staggerLabelsStr); + chartOptionsMap.put("showMaxMin", showMaxMinStr); + chartOptionsMap.put("showControls", showControlsStr); + chartOptionsMap.put("showLegend", showLegendStr); + chartOptionsMap.put("topMargin", topMargin); + chartOptionsMap.put("bottomMargin", bottomMargin); + chartOptionsMap.put("leftMargin", leftMargin); + chartOptionsMap.put("rightMargin", rightMargin); + chartOptionsMap.put("showTitle", showTitleStr); + chartOptionsMap.put("subType", subType); + chartOptionsMap.put("stacked", stackedStr); + chartOptionsMap.put("horizontalBar", horizontalBar); + chartOptionsMap.put("timeAxis", timeAxis); + chartOptionsMap.put("barRealTimeAxis", barRealTimeAxis); + chartOptionsMap.put("barReduceXAxisLabels", barReduceXAxisLabels); + + chartOptionsMap.put("logScale", logScale); + chartOptionsMap.put("precision", precision); + + + } catch (RaptorException ex) { + logger.error("Exception in generateJSON", ex); + } + return generateJSON(reportRuntime, chartOptionsMap, request, showData); + } public String generateJSON(ReportRuntime reportRuntime, HttpServletRequest request, boolean showData) throws RaptorException { String rotateLabelsStr = ""; rotateLabelsStr = AppUtils.nvl(reportRuntime.getLegendLabelAngle()); - if(rotateLabelsStr.toLowerCase().equals("standard")) { - rotateLabelsStr = "0"; - } else if (rotateLabelsStr.toLowerCase().equals("up45")) { - rotateLabelsStr = "45"; - } else if (rotateLabelsStr.toLowerCase().equals("down45")) { - rotateLabelsStr = "-45"; - } else if (rotateLabelsStr.toLowerCase().equals("up90")) { - rotateLabelsStr = "90"; - } else if (rotateLabelsStr.toLowerCase().equals("down90")) { - rotateLabelsStr = "-90"; - } else - rotateLabelsStr = "0"; + if (rotateLabelsStr.equalsIgnoreCase("standard")) { + rotateLabelsStr = "0"; + } else if (rotateLabelsStr.equalsIgnoreCase("up45")) { + rotateLabelsStr = "45"; + } else if (rotateLabelsStr.equalsIgnoreCase("down45")) { + rotateLabelsStr = "-45"; + } else if (rotateLabelsStr.equalsIgnoreCase("up90")) { + rotateLabelsStr = "90"; + } else if (rotateLabelsStr.equalsIgnoreCase("down90")) { + rotateLabelsStr = "-90"; + } else { + rotateLabelsStr = "0"; + } - HashMap<String,String> chartOptionsMap = new HashMap<String, String>(); + HashMap<String,String> chartOptionsMap = new HashMap<>(); chartOptionsMap.put("width", reportRuntime.getChartWidth()); chartOptionsMap.put("height", reportRuntime.getChartHeight()); - chartOptionsMap.put("animation", new Boolean(reportRuntime.isAnimateAnimatedChart()).toString()); + chartOptionsMap.put("animation", Boolean.toString(reportRuntime.isAnimateAnimatedChart())); chartOptionsMap.put("rotateLabels", rotateLabelsStr); chartOptionsMap.put("staggerLabels", "false"); chartOptionsMap.put("showMaxMin", "false"); - chartOptionsMap.put("showControls", new Boolean(reportRuntime.displayBarControls()).toString()); - chartOptionsMap.put("showLegend", new Boolean(!reportRuntime.hideChartLegend()).toString()); + chartOptionsMap.put("showControls", Boolean.toString(reportRuntime.displayBarControls())); + chartOptionsMap.put("showLegend", Boolean.toString(!reportRuntime.hideChartLegend())); chartOptionsMap.put("topMargin", reportRuntime.getTopMargin()!=null?reportRuntime.getTopMargin().toString():"30"); chartOptionsMap.put("bottomMargin", reportRuntime.getBottomMargin()!=null?reportRuntime.getBottomMargin().toString():"50"); chartOptionsMap.put("leftMargin", reportRuntime.getLeftMargin()!=null?reportRuntime.getLeftMargin().toString():"100"); chartOptionsMap.put("rightMargin", reportRuntime.getRightMargin()!=null?reportRuntime.getRightMargin().toString():"160"); - chartOptionsMap.put("showTitle", new Boolean(reportRuntime.displayChartTitle()).toString()); + chartOptionsMap.put("showTitle", Boolean.toString(reportRuntime.displayChartTitle())); chartOptionsMap.put("subType", (AppUtils.nvl(reportRuntime.getTimeSeriesRender()).equals("area")?reportRuntime.getTimeSeriesRender():"")); - chartOptionsMap.put("stacked", new Boolean(reportRuntime.isChartStacked()).toString()); - chartOptionsMap.put("horizontalBar", new Boolean(reportRuntime.isHorizontalOrientation()).toString()); - chartOptionsMap.put("timeAxis", new Boolean(reportRuntime.isTimeAxis()).toString()); - chartOptionsMap.put("barReduceXAxisLabels", new Boolean(reportRuntime.isLessXaxisTickers()).toString()); + chartOptionsMap.put("stacked", Boolean.toString(reportRuntime.isChartStacked())); + chartOptionsMap.put("horizontalBar", Boolean.toString(reportRuntime.isHorizontalOrientation())); + chartOptionsMap.put("timeAxis", Boolean.toString(reportRuntime.isTimeAxis())); + chartOptionsMap.put("barReduceXAxisLabels", Boolean.toString(reportRuntime.isLessXaxisTickers())); - chartOptionsMap.put("logScale", new Boolean(reportRuntime.isLogScale()).toString()); + chartOptionsMap.put("logScale", Boolean.toString(reportRuntime.isLogScale())); chartOptionsMap.put("precision", "2"); @@ -247,7 +300,7 @@ public class ChartJSONHelper { return generateJSON(reportRuntime, chartOptionsMap, request, showData); } - public String generateJSON(ReportRuntime reportRuntime, HashMap<String,String> chartOptionsMap, HttpServletRequest request, boolean showData) throws RaptorException { + public String generateJSON(ReportRuntime reportRuntime,Map<String, String> chartOptionsMap, HttpServletRequest request, boolean showData) throws RaptorException { //String width, String height, boolean animation, String rotateLabels, boolean staggerLabels, boolean showMaxMin, boolean showLegend, boolean showControls, String topMargin, String bottomMargin, boolean showTitle, String subType String userId = AppUtils.getUserID(request); @@ -375,97 +428,6 @@ public class ChartJSONHelper { chartColumnJSONList.add(ccJSON); } chartJSON.setChartColumnJSONList(chartColumnJSONList); - /* setting formfields show only showForm got triggered*/ - /*ArrayList<IdNameValue> formFieldValues = new ArrayList<IdNameValue>(); - ArrayList<FormFieldJSON> formFieldJSONList = new ArrayList<FormFieldJSON>(); - if(reportRuntime.getReportFormFields()!=null) { - formFieldJSONList = new ArrayList<FormFieldJSON>(reportRuntime.getReportFormFields().size()); - for (Iterator iter = reportRuntime.getReportFormFields().iterator(); iter.hasNext();) { - formFieldValues = new ArrayList<IdNameValue>(); - FormField ff = (FormField) iter.next(); - ff.setDbInfo(reportRuntime.getDbInfo()); - FormFieldJSON ffJSON = new FormFieldJSON(); - ffJSON.setFieldId(ff.getFieldName()); - ffJSON.setFieldType(ff.getFieldType()); - ffJSON.setFieldDisplayName(ff.getFieldDisplayName()); - ffJSON.setHelpText(ff.getHelpText()); - ffJSON.setValidationType(ff.getValidationType()); - //ffJSON.setTriggerOtherFormFields(ff.getDependsOn()); - IdNameList lookup = null; - lookup = ff.getLookupList(); - String selectedValue = ""; - String oldSQL = ""; - IdNameList lookupList = null; - boolean readOnly = false; - if(lookup!=null) { - if(!ff.hasPredefinedList) { - IdNameSql lu = (IdNameSql) lookup; - String SQL = lu.getSql(); - oldSQL = lu.getSql(); - reportRuntime.setTriggerFormFieldCheck( reportRuntime.getReportFormFields(), ff); - ffJSON.setTriggerOtherFormFields(ff.isTriggerOtherFormFields()); - SQL = reportRuntime.parseAndFillReq_Session_UserValues(request, SQL, userId); - SQL = reportRuntime.parseAndFillWithCurrentValues(request, SQL, ff); - String defaultSQL = lu.getDefaultSQL(); - defaultSQL = reportRuntime.parseAndFillReq_Session_UserValues(request, defaultSQL, userId); - defaultSQL = reportRuntime.parseAndFillWithCurrentValues(request, SQL, ff); - lookup = new IdNameSql(-1,SQL,defaultSQL); - - lookupList = lookup; - try { - lookup.loadUserData(0, "", ff.getDbInfo(), ff.getUserId()); - } catch (Exception e ){ e.printStackTrace(); //throw new RaptorRuntimeException(e); - } - } - lookup.trimToSize(); - - String[] requestValue = request.getParameterValues(ff.getFieldName()); - - if(lookup != null && lookup.size() > 0) { - for (lookup.resetNext(); lookup.hasNext();) { - IdNameValue value = lookup.getNext(); - readOnly = value.isReadOnly(); - if(requestValue != null && Arrays.asList(requestValue).contains(value.getId())) { - //if(value.getId().equals(requestValue)) - value.setDefaultValue(true); - } - if(!(ff.getFieldType().equals(FormField.FFT_CHECK_BOX) || ff.getFieldType().equals(FormField.FFT_COMBO_BOX) || ff.getFieldType().equals(FormField.FFT_LIST_BOX) - || ff.getFieldType().equals(FormField.FFT_LIST_MULTI)) && value.isDefaultValue()) - formFieldValues.add(value); - else if(ff.getFieldType().equals(FormField.FFT_CHECK_BOX) || ff.getFieldType().equals(FormField.FFT_COMBO_BOX) || ff.getFieldType().equals(FormField.FFT_LIST_BOX) - || ff.getFieldType().equals(FormField.FFT_LIST_MULTI)) { - formFieldValues.add(value); - } - //break; - } - } else { - if(requestValue!=null && requestValue.length>0) { - IdNameValue value = new IdNameValue(requestValue[0], requestValue[0], true, false); - formFieldValues.add(value); - } - } - - } else { - String[] requestValue = request.getParameterValues(ff.getFieldName()); - if(requestValue!=null && requestValue.length>0) { - IdNameValue value = new IdNameValue(requestValue[0], requestValue[0], true, false); - formFieldValues.add(value); - } - } - if(!ff.hasPredefinedList) { - if(oldSQL != null && !oldSQL.equals("")) { - ((IdNameSql)lookup).setSQL(oldSQL); - } - } - - - - ffJSON.setFormFieldValues(formFieldValues); - formFieldJSONList.add(ffJSON); - } // for - } - chartJSON.setFormFieldList(formFieldJSONList); - chartJSON.setChartSqlWhole(sql);*/ chartJSON.setChartAvailable(displayChart); ChartTypeJSON chartTypeJSON = new ChartTypeJSON(); @@ -687,7 +649,7 @@ public class ChartJSONHelper { } public boolean getFlagInBoolean(String s) { - return nvl(s).toUpperCase().startsWith("Y") || nvl(s).toLowerCase().equals("true"); + return nvl(s).toUpperCase().startsWith("Y") || nvl(s).equalsIgnoreCase("true"); } public DataSet loadChartData(String userId, HttpServletRequest request) throws RaptorException { diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntime.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntime.java index fcb0541e..361f405d 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntime.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntime.java @@ -70,7 +70,7 @@ public class ChartWebRuntime implements Serializable { public final String QRY_DATA_REPORT = ""; // Not used planning to use when filter is used - private StringBuffer whereClause = new StringBuffer(""); + private StringBuilder whereClause = new StringBuilder(""); // request used to grab request parameters private HttpServletRequest request; @@ -79,11 +79,11 @@ public class ChartWebRuntime implements Serializable { public ReportData reportData; //Used to pass user information - private final Map<String, Object> params = new HashMap<String, Object>(); + private final Map<String, Object> params = new HashMap<>(); //from chart generator retrieves list of charts to render - public ArrayList chartList; - public ArrayList infoList; + public List chartList; + public List infoList; private String totalSql; @@ -94,8 +94,6 @@ public class ChartWebRuntime implements Serializable { public List getRolesCommaSeperated(HttpServletRequest request) { Map roles = UserUtils.getRoles(request); List roleList = null; -// StringBuffer roleBuf = new StringBuffer(""); - int count = 0; if( roles != null ) { roleList = Arrays.asList(roles.keySet().toArray()); } @@ -119,7 +117,7 @@ public class ChartWebRuntime implements Serializable { long currentTime = System.currentTimeMillis(); HttpSession session = request.getSession(); String action = nvl(request.getParameter(AppConstants.RI_ACTION), request.getParameter("action")); - boolean genReportData = (!action.equals("chart.json") || action.equals("chart.data.json")); + boolean genReportData = (!"chart.json".equals(action) || "chart.data.json".equals(action)); @@ -165,7 +163,7 @@ public class ChartWebRuntime implements Serializable { reportData = getReportData(); - HashMap<String, String> chartOptionsMap = new HashMap<String, String>(); + HashMap<String, String> chartOptionsMap = new HashMap<>(); String rotateLabelsStr = ""; rotateLabelsStr = AppUtils.nvl(reportRuntime.getLegendLabelAngle()); @@ -244,11 +242,11 @@ public class ChartWebRuntime implements Serializable { if(reportRuntime!=null) { - StringBuffer title = new StringBuffer(""); + StringBuilder title = new StringBuilder(""); title.append(reportRuntime.getReportName()); } - if(! (action.equals("chart.json") || action.equals("chart.data.json"))) { + if(! ("chart.json".equals(action) || "chart.data.json".equals(action))) { //Chart @@ -328,28 +326,28 @@ public class ChartWebRuntime implements Serializable { /** * @return the chartList */ - public ArrayList getChartList() { + public List getChartList() { return chartList; } /** * @param chartList the chartList to set */ - public void setChartList(ArrayList chartList) { + public void setChartList(List chartList) { this.chartList = chartList; } /** * @return the infoList */ - public ArrayList getInfoList() { + public List getInfoList() { return infoList; } /** * @param infoList the infoList to set */ - public void setInfoList(ArrayList infoList) { + public void setInfoList(List infoList) { this.infoList = infoList; } @@ -408,7 +406,7 @@ public class ChartWebRuntime implements Serializable { } */ - public String drawD3Charts(HashMap<String,String> chartOptionsMap, HttpServletRequest request) { + public String drawD3Charts(Map<String,String> chartOptionsMap, HttpServletRequest request) { ChartD3Helper chartHelper = new ChartD3Helper(reportRuntime); chartHelper.setChartType(reportRuntime.getChartType()); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java index fd225246..fc5fdb36 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java @@ -37,6 +37,7 @@ */ package org.onap.portalsdk.analytics.system.fusion.adapter; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -49,6 +50,8 @@ import java.util.TreeSet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Restrictions; import org.onap.portalsdk.analytics.system.AppUtils; import org.onap.portalsdk.core.domain.Menu; import org.onap.portalsdk.core.domain.MenuData; @@ -145,7 +148,10 @@ public class RaptorAdapter extends FusionAdapter { String loginId = ""; try{ - List list = getDataAccessService().getList(User.class, " where user_id = " + userId, null, null); + List<Criterion> restrictionsList = new ArrayList<Criterion>(); + Criterion criterion1 = Restrictions.eq("user_id", userId); + restrictionsList.add(criterion1); + List list = getDataAccessService().getList(User.class, null, restrictionsList, null); if (list != null) { if (!list.isEmpty()) { User user = (User)list.get(0); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java index dbecbbd8..9e11affe 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java @@ -452,6 +452,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { ReportDefinition rdef = rh.loadReportDefinition(request, reportID); rdef.setAsCopy(request); request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef); + request.getSession().setAttribute("COPY_REPORT_EVENT", "true"); messageJSON.setMessage("Success- Report Copied."); messageJSON.setAnyStacktrace(rdef.getReportID() + " is Modified and added to session and DB."); @@ -671,12 +672,10 @@ public class RaptorControllerAsync extends RestrictedBaseController { ReportRuntime rr = null; boolean newReport = false; MessageJSON messageJSON = new MessageJSON(); - if("-1".equals(id)) { - id = "Create"; - } try { - if (id.equals("InSession")) { - rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION); + String copyReportEvent = (String)request.getSession().getAttribute("COPY_REPORT_EVENT"); + if (id.equals("InSession") || "true".equals(copyReportEvent)) { + rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION); newReport = false; } else if (id.equals("Create")) { @@ -833,7 +832,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { persistReportDefinition(request, rdef); messageJSON.setMessage("Success Definition of given report is saved in session."); messageJSON.setAnyStacktrace((newReport ? " New Report info is added to Session " - : rdef.getReportID() + " is Modified and added to session and DB.")); + : rdef.getReportID() + "- is Modified and added to session and DB.")); } catch (Exception ex) { messageJSON.setMessage("Error occured while saving definition Tab"); @@ -1389,9 +1388,9 @@ public class RaptorControllerAsync extends RestrictedBaseController { if (!Globals.isSystemInitialized()) { Globals.initializeSystem(servletContext); } - - if (tabId.equals("Def") && id.equals("InSession")) { - rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION); + String copyReportEvent = (String)request.getSession().getAttribute("COPY_REPORT_EVENT"); + if (tabId.equals("Def") && id.equals("InSession") || "true".equals(copyReportEvent)) { + rdef = (ReportDefinition) request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION); newReport = false; } else if (tabId.equals("Def") && id.equals("Create")) { diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapterTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapterTest.java new file mode 100644 index 00000000..34bdd787 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapterTest.java @@ -0,0 +1,83 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +package org.onap.portalsdk.analytics.system.fusion.adapter; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.portalsdk.core.domain.User; +import org.onap.portalsdk.core.service.DataAccessService; +import org.onap.portalsdk.core.web.support.AppUtils; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest(AppUtils.class) +public class RaptorAdapterTest { + + @Test + public void testGetUserLoginId() { + User user = new User(); + user.setLoginId("test"); + List<User> userList = new ArrayList<>(); + userList.add(user); + DataAccessService mockDataAccessService = Mockito.mock(DataAccessService.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.when(AppUtils.getDataAccessService()).thenReturn(mockDataAccessService); + Mockito.doReturn(userList).when(mockDataAccessService).getList(Mockito.eq(User.class), Mockito.eq(null), Mockito.anyList(), Mockito.eq(null)); + String loginID = RaptorAdapter.getUserLoginId("1"); + assertEquals("test",loginID); + } + + @Test + public void testGetUserLoginIdWithNullList() { + DataAccessService mockDataAccessService = Mockito.mock(DataAccessService.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.when(AppUtils.getDataAccessService()).thenReturn(mockDataAccessService); + Mockito.doReturn(null).when(mockDataAccessService).getList(Mockito.eq(User.class), Mockito.eq(null), Mockito.anyList(), Mockito.eq(null)); + String loginID = RaptorAdapter.getUserLoginId("1"); + assertEquals("",loginID); + } +} diff --git a/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkDMLMySql_2_5_Common.sql b/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkDMLMySql_2_5_Common.sql index 50221612..c158719b 100644 --- a/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkDMLMySql_2_5_Common.sql +++ b/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkDMLMySql_2_5_Common.sql @@ -135,35 +135,66 @@ INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('tab3.htm',' INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('tab4.htm','menu_tab'); INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('raptor.htm','view_reports'); INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('raptor_blob_extract.htm','view_reports'); -INSERT INTO fn_restricted_url VALUES('admin','menu_admin'); -INSERT INTO fn_restricted_url VALUES('get_role','menu_admin'); -INSERT INTO fn_restricted_url VALUES('get_role_functions','menu_admin'); -INSERT INTO fn_restricted_url VALUES('role_list/*','menu_admin'); -INSERT INTO fn_restricted_url VALUES('role_function_list/*','menu_admin'); -INSERT INTO fn_restricted_url VALUES('addRole','menu_admin'); -INSERT INTO fn_restricted_url VALUES('addRoleFunction','menu_admin'); -INSERT INTO fn_restricted_url VALUES('removeRole','menu_admin'); -INSERT INTO fn_restricted_url VALUES('removeRoleFunction','menu_admin'); -INSERT INTO fn_restricted_url VALUES('profile/*','menu_admin'); -INSERT INTO fn_restricted_url VALUES('samplePage','menu_sample'); -INSERT INTO fn_restricted_url VALUES('workflows','menu_admin'); -INSERT INTO fn_restricted_url VALUES('workflows/list','menu_admin'); -INSERT INTO fn_restricted_url VALUES('workflows/addWorkflow','menu_admin'); -INSERT INTO fn_restricted_url VALUES('workflows/saveCronJob','menu_admin'); -INSERT INTO fn_restricted_url VALUES('workflows/editWorkflow','menu_admin'); -INSERT INTO fn_restricted_url VALUES('workflows/removeWorkflow','menu_admin'); -INSERT INTO fn_restricted_url VALUES('workflows/removeAllWorkflows','menu_admin'); -INSERT INTO fn_restricted_url VALUES('role/saveRole.htm','menu_admin'); -INSERT INTO fn_restricted_url VALUES('post_search/process','menu_admin'); -INSERT INTO fn_restricted_url VALUES('post_search/search','menu_admin'); -INSERT INTO fn_restricted_url VALUES('post_search/search','menu_profile'); -INSERT INTO fn_restricted_url VALUES('report/wizard/retrieve_def_tab_wise_data/*','menu_reports'); -INSERT INTO fn_restricted_url VALUES('report/wizard/retrieve_form_tab_wise_data/*','menu_reports'); -INSERT INTO fn_restricted_url VALUES('report/wizard/retrieve_sql_tab_wise_data/*','menu_reports'); -INSERT INTO fn_restricted_url VALUES('report/wizard/security/*','menu_reports'); -INSERT INTO fn_restricted_url VALUES('report/wizard/copy_report/*','menu_reports'); -INSERT INTO fn_restricted_url VALUES('report/wizard/save_def_tab_data/*','menu_reports'); -INSERT INTO fn_restricted_url VALUES('report/wizard/retrieve_data/true','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('admin','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('get_role','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('get_role_functions','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('role_list/*','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('role_function_list/*','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('addRole','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('addRoleFunction','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('removeRole','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('removeRoleFunction','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('profile/*','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('samplePage','menu_sample'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('workflows','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('workflows/list','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('workflows/addWorkflow','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('workflows/saveCronJob','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('workflows/editWorkflow','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('workflows/removeWorkflow','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('workflows/removeAllWorkflows','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('role/saveRole.htm','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('post_search/process','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('post_search/search','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('post_search/search','menu_profile'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/retrieve_def_tab_wise_data/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/retrieve_form_tab_wise_data/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/retrieve_sql_tab_wise_data/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/security/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/copy_report/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/save_def_tab_data/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/retrieve_data/true','menu_reports'); + +-- new for Dublin +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('novamap_controller.htm','menu_map'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('/report*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('/report/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('/report/wizard/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('/report/wizard/retrieve_col_tab_wise_data/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('/report/wizard/retrieve_sql_tab_wise_data/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/security/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/security/addReportRole','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/security/addReportUser','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/drill_down_param/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/get_report_log/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/getDrillDownReportList','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/list_child_report_col/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/list_child_report_ff/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/list_columns','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/list_formfields','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/retrieve_col_tab_wise_data/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/retrieve_data/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/retrieve_form_tab_wise_data/*/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/retrieveTotalForTheColList','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report_blob_extract.htm','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report_email_attachment.htm','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report_search.htm','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report2.htm','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('sample_heat_map.htm','menu_tab'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('sample_heat_map_no_header.htm','menu_tab'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('serviceModels','menu_admin'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('welcome','menu_reports'); -- fn_role Insert into fn_role (ROLE_ID,ROLE_NAME,ACTIVE_YN,PRIORITY) values (16,'Standard User','Y',5); @@ -2878,4 +2909,4 @@ INSERT INTO demo_util_chart (TRAFFIC_DATE,UTIL_PERC ) VALUES (str_to_date('2016- INSERT INTO demo_util_chart (TRAFFIC_DATE,UTIL_PERC ) VALUES (str_to_date('2016-03-07','%Y-%m-%d'),61.86667); INSERT INTO demo_util_chart (TRAFFIC_DATE,UTIL_PERC ) VALUES (str_to_date('2016-03-08','%Y-%m-%d'),62.00000); -commit;
\ No newline at end of file +commit; diff --git a/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkDMLMySql_2_6_Common.sql b/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkDMLMySql_2_6_Common.sql index 2ff2dc26..66637e62 100644 --- a/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkDMLMySql_2_6_Common.sql +++ b/ecomp-sdk/epsdk-app-common/db-scripts/EcompSdkDMLMySql_2_6_Common.sql @@ -135,6 +135,11 @@ INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('tab3.htm',' INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('tab4.htm','menu_tab'); INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('raptor.htm','view_reports'); INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('raptor_blob_extract.htm','view_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/add_formfield_tab_data/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/save_formfield_tab_data/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/retrieve_form_tab_wise_data/*/delete','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/list_child_report_col/*','menu_reports'); +INSERT INTO fn_restricted_url (restricted_url, function_cd) VALUES ('report/wizard/list_child_report_ff/*','menu_reports'); INSERT INTO fn_restricted_url VALUES('admin','menu_admin'); INSERT INTO fn_restricted_url VALUES('get_role','menu_admin'); INSERT INTO fn_restricted_url VALUES('get_role_functions','menu_admin'); diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/RoleFunctionListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/RoleFunctionListController.java index 699e83ca..4ac5f37a 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/RoleFunctionListController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/RoleFunctionListController.java @@ -67,6 +67,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class RoleFunctionListController extends RestrictedBaseController { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RoleFunctionListController.class); + private static final String SUCCESS = "SUCCESS"; @Autowired private RoleService service; @@ -117,7 +118,7 @@ public class RoleFunctionListController extends RestrictedBaseController { RoleFunction domainRoleFunction = service.getRoleFunction(user.getOrgUserId(), code); domainRoleFunction.setName(availableRoleFunction.getName()); domainRoleFunction.setCode(code); - restCallStatus = "success"; + restCallStatus = SUCCESS; service.saveRoleFunction(user.getOrgUserId(), domainRoleFunction); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "saveRoleFunction failed", e); @@ -141,7 +142,7 @@ public class RoleFunctionListController extends RestrictedBaseController { RoleFunction availableRoleFunction = mapper.readValue(data, RoleFunction.class); String code = availableRoleFunction.getCode(); List<RoleFunction> currentRoleFunction = service.getRoleFunctions(user.getOrgUserId()); - restCallStatus = "success"; + restCallStatus = SUCCESS; for (RoleFunction roleF : currentRoleFunction) { if (roleF.getCode().equals(code)) { restCallStatus = "code exists"; @@ -177,7 +178,7 @@ public class RoleFunctionListController extends RestrictedBaseController { service.deleteRoleFunction(user.getOrgUserId(), domainRoleFunction); logger.info(EELFLoggerDelegate.auditLogger, "Remove role function " + domainRoleFunction.getName()); - restCallStatus = "success"; + restCallStatus = SUCCESS; } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "removeRoleFunction failed", e); throw new IOException(e); diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/UsageListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/UsageListController.java index 04c1f2bc..fabc06bf 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/UsageListController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/UsageListController.java @@ -65,6 +65,8 @@ public class UsageListController extends RestrictedBaseController { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UsageListController.class); + private static final String ACTIVE_USERS = "activeUsers"; + private void addUsers2jsonArray(JSONArray ja,HashMap activeUsers,String httpSessionId) { List<UserRowBean> rows = UsageUtils.getActiveUsers(activeUsers); @@ -96,10 +98,10 @@ public class UsageListController extends RestrictedBaseController { Map<String, Object> model = new HashMap<>(); HttpSession httpSession = request.getSession(); - HashMap activeUsers = (HashMap) httpSession.getServletContext().getAttribute("activeUsers"); + HashMap activeUsers = (HashMap) httpSession.getServletContext().getAttribute(ACTIVE_USERS); if (activeUsers.size() == 0) { activeUsers.put(httpSession.getId(), httpSession); - httpSession.getServletContext().setAttribute("activeUsers", activeUsers); + httpSession.getServletContext().setAttribute(ACTIVE_USERS, activeUsers); } JSONArray ja = new JSONArray(); @@ -119,10 +121,10 @@ public class UsageListController extends RestrictedBaseController { public void getUsageList(HttpServletRequest request, HttpServletResponse response) { HttpSession httpSession = request.getSession(); - HashMap activeUsers = (HashMap) httpSession.getServletContext().getAttribute("activeUsers"); + HashMap activeUsers = (HashMap) httpSession.getServletContext().getAttribute(ACTIVE_USERS); if (activeUsers.size() == 0) { activeUsers.put(httpSession.getId(), httpSession); - httpSession.getServletContext().setAttribute("activeUsers", activeUsers); + httpSession.getServletContext().setAttribute(ACTIVE_USERS, activeUsers); } JSONArray ja = new JSONArray(); try { @@ -144,7 +146,7 @@ public class UsageListController extends RestrictedBaseController { @SuppressWarnings("rawtypes") @RequestMapping(value = { "/usage_list/removeSession" }, method = RequestMethod.GET) public void removeSession(HttpServletRequest request, HttpServletResponse response) throws IOException { - HashMap activeUsers = (HashMap) request.getSession().getServletContext().getAttribute("activeUsers"); + HashMap activeUsers = (HashMap) request.getSession().getServletContext().getAttribute(ACTIVE_USERS); UserRowBean data = new UserRowBean(); data.setSessionId(request.getParameter("deleteSessionId")); UsageUtils.getActiveUsersAfterDelete(activeUsers, data); diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/CollaborationController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/CollaborationController.java index 93a6f74f..18cd6a6a 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/CollaborationController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/CollaborationController.java @@ -56,7 +56,7 @@ public class CollaborationController extends RestrictedBaseController{ @RequestMapping(value = {"/collaboration" }, method = RequestMethod.GET) public ModelAndView view(HttpServletRequest request) { - Map<String, Object> model = new HashMap<String, Object>(); + Map<String, Object> model = new HashMap<>(); User user = UserUtils.getUserSession(request); model.put("name",(user.getFirstName() + " " + (user.getLastName() != null? user.getLastName().substring(0,1): "" ))); @@ -64,7 +64,7 @@ public class CollaborationController extends RestrictedBaseController{ } @RequestMapping(value = {"/openCollaboration" }, method = RequestMethod.GET) public ModelAndView openCollaboration(HttpServletRequest request) { - Map<String, Object> model = new HashMap<String, Object>(); + Map<String, Object> model = new HashMap<>(); User user = UserUtils.getUserSession(request); model.put("name",(user.getFirstName() + " " + (user.getLastName() != null? user.getLastName().substring(0,1): "" ))); diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/NetMapController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/NetMapController.java index 38ae6ee8..f3f739f4 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/NetMapController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/NetMapController.java @@ -58,7 +58,7 @@ public class NetMapController extends RestrictedBaseController { @RequestMapping(value = { "/net_map" }, method = RequestMethod.GET) public ModelAndView plot(HttpServletRequest request) { - Map<String, Object> model = new HashMap<String, Object>(); + Map<String, Object> model = new HashMap<>(); model.put("frame_int", "net_map_int"); // This view resolves to page frame_insert.jsp return new ModelAndView("frame_insert", model); diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/PostDroolsController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/PostDroolsController.java index 43d548f9..cf7fa06a 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/PostDroolsController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/PostDroolsController.java @@ -109,7 +109,7 @@ public class PostDroolsController extends RestrictedBaseController { } @RequestMapping(value = { "/post_drools/execute" }, method = RequestMethod.POST) - public ModelAndView search(HttpServletRequest request, HttpServletResponse response) throws Exception { + public ModelAndView search(HttpServletRequest request, HttpServletResponse response) { try { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/SamplePageController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/SamplePageController.java index 26a4e444..5adaf66e 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/SamplePageController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/SamplePageController.java @@ -58,10 +58,8 @@ public class SamplePageController extends RestrictedBaseController { @RequestMapping(value = { "/samplePage" }, method = RequestMethod.GET) public ModelAndView plot(HttpServletRequest request) { - Map<String, Object> model = new HashMap<String, Object>(); - /*model.put("frame_int", "net_map_int"); - // This view resolves to page frame_insert.jsp - return new ModelAndView("frame_insert", model);*/ + Map<String, Object> model = new HashMap<>(); + return new ModelAndView("samplePage", "model", model); } diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/util/SecurityXssValidator.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/util/SecurityXssValidator.java index 8a2cf3e7..ef53d16e 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/util/SecurityXssValidator.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/util/SecurityXssValidator.java @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * + * */ package org.onap.portalapp.util; @@ -42,7 +42,6 @@ import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.regex.Pattern; - import org.apache.commons.lang.NotImplementedException; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.StringEscapeUtils; @@ -51,157 +50,162 @@ import org.onap.portalsdk.core.util.SystemProperties; import org.owasp.esapi.ESAPI; import org.owasp.esapi.codecs.Codec; import org.owasp.esapi.codecs.MySQLCodec; -import org.owasp.esapi.codecs.OracleCodec; import org.owasp.esapi.codecs.MySQLCodec.Mode; +import org.owasp.esapi.codecs.OracleCodec; public class SecurityXssValidator { - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SecurityXssValidator.class); - - private static final String MYSQL_DB = "mysql"; - private static final String ORACLE_DB = "oracle"; - private static final String MARIA_DB = "mariadb"; - private static final int FLAGS = Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL; - - static SecurityXssValidator validator = null; - private static Codec instance; - private static final Lock lock = new ReentrantLock(); - - public static SecurityXssValidator getInstance() { - - if (validator == null) { - lock.lock(); - try { - if (validator == null) - validator = new SecurityXssValidator(); - } finally { - lock.unlock(); - } - } - return validator; - } + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SecurityXssValidator.class); - private SecurityXssValidator() { - // Avoid anything between script tags - XSS_INPUT_PATTERNS.add(Pattern.compile("<script>(.*?)</script>", FLAGS)); + private static final String MYSQL_DB = "mysql"; + private static final String ORACLE_DB = "oracle"; + private static final String MARIA_DB = "mariadb"; + private static final int FLAGS = Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL; - // avoid iframes - XSS_INPUT_PATTERNS.add(Pattern.compile("<iframe(.*?)>(.*?)</iframe>", FLAGS)); + static SecurityXssValidator validator = null; + private static Codec instance; + private static final Lock lock = new ReentrantLock(); - // Avoid anything in a src='...' type of expression - XSS_INPUT_PATTERNS.add(Pattern.compile("src[\r\n]*=[\r\n]*\\\'(.*?)\\\'", FLAGS)); + private List<Pattern> xssInputPatterns = new ArrayList<>(); - XSS_INPUT_PATTERNS.add(Pattern.compile("src[\r\n]*=[\r\n]*\\\"(.*?)\\\"", FLAGS)); + private SecurityXssValidator() { + // Avoid anything between script tags + xssInputPatterns.add(Pattern.compile("<script>(.*?)</script>", FLAGS)); - XSS_INPUT_PATTERNS.add(Pattern.compile("src[\r\n]*=[\r\n]*([^>]+)", FLAGS)); + // avoid iframes + xssInputPatterns.add(Pattern.compile("<iframe(.*?)>(.*?)</iframe>", FLAGS)); - // Remove any lonesome </script> tag - XSS_INPUT_PATTERNS.add(Pattern.compile("</script>", FLAGS)); + // Avoid anything in a src='...' type of expression + xssInputPatterns.add(Pattern.compile("src[\r\n]*=[\r\n]*\\\'(.*?)\\\'", FLAGS)); - XSS_INPUT_PATTERNS.add(Pattern.compile(".*(<script>|</script>).*", FLAGS)); + xssInputPatterns.add(Pattern.compile("src[\r\n]*=[\r\n]*\\\"(.*?)\\\"", FLAGS)); - XSS_INPUT_PATTERNS.add(Pattern.compile(".*(<iframe>|</iframe>).*", FLAGS)); + xssInputPatterns.add(Pattern.compile("src[\r\n]*=[\r\n]*([^>]+)", FLAGS)); - // Remove any lonesome <script ...> tag - XSS_INPUT_PATTERNS.add(Pattern.compile("<script(.*?)>", FLAGS)); + // Remove any lonesome </script> tag + xssInputPatterns.add(Pattern.compile("</script>", FLAGS)); - // Avoid eval(...) expressions - XSS_INPUT_PATTERNS.add(Pattern.compile("eval\\((.*?)\\)", FLAGS)); + xssInputPatterns.add(Pattern.compile(".*(<script>|</script>).*", FLAGS)); - // Avoid expression(...) expressions - XSS_INPUT_PATTERNS.add(Pattern.compile("expression\\((.*?)\\)", FLAGS)); + xssInputPatterns.add(Pattern.compile(".*(<iframe>|</iframe>).*", FLAGS)); - // Avoid javascript:... expressions - XSS_INPUT_PATTERNS.add(Pattern.compile(".*(javascript:|vbscript:).*", FLAGS)); + // Remove any lonesome <script ...> tag + xssInputPatterns.add(Pattern.compile("<script(.*?)>", FLAGS)); - // Avoid onload= expressions - XSS_INPUT_PATTERNS.add(Pattern.compile(".*(onload(.*?)=).*", FLAGS)); - } + // Avoid eval(...) expressions + xssInputPatterns.add(Pattern.compile("eval\\((.*?)\\)", FLAGS)); - private List<Pattern> XSS_INPUT_PATTERNS = new ArrayList<Pattern>(); + // Avoid expression(...) expressions + xssInputPatterns.add(Pattern.compile("expression\\((.*?)\\)", FLAGS)); - /** - * * This method takes a string and strips out any potential script injections. - * - * @param value - * @return String - the new "sanitized" string. - */ - public String stripXSS(String value) { + // Avoid javascript:... expressions + xssInputPatterns.add(Pattern.compile(".*(javascript:|vbscript:).*", FLAGS)); - try { + // Avoid onload= expressions + xssInputPatterns.add(Pattern.compile(".*(onload(.*?)=).*", FLAGS)); + } - if (StringUtils.isNotBlank(value)) { + public static SecurityXssValidator getInstance() { - value = StringEscapeUtils.escapeHtml4(value); + if (validator == null) { + lock.lock(); + try { + if (validator == null) { + validator = new SecurityXssValidator(); + } + } finally { + lock.unlock(); + } + } - value = ESAPI.encoder().canonicalize(value); + return validator; + } - // Avoid null characters - value = value.replaceAll("\0", ""); + /** + * * This method takes a string and strips out any potential script injections. + * + * @return String - the new "sanitized" string. + */ + public String stripXSS(String value) { - for (Pattern xssInputPattern : XSS_INPUT_PATTERNS) { - value = xssInputPattern.matcher(value).replaceAll(""); - } - } + try { - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "stripXSS() failed", e); - } + if (StringUtils.isNotBlank(value)) { - return value; - } + value = StringEscapeUtils.escapeHtml4(value); - public Boolean denyXSS(String value) { - Boolean flag = Boolean.FALSE; - try { - if (StringUtils.isNotBlank(value)) { - value = ESAPI.encoder().canonicalize(value); - for (Pattern xssInputPattern : XSS_INPUT_PATTERNS) { - if (xssInputPattern.matcher(value).matches()) { - flag = Boolean.TRUE; - break; - } + value = ESAPI.encoder().canonicalize(value); - } - } + // Avoid null characters + value = value.replaceAll("\0", ""); - } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, "denyXSS() failed", e); - } + for (Pattern xssInputPattern : xssInputPatterns) { + value = xssInputPattern.matcher(value).replaceAll(""); + } + } - return flag; - } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "stripXSS() failed", e); + } - public Codec getCodec() { - try { - if (null == instance) { - if (StringUtils.containsIgnoreCase(SystemProperties.getProperty(SystemProperties.DB_DRIVER), MYSQL_DB) - || StringUtils.containsIgnoreCase(SystemProperties.getProperty(SystemProperties.DB_DRIVER), - MARIA_DB)) { - instance = new MySQLCodec(Mode.STANDARD); + return value; + } - } else if (StringUtils.containsIgnoreCase(SystemProperties.getProperty(SystemProperties.DB_DRIVER), - ORACLE_DB)) { - instance = new OracleCodec(); - } else { - throw new NotImplementedException("Handling for data base \"" - + SystemProperties.getProperty(SystemProperties.DB_DRIVER) + "\" not yet implemented."); - } - } + public Boolean denyXSS(String value) { + Boolean flag = Boolean.FALSE; + try { + if (StringUtils.isBlank(value)) + return flag; - } catch (Exception ex) { - logger.error(EELFLoggerDelegate.errorLogger, "getCodec() failed", ex); - } - return instance; + value = ESAPI.encoder().canonicalize(value); + for (Pattern xssInputPattern : xssInputPatterns) { + if (xssInputPattern.matcher(value).matches()) { + flag = Boolean.TRUE; + break; + } + } - } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "denyXSS() failed", e); + } - public List<Pattern> getXSS_INPUT_PATTERNS() { - return XSS_INPUT_PATTERNS; - } + return flag; + } - public void setXSS_INPUT_PATTERNS(List<Pattern> xSS_INPUT_PATTERNS) { - XSS_INPUT_PATTERNS = xSS_INPUT_PATTERNS; - } + public Codec getCodec() { + try { + if (null == instance) { + if (StringUtils + .containsIgnoreCase(SystemProperties.getProperty(SystemProperties.DB_DRIVER), MYSQL_DB) + || StringUtils + .containsIgnoreCase(SystemProperties.getProperty(SystemProperties.DB_DRIVER), + MARIA_DB)) { + instance = new MySQLCodec(Mode.STANDARD); + + } else if (StringUtils + .containsIgnoreCase(SystemProperties.getProperty(SystemProperties.DB_DRIVER), + ORACLE_DB)) { + instance = new OracleCodec(); + } else { + throw new NotImplementedException("Handling for data base \"" + + SystemProperties.getProperty(SystemProperties.DB_DRIVER) + + "\" not yet implemented."); + } + } + + } catch (Exception ex) { + logger.error(EELFLoggerDelegate.errorLogger, "getCodec() failed", ex); + } + return instance; + + } + + public List<Pattern> getXssInputPatterns() { + return xssInputPatterns; + } + + public void setXssInputPatterns(List<Pattern> xssInputPatterns) { + this.xssInputPatterns = xssInputPatterns; + } }
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-os/README.md b/ecomp-sdk/epsdk-app-os/README.md index 1034949d..3ab427e3 100644 --- a/ecomp-sdk/epsdk-app-os/README.md +++ b/ecomp-sdk/epsdk-app-os/README.md @@ -17,7 +17,10 @@ Version 2.6.0-SNAPSHOT - PORTAL-543 Fix fortify scan security vulnerability issues - PORTAL-273 Raise JUnit test coverage of Portal/SDK repos to 50% Including JavaScript - PORTAL-544 Fix for Raptor issues - +- PORTAL-545 Copied report is not saved due to report id -1 +- PORTAL-581 Fix for edited copy report name save issue +- PORTAL-582 Handled SQL injection for user Login Id, Added JUNIT test case for RaptorAdapter.java, Added AT&Tlicense and fixed compilation issue. +- PORTAL-583 Added portal/SDK 2_6 Scripts to fix Raptor UI issues Version 2.5.0 - PORTAL-356 Bootstrapping hybrid applications (Angular and AngularJS) diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js index 54a14242..a23823e3 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js @@ -2,6 +2,7 @@ appDS2.controller('reportStepController', function($scope,$http,$location, $rout /*****************Init values*********************/ $scope.reportIdURL = $routeParams.reportId; $scope.isEdit = ($scope.reportIdURL==null||$scope.reportIdURL=='')?false:true; + $scope.isCopy = false; $scope.isDefReady = $scope.isEdit; $scope.activeTabsId = 'definition'; $scope.pageMsg ='' @@ -260,6 +261,11 @@ appDS2.controller('reportStepController', function($scope,$http,$location, $rout $scope.stepTabs[x].disabled=false; } $scope.showLoader=false; + if(isCopy){ + var newReportId = data.anyStacktrace.split("-")[0]; + if(newReportId!=null && newReportId!='' && newReportId!=-1) + $window.location.href = "#/report_wizard/"+newReportId; + } },function(error){ $scope.errorPopUp(error); $log.error("report-step-controller: updateDefinition by Id failed."); @@ -710,6 +716,7 @@ appDS2.controller('reportStepController', function($scope,$http,$location, $rout /********************Init*************/ $scope.init = function(){ if ($routeParams.reportMode=="copy") { + $scope.isCopy = true; raptorReportFactory.copyReportById($routeParams.reportId).then(function(data){ $scope.isEdit = true; $scope.reportId = -1; diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step1.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step1.html index 64d31d97..0ad05d24 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step1.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-view-models/ds2-reports/steps/step1.html @@ -7,7 +7,7 @@ <div class="span6" ng-hide="showLoader"> - <div class="form-row" ng-if="isEdit"> + <div class="form-row" ng-if="isEdit && !isCopy"> <label for="textinputID-2a">Report ID</label> <div class="field-group"> <input id="textinputID-2a" ddh-reset="" class="span12" type="text" data-ng-model="definitionData.reportId" ng-disabled="true"> diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java index ed8e89e3..dc18c3be 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/web/socket/WebRTCSocket.java @@ -33,13 +33,14 @@ * * ============LICENSE_END============================================ * - * + * */ package org.onap.portalsdk.core.web.socket; -import java.util.Hashtable; +import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import javax.websocket.OnClose; import javax.websocket.OnMessage; import javax.websocket.OnOpen; @@ -55,8 +56,9 @@ public class WebRTCSocket { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WebRTCSocket.class); - private final static Map<String, Hashtable<String, Object[]>> channelMap = new Hashtable<String, Hashtable<String, Object[]>>(); - private final Map<String, String> sessionMap = new Hashtable<String, String>(); + private static final Map<String, HashMap<String, Object[]>> channelMap = new HashMap<>(); + private static final String MESSAGE_FAILED = "mesage failed"; + private final Map<String, String> sessionMap = new HashMap<>(); private final ObjectMapper mapper = new ObjectMapper(); @OnMessage @@ -69,11 +71,11 @@ public class WebRTCSocket { if (isOpen != null && (Boolean) isOpen) { String channel = (String) jsonObject.get("channel"); Object value = channelMap.get(channel); - Hashtable<String, Object[]> sourceDestMap; + HashMap<String, Object[]> sourceDestMap; if (value == null) - sourceDestMap = new Hashtable<>(); + sourceDestMap = new HashMap<>(); else - sourceDestMap = (Hashtable<String, Object[]>) value; + sourceDestMap = (HashMap<String, Object[]>) value; sourceDestMap.put(session.getId(), new Object[] { session }); channelMap.put(channel, sourceDestMap); @@ -81,7 +83,7 @@ public class WebRTCSocket { } } catch (Exception je) { - logger.error(EELFLoggerDelegate.errorLogger, "mesage failed", je); + logger.error(EELFLoggerDelegate.errorLogger, MESSAGE_FAILED, je); } try { @@ -97,26 +99,27 @@ public class WebRTCSocket { else channel = (String) jsonObject.get("channel"); } catch (Exception json) { - logger.error(EELFLoggerDelegate.errorLogger, "mesage failed", json); + logger.error(EELFLoggerDelegate.errorLogger, MESSAGE_FAILED, json); } - Hashtable<String, Object[]> sourceDestMap = channelMap.get(channel); + HashMap<String, Object[]> sourceDestMap = channelMap.get(channel); if (sourceDestMap != null) - for (String id : sourceDestMap.keySet()) { - if (!id.equals(session.getId())) { - Session otherSession = (Session) (sourceDestMap.get(id))[0]; + for (Entry<String, Object[]> entry : sourceDestMap.entrySet()){ + + if (!entry.getKey().equals(session.getId())) { + Session otherSession = (Session) (entry.getValue())[0]; if (otherSession.isOpen()) otherSession.getBasicRemote().sendText(mapper.writeValueAsString(dataObj)); } } } catch (Exception je) { - logger.error(EELFLoggerDelegate.errorLogger, "mesage failed", je); + logger.error(EELFLoggerDelegate.errorLogger, MESSAGE_FAILED, je); } } catch (Exception je) { - logger.error(EELFLoggerDelegate.errorLogger, "mesage failed", je); + logger.error(EELFLoggerDelegate.errorLogger, MESSAGE_FAILED, je); } } diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java index c8d15884..2cbc5a94 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java @@ -120,7 +120,7 @@ public class MusicService { } if (isAtomicPut) - result = MusicCore.atomicPutWithDeleteLock(musicKeySpace, tableName, sessionId, queryObject, null); + result = MusicCore.atomicPut(musicKeySpace, tableName, sessionId, queryObject, null); else result = MusicCore.eventualPut(queryObject); logger.debug(EELFLoggerDelegate.debugLogger, "setAttribute: attributeName: " + attributeName @@ -152,7 +152,7 @@ public class MusicService { queryObject.addValue(String.valueOf(session.getMaxInactiveInterval())); queryObject.addValue(session.getId()); if (isAtomicPut) - result = MusicCore.atomicPutWithDeleteLock(musicKeySpace, musicMetaTable, session.getId(), queryObject, null); + result = MusicCore.atomicPut(musicKeySpace, musicMetaTable, session.getId(), queryObject, null); else result = MusicCore.eventualPut(queryObject); logger.debug(EELFLoggerDelegate.debugLogger, @@ -178,7 +178,7 @@ public class MusicService { queryObject.appendQueryString(querySB.toString()); queryObject.addValue(sessionId); if (isAtomicGet) - result = MusicCore.atomicGetWithDeleteLock(musicKeySpace, musicMetaTable, sessionId, queryObject); + result = MusicCore.atomicGet(musicKeySpace, musicMetaTable, sessionId, queryObject); else result = MusicCore.get(queryObject); logger.debug(EELFLoggerDelegate.debugLogger, "getMetaAttribute: with session id: " + sessionId); @@ -234,7 +234,7 @@ public class MusicService { queryObject.appendQueryString(querySB.toString()); if (isAtomicGet) - result = MusicCore.atomicGetWithDeleteLock(musicKeySpace, tableName, sessionId, queryObject); + result = MusicCore.atomicGet(musicKeySpace, tableName, sessionId, queryObject); else result = MusicCore.get(queryObject); return MusicUtil.musicRestResponseDataParsing(result, attributeName); @@ -270,7 +270,7 @@ public class MusicService { tableName = musicMetaTable; queryObject.appendQueryString(querySB.toString()); if (isAtomicPut) - result = MusicCore.atomicPutWithDeleteLock(musicKeySpace, tableName, sessionId, queryObject, null); + result = MusicCore.atomicPut(musicKeySpace, tableName, sessionId, queryObject, null); else result = MusicCore.eventualPut(queryObject); logger.debug(EELFLoggerDelegate.debugLogger, @@ -298,7 +298,7 @@ public class MusicService { queryObject.appendQueryString(querySB.toString()); queryObject.addValue(sessionId); if (isAtomic) - result = MusicCore.atomicPutWithDeleteLock(musicKeySpace, musicMetaTable, sessionId, queryObject, null); + result = MusicCore.atomicPut(musicKeySpace, musicMetaTable, sessionId, queryObject, null); else result = MusicCore.eventualPut(queryObject); logger.debug(EELFLoggerDelegate.debugLogger, REMOVE_SESSION + musicMetaTable + WITH_SESSION_ID @@ -311,7 +311,7 @@ public class MusicService { queryObject.appendQueryString(querySB.toString()); queryObject.addValue(sessionId); if (isAtomic) - result = MusicCore.atomicPutWithDeleteLock(musicKeySpace, musicAttrTable, sessionId, queryObject, null); + result = MusicCore.atomicPut(musicKeySpace, musicAttrTable, sessionId, queryObject, null); else result = MusicCore.eventualPut(queryObject); @@ -575,7 +575,7 @@ public class MusicService { try{ if (isAtomicGet) - result = MusicCore.atomicGetWithDeleteLock(musicKeySpace, musicMetaTable, null, queryObject); + result = MusicCore.atomicGet(musicKeySpace, musicMetaTable, null, queryObject); else result = MusicCore.get(queryObject); Row row = result.one(); @@ -621,7 +621,7 @@ public class MusicService { queryObject.appendQueryString(querySB.toString()); try{ if (isAtomicPut) - result = MusicCore.atomicPutWithDeleteLock(musicKeySpace, null, null, queryObject, null); + result = MusicCore.atomicPut(musicKeySpace, null, null, queryObject, null); else result = MusicCore.eventualPut(queryObject); }catch(Exception e){ @@ -639,7 +639,7 @@ public class MusicService { queryObject.appendQueryString(querySB.toString()); try{ if (isAtomicPut) - result = MusicCore.atomicPutWithDeleteLock(musicKeySpace, null, null, queryObject, null); + result = MusicCore.atomicPut(musicKeySpace, null, null, queryObject, null); else result = MusicCore.eventualPut(queryObject); }catch(Exception e){ diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicProperties.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicProperties.java index 9aae9770..3a03b386 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicProperties.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicProperties.java @@ -121,8 +121,6 @@ public class MusicProperties { public static final String EXPIRY_TIME = "EXPIRY_TIME"; public static final String PRINCIPAL_NAME = "PRINCIPAL_NAME"; - - private MusicProperties(){} private static Properties properties; @@ -132,6 +130,7 @@ public class MusicProperties { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicProperties.class); + private MusicProperties(){} /** * Gets the property value for the specified key. If a value is found, leading * and trailing space is trimmed. @@ -185,40 +184,5 @@ public class MusicProperties { } return true; } - - /** - * Tests whether a property value is available for the specified key. - * - * @param key - * Property key - * @return True if the key is known, otherwise false. - */ -/* public static boolean containsProperty(String key) { - return environment.containsProperty(key); - }*/ - - /** - * Returns the property value associated with the given key (never - * {@code null}), after trimming any trailing space. - * - * @param key - * Property key - * @return Property value; the empty string if the environment was not - * autowired, which should never happen. - * @throws IllegalStateException - * if the key is not found - */ -/* public static String getProperty(String key) { - String value = ""; - if (environment == null) { - // logger.error(EELFLoggerDelegate.errorLogger, "getProperty: environment is null, should never happen!"); - } else { - value = environment.getRequiredProperty(key); - // java.util.Properties preserves trailing space - if (value != null) - value = value.trim(); - } - return value; - }*/ } |