diff options
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller')
4 files changed, 109 insertions, 233 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/Action.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/Action.java index a3a5c60f..81ed950b 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/Action.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/Action.java @@ -63,7 +63,6 @@ public class Action extends org.onap.portalsdk.analytics.RaptorObject { Action a = new Action(); StringTokenizer st = new StringTokenizer(configFileEntry, "| \t", false); - // if(st.hasMoreTokens()) a.setAction(st.nextToken()); a.setControllerClass(st.nextToken()); a.setControllerMethod(st.nextToken()); 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 a50a04eb..1cc75b5e 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 @@ -73,6 +73,7 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; @@ -95,6 +96,7 @@ import org.onap.portalsdk.analytics.error.RaptorSchedularException; import org.onap.portalsdk.analytics.error.ReportSQLException; import org.onap.portalsdk.analytics.error.UserDefinedException; import org.onap.portalsdk.analytics.error.ValidationException; +import org.onap.portalsdk.analytics.model.DashboardChildReport; import org.onap.portalsdk.analytics.model.DataCache; import org.onap.portalsdk.analytics.model.ReportHandler; import org.onap.portalsdk.analytics.model.ReportLoader; @@ -131,7 +133,10 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SecurityCodecUtil; import org.owasp.esapi.ESAPI; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -322,9 +327,9 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REP_ID, reportID); String strHTML = rr1.getDashboardLayoutHTML(); - - TreeMap treeMap = getListOfReportsFromDashBoardHTML(strHTML); - + String strJson = rr1.getDashboardLayoutJSON(); + TreeMap treeMap = getListOfReportsFromDashBoardJson(strJson); + TreeMap treeMapHtml = getListOfReportsFromDashBoardHTML(strHTML); Set set = treeMap.entrySet(); HashMap reportsRuntimeMap = new HashMap(); @@ -350,10 +355,13 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { record++; Map.Entry entry = (Entry) iter.next(); 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 + // 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); if(similiarReportRuntime != null ) { - rrDashboardReports = (ReportRuntime) getSimiliarReportRuntime(reportsRuntimeMap, reportIDFromMap).clone(); + rrDashboardReports = (ReportRuntime) getSimiliarReportRuntime(reportsRuntimeMap, + reportIDFromMap).clone(); intObj = getKey(reportsRuntimeMap,reportIDFromMap); } else { rrDashboardReports = rh.loadReportRuntime(request, reportIDFromMap, true, requestFlag); @@ -364,10 +372,12 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { rrDashboardReports.setDisplayMode(ReportRuntime.DISPLAY_DATA_ONLY); } - downloadLimit = (rrDashboardReports.getMaxRowsInExcelDownload()>0)?rrDashboardReports.getMaxRowsInExcelDownload():Globals.getDownloadLimit(); + downloadLimit = (rrDashboardReports.getMaxRowsInExcelDownload() > 0) + ? rrDashboardReports.getMaxRowsInExcelDownload() : Globals.getDownloadLimit(); if(record == 1) { - if(rrDashboardReports.getReportFormFields()!=null && rrDashboardReports.getReportFormFields().size()>0) { + if (rrDashboardReports.getReportFormFields() != null + && rrDashboardReports.getReportFormFields().size() > 0) { buildReportdata = false; if(rDisplayContent) buildReportdata = true; @@ -380,26 +390,37 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { ds = (DataSet) reportChartDataMap.get(intObj); } else { if (!rrDashboardReports.getReportType().equals(AppConstants.RT_HIVE)) - rd = rrDashboardReports.loadReportData(pageNo, userId, downloadLimit,request, false /*download*/); + rd = rrDashboardReports.loadReportData(pageNo, userId, downloadLimit, request, + false /* download */); else - rd = rrDashboardReports.loadHiveLinearReportData(rrDashboardReports.getReportSQL(), userId, 2,request); + rd = rrDashboardReports.loadHiveLinearReportData(rrDashboardReports.getReportSQL(), + userId, 2, request); ds = rrDashboardReports.loadChartData(userId,request); } } - long totalTime = System.currentTimeMillis() - currentTime; formFields = AppUtils.getRequestNvlValue(request, FORM_FIELDS); if(buildReportdata) { - rrDashboardReports.logReportRun(userId, String.valueOf(totalTime),formFields); - rrDashboardReports.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_EXECUTION_TIME, formFields); + /* + * rrDashboardReports.logReportRun(userId, String.valueOf(totalTime), + * formFields); rrDashboardReports.logReportExecutionTime(userId, + * String.valueOf(totalTime), AppConstants.RLA_EXECUTION_TIME, formFields); + */ } - - 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(!entry.getValue().toString().toLowerCase().startsWith("c")) { + 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) { - reportDataMap.put(new Integer(entry.getKey().toString())+"_"+rrDashboardReports.getReportID(), rd); - reportChartDataMap.put(new Integer(entry.getKey().toString())+"_"+rrDashboardReports.getReportID(), ds); + reportDataMap.put( + new Integer(entry.getKey().toString()) + "_" + rrDashboardReports.getReportID(), rd); + reportChartDataMap.put( + new Integer(entry.getKey().toString()) + "_" + rrDashboardReports.getReportID(), ds); + } } } @@ -417,7 +438,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME, rr1); } - return "raptor/report_dashboard_run_container.jsp"; + return "{\"return\" : \"raptor/report_dashboard_run_container.jsp\"}"; } else { fromDashboard = AppUtils.getRequestFlag(request,"fromDashboard"); if(isDashboardInDrillDownList(request)) @@ -465,14 +486,11 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { int requestFlag = DASH; ReportHandler rh = new ReportHandler(); request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REP_ID, reportID); - //rr = null; // get dashboard HTML from report runtime. getListOfReportsFromDashBoardHTML String strHTML = rr.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 = ""; @@ -511,17 +529,12 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { downloadLimit = (rrDashboardReports.getMaxRowsInExcelDownload()>0)?rrDashboardReports.getMaxRowsInExcelDownload():Globals.getDownloadLimit(); - if (new Integer(nvl(rrDashboardReports.getDataContainerWidth(),"100")).intValue() >100) - widthFlag = 1; - if (new Integer(nvl(rrDashboardReports.getDataContainerHeight(),"100")).intValue() >100) - heightFlag = 1; + if (new Integer(nvl(rrDashboardReports.getDataContainerWidth(),"100")).intValue() >100) widthFlag = 1; + if (new Integer(nvl(rrDashboardReports.getDataContainerHeight(),"100")).intValue() >100) heightFlag = 1; if(record == 1) { if(rrDashboardReports.getReportFormFields()!=null && rrDashboardReports.getReportFormFields().size()>0) { buildReportdata = false; - if(rDisplayContent){ - buildReportdata = true; - } - + if(rDisplayContent) buildReportdata = true; } } if(buildReportdata) { @@ -551,30 +564,21 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { if(buildReportdata) { 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)); } } - /*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_REPORT_RUNTIME, rr); //changing session to request if(buildReportdata) { request.getSession().setAttribute(AppConstants.SI_DASHBOARD_DISPLAYTYPE_MAP, new TreeMap(reportDisplayTypeMap)); request.getSession().setAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP, new TreeMap(reportDataMap)); request.getSession().setAttribute(AppConstants.SI_DASHBOARD_CHARTDATA_MAP, new TreeMap(reportChartDataMap)); - } - //request.setAttribute(AppConstants.SI_REPORT_RUNTIME, rr1); - //return nextPage; + } } else { // Ends -// debugLogger.debug("Action Handler *****************" + new java.util.Date()+ " " + isGoBackAction); ReportHandler rh = new ReportHandler(); //rr = null; // COMMENT THIS LINE boolean resetParams = AppUtils.getRequestFlag(request, @@ -593,42 +597,18 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } return nextPage; } - - /*if (isGoBackAction) { -// debugLogger.debug("Report back in action handler " + ((ReportRuntime) request.getSession().getAttribute( -// AppConstants.SI_REPORT_RUN_BACKUP))!=null?((ReportRuntime) request.getSession().getAttribute( -// AppConstants.SI_REPORT_RUN_BACKUP)).getReportID():((ReportRuntime) request.getSession().getAttribute( -// AppConstants.SI_REPORT_RUN_BACKUP))); - rr = null; - rr = getReportRuntimeFromBackup(request); - if (rr == null) - throw new Exception("[ActionHandler.reportRun] Report backup not found"); - reportID = rr.getReportID(); - } else {*/ logger.debug(EELFLoggerDelegate.debugLogger, ("Ocurring during Schedule ")); //TODO differentiate Schedule with other actions -// if(isEmailAttachment) { -// -// } else { -// -// } + rr = rh.loadReportRuntime(request, reportID); //setParamValues called for Drilldown to display formfield - //rr.setParamValues(request, false,true); //} // else ArrayList aL = (ArrayList)request.getSession().getAttribute(AppConstants.DRILLDOWN_REPORTS_LIST); ReportRuntime aLR = null; if(aL != null) { -// for (int i = 1; i < aL.size(); i++) { -// aLR = (ReportRuntime) aL.get(i); -// if (!aLR.getReportID().equals(reportID)) { -// request.setAttribute(AppConstants.RI_SHOW_BACK_BTN, "Y"); -// } -// } -// if(reportID.equals(reportIDFromSession)) { aLR = (ReportRuntime) aL.get(0); if (aLR!=null && !aLR.getReportID().equals(reportID)) { request.setAttribute(AppConstants.RI_SHOW_BACK_BTN, "Y"); @@ -668,7 +648,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { String limit = nvl(request.getParameter("download_limit"),"1000"); downloadLimit = Integer.parseInt(limit); } - //if (action.startsWith("mobile")) rr.setPageSize(5); long reportTime = System.currentTimeMillis(); if (!rr.getReportType().equals(AppConstants.RT_HIVE)) rd = rr.loadReportData(pageNo, userId, downloadLimit,request,false /*download*/); @@ -677,12 +656,9 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] ------->Time Taken for the loading report data --- " + (System.currentTimeMillis() - reportTime))); ReportData rd_whole = null; boolean hideReportMap = rr.isDisplayOptionHideMap()||AppUtils.getRequestNvlValue(request, "noMap").equals("Y"); -/* if (Globals.getMapAllowedYN().equals("Y") && !hideReportMap && rr.getReportMap()!=null){ - rd_whole = rr.loadReportData(-1, userId, downloadLimit,request); - } -*/ + + request.getSession().setAttribute(AppConstants.RI_REPORT_DATA, rd); - //if (Globals.getMapAllowedYN().equals("Y") && !hideReportMap && (rr.getReportMap()!=null && rr.getReportMap().getLatColumn()!=null && rr.getReportMap().getLongColumn()!=null)) { if(rr!=null && rr.getReportType().equals(AppConstants.RT_LINEAR)) { String sqlWhole = rr.getReportDataSQL(userId, downloadLimit, request); request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sqlWhole); @@ -727,7 +703,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { rr.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_DOWNLOAD_TEXT, formFields); } else { - //rr.logReportRun(userId, String.valueOf(totalTime),formFields); if(rd!=null && !action.equals("report.run.container")) rr.logReportExecutionTime(userId, String.valueOf(totalTime),AppConstants.RLA_EXECUTION_TIME, formFields); } @@ -736,12 +711,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { rr.logReportExecutionTimeFromLogList(userId, String.valueOf(totalTime),formFields); } -/* if((String) request.getSession().getAttribute(AppConstants.SI_DASHBOARD_REP_ID)!=null) { - reportID = (String) request.getSession().getAttribute(AppConstants.SI_DASHBOARD_REP_ID); - ReportRuntime rrDash = rh1.loadReportRuntime(request, reportID, true, 1); - request.getSession().setAttribute(AppConstants.SI_REPORT_RUNTIME, rrDash); - } -*/ if(rr.isDrillDownURLInPopupPresent()) { request.getSession().setAttribute(PARENT+rr.getReportID()+"_rr", rr); request.getSession().setAttribute(PARENT+rr.getReportID()+"_rd", rd); @@ -783,8 +752,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { ReportJSONRuntime reportJSONRuntime = rr.createReportJSONRuntime(request, rd); ObjectMapper mapper = new ObjectMapper(); - //mapper.setVisibility(JsonMethod.FIELD, Visibility.ANY); - //mapper.setVisibilityChecker(mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE)); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); String jsonInString = ""; @@ -805,13 +772,15 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { else rr.logReportExecutionTime(userId, "", "On Demand: " + AppConstants.RLA_ERROR, formFields); } - + ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime(); + if (rr != null) { + reportJSONRuntime = rr.createReportJSONRuntime(request, rd); + } ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime(); + errorJSONRuntime.setAllowEdit(reportJSONRuntime.isAllowEdit()); errorJSONRuntime.setErrormessage(e.getMessage()); errorJSONRuntime.setStacktrace(getStackTrace(e)); ObjectMapper mapper = new ObjectMapper(); - //mapper.setVisibility(JsonMethod.FIELD, Visibility.ANY); - //mapper.setVisibilityChecker(mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE)); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); String jsonInString = ""; @@ -825,12 +794,15 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } catch (RaptorException ex) { nextPage = (new ErrorHandler()).processFatalError(request, ex); + ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime(); + if (rr != null) { + reportJSONRuntime = rr.createReportJSONRuntime(request, rd); + } ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime(); + errorJSONRuntime.setAllowEdit(reportJSONRuntime.isAllowEdit()); errorJSONRuntime.setErrormessage(ex.getMessage()); errorJSONRuntime.setStacktrace(getStackTrace(ex)); ObjectMapper mapper = new ObjectMapper(); - //mapper.setVisibility(JsonMethod.FIELD, Visibility.ANY); - //mapper.setVisibilityChecker(mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE)); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); String jsonInString = ""; @@ -841,15 +813,19 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } return jsonInString; } - //nextPage = (new ErrorHandler()).processFatalError(request, e); } catch (Exception t) { logger.error(EELFLoggerDelegate.errorLogger,t.getMessage(), t); + + ReportJSONRuntime reportJSONRuntime = new ReportJSONRuntime(); + if (rr != null) { + reportJSONRuntime = rr.createReportJSONRuntime(request, rd); + } + ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime(); + errorJSONRuntime.setAllowEdit(reportJSONRuntime.isAllowEdit()); errorJSONRuntime.setErrormessage(t.toString()); errorJSONRuntime.setStacktrace(getStackTrace(t)); ObjectMapper mapper = new ObjectMapper(); - //mapper.setVisibility(JsonMethod.FIELD, Visibility.ANY); - //mapper.setVisibilityChecker(mapper.getVisibilityChecker().with(JsonAutoDetect.Visibility.NONE)); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); String jsonInString = ""; @@ -862,7 +838,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { return jsonInString; } - //return nextPage; } // reportRun public static String getStackTrace(Throwable aThrowable) { @@ -891,7 +866,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { for(Iterator iter = set.iterator(); iter.hasNext(); ) { Map.Entry entry = (Entry) iter.next(); if (((ReportRuntime) entry.getValue()).getReportID().equals(reportID)) { - return new Integer(((String) entry.getKey()).substring(2)); + return new Integer(((String) entry.getKey()).substring(((String) entry.getKey()).indexOf("_")+1)); } } return null; @@ -1110,17 +1085,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { /****Remove Report Data from Session when Javascript throw error on onSubmit***/ public String removeReportDataFromSession (HttpServletRequest request, String nextPage) { HttpSession session = request.getSession(false); -/* if (session.getAttribute(AppConstants.RI_REPORT_DATA)!=null) - request.getSession().removeAttribute(AppConstants.RI_REPORT_DATA); - if (request.getAttribute(AppConstants.RI_REPORT_DATA)!=null) - request.removeAttribute(AppConstants.RI_REPORT_DATA); - if (session.getAttribute(AppConstants.RI_CHART_DATA)!=null) - request.getSession().removeAttribute(AppConstants.RI_CHART_DATA); - if (request.getAttribute(AppConstants.RI_CHART_DATA)!=null) - request.removeAttribute(AppConstants.RI_CHART_DATA); -*/ /*if (session.getAttribute(AppConstants.SI_REPORT_RUNTIME)!=null) - request.getSession().removeAttribute(AppConstants.SI_REPORT_RUNTIME);*/ - //request.setAttribute(AppConstants.RI_RESET_ACTION, "Y"); return nextPage; } // processScheduleDelete @@ -1185,10 +1149,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute( AppConstants.SI_REPORT_DEFINITION); WizardSequence ws = rdef.getWizardSequence(); - //debugLogger.debug("Step Count " + ws.getStepCount()); - //debugLogger.debug("Dashboard " + ((ws instanceof WizardSequenceDashboard) ? ws.getStepCount(): "Not a Dashboard")); - //debugLogger.debug("GO TO STEP LENGTH " + goToStep.length()); - //debugLogger.debug("NumDash Cols in Action Handler " + AppUtils.getRequestNvlValue(request, "numDashCols")); if (goToStep.length() > 0) ws.performGoToStep(goToStep); else @@ -1205,7 +1165,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } // reportWizard public String refreshCache ( HttpServletRequest request, String nextPage ) { - //DataCache.refreshReportTableSources(); removeVariablesFromSession(request); DataCache.refreshAll(); Globals.getAppUtils().resetUserCache(); @@ -1218,8 +1177,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { ReportDefinition rdef = ReportDefinition.createBlank(request); request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef); - // request.setAttribute(AppConstants.RI_CUR_STEP, - // AppConstants.WS_DEFINITION); DataCache.refreshReportTableSources(); request.getSession().removeAttribute("remoteDB"); } catch (RaptorException e) { @@ -1262,8 +1219,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { rdef.getWizardSequence().performGoToStep(AppConstants.WS_DEFINITION); request.getSession().setAttribute(AppConstants.SI_REPORT_DEFINITION, rdef); - // request.setAttribute(AppConstants.RI_CUR_STEP, - // AppConstants.WS_DEFINITION); } catch (RaptorException e) { nextPage = (new ErrorHandler()).processFatalError(request, e); } @@ -1294,12 +1249,10 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { ReportLoader.deleteReportRecord(reportID); return "{\"deleted\":true}"; - //nextPage = reportSearchExecute(request, nextPage); } catch (RaptorException e) { nextPage = (new ErrorHandler()).processFatalError(request, e); } - //return nextPage; return "{\"deleted\":false}"; } // reportDelete @@ -1377,8 +1330,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { value = (String) entry.getValue(); } // added so empty string would be treated as null value if not given in single quotes. - if(value==null || value.trim().length()<=0) - value="NULL"; + if(value==null || value.trim().length()<=0) value="NULL"; SQL = Utils.replaceInString(SQL, "["+entry.getKey()+"]", Utils.oracleSafe(value)); } if(request.getParameter(ff.getFieldName())!=null) { @@ -1389,12 +1341,8 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { lookup = new IdNameSql(-1,SQL,lu.getDefaultSQL()); lookup.setOldSql(oldSQL); } - //lookup.loadData("0"); } - if(lookup instanceof IdNameSql){ - ((IdNameSql)lookup).setDataSizeUsedinPopup(-3); // -3 indicates to run the count sql for pagination. - } - + if(lookup instanceof IdNameSql) ((IdNameSql)lookup).setDataSizeUsedinPopup(-3); // -3 indicates to run the count sql for pagination. } if(lookup instanceof IdNameSql) { ((IdNameSql)lookup).loadUserData(request.getParameter(AppConstants.RI_NEXT_PAGE), @@ -1584,8 +1532,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { request.setAttribute("msg_align", " align=center"); request.setAttribute(AppConstants.RI_PAGE_TITLE, "Test Scheduler Condition"); - // request.setAttribute(AppConstants.RI_PAGE_SUBTITLE, ...); - //String query = "SELECT 1 FROM DUAL WHERE EXISTS (" + sql + ")"; String query = Globals.getTestSchedCondPopup(); query = query.replace("[sql]", sql); @@ -1595,13 +1541,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { String remoteDbPrefix = (remoteDb != null && !remoteDb.equalsIgnoreCase("null")) ? remoteDb : rdef.getDBInfo(); ds = ConnectionUtils.getDataSet(sql, remoteDbPrefix); - // if ( (remoteDbPrefix!=null) && - // (!remoteDbPrefix.equals(AppConstants.DB_LOCAL))) { - // Globals.getRDbUtils().setDBPrefix(remoteDbPrefix); - // ds = RemDbUtils.executeQuery(query); - // } - // else - // ds = DbUtils.executeQuery(query); if (ds.getRowCount() == 0) request .setAttribute(AppConstants.RI_FORMATTED_SQL, @@ -1611,7 +1550,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { .setAttribute(AppConstants.RI_FORMATTED_SQL, "<br><b>Condition satisfied</b> - email notification will be send.<br><br>"); } catch (Exception e) { - // nextPage = (new ErrorHandler()).processFatalError(request, e); request.setAttribute(AppConstants.RI_FORMATTED_SQL, "<br><b>SQL ERROR</b> " + e.getMessage() + "<br>Email notification will NOT be send.<br><br>"); } @@ -1642,13 +1580,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { FormFieldType fft = (FormFieldType) iter.next(); String fieldId = fft.getFieldId(); String fieldDisplay = rdef.getFormFieldDisplayName(fft); - /* - * if(paramValues.isParameterMultiValue(fieldId)) - * generatedSQL = Utils.replaceInString(generatedSQL, - * fieldDisplay, nvl(formatListValue((String) - * paramValues.get(fieldId), null, false, false, null), - * "NULL")); else - */ sql = Utils.replaceInString(sql, fieldDisplay, "NULL"); } // for } // if @@ -1672,25 +1603,13 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } if(session != null ) { for (int i = 0; i < sessionParameters.length; i++) { - //if(!sessionParameters[i].startsWith("ff")) - //sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i].toUpperCase()) ); - //else { logger.debug(EELFLoggerDelegate.debugLogger, (" Session " + " sessionParameters[i] " + sessionParameters[i] + " " + (String)session.getAttribute(sessionParameters[i]))); sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) ); - //} } } logger.debug(EELFLoggerDelegate.debugLogger, ("After testRunSQL " + sql)); ds = ConnectionUtils.getDataSet(sql, remoteDbPrefix, true); - // if ( (remoteDbPrefix!=null) && - // (!remoteDbPrefix.equals(AppConstants.DB_LOCAL))) { - // Globals.getRDbUtils().setDBPrefix(remoteDbPrefix); - // ds = RemDbUtils.executeQuery(sql, - // Globals.getDefaultPageSize()+1); - // } - // else - // ds = DbUtils.executeQuery(sql, Globals.getDefaultPageSize()+1); if (chkFormFieldSQL && ds.getRowCount() > 0) { String id = ds.getString(0, "id"); String name = ds.getString(0, "name"); @@ -1749,20 +1668,13 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { ReportRuntime rr = null; if(!isFromSchedule) { rr = (ReportRuntime) request.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME); - if(rr!=null) - AppUtils.getUserEmail(request); + if(rr!=null) AppUtils.getUserEmail(request); } String scheduleId = ""; if(isFromSchedule) { String reportID = null; String report_email_sent_log_id = AppUtils.getRequestValue(request, "log_id"); - /*String query = "Select user_id, rep_id from CR_REPORT_EMAIL_SENT_LOG" + - " where rownum = 1" + - " and gen_key='"+pdfAttachmentKey.trim()+"'" + - " and log_id ="+report_email_sent_log_id.trim() + - " and (sysdate - sent_date) < 1 ";*/ - String query = Globals.getDownloadAllEmailSent(); query = query.replace("[pdfAttachmentKey.trim()]", pdfAttachmentKey.trim()); query = query.replace("[report_email_sent_log_id.trim()]", report_email_sent_log_id.trim()); @@ -1787,7 +1699,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { String d_sql = Globals.getDownloadAllGenKey(); d_sql = d_sql.replace("[pdfAttachmentKey]", pdfAttachmentKey); - //ds = DbUtils.executeQuery("select schedule_id from cr_report_email_sent_log u where U.GEN_KEY = '"+ pdfAttachmentKey + "'"); ds = DbUtils.executeQuery(d_sql); for (int i = 0; i < ds.getRowCount(); i++) { @@ -1798,13 +1709,9 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { String fileName = FilenameUtils.normalize(rr.getReportID()+"_"+userId+"_"+timestamp); boolean flag = false; logger.debug(EELFLoggerDelegate.debugLogger, (""+Utils.isDownloadFileExists(rr.getReportID()+"_"+userId+"_"+dateStr))); - // if(Utils.isDownloadFileExists(rr.getReportID()+"_"+userId+"_"+dateStr)) { - // flag = true; - // } if(flag){ String strFileName = Utils.getLatestDownloadableFile(rr.getReportID()+"_"+userId+"_"+dateStr); - //debugLogger.debug("File Name " + strFileName); StringBuffer messageBuffer = new StringBuffer(""); messageBuffer.append("Download data file using the following link<BR>"); messageBuffer.append("<a href=\"" + request.getContextPath() + "/raptor/dwnld/data/" + @@ -1841,8 +1748,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { logger.debug(EELFLoggerDelegate.debugLogger, ("************************")); logger.debug(EELFLoggerDelegate.debugLogger, (rr.parseReportSQL(rr.getWholeSQL()))); xmlOut.println(rr.parseReportSQL(rr.getWholeSQL())); - //xmlOut.println("******************"); - //xmlOut.println(rr.getWholeSQL()); xmlOut.flush(); xmlOut.close(); } catch (IOException e) {logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), e);} @@ -1859,7 +1764,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { logger.debug(EELFLoggerDelegate.debugLogger, ("Command " + command)); Process downloadProcess = runtime.exec(command.toString()); logger.debug(EELFLoggerDelegate.debugLogger, ("Command Executed ")); - //Connection connection = DbUtils.getConnection(); Enumeration enum1 = rr.getParamKeys(); String value = ""; String paramStr = ""; @@ -1876,26 +1780,9 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { StringBuffer retrieveUserEmailQry = null; ArrayList userEmailList = new ArrayList(); if(nvl(scheduleId).length()>0) { - /*retrieveUserEmailQry = new StringBuffer(); - retrieveUserEmailQry.append(" SELECT "); - retrieveUserEmailQry.append(" au.user_id "); - retrieveUserEmailQry.append(" FROM "); - retrieveUserEmailQry.append(" (SELECT rs.schedule_id, rs.rep_id FROM cr_report_schedule rs WHERE rs.enabled_yn='Y' AND rs.run_date IS NOT NULL "); - retrieveUserEmailQry.append(" AND rs.schedule_id = " + scheduleId + " ) x, cr_report r, app_user au "); - retrieveUserEmailQry.append(" WHERE "); - retrieveUserEmailQry.append("x.rep_id = r.rep_id "); - retrieveUserEmailQry.append(" AND au.user_id IN (SELECT rsu.user_id FROM cr_report_schedule_users rsu WHERE rsu.schedule_id = x.schedule_id and rsu.schedule_id = " + scheduleId ); - retrieveUserEmailQry.append(" UNION "); - retrieveUserEmailQry.append(" SELECT ur.user_id FROM fn_user_role ur "); - retrieveUserEmailQry.append(" WHERE ur.role_id IN "); - retrieveUserEmailQry.append(" (SELECT rsu2.role_id FROM cr_report_schedule_users rsu2 "); - retrieveUserEmailQry.append(" WHERE rsu2.schedule_id = x.schedule_id and "); - retrieveUserEmailQry.append(" rsu2.schedule_id = "+ scheduleId + ")) ");*/ String r_sql = Globals.getDownloadAllRetrieve(); r_sql = r_sql.replace("[scheduleId]", scheduleId); - - // DataSet ds = DbUtils.executeQuery(retrieveUserEmailQry.toString()); DataSet ds = DbUtils.executeQuery(r_sql); for (int i = 0; i < ds.getRowCount(); i++) { @@ -1903,7 +1790,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } } - // String insertQry = "insert into cr_report_dwnld_log (user_id,rep_id,file_name,dwnld_start_time,filter_params) values (?,?,?,?,?)"; String insertQry = Globals.getDownloadAllInsert(); @@ -1936,39 +1822,13 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } catch (Exception ex) { throw new RaptorException (ex); } - //DbUtils.commitTransaction(connection); - //DbUtils.clearConnection(connection); - - - -// debugLogger.debug("|"+downloadProcess.toString() + "|"); -// if (downloadProcess == null) -// throw new Exception("unable to create a process for command:" + -// command); -// int retCode= 1; -// try { -// retCode= downloadProcess.waitFor(); -// } catch (InterruptedException e){ -// e.printStackTrace(); -// } -// debugLogger.debug("retCode " + retCode); -// Process child = rtime.exec("/bin/bash"); -// BufferedWriter outCommand = new BufferedWriter(new -// OutputStreamWriter(child.getOutputStream())); -// outCommand.write(Globals.getShellScriptName()); -// outCommand.flush(); -// int retCode = child.waitFor(); -// debugLogger.debug("RetCode " + retCode); - //request.setAttribute(MESSAGE, "Shell Script is running in the background. You'll get an email once it is done"); } return nextPage; } public String getChildDropDown(HttpServletRequest request, String nextPage) throws RaptorRuntimeException { - if(request.getParameter("firstTime") != null){ - return nextPage; - } + if(request.getParameter("firstTime") != null) { return nextPage; } /*ReportRuntime rr = (ReportRuntime) request.getSession().getAttribute( AppConstants.SI_REPORT_RUNTIME); @@ -2033,11 +1893,25 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { } + private TreeMap getListOfReportsFromDashBoardJson(String jsonString) throws Exception { + HashMap hashReports = new HashMap(); + ObjectMapper mapper = new ObjectMapper(); + + TypeReference<List<DashboardChildReport>> mapType = new TypeReference<List<DashboardChildReport>>() { + }; + List<DashboardChildReport> reportList = mapper.readValue(jsonString, mapType); + int index = 1; + for (DashboardChildReport childRep : reportList) { + String str = childRep.getHasContent().get("id"); + hashReports.put(index, (str.substring(0).toLowerCase().startsWith("chart") ? "c" : "d") + + str.substring(str.indexOf("#") + 1, str.length())); + index++; + } + return new TreeMap(hashReports); + } + private TreeMap getListOfReportsFromDashBoardHTML(String htmlString) { - //String sourcestring = "<table border=1><tr><td>[Report#123]</td><td>[Report#124]</td></tr><tr><td>[Report#125]</td><td>[Report#126]</td></tr></table>"; String sourcestring = htmlString; - //Pattern re = Pattern.compile("([a-z]+)\\[([a-z]+)([=<>]+)([a-z]+)\\]",Pattern.CASE_INSENSITIVE); - //Pattern re = Pattern.compile("\\[([R][e][p][o][r][t][#])[(*)]\\]"); Pattern re = Pattern.compile("\\[(.*?)\\]"); //\\[(.*?)\\] Matcher m = re.matcher(sourcestring); HashMap hashReports = new HashMap(); @@ -2045,24 +1919,10 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { while (m.find()){ for( int groupIdx = 0; groupIdx < m.groupCount(); groupIdx++ ){ String str = m.group(groupIdx); - //System.out.println(str); hashReports.put(new String(Integer.toString(mIdx+1)), (str.substring(1).toLowerCase().startsWith("chart")?"c":"d") + str.substring(str.indexOf("#")+1, str.length()-1)); } mIdx++; } - // Sorting HashMap based on Keys - /*List mapKeys = new ArrayList(hashReports.keySet()); - List mapValues = new ArrayList(hashReports.values()); - hashReports.clear(); - hashReports = null; - hashReports = new HashMap(); - - TreeSet sortedSet = new TreeSet(mapKeys); - Object[] sortedArray = sortedSet.toArray(); - int size = sortedArray.length; - for (int i=0; i<size; i++) { - hashReports.put(sortedArray[i], mapValues.get(mapKeys.indexOf(sortedArray[i]))); - }*/ return new TreeMap(hashReports); } @@ -2201,8 +2061,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { // "[ReportRuntime.loadLinearReportData] The number of visible columns // does not match the number of data columns"); //TODO: This should be optimized to accept -1 for flat file download - if(maxRows > totalRows) - maxRows = totalRows; + if(maxRows > totalRows) maxRows = totalRows; ArrayList reportDataList = new ArrayList(); for (int r = 0; r < maxRows; r++) { DataRow dr = new DataRow(); @@ -2329,4 +2188,4 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { return ""; } -} // ActionHandler +} // ActionHandler
\ No newline at end of file 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 30ec7b15..278f6739 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 @@ -49,6 +49,7 @@ import org.onap.portalsdk.analytics.error.RaptorException; import org.onap.portalsdk.analytics.error.ReportSQLException; import org.onap.portalsdk.analytics.model.definition.ReportDefinition; import org.onap.portalsdk.analytics.model.runtime.ErrorJSONRuntime; +import org.onap.portalsdk.analytics.model.runtime.ReportJSONRuntime; import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; import org.onap.portalsdk.analytics.system.AppUtils; import org.onap.portalsdk.analytics.system.Globals; @@ -132,6 +133,7 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime(); errorJSONRuntime.setErrormessage(e.toString()); errorJSONRuntime.setStacktrace(getStackTrace(e)); + errorJSONRuntime.setAllowEdit(isAllowEdit(request)); ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -146,6 +148,24 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { return jsonInString; } // processFatalError + private boolean isAllowEdit(HttpServletRequest request) { + HttpSession session = request.getSession(); + ReportRuntime rr = (ReportRuntime) session.getAttribute(AppConstants.SI_REPORT_RUNTIME); + boolean allowEdit = false; + String userId = AppUtils.getUserID(request); + try { + if( AppUtils.isAdminUser(request) || AppUtils.isSuperUser(request) ) { + allowEdit = true; + } else { + if(rr.getOwnerID().equals(userId)) allowEdit = true; + else allowEdit = false; + } + } catch (RaptorException ex) { + allowEdit = false; + } + return allowEdit; + } + public static String getStackTrace(Throwable aThrowable) { Writer result = new StringWriter(); PrintWriter printWriter = new PrintWriter(result); 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 298f2517..8605f208 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 @@ -1161,8 +1161,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setClassifier(classifiers); String dateAttrColId = AppUtils.getRequestNvlValue(request, "timeAttribute"); String timeFormat = AppUtils.getRequestNvlValue(request, "timeFormat"); - if(timeFormat.equals("Default")) - timeFormat = "yyyy-MM-dd HH:mm:ss"; + if(timeFormat.equals("Default")) timeFormat = "yyyy-MM-dd HH:mm:ss"; String forecastingPeriod = AppUtils.getRequestNvlValue(request, "forecastingPeriod"); String[] forecastCols = request.getParameterValues("forecastCol"); @@ -1177,8 +1176,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { dct = (DataColumnType) iter.next(); if(dct.getColId().equals(dateAttrColId)) { dct.setDataMiningCol(AppConstants.DM_DATE_ATTR); - if(timeFormat!=null) - rdef.setForecastingTimeFormat(timeFormat); + if(timeFormat!=null) rdef.setForecastingTimeFormat(timeFormat); break; } } |