diff options
Diffstat (limited to 'ecomp-sdk')
16 files changed, 560 insertions, 502 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/RaptorObject.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/RaptorObject.java index 8b968cc8..fd5fdba1 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/RaptorObject.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/RaptorObject.java @@ -44,7 +44,7 @@ public class RaptorObject extends java.lang.Object { } protected String nvl(String s, String sDefault) { - return nvl(s).equals("") ? sDefault : s; + return nvl(s).isEmpty() ? sDefault : s; } protected static String nvls(String s) { @@ -52,11 +52,11 @@ public class RaptorObject extends java.lang.Object { } protected static String nvls(String s, String sDefault) { - return nvls(s).equals("") ? sDefault : s; + return nvls(s).isEmpty() ? sDefault : s; } protected boolean getFlagInBoolean(String s) { - return nvl(s).toUpperCase().startsWith("Y") || nvl(s).toLowerCase().equals("true"); + return nvl(s).toUpperCase().startsWith("Y") || "true".equalsIgnoreCase(nvl(s)); } } // RaptorObject diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/Controller.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/Controller.java index 24f66092..b26beb7a 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/Controller.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/Controller.java @@ -37,10 +37,12 @@ */ package org.onap.portalsdk.analytics.controller; +import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import javax.servlet.ServletContext; +import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -51,7 +53,12 @@ import org.onap.portalsdk.analytics.util.AppConstants; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; public class Controller extends org.onap.portalsdk.analytics.RaptorObject { - + + private static final String CONTROLLER_INVALID_ACTION = + "[Controller.processRequest]Invalid raptor action ["; + private static final String CONTROLLER_INSTANTIATE_EXCEPTION = + "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "; + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(Controller.class); public Controller() { @@ -70,11 +77,11 @@ public class Controller extends org.onap.portalsdk.analytics.RaptorObject { if (action == null) throw new RaptorRuntimeException("Action not found"); } catch (RaptorException e) { - logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action [" + actionKey + logger.debug(EELFLoggerDelegate.debugLogger, (CONTROLLER_INVALID_ACTION + actionKey + "]. RaptorException: " + e.getMessage())); return (new ErrorHandler()).processFatalError(request, new RaptorRuntimeException( - "[Controller.processRequest]Invalid raptor action [" + actionKey + CONTROLLER_INVALID_ACTION + actionKey + "]. Exception: " + e.getMessage())); } @@ -94,34 +101,34 @@ public class Controller extends org.onap.portalsdk.analytics.RaptorObject { return (String) handlerMethod.invoke(handler, paramValues); } catch (ClassNotFoundException e) { - logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action [" + actionKey + logger.debug(EELFLoggerDelegate.debugLogger, (CONTROLLER_INVALID_ACTION + actionKey + "]. ClassNotFoundException: " + e.getMessage())); return (new ErrorHandler()).processFatalError(request, new RaptorRuntimeException( - "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: " + CONTROLLER_INSTANTIATE_EXCEPTION + e.getMessage())); } catch (IllegalAccessException e) { - logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action [" + actionKey + logger.debug(EELFLoggerDelegate.debugLogger, (CONTROLLER_INVALID_ACTION + actionKey + "]. IllegalAccessException: " + e.getMessage())); return (new ErrorHandler()).processFatalError(request, new RaptorRuntimeException( - "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: " + CONTROLLER_INSTANTIATE_EXCEPTION + e.getMessage())); }catch (InstantiationException e) { - logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action [" + actionKey + logger.debug(EELFLoggerDelegate.debugLogger, (CONTROLLER_INVALID_ACTION + actionKey + "]. InstantiationException: " + e.getMessage())); return (new ErrorHandler()).processFatalError(request, new RaptorRuntimeException( - "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: " + CONTROLLER_INSTANTIATE_EXCEPTION + e.getMessage())); }catch (NoSuchMethodException e) { - logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action [" + actionKey + logger.debug(EELFLoggerDelegate.debugLogger, (CONTROLLER_INVALID_ACTION + actionKey + "]. NoSuchMethodException: " + e.getMessage())); return (new ErrorHandler()).processFatalError(request, new RaptorRuntimeException( - "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: " + CONTROLLER_INSTANTIATE_EXCEPTION + e.getMessage())); }catch (InvocationTargetException e) { - logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action [" + actionKey + logger.debug(EELFLoggerDelegate.debugLogger, (CONTROLLER_INVALID_ACTION + actionKey + "]. InvocationTargetException: " + e.getMessage())); return (new ErrorHandler()).processFatalError(request, new RaptorRuntimeException( - "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: " + CONTROLLER_INSTANTIATE_EXCEPTION + e.getMessage())); } } // processRequest @@ -134,7 +141,7 @@ public class Controller extends org.onap.portalsdk.analytics.RaptorObject { } // handleRequest public void handleRequest(String actionKey, HttpServletRequest request, - HttpServletResponse response, ServletContext servletContext) throws Exception { + HttpServletResponse response, ServletContext servletContext) throws IOException,ServletException { servletContext.getRequestDispatcher("/" + processRequest(actionKey, request)).forward( request, response); } // handleRequest 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 403c6b6b..1a31e604 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 @@ -68,13 +68,12 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { } public void processError(HttpServletRequest request, String errorMsg) { - //Log.write(errorMsg, 2); logger.error(EELFLoggerDelegate.debugLogger, (errorMsg)); - ArrayList error_list = (ArrayList) request.getAttribute(AppConstants.RI_ERROR_LIST); - if (error_list == null) - error_list = new ArrayList(1); - error_list.add(errorMsg); - request.setAttribute(AppConstants.RI_ERROR_LIST, error_list); + ArrayList errorList = (ArrayList) request.getAttribute(AppConstants.RI_ERROR_LIST); + if (errorList == null) + errorList = new ArrayList(1); + errorList.add(errorMsg); + request.setAttribute(AppConstants.RI_ERROR_LIST, errorList); } // processError public void processError(HttpServletRequest request, RaptorException e) { @@ -83,7 +82,7 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { private String getSessionLog(HttpServletRequest request) { String[] sessionVariablesToLog = Globals.getLogVariablesInSession().split(","); - StringBuffer sessionLogStrBuf = new StringBuffer("\n"); + StringBuilder sessionLogStrBuf = new StringBuilder("\n"); sessionLogStrBuf.append("***** ADDITIONAL INFORMATION ******"); HttpSession session = request.getSession(); ReportRuntime rr = (ReportRuntime) session.getAttribute(AppConstants.SI_REPORT_RUNTIME); @@ -106,7 +105,6 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { return sessionLogStrBuf.toString(); } public String processFatalError(HttpServletRequest request, RaptorException e) { - //Log.write("Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage()), 1); logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage())+" "+ getSessionLog(request) + e.getMessage()),AlarmSeverityEnum.MAJOR); if (e instanceof ReportSQLException) { String errorSQL = ((ReportSQLException) e).getReportSQL(); @@ -120,28 +118,25 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { } // processFatalError public String processFatalErrorJSON(HttpServletRequest request, RaptorException e) { - //Log.write("Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage()), 1); logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] 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); } // if - //AppUtils.processErrorNotification(request, e); request.setAttribute(AppConstants.RI_EXCEPTION, e); ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime(); errorJSONRuntime.setErrormessage(e.toString()); 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 = ""; 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); ex.printStackTrace(); } @@ -155,7 +150,6 @@ public class ErrorHandler extends org.onap.portalsdk.analytics.RaptorObject { return result.toString(); } public String processFatalErrorWMenu(HttpServletRequest request, RaptorException e) { - //Log.write("Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage()), 1); logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] Fatal error [" + e.getClass().getName() + "]: " + nvl(e.getMessage())+" "+ getSessionLog(request) + e.getMessage()),AlarmSeverityEnum.MAJOR); if (e instanceof ReportSQLException) { String errorSQL = ((ReportSQLException) e).getReportSQL(); 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 47af1b71..f0829d29 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 @@ -33,7 +33,7 @@ * * ============LICENSE_END============================================ * - * + * */ package org.onap.portalsdk.analytics.controller; @@ -80,35 +80,36 @@ import org.onap.portalsdk.analytics.xmlobj.SemaphoreType; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; /**<HR/> - * This class is part of <B><I>RAPTOR (Rapid Application Programming Tool for OLAP Reporting)</I></B><BR/> + * This class is part of <B><I>RAPTOR (Rapid Application Programming Tool for OLAP Reporting)</I></B><BR/> * <HR/> * * --------------------------------------------------------------------------------------------------<BR/> - * <B>WizardProcessor.java</B> - This class is used to process the user input provided in the wizard.<BR/> + * <B>WizardProcessor.java</B> - This class is used to process the user input provided in the wizard.<BR/> * It is called in creation as well as updation process. It builds report xml via JAXB using user<BR/> * input. This is vital one, to store meta information of each report<BR/> * ---------------------------------------------------------------------------------------------------<BR/> * * * <U>Change Log</U><BR/><BR/> - * - * 31-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> For Time Series multi series property is exposed. </LI></UL> - * 28-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> If user login id is null, it would display user name when user is added for schedule. </LI></UL> - * 18-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> request Object is passed to prevent caching user/roles - Datamining/Hosting. </LI></UL> - * 12-Aug-2009 : Version 8.5 (Sundar); <UL><LI> For Line Charts too options are captured and rendering is customized. </LI></UL> - * 29-Jul-2009 : Version 8.4 (Sundar); <UL><LI> Maximum Excel Download size would be persisted if changed. </LI></UL> - * 14-Jul-2009 : Version 8.4 (Sundar); <UL><LI> Schedule feature is added to Dashboard Reports. </LI></UL> + * + * 31-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> For Time Series multi series property is exposed. </LI></UL> + * 28-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> If user login id is null, it would display user name when user is added for schedule. </LI></UL> + * 18-Aug-2009 : Version 8.5.1 (Sundar);<UL><LI> request Object is passed to prevent caching user/roles - Datamining/Hosting. </LI></UL> + * 12-Aug-2009 : Version 8.5 (Sundar); <UL><LI> For Line Charts too options are captured and rendering is customized. </LI></UL> + * 29-Jul-2009 : Version 8.4 (Sundar); <UL><LI> Maximum Excel Download size would be persisted if changed. </LI></UL> + * 14-Jul-2009 : Version 8.4 (Sundar); <UL><LI> Schedule feature is added to Dashboard Reports. </LI></UL> * 29-Jun-2009 : Version 8.4 (Sundar); <UL><LI> Options for <I>Compare to Previous year Chart</I> are processed.</LI> * <LI> In the Bar chart Last Occuring Series/Category can be plotted as Bar or Line Renderer. </LI> - * </UL> - * 22-Jun-2009 : Version 8.4 (Sundar); <UL><LI> processChart method is modified to accommodate creating - * Bar Charts, Time Difference Charts and adding generic chart options.</LI></UL> - * + * </UL> + * 22-Jun-2009 : Version 8.4 (Sundar); <UL><LI> processChart method is modified to accommodate creating + * Bar Charts, Time Difference Charts and adding generic chart options.</LI></UL> + * */ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WizardProcessor.class); + public static Calendar getCalendar(XMLGregorianCalendar xmlCalendar){ - // log.debug("Zone ID is " + xmlCalendar.getTimezone()); TimeZone timeZone = xmlCalendar.getTimeZone(xmlCalendar.getTimezone()); Calendar calendar = Calendar.getInstance(timeZone); calendar.set(Calendar.YEAR,xmlCalendar.getYear()); @@ -119,12 +120,12 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { calendar.set(Calendar.SECOND,xmlCalendar.getSecond()); return calendar; } - private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WizardProcessor.class); + public WizardProcessor() { } private String adjustDataType(String oracleDataType) { - return oracleDataType.equals("VARCHAR2") ? AppConstants.CT_CHAR : oracleDataType; + return "VARCHAR2".equals(oracleDataType) ? AppConstants.CT_CHAR : oracleDataType; // Probably should be expanded to convert any CHAR or VARCHAR type to // CT_CHAR, number type to CT_NUMBER and date to CT_DATE } // adjustDataType @@ -148,12 +149,12 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { String curStep = rdef.getWizardSequence().getCurrentStep(); String curSubStep = rdef.getWizardSequence().getCurrentSubStep(); - if (AppUtils.getRequestNvlValue(request, "showDashboardOptions").length()<=0) + if (AppUtils.getRequestNvlValue(request, "showDashboardOptions").length()<=0) request.setAttribute("showDashboardOptions", "F"); logger.debug(EELFLoggerDelegate.debugLogger, ("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^curStep " + curStep + " " + curSubStep + " " + action)); boolean reportUpdated = false; if (!action.equals(AppConstants.WA_BACK)) { - if (curStep.equals(AppConstants.WS_DEFINITION)) { + if (curStep.equals(AppConstants.WS_DEFINITION)) { reportUpdated = processDefinition(request); } else if (curStep.equals(AppConstants.WS_SQL)) { if (action.equals(AppConstants.WA_VALIDATE)) @@ -171,7 +172,6 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { reportUpdated = processColumnAddEdit(request, curSubStep .equals(AppConstants.WSS_EDIT) || curSubStep .equals(AppConstants.WA_MODIFY)); - //reportUpdated = processColumnAddEdit(request, true); } else if (curSubStep.equals(AppConstants.WSS_ADD_MULTI)) reportUpdated = processColumnAddMulti(request); @@ -197,7 +197,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { else if (action.equals(AppConstants.WSS_ADD_BLANK)) reportUpdated = processFormFieldBlank(request); else if (action.equals(AppConstants.WSS_INFO_BAR)) - reportUpdated = processFormFieldInfoBar(request); + reportUpdated = processFormFieldInfoBar(request); } else if (curStep.equals(AppConstants.WS_FILTERS)) { if (curSubStep.equals(AppConstants.WSS_ADD) || curSubStep.equals(AppConstants.WSS_EDIT)) @@ -236,15 +236,15 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { reportUpdated = processClearLog(request); } else if (curStep.equals(AppConstants.WS_SCHEDULE)) { reportUpdated = processSchedule(request, action); - } else if(curStep.equals(AppConstants.WS_DATA_FORECASTING)) { + } else if(curStep.equals(AppConstants.WS_DATA_FORECASTING)) { reportUpdated = processForecasting(request, action); - } + } /****For Report Maps - Start*****/ else if (curStep.equals(AppConstants.WS_MAP)) { reportUpdated = processMap(request, action); - } + } /****For Report Maps - End*****/ - + // else } if (reportUpdated) @@ -270,7 +270,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { .add(new IdNameValue(sem.getSemaphoreId(), sem.getSemaphoreName())); } // for - if (importedList.size() > 0) { + if (!importedList.isEmpty()) { request.setAttribute(AppConstants.RI_DATA_SET, importedList); persistReportDefinition(request, rdef); } // if @@ -294,7 +294,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.deleteSemaphore(semaphore); semaphore.setSemaphoreName(semaphoreName); semaphore.setSemaphoreType(semaphoreType); - + rdef.setSemaphore(semaphore); } @@ -308,36 +308,31 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { String[] fontColor = request.getParameterValues("fontColor"); String[] fontFace = request.getParameterValues("fontFace"); String[] fontSize = request.getParameterValues("fontSize"); - //String[] anyFmt = request.getParameterValues("anyFmt"); - - // String[] alignment = request.getParameterValues("alignment"); for (int i = 0; i < lessThanValue.length; i++) if (i == 0 || nvl(lessThanValue[i]).length() > 0) { FormatType fmt = null; if (i == 0 || nvl(formatId[i]).length() > 0) - fmt = rdef.getSemaphoreFormatById(semaphore, nvl(formatId[i])); + fmt = ReportDefinition.getSemaphoreFormatById(semaphore, nvl(formatId[i])); if (fmt == null) - fmt = rdef.addEmptyFormatType(new ObjectFactory(), semaphore); + fmt = ReportDefinition.addEmptyFormatType(new ObjectFactory(), semaphore); fmt.setLessThanValue(nvl(lessThanValue[i])); fmt.setExpression(nvl(expression[i])); - fmt.setBold(bold[i].equals("Y")); - fmt.setItalic(italic[i].equals("Y")); - fmt.setUnderline(underline[i].equals("Y")); + fmt.setBold("Y".equals(bold[i])); + fmt.setItalic("Y".equals(italic[i])); + fmt.setUnderline("Y".equals(underline[i])); fmt.setBgColor(bgColor[i]); fmt.setFontColor(fontColor[i]); fmt.setFontFace(fontFace[i]); fmt.setFontSize(fontSize[i]); - //fmt.setAnyFmt((anyFmt[i]!=null)?anyFmt[i].startsWith("Y"):false); - // fmt.setAlignment(alignment[i]); } else if (nvl(formatId[i]).length() > 0) - rdef.deleteFormatType(semaphore, formatId[i]); + ReportDefinition.deleteFormatType(semaphore, formatId[i]); persistReportDefinition(request, rdef); } // processSemaphorePopup - private boolean processDefinition(HttpServletRequest request) throws Exception { + private boolean processDefinition(HttpServletRequest request) throws RaptorException { ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute( AppConstants.SI_REPORT_DEFINITION); @@ -350,35 +345,29 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { boolean isSizedByContent= (AppUtils.getRequestNvlValue(request, "sizedByContent").length()<=0?"N":AppUtils.getRequestNvlValue(request, "sizedByContent")).startsWith("Y"); boolean reportsInNewWindow = false; boolean hideFormFieldAfterRun = false; - + /*recurrance in schedule tab - Start*/ - String isOneTimeScheduleAllowed = nvl(AppUtils.getRequestValue(request, "isOneTimeScheduleAllowed"),"N"); + String isOneTimeScheduleAllowed = nvl(AppUtils.getRequestValue(request, "isOneTimeScheduleAllowed"),"N"); String isHourlyScheduleAllowed = nvl(AppUtils.getRequestValue(request, "isHourlyScheduleAllowed"),"N"); String isDailyScheduleAllowed = nvl(AppUtils.getRequestValue(request, "isDailyScheduleAllowed"),"N"); String isDailyMFScheduleAllowed = nvl(AppUtils.getRequestValue(request, "isDailyMFScheduleAllowed"),"N"); String isWeeklyScheduleAllowed = nvl(AppUtils.getRequestValue(request, "isWeeklyScheduleAllowed"),"N"); String isMonthlyScheduleAllowed = nvl(AppUtils.getRequestValue(request, "isMonthlyScheduleAllowed"),"N"); - //System.out.println("//////////// + isOneTimeScheduleAllowed : " + isOneTimeScheduleAllowed); - /*recurrance in schedule tab - End*/ + /*recurrance in schedule tab - End*/ if (reportDescr.length() > 1000) reportDescr = reportDescr.substring(0, 1000); boolean reportUpdated; - + String reportType = AppUtils.getRequestNvlValue(request, "reportType"); - - - - //rdef.setReportName(reportName); - //rdef.setReportDescr(reportDescr); - //rdef.setReportType(reportType); + rdef.setFolderId(folderId); -// debugLogger.debug("setting folder ID = " + folderId); + if(reportType.equals(AppConstants.RT_DASHBOARD)) { rdef.setReportName(reportName); rdef.setReportDescr(reportDescr); - rdef.setReportType(reportType); + rdef.setReportType(reportType); String dashboardLayoutHTML = AppUtils.getRequestNvlValue(request, "dashboardLayoutHTML"); rdef.setDashboardLayoutHTML(dashboardLayoutHTML); String dataContainerHeight = nvl(AppUtils.getRequestValue(request, "heightContainer"), "auto"); @@ -386,65 +375,32 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setDataContainerHeight(dataContainerHeight); rdef.setDataContainerWidth(dataContainerWidth); rdef.setAllowSchedule(isAllowSchedule?"Y":"N"); - - - /* - String numDashCols = AppUtils.getRequestNvlValue(request, "numDashCols"); - String reports1 = AppUtils.getRequestNvlValue(request, "reports1"); - String reports2 = AppUtils.getRequestNvlValue(request, "reports2"); - String reports3 = AppUtils.getRequestNvlValue(request, "reports3"); - String reports4 = AppUtils.getRequestNvlValue(request, "reports4"); - String repBgColor1 = AppUtils.getRequestNvlValue(request, "repBgColor1"); - String repBgColor2 = AppUtils.getRequestNvlValue(request, "repBgColor2"); - String repBgColor3 = AppUtils.getRequestNvlValue(request, "repBgColor3"); - String repBgColor4 = AppUtils.getRequestNvlValue(request, "repBgColor4"); - - //List reports = rdef.getDashBoardReports(); - rdef.setNumDashCols(numDashCols); - DashboardReports reportsList = new DashboardReportsImpl(); - - String reports[] = new String[]{reports1, reports2, reports3, reports4}; - String repBgColors[] = new String[]{repBgColor1, repBgColor2, repBgColor3, repBgColor4}; - for (int i = 0; i < reports.length; i++) { - Reports report = new ReportsImpl(); - report.setReportId(reports[i]); - report.setBgcolor(repBgColors[i]); - reportsList.getReportsList().add(report); - } - - - - rdef.setDashBoardReports(reportsList); - */ + + reportUpdated = true; - -// reportUpdated = (!(reportName.equals(nvl(rdef.getReportName())) -// && reportDescr.equals(nvl(rdef.getReportDescr())) -// && reportType.equals(nvl(rdef.getReportType())) -// && numDashCols.equals(nvl(rdef.getNumDashCols())))); -//// && rdef.getR - + + if (rdef.getWizardSequence() instanceof WizardSequence) rdef.generateWizardSequence(request); - + } else { - + if (AppUtils.getRequestNvlValue(request, "reportType").equals(AppConstants.RT_CROSSTAB) || rdef.getReportType().equals(AppConstants.RT_CROSSTAB)) { - + String widthNo = AppUtils.getRequestNvlValue(request, "widthNo"); if(nvl(widthNo).endsWith("px")) rdef.setWidthNoColumn(widthNo); else rdef.setWidthNoColumn(widthNo+"px"); } - + String dataGridAlign = AppUtils.getRequestNvlValue(request, "dataGridAlign"); if(nvl(dataGridAlign).length()>0) { rdef.setDataGridAlign(dataGridAlign); } else { rdef.setDataGridAlign("left"); } - + String pdfImgLogo = AppUtils.getRequestNvlValue(request, "pdfImg"); if(nvl(pdfImgLogo).length()>0) rdef.setPdfImg(pdfImgLogo); @@ -464,12 +420,12 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { } 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) + if(AppUtils.getRequestNvlValue(request, "reportInNewWindow").length()>0) reportsInNewWindow = AppUtils.getRequestNvlValue(request,"reportInNewWindow").equals("Y"); - if(AppUtils.getRequestNvlValue(request, "hideFormFieldsAfterRun").length()>0) + if(AppUtils.getRequestNvlValue(request, "hideFormFieldsAfterRun").length()>0) hideFormFieldAfterRun = AppUtils.getRequestNvlValue(request,"hideFormFieldsAfterRun").equals("Y"); - + if(AppUtils.getRequestNvlValue(request, "displayFolderTree").length()>0) rdef.setDisplayFolderTree(AppUtils.getRequestNvlValue(request,"displayFolderTree").equals("Y")); else @@ -481,20 +437,20 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { DataSet ds = null; try { ds = DbUtils.executeQuery(schemaSql); - + String prefix = "", desc = ""; - + for (int i = 0; i < ds.getRowCount(); i++) { dbType = ds.getItem(i, 2); } } catch (Exception e) {} - + int pageSize = Globals.getDefaultPageSize(); try { pageSize = Integer.parseInt(AppUtils.getRequestValue(request, "pageSize")); } catch (NumberFormatException e) { - } + } String rApproved = nvl(AppUtils.getRequestValue(request, "menuApproved"), "N"); String menuID = ""; String[] menuIDs = request.getParameterValues("menuID"); @@ -502,7 +458,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { for (int i = 0; i < menuIDs.length; i++) menuID += (menuID.length() == 0 ? "" : "|") + menuIDs[i]; /* else - menuID = "";*/ + menuID = "";*/ // boolean additionalFieldsShown = AppUtils.getRequestNvlValue(request, // "additionalFieldsShown").equals("Y"); @@ -510,7 +466,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { String reportDefType = AppUtils.getRequestNvlValue(request, "reportDefType"); String dataContainerHeight = nvl(AppUtils.getRequestValue(request, "heightContainer"), "auto"); String dataContainerWidth = nvl(AppUtils.getRequestValue(request, "widthContainer"), "auto"); - + String displayOptions = nvl(AppUtils.getRequestValue(request, "hideForm"), "N") + nvl(AppUtils.getRequestValue(request, "hideChart"), "N") + nvl(AppUtils.getRequestValue(request, "hideData"), "N") @@ -522,20 +478,20 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { 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")); String reportSubTitle = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "reportSubTitle")); String reportHeader = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "reportHeader")); String reportFooter = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "reportFooter")); - + int frozenColumns = 0; - try { + try { frozenColumns = Integer.parseInt(AppUtils.getRequestValue(request, "frozenColumns")); } catch (NumberFormatException ex) { - + } - + /* reportUpdated = (!(reportName.equals(nvl(rdef.getReportName())))) && (!(reportDescr.equals(nvl(rdef.getReportDescr())))) && (!(formHelp.equals(nvl(rdef.getFormHelpText())))) @@ -559,17 +515,17 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { && numFormCols.equals(nvl(rdef.getNumFormCols())) && reportTitle.equals(nvl(rdef.getReportTitle())) && reportSubTitle.equals(nvl(rdef.getReportSubTitle())) - && reportHeader.equals(nvl(rdef.getReportHeader())) + && 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()) + && (pageSize == rdef.getPageSize()) && excelDownloadSize == rdef.getMaxRowsInExcelDownload() && reportsInNewWindow == rdef.isReportInNewWindow() && displayOptions.equals(rdef.getDisplayOptions()) @@ -617,7 +573,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setDashboardOptions(dashboardOptions.toString()); }*/ rdef.setHideFormFieldAfterRun(hideFormFieldAfterRun); - rdef.setReportInNewWindow(reportsInNewWindow); + rdef.setReportInNewWindow(reportsInNewWindow); rdef.setRuntimeColSortDisabled(rRCSDisabled); rdef.setNumFormCols(numFormCols); rdef.setReportTitle(reportTitle); @@ -633,11 +589,11 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setFrozenColumns(frozenColumns); } // if - + if (rdef.getWizardSequence() instanceof WizardSequence) rdef.generateWizardSequence(request); - + /* * if(formHelp.length()>255) formHelp = formHelp.substring(0, 255); */ @@ -648,10 +604,10 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { // String menuID = AppUtils.getRequestNvlValue(request, "menuID"); // boolean dashboardOptionsShown = AppUtils.getRequestNvlValue(request, -// "dashboardOptionsShown").equals("Y"); +// "dashboardOptionsShown").equals("Y"); reportUpdated = true; - + if (rdef.getReportID().equals("-1")) // Always need to persist new report - in case it is a copy reportUpdated = true; @@ -668,13 +624,13 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { String joinTableExpr = null; String joinTableId = null; - - DataSourceType joinTable = + + DataSourceType joinTable = rdef.getTableById(AppUtils.getRequestValue(request, "joinTableName")); if (joinTable != null) { String joinTableName = joinTable.getTableName(); joinTableId = joinTable.getTableId(); - + String joinExpr = AppUtils.getRequestNvlValue(request, "joinExpr").toUpperCase(); joinTableExpr = joinExpr.replaceAll("\\["+tableName+"\\]", tableId); @@ -705,24 +661,24 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { String tableName = AppUtils.getRequestNvlValue(request, "tableName").toUpperCase(); String joinTableId = AppUtils.getRequestNvlValue(request, "joinTableName"); - + String joinExpr = AppUtils.getRequestNvlValue(request, "joinExpr").toUpperCase(); - + String joinTableExpr = null; if(joinExpr.length()!=0){ joinTableExpr = joinExpr.replaceAll("\\["+tableName+"\\]", rdef.getTableByDBName(tableName).getTableId()); joinTableExpr = joinTableExpr.replaceAll("\\["+rdef.getTableById(joinTableId).getTableName().toUpperCase()+"\\]", joinTableId); dst.setRefDefinition(joinTableExpr); } - boolean reportUpdated = (!displayName.equals(nvl(dst.getDisplayName())) || + boolean reportUpdated = (!displayName.equals(nvl(dst.getDisplayName())) || !outerJoin.equals(rdef.getOuterJoinType(dst)) || !(joinExpr.length()==0)); - + dst.setDisplayName(displayName); rdef.setOuterJoin(dst, outerJoin); if (reportUpdated) rdef.resetCache(true); - + return true; // reportUpdated; } // processTableEdit @@ -813,24 +769,24 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { } String dependsOnFormField = AppUtils.getRequestNvlValue(request, "dependsOnFormField"); boolean isGroupBreak = AppUtils.getRequestFlag(request, "groupBreak"); - String groupByPosStr = AppUtils.nvls(AppUtils.getRequestValue(request, "groupByPos"), "0"); + String groupByPosStr = AppUtils.nvls(AppUtils.getRequestValue(request, "groupByPos"), "0"); int groupByPos = Integer.parseInt(groupByPosStr); currColumn.setGroupByPos(groupByPos); - + if(groupByPos > 0) { - String subTotalCustomText = AppUtils.nvls(AppUtils.getRequestValue(request, "subTotalCustomText"), "Sub Total"); + String subTotalCustomText = AppUtils.nvls(AppUtils.getRequestValue(request, "subTotalCustomText"), "Sub Total"); currColumn.setSubTotalCustomText(subTotalCustomText); - + boolean hideRepeatedKey = AppUtils.getRequestFlag(request, "hideRepeatedKeys"); currColumn.setHideRepeatedKey(hideRepeatedKey); } - + String displayTotal = AppUtils.getRequestNvlValue(request, "displayTotal"); String widthInPxls = AppUtils.getRequestNvlValue(request, "widthInPxls"); - + if (rdef.getReportType().equals(AppConstants.RT_CROSSTAB)) { - - + + crossTabValue = AppUtils.getRequestValue(request, "crossTabValue"); isVisible = nvl(crossTabValue).equals(AppConstants.CV_ROW) @@ -849,7 +805,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { String displayName = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "displayName")); String colType = AppUtils.getRequestNvlValue(request, "colType"); String displayFormat = AppUtils.getRequestNvlValue(request, "displayFormat"); - + //HYPERLINK if(colType.equals(AppConstants.CT_HYPERLINK)) { String hyperlinkURL = AppUtils.getRequestValue(request, "hyperlinkURL"); @@ -861,9 +817,9 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { currColumn.setActionImg(actionImg); } } - - - + + + String displayAlign = AppUtils.getRequestValue(request, "displayAlign"); String displayHeaderAlign = AppUtils.getRequestValue(request, "displayHeaderAlign"); String drillDownURL = AppUtils.getRequestValue(request, "drillDownURL"); @@ -888,7 +844,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { //startColGroupInt = Integer.parseInt(startColGroup); colGroupColSpanInt = Integer.parseInt(colGroupColSpan); } catch (NumberFormatException ex) { - + } } currColumn.setLevel(level); @@ -896,13 +852,13 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { currColumn.setStart(startColGroupInt); currColumn.setColspan(colGroupColSpanInt); } - + String targetColumnId = (semaphoreType.indexOf("|")!= -1 ? semaphoreType.substring(semaphoreType.indexOf("|")+1):""); DataColumnType targetColumn = rdef.getColumnById(targetColumnId); - + SemaphoreType semaphore = rdef.getSemaphoreById(semaphoreId); rdef.deleteSemaphore(semaphore); - if(nvl(semaphoreType).length() > 0 && semaphoreType.indexOf("|")!=-1) + if(nvl(semaphoreType).length() > 0 && semaphoreType.indexOf("|")!=-1) semaphore.setSemaphoreType(semaphoreType.substring(0,semaphoreType.indexOf("|"))); if(semaphore!=null) { semaphore.setComment(currColumn.getColId()); @@ -910,7 +866,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { semaphore.setTarget(targetColumnId.length()>0? targetColumnId: ""); rdef.setSemaphore(semaphore); } - + if (isEdit) { if(nvl(widthInPxls).length()>0) { @@ -926,7 +882,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { currColumn.setDependsOnFormField(dependsOnFormField); currColumn.setDisplayName(displayName); //currColumn.setOriginalDisplayName(displayName); - + if (displayWidth > 0) currColumn.setDisplayWidth(displayWidth); currColumn.setDisplayAlignment(displayAlign); @@ -953,11 +909,11 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { currColumn.setIsSortable(isSortable); currColumn.setNowrap(nowrap); //else - // currColumn.setVisible(true); - if (rdef.getReportDefType().equals(AppConstants.RD_SQL_BASED)) { + // currColumn.setVisible(true); + if (rdef.getReportDefType().equals(AppConstants.RD_SQL_BASED)) { if(colType!=null) currColumn.setColType(colType); - displayFormat = AppUtils.getRequestValue(request, "colDataFormat"); + displayFormat = AppUtils.getRequestValue(request, "colDataFormat"); if (displayFormat != null){ currColumn.setColFormat(displayFormat); } @@ -1138,18 +1094,18 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { String rangeStartDateSQL = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "rangeStartDateSQL")); String rangeEndDateSQL = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "rangeEndDateSQL")); boolean isGroupFormField = AppUtils.getRequestFlag(request,"isGroupFormField"); - + Calendar start = null; Calendar end = null; if (AppUtils.nvl(rangeStartDate).length()>0){ SimpleDateFormat dtf = new SimpleDateFormat("MM/dd/yyyy"); start = Calendar.getInstance(); - start.setTime(dtf.parse(rangeStartDate)); + start.setTime(dtf.parse(rangeStartDate)); } if (AppUtils.nvl(rangeEndDate).length()>0){ SimpleDateFormat dtf = new SimpleDateFormat("MM/dd/yyyy"); end = Calendar.getInstance(); - end.setTime(dtf.parse(rangeEndDate)); + end.setTime(dtf.parse(rangeEndDate)); }/* * if(fieldHelp.length()>255) fieldHelp = fieldHelp.substring(0, 255); */ @@ -1168,7 +1124,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { && validation.equals(nvl(currField.getValidationType())) && mandatory.equals(nvl(currField.getMandatory(), "N")) && defaultValue.equals(nvl(currField.getDefaultValue())) - && fieldSQL.equals(nvl(currField.getFieldSQL())) + && fieldSQL.equals(nvl(currField.getFieldSQL())) && fieldDefaultSQL.equals(nvl(currField.getFieldDefaultSQL())) && dependsOn.equals(nvl(currField.getDependsOn(), "N")) && (start == null || (start != null && currField.getRangeStartDate() == null) || (start.compareTo(getCalendar(currField.getRangeStartDate())) )==0) @@ -1209,9 +1165,9 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { /*currField.setRangeEndDate(DatatypeFactory.newInstance() .newXMLGregorianCalendar(end));*/ } catch (DatatypeConfigurationException ex) { - + } - + currField.setRangeStartDateSQL(rangeStartDateSQL); currField.setRangeEndDateSQL(rangeEndDateSQL); currField.setGroupFormField(isGroupFormField); @@ -1220,7 +1176,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { currField.setMultiSelectListSize(multiSelectSize); } - + } // if } else { reportUpdated = true; @@ -1277,7 +1233,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.addFormFieldBlank(new ObjectFactory()); return true; } // processFormFieldMoveDown - + //processFormFieldInfoBar private boolean processFormFieldInfoBar(HttpServletRequest request) throws Exception { boolean reportUpdated = false; @@ -1287,31 +1243,31 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.addCustomizedTextForParameters(XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "blueBarField"))); return true; } // processFormFieldMoveDown - - + + private boolean processForecasting(HttpServletRequest request, String action) throws Exception { ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute( AppConstants.SI_REPORT_DEFINITION); - + if(rdef.getDataminingOptions()==null) - rdef.addDataminingOptions(new ObjectFactory()); - + rdef.addDataminingOptions(new ObjectFactory()); + String classifiers = AppUtils.getRequestNvlValue(request, "classifiers"); 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"; String forecastingPeriod = AppUtils.getRequestNvlValue(request, "forecastingPeriod"); - + String[] forecastCols = request.getParameterValues("forecastCol"); List reportCols = rdef.getAllColumns(); DataColumnType dct = null; Iterator iter = null; - - + + if(dateAttrColId != null) { - for(iter=reportCols.iterator(); iter.hasNext(); ) { + for(iter=reportCols.iterator(); iter.hasNext(); ) { dct = (DataColumnType) iter.next(); if(dct.getColId().equals(dateAttrColId)) { dct.setDataMiningCol(AppConstants.DM_DATE_ATTR); @@ -1320,10 +1276,10 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { } } } - + if(forecastCols != null) { for (int i = 0; i < forecastCols.length; i++) { - for(iter=reportCols.iterator(); iter.hasNext(); ) { + for(iter=reportCols.iterator(); iter.hasNext(); ) { dct = (DataColumnType) iter.next(); if(dct.getColId().equals(forecastCols[i])) { dct.setDataMiningCol(AppConstants.DM_FORECASTING_ATTR); @@ -1333,11 +1289,11 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setForecastingPeriod(forecastingPeriod); } boolean reportUpdated = true; - + return reportUpdated; } // processForecasting - - + + private boolean processFilterAddEdit(HttpServletRequest request, boolean isEdit) throws Exception { ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute( @@ -1380,7 +1336,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { + nvl(currColumn.getColFormat(), AppConstants.DEFAULT_DATE_FORMAT) + "')") : ("'" + argValue + "'"))) + " FROM dual");*/ - + DataSet ds = DbUtils.executeQuery("SELECT " + (currColType.equals(AppConstants.CT_NUMBER) ? ("TO_NUMBER('" + argValue + "')") @@ -1561,7 +1517,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { processSaveJavascriptElement(request); return true; } - + private boolean processSaveJavascriptElement (HttpServletRequest request) throws Exception { ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute( AppConstants.SI_REPORT_DEFINITION); @@ -1569,9 +1525,9 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { String id = AppUtils.getRequestNvlValue(request, AppConstants.RI_JAVASCRIPT_ITEM_ID); String fieldId = AppUtils.getRequestNvlValue(request, "javascriptFormField-"+id); if( nvl(fieldId).length()>0 && !(fieldId.startsWith("-1"))) { - + String callableJavascriptText = AppUtils.getRequestNvlValue(request, "callText-"+id); - + logger.debug(EELFLoggerDelegate.debugLogger, ("FieldId " + fieldId + " Call Text " + callableJavascriptText+ " id " + id)); JavascriptItemType javaScriptType = null; if(id.length()>0 && id.startsWith("-1")) { @@ -1585,23 +1541,23 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { else javaScriptType.setId("ol1|1"); } - javaScriptType.setCallText(callableJavascriptText); + javaScriptType.setCallText(callableJavascriptText); } else { javaScriptType = rdef.addJavascriptType(new ObjectFactory(), id); javaScriptType.setCallText(callableJavascriptText); } } return true; - } + } private boolean processAddJavascriptElement (HttpServletRequest request) throws Exception { ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute( AppConstants.SI_REPORT_DEFINITION); - + JavascriptItemType javaScriptType = rdef.addJavascriptType(new ObjectFactory(), ""); javaScriptType.setId(""); javaScriptType.setFieldId(""); - javaScriptType.setCallText(""); - + javaScriptType.setCallText(""); + return true; } @@ -1632,36 +1588,36 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { String chartMultiseries = AppUtils.getRequestNvlValue(request, "multiSeries"); String lastSeriesALineChart = AppUtils.getRequestNvlValue(request, "lastSeriesALineChart"); String lastSeriesABarChart = AppUtils.getRequestNvlValue(request, "lastSeriesABarChart"); - String overLayItemLabel = "N"; + String overLayItemLabel = "N"; String chartDisplay = null; - + String multiplePieOrder = null; String multiplePieLabelDisplay = null; String chartOrientation = null; String secondaryChartRenderer = null; - - String linearRegression = null; + + String linearRegression = null; boolean multiplePieOrderInRunPage = false; boolean multiplePieLabelDisplayInRunPage = false; boolean chartOrientationInRunPage = false; boolean secondaryChartRendererInRunPage = false; - + boolean chartDisplayInRunPage = false; - + String intervalFromdate = null; String intervalTodate = null; String intervalLabel = null; - boolean displayIntervalInputInRunPage = false; + boolean displayIntervalInputInRunPage = false; boolean animate = false; - + animate = AppUtils.getRequestNvlValue(request, "animatedOption").equals("animate"); if(Globals.showAnimatedChartOption()) rdef.setChartAnimate(animate); - - + + String removeColId = ""; if (action.equals(AppConstants.WA_DELETE_USER)) { removeColId = AppUtils.getRequestNvlValue(request, AppConstants.RI_DETAIL_ID); @@ -1674,27 +1630,27 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { } } } - + if(rdef.getChartAdditionalOptions()==null) rdef.addChartAdditionalOptions(new ObjectFactory()); - + if(rdef.getChartDrillOptions()==null) - rdef.addChartDrillOptions(new ObjectFactory()); + rdef.addChartDrillOptions(new ObjectFactory()); //clearing already added if(rdef.getChartDrillOptions().getTargetFormfield()!=null) rdef.getChartDrillOptions().getTargetFormfield().removeAll(rdef.getChartDrillOptions().getTargetFormfield()); - - + + if(chartType.equals(AppConstants.GT_PIE_MULTIPLE)) { multiplePieOrder = AppUtils.getRequestNvlValue(request, "multiplePieOrder"); multiplePieLabelDisplay = AppUtils.getRequestNvlValue(request, "multiplePieLabelDisplay"); chartDisplay = AppUtils.getRequestNvlValue(request, "chartDisplay"); - //if(AppUtils.getRequestNvlValue(request, "multiplePieOrderInRunPage").length()>0) + //if(AppUtils.getRequestNvlValue(request, "multiplePieOrderInRunPage").length()>0) multiplePieOrderInRunPage = AppUtils.getRequestNvlValue(request,"multiplePieOrderInRunPage").equals("Y"); - //if(AppUtils.getRequestNvlValue(request, "multiplePieLabelDisplayInRunPage").length()>0) + //if(AppUtils.getRequestNvlValue(request, "multiplePieLabelDisplayInRunPage").length()>0) multiplePieLabelDisplayInRunPage = AppUtils.getRequestNvlValue(request,"multiplePieLabelDisplayInRunPage").equals("Y"); - //if(AppUtils.getRequestNvlValue(request, "chartDisplayInRunPage").length()>0) + //if(AppUtils.getRequestNvlValue(request, "chartDisplayInRunPage").length()>0) chartDisplayInRunPage = AppUtils.getRequestNvlValue(request,"chartDisplayInRunPage").equals("Y"); if(rdef.getChartAdditionalOptions()!=null) { rdef.setChartMultiplePieOrder(multiplePieOrder+(multiplePieOrderInRunPage?"|Y":"")); @@ -1702,14 +1658,14 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setChartDisplay(chartDisplay+(chartDisplayInRunPage?"|Y":"")); } - } - + } + if(chartType.equals(AppConstants.GT_REGRESSION)) { linearRegression = AppUtils.getRequestNvlValue(request, "regressionType"); rdef.setLinearRegressionColor(AppUtils.getRequestNvlValue(request, "valueLinearRegressionColor")); rdef.setExponentialRegressionColor(AppUtils.getRequestNvlValue(request, "valueExponentialRegressionColor")); rdef.setCustomizedRegressionPoint(AppUtils.getRequestNvlValue(request, "regressionPointCustomization")); - + if(nvl(linearRegression).length()>0) rdef.setLinearRegression(linearRegression); else @@ -1720,27 +1676,27 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { chartOrientation = AppUtils.getRequestNvlValue(request, "chartOrientation"); secondaryChartRenderer = AppUtils.getRequestNvlValue(request, "secondaryChartRenderer"); chartDisplay = AppUtils.getRequestNvlValue(request, "chartDisplay"); - //if(AppUtils.getRequestNvlValue(request, "chartOrientationInRunPage").length()>0) + //if(AppUtils.getRequestNvlValue(request, "chartOrientationInRunPage").length()>0) chartOrientationInRunPage = AppUtils.getRequestNvlValue(request,"chartOrientationInRunPage").equals("Y"); - //if(AppUtils.getRequestNvlValue(request, "secondaryChartRendererInRunPage").length()>0) + //if(AppUtils.getRequestNvlValue(request, "secondaryChartRendererInRunPage").length()>0) secondaryChartRendererInRunPage = AppUtils.getRequestNvlValue(request,"secondaryChartRendererInRunPage").equals("Y"); - //if(AppUtils.getRequestNvlValue(request, "chartDisplayInRunPage").length()>0) + //if(AppUtils.getRequestNvlValue(request, "chartDisplayInRunPage").length()>0) chartDisplayInRunPage = AppUtils.getRequestNvlValue(request,"chartDisplayInRunPage").equals("Y"); rdef.setChartOrientation(chartOrientation+(chartOrientationInRunPage?"|Y":"")); rdef.setSecondaryChartRenderer(secondaryChartRenderer+(secondaryChartRendererInRunPage?"|Y":"")); rdef.setChartDisplay(chartDisplay+(chartDisplayInRunPage?"|Y":"")); rdef.setLastSeriesALineChart(nvl(lastSeriesALineChart, "N")); } - + if(chartType.equals(AppConstants.GT_LINE)) { chartOrientation = AppUtils.getRequestNvlValue(request, "chartOrientation"); secondaryChartRenderer = AppUtils.getRequestNvlValue(request, "secondaryChartRenderer"); chartDisplay = AppUtils.getRequestNvlValue(request, "chartDisplay"); - //if(AppUtils.getRequestNvlValue(request, "chartOrientationInRunPage").length()>0) + //if(AppUtils.getRequestNvlValue(request, "chartOrientationInRunPage").length()>0) chartOrientationInRunPage = AppUtils.getRequestNvlValue(request,"chartOrientationInRunPage").equals("Y"); - //if(AppUtils.getRequestNvlValue(request, "secondaryChartRendererInRunPage").length()>0) + //if(AppUtils.getRequestNvlValue(request, "secondaryChartRendererInRunPage").length()>0) secondaryChartRendererInRunPage = AppUtils.getRequestNvlValue(request,"secondaryChartRendererInRunPage").equals("Y"); - //if(AppUtils.getRequestNvlValue(request, "chartDisplayInRunPage").length()>0) + //if(AppUtils.getRequestNvlValue(request, "chartDisplayInRunPage").length()>0) chartDisplayInRunPage = AppUtils.getRequestNvlValue(request,"chartDisplayInRunPage").equals("Y"); rdef.setChartOrientation(chartOrientation+(chartOrientationInRunPage?"|Y":"")); rdef.setSecondaryChartRenderer(secondaryChartRenderer+(secondaryChartRendererInRunPage?"|Y":"")); @@ -1750,7 +1706,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { if(chartType.equals(AppConstants.GT_TIME_DIFFERENCE_CHART)) { intervalFromdate = AppUtils.getRequestNvlValue(request, "intervalFromDate"); intervalTodate = AppUtils.getRequestNvlValue(request, "intervalToDate"); - intervalLabel = AppUtils.getRequestNvlValue(request, "intervalLabel"); + intervalLabel = AppUtils.getRequestNvlValue(request, "intervalLabel"); displayIntervalInputInRunPage = AppUtils.getRequestNvlValue(request,"intervalInputInRunPage").equals("Y"); rdef.setIntervalFromdate(intervalFromdate+(displayIntervalInputInRunPage?"|Y":"")); rdef.setIntervalTodate(intervalTodate+(displayIntervalInputInRunPage?"|Y":"")); @@ -1758,7 +1714,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { } if(chartType.equals(AppConstants.GT_STACKED_VERT_BAR) || chartType.equals(AppConstants.GT_STACKED_HORIZ_BAR) || chartType.equals(AppConstants.GT_STACKED_VERT_BAR_LINES) || chartType.equals(AppConstants.GT_STACKED_HORIZ_BAR_LINES)) { - overLayItemLabel = AppUtils.getRequestNvlValue(request, "overlayItemValue"); + overLayItemLabel = AppUtils.getRequestNvlValue(request, "overlayItemValue"); rdef.setOverlayItemValueOnStackBar(nvl(overLayItemLabel, "N")); animate = AppUtils.getRequestNvlValue(request, "animatedOption").equals("animate"); rdef.setChartAnimate(animate); @@ -1770,12 +1726,12 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setLegendPosition(AppUtils.getRequestNvlValue(request,"legendPosition")); rdef.setMaxLabelsInDomainAxis(AppUtils.getRequestNvlValue(request,"maxLabelsInDomainAxis")); String chartLegendDisplay = AppUtils.getRequestNvlValue(request,"hideLegend"); - boolean showLegendDisplayOptionsInRunPage = false; + boolean showLegendDisplayOptionsInRunPage = false; showLegendDisplayOptionsInRunPage = AppUtils.getRequestNvlValue(request,"showLegendDisplayOptionsInRunPage").equals("Y"); rdef.setChartLegendDisplay(chartLegendDisplay+(showLegendDisplayOptionsInRunPage?"|Y":"")); rdef.setChartToolTips(AppUtils.getRequestNvlValue(request,"hideTooltips")); rdef.setDomainAxisValuesAsString(AppUtils.getRequestNvlValue(request,"keepAsString")); - + //System.out.println("KeepAsString " + AppUtils.getRequestNvlValue(request,"keepAsString")); //System.out.println("From ReportDef " + rdef.keepDomainAxisValueInChartAsString()); // boolean reportUpdated = (! @@ -1784,7 +1740,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setChartTypeFixed(nvl(chartTypeFixed, "N")); if (nvl(leftAxisLabel).length()>0) rdef.setChartLeftAxisLabel(leftAxisLabel); - else + else rdef.setChartLeftAxisLabel(null); if (nvl(rightAxisLabel).length()>0) rdef.setChartRightAxisLabel(rightAxisLabel); @@ -1822,27 +1778,27 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { } // for int idx = 1; - List columns = rdef.getAllColumns(); + List columns = rdef.getAllColumns(); if(chartType.equals(AppConstants.GT_TIME_SERIES)) { String chartSeries = AppUtils.getRequestNvlValue(request, "chartSeries"); String chartGroup = AppUtils.getRequestNvlValue(request, "chartGroup"); - String yAxis = AppUtils.getRequestNvlValue(request, "yAxis"); + String yAxis = AppUtils.getRequestNvlValue(request, "yAxis"); for (Iterator iterator = columns.iterator(); iterator.hasNext();) { DataColumnType alldct = (DataColumnType) iterator.next(); //debugLogger.debug("**********In " + chartSeries + " " + alldct.getColId()); - alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); + alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); } - + String drillDownReportId = AppUtils.getRequestNvlValue(request, "drillDownReport"); if(!drillDownReportId.equals("-1")) { ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, drillDownReportId, false); if (ddRr != null) request.setAttribute("CHART_FORMFIELDS", ddRr.getReportFormFields()); - - for(ddRr.getReportFormFields().resetNext(); ddRr.getReportFormFields().hasNext(); ) { + + for(ddRr.getReportFormFields().resetNext(); ddRr.getReportFormFields().hasNext(); ) { FormField ff = ddRr.getReportFormFields().getNext(); - if(!ff.getFieldType().equals(FormField.FFT_BLANK)) { + if(!ff.getFieldType().equals(FormField.FFT_BLANK)) { String value = AppUtils.getRequestNvlValue(request, "drillDown_"+ff.getFieldName()); ChartDrillFormfield cdf = new ObjectFactory().createChartDrillFormfield(); cdf.setFormfield(value); @@ -1850,46 +1806,46 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { } } } - + } else { if(chartType.equals(AppConstants.GT_BAR_3D)) { String chartSeries = AppUtils.getRequestNvlValue(request, "chartSeries"); String chartGroup = AppUtils.getRequestNvlValue(request, "chartGroup"); - String yAxis = AppUtils.getRequestNvlValue(request, "yAxis"); + String yAxis = AppUtils.getRequestNvlValue(request, "yAxis"); for (Iterator iterator = columns.iterator(); iterator.hasNext();) { DataColumnType alldct = (DataColumnType) iterator.next(); //debugLogger.debug("**********In " + chartSeries + " " + alldct.getColId()); - alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); + alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); } String drillDownReportId = AppUtils.getRequestNvlValue(request, "drillDownReport"); rdef.setDrillReportIdForChart(drillDownReportId); if(drillDownReportId.equals("-1")){ rdef.setDrillReportIdForChart(""); } - + if(!drillDownReportId.equals("-1")) { ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, drillDownReportId, false); if (ddRr != null) request.setAttribute("CHART_FORMFIELDS", ddRr.getReportFormFields()); - - for(ddRr.getReportFormFields().resetNext(); ddRr.getReportFormFields().hasNext(); ) { + + for(ddRr.getReportFormFields().resetNext(); ddRr.getReportFormFields().hasNext(); ) { FormField ff = ddRr.getReportFormFields().getNext(); - if(!ff.getFieldType().equals(FormField.FFT_BLANK)) { + if(!ff.getFieldType().equals(FormField.FFT_BLANK)) { String value = AppUtils.getRequestNvlValue(request, "drillDown_"+ff.getFieldName()); ChartDrillFormfield cdf = new ObjectFactory().createChartDrillFormfield(); cdf.setFormfield(value); rdef.getChartDrillOptions().getTargetFormfield().add(cdf); } } - + String xAxisFormField = AppUtils.getRequestNvlValue(request, "drillDownXAxisFormfield"); String yAxisFormField = AppUtils.getRequestNvlValue(request, "drillDownYAxisFormfield"); String seriesAxisFormField = AppUtils.getRequestNvlValue(request, "drillDownSeriesAxisFormfield"); - + if(!xAxisFormField.equals("-1")){ rdef.setDrillXAxisFormField(xAxisFormField); - + if(!yAxisFormField.equals("-1")) rdef.setDrillYAxisFormField(yAxisFormField); if(!seriesAxisFormField.equals("-1")) @@ -1900,21 +1856,21 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setDrillSeriesFormField(""); } } - + } else if(chartType.equals(AppConstants.GT_SCATTER)) { String chartSeries = AppUtils.getRequestNvlValue(request, "chartSeries"); for (Iterator iterator = columns.iterator(); iterator.hasNext();) { DataColumnType alldct = (DataColumnType) iterator.next(); //debugLogger.debug("**********In " + chartSeries + " " + alldct.getColId()); - alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); + alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); } - + }else if(chartType.equals(AppConstants.GT_REGRESSION)) { String chartSeries = AppUtils.getRequestNvlValue(request, "chartSeries"); for (Iterator iterator = columns.iterator(); iterator.hasNext();) { DataColumnType alldct = (DataColumnType) iterator.next(); //debugLogger.debug("**********In " + chartSeries + " " + alldct.getColId()); - alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); + alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); } }else if(chartType.equals(AppConstants.GT_STACKED_HORIZ_BAR) || chartType.equals(AppConstants.GT_STACKED_VERT_BAR) || chartType.equals(AppConstants.GT_STACKED_VERT_BAR_LINES) || chartType.equals(AppConstants.GT_STACKED_HORIZ_BAR_LINES)) { @@ -1922,66 +1878,66 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { for (Iterator iterator = columns.iterator(); iterator.hasNext();) { DataColumnType alldct = (DataColumnType) iterator.next(); //debugLogger.debug("**********In " + chartSeries + " " + alldct.getColId()); - alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); + alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); } }else if(chartType.equals(AppConstants.GT_LINE)) { String chartSeries = AppUtils.getRequestNvlValue(request, "chartSeries"); for (Iterator iterator = columns.iterator(); iterator.hasNext();) { DataColumnType alldct = (DataColumnType) iterator.next(); //debugLogger.debug("**********In " + chartSeries + " " + alldct.getColId()); - alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); + alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); } } else if (chartType.equals(AppConstants.GT_TIME_DIFFERENCE_CHART)) { String chartSeries = AppUtils.getRequestNvlValue(request, "chartSeries"); for (Iterator iterator = columns.iterator(); iterator.hasNext();) { DataColumnType alldct = (DataColumnType) iterator.next(); //debugLogger.debug("**********In " + chartSeries + " " + alldct.getColId()); - alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); + alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); } } else if (chartType.equals(AppConstants.GT_COMPARE_PREVYEAR_CHART)) { String chartSeries = AppUtils.getRequestNvlValue(request, "chartSeries"); for (Iterator iterator = columns.iterator(); iterator.hasNext();) { DataColumnType alldct = (DataColumnType) iterator.next(); //debugLogger.debug("**********In " + chartSeries + " " + alldct.getColId()); - alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); + alldct.setChartSeries((chartSeries.equals(alldct.getColId()))?true : false); } } else { if (rdef.hasSeriesColumn()) { for (Iterator iterator = columns.iterator(); iterator.hasNext();) { DataColumnType alldct = (DataColumnType) iterator.next(); - alldct.setChartSeries(false); + alldct.setChartSeries(false); } } - + String drillDownReportId = AppUtils.getRequestNvlValue(request, "drillDownReport"); rdef.setDrillReportIdForChart(drillDownReportId); if(drillDownReportId.equals("-1")){ rdef.setDrillReportIdForChart(""); } - + if(!drillDownReportId.equals("-1")) { ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, drillDownReportId, false); if (ddRr != null) request.setAttribute("CHART_FORMFIELDS", ddRr.getReportFormFields()); - for(ddRr.getReportFormFields().resetNext(); ddRr.getReportFormFields().hasNext(); ) { + for(ddRr.getReportFormFields().resetNext(); ddRr.getReportFormFields().hasNext(); ) { FormField ff = ddRr.getReportFormFields().getNext(); - if(!ff.getFieldType().equals(FormField.FFT_BLANK)) { + if(!ff.getFieldType().equals(FormField.FFT_BLANK)) { String value = AppUtils.getRequestNvlValue(request, "drillDown_"+ff.getFieldName()); ChartDrillFormfield cdf = new ObjectFactory().createChartDrillFormfield(); cdf.setFormfield(value); rdef.getChartDrillOptions().getTargetFormfield().add(cdf); } } - + String xAxisFormField = AppUtils.getRequestNvlValue(request, "drillDownXAxisFormfield"); String yAxisFormField = AppUtils.getRequestNvlValue(request, "drillDownYAxisFormfield"); String seriesAxisFormField = AppUtils.getRequestNvlValue(request, "drillDownSeriesAxisFormfield"); - + if(!xAxisFormField.equals("-1")){ rdef.setDrillXAxisFormField(xAxisFormField); - + if(!yAxisFormField.equals("-1")) rdef.setDrillYAxisFormField(yAxisFormField); if(!seriesAxisFormField.equals("-1")) @@ -1992,12 +1948,12 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setDrillSeriesFormField(""); } } - + } } - + for (int i = 1; i < Math.max(valueColsCount, 1) + 1; i++) { - //debugLogger.debug("********** " + chartSeries); + //debugLogger.debug("********** " + chartSeries); if(i==1) { /* Range Axis is resetted before adding */ for (Iterator iterator = columns.iterator(); iterator.hasNext();) { @@ -2011,7 +1967,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { dct.setYAxis(null); } } - + } String newChartColAxis = AppUtils.getRequestNvlValue(request, "newChart" + i+"Axis"); String valueColId = AppUtils.getRequestNvlValue(request, "valueCol" + i); @@ -2024,7 +1980,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { yAxisGroup = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "YAxisLabel" + valueColId)); //debugLogger.debug("^^^^^^^^^^^^^^^^^Chart Group " + chartGroup); //if(chartType.equals(AppConstants.GT_TIME_SERIES)) { - // debugLogger.debug("**********Outer If " + chartSeries); + // debugLogger.debug("**********Outer If " + chartSeries); //} if (valueColId.length() > 0 && (!valueColId.equals(removeColId))) { @@ -2116,14 +2072,14 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { AppUtils.getRequestNvlValue(request, "formFields")); reportSchedule.setAttachmentMode( AppUtils.getRequestNvlValue(request, "sendAttachment")); - + String userId = AppUtils.getRequestNvlValue(request, "schedEmailAdd"); String roleId = AppUtils.getRequestNvlValue(request, "schedEmailAddRole"); int flag = 0; if ((!(userId.length()>0 || roleId.length()>0) && (reportSchedule.getEmailToUsers().isEmpty() && reportSchedule.getEmailToRoles().isEmpty())) ) { flag = 1; } - + if (flag == 1 || (action.equals(AppConstants.WA_ADD_USER) || action.equals(AppConstants.WA_ADD_ROLE)) ) { String loggedInUserId = AppUtils.getUserID(request); if (Globals.getUseLoginIdInSchedYN().equals("Y")){ @@ -2152,7 +2108,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { reportSchedule.addEmailToUser(userId, userId); } } - + } else if (action.equals(AppConstants.WA_DELETE_USER)) reportSchedule.removeEmailToUser( AppUtils.getRequestNvlValue(request, AppConstants.RI_DETAIL_ID)); @@ -2164,10 +2120,10 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { } else if (action.equals(AppConstants.WA_DELETE_ROLE)) reportSchedule.removeEmailToRole( AppUtils.getRequestNvlValue(request, AppConstants.RI_DETAIL_ID)); - request.getSession().setAttribute(AppConstants.SI_REPORT_SCHEDULE, reportSchedule); + request.getSession().setAttribute(AppConstants.SI_REPORT_SCHEDULE, reportSchedule); return true; } // processAdhocSchedule - + private boolean processSchedule(HttpServletRequest request, String action) throws Exception { // Added for form field chaining in schedule tab so that setParamValues() is called @@ -2251,7 +2207,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { String ownerID = AppUtils.getRequestNvlValue(request, "reportOwner"); String rPublic = nvl(AppUtils.getRequestValue(request, "public"), "N"); - + boolean reportUpdated = (!(ownerID.equals(nvl(rdef.getOwnerID())) && rPublic .equals(rdef.isPublic() ? "Y" : "N"))); @@ -2306,8 +2262,8 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { return true; } // processValidateSQL - - + + /*****For Report Maps - Start******/ private boolean processMap(HttpServletRequest request, String action) throws Exception { ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute( @@ -2330,7 +2286,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { String height = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "height")); String width = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "width")); System.out.println(" #$%#$%#$% -- useDefaultSize="+ useDefaultSize+" height = " + height+" width="+width); - + String addAddress = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "addAddress")); String latCol = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "latColumn")); String longCol = XSSFilter.filterRequestOnlyScript(AppUtils.getRequestNvlValue(request, "longColumn")); @@ -2355,7 +2311,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { repMap.setWidth(width.trim()); repMap.setLegendColumn(legendColumn); //repMap.setLegendDisplayName(legendDisplayName); - + Marker m = new ObjectFactory().createMarker(); m.setAddressColumn(addressColumn); m.setDataColumn(dataColumn); @@ -2380,10 +2336,10 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { } } } - + return true; } // processMap /*****For Report Maps - End******/ - + } // WizardProcessor diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java index 139f69a2..acf94bae 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java @@ -38,7 +38,6 @@ package org.onap.portalapp.service; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -46,7 +45,6 @@ import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; @@ -81,7 +79,6 @@ import org.onap.portalsdk.core.web.support.UserUtils; import org.slf4j.MDC; import org.springframework.context.ApplicationContext; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.type.TypeFactory; @@ -107,10 +104,10 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR private RestApiRequestBuilder restApiRequestBuilder; private AppService appServiceImpl; - private static final String isAccessCentralized = PortalApiProperties + private static final String IS_ACCESS_CENTRALIZED = PortalApiProperties .getProperty(PortalApiConstants.ROLE_ACCESS_CENTRALIZED); - private static final String isCentralized = "remote"; + private static final String IS_CENTRALIZED = "remote"; private static String portalApiVersion = "/v3"; public OnBoardingApiServiceImpl() { @@ -118,7 +115,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR // that was caused by a spurious Spring annotation on this class. ApplicationContext appContext = AppContextManager.getAppContext(); if (appContext == null) - throw new RuntimeException("OnBoardingApiServiceImpl ctor failed to get appContext"); + throw new IllegalStateException("OnBoardingApiServiceImpl ctor failed to get appContext"); roleService = appContext.getBean(RoleService.class); userProfileService = appContext.getBean(UserProfileService.class); loginStrategy = appContext.getBean(LoginStrategy.class); @@ -127,7 +124,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR userService = appContext.getBean(UserService.class); appServiceImpl = appContext.getBean(AppService.class); - if(isCentralized.equals(isAccessCentralized)){ + if(IS_CENTRALIZED.equals(IS_ACCESS_CENTRALIZED)){ restApiRequestBuilder = appContext.getBean(RestApiRequestBuilder.class); } } @@ -148,7 +145,17 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR user.setPhone(userJson.getPhone()); user.setOrgUserId(userJson.getOrgUserId()); user.setActive(userJson.isActive()); -// user.setRoles(new TreeSet(userJson.getRoles())); + } + + private void saveUserExtension(User user) + { + if (adminAuthExtensionServiceImpl != null) { + try { + adminAuthExtensionServiceImpl.saveUserExtension(user); + } catch (Exception ex) { + logger.error("pushUser: saveUserExtension failed", ex); + } + } } @Override @@ -156,7 +163,6 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR if (logger.isDebugEnabled()) logger.debug(EELFLoggerDelegate.debugLogger, "pushUser was invoked: {}", userJson); User user = new User(); - String response = ""; try { // Set input attributes to the object obout to be saved setCurrentAttributes(user, userJson); @@ -185,17 +191,9 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR roles.add(convertToRole(epRole)); } user.setRoles(roles); - if (adminAuthExtensionServiceImpl != null) { - try { - adminAuthExtensionServiceImpl.saveUserExtension(user); - } catch (Exception ex) { - logger.error("pushUser: saveUserExtension failed", ex); - } - } - response = "push user success."; - response = JSONUtil.convertResponseToJSON(response); + saveUserExtension(user); } catch (Exception e) { - response = "OnboardingApiService.pushUser failed"; + String response = "OnboardingApiService.pushUser failed"; logger.error(EELFLoggerDelegate.errorLogger, response, e); throw new PortalAPIException(response, e); } finally { @@ -230,7 +228,17 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR roleFunction.setAction(rolefun.getAction()); return roleFunction; } - + + private void editUserExtension(User domainUser) + { + if (adminAuthExtensionServiceImpl != null) { + try { + adminAuthExtensionServiceImpl.editUserExtension(domainUser); + } catch (Exception ex) { + logger.error("editUser: editUserExtension failed", ex); + } + } + } @Override public void editUser(String loginId, EcompUser userJson) throws PortalAPIException { @@ -239,7 +247,6 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR logger.debug(EELFLoggerDelegate.debugLogger, "OnboardingApi editUser was invoked with loginID {}, JSON {}", loginId, userJson); User editUser = new User(); - String response = ""; try { setCurrentAttributes(editUser, userJson); if (editUser.getOrgUserId() != null) { @@ -266,25 +273,15 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR domainUser.setRoles(roles); // After successful edit, call the admin auth extension - if (adminAuthExtensionServiceImpl != null) { - try { - adminAuthExtensionServiceImpl.editUserExtension(domainUser); - } catch (Exception ex) { - logger.error("editUser: editUserExtension failed", ex); - } - } + editUserExtension(domainUser); - response = "edit user success."; - response = JSONUtil.convertResponseToJSON(response); } catch (Exception e) { - response = "OnboardingApiService.editUser failed"; + String response = "OnboardingApiService.editUser failed"; logger.error(EELFLoggerDelegate.errorLogger, response, e); throw new PortalAPIException(response, e); } finally { MDC.remove(SystemProperties.MDC_TIMER); } - - // return response; } @Override @@ -294,14 +291,14 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR logger.debug(EELFLoggerDelegate.debugLogger, "## REST API ## loginId: {}", loginId); User user = null; - if (isCentralized.equals(isAccessCentralized)) { + if (IS_CENTRALIZED.equals(IS_ACCESS_CENTRALIZED)) { String responseString = restApiRequestBuilder.getViaREST(portalApiVersion+"/user/" + loginId, true, loginId); user = userService.userMapper(responseString); } else{ user = userProfileService.getUserByLoginId(loginId); - user.getRoles().removeIf(role -> (role.getActive() == false)); + user.getRoles().removeIf(role -> (!role.getActive())); } if (user == null) { logger.info(EELFLoggerDelegate.debugLogger, "User + " + loginId + " doesn't exist"); @@ -326,20 +323,20 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR @Override public List<EcompUser> getUsers() throws PortalAPIException { - String users_List = ""; + String usersList = ""; try { - if (isCentralized.equals(isAccessCentralized)) { - List<EcompUser> UsersList = new ArrayList<>(); + if (IS_CENTRALIZED.equals(IS_ACCESS_CENTRALIZED)) { + List<EcompUser> ecompUsers; List<EcompUser> finalUsersList = new ArrayList<>(); - users_List = restApiRequestBuilder.getViaREST(portalApiVersion + "/users", true, null); + usersList = restApiRequestBuilder.getViaREST(portalApiVersion + "/users", true, null); ObjectMapper mapper = new ObjectMapper(); - UsersList = mapper.readValue(users_List, + ecompUsers = mapper.readValue(usersList, TypeFactory.defaultInstance().constructCollectionType(List.class, EcompUser.class)); - for (EcompUser userString : UsersList) { + for (EcompUser userString : ecompUsers) { EcompUser ecompUser = mapper.convertValue(userString, EcompUser.class); finalUsersList.add(ecompUser); } - return UsersList; + return ecompUsers; } else { List<User> users = userProfileService.findAllActive(); @@ -351,7 +348,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR } catch (Exception e) { String response = "OnboardingApiService.getUsers failed"; logger.error(EELFLoggerDelegate.errorLogger, response, e); - if (users_List.equals("")) { + if (usersList.isEmpty()) { throw new PortalAPIException("Application is Inactive"); } else { throw new PortalAPIException(response, e); @@ -374,9 +371,19 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR } } + private void saveUserRoleExtension(Set<Role> roles, User user) + { + if (adminAuthExtensionServiceImpl != null) { + try { + adminAuthExtensionServiceImpl.saveUserRoleExtension(roles, user); + } catch (Exception ex) { + logger.error("pushUserRole: saveUserRoleExtension failed", ex); + } + } + } + @Override public void pushUserRole(String loginId, List<EcompRole> rolesJson) throws PortalAPIException { - String response = ""; try { if (logger.isDebugEnabled()) logger.debug(EELFLoggerDelegate.debugLogger, "## REST API ## loginId: {}, roles Json {}", loginId, @@ -397,26 +404,23 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR logger.debug(EELFLoggerDelegate.debugLogger, "push user role success."); // After successful creation, call admin auth extension - if (adminAuthExtensionServiceImpl != null) { - try { - adminAuthExtensionServiceImpl.saveUserRoleExtension(roles, user); - } catch (Exception ex) { - logger.error("pushUserRole: saveUserRoleExtension failed", ex); - } - } - response = "push user role success."; - response = JSONUtil.convertResponseToJSON(response); - + saveUserRoleExtension(roles,user); } catch (Exception e) { - response = "OnboardingApiService.pushUserRole failed"; + String response = "OnboardingApiService.pushUserRole failed"; logger.error(EELFLoggerDelegate.errorLogger, response, e); throw new PortalAPIException(response, e); } finally { MDC.remove(SystemProperties.MDC_TIMER); } - } + private static void addRoles2Ecomp(SortedSet<Role> currentRoles,List<EcompRole> ecompRoles) + { + if (currentRoles != null && ecompRoles!=null) + for (Role role : currentRoles) + ecompRoles.add(UserUtils.convertToEcompRole(role)); + } + @Override public List<EcompRole> getUserRoles(String loginId) throws PortalAPIException { if (logger.isDebugEnabled()) @@ -424,7 +428,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR List<EcompRole> ecompRoles = new ArrayList<>(); try { - if (isCentralized.equals(isAccessCentralized)) { + if (IS_CENTRALIZED.equals(IS_ACCESS_CENTRALIZED)) { User user = null; String responseString = restApiRequestBuilder.getViaREST(portalApiVersion+"/user/" + loginId, true, loginId); @@ -432,19 +436,15 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR SortedSet<Role> currentRoles = null; if (user != null) { currentRoles = user.getRoles(); - if (currentRoles != null) - for (Role role : currentRoles) - ecompRoles.add(UserUtils.convertToEcompRole(role)); + addRoles2Ecomp(currentRoles,ecompRoles); } } else { User user = userProfileService.getUserByLoginId(loginId); SortedSet<Role> currentRoles = null; if (user != null) { currentRoles = user.getRoles(); - currentRoles.removeIf(role -> (role.getActive() == false)); - if (currentRoles != null) - for (Role role : currentRoles) - ecompRoles.add(UserUtils.convertToEcompRole(role)); + currentRoles.removeIf(role -> (!role.getActive())); + addRoles2Ecomp(currentRoles,ecompRoles); } } return ecompRoles; @@ -486,13 +486,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR try { String appUser = request.getHeader("username"); String password = request.getHeader("password"); - // System.out.println("username = " + appUser); - // System.out.println("password = " + password); - boolean flag = securityService.verifyRESTCredential(null, appUser, password); - // System.out.println("username = " + appUser); - // System.out.println("password = " + password); - return flag; - + return securityService.verifyRESTCredential(null, appUser, password); } catch (Exception e) { String response = "OnboardingApiService.isAppAuthenticated failed"; logger.error(EELFLoggerDelegate.errorLogger, response, e); @@ -500,11 +494,11 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR } } - public String getSessionTimeOuts() throws Exception { + public String getSessionTimeOuts() { return PortalTimeoutHandler.gatherSessionExtensions(); } - public void updateSessionTimeOuts(String sessionMap) throws Exception { + public void updateSessionTimeOuts(String sessionMap) { PortalTimeoutHandler.updateSessionExtensions(sessionMap); } @@ -514,7 +508,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR } @Override - public Map<String, String> getAppCredentials() throws PortalAPIException{ + public Map<String, String> getAppCredentials() { Map<String, String> credentialsMap = new HashMap<>(); String appName = null; String appUserName = null; diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/ElementMapService.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/ElementMapService.java index 210e494d..7fdc5609 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/ElementMapService.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/ElementMapService.java @@ -655,10 +655,14 @@ public class ElementMapService { Domain eachDomain = domainMap.get(domainsKey); domainWidth += eachDomain.computeSize().getWidth(); } - thisDomain = new Domain(id, name, 2, 2, domainWidth, 10, 3, rows, columns); + thisDomain = new Domain.DomainBuilder().setId(id).setName(name).setInterContWd(2).setInterContH(2) + .setDomainToLayoutWd(domainWidth).setDomainToLayoutH(10).setDomainToContH(3) + .setNumOfRowsofContainer(rows).setNumOfColsofContainer(columns).createDomain(); } else { - thisDomain = new Domain(id, name, 2, 1, 11, 10, 3, rows, columns); + thisDomain = new Domain.DomainBuilder().setId(id).setName(name).setInterContWd(2).setInterContH(1) + .setDomainToLayoutWd(11).setDomainToLayoutH(10).setDomainToContH(3).setNumOfRowsofContainer(rows) + .setNumOfColsofContainer(columns).createDomain(); } thisDomain.setContainers(domainContainersMap); diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/ElementMapServiceTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/ElementMapServiceTest.java index f0e4304c..e2655b59 100644 --- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/ElementMapServiceTest.java +++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/ElementMapServiceTest.java @@ -130,8 +130,9 @@ public class ElementMapServiceTest { Layout layout = new Layout(null, 0, 0, 2, 2); Map<String, Domain> domainRowCol = new HashMap<>(); - Domain domain = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2); - + Domain domain = new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0) + .setDomainToLayoutWd(0).setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2) + .setNumOfColsofContainer(2).createDomain(); Position position = new Position(); position.setX(10); position.setY(10); diff --git a/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Domain.java b/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Domain.java index dcf4fd54..8dd51757 100644 --- a/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Domain.java +++ b/ecomp-sdk/epsdk-domain/src/main/java/org/onap/portalsdk/core/domain/support/Domain.java @@ -65,20 +65,80 @@ public class Domain { double newXafterColl; double YafterColl; - public Domain(String id, String name, double interContWd, double interContH, double domainToLayoutWd, - double domainToLayoutH, double domainToContH, int numOfRowsofContainer, int numOfColsofContainer) { - this.id = id; - this.name = name; - this.interContWd = interContWd; - this.interContH = interContH; - this.domainToLayoutWd = domainToLayoutWd; - this.domainToLayoutH = domainToLayoutH; - this.domainToContH = domainToContH; - this.numOfRowsofContainer = numOfRowsofContainer; - this.numOfColsofContainer = numOfColsofContainer; - } - - public Position getP() { + public static class DomainBuilder { + private String id; + private String name; + private double interContWd; + private double interContH; + private double domainToLayoutWd; + private double domainToLayoutH; + private double domainToContH; + private int numOfRowsofContainer; + private int numOfColsofContainer; + + public DomainBuilder setId(String id) { + this.id = id; + return this; + } + + public DomainBuilder setName(String name) { + this.name = name; + return this; + } + + public DomainBuilder setInterContWd(double interContWd) { + this.interContWd = interContWd; + return this; + } + + public DomainBuilder setInterContH(double interContH) { + this.interContH = interContH; + return this; + } + + public DomainBuilder setDomainToLayoutWd(double domainToLayoutWd) { + this.domainToLayoutWd = domainToLayoutWd; + return this; + } + + public DomainBuilder setDomainToLayoutH(double domainToLayoutH) { + this.domainToLayoutH = domainToLayoutH; + return this; + } + + public DomainBuilder setDomainToContH(double domainToContH) { + this.domainToContH = domainToContH; + return this; + } + + public DomainBuilder setNumOfRowsofContainer(int numOfRowsofContainer) { + this.numOfRowsofContainer = numOfRowsofContainer; + return this; + } + + public DomainBuilder setNumOfColsofContainer(int numOfColsofContainer) { + this.numOfColsofContainer = numOfColsofContainer; + return this; + } + + public Domain createDomain() { + return new Domain(this); + } + } + + public Domain(DomainBuilder domainBuilder) { + this.id = domainBuilder.id; + this.name = domainBuilder.name; + this.interContWd = domainBuilder.interContWd; + this.interContH = domainBuilder.interContH; + this.domainToLayoutWd = domainBuilder.domainToLayoutWd; + this.domainToLayoutH = domainBuilder.domainToLayoutH; + this.domainToContH = domainBuilder.domainToContH; + this.numOfRowsofContainer = domainBuilder.numOfRowsofContainer; + this.numOfColsofContainer = domainBuilder.numOfColsofContainer; + } + + public Position getP() { return p; } diff --git a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/DomainTest.java b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/DomainTest.java index ec455b43..016cd3f9 100644 --- a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/DomainTest.java +++ b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/DomainTest.java @@ -43,9 +43,6 @@ import java.util.HashMap; import java.util.Map; import org.junit.Test; -import org.onap.portalsdk.core.domain.support.Container; -import org.onap.portalsdk.core.domain.support.Domain; -import org.onap.portalsdk.core.domain.support.Size; public class DomainTest { @@ -53,7 +50,10 @@ public class DomainTest { public Domain mockDomain(){ - Domain domain = new Domain(null, null, 0, 0, 0, 0, 0, 0, 0); + Domain domain = + new Domain.DomainBuilder().setId(null).setName(null).setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(0).setNumOfColsofContainer(0) + .createDomain(); domain.setP(null); domain.setNewXafterColl(0); @@ -74,7 +74,10 @@ public class DomainTest { public void domainTest(){ Domain domain = mockDomain(); - Domain domain1 = new Domain(null, null, 0, 0, 0, 0, 0, 0, 0); + Domain domain1 = + new Domain.DomainBuilder().setId(null).setName(null).setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(0).setNumOfColsofContainer(0) + .createDomain(); domain1.setP(null); domain1.setNewXafterColl(0); @@ -103,7 +106,10 @@ public class DomainTest { @Test public void computeSizeTest(){ - Domain domain = new Domain("test", "VNI", 0, 0, 0, 0, 0, 2, 2); + Domain domain = + new Domain.DomainBuilder().setId("test").setName("VNI").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); Container container = new Container("test","test",1,1,10,10,10,10,10,10); Map<String, Container> containerRowCol = new HashMap<>(); containerRowCol.put("00", container); @@ -115,7 +121,10 @@ public class DomainTest { } @Test public void computeSizeWithoutNameTest(){ - Domain domain = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2); + Domain domain = + new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); Container container = new Container("test","test",1,1,10,10,10,10,10,10); Map<String, Container> containerRowCol = new HashMap<>(); containerRowCol.put("00", container); @@ -135,7 +144,10 @@ public class DomainTest { containerRowCol.put("10", container01); containerRowCol.put("11", container01); - Domain domain = new Domain("test", "XYZ", 0, 1, 1, 4, 4, 2, 2); + Domain domain = + new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(1).setDomainToLayoutWd(1) + .setDomainToLayoutH(4).setDomainToContH(4).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); domain.setContainers(containerRowCol); domain.computeConatinerPositions(); assertEquals(21.0, domain.getContainerRowCol().get("10").getP().getX(), DELTA); diff --git a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/LayoutTest.java b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/LayoutTest.java index c7038144..1573da86 100644 --- a/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/LayoutTest.java +++ b/ecomp-sdk/epsdk-domain/src/test/java/org/onap/portalsdk/core/domain/support/LayoutTest.java @@ -45,10 +45,6 @@ import java.util.List; import java.util.Map; import org.junit.Test; -import org.onap.portalsdk.core.domain.support.Container; -import org.onap.portalsdk.core.domain.support.Domain; -import org.onap.portalsdk.core.domain.support.Layout; -import org.onap.portalsdk.core.domain.support.Position; public class LayoutTest { @@ -84,7 +80,10 @@ public class LayoutTest { @Test public void computeDomainPositionsTest(){ Layout layout = new Layout(null, 0, 0, 2, 2); - Domain domain = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2); + Domain domain = + new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); Map<String, Domain> domainRowCol = new HashMap<>(); List<Domain> domainList = new ArrayList<>(); domainList.add(domain); @@ -100,7 +99,10 @@ public class LayoutTest { @Test public void computeDomainPositionsModifiedTest(){ Layout layout = new Layout(null, 0, 0, 2, 2); - Domain domain = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2); + Domain domain = + new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); Map<String, Container> containerRowCol = new HashMap<>(); Container container00 = new Container("test","test",1,1,10,10,10,10,10,10); Position position = new Position(); @@ -124,8 +126,14 @@ public class LayoutTest { @Test public void collapseDomainModifiedTest(){ Layout layout = new Layout(null, 0, 0, 2, 2); - Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2); - Domain domain2 = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2); + Domain domain = + new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); + Domain domain2 = + new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); Map<String, Container> containerRowCol = new HashMap<>(); Container container00 = new Container("test","test",1,1,10,10,10,10,10,10); Position position = new Position(); @@ -149,8 +157,14 @@ public class LayoutTest { @Test public void collapseDomainNewTest(){ Layout layout = new Layout(null, 0, 0, 2, 2); - Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2); - Domain domain2 = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2); + Domain domain = + new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); + Domain domain2 = + new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); Map<String, Container> containerRowCol = new HashMap<>(); Container container00 = new Container("test","test",1,1,10,10,10,10,10,10); Position position = new Position(); @@ -174,8 +188,14 @@ public class LayoutTest { @Test public void collapseDomainTest(){ Layout layout = new Layout(null, 0, 0, 2, 2); - Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2); - Domain domain2 = new Domain("test", "XYZ", 0, 0, 0, 0, 0, 2, 2); + Domain domain = + new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); + Domain domain2 = + new Domain.DomainBuilder().setId("test").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); Map<String, Container> containerRowCol = new HashMap<>(); Container container00 = new Container("test","test",1,1,10,10,10,10,10,10); Position position = new Position(); @@ -204,7 +224,10 @@ public class LayoutTest { Layout layout = new Layout(null, 0, 0, 2, 2); - Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2); + Domain domain = + new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); Position position = new Position(); position.setX(10); position.setY(10); @@ -239,7 +262,10 @@ public class LayoutTest { public void uncollapseDomainTest(){ Layout layout = new Layout(null, 0, 0, 2, 2); - Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2); + Domain domain = + new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); Position position = new Position(); position.setX(10); position.setY(10); @@ -272,7 +298,10 @@ public class LayoutTest { public void uncollapseDomainNewTest(){ Layout layout = new Layout(null, 0, 0, 2, 2); - Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2); + Domain domain = + new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); Position position = new Position(); position.setX(10); position.setY(10); @@ -304,7 +333,10 @@ public class LayoutTest { Layout layout = new Layout(null, 0, 0, 2, 2); - Domain domain = new Domain("test1", "XYZ", 0, 0, 0, 0, 0, 2, 2); + Domain domain = + new Domain.DomainBuilder().setId("test1").setName("XYZ").setInterContWd(0).setInterContH(0).setDomainToLayoutWd(0) + .setDomainToLayoutH(0).setDomainToContH(0).setNumOfRowsofContainer(2).setNumOfColsofContainer(2) + .createDomain(); Position position = new Position(); position.setX(10); position.setY(10); diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSession.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSession.java index 1f68bda0..322e1b41 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSession.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSession.java @@ -283,8 +283,6 @@ public final class MusicSession implements Session, Serializable { } } catch (MusicLockingException e) { logger.error(EELFLoggerDelegate.errorLogger, "isExpired locking failed with id:" + id, e); - } catch (MusicServiceException e) { - logger.error(EELFLoggerDelegate.errorLogger, "isExpired failed with id:" + id, e); } return isExpired; } @@ -331,8 +329,6 @@ public final class MusicSession implements Session, Serializable { MusicService.removeAttribute(attributeName, this.id); }catch(MusicLockingException e){ logger.error(EELFLoggerDelegate.errorLogger, " removeAttribute locking failed id:" + this.id + " attribute name "+ attributeName , e); - }catch(MusicServiceException e){ - logger.error(EELFLoggerDelegate.errorLogger, " removeAttribute failed id:" + this.id + " attribute name "+ attributeName , e); } } diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandler.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandler.java index 0e8551b9..167ed955 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandler.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandler.java @@ -80,8 +80,6 @@ public class MusicSessionRepositoryHandler { MusicService.removeSession(id); } catch (MusicLockingException e) { logger.error(EELFLoggerDelegate.errorLogger, "removeSession locking failed with id " + id, e); - } catch (MusicServiceException e) { - logger.error(EELFLoggerDelegate.errorLogger, "removeSession failed with id " + id, e); } } } 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 3861b2dd..c8d15884 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 @@ -80,9 +80,17 @@ public class MusicService { private static String musicMetaTable = MusicProperties.getProperty(MusicProperties.MUSIC_SESSION_META_TABLES); private static String musicAttrTable = MusicProperties.getProperty(MusicProperties.MUSIC_SESSION_ATTR_TABLES); + private static final String WITH_SESSION_ID = " with session id: "; + private static final String RESULT = "result:"; + private static final String WHERE = " WHERE "; + private static final String FROM = " FROM "; + private static final String DELETE = "DELETE "; + private static final String REMOVE_SESSION = "removeSession: "; + private static final String SUCCESS = "success"; + /** * Store session attribute name and values into Cassandra via Music - * + * * @param attributeName * @param value * @param sessionId @@ -116,18 +124,18 @@ public class MusicService { else result = MusicCore.eventualPut(queryObject); logger.debug(EELFLoggerDelegate.debugLogger, "setAttribute: attributeName: " + attributeName - + " with session id: " + sessionId + "result:" + result.getMessage()); + + WITH_SESSION_ID + sessionId + RESULT + result.getMessage()); return result; } /** * Store session meta data values into Cassandra via Music - * + * * @param session * @return ReturnType that includes required body information for Music api * @throws Exception */ - public static ReturnType setMetaAttribute(Session session) throws Exception { + public static ReturnType setMetaAttribute(Session session) throws MusicLockingException { logger.debug(EELFLoggerDelegate.debugLogger, "setMetaAttribute: start with session id: " + session.getId()); ReturnType result = null; PreparedQueryObject queryObject = new PreparedQueryObject(); @@ -148,14 +156,14 @@ public class MusicService { else result = MusicCore.eventualPut(queryObject); logger.debug(EELFLoggerDelegate.debugLogger, - "setMetaAttribute: with session id: " + session + "result:" + result.getMessage()); + "setMetaAttribute: with session id: " + session + RESULT + result.getMessage()); return result; } /** * Retrieve session meta data from Cassandra via Music - * + * * @param sessionId * @return MusicSession * @throws Exception @@ -165,7 +173,7 @@ public class MusicService { ResultSet result = null; PreparedQueryObject queryObject = new PreparedQueryObject(); StringBuilder querySB = new StringBuilder(); - querySB.append("SELECT * FROM ").append(musicKeySpace).append(".").append(musicMetaTable).append(" WHERE ") + querySB.append("SELECT * FROM ").append(musicKeySpace).append(".").append(musicMetaTable).append(WHERE) .append(MusicProperties.PRIMARY_ID).append("=?;"); queryObject.appendQueryString(querySB.toString()); queryObject.addValue(sessionId); @@ -179,7 +187,7 @@ public class MusicService { /** * Get proper column names (from meta or attribute table) base on isMeta - * + * * @param isMeta * @param attributeName * @return String @@ -199,7 +207,7 @@ public class MusicService { /** * Retrieve session attribute data from Cassandra via Music - * + * * @param attributeName * @param sessionId * @return attribute value with T type @@ -212,8 +220,8 @@ public class MusicService { boolean isMeta = MusicUtil.isSessionMetaAttr(attributeName); PreparedQueryObject queryObject = new PreparedQueryObject(); StringBuilder querySB = new StringBuilder(); - querySB.append("SELECT ").append(getColumn(attributeName, isMeta)).append(" FROM ").append(musicKeySpace) - .append(".").append(getTableName(isMeta)).append(" WHERE ").append(MusicProperties.PRIMARY_ID) + querySB.append("SELECT ").append(getColumn(attributeName, isMeta)).append(FROM).append(musicKeySpace) + .append(".").append(getTableName(isMeta)).append(WHERE).append(MusicProperties.PRIMARY_ID) .append("= ?"); queryObject.addValue(sessionId); @@ -235,22 +243,22 @@ public class MusicService { /** * Remove session attribute data from Cassandra via Music - * + * * @param attributeName * @param sessionId * @return ReturnType * @throws MusicServiceException - * @throws MusicLockingException + * @throws MusicLockingException */ - public static ReturnType removeAttribute(String attributeName, String sessionId) throws MusicServiceException, MusicLockingException { + public static ReturnType removeAttribute(String attributeName, String sessionId) throws MusicLockingException { logger.debug(EELFLoggerDelegate.debugLogger, "removeAttribute: start with session id: " + sessionId); boolean isMeta = MusicUtil.isSessionMetaAttr(attributeName); ReturnType result = null; String tableName = null; PreparedQueryObject queryObject = new PreparedQueryObject(); StringBuilder querySB = new StringBuilder(); - querySB.append("DELETE ").append(getDelColumn(isMeta, attributeName)).append(" FROM ").append(musicKeySpace) - .append(".").append(getTableName(isMeta)).append(" WHERE ").append(MusicProperties.PRIMARY_ID) + querySB.append(DELETE).append(getDelColumn(isMeta, attributeName)).append(FROM).append(musicKeySpace) + .append(".").append(getTableName(isMeta)).append(WHERE).append(MusicProperties.PRIMARY_ID) .append("= ? "); queryObject.addValue(sessionId); @@ -266,40 +274,40 @@ public class MusicService { else result = MusicCore.eventualPut(queryObject); logger.debug(EELFLoggerDelegate.debugLogger, - "removeSession: " + attributeName + " with session id: " + sessionId + "result:" + result.getMessage()); + REMOVE_SESSION + attributeName + WITH_SESSION_ID + sessionId + RESULT + result.getMessage()); return result; } /** * Remove entire session from Cassandra via Music - * + * * @param sessionId * @return ReturnType * @throws MusicServiceException - * @throws MusicLockingException + * @throws MusicLockingException */ - public static ReturnType removeSession(String sessionId) throws MusicServiceException, MusicLockingException { + public static ReturnType removeSession(String sessionId) throws MusicLockingException { ReturnType result = null; boolean isAtomic = isAtomicPut; logger.debug(EELFLoggerDelegate.debugLogger, "removeSession: start with session id: " + sessionId); PreparedQueryObject queryObject = new PreparedQueryObject(); StringBuilder querySB = new StringBuilder(); - querySB.append("DELETE ").append(" FROM ").append(musicKeySpace).append(".").append(musicMetaTable) - .append(" WHERE ").append(MusicProperties.PRIMARY_ID).append("= ? "); + querySB.append(DELETE).append(FROM).append(musicKeySpace).append(".").append(musicMetaTable) + .append(WHERE).append(MusicProperties.PRIMARY_ID).append("= ? "); queryObject.appendQueryString(querySB.toString()); queryObject.addValue(sessionId); if (isAtomic) result = MusicCore.atomicPutWithDeleteLock(musicKeySpace, musicMetaTable, sessionId, queryObject, null); else result = MusicCore.eventualPut(queryObject); - logger.debug(EELFLoggerDelegate.debugLogger, "removeSession: " + musicMetaTable + " with session id: " - + sessionId + "result:" + result.getMessage()); + logger.debug(EELFLoggerDelegate.debugLogger, REMOVE_SESSION + musicMetaTable + WITH_SESSION_ID + + sessionId + RESULT + result.getMessage()); queryObject = new PreparedQueryObject(); querySB = new StringBuilder(); - querySB.append("DELETE ").append(" FROM ").append(musicKeySpace).append(".").append(musicAttrTable) - .append(" WHERE ").append(MusicProperties.PRIMARY_ID).append("= ? "); + querySB.append(DELETE).append(FROM).append(musicKeySpace).append(".").append(musicAttrTable) + .append(WHERE).append(MusicProperties.PRIMARY_ID).append("= ? "); queryObject.appendQueryString(querySB.toString()); queryObject.addValue(sessionId); if (isAtomic) @@ -307,15 +315,15 @@ public class MusicService { else result = MusicCore.eventualPut(queryObject); - logger.debug(EELFLoggerDelegate.debugLogger, "removeSession: " + musicAttrTable + " with session id: " - + sessionId + "result:" + result.getMessage()); + logger.debug(EELFLoggerDelegate.debugLogger, REMOVE_SESSION + musicAttrTable + WITH_SESSION_ID + + sessionId + RESULT + result.getMessage()); return result; } /** * Get proper table name (Meta or Attribute) base on isMeta. - * + * * @param isMeta * @return String */ @@ -330,7 +338,7 @@ public class MusicService { /** * Get proper column name (Meta or Attribute) base on isMeta. - * + * * @param attributeName * @param isMeta * @return String @@ -346,7 +354,7 @@ public class MusicService { /** * Get proper column name (Meta or Attribute) base on isMeta for removing. - * + * * @param attributeName * @param isMeta * @return String @@ -360,7 +368,7 @@ public class MusicService { /** * To set session attributes in Music - * + * * @param attributeName * @param value * @param session @@ -374,22 +382,22 @@ public class MusicService { String sessionId, String className, boolean isMeta) throws JsonProcessingException { System.out.println("setAttribute: " + attributeName); RestResponse<String> portalRestResponse = null; - HttpEntity<Map<String, Object>> entity = new HttpEntity<Map<String, Object>>( + HttpEntity<Map<String, Object>> entity = new HttpEntity<>( getMusicRestBody(attributeName, value, sessionId, session, className, isMeta), getMusicHeader()); String url = getInsertUrl(isMeta); ResponseEntity<String> response = null; try { response = template.exchange(url, HttpMethod.POST, entity, String.class); - portalRestResponse = new RestResponse<String>(RestStatusEnum.OK, "success", response.getBody()); + portalRestResponse = new RestResponse<>(RestStatusEnum.OK, SUCCESS, response.getBody()); } catch (Exception e) { - portalRestResponse = new RestResponse<String>(RestStatusEnum.ERROR, e.getMessage(), null); + portalRestResponse = new RestResponse<>(RestStatusEnum.ERROR, e.getMessage(), null); } return portalRestResponse; } /** * To get session attribute in Music - * + * * @param attributeName * @param value * @param sessionId @@ -401,23 +409,22 @@ public class MusicService { boolean isMeta) { System.out.println("getAttribute: " + attributeName); RestResponse<String> portalRestResponse = null; - HttpEntity<String> entity = new HttpEntity<String>(null, getMusicHeader()); + HttpEntity<String> entity = new HttpEntity<>(null, getMusicHeader()); ResponseEntity<String> response = null; String url = getSelectSessionIdUrl(attributeName, sessionId, isMeta); try { response = template.exchange(url, HttpMethod.GET, entity, String.class); - portalRestResponse = new RestResponse<String>(RestStatusEnum.OK, "success", response.getBody()); + portalRestResponse = new RestResponse<>(RestStatusEnum.OK, SUCCESS, response.getBody()); } catch (Exception e) { - portalRestResponse = new RestResponse<String>(RestStatusEnum.ERROR, e.getMessage(), null); + portalRestResponse = new RestResponse<>(RestStatusEnum.ERROR, e.getMessage(), null); } return portalRestResponse; } /** * To remove session attribute or session meta in Music - * + * * @param attributeName - * @param value * @param sessionId * @param isMeta * @return RestResponse<String> @@ -428,20 +435,18 @@ public class MusicService { ResponseEntity<String> response = null; String url = getSelectSessionIdUrl(attributeName, sessionId, true); try { - response = template.exchange(url, HttpMethod.DELETE, entity, String.class); - portalRestResponse = new RestResponse<String>(RestStatusEnum.OK, "success", response.getBody()); url = getSelectSessionIdUrl(attributeName, sessionId, false); response = template.exchange(url, HttpMethod.DELETE, entity, String.class); - portalRestResponse = new RestResponse<String>(RestStatusEnum.OK, "success", response.getBody()); + portalRestResponse = new RestResponse<>(RestStatusEnum.OK, SUCCESS, response.getBody()); } catch (Exception e) { - portalRestResponse = new RestResponse<String>(RestStatusEnum.ERROR, e.getMessage(), null); + portalRestResponse = new RestResponse<>(RestStatusEnum.ERROR, e.getMessage(), null); } return portalRestResponse; } /** * Generate body for Music api calls - * + * * @return String that includes required body information for Music api * calls * @throws JsonProcessingException @@ -475,7 +480,7 @@ public class MusicService { /** * Generate body for Music delete api calls - * + * * @return String that includes required body information for Music api * calls * @throws JsonProcessingException @@ -512,7 +517,7 @@ public class MusicService { /** * Generate header for Music api calls - * + * * @return header that contains required header information for Music api * calls */ @@ -529,7 +534,7 @@ public class MusicService { /** * Construct URL for Music api calls - * + * * @return path */ private static String constructPath(boolean isMeta) { @@ -545,10 +550,10 @@ public class MusicService { path.append("/"); return path.toString(); } - + /** * Get a list of sessions that need to be cleaned up - * + * * @return List<String> */ private static List<String> getSessionToBeDeleted(){ @@ -559,15 +564,15 @@ public class MusicService { List<String> sessionIDList = new ArrayList<>(); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); StringBuilder querySB = new StringBuilder(); - String cleanUpThreshold = MusicProperties.getProperty(MusicProperties.MUSIC_CLEAN_UP_THRESHOLD); //Clean up sessions that's cleanUpThreshold hours ago - Date dateForCleanup = new Date(System.currentTimeMillis() - 3600 * 1000 * Integer.valueOf(cleanUpThreshold)); // Get the threshold date that needs to be clean up + String cleanUpThreshold = MusicProperties.getProperty(MusicProperties.MUSIC_CLEAN_UP_THRESHOLD); //Clean up sessions that's cleanUpThreshold hours ago + Date dateForCleanup = new Date(System.currentTimeMillis() - 3600 * 1000 * Integer.valueOf(cleanUpThreshold)); // Get the threshold date that needs to be clean up String dateForCleanupCondition = dateFormat.format(dateForCleanup); - querySB.append("SELECT ").append(MusicProperties.PRIMARY_ID).append(" FROM ").append(musicKeySpace) - .append(".").append(getTableName(true)).append(" WHERE ").append(MusicProperties.LAST_ACCESS_TIME) + querySB.append("SELECT ").append(MusicProperties.PRIMARY_ID).append(FROM).append(musicKeySpace) + .append(".").append(getTableName(true)).append(WHERE).append(MusicProperties.LAST_ACCESS_TIME) .append("< ? ").append(" ALLOW FILTERING"); queryObject.appendQueryString(querySB.toString()); queryObject.addValue(dateForCleanupCondition); - + try{ if (isAtomicGet) result = MusicCore.atomicGetWithDeleteLock(musicKeySpace, musicMetaTable, null, queryObject); @@ -583,10 +588,10 @@ public class MusicService { } return sessionIDList; } - + /** * Remove session data in music base on the defined frequency - * + * * @return List<String> */ public static void cleanUpMusic() { @@ -605,13 +610,13 @@ public class MusicService { sessionIDListCondition.deleteCharAt(sessionIDListCondition.length()-1); sessionIDListCondition.deleteCharAt(sessionIDListCondition.length()-1); sessionIDListCondition.append(")"); - StringBuilder querySB = new StringBuilder(); + StringBuilder querySB = new StringBuilder(); PreparedQueryObject queryObject = new PreparedQueryObject(); /**Deleting attributes table**/ querySB = new StringBuilder(); queryObject = new PreparedQueryObject(); querySB.append("DELETE FROM ").append(musicKeySpace) - .append(".").append(getTableName(false)).append(" WHERE ").append(MusicProperties.PRIMARY_ID) + .append(".").append(getTableName(false)).append(WHERE).append(MusicProperties.PRIMARY_ID) .append(" in ").append(sessionIDListCondition); queryObject.appendQueryString(querySB.toString()); try{ @@ -623,13 +628,13 @@ public class MusicService { logger.error(EELFLoggerDelegate.errorLogger, "Error while cleaning up music attributes tables" , e); } logger.debug(EELFLoggerDelegate.debugLogger, "Music sessions have been cleaned up !"); - + /**Deleting meta table**/ logger.debug(EELFLoggerDelegate.debugLogger, "Cleaning up meta table ..."); querySB = new StringBuilder(); queryObject = new PreparedQueryObject(); querySB.append("DELETE FROM ").append(musicKeySpace) - .append(".").append(getTableName(true)).append(" WHERE ").append(MusicProperties.PRIMARY_ID) + .append(".").append(getTableName(true)).append(WHERE).append(MusicProperties.PRIMARY_ID) .append(" in ").append(sessionIDListCondition); queryObject.appendQueryString(querySB.toString()); try{ @@ -640,13 +645,13 @@ public class MusicService { }catch(Exception e){ logger.error(EELFLoggerDelegate.errorLogger, "Error while cleaning up music meta tables" , e); } - + logger.debug(EELFLoggerDelegate.debugLogger, "Cleaned up attributes table ... "); }else{ logger.debug(EELFLoggerDelegate.debugLogger, "No Session needs to be cleaned up"); } - - } + + } } } diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicCleanUp.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicCleanUp.java index aab04eaf..72ce5f67 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicCleanUp.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicCleanUp.java @@ -42,12 +42,13 @@ import java.util.Date; public class MusicCleanUp { private static volatile MusicCleanUp musicCleanUp = new MusicCleanUp(); + + private Date lastCleanUpTime = new Date(); + // private constructor restricted to this class itself private MusicCleanUp(){ } - private Date lastCleanUpTime = new Date(); - public static MusicCleanUp getInstance(){ return musicCleanUp; } diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java index 15c3bb0c..2e17d0c1 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java @@ -68,11 +68,18 @@ public class MusicUtil { private static String cleanUpFreq = MusicProperties.getProperty(MusicProperties.MUSIC_CLEAN_UP_FREQUENCY); private static String musicSerializeCompress = MusicProperties.getProperty(MusicProperties.MUSIC_SERIALIZE_COMPRESS); private static String musicEnable = MusicProperties.getProperty(MusicProperties.MUSIC_ENABLE); + private static final String FAILED_2_READ_PROPERTY_FILE = "Failed to read property file "; + private static final String TRUE = "true"; public static boolean isSessionMetaAttr(String key){ return sessionAttrNameSet.contains(key); } + //hide public constructor + private MusicUtil() + { + } + @SuppressWarnings("unchecked") public static <T> T musicRestResponseDataParsing(ResultSet rs, String attributeName) throws Exception{ logger.debug(EELFLoggerDelegate.debugLogger, "musicRestResponseDataParsing: start"); @@ -87,7 +94,7 @@ public class MusicUtil { } @SuppressWarnings("unchecked") - public static <T> T musicDeserialize (ByteBuffer byteBuf) throws Exception{ + public static <T> T musicDeserialize (ByteBuffer byteBuf) throws IOException, ClassNotFoundException { logger.debug(EELFLoggerDelegate.debugLogger, "musicDeserialize: start"); ByteArrayInputStream byteArr = new ByteArrayInputStream(byteBuf.array()); ObjectInputStream ois = null; @@ -100,7 +107,7 @@ public class MusicUtil { return (T) ois.readObject(); } - public static ByteBuffer musicSerialize (Object value) throws Exception{ + public static ByteBuffer musicSerialize (Object value) { logger.debug(EELFLoggerDelegate.debugLogger, "musicSerialize: start"); ByteArrayOutputStream bo = new ByteArrayOutputStream(); try { @@ -121,7 +128,7 @@ public class MusicUtil { return ByteBuffer.wrap(bo.toByteArray()); } - public static MusicSession parseMetaData (Row row) throws Exception{ + public static MusicSession parseMetaData (Row row) { logger.debug(EELFLoggerDelegate.debugLogger, "parseMetaData: start"); if(row==null) @@ -157,34 +164,34 @@ public class MusicUtil { public static boolean isMusicSerializeCompress(){ if(musicSerializeCompress==null){ - logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + MusicProperties.MUSIC_SERIALIZE_COMPRESS +" fall back to eventual put"); + logger.error(EELFLoggerDelegate.errorLogger, FAILED_2_READ_PROPERTY_FILE + MusicProperties.MUSIC_SERIALIZE_COMPRESS +" fall back to eventual put"); return false; } - return musicSerializeCompress.trim().equalsIgnoreCase("true"); + return TRUE.equalsIgnoreCase(musicSerializeCompress.trim()); } public static boolean isAtomicPut(){ if(atomicPut==null){ - logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + MusicProperties.MUSIC_ATOMIC_PUT +" fall back to eventual put"); + logger.error(EELFLoggerDelegate.errorLogger, FAILED_2_READ_PROPERTY_FILE + MusicProperties.MUSIC_ATOMIC_PUT +" fall back to eventual put"); return false; } - return atomicPut.trim().equalsIgnoreCase("true"); + return TRUE.equalsIgnoreCase(atomicPut.trim()); } public static boolean isAtomicGet(){ if(atomicGet==null){ - logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + MusicProperties.MUSIC_ATOMIC_GET +" fall back to eventual get"); + logger.error(EELFLoggerDelegate.errorLogger, FAILED_2_READ_PROPERTY_FILE + MusicProperties.MUSIC_ATOMIC_GET +" fall back to eventual get"); return false; } - return atomicGet.trim().equalsIgnoreCase("true"); + return TRUE.equalsIgnoreCase(atomicGet.trim()); } public static boolean isCached(){ if(cached==null){ - logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + MusicProperties.MUSIC_CACHE +" fall back to non cache"); + logger.error(EELFLoggerDelegate.errorLogger, FAILED_2_READ_PROPERTY_FILE + MusicProperties.MUSIC_CACHE +" fall back to non cache"); return false; } - return cached.trim().equalsIgnoreCase("true"); + return TRUE.equalsIgnoreCase(cached.trim()); } public static int convertHoursToMillSec(int hour){ @@ -211,9 +218,7 @@ public class MusicUtil { public static boolean isMusicEnable(){ if(musicEnable==null) return false; - if(musicEnable.equals("true")) - return true; - else - return false; + + return TRUE.equals(musicEnable); } } diff --git a/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionTest.java b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionTest.java index 65290d48..fab1ba7b 100644 --- a/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionTest.java +++ b/ecomp-sdk/epsdk-music/src/test/java/org/onap/portalapp/music/conf/MusicSessionTest.java @@ -233,14 +233,7 @@ public class MusicSessionTest { } @Test - public void removeAttributeMusicServiceExceptionTest() throws MusicServiceException, MusicLockingException { - Mockito.when(MusicService.removeAttribute(Matchers.anyString(), Matchers.anyString())) - .thenThrow(new MusicServiceException()); - musicSession.removeAttribute("test_attr_name"); - } - - @Test - public void removeAttributeMusicLockingExceptionTest() throws MusicServiceException, MusicLockingException { + public void removeAttributeMusicLockingExceptionTest() throws MusicLockingException { Mockito.when(MusicService.removeAttribute(Matchers.anyString(), Matchers.anyString())) .thenThrow(new MusicLockingException()); musicSession.removeAttribute("test_attr_name"); |