From bd394463f9f73c4c40f19ae55e43d54a55d61e84 Mon Sep 17 00:00:00 2001 From: burdziak Date: Mon, 8 Jul 2019 16:47:50 +0200 Subject: Fix sonar issue in ActionHandler Change-Id: Iecda5ffe25903df8657cd83503b8aa4e3e93e553 Issue-ID: PORTAL-523 Signed-off-by: burdziak --- .../analytics/controller/ActionHandler.java | 68 +++++++++------------- 1 file changed, 26 insertions(+), 42 deletions(-) (limited to 'ecomp-sdk/epsdk-analytics/src/main') 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 d6ae3e2d..7e76c46f 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 @@ -145,7 +145,8 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { 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 static final String REPORT_DOWNLOAD_PAGE = ";report.download.page"; + private static final String FALSE = "false"; private void preserveReportRuntimeAsBackup(HttpServletRequest request) { HttpSession session = request.getSession(); @@ -923,7 +924,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { SearchHandler sh = new SearchHandler(); ReportSearchResultJSON sr = sh.loadReportSearchResult(request); return sr.getJSONString(); - //request.setAttribute(AppConstants.RI_SEARCH_RESULT, sr); } catch (RaptorException e) { nextPage = (new ErrorHandler()).processFatalError(request, e); } @@ -940,20 +940,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { ChartWebRuntime cwr = new ChartWebRuntime(); return cwr.generateChart(request); //data } // reportSearchExecute - - - // public String reportRunExecute(HttpServletRequest request, String nextPage) { -// try { -// ReportRunHandler rh = new ReportRunHandler(); -// ReportRunResultJSON sr = rh.loadReportRunResult(request); -// return sr.getJSONString(); -// //request.setAttribute(AppConstants.RI_SEARCH_RESULT, sr); -// } catch (RaptorException e) { -// nextPage = (new ErrorHandler()).processFatalError(request, e); -// } -// -// return nextPage; -// } public String getQuickLinksJSON(HttpServletRequest request, String nextPage) { String jsonInString = null; @@ -985,22 +971,22 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { logger.debug(EELFLoggerDelegate.debugLogger, ("^^^^^^^^^^^^^Check " + check + " Admin "+ isAdmin)); - if(check || isAdmin) { - if(reportID.length()>0) { - ReportHandler rh = new ReportHandler(); - ReportDefinition rdef = rh.loadReportDefinition(request, reportID); - request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef); - ReportSchedule reportSchedule = null; - if(rdef!=null) { - reportSchedule = new ReportSchedule(reportID, AppUtils.getUserID(request), false, request); - } - request.getSession().setAttribute(AppConstants.SI_REPORT_SCHEDULE, reportSchedule); - } - } else { - //String message = "You have reached your schedule limit. Please visit this page again after removing your old schedules in \"My Schedule\" section."; + if(!(check || isAdmin)) { String message = "You have reached the scheduled report limit for your Login ID. Please remove any old schedule requests in the \"My Scheduled Reports\" screen before attempting to schedule any additional reports."; nextPage = (new ErrorHandler()).processFatalError(request, new RaptorSchedularException(message)); + return nextPage; } + + if(!reportID.isEmpty()) { + ReportHandler rh = new ReportHandler(); + ReportDefinition rdef = rh.loadReportDefinition(request, reportID); + request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef); + ReportSchedule reportSchedule = null; + if(rdef!=null) { + reportSchedule = new ReportSchedule(reportID, AppUtils.getUserID(request), false, request); + } + request.getSession().setAttribute(AppConstants.SI_REPORT_SCHEDULE, reportSchedule); + } } catch(Exception ex) { logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), ex);} return nextPage; @@ -1034,12 +1020,13 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } } catch (Exception ex) { logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), ex);} - if(reportSchedule == null) reportSchedule = new ReportSchedule(reportID, scheduleID, AppUtils.getUserID(request), request); + if(reportSchedule == null) + reportSchedule = new ReportSchedule(reportID, scheduleID, AppUtils.getUserID(request), request); String formFields = ""; formFields = reportSchedule.getFormFields(); formFields = (formFields.length()>1)?formFields.substring(1):formFields; - String formFieldsArr[] = formFields.split("&"); - String sessionParams[] = Globals.getSessionParamsForScheduling().split(","); + String[] formFieldsArr = formFields.split("&"); + String[] sessionParams = Globals.getSessionParamsForScheduling().split(","); for (int i=0; i1)?formFields.substring(1):formFields; - String formFieldsArr[] = formFields.split("&"); - String sessionParams[] = Globals.getSessionParamsForScheduling().split(","); + String[] formFieldsArr = formFields.split("&"); + String[] sessionParams = Globals.getSessionParamsForScheduling().split(","); for (int i=0; i 0) { -- cgit 1.2.3-korg