diff options
35 files changed, 169 insertions, 402 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java index 49ed35b3..e144ef77 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java @@ -559,9 +559,7 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } lookup = new IdNameSql(-1, SQL, lu.getDefaultSQL()); } - // } lookupList = lookup; - // } lookup.loadUserData(0, "", getDbInfo(), getUserId()); } @@ -580,9 +578,7 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } // for - // lookup.clearData(); } catch (Exception e) { - // throw new RaptorRuntimeException(e); } if (!hasPredefinedList) { if (oldSQL != null && !oldSQL.equals("")) { @@ -751,7 +747,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme lookup = new IdNameSql(-1, SQL, lu.getDefaultSQL()); } lookupList = lookup; - // } if (nvl(fieldValue).length() > 0 && (dependsOn == null || dependsOn.length() <= 0)) { sb.append((fieldValue != null) ? "obj.value=\"" + nvl(fieldValue) + "\";" : ""); } else if (lookup != null) { @@ -779,7 +774,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } } catch (Exception e) { } - // if(isVisible()) return sb.toString(); } else if (fieldType.equals(FFT_LIST_BOX)) { StringBuffer sb = new StringBuffer(); @@ -817,10 +811,7 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } lookup = new IdNameSql(-1, SQL, lu.getDefaultSQL()); } - // } lookupList = lookup; - - // } try { lookup.loadUserData(0, "", getDbInfo(), getUserId()); } catch (Exception e) { @@ -867,7 +858,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme ((IdNameSql) lookup).setSQL(oldSQL); } } - // System.out.println("FORMFIELD 6666667 " + ((IdNameSql)lookup).getSql()); if (isVisible()) return sb.toString(); else @@ -890,9 +880,7 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } catch (IllegalArgumentException ex1) { } catch (Exception ex2) { } - // System.out.println(fieldName + " " + fieldType + " " + fieldValue); if (fieldType.equals(FFT_TEXT_W_POPUP)) { - // System.out.println("TEXT POPUP " + fieldName); String oldSQL = ""; IdNameValue idNamevalue = null; String fieldDefValue = ""; @@ -915,7 +903,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme Map.Entry entry = (Entry) iter.next(); value = (String) entry.getValue(); SQL = Utils.replaceInString(SQL, "[" + entry.getKey() + "]", value); - // if(SQL.indexOf("'"+"["+entry.getKey()+"]"+"'")!=-1) { if (SQL.indexOf("'" + "[" + entry.getKey() + "]" + "'") != -1 || SQL.indexOf("'" + "[" + entry.getKey()) != -1 || SQL.indexOf(entry.getKey() + "]" + "'") != -1 @@ -952,7 +939,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme lookup = new IdNameSql(-1, SQL, null); } } - // lookupList = lookup; if (getFieldDefaultSQL() != null && (fieldValue == null || fieldValue.trim().equalsIgnoreCase("null") || fieldValue.trim().length() <= 0)) { @@ -1034,13 +1020,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } if (isVisible()) { - /* - * return "<input type=text class=\"text\" size=30 maxlength=50 id=\"" + - * fieldName +"\" name=\"" + fieldName + "\" value=\"" + nvl(fieldDefValue) + - * "\">\n" + "<a href=\"javascript:showArgPopupNew('" + fieldName + - * "', 'document.formd." + fieldName + "')\"><img border=0 src=\"" + - * AppUtils.getImgFolderURL() + "shareicon.gif\" " + getHelpLink(fieldName); - */ String progress = "<div id=\"" + fieldName + "_content\" style=\"display:none;width:100%;height:100%;align:center;\"> <img src=\"" + AppUtils.getImgFolderURL() @@ -1070,8 +1049,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme if (lu.getSql().length() > 0) { valueSQL = lu.getSql(); avail_ReadOnly = (valueSQL.toLowerCase().indexOf(readOnlyInSql) != -1); - // System.out.println("OLD SQL TEXT" + valueSQL); - // oldSQL = lu.getSql(); if (formValues != null) { Set set = formValues.entrySet(); String value1 = ""; @@ -1087,11 +1064,8 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } } // should be value one. - // lookup = new IdNameSql(-1,valueSQL,lu.getDefaultSQL()); } } - // lookupList = lookup; - // System.out.println("8888888 88 " + valueSQL); } if (valueSQL != null && valueSQL.length() > 0) { DataSet ds = ConnectionUtils.getDataSet(valueSQL.toString(), dbInfo); @@ -1113,10 +1087,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme && !inSchedule) ? "" : "") + getCallableJavascript(getFieldName(), rr) + " " + (readOnly ? " readonly " : " ") + " value=\""; - /* - * if(getFieldDefaultSQL()!=null) returnString += nvl(value.getId()); else - * returnString += fieldValue; - */ if (fieldValue != null && fieldValue.length() > 0 && (!(fieldValue.toUpperCase().indexOf("SELECT ") != -1 && fieldValue.toUpperCase().indexOf("FROM") != -1))) { if (validationType.startsWith("TIMESTAMP")) { @@ -1159,15 +1129,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } else returnString += nvl((value != null) ? value.getId() : ""); - /* - * returnString += "\">" + (validationType.equals(VT_DATE) ? - * "\n\t\t\t<a href=\"#\" onClick=\"window.dateField=document." + HTML_FORM + - * "." + fieldName + ";calendar=window.open('" + AppUtils.getRaptorActionURL() + - * "popup.calendar','cal','WIDTH=200,HEIGHT=250');return false;\">" + - * "\n\t\t\t\t<img src=\"" + AppUtils.getImgFolderURL() + - * "calender_icon.gif\" align=absmiddle border=0 width=20 height=20></a>" : ""); - */ - SimpleDateFormat dtf = new SimpleDateFormat("MM/dd/yyyy"); String stRangeText = this.getRangeStartDate() == null ? null : dtf.format(this.getRangeStartDate().getTime()); @@ -1176,12 +1137,8 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme // get the date sqls - // System.out.println("////////////start range date before Start" + - // this.getRangeStartDateSQL()); - if (this.getRangeStartDateSQL() != null && this.getRangeStartDateSQL().trim().toLowerCase().startsWith("select")) { - // System.out.println("////////////start range date Starting"); String SQL = this.getRangeStartDateSQL(); if (formValues != null) { Set set = formValues.entrySet(); @@ -1189,15 +1146,12 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme for (Iterator iter = set.iterator(); iter.hasNext();) { Map.Entry entry = (Entry) iter.next(); v = (String) entry.getValue(); - // System.out.println("///////// key is " + entry.getKey() + " = " + v); SQL = Utils.replaceInString(SQL, "[" + entry.getKey() + "]", v); } } - // System.out.println("////////////start range date sql created" + SQL); try { DataSet ds = ConnectionUtils.getDataSet(SQL.toString(), dbInfo); - // System.out.println("////////////start range date is : " + ds.get(0)); dtf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar tStart = Calendar.getInstance(); tStart.setTime(dtf.parse(ds.getString(0, 0))); @@ -1211,7 +1165,6 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme if (this.getRangeEndDateSQL() != null && this.getRangeEndDateSQL().trim().toLowerCase().startsWith("select")) { - // System.out.println("////////////end range date Starting"); String SQL = this.getRangeEndDateSQL(); if (formValues != null) { Set set = formValues.entrySet(); @@ -1225,12 +1178,10 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme } try { DataSet ds = ConnectionUtils.getDataSet(SQL.toString(), dbInfo); - // System.out.println("////////////end range date is : " + ds.get(0)); dtf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar tStart = Calendar.getInstance(); tStart.setTime(dtf.parse(ds.getString(0, 0))); dtf = new SimpleDateFormat("MM/dd/yyyy"); - // endRangeText = dtf.format(tStart.getTime()); endRangeText = dtf.format(tStart.getTime().getTime() + MILLIS_IN_DAY); } catch (Exception e) { System.out.println("Exception////////// : end range date is : " + e); @@ -1267,30 +1218,17 @@ public class FormField extends org.onap.portalsdk.analytics.RaptorObject impleme if (inSchedule) hour = Integer.parseInt(nvl(((String) formValues.get(fieldName + "_Hr")), "0")); } - // System.out.println("Hour =" + hour); } catch (NumberFormatException ex) { hour = 0; } try { t_hr = Integer.parseInt(timestamphr); - // System.out.println("THR =" + t_hr); } catch (NumberFormatException ex) { t_hr = 0; } if (hour <= 0) hour = t_hr; - // System.out.println("Form Values 887 " + formValues); - /* - * if (formValues.containsKey(fieldDisplayName+"_Hr")){ - * formValues.remove(fieldDisplayName+"_Hr"); - * formValues.put(fieldDisplayName+"_Hr", hour); } else - * formValues.put(fieldDisplayName+"_Hr", hour); - * System.out.println("Form Values 887 " + formValues); - */ - - // int t_min = Integer.parseInt(timestampmin); - // int t_sec = Integer.parseInt(timestampsec); for (int i = 0; i < 24; i++) { if (i == 0) timeStampStr += "<option value=\"" + i + "\"" + ((hour == i) ? " selected" : "") diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessor.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessor.java index 62bf4335..1c0e1c3d 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessor.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessor.java @@ -343,7 +343,6 @@ public class FormatProcessor extends RaptorObject { count++; } } - //} } else { dv.setCellFormatter(formatter); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamDateValueParser.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamDateValueParser.java index 73380025..037a6ec5 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamDateValueParser.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamDateValueParser.java @@ -48,22 +48,6 @@ import org.onap.portalsdk.analytics.util.Utils; public class ReportParamDateValueParser { - /*public static final SimpleDateFormat[] dateFormats; - - static { - dateFormats = new SimpleDateFormat[5]; - (dateFormats[0] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MONTHYYYY)) - .setLenient(true); - (dateFormats[1] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MONTHDDYYYY)) - .setLenient(true); - (dateFormats[2] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MMDDYYYY)) - .setLenient(true); - (dateFormats[3] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MMYYYY)) - .setLenient(true); - (dateFormats[4] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_DDMONYYYY)) - .setLenient(true); - }*/ - public static boolean isDateHrParam(String param) { SimpleDateFormat[] dateFormats = new SimpleDateFormat[2]; dateFormats[0] = new SimpleDateFormat(AppConstants.JAVA_DATE_FORMAT_MMDDYYYY_HR); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValues.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValues.java index 2cff3e63..98651143 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValues.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValues.java @@ -107,12 +107,6 @@ public class ReportParamValues extends Hashtable { } // for } // ReportParamValues - /* - * public ReportParamValues(ReportFormFields rff, HttpServletRequest - * request) { this(rff); - * - * setParamValues(request); } // ReportParamValues - */ public boolean isParameterMultiValue(String fieldName) { Boolean b = (Boolean) paramIsMultiValue.get(fieldName); return (b != null) ? b.booleanValue() : false; @@ -130,7 +124,6 @@ public class ReportParamValues extends Hashtable { public boolean setParamValues(HttpServletRequest request, boolean refresh) { long currentTime = System.currentTimeMillis(); - //System.out.println("ReportParamValues setParamValues called " + refresh); boolean paramUpdated = false; if(refresh) clearValues(); @@ -152,41 +145,24 @@ public class ReportParamValues extends Hashtable { newValue = XSSFilter.filterRequestOnlyScript(sb.toString()); } // if } else if (isParameterTextAreaValue(key)) { -/* String[] values = request.getParameterValues(key); - - if (values != null) { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < values.length; i++) { - if (sb.length() > 0) - sb.append('|'); - sb.append(values[i]); - } // for -*/ String value = ""; value = request.getParameter(key); value = Utils.oracleSafe(nvl(value)); paramIsTextAreaDrilldownValue.put(key, value); value = value.replaceAll(",", "|"); value = "('" + Utils.replaceInString(value, "|", "','") + "')"; - //value = Utils.replaceInString(value, "|", ","); newValue = XSSFilter.filterRequestOnlyScript(value); paramIsTextAreaValueModified.put(key, new Boolean(true)); //} // if } else - // newValue = nvl(request.getParameter(key)); newValue = XSSFilter.filterRequestOnlyScript(request.getParameter(key)); - //debugLogger.debug("IN REPORTPARAM ^NEW VALUE " + newValue + " OLD VALUE " + oldValue + " KEY " + key + " isParameterMultiValue(key) " + isParameterMultiValue(key)); if(!isParameterMultiValue(key) && !isParameterTextAreaValue(key)) { if(refresh && nvl(newValue).length()<=0) { put(key, oldValue); } else if ( ((newValue != null && newValue.trim().length()>0) && (oldValue!=null && oldValue.trim().length()>0) && !newValue.equals(oldValue)) || ((newValue != null && newValue.trim().length()>0) && (oldValue == null || oldValue.trim().length() <= 0)) ) { - paramUpdated = true; - //System.out.println("paramupdated1 " +paramUpdated+ " " + newValue + " " + oldValue); - // if(newValue.startsWith("[") && newValue.endsWith("]")) { - // newValue = getDateAsString(newValue); - // } + paramUpdated = true; put(key, newValue); } else if (((newValue == null || newValue.trim().length()<=0)) && (oldValue!=null && oldValue.trim().length()>0)) { paramUpdated = true; @@ -212,12 +188,10 @@ public class ReportParamValues extends Hashtable { } else if (((newValue == null || newValue.trim().length()<=0)) && (oldValue!=null && oldValue.trim().length()>0) && (isParameterMultiValue(key)||isParameterTextAreaValue(key))) { paramUpdated = true; - //System.out.println("paramupdated3 " +paramUpdated+ " N" + newValue + " O" + oldValue); put(key, ""); } } } // for - //printValues(); logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] ------->Time Taken for Adding/Clearing Param Values for Search Field Display " + (System.currentTimeMillis() - currentTime))); return paramUpdated; } // setParamValues @@ -240,18 +214,10 @@ public class ReportParamValues extends Hashtable { } value = Utils.replaceInString(value, "~", "' , '"); value = "('" + Utils.replaceInString(value, "|", "','") + "')"; // changed from "|" - //value = Utils.replaceInString(value, "|", ","); value = XSSFilter.filterRequestOnlyScript(value); return value; } else return ""; -// if(nvl(value).length()>0) { -// value = Utils.replaceInString(value, ",", "|"); -// value = value.indexOf("('")!=-1? value.substring(2, value.length()-2):value; -// value = Utils.replaceInString(value, "'|'", ","); -// } -// return value; - } else return (String) get(key); } @@ -305,7 +271,6 @@ public class ReportParamValues extends Hashtable { if(nvl(defaultValue).length()>0) { put(key,ff.getDefaultValue()); } else if(nvl(defaultSQL).length() > 0) { - //defaultSQL = Utils.replaceInString(defaultSQL, "[LOGGED_USERID]", userId); if(!(isParameterMultiValue(key) || isParameterTextAreaValue(key))) { defaultQuery = "SELECT id, name FROM (SELECT rownum r, id, name FROM (" + defaultSQL + ") x " @@ -325,13 +290,7 @@ public class ReportParamValues extends Hashtable { } } } - } - -/* for (Enumeration enKeys = keys(); enKeys.hasMoreElements();) { - String key = (String) enKeys.nextElement(); - put(key,""); - } -*/ + } } @@ -346,28 +305,20 @@ public class ReportParamValues extends Hashtable { private String getDateAsString (String keyword) { String sql = ""; if (keyword.equals("[PROCESSING_DATE]")) { - //sql = "select to_char(trunc(sysdate,'dd'), 'mm/dd/yyyy') as dateStr from dual"; sql = "select to_char(trunc(sysdate,'dd'), 'mm/dd/yyyy') as dateStr" + Globals.getGenerateSqlVisualDual(); } else if (keyword.equals("[PROCESSING_NEXT_DATE]")) { - //sql = "select to_char(trunc(sysdate+1,'dd'), 'mm/dd/yyyy') as dateStr from dual"; sql = "select to_char(trunc(sysdate+1,'dd'), 'mm/dd/yyyy') as dateStr" + Globals.getGenerateSqlVisualDual(); } else if (keyword.equals("[PROCESSING_DAY_BEFORE_DATE]")) { - //sql = "select to_char(trunc(sysdate-1,'dd'), 'mm/dd/yyyy') as dateStr from dual"; sql = "select to_char(trunc(sysdate-1,'dd'), 'mm/dd/yyyy') as dateStr"+ Globals.getGenerateSqlVisualDual(); } else if (keyword.equals("[PROCESSING_MONTH_START_DATE]")) { - //sql = "select to_char(trunc(sysdate,'MM'), 'mm/dd/yyyy') as dateStr from dual"; sql = "select to_char(trunc(sysdate,'MM'), 'mm/dd/yyyy') as dateStr"+ Globals.getGenerateSqlVisualDual(); } else if (keyword.equals("[PROCESSING_MONTH_END_DATE]")) { - //sql = "select to_char(last_day(sysdate), 'mm/dd/yyyy') as dateStr from dual"; sql = "select to_char(last_day(sysdate), 'mm/dd/yyyy') as dateStr" + Globals.getGenerateSqlVisualDual(); } else if (keyword.equals("[CURRENT_HOUR]")) { - //sql = "select to_char(trunc(sysdate,'HH24'),'mm/dd/yyyy HH24') as dateStr from dual"; sql = "select to_char(trunc(sysdate,'HH24'),'mm/dd/yyyy HH24') as dateStr"+ Globals.getGenerateSqlVisualDual(); } else if (keyword.equals("[PREVIOUS_HOUR]")) { - //sql = "select to_char(trunc(sysdate-1/24, 'HH24'),'mm/dd/yyyy HH24') as dateStr from dual"; sql = "select to_char(trunc(sysdate-1/24, 'HH24'),'mm/dd/yyyy HH24') as dateStr" + Globals.getGenerateSqlVisualDual(); } else if (keyword.equals("[NEXT_HOUR]")) { - //sql = "select to_char(trunc(sysdate+1/24, 'HH24'),'mm/dd/yyyy HH24') as dateStr from dual"; sql = "select to_char(trunc(sysdate+1/24, 'HH24'),'mm/dd/yyyy HH24') as dateStr" + Globals.getGenerateSqlVisualDual(); } DataSet ds = null; @@ -381,7 +332,6 @@ public class ReportParamValues extends Hashtable { return ""; } catch (RaptorException ex) { logger.error(EELFLoggerDelegate.errorLogger, "RaptorException in getDateAsString", ex); - //throw ex; } return ""; } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java index 483e9fe4..62d95efb 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcel.java @@ -91,12 +91,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { } // for } // ReportParamValues - /* - * public ReportParamValues(ReportFormFields rff, HttpServletRequest - * request) { this(rff); - * - * setParamValues(request); } // ReportParamValues - */ public boolean isParameterMultiValue(String fieldName) { Boolean b = (Boolean) paramIsMultiValue.get(fieldName); return (b != null) ? b.booleanValue() : false; @@ -108,7 +102,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { } // isParameterMultiValue public boolean setParamValues(HttpServletRequest request, boolean refresh) { - //debugLogger.debug("ReportParamValues for PDF Excel setParamValues called " + refresh); long currentTime = System.currentTimeMillis(); boolean paramUpdated = false; if(refresh) @@ -141,7 +134,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { for (Iterator iter = rff.iterator(); iter.hasNext();) { name=""; //just added ff = (FormField) iter.next(); - //debugLogger.debug("ff.getFieldName " + ff.getFieldName() + " " + ff.getFieldDisplayName() + " " + ff.getFieldType()+ " " +ff.getBaseSQLForPDFExcel()+ " "+ rr.getParamValue(ff.getFieldName())); if(!ff.getFieldType().equals(FormField.FFT_BLANK)) { sql = ff.getBaseSQLForPDFExcel(); if(sql!=null && sql.trim().length()>0) @@ -197,34 +189,28 @@ public class ReportParamValuesForPDFExcel extends Hashtable { if(name.length()<=0) name = ff.getFieldName(); value = rr.getParamValue(name); - //debugLogger.debug("Name "+ name+ " value:" + value); String paramValue = ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), getParamValueForSQL(name, value)); - //debugLogger.debug("PDFEXCEL " + name+ " " + ff.getFieldName()+ " " + value + " " + sql +" "+ paramValue); if(name!=null && name.equals(ff.getFieldName())) sql = Utils.replaceInString(sql, "[VALUE]", paramValue); if(paramValue == null) { if(sql.lastIndexOf("where id = ''")>0) sql = sql.substring(0, sql.lastIndexOf("where id = ''")); } - //debugLogger.debug("SQL Modified " + sql); FormField ff2 = null; for (Iterator iter1 = rff.iterator(); iter1.hasNext();) { ff2 = (FormField)iter1.next(); sql = Utils.replaceInString(sql, "[" + ff2.getFieldDisplayName() +"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(),getParamValue(ff2.getFieldName()))); } - //debugLogger.debug("SQL Modified after replacing formfield" + sql); try { String[] reqParameters = Globals.getRequestParams().split(","); String[] sessionParameters = Globals.getSessionParams().split(","); String[] scheduleSessionParameters = Globals.getSessionParamsForScheduling().split(","); - javax.servlet.http.HttpSession session = request.getSession(); - //debugLogger.debug("B4 Session " + sql); + javax.servlet.http.HttpSession session = request.getSession(); if(session != null ) { for (int i = 0; i < sessionParameters.length; i++) { sql = Utils.replaceInString(sql, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) ); } - } - //debugLogger.debug("B4 request " + sql); + } if(request != null ) { for (int i = 0; i < scheduleSessionParameters.length; i++) { sql = Utils.replaceInString(sql, "[" + scheduleSessionParameters[i].toUpperCase()+"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(scheduleSessionParameters[i]) )); @@ -243,8 +229,7 @@ public class ReportParamValuesForPDFExcel extends Hashtable { else sql = Utils.replaceInString(sql, "[" + reqParameters[i].toUpperCase()+"]", ESAPI.encoder().encodeForSQL( SecurityCodecUtil.getCodec(), request.getParameter(reqParameters[i]) )); } - } - //debugLogger.debug("After request " + sql); + } DataSet ds = null; try { ds = ConnectionUtils.getDataSet(sql, dbInfo); @@ -255,12 +240,9 @@ public class ReportParamValuesForPDFExcel extends Hashtable { StringBuffer multiValue = new StringBuffer(""); if(ds!=null) { for(int i = 0; i < ds.getRowCount(); i++) { - //if(i==0) multiValue.append("("); multiValue.append(ds.getString(i,1)); if(i<ds.getRowCount()-1) multiValue.append("|"); - //else multiValue.append(")"); - } } put(ff.getFieldName(), nvl(multiValue.toString())); @@ -278,7 +260,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { .getParamValue(ff.getFieldName()+"_Sec")).length() > 0 ? ":"+ addZero(Utils.oracleSafe(nvl(rr .getParamValue(ff.getFieldName()+"_Sec")))) : ""); } - //debugLogger.debug("77777777777777 " + value1); put(ff.getFieldName(), nvl(value1)); } else { @@ -293,15 +274,12 @@ public class ReportParamValuesForPDFExcel extends Hashtable { logger.debug(EELFLoggerDelegate.debugLogger, ("sql not complete" + sql)); } catch (Exception ex) {} - - //debugLogger.debug("66666666666666666 " + ff.getValidationType()); //Added for TimeStamp validation } else { if(!ff.getFieldType().equals(FormField.FFT_BLANK)) { //Added for TimeStamp validation - //debugLogger.debug("666666666666 " + ff.getValidationType()); if(ff.getValidationType().equals(FormField.VT_TIMESTAMP_HR) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_MIN) || ff.getValidationType().equals(FormField.VT_TIMESTAMP_SEC) ) { value1 = nvl(rr.getParamValue(ff.getFieldName())) + " "+addZero(Utils.oracleSafe(nvl(rr .getParamValue(ff.getFieldName()+"_Hr")))); @@ -315,7 +293,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { .getParamValue(ff.getFieldName()+"_Sec")).length() > 0 ? ":"+ addZero(Utils.oracleSafe(nvl(rr .getParamValue(ff.getFieldName()+"_Sec")))) : ""); } - //debugLogger.debug("77777777777777 " + value1); } else value1 = nvl(rr.getParamValue(ff.getFieldName())); if(value1.length()<=0) @@ -331,7 +308,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { } // dbInfo } // !=null - //printValues(); logger.debug(EELFLoggerDelegate.debugLogger, ("[DEBUG MESSAGE FROM RAPTOR] ------->Time Taken for Adding/Clearing Param Values for FormField Info Bar " + (System.currentTimeMillis() - currentTime))); return paramUpdated; } // setParamValues @@ -351,7 +327,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { } // getParamValue public String getParamDisplayValue(String key) { - //debugLogger.debug("Key is " + key +" Value is " + getParamValue(key)); String value = getParamValue(key); if (isParameterMultiValue(key)) value = "(" + Utils.replaceInString(value, "|", ",") + ")"; @@ -397,7 +372,6 @@ public class ReportParamValuesForPDFExcel extends Hashtable { if(nvl(defaultValue).length()>0) { put(key,ff.getDefaultValue()); } else if(nvl(defaultSQL).length() > 0) { - //defaultSQL = Utils.replaceInString(defaultSQL, "[LOGGED_USERID]", userId); if(!(isParameterMultiValue(key) || isParameterTextAreaValue(key))) { defaultQuery = "SELECT id, name FROM (SELECT rownum r, id, name FROM (" + defaultSQL + ") x " diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java index d10826af..c62e1f07 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ReportRuntime.java @@ -1129,9 +1129,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa Vector visibleCols = new Vector(reportCols.size()); Vector formatProcessors = new Vector(reportCols.size()); - // ColumnHeaderRow chr = new ColumnHeaderRow(); - // rd.reportColumnHeaderRows.addColumnHeaderRow(chr); - // chr.setRowHeight("30"); int count =0 ; ReportFormFields rff = getReportFormFields(); ReportFormFields childReportFormFields = null; @@ -1189,7 +1186,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } } } - //} String widthInPxls = dc.getDisplayWidthInPxls(); @@ -1446,7 +1442,6 @@ public class ReportRuntime extends ReportWrapper implements Cloneable, Serializa } } } - //} String widthInPxls = dc.getDisplayWidthInPxls(); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResult.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResult.java index b68acec8..82d3f76c 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResult.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResult.java @@ -68,13 +68,6 @@ public class ReportSearchResult extends SearchResult { "Are you sure you want to create a copy of this report?", AppUtils .getImgFolderURL() + "modify_icon.gif", "13", "12", true, false, false)); - /*addColumn(new SearchResultColumn(" Schedule ", "5%", "Center", - "document." + HTML_FORM + "." + AppConstants.RI_ACTION - + ".value='report.schedule_only';", "Schedule report", HTML_FORM, - null, AppUtils - .getImgFolderURL() - + "calendar_icon.gif", "13", "12", true, false, false)); - */ addColumn(new SearchResultColumn("edit"," Edit ", "5%", "Center", "document." + HTML_FORM + "." + AppConstants.RI_ACTION diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultField.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultField.java index 9f32eeba..7d74f59a 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultField.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultField.java @@ -216,17 +216,6 @@ public class SearchResultField extends org.onap.portalsdk.analytics.RaptorObject return (displayValue.length() == 0) ? " " : displayValue; } - /*public String getAlignmentHtml() { - return (alignment.length() == 0) ? "" : (" align=" + alignment); - }*/ - - /*public String getDisplayValueLinkHtml() { - if (nvl(drillDownLink).length() == 0) - return getDisplayValueHtml(); - else - return getDrillDownLink(); - } // getDisplayValueLinkHtml*/ - public String getColumnId() { return columnId; } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultRow.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultRow.java index 9bb5c7dd..d141eb43 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultRow.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResultRow.java @@ -65,8 +65,6 @@ class ColumnContent { } public class SearchResultRow extends ArrayList { - - //private SearchResultField searchresultField; private int nextElemIdx = 0; public void resetNext() { diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java index c13e2ba7..fba9fee4 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/scheduler/SendNotifications.java @@ -346,18 +346,6 @@ public class SendNotifications { } } - // schedulerUtil.getAndExecute("select c.column_value from table(CR_DISSECTURL(p_formfields)) c - // where substr(c.column_value, 1, instr(c.column_value, '=')-1) = substr(" + result.v_name + - // ",1,instr(" + result.v_name + ",'_auto')-1)||'_Hr'", new Executor() { - // - // @Override - // public void execute(ResultSet rs) throws SQLException { - // - // result.v_hour = rs.getString("column_value"); - // } - // - // }); - if (result.v_hour.length() > 0) { result.v_hour_value = result.v_hour.substring(result.v_hour.indexOf('=') + 1); } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/AppUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/AppUtils.java index 972cf721..245ae55a 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/AppUtils.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/AppUtils.java @@ -135,10 +135,6 @@ public class AppUtils /* implements IAppUtils */{ return Globals.getAppUtils().isUserInRole(request,roleId); } // isUserInRole -// public static boolean isUserInRole(String userId, String roleId) throws RaptorException { -// return Globals.getAppUtils().isUserInRole(userId, roleId); -// } // isUserInRole - public static Vector getUserRoles(HttpServletRequest request) throws RaptorException { return Globals.getAppUtils().getUserRoles(request); } // getUserRoles @@ -146,10 +142,6 @@ public class AppUtils /* implements IAppUtils */{ public static Vector getUserRoles(String userID) throws RaptorException { return Globals.getAppUtils().getUserRoles(userID); } // getUserRoles - -// public static Vector getUserRoles(HttpServletRequest request) throws RaptorException { -// return Globals.getAppUtils().getUserRoles(request); -// } // getUserRoles public static void resetUserCache() { Globals.getAppUtils().resetUserCache(); @@ -170,12 +162,6 @@ public class AppUtils /* implements IAppUtils */{ else return isUserInRole(request, getSuperRoleID()); } // isSuperUser - /*public static boolean isSuperUser(String userId) throws RaptorException { - if(Globals.isAdminRoleEquivalenttoSuperRole()) return isAdminUser(userId); - else return isUserInRole(userId, getSuperRoleID()); - } // isSuperUser - */ - public static boolean isAdminUser(HttpServletRequest request) throws RaptorException { if (isSuperUser(request)) return true; @@ -186,18 +172,6 @@ public class AppUtils /* implements IAppUtils */{ return false; } // isAdminUser - /*public static boolean isAdminUser(String userId) throws RaptorException { - if (isSuperUser(userId)) - return true; - - for (int i = 0; i < getAdminRoleIDs().size(); i++) - if (isUserInRole(userId, (String) getAdminRoleIDs().get(i))) - return true; - - return false; - } // isAdminUser - */ - public static String getTempFolderPath() { String path = Globals.getAppUtils().getTempFolderPath(); if (path.endsWith(File.separator) || path.endsWith("/")){ @@ -266,19 +240,6 @@ public class AppUtils /* implements IAppUtils */{ return Globals.getAppUtils().getFolderPathAdj(); } // getBaseFolderURL - - /* - * public static String getReportExecuteActionURL() { return - * Globals.getAppUtils().getReportExecuteActionURL(); } // - * getReportExecuteActionURL - * - * public static String getDataViewActionURL() { return - * Globals.getAppUtils().getDataViewActionURL(); } // getDataViewActionURL - * - * public static String getDataViewActionParam() { return - * Globals.getAppUtils().getDataViewActionParam(); } // - * getDataViewActionParam - */ public static String getDirectAccessURL() { return Globals.getAppUtils().getDirectAccessURL(); } // getDirectAccessURL diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/Globals.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/Globals.java index b64f8e07..6d9c94f9 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/Globals.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/Globals.java @@ -990,10 +990,6 @@ return sheetName; } return limit; } - -// public static String getWhereConditionForUserRole() { -// return nvls(raptorProperties.getProperty("schedule_where_condition"),"").trim(); -// } public static String getCustomizedScheduleQueryForUsers() { return nvls(raptorProperties.getProperty("schedule_custom_query_for_users"),"").trim(); } @@ -1336,65 +1332,6 @@ return sheetName; List formParameter = new ArrayList(); String formField = ""; -// for(int i = 1 ; i < (countOfFields+1); i++) -// { -// formField ="ff"+i; -// -// if(request.getParameterValues(formField) != null && request.getParameterValues(formField).length > 1 ) -// { -// String[] vals = request.getParameterValues(formField); -// boolean isMultiValue = false; -// StringBuffer value = new StringBuffer(""); -// if(vals.length > 1) { -// isMultiValue = true; -// value.append("("); -// } -// for(int j = 0 ; j < vals.length; j++) -// { -// if(isMultiValue) value.append("'"); -// try { -// if(vals[j] !=null && vals[j].length() > 0) -// value.append(java.net.URLDecoder.decode(vals[j], "UTF-8"));// + ","; -// else -// value.append(vals[j]); -// } catch (UnsupportedEncodingException ex) {value.append(vals[j]);} -// catch (IllegalArgumentException ex1){value.append(vals[j]);} -// catch (Exception ex2){value.append(vals[j]);} -// -// -// if(isMultiValue) value.append("'"); -// -// if(j != vals.length -1) { -// value.append(","); -// } -// } -// if(vals.length > 1) { -// value.append(")"); -// } -// -// //value = value.substring(0 , value.length()); -// -// valuesMap.put(fieldNameMap.get(formField), value.toString()); -// value = new StringBuffer(""); -// -// } -// else if(request.getParameter(formField) != null) -// { -// String value = ""; -// value = request.getParameter(formField); -// try { -// if(value !=null && value.length() > 0) -// value = java.net.URLDecoder.decode(request.getParameter(formField), "UTF-8"); -// } catch (UnsupportedEncodingException ex) {} -// catch (IllegalArgumentException ex1){} -// catch (Exception ex2){} -// valuesMap.put(fieldNameMap.get(formField), value); -// -// }else -// { -// valuesMap.put(fieldNameMap.get(formField), "NULL" ); -// } -// } for(int i = 0 ; i < rff.size(); i++) { ff = ((FormField)rff.getFormField(i)); formField = ff.getFieldName(); diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/FavoritesController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/FavoritesController.java index fbb9cc5d..09cbb0ac 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/FavoritesController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/FavoritesController.java @@ -52,6 +52,8 @@ import org.onap.portalsdk.core.logging.aspect.AuditLog; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.rest.FavoritesClient; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.service.AppService; import org.onap.portalsdk.core.util.SystemProperties; import org.slf4j.MDC; @@ -109,7 +111,7 @@ public class FavoritesController extends RestrictedBaseController { appUserName = app.getUsername(); try { decryptedPwd = CipherUtil.decryptPKC(app.getAppPassword(), - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "FavoritesController.getFavorites failed while decrypting password", e); 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 ff80d413..24e44d4b 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 @@ -139,6 +139,24 @@ public class ProfileSearchController extends RestrictedBaseController { logger.error(EELFLoggerDelegate.applicationLogger, "getUserPagination failed", e); } } + + @RequestMapping(value = { "/get_all_users" }, method = RequestMethod.GET) + public void getAllUsers(HttpServletRequest request, HttpServletResponse response) { + Map<String, Object> model = new HashMap<>(); + ObjectMapper mapper = new ObjectMapper(); + logger.info(EELFLoggerDelegate.applicationLogger, "Initiating get_all_users in ProfileSearchController"); + List<User> profileList = null; + try { + profileList = service.listAllUsers(); + model.put("profileList", mapper.writeValueAsString(profileList)); + JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model)); + JSONObject j = new JSONObject(msg); + response.setContentType(APPLICATION_JSON); + response.getWriter().write(j.toString()); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.applicationLogger, "getAllUsers failed", e); + } + } @SuppressWarnings("unchecked") private Map<String, Object> setDashboardData(HttpServletRequest request) 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 2b75aea1..8598ed15 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 @@ -62,6 +62,8 @@ import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; import org.onap.portalsdk.core.restful.domain.EcompRole; @@ -527,7 +529,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService, IPortalR appUserName = app.getUsername(); try { decryptedPwd = CipherUtil.decryptPKC(app.getAppPassword(), - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (CipherUtilException e) { logger.error(EELFLoggerDelegate.errorLogger, "getAppCredentials failed", e); } diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FavoritesControllerTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FavoritesControllerTest.java index 5c54d40d..e980f2a1 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FavoritesControllerTest.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FavoritesControllerTest.java @@ -53,6 +53,8 @@ import org.onap.portalsdk.core.domain.App; import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.onboarding.rest.FavoritesClient; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.service.AppService; import org.onap.portalsdk.core.util.SystemProperties; import org.powermock.api.mockito.PowerMockito; @@ -60,7 +62,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PrepareForTest({SystemProperties.class, CipherUtil.class, FavoritesClient.class}) +@PrepareForTest({SystemProperties.class, CipherUtil.class, FavoritesClient.class, KeyProperties.class, KeyConstants.class}) public class FavoritesControllerTest { @InjectMocks @@ -89,6 +91,8 @@ public class FavoritesControllerTest { HttpSession session = Mockito.mock(HttpSession.class); Mockito.when(request.getSession()).thenReturn(session); PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); User user = new User(); user.setId(123L); Mockito.when(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)).thenReturn("user"); @@ -101,7 +105,7 @@ public class FavoritesControllerTest { Mockito.when(appService.getDefaultApp()).thenReturn(app); PowerMockito.mockStatic(CipherUtil.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), app.getAppPassword())).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(FavoritesClient.class); @@ -120,6 +124,8 @@ public class FavoritesControllerTest { HttpSession session = Mockito.mock(HttpSession.class); Mockito.when(request.getSession()).thenReturn(session); PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); User user = new User(); user.setId(123L); Mockito.when(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)).thenReturn("user"); @@ -131,7 +137,7 @@ public class FavoritesControllerTest { app.setAppPassword("Password"); Mockito.when(appService.getDefaultApp()).thenReturn(app); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(FavoritesClient.class); Mockito.when(FavoritesClient.getFavorites(Mockito.anyString(), Mockito.anyString(), @@ -149,6 +155,8 @@ public class FavoritesControllerTest { HttpSession session = Mockito.mock(HttpSession.class); Mockito.when(request.getSession()).thenReturn(session); PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); User user = new User(); user.setId(123L); Mockito.when(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)).thenReturn("user"); @@ -161,7 +169,7 @@ public class FavoritesControllerTest { Mockito.when(appService.getDefaultApp()).thenReturn(null); PowerMockito.mockStatic(CipherUtil.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), app.getAppPassword())).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(FavoritesClient.class); diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java index 9d5e4fea..2c6827ed 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java @@ -65,6 +65,8 @@ import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; import org.onap.portalsdk.core.restful.domain.EcompRole; @@ -83,7 +85,7 @@ import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.context.ApplicationContext; @RunWith(PowerMockRunner.class) -@PrepareForTest({ AppContextManager.class, PortalApiProperties.class, JSONUtil.class, PortalTimeoutHandler.class, SystemProperties.class, CipherUtil.class }) +@PrepareForTest({ AppContextManager.class, PortalApiProperties.class, JSONUtil.class, PortalTimeoutHandler.class, SystemProperties.class, CipherUtil.class, KeyProperties.class, KeyConstants.class }) public class OnBoardingApiServiceImplTest { @Mock @@ -426,7 +428,9 @@ public class OnBoardingApiServiceImplTest { PowerMockito.mockStatic(SystemProperties.class); PowerMockito.mockStatic(CipherUtil.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(key); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(key); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), key)).thenReturn(app.getAppPassword()); Mockito.when(appServiceImpl.getDefaultApp()).thenReturn(app); OnBoardingApiServiceImpl onBoardingApiServiceImpl = new OnBoardingApiServiceImpl(); @@ -453,7 +457,9 @@ public class OnBoardingApiServiceImplTest { PowerMockito.mockStatic(SystemProperties.class); PowerMockito.mockStatic(CipherUtil.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(key); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(key); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), key)).thenThrow(CipherUtilException.class); Mockito.when(appServiceImpl.getDefaultApp()).thenReturn(app); OnBoardingApiServiceImpl onBoardingApiServiceImpl = new OnBoardingApiServiceImpl(); diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/app.module.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/app.module.ts index a86ea759..6dcdda67 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/app.module.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/app.module.ts @@ -36,7 +36,7 @@ * */ import { CommonModule } from '@angular/common'; -import { HttpClientModule } from '@angular/common/http'; +import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @@ -47,6 +47,7 @@ import { SidebarService } from './shared/services/index'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { UserService } from './shared/services/user/user.service'; +import { HeaderInterceptor } from './shared/interceptors/header-interceptor'; @NgModule({ imports: [ @@ -60,7 +61,11 @@ import { UserService } from './shared/services/user/user.service'; ReactiveFormsModule, ], declarations: [AppComponent], - providers: [SidebarService,UserService], + providers: [SidebarService,UserService,{ + provide: HTTP_INTERCEPTORS, + useClass: HeaderInterceptor, + multi: true, + }], bootstrap: [AppComponent] }) export class AppModule {} diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/ext/profile/profile.service.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/ext/profile/profile.service.ts index 7d14ee39..1c631347 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/ext/profile/profile.service.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/ext/profile/profile.service.ts @@ -10,56 +10,59 @@ export class ProfileService { constructor(private http:HttpClient) { } getUserPagination(){ - return this.http.get(environment.getUserPagination,{ withCredentials: true }); + return this.http.get(environment.getUserPagination); } + getAllUsers(){ + return this.http.get(environment.getAllUsers); + } getPostSearch(postSearchBean:any) { - return this.http.post(environment.postSearch,JSON.stringify({postSearchBean: postSearchBean}),{ withCredentials: true }); + return this.http.post(environment.postSearch,JSON.stringify({postSearchBean: postSearchBean})); } importUser(postSearchBean:any) { - return this.http.post(environment.importSearch,JSON.stringify({postSearchBean: postSearchBean}),{ withCredentials: true }); + return this.http.post(environment.importSearch,JSON.stringify({postSearchBean: postSearchBean})); } getPostProfile() { - return this.http.get(environment.getPostProfile,{ withCredentials: true }); + return this.http.get(environment.getPostProfile); } getSelfProfile() { - return this.http.get(environment.getSelfProfile,{ withCredentials: true }); + return this.http.get(environment.getSelfProfile); } getProfileById(profileId){ - return this.http.get(environment.getProfileById+"?profile_id="+profileId, {withCredentials: true }); + return this.http.get(environment.getProfileById+"?profile_id="+profileId); } removeRole(data,profileId) { - return this.http.post(environment.removeUserRole+'?profile_id='+profileId,JSON.stringify({role: data}),{ withCredentials: true }); + return this.http.post(environment.removeUserRole+'?profile_id='+profileId,JSON.stringify({role: data})); } addUserRole(data,profileId) { - return this.http.post(environment.addUserRole+'?profile_id='+profileId,JSON.stringify({role: data}),{ withCredentials: true }); + return this.http.post(environment.addUserRole+'?profile_id='+profileId,JSON.stringify({role: data})); } saveProfile(data,profileId) { - return this.http.post(environment.saveProfile+'?profile_id='+profileId,JSON.stringify({profile: data.profile,selectedCountry:data.selectedCountry, selectedState:data.selectedState, selectedTimeZone:data.selectedTimeZone}),{ withCredentials: true }); + return this.http.post(environment.saveProfile+'?profile_id='+profileId,JSON.stringify({profile: data.profile,selectedCountry:data.selectedCountry, selectedState:data.selectedState, selectedTimeZone:data.selectedTimeZone})); } toggleProfileActive(profileId){ - return this.http.get(environment.toggleProfileActive+profileId,{ withCredentials: true }); + return this.http.get(environment.toggleProfileActive+profileId); } diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.prod.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.prod.ts index e53aeb67..a0f59731 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.prod.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.prod.ts @@ -11,6 +11,7 @@ export const environment = { getFunctionCdList:'admin_fn_menu/get_function_cd_list', getParentList:'admin_fn_menu/get_parent_list', getUserPagination:'get_user_pagination?pageNum=0&viewPerPage=0', + getAllUsers:'get_all_users', deleteRole:'role_list/removeRole', getTopMenu:'get_topMenuInfo', deleteRoleFunction:'role_function_list/removeRoleFunction', diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.ts index 0114df00..214c39df 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/environments/environment.ts @@ -15,6 +15,7 @@ export const environment = { getFunctionCdList:'http://www.sdk.onap.org:8080/epsdk-app-os/admin_fn_menu/get_function_cd_list', getParentList:'http://www.sdk.onap.org:8080/epsdk-app-os/admin_fn_menu/get_parent_list', getUserPagination:'http://www.sdk.onap.org:8080/epsdk-app-os/get_user_pagination?pageNum=0&viewPerPage=0', + getAllUsers:'http://www.sdk.onap.org:8080/epsdk-app-os/get_all_users', deleteRole:'http://www.sdk.onap.org:8080/epsdk-app-os/role_list/removeRole', getTopMenu:'http://www.sdk.onap.org:8080/epsdk-app-os/get_topMenuInfo', deleteRoleFunction:'http://www.sdk.onap.org:8080/epsdk-app-os/role_function_list/removeRoleFunction', diff --git a/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java b/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java index 074311dc..d8076a71 100644 --- a/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java +++ b/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java @@ -47,6 +47,8 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.util.SystemProperties; import org.springframework.web.servlet.ModelAndView; @@ -100,9 +102,9 @@ public class LoginStrategyImpl extends LoginStrategy { Cookie userIdCookie = getCookie(request, USER_ID); if (userIdCookie != null) { final String cookieValue = userIdCookie.getValue(); - if (!SystemProperties.containsProperty(SystemProperties.Decryption_Key)) - throw new IllegalStateException("Failed to find property " + SystemProperties.Decryption_Key); - final String decryptionKey = SystemProperties.getProperty(SystemProperties.Decryption_Key); + if ((null == KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)) || ("".equalsIgnoreCase(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)))) + throw new IllegalStateException("Failed to find property " + KeyConstants.CIPHER_ENCRYPTION_KEY); + final String decryptionKey = KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY); userId = CipherUtil.decrypt(cookieValue, decryptionKey); logger.debug(EELFLoggerDelegate.debugLogger, "getUserIdFromCookie: decrypted as {}", userId); } diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/admin.service.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/admin.service.ts index 1240e981..c42235be 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/admin.service.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/admin.service.ts @@ -51,7 +51,7 @@ export class AdminService { constructor(private http:HttpClient) { } getRoleFunctionList(){ - return this.http.get(environment.roleFunctionList,{ withCredentials: true }); + return this.http.get(environment.roleFunctionList); } saveRoleFunction(roleData:string){ @@ -60,65 +60,65 @@ export class AdminService { getUsageList() { - return this.http.get(environment.usageList,{ withCredentials: true }); + return this.http.get(environment.usageList); } getCacheRegions(){ - return this.http.get(environment.cachedRegions,{ withCredentials: true }); + return this.http.get(environment.cachedRegions); } getRole(roleId){ - return this.http.get(environment.getRole+'?role_id=' + roleId,{ withCredentials: true }); + return this.http.get(environment.getRole+'?role_id=' + roleId); } getFnMenuItems() { - return this.http.get(environment.getFnMenuItems,{ withCredentials: true }); + return this.http.get(environment.getFnMenuItems); } updateFnMenuItem(menuObj: any): Observable<any> { let updateMenuURL = environment.updateFnMenuItem; - return this.http.post(updateMenuURL, menuObj, {withCredentials: true}) + return this.http.post(updateMenuURL, menuObj) } getFunctionCdList(): Observable<any>{ let getFunctionCdListURL = environment.getFunctionCdList; - return this.http.get(getFunctionCdListURL , { withCredentials: true } ); + return this.http.get(getFunctionCdListURL); } getParentData(): Observable<any>{ let getParentDataURL = environment.getParentList; - return this.http.get(getParentDataURL , { withCredentials: true } ); + return this.http.get(getParentDataURL); } deleteRole(roleData:any){ - return this.http.post(environment.deleteRole,JSON.stringify({role: roleData}),{ withCredentials: true }); + return this.http.post(environment.deleteRole,JSON.stringify({role: roleData})); } deleteRoleFunction(roleFunc:any) { - return this.http.post(environment.deleteRoleFunction,roleFunc,{ withCredentials: true }); + return this.http.post(environment.deleteRoleFunction,roleFunc); } removeRoleFunction(roleFunc:any, roleId:any){ let removeRoleFunctionURL = environment.removeRoleFunction+roleId; - return this.http.post(removeRoleFunctionURL,JSON.stringify({roleFunction:roleFunc}),{ withCredentials: true }); + return this.http.post(removeRoleFunctionURL,JSON.stringify({roleFunction:roleFunc})); } saveRole(roleObj:any, roleId:any){ let saveRoleURL = environment.saveRole+roleId; - return this.http.post(saveRoleURL,JSON.stringify(roleObj),{ withCredentials: true }); + return this.http.post(saveRoleURL,JSON.stringify(roleObj)); } deleteMenu(fnMenuItem:any){ - return this.http.post(environment.deleteMenu,JSON.stringify({fnMenuItem: fnMenuItem}),{ withCredentials: true }); + return this.http.post(environment.deleteMenu,JSON.stringify({fnMenuItem: fnMenuItem})); } getCacheRegionDetails(cacheName:any){ - return this.http.get(environment.getRegion+'?cacheName='+cacheName,{ withCredentials: true }); + return this.http.get(environment.getRegion+'?cacheName='+cacheName); } } diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html index 5f131fb6..a6682306 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html @@ -50,12 +50,12 @@ <ng-container matColumnDef="Last Name"> <th mat-header-cell *matHeaderCellDef id="heading2"> {{userHeaders[1]}} </th> - <td mat-cell *matCellDef="let rowData"> {{rowData.lastName}} </td> + <td mat-cell *matCellDef="let rowData"> {{rowData.last_name}} </td> </ng-container> <ng-container matColumnDef="First Name"> <th mat-header-cell *matHeaderCellDef id="heading3">{{userHeaders[2]}} </th> - <td mat-cell *matCellDef="let rowData"> {{rowData.firstName}}</td> + <td mat-cell *matCellDef="let rowData"> {{rowData.first_name}}</td> </ng-container> <ng-container matColumnDef="Email"> @@ -63,12 +63,12 @@ <td mat-cell *matCellDef="let rowData" > {{rowData.email}} </td> </ng-container> - <ng-container matColumnDef="orgUserId"> + <ng-container matColumnDef="Org User ID"> <th mat-header-cell *matHeaderCellDef id="heading4"> {{userHeaders[4]}} </th> <td mat-cell *matCellDef="let rowData" > {{rowData.orgUserId}} </td> </ng-container> - <ng-container matColumnDef="orgManagerUserId"> + <ng-container matColumnDef="Org Manager User ID"> <th mat-header-cell *matHeaderCellDef id="heading4"> {{userHeaders[5]}} </th> <td mat-cell *matCellDef="let rowData" > {{rowData.orgManagerUserId}} </td> </ng-container> @@ -86,7 +86,7 @@ <ng-container matColumnDef="Active?"> <th mat-header-cell *matHeaderCellDef id="heading6"> {{userHeaders[7]}} </th> <td mat-cell *matCellDef="let rowData"> - <mat-slide-toggle [(ngModel)]="rowData.active" (change)="toggleUserActive(rowData)"></mat-slide-toggle> + <mat-slide-toggle [checked]="(rowData.active_yn =='Y' || rowData.active_yn == true) ? true : false" (change)="toggleUserActive(rowData,$event)"></mat-slide-toggle> </td> </ng-container> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.scss b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.scss index 3b9e9d3b..ec84c3b0 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.scss +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.scss @@ -37,35 +37,18 @@ */ table { - width: 100%; - } - - .mat-form-field { - font-size: 14px; - width: 100%; - } - - td, th { - width: 25%; - } - .mat-form-field[_ngcontent-c4] { - font-size: 14px; - width: 20%; - float: right; - } + width: 100%; +} - /*td.mat-cell, td.mat-footer-cell{ - padding: 0; - border-bottom-width: 1px; - border-bottom-style: solid; - border-right-style: solid; - border-right-color: rgba(0,0,0,.12); - border-right-width: 1px; - } -*/ +::ng-deep .mat-header-cell{ + font-weight: bold; + font-size: 14px; + color: #343a40; +} -td[_ngcontent-c4], th[_ngcontent-c4] { - width: 15%; +::ng-deep .mat-form-field[_ngcontent-c4] { + font-size: 14px; + width: 20%; } #edit-button{ diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts index 9ae59ca8..734aaf09 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts @@ -57,14 +57,13 @@ export class SearchComponent implements OnInit { response: any; result: any; profileList:any; - userHeaders = ["User ID","Last Name","First Name","Email","orgUserId","orgManagerUserId","Edit","Active?"]; + userHeaders = ["User ID","Last Name","First Name","Email","Org User ID","Org Manager User ID","Edit","Active?"]; constructor(public profileservice:ProfileService, public ngbModal: NgbModal,private _router: Router) { } dataSource: MatTableDataSource<[]>; @ViewChild(MatPaginator, {}) paginator: MatPaginator; @ViewChild(MatSort, {}) sort: MatSort; - ngOnInit() { this.getUsers(); } @@ -72,7 +71,7 @@ export class SearchComponent implements OnInit { getUsers(){ this.showSpinner = true; let response; - this.response = this.profileservice.getUserPagination(); + this.response = this.profileservice.getAllUsers(); this.response.subscribe(data => { response = data; this.result = JSON.parse(response.data); @@ -84,9 +83,9 @@ export class SearchComponent implements OnInit { }); } - toggleUserActive(user){ - let activeOrInactive = (user.active) ? 'activate' : 'inactivate'; - let confirmationMsg = 'You are about to ' + activeOrInactive + ' the user ' + user.firstName +" "+user.lastName+ '. Do you want to continue?'; + toggleUserActive(user, e){ + let activeOrInactive = (e.checked) ? 'activate' : 'inactivate'; + let confirmationMsg = 'You are about to ' + activeOrInactive + ' the user ' + user.first_name +" "+user.last_name+ '. Do you want to continue?'; const modalInfoRef = this.ngbModal.open(InformationModalComponent); modalInfoRef.componentInstance.title = 'Confirmation'; modalInfoRef.componentInstance.message = confirmationMsg; @@ -104,7 +103,7 @@ export class SearchComponent implements OnInit { this.openConfirmationModal("Error",error); }); } else { - user.active = !user.active; + this.ngOnInit(); } }, (result) => { diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts index 5a5a41a8..50973763 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.ts @@ -45,18 +45,11 @@ import { } from '@angular/common/http'; import { Observable } from 'rxjs'; import { v4 as uuid } from 'uuid'; -declare const getWebJunctionXSRFToken: any; export class HeaderInterceptor implements HttpInterceptor { intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { - // Clone the request to add the new header - // HttpHeader object immutable - copy values - var XSRFToken = getWebJunctionXSRFToken(); - console.log('XSRFToken:', XSRFToken); const headerSettings: { [name: string]: string | string[]; } = {}; headerSettings['X-ECOMP-RequestID'] = uuid(); const requestType = req.params.get('requestType'); - if (XSRFToken.name && XSRFToken.value) - headerSettings['X-XSRF-TOKEN'] = XSRFToken.value; if(requestType!=null && requestType==='fileUpload'){ //headerSettings['Content-Type'] = 'multipart/form-data'; }else{ diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/interceptor/ResourceInterceptor.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/interceptor/ResourceInterceptor.java index 58c6cd62..3a7baccd 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/interceptor/ResourceInterceptor.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/interceptor/ResourceInterceptor.java @@ -51,6 +51,8 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.objectcache.AbstractCacheManager; import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; import org.onap.portalsdk.core.service.DataAccessService; @@ -144,7 +146,7 @@ public class ResourceInterceptor extends HandlerInterceptorAdapter { String decreptedPwd = null; try { decreptedPwd = CipherUtil.decryptPKC(app.getAppPassword(), - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "handleSessionUpdates failed to decrypt password", e); } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RestApiRequestBuilder.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RestApiRequestBuilder.java index d9b96284..8f1a26bb 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RestApiRequestBuilder.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/RestApiRequestBuilder.java @@ -46,6 +46,8 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; import org.onap.portalsdk.core.onboarding.rest.RestWebServiceClient; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.util.SystemProperties; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; @@ -78,7 +80,7 @@ public class RestApiRequestBuilder { appUserName = app.getUsername(); try { decryptedPwd = CipherUtil.decryptPKC(app.getAppPassword(), - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (CipherUtilException e) { logger.error(EELFLoggerDelegate.errorLogger, "getViaREST failed", e); throw new IOException("getViaREST failed", e); @@ -116,7 +118,7 @@ public class RestApiRequestBuilder { appUserName = app.getUsername(); try { decryptedPwd = CipherUtil.decryptPKC(app.getAppPassword(), - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (CipherUtilException e) { logger.error(EELFLoggerDelegate.errorLogger, "postViaREST failed", e); throw new IOException("postViaREST failed", e); @@ -153,7 +155,7 @@ public class RestApiRequestBuilder { appUserName = app.getUsername(); try { decryptedPwd = CipherUtil.decryptPKC(app.getAppPassword(), - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (CipherUtilException e) { logger.error(EELFLoggerDelegate.errorLogger, "deleteViaRest failed", e); throw new IOException("deleteViaRest failed", e); diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserApiServiceImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserApiServiceImpl.java index 9ed0f38c..7df80183 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserApiServiceImpl.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserApiServiceImpl.java @@ -58,6 +58,8 @@ 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.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.portalsdk.external.authorization.domain.ExternalAccessPerms; import org.onap.portalsdk.external.authorization.domain.ExternalAccessRole; @@ -265,7 +267,7 @@ public class UserApiServiceImpl implements UserApiService { if (encrypted != null && encrypted.length() > 0) { try { result = CipherUtil.decryptPKC(encrypted, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e); throw e; diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileService.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileService.java index 9a43a203..880b6d73 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileService.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileService.java @@ -51,4 +51,6 @@ public interface UserProfileService { public List<User> findAllUserWithOnOffline(String originOrgUserId); List<User> findAllActive(); + + List<User> listAllUsers(); } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileServiceImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileServiceImpl.java index 879a11de..67dfefab 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileServiceImpl.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/UserProfileServiceImpl.java @@ -45,6 +45,7 @@ import java.util.SortedSet; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; +import org.onap.portalsdk.core.domain.Profile; import org.onap.portalsdk.core.domain.Role; import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.domain.support.CollaborateList; @@ -132,4 +133,11 @@ public class UserProfileServiceImpl implements UserProfileService { return users; } + @Override + public List<User> listAllUsers() { + @SuppressWarnings("unchecked") + List<User> users = getDataAccessService().getList(Profile.class, null); + return users; + } + } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/WebServiceCallServiceImpl.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/WebServiceCallServiceImpl.java index 5582fd2e..a49be085 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/WebServiceCallServiceImpl.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/service/WebServiceCallServiceImpl.java @@ -42,6 +42,8 @@ import java.util.List; import org.onap.portalsdk.core.domain.App; import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.util.SystemProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -70,7 +72,7 @@ public class WebServiceCallServiceImpl implements WebServiceCallService { String encriptedPwdDB = app.getAppPassword(); String appUserName = app.getUsername(); String decreptedPwd = CipherUtil.decryptPKC(encriptedPwdDB, - secretKey == null ? SystemProperties.getProperty(SystemProperties.Decryption_Key) : secretKey); + secretKey == null ? KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY) : secretKey); if (decreptedPwd.equals(requestPassword) && appUserName.equals(requestAppName)) { return true; } diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RestApiRequestBuilderTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RestApiRequestBuilderTest.java index 099f4c42..132ab546 100644 --- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RestApiRequestBuilderTest.java +++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RestApiRequestBuilderTest.java @@ -48,13 +48,15 @@ import org.mockito.Mockito; import org.onap.portalsdk.core.domain.App; import org.onap.portalsdk.core.onboarding.rest.RestWebServiceClient; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.util.SystemProperties; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PrepareForTest({ SystemProperties.class, CipherUtil.class, RestWebServiceClient.class }) +@PrepareForTest({ SystemProperties.class, CipherUtil.class, RestWebServiceClient.class, KeyProperties.class, KeyConstants.class }) public class RestApiRequestBuilderTest { @InjectMocks @@ -77,10 +79,12 @@ public class RestApiRequestBuilderTest { String status = "SUCCESS"; PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(CipherUtil.class); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), - SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn(app.getAppPassword()); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(RestWebServiceClient.class); @@ -110,7 +114,9 @@ public class RestApiRequestBuilderTest { app.setAppPassword("Password"); PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); Mockito.when(appService.getDefaultApp()).thenReturn(app); restApiRequestBuilder.getViaREST(restEndPoint, isBasicAuth, userId); @@ -155,10 +161,12 @@ public class RestApiRequestBuilderTest { String status = "SUCCESS"; PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(CipherUtil.class); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), - SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn(app.getAppPassword()); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(RestWebServiceClient.class); RestWebServiceClient client = Mockito.mock(RestWebServiceClient.class); @@ -187,7 +195,9 @@ public class RestApiRequestBuilderTest { app.setAppPassword("Password"); PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); Mockito.when(appService.getDefaultApp()).thenReturn(app); restApiRequestBuilder.postViaREST(restEndPoint, isBasicAuth,content, userId); @@ -230,10 +240,12 @@ public class RestApiRequestBuilderTest { String status = "SUCCESS"; PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(CipherUtil.class); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), - SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn(app.getAppPassword()); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(RestWebServiceClient.class); RestWebServiceClient client = Mockito.mock(RestWebServiceClient.class); @@ -262,7 +274,9 @@ public class RestApiRequestBuilderTest { app.setAppPassword("Password"); PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); Mockito.when(appService.getDefaultApp()).thenReturn(app); restApiRequestBuilder.deleteViaRest(restEndPoint, isBasicAuth,content, userId); diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/WebServiceCallServiceImplTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/WebServiceCallServiceImplTest.java index 69e9b410..89c2fabf 100644 --- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/WebServiceCallServiceImplTest.java +++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/WebServiceCallServiceImplTest.java @@ -48,13 +48,15 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.onap.portalsdk.core.domain.App; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.util.SystemProperties; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PrepareForTest({CipherUtil.class, SystemProperties.class}) +@PrepareForTest({CipherUtil.class, SystemProperties.class, KeyProperties.class, KeyConstants.class}) public class WebServiceCallServiceImplTest { @InjectMocks @@ -78,7 +80,9 @@ public class WebServiceCallServiceImplTest { Mockito.when(appService.getDefaultApp()).thenReturn(app); PowerMockito.mockStatic(CipherUtil.class); PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(secretKey); Mockito.when(CipherUtil.decryptPKC(Mockito.anyString(), Mockito.anyString())).thenReturn(requestPassword); webServiceCallServiceImpl.verifyRESTCredential(secretKey, requestAppName, requestPassword); Assert.assertTrue(true); @@ -95,7 +99,9 @@ public class WebServiceCallServiceImplTest { Mockito.when(appService.getDefaultApp()).thenReturn(app); PowerMockito.mockStatic(CipherUtil.class); PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn("Key"); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn("Key"); Mockito.when(CipherUtil.decryptPKC(Mockito.anyString(), Mockito.anyString())).thenReturn("Key"); webServiceCallServiceImpl.verifyRESTCredential(secretKey, requestAppName, requestPassword); Assert.assertFalse(false); |