diff options
7 files changed, 60 insertions, 72 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java index 7e76c46f..3eca7c68 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java @@ -147,7 +147,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { private static final String REPORT_DOWNLOAD = "report.download"; private static final String REPORT_DOWNLOAD_PAGE = ";report.download.page"; private static final String FALSE = "false"; - + private static final String COLNAME = "[colName]"; private void preserveReportRuntimeAsBackup(HttpServletRequest request) { HttpSession session = request.getSession(); ArrayList repAl = null; @@ -254,8 +254,8 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { downloadLimit = Globals.getCSVDownloadLimit(); if(rr!=null && rr.getReportType().equals(AppConstants.RT_LINEAR)) { - String sql_whole = rr.getReportDataSQL(userId, downloadLimit, request); - request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sql_whole); + String sqlWhole = rr.getReportDataSQL(userId, downloadLimit, request); + request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sqlWhole); } else if(rr!=null && rr.getReportType().equals(AppConstants.RT_CROSSTAB)) { rd = rr.loadReportData(-1, userId, downloadLimit,request, false); /* TODO: should be changed to true */ request.getSession().setAttribute(AppConstants.RI_REPORT_DATA, rd); @@ -683,11 +683,11 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { request.getSession().setAttribute(AppConstants.RI_REPORT_DATA, rd); //if (Globals.getMapAllowedYN().equals("Y") && !hideReportMap && (rr.getReportMap()!=null && rr.getReportMap().getLatColumn()!=null && rr.getReportMap().getLongColumn()!=null)) { if(rr!=null && rr.getReportType().equals(AppConstants.RT_LINEAR)) { - String sql_whole = rr.getReportDataSQL(userId, downloadLimit, request); - request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sql_whole); + String sqlWhole = rr.getReportDataSQL(userId, downloadLimit, request); + request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sqlWhole); } else if(rr.getReportType().equals(AppConstants.RT_HIVE)) { - String sql_whole = rr.getReportSQL(); - request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sql_whole); + String sqlWhole = rr.getReportSQL(); + request.setAttribute(AppConstants.RI_REPORT_SQL_WHOLE, sqlWhole); } if (!rr.getReportType().equals(AppConstants.RT_HIVE)) { long currentChartTime = System.currentTimeMillis(); @@ -1315,8 +1315,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { FormField ff = rr.getFormField(request.getParameter(AppConstants.RI_FIELD_NAME)); ReportFormFields rff = rr.getReportFormFields(); - - int idx = 0; + FormField ff1 = null; Map fieldNameMap = new HashMap(); int countOfFields = 0 ; @@ -1325,27 +1324,27 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { String oldSQL = lookup.getOldSql(); if(AppUtils.getRequestFlag(request, AppConstants.RI_TEXTFIELD_POP)) { - for(rff.resetNext(); rff.hasNext(); idx++) { + for(rff.resetNext(); rff.hasNext(); ) { ff1 = rff.getNext(); fieldNameMap.put(ff1.getFieldName(), ff1.getFieldDisplayName()); countOfFields++; } - - - //List formParameter = new ArrayList(); + String formField = ""; HashMap valuesMap = new HashMap(); for(int i = 0 ; i < rff.size(); i++) { - formField = ((FormField)rff.getFormField(i)).getFieldName(); + formField = (rff.getFormField(i)).getFieldName(); if(request.getParameterValues(formField) != null && request.getParameterValues(formField).length > 1 ) { - String[] vals = (String[]) request.getParameterValues(formField); + String[] vals = request.getParameterValues(formField); String value = ""; - StringBuffer valueBuf = new StringBuffer(); + StringBuilder valueBuf = new StringBuilder(); for(int ii = 0 ; ii < vals.length; ii++) { - if(ii == 0) valueBuf.append("("); + if(ii == 0) + valueBuf.append("("); valueBuf.append(vals[ii]); - if(ii == vals.length-1) valueBuf.append(")"); - else valueBuf.append(","); + if(ii == vals.length-1) + valueBuf.append(")"); + else valueBuf.append(","); } value = valueBuf.toString(); valuesMap.put(fieldNameMap.get(formField), value); @@ -1359,16 +1358,18 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { oldSQL = SQL; Set set = valuesMap.entrySet(); String value = ""; - StringBuffer valueBuf = new StringBuffer(); + StringBuilder valueBuf = new StringBuilder(); for(Iterator iter = set.iterator(); iter.hasNext(); ) { Map.Entry entry = (Entry) iter.next(); if(entry.getValue() instanceof String[]) { String[] vals = (String[]) entry.getValue(); for(int i = 0 ; i < vals.length; i++) { - if(i == 0) valueBuf.append("("); + if(i == 0) + valueBuf.append("("); valueBuf.append(vals[i]); - if(i == vals.length-1) valueBuf.append(")"); - else valueBuf.append(","); + if(i == vals.length-1) + valueBuf.append(")"); + else valueBuf.append(","); } value = valueBuf.toString(); } else { @@ -1427,27 +1428,19 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { if (Utils.isNull(dbInfo)) { dbInfo = (String) request.getSession().getAttribute("remoteDB"); } - /*String query = "SELECT x FROM (SELECT DISTINCT " - + (colType.equals(AppConstants.CT_DATE) ? ("TO_CHAR(" + colName + ", '" - + nvl(displayFormat, AppConstants.DEFAULT_DATE_FORMAT) + "')") - : colName) + " x FROM " - + rdef.getTableById(tableId).getTableName() + " WHERE " + colName - + " IS NOT NULL ORDER BY 1) xx WHERE ROWNUM <= " - + Globals.getDefaultPageSize();*/ - String q1 = Globals.getReportValuesMapDefA(); String q2 = Globals.getReportValuesMapDefB(); - q2 = q2.replace("[colName]", colName); + q2 = q2.replace(COLNAME, colName); q2 = q2.replace("[nvl(displayFormat, AppConstants.DEFAULT_DATE_FORMAT)]", nvl(displayFormat, AppConstants.DEFAULT_DATE_FORMAT)); String q3 = Globals.getReportValuesMapDefC(); - q3 = q3.replace("[colName]", colName); + q3 = q3.replace(COLNAME, colName); String q4 = Globals.getReportValuesMapDefD(); q4 = q4.replace("[rdef.getTableById(tableId).getTableName()]", rdef.getTableById(tableId).getTableName()); - q4 = q4.replace("[colName]", colName); + q4 = q4.replace(COLNAME, colName); q4 = q4.replace("[Globals.getDefaultPageSize()]", String.valueOf(Globals.getDefaultPageSize())); String query = q1 + (colType.equals(AppConstants.CT_DATE) ? q2 : q3) + q4; @@ -1463,8 +1456,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { public String reportDrillDownToReportDefPopup(HttpServletRequest request, String nextPage) { try { - // ReportDefinition rdef = (ReportDefinition) - // request.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION); String ddReportID = AppUtils .getRequestNvlValue(request, AppConstants.RI_REPORT_ID); ReportRuntime ddRr = (new ReportHandler()).loadReportRuntime(request, ddReportID, 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 bd8d778e..8605f208 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/WizardProcessor.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/WizardProcessor.java @@ -109,6 +109,9 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WizardProcessor.class); + public WizardProcessor() { + } + public static Calendar getCalendar(XMLGregorianCalendar xmlCalendar){ TimeZone timeZone = xmlCalendar.getTimeZone(xmlCalendar.getTimezone()); Calendar calendar = Calendar.getInstance(timeZone); @@ -121,9 +124,6 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { return calendar; } - public WizardProcessor() { - } - private String adjustDataType(String oracleDataType) { return "VARCHAR2".equals(oracleDataType) ? AppConstants.CT_CHAR : oracleDataType; // Probably should be expanded to convert any CHAR or VARCHAR type to @@ -428,8 +428,6 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { try { ds = DbUtils.executeQuery(schemaSql); - String prefix = "", desc = ""; - for (int i = 0; i < ds.getRowCount(); i++) { dbType = ds.getItem(i, 2); } @@ -448,7 +446,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { for (int i = 0; i < menuIDs.length; i++) menuID += (menuID.length() == 0 ? "" : "|") + menuIDs[i]; - boolean rRCSDisabled = AppUtils.getRequestNvlValue(request, "runtimeColSortDisabled").equals("Y"); + boolean rRCSDisabled = "Y".equals(AppUtils.getRequestNvlValue(request, "runtimeColSortDisabled")); String reportDefType = AppUtils.getRequestNvlValue(request, "reportDefType"); String dataContainerHeight = nvl(AppUtils.getRequestValue(request, "heightContainer"), "auto"); String dataContainerWidth = nvl(AppUtils.getRequestValue(request, "widthContainer"), "auto"); @@ -489,7 +487,7 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { rdef.setTopDown(isTopDown?"Y":"N"); rdef.setSizedByContent(isSizedByContent?"Y":"N"); rdef.setMenuID(menuID); - rdef.setMenuApproved(rApproved.equals("Y")); + rdef.setMenuApproved("Y".equals(rApproved)); if (reportDefType.length() > 0) rdef.setReportDefType(reportDefType); @@ -511,20 +509,18 @@ public class WizardProcessor extends org.onap.portalsdk.analytics.RaptorObject { } // if - if (rdef.getWizardSequence() instanceof WizardSequence) - rdef.generateWizardSequence(request); - + rdef.generateWizardSequence(request); reportUpdated = true; - if (rdef.getReportID().equals("-1")) + if ("-1".equals(rdef.getReportID())) // Always need to persist new report - in case it is a copy reportUpdated = true; return reportUpdated; } // processDefinition - private boolean processTableAdd(HttpServletRequest request) throws Exception { + private boolean processTableAdd(HttpServletRequest request) throws RaptorException { ReportDefinition rdef = (ReportDefinition) request.getSession().getAttribute( AppConstants.SI_REPORT_DEFINITION); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PageEvent.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PageEvent.java index 5b8ae4db..59bbed32 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PageEvent.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/pdf/PageEvent.java @@ -69,8 +69,9 @@ class PageEvent extends PdfPageEventHelper { private PdfBean pb; private int pageNo = 0; - private int omit_page_count = 0; - private int DEFAULT_LOGO_SIZE = 100; + private int omitPageCount = 0; + private int defaultLogoSize = 100; + private static String nLogo = "<no logo>"; public PageEvent(PdfBean pb) { this.pb = pb; @@ -79,10 +80,10 @@ class PageEvent extends PdfPageEventHelper { private int getHowManyLogos(){ int howManyLogos = 0; - if(AppUtils.isNotEmpty(pb.getLogo1Url()) && !pb.getLogo1Url().equalsIgnoreCase("<no logo>")) + if(AppUtils.isNotEmpty(pb.getLogo1Url()) && !pb.getLogo1Url().equalsIgnoreCase(nLogo)) howManyLogos ++; - if(AppUtils.isNotEmpty(pb.getLogo2Url()) && !pb.getLogo2Url().equalsIgnoreCase("<no logo>")) + if(AppUtils.isNotEmpty(pb.getLogo2Url()) && !pb.getLogo2Url().equalsIgnoreCase(nLogo)) howManyLogos ++; return howManyLogos; @@ -121,16 +122,16 @@ class PageEvent extends PdfPageEventHelper { PdfPTable foot = new PdfPTable(widths); - if(AppUtils.isNotEmpty(pb.getLogo1Url()) && !pb.getLogo1Url().equalsIgnoreCase("<no logo>")) - addLogo(foot, font, pb.getLogo1Url().substring(pb.getLogo1Url().indexOf("|") + 1).trim(), Cell.ALIGN_LEFT, pb.getLogo1Size() == null ? DEFAULT_LOGO_SIZE : pb.getLogo1Size()); + if(AppUtils.isNotEmpty(pb.getLogo1Url()) && !pb.getLogo1Url().equalsIgnoreCase(nLogo)) + addLogo(foot, font, pb.getLogo1Url().substring(pb.getLogo1Url().indexOf("|") + 1).trim(), Cell.ALIGN_LEFT, pb.getLogo1Size() == null ? defaultLogoSize : pb.getLogo1Size()); PdfPCell spacingCell = new PdfPCell(); spacingCell.setBorderColor(Color.WHITE); foot.addCell(spacingCell); //Using logo1 size for now - use logo2 size if it is required to deal it separately. - if(AppUtils.isNotEmpty(pb.getLogo2Url()) && !pb.getLogo2Url().equalsIgnoreCase("<no logo>")) - addLogo(foot, font, pb.getLogo2Url().substring(pb.getLogo2Url().indexOf("|") + 1).trim(), Cell.ALIGN_RIGHT, pb.getLogo2Size() == null ? DEFAULT_LOGO_SIZE : pb.getLogo2Size()); + if(AppUtils.isNotEmpty(pb.getLogo2Url()) && !pb.getLogo2Url().equalsIgnoreCase(nLogo)) + addLogo(foot, font, pb.getLogo2Url().substring(pb.getLogo2Url().indexOf("|") + 1).trim(), Cell.ALIGN_RIGHT, pb.getLogo2Size() == null ? defaultLogoSize : pb.getLogo2Size()); foot.setTotalWidth(getPageWidth(document)); foot.writeSelectedRows(0, -1, 36, 600, writer.getDirectContent()); @@ -167,19 +168,19 @@ class PageEvent extends PdfPageEventHelper { pageNo++; PdfContentByte cb = writer.getDirectContent(); PdfDestination destination = new PdfDestination(PdfDestination.FITH); - String bookmark = "Data Page " + (pageNo - omit_page_count); + String bookmark = "Data Page " + (pageNo - omitPageCount); if (pageNo == 1) { if (pb.isCoverPageIncluded()) { bookmark = "Cover Page"; - omit_page_count++; + omitPageCount++; } else if (pb.isDisplayChart()) { bookmark = "Chart"; - omit_page_count++; + omitPageCount++; } } if (pageNo == 2 && pb.isCoverPageIncluded() && pb.isDisplayChart()) { bookmark = "Chart"; - omit_page_count++; + omitPageCount++; } PdfOutline outline = new PdfOutline(cb.getRootOutline(), destination, bookmark); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportFormFields.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportFormFields.java index 02a3de4e..7bacd229 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportFormFields.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportFormFields.java @@ -90,7 +90,7 @@ public class ReportFormFields extends Vector { //Calendar rangeEndDate = fft.getRangeEndDate().toGregorianCalendar(); String rangeStartDateSQL = fft.getRangeStartDateSQL(); String rangeEndDateSQL = fft.getRangeEndDateSQL(); - String user_id = AppUtils.getUserID(request); + String userId = AppUtils.getUserID(request); String multiSelectListSize = fft.getMultiSelectListSize(); //s_logger.debug("ranges are : " + fft.getRangeStartDate() + fft.getRangeEndDate()); @@ -122,9 +122,9 @@ public class ReportFormFields extends Vector { } // } } - fieldSQL = Utils.replaceInString(fieldSQL, "[USERID]", user_id); - fieldSQL = Utils.replaceInString(fieldSQL, "[USER_ID]", user_id); - fieldSQL = Utils.replaceInString(fieldSQL, "[LOGGED_USERID]", user_id); + fieldSQL = Utils.replaceInString(fieldSQL, "[USERID]", userId); + fieldSQL = Utils.replaceInString(fieldSQL, "[USER_ID]", userId); + fieldSQL = Utils.replaceInString(fieldSQL, "[LOGGED_USERID]", userId); } @@ -152,9 +152,9 @@ public class ReportFormFields extends Vector { fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) ); } - fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[USERID]", user_id); - fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[USER_ID]", user_id); - fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[LOGGED_USERID]", user_id); + fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[USERID]", userId); + fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[USER_ID]", userId); + fieldDefaultSQL = Utils.replaceInString(fieldDefaultSQL, "[LOGGED_USERID]", userId); } //s_logger.debug("fieldSQL After" + fieldSQL); if(rangeStartDateSQL!=null) { diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/RemDbUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/RemDbUtils.java index 8e4def24..2a9d487a 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/RemDbUtils.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/RemDbUtils.java @@ -172,7 +172,7 @@ public class RemDbUtils /* implements IDbUtils */{ // } // } // executeUpdate - public static DataSet executeQuery(Connection con, String sql, String dbKey) throws ReportSQLException, Exception { + public static DataSet executeQuery(Connection con, String sql, String dbKey) throws Exception { return executeQuery(con, sql, Integer.MAX_VALUE,dbKey); } // executeQuery diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileSearchController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileSearchController.java index fdd26bab..ff80d413 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileSearchController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/ProfileSearchController.java @@ -56,7 +56,6 @@ import org.onap.portalsdk.core.domain.MenuData; import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.domain.UserApp; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; import org.onap.portalsdk.core.service.FnMenuService; import org.onap.portalsdk.core.service.UserProfileService; import org.onap.portalsdk.core.service.UserService; @@ -134,7 +133,7 @@ public class ProfileSearchController extends RestrictedBaseController { model.put("profileList", mapper.writeValueAsString(profileFinalList)); JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); JSONObject j = new JSONObject(msg); - response.setContentType("application/json"); + response.setContentType(APPLICATION_JSON); response.getWriter().write(j.toString()); } catch (Exception e) { logger.error(EELFLoggerDelegate.applicationLogger, "getUserPagination failed", e); diff --git a/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/filter/SecurityXssFilter.java b/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/filter/SecurityXssFilter.java index 4bc8b436..91025d14 100644 --- a/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/filter/SecurityXssFilter.java +++ b/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/filter/SecurityXssFilter.java @@ -170,7 +170,8 @@ public class SecurityXssFilter extends OncePerRequestFilter { } private boolean validateRequestType(HttpServletRequest request) { - return (request.getMethod().equalsIgnoreCase("POST") || request.getMethod().equalsIgnoreCase("PUT") - || request.getMethod().equalsIgnoreCase("DELETE")); + return ("POST".equalsIgnoreCase(request.getMethod() ) || + "PUT".equalsIgnoreCase( request.getMethod() ) || + "DELETE".equalsIgnoreCase( request.getMethod() ) ); } }
\ No newline at end of file |