summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-analytics/src/main
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2019-10-02 11:25:24 +0900
committerParshad Patel <pars.patel@samsung.com>2019-10-02 11:25:31 +0900
commitd98d4c9f564428ee9edd398675b27226645d7ef5 (patch)
tree6b9d671ac65402a46eade8ce2612e4e5cfe443fb /ecomp-sdk/epsdk-analytics/src/main
parent5cee34b123b218eff6cb488bb122f07b5056c140 (diff)
Fix NPE issue in epsdk-analytics
Fix A "NullPointerException" could be thrown Either log or rethrow this exception Define a constant instead of duplicating this literal Replace the type specification in this constructor call with the diamond operator ("<>") Issue-ID: PORTAL-562 Change-Id: I51a8bb0feec5b63f82b19097d62a4977a020fdfe Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResultJSON.java462
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResult.java309
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorController.java277
3 files changed, 545 insertions, 503 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResultJSON.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResultJSON.java
index 39b9707c..c3fc0a7b 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResultJSON.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/ReportSearchResultJSON.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- *
+ *
*/
package org.onap.portalsdk.analytics.model.search;
@@ -43,227 +43,263 @@ import javax.servlet.http.HttpServletRequest;
import org.onap.portalsdk.analytics.error.RaptorException;
import org.onap.portalsdk.analytics.system.AppUtils;
+import org.onap.portalsdk.analytics.system.DbUtils;
import org.onap.portalsdk.analytics.system.Globals;
import org.onap.portalsdk.analytics.util.AppConstants;
import org.onap.portalsdk.analytics.util.DataSet;
-
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import com.fasterxml.jackson.databind.ObjectMapper;
-class MetaReport {
- private boolean pagination = true;
- private int pageSize;
- private int totalSize;
- private int pageNo;
- public boolean isPagination() {
- return pagination;
- }
- public void setPagination(boolean pagination) {
- this.pagination = pagination;
- }
- public int getPageSize() {
- return pageSize;
- }
- public void setPageSize(int pageSize) {
- this.pageSize = pageSize;
- }
- public int getTotalSize() {
- return totalSize;
- }
- public void setTotalSize(int totalSize) {
- this.totalSize = totalSize;
- }
- public int getPageNo() {
- return pageNo;
- }
- public void setPageNo(int pageNo) {
- this.pageNo = pageNo;
- }
-
-
+class MetaReport {
+ private boolean pagination = true;
+ private int pageSize;
+ private int totalSize;
+ private int pageNo;
+
+ public boolean isPagination() {
+ return pagination;
+ }
+
+ public void setPagination(boolean pagination) {
+ this.pagination = pagination;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ public int getTotalSize() {
+ return totalSize;
+ }
+
+ public void setTotalSize(int totalSize) {
+ this.totalSize = totalSize;
+ }
+
+ public int getPageNo() {
+ return pageNo;
+ }
+
+ public void setPageNo(int pageNo) {
+ this.pageNo = pageNo;
+ }
+
}
+
+
class SearchReport {
- private MetaReport metaReport;
- public MetaReport getMetaReport() {
- return metaReport;
- }
- public void setMetaReport(MetaReport metaReport) {
- this.metaReport = metaReport;
- }
- private ArrayList<ArrayList<SearchResultColumn>> columns = new ArrayList<ArrayList<SearchResultColumn>>();
- private ArrayList<ArrayList<SearchResultRow>> rows = new ArrayList<ArrayList<SearchResultRow>>();
- public ArrayList<ArrayList<SearchResultColumn>> getColumns() {
- return columns;
- }
- public void setColumns(ArrayList<ArrayList<SearchResultColumn>> columns) {
- this.columns = columns;
- }
- public ArrayList<ArrayList<SearchResultRow>> getRows() {
- return rows;
- }
- public void setRows(ArrayList<ArrayList<SearchResultRow>> rows) {
- this.rows = rows;
- }
-
+ private MetaReport metaReport;
+
+ public MetaReport getMetaReport() {
+ return metaReport;
+ }
+
+ public void setMetaReport(MetaReport metaReport) {
+ this.metaReport = metaReport;
+ }
+
+ private ArrayList<ArrayList<SearchResultColumn>> columns = new ArrayList<>();
+ private ArrayList<ArrayList<SearchResultRow>> rows = new ArrayList<>();
+
+ public ArrayList<ArrayList<SearchResultColumn>> getColumns() {
+ return columns;
+ }
+
+ public void setColumns(ArrayList<ArrayList<SearchResultColumn>> columns) {
+ this.columns = columns;
+ }
+
+ public ArrayList<ArrayList<SearchResultRow>> getRows() {
+ return rows;
+ }
+
+ public void setRows(ArrayList<ArrayList<SearchResultRow>> rows) {
+ this.rows = rows;
+ }
+
}
+
public class ReportSearchResultJSON extends SearchResultJSON {
- private static final String HTML_FORM = "forma";
- private String JSONString= "";
- private SearchReport searchReport;
- //private ArrayList<ArrayList<SearchResultColumn>> columns = new ArrayList<ArrayList<SearchResultColumn>>();
- //private ArrayList<ArrayList<SearchResultRow>> rows = new ArrayList<ArrayList<SearchResultRow>>();
-
-
- public ReportSearchResultJSON(int pageNo) {
- this(pageNo, Globals.getDefaultPageSize(), -1, -1);
- } // ReportSearchResult
-
- public ReportSearchResultJSON(int pageNo, int writeAccessColIndex, int ownerIndicatorColIndex) {
- this(pageNo, Globals.getDefaultPageSize(), writeAccessColIndex, ownerIndicatorColIndex);
- } // ReportSearchResult
-
- public ReportSearchResultJSON(int pageNo, int pageSize, int writeAccessColIndex,
- int ownerIndicatorColIndex) {
-
- searchReport = new SearchReport();
- MetaReport metaReport = new MetaReport();
- //if(searchReport.getMetaReport()!=null)
- searchReport.setMetaReport(metaReport);
- metaReport.setPageNo(pageNo);
- metaReport.setPageSize(pageSize);
- metaReport.setPagination(true);
- addColumn(new SearchResultColumn("no", "No", "5%", "Center"));
- addColumn(new SearchResultColumn("rep_id", "Report ID", "5%", "Center"));
- addColumn(new SearchResultColumn("rep_name", "Report Name", "25%", "Left"));
- addColumn(new SearchResultColumn("descr", "Description", "30%", "Left"));
- addColumn(new SearchResultColumn("owner", "Report Owner", "10%", "Center"));
- addColumn(new SearchResultColumn("create_date", "Create Date", "10%", "Center"));
- addColumn(new SearchResultColumn("copy", "Copy", "5%", "Center",
- "document." + HTML_FORM + "." + AppConstants.RI_ACTION
- + ".value='report.copy';", "Copy report", HTML_FORM,
- "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("&nbsp;&nbsp;Schedule&nbsp;&nbsp;", "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
- + ".value='report.edit';", "Edit report", HTML_FORM, null, AppUtils
- .getImgFolderURL()
- + "pen_paper.gif", "12", "12", false, true, false));
- addColumn(new SearchResultColumn("delete", "Delete", "5%", "Center", "document." + HTML_FORM
- + "." + AppConstants.RI_ACTION + ".value='report.delete';", "Delete report",
- HTML_FORM, "Are you sure you want to delete this report?", AppUtils
- .getImgFolderURL()
- + "deleteicon.gif", "12", "12", false, false, true));
- addColumn(new SearchResultColumn("schedule", "Schedule", "5%", "Center", "document." + HTML_FORM
- + "." + AppConstants.RI_ACTION + ".value='report.schedule.report.submit_wmenu';", "Schedule report",
- HTML_FORM, null, AppUtils
- .getImgFolderURL()
- + "calendar_icon.gif", "20", "20", false, false, false, true));
- addColumn(new SearchResultColumn("run", "Run", "5%", "Center",
- "document." + HTML_FORM + "." + AppConstants.RI_ACTION
- + ".value='report.run';", "Run report", HTML_FORM, null, AppUtils
- .getImgFolderURL()
- + "test_run.gif", "12", "12"));
- searchReport.getColumns().add(searchResultColumns);
- } // ReportSearchResult
-
- public void parseData(DataSet ds, HttpServletRequest request, int pageNo, int pageSize, int writeAccessColIndex, int ownerIndicatorColIndex) throws RaptorException {
- // Presumes single ID field in the first column of the DataSet and row
- // number in the first SearchResultColumn
-
- pageNo = AppUtils.getRequestNvlValue(request, "r_page").length()>0?Integer.parseInt(AppUtils.getRequestNvlValue(request, "r_page")):0;
- String userID = AppUtils.getUserID(request);
- int dataSize = ds.getRowCount();
- //pageSize = 0;
-
- if(searchReport.getMetaReport()!=null) {
- searchReport.getMetaReport().setPageNo(pageNo);
- //searchReport.getMetaReport().setPageSize(pageSize);
- pageSize = searchReport.getMetaReport().getPageSize();
- searchReport.getMetaReport().setTotalSize(dataSize);
- }
- int startRow = (pageNo >= 0) ? (pageNo * pageSize) : 0;
- int endRow = (pageNo >= 0) ? Math.min(startRow + pageSize, ds.getRowCount()) : ds
- .getRowCount();
- for (int r = startRow; r < endRow; r++) {
- SearchResultRow row = new SearchResultRow();
- searchResultRows.add(row);
-
- String idValue = ds.getString(r, 0);
-
- boolean bCanEdit = true;
- if (writeAccessColIndex >= 0) {
- String isReadOnlyValue = nvl(ds.getString(r, writeAccessColIndex), "Y");
- bCanEdit = AppUtils.isSuperUser(request) || AppUtils.isAdminUser(request)
- || isReadOnlyValue.equals("N");
- }
-
- boolean bCanDelete = bCanEdit;
- if (Globals.getDeleteOnlyByOwner() && ownerIndicatorColIndex >= 0) {
- String isOwnedByUserRecord = nvl(ds.getString(r, ownerIndicatorColIndex), "N");
- bCanDelete = AppUtils.isSuperUser(request) || isOwnedByUserRecord.equals("Y");
- }
-
- boolean bCanSchedule = ds.getString(r, getNumColumns()-3).equals("Y");
-
- row.addColumnContent(new ColumnContent(getColumn(0).getColumnId(), new SearchResultField("" + (r + 1), idValue,
- getColumn(0), true)));
- boolean isAuthorized = true;
- for (int c = 1; c < getNumColumns(); c++) {
- SearchResultColumn column = getColumn(c);
- isAuthorized = true;
-
- if(column.isCopyLink())
- isAuthorized = Globals.getCanCopyOnReadOnly()? true:bCanEdit;
- else if (column.isDeleteLink())
- isAuthorized = bCanDelete;
- else if (column.isEditLink())
- isAuthorized = bCanEdit;
- else if (column.isScheduleLink())
- isAuthorized = bCanSchedule;
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportSearchResultJSON.class);
+ private static final String HTML_FORM = "forma";
+ private String jsonString = "";
+ private SearchReport searchReport;
+ // private ArrayList<ArrayList<SearchResultColumn>> columns = new
+ // ArrayList<ArrayList<SearchResultColumn>>();
+ // private ArrayList<ArrayList<SearchResultRow>> rows = new ArrayList<ArrayList<SearchResultRow>>();
+
+ public ReportSearchResultJSON(int pageNo) {
+ this(pageNo, Globals.getDefaultPageSize(), -1, -1);
+ } // ReportSearchResult
+
+ public ReportSearchResultJSON(int pageNo, int writeAccessColIndex, int ownerIndicatorColIndex) {
+ this(pageNo, Globals.getDefaultPageSize(), writeAccessColIndex, ownerIndicatorColIndex);
+ } // ReportSearchResult
+
+ public ReportSearchResultJSON(int pageNo, int pageSize, int writeAccessColIndex,
+ int ownerIndicatorColIndex) {
+
+ searchReport = new SearchReport();
+ MetaReport metaReport = new MetaReport();
+ // if(searchReport.getMetaReport()!=null)
+ searchReport.setMetaReport(metaReport);
+ metaReport.setPageNo(pageNo);
+ metaReport.setPageSize(pageSize);
+ metaReport.setPagination(true);
+ addColumn(new SearchResultColumn("no", "No", "5%", "Center"));
+ addColumn(new SearchResultColumn("rep_id", "Report ID", "5%", "Center"));
+ addColumn(new SearchResultColumn("rep_name", "Report Name", "25%", "Left"));
+ addColumn(new SearchResultColumn("descr", "Description", "30%", "Left"));
+ addColumn(new SearchResultColumn("owner", "Report Owner", "10%", "Center"));
+ addColumn(new SearchResultColumn("create_date", "Create Date", "10%", "Center"));
+ addColumn(new SearchResultColumn("copy", "Copy", "5%", "Center",
+ "document." + HTML_FORM + "." + AppConstants.RI_ACTION
+ + ".value='report.copy';",
+ "Copy report", HTML_FORM,
+ "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("&nbsp;&nbsp;Schedule&nbsp;&nbsp;", "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
+ + ".value='report.edit';",
+ "Edit report", HTML_FORM, null, AppUtils
+ .getImgFolderURL()
+ + "pen_paper.gif",
+ "12", "12", false, true, false));
+ addColumn(new SearchResultColumn("delete", "Delete", "5%", "Center", "document." + HTML_FORM
+ + "." + AppConstants.RI_ACTION + ".value='report.delete';", "Delete report",
+ HTML_FORM, "Are you sure you want to delete this report?", AppUtils
+ .getImgFolderURL()
+ + "deleteicon.gif",
+ "12", "12", false, false, true));
+ addColumn(new SearchResultColumn("schedule", "Schedule", "5%", "Center", "document." + HTML_FORM
+ + "." + AppConstants.RI_ACTION + ".value='report.schedule.report.submit_wmenu';", "Schedule report",
+ HTML_FORM, null, AppUtils
+ .getImgFolderURL()
+ + "calendar_icon.gif",
+ "20", "20", false, false, false, true));
+ addColumn(new SearchResultColumn("run", "Run", "5%", "Center",
+ "document." + HTML_FORM + "." + AppConstants.RI_ACTION
+ + ".value='report.run';",
+ "Run report", HTML_FORM, null, AppUtils
+ .getImgFolderURL()
+ + "test_run.gif",
+ "12", "12"));
+ searchReport.getColumns().add(searchResultColumns);
+ } // ReportSearchResult
+
+ public void parseData(DataSet ds, HttpServletRequest request, int pageNo, int pageSize, int writeAccessColIndex,
+ int ownerIndicatorColIndex) throws RaptorException {
+ // Presumes single ID field in the first column of the DataSet and row
+ // number in the first SearchResultColumn
+
+ pageNo = AppUtils.getRequestNvlValue(request, "r_page").length() > 0
+ ? Integer.parseInt(AppUtils.getRequestNvlValue(request, "r_page"))
+ : 0;
+ String userID = AppUtils.getUserID(request);
+ int dataSize = ds.getRowCount();
+ // pageSize = 0;
+
+ if (searchReport.getMetaReport() != null) {
+ searchReport.getMetaReport().setPageNo(pageNo);
+ // searchReport.getMetaReport().setPageSize(pageSize);
+ pageSize = searchReport.getMetaReport().getPageSize();
+ searchReport.getMetaReport().setTotalSize(dataSize);
+ }
+ int startRow = (pageNo >= 0) ? (pageNo * pageSize) : 0;
+ int endRow = (pageNo >= 0) ? Math.min(startRow + pageSize, ds.getRowCount())
+ : ds
+ .getRowCount();
+ for (int r = startRow; r < endRow; r++) {
+ SearchResultRow row = new SearchResultRow();
+ searchResultRows.add(row);
+
+ String idValue = ds.getString(r, 0);
+
+ boolean bCanEdit = true;
+ if (writeAccessColIndex >= 0) {
+ String isReadOnlyValue = nvl(ds.getString(r, writeAccessColIndex), "Y");
+ bCanEdit = AppUtils.isSuperUser(request) || AppUtils.isAdminUser(request);
+ if (isReadOnlyValue != null) {
+ bCanEdit = bCanEdit || isReadOnlyValue.equals("N");
+ }
+
+ }
+
+ boolean bCanDelete = bCanEdit;
+ if (Globals.getDeleteOnlyByOwner() && ownerIndicatorColIndex >= 0) {
+ String isOwnedByUserRecord = nvl(ds.getString(r, ownerIndicatorColIndex), "N");
+ bCanDelete = AppUtils.isSuperUser(request);
+ if (isOwnedByUserRecord != null) {
+ bCanDelete = bCanDelete || isOwnedByUserRecord.equals("Y");
+ }
+ }
+
+ boolean bCanSchedule = ds.getString(r, getNumColumns() - 3).equals("Y");
+
+ row.addColumnContent(
+ new ColumnContent(getColumn(0).getColumnId(), new SearchResultField("" + (r + 1), idValue,
+ getColumn(0), true)));
+ boolean isAuthorized = true;
+ for (int c = 1; c < getNumColumns(); c++) {
+ SearchResultColumn column = getColumn(c);
+ isAuthorized = true;
+
+ if (column.isCopyLink())
+ isAuthorized = Globals.getCanCopyOnReadOnly() ? true : bCanEdit;
+ else if (column.isDeleteLink())
+ isAuthorized = bCanDelete;
+ else if (column.isEditLink())
+ isAuthorized = bCanEdit;
+ else if (column.isScheduleLink())
+ isAuthorized = bCanSchedule;
row.addColumnContent(new ColumnContent(column.getColumnId(), new SearchResultField(
- (column.getLinkURL() == null) ? ds.getString(r, c) : column
- .getLinkTitle(), idValue, column, isAuthorized
- )));
- } // for
- } // for
- searchReport.getRows().add(searchResultRows);
- ObjectMapper mapper = new ObjectMapper();
- String jsonInString = "";
- try {
- jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(searchReport);
- } catch (Exception ex) {
- ex.printStackTrace();
-
- }
- System.out.println(jsonInString);
- this.JSONString = jsonInString;
- } // parseData
-
- private String nvl(String s) {
- return (s == null) ? "" : s;
- }
-
- private String nvl(String s, String sDefault) {
- return nvl(s).equals("") ? sDefault : s;
- }
-
- public String getJSONString() {
- return JSONString;
- }
-
- public void setJSONString(String jSONString) {
- JSONString = jSONString;
- }
-
-
-} // ReportSearchResult
+ (column.getLinkURL() == null) ? ds.getString(r, c)
+ : column
+ .getLinkTitle(),
+ idValue, column, isAuthorized)));
+ } // for
+ } // for
+ searchReport.getRows().add(searchResultRows);
+ ObjectMapper mapper = new ObjectMapper();
+ String jsonInString = "";
+ try {
+ jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(searchReport);
+ } catch (Exception ex) {
+ logger.warn("Exception in parseData", ex);
+ }
+ logger.debug(jsonInString);
+ this.jsonString = jsonInString;
+ } // parseData
+ private String nvl(String s) {
+ return (s == null) ? "" : s;
+ }
+
+ private String nvl(String s, String sDefault) {
+ return nvl(s).equals("") ? sDefault : s;
+ }
+
+ public String getJSONString() {
+ return jsonString;
+ }
+
+ public void setJSONString(String jSONString) {
+ jsonString = jSONString;
+ }
+
+} // ReportSearchResult
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResult.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResult.java
index 056ab5b9..5b44681c 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResult.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/search/SearchResult.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- *
+ *
*/
package org.onap.portalsdk.analytics.model.search;
@@ -46,186 +46,187 @@ import org.onap.portalsdk.analytics.system.AppUtils;
import org.onap.portalsdk.analytics.system.Globals;
import org.onap.portalsdk.analytics.util.DataSet;
-public class SearchResult{
- private int pageNo = -1;
-
- private int pageSize = 50;
-
- private int dataSize = -1;
+public class SearchResult {
+ private int pageNo = -1;
- private int writeAccessColIndex = -1;
+ private int pageSize = 50;
- private int ownerIndicatorColIndex = -1;
+ private int dataSize = -1;
- private String csvPageFileName = null;
-
+ private int writeAccessColIndex = -1;
+ private int ownerIndicatorColIndex = -1;
- private String csvAllRowsFileName = null;
-
- private String excelAllRowsFileName = null;
+ private String csvPageFileName = null;
- public ArrayList searchResultColumns = new ArrayList();
-
- public ArrayList searchResultRows = new ArrayList();
+ private String csvAllRowsFileName = null;
- public SearchResult(int pageNo) {
- this(pageNo, Globals.getDefaultPageSize());
- } // SearchResult
+ private String excelAllRowsFileName = null;
- public SearchResult(int pageNo, int pageSize) {
- this(pageNo, pageSize, -1, -1);
- } // SearchResult
+ public ArrayList searchResultColumns = new ArrayList();
- public SearchResult(int pageNo, int pageSize, int writeAccessColIndex,
- int ownerIndicatorColIndex) {
- super();
+ public ArrayList searchResultRows = new ArrayList();
- this.pageNo = pageNo;
- this.pageSize = pageSize;
+ public SearchResult(int pageNo) {
+ this(pageNo, Globals.getDefaultPageSize());
+ } // SearchResult
- this.writeAccessColIndex = writeAccessColIndex;
- this.ownerIndicatorColIndex = ownerIndicatorColIndex;
- } // SearchResult
+ public SearchResult(int pageNo, int pageSize) {
+ this(pageNo, pageSize, -1, -1);
+ } // SearchResult
- public int getPageNo() {
- return pageNo;
- }
+ public SearchResult(int pageNo, int pageSize, int writeAccessColIndex,
+ int ownerIndicatorColIndex) {
+ super();
- public int getPageSize() {
- return pageSize;
- }
+ this.pageNo = pageNo;
+ this.pageSize = pageSize;
- public int getDataSize() {
- return dataSize;
- }
+ this.writeAccessColIndex = writeAccessColIndex;
+ this.ownerIndicatorColIndex = ownerIndicatorColIndex;
+ } // SearchResult
- public String getCsvPageFileName() {
- return csvPageFileName;
- }
+ public int getPageNo() {
+ return pageNo;
+ }
- public String getCsvAllRowsFileName() {
- return csvAllRowsFileName;
- }
+ public int getPageSize() {
+ return pageSize;
+ }
- public String getExcelAllRowsFileName() {
- return excelAllRowsFileName;
- }
-
- private void setDataSize(int dataSize) {
- this.dataSize = dataSize;
- }
+ public int getDataSize() {
+ return dataSize;
+ }
- public void setCsvPageFileName(String csvPageFileName) {
- this.csvPageFileName = csvPageFileName;
- }
+ public String getCsvPageFileName() {
+ return csvPageFileName;
+ }
+
+ public String getCsvAllRowsFileName() {
+ return csvAllRowsFileName;
+ }
+
+ public String getExcelAllRowsFileName() {
+ return excelAllRowsFileName;
+ }
+ private void setDataSize(int dataSize) {
+ this.dataSize = dataSize;
+ }
-
- public void setCsvAllRowsFileName(String csvAllRowsFileName) {
- this.csvAllRowsFileName = csvAllRowsFileName;
- }
+ public void setCsvPageFileName(String csvPageFileName) {
+ this.csvPageFileName = csvPageFileName;
+ }
+ public void setCsvAllRowsFileName(String csvAllRowsFileName) {
+ this.csvAllRowsFileName = csvAllRowsFileName;
+ }
+ public void addColumn(SearchResultColumn column) {
+ searchResultColumns.add(column);
+ } // addColumn
- public void addColumn(SearchResultColumn column) {
- searchResultColumns.add(column);
- } // addColumn
+ public SearchResultColumn getColumn(int index) {
+ return (SearchResultColumn) searchResultColumns.get(index);
+ } // getColumn
- public SearchResultColumn getColumn(int index) {
- return (SearchResultColumn) searchResultColumns.get(index);
- } // getColumn
+ public int getNumColumns() {
+ return searchResultColumns.size();
+ } // getNumColumns
- public int getNumColumns() {
- return searchResultColumns.size();
- } // getNumColumns
+ public int getNumRows() {
+ return searchResultRows.size();
+ } // getNumRows
- public int getNumRows() {
- return searchResultRows.size();
- } // getNumRows
+ public SearchResultRow getRow(int index) {
+ return (SearchResultRow) searchResultRows.get(index);
+ } // getRow
- public SearchResultRow getRow(int index) {
- return (SearchResultRow) searchResultRows.get(index);
- } // getRow
+ public void parseData(DataSet ds, HttpServletRequest request) throws RaptorException {
+ // Presumes single ID field in the first column of the DataSet and row
+ // number in the first SearchResultColumn
+ String userID = AppUtils.getUserID(request);
+ setDataSize(ds.getRowCount());
- public void parseData(DataSet ds, HttpServletRequest request) throws RaptorException {
- // Presumes single ID field in the first column of the DataSet and row
- // number in the first SearchResultColumn
- String userID = AppUtils.getUserID(request);
- setDataSize(ds.getRowCount());
-
- int startRow = (pageNo >= 0) ? (pageNo * pageSize) : 0;
- int endRow = (pageNo >= 0) ? Math.min(startRow + pageSize, ds.getRowCount()) : ds
- .getRowCount();
- for (int r = startRow; r < endRow; r++) {
- SearchResultRow row = new SearchResultRow();
- searchResultRows.add(row);
-
- String idValue = ds.getString(r, 0);
-
- boolean bCanEdit = true;
- if (writeAccessColIndex >= 0) {
- String isReadOnlyValue = nvl(ds.getString(r, writeAccessColIndex), "Y");
- bCanEdit = AppUtils.isSuperUser(request) || AppUtils.isAdminUser(request)
- || isReadOnlyValue.equals("N");
- }
-
- boolean bCanDelete = bCanEdit;
- if (Globals.getDeleteOnlyByOwner() && ownerIndicatorColIndex >= 0) {
- String isOwnedByUserRecord = nvl(ds.getString(r, ownerIndicatorColIndex), "N");
- bCanDelete = AppUtils.isSuperUser(request) || isOwnedByUserRecord.equals("Y");
- }
-
- boolean bCanSchedule = ds.getString(r, getNumColumns()-3).equals("Y");
-
- row.addSearchResultField(new SearchResultField("" + (r + 1), idValue,
- getColumn(0), true));
- boolean isAuthorized = true;
- for (int c = 1; c < getNumColumns(); c++) {
- SearchResultColumn column = getColumn(c);
- isAuthorized = true;
-
- if(column.isCopyLink())
- isAuthorized = Globals.getCanCopyOnReadOnly()? true:bCanEdit;
- else if (column.isDeleteLink())
- isAuthorized = bCanDelete;
- else if (column.isEditLink())
- isAuthorized = bCanEdit;
- else if (column.isScheduleLink())
- isAuthorized = bCanSchedule;
-
- row.addSearchResultField(new SearchResultField(
- (column.getLinkURL() == null) ? ds.getString(r, c) : column
- .getLinkTitle(), idValue, column, isAuthorized
- ));
- } // for
- } // for
- } // parseData
-
- public void truncateToPage(int pageNo) {
- if (this.pageNo >= 0 || pageNo < 0)
- return;
-
- this.pageNo = pageNo;
-
- int startRow = pageNo * pageSize;
- int endRow = Math.min(startRow + pageSize, dataSize);
-
- for (int r = getNumRows() - 1; r >= endRow; r--)
- searchResultRows.remove(r);
-
- for (int r = startRow - 1; r >= 0; r--)
- searchResultRows.remove(r);
- } // truncateToPage
-
- /** *********************************************************************** */
-
- private String nvl(String s) {
- return (s == null) ? "" : s;
- }
-
- private String nvl(String s, String sDefault) {
- return nvl(s).equals("") ? sDefault : s;
- }
+ int startRow = (pageNo >= 0) ? (pageNo * pageSize) : 0;
+ int endRow = (pageNo >= 0) ? Math.min(startRow + pageSize, ds.getRowCount())
+ : ds
+ .getRowCount();
+ for (int r = startRow; r < endRow; r++) {
+ SearchResultRow row = new SearchResultRow();
+ searchResultRows.add(row);
+
+ String idValue = ds.getString(r, 0);
+
+ boolean bCanEdit = true;
+ if (writeAccessColIndex >= 0) {
+ String isReadOnlyValue = nvl(ds.getString(r, writeAccessColIndex), "Y");
+ bCanEdit = AppUtils.isSuperUser(request) || AppUtils.isAdminUser(request);
+ if (isReadOnlyValue != null) {
+ bCanEdit = bCanEdit || isReadOnlyValue.equals("N");
+ }
+ }
+
+ boolean bCanDelete = bCanEdit;
+ if (Globals.getDeleteOnlyByOwner() && ownerIndicatorColIndex >= 0) {
+ String isOwnedByUserRecord = nvl(ds.getString(r, ownerIndicatorColIndex), "N");
+ bCanDelete = AppUtils.isSuperUser(request);
+ if (isOwnedByUserRecord != null) {
+ bCanDelete = bCanDelete || isOwnedByUserRecord.equals("Y");
+ }
+ }
+
+ boolean bCanSchedule = ds.getString(r, getNumColumns() - 3).equals("Y");
+
+ row.addSearchResultField(new SearchResultField("" + (r + 1), idValue,
+ getColumn(0), true));
+ boolean isAuthorized = true;
+ for (int c = 1; c < getNumColumns(); c++) {
+ SearchResultColumn column = getColumn(c);
+ isAuthorized = true;
+
+ if (column.isCopyLink())
+ isAuthorized = Globals.getCanCopyOnReadOnly() ? true : bCanEdit;
+ else if (column.isDeleteLink())
+ isAuthorized = bCanDelete;
+ else if (column.isEditLink())
+ isAuthorized = bCanEdit;
+ else if (column.isScheduleLink())
+ isAuthorized = bCanSchedule;
+
+ row.addSearchResultField(new SearchResultField(
+ (column.getLinkURL() == null) ? ds.getString(r, c)
+ : column
+ .getLinkTitle(),
+ idValue, column, isAuthorized));
+ } // for
+ } // for
+ } // parseData
+
+ public void truncateToPage(int pageNo) {
+ if (this.pageNo >= 0 || pageNo < 0)
+ return;
+
+ this.pageNo = pageNo;
+
+ int startRow = pageNo * pageSize;
+ int endRow = Math.min(startRow + pageSize, dataSize);
+
+ for (int r = getNumRows() - 1; r >= endRow; r--)
+ searchResultRows.remove(r);
+
+ for (int r = startRow - 1; r >= 0; r--)
+ searchResultRows.remove(r);
+ } // truncateToPage
+
+ /** *********************************************************************** */
+
+ private String nvl(String s) {
+ return (s == null) ? "" : s;
+ }
+
+ private String nvl(String s, String sDefault) {
+ return nvl(s).equals("") ? sDefault : s;
+ }
} // SearchResult
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorController.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorController.java
index 3fd2f1b8..8eda540d 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorController.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorController.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- *
+ *
*/
package org.onap.portalsdk.analytics.system.fusion.web;
@@ -69,140 +69,145 @@ import com.fasterxml.jackson.databind.SerializationFeature;
@RequestMapping("/")
public class RaptorController extends RestrictedBaseController {
- private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RaptorController.class);
-
- @RequestMapping(value = { "/report" }, method = RequestMethod.GET)
- public ModelAndView report(HttpServletRequest request) {
- request.getSession().setAttribute("isEmbedded", false);
- return new ModelAndView("report");
- }
-
- @RequestMapping(value = { "/reportDS1" }, method = RequestMethod.GET)
- public ModelAndView reportDS1(HttpServletRequest request) {
- request.getSession().setAttribute("isEmbedded", false);
- return new ModelAndView("reportDS1");
- }
-
- @RequestMapping(value = { "/report_embedded" }, method = RequestMethod.GET)
- public ModelAndView reportEmbedded(HttpServletRequest request) {
- request.getSession().setAttribute("isEmbedded", true);
- return new ModelAndView("report_embedded");
- }
-
- @RequestMapping(value = { "/report_sample" }, method = RequestMethod.GET)
- public ModelAndView reportSample(HttpServletRequest request) {
- return new ModelAndView("report_sample");
- }
-
- @RequestMapping(value = { "/report_import.htm" }, method = RequestMethod.GET)
- public ModelAndView reportImport(HttpServletRequest request) throws IOException {
- String viewName = "report_import";
- Action action = null;
- String actionKey = "report.import";
- ServletContext servletContext = request.getSession().getServletContext();
- if (!Globals.isSystemInitialized()) {
- Globals.initializeSystem(servletContext);
- }
- try {
- action = Globals.getRaptorActionMapping().getAction(actionKey);
- if (action == null)
- throw new RaptorRuntimeException("Action not found");
- } catch (RaptorException e) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
- + actionKey + "]. RaptorException: " + e.getMessage()));
- viewName = new ErrorHandler().processFatalError(request,
- new RaptorRuntimeException("[Controller.processRequest]Invalid raptor action [" + actionKey
- + "]. Exception: " + e.getMessage()));
- }
- return new ModelAndView(viewName, "model", null);
- }
-
- @RequestMapping(value = { "/report_wizard.htm" }, method = { RequestMethod.POST, RequestMethod.GET })
- public ModelAndView reportWizard(HttpServletRequest request, HttpServletResponse response) throws IOException {
- String viewName = "";
- String actionKey = nvl(request.getParameter(AppConstants.RI_ACTION), request.getParameter("action"));
- actionKey = nvl(actionKey, "report.run");
- Action action = null;
- ServletContext servletContext = request.getSession().getServletContext();
- if (!Globals.isSystemInitialized()) {
- Globals.initializeSystem(servletContext);
- }
- try {
- action = Globals.getRaptorActionMapping().getAction(actionKey);
- if (action == null)
- throw new RaptorRuntimeException("Action not found");
- } catch (RaptorException e) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
- + actionKey + "]. RaptorException: " + e.getMessage()));
- viewName = (new ErrorHandler()).processFatalError(request,
- new RaptorRuntimeException("[Controller.processRequest]Invalid raptor action [" + actionKey
- + "]. Exception: " + e.getMessage()));
- ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
- errorJSONRuntime.setErrormessage(e.toString());
- errorJSONRuntime.setStacktrace(getStackTrace(e));
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- String jsonInString = "";
- try {
- jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
- } catch (Exception ex) {
- ex.printStackTrace();
-
- }
- }
-
- try {
- Class<?>[] paramTypes = new Class[2];
- paramTypes[0] = Class.forName("javax.servlet.http.HttpServletRequest");
- paramTypes[1] = Class.forName("java.lang.String");
-
- Class<?> handlerClass = Class.forName(action.getControllerClass());
- Object handler = handlerClass.newInstance();
- Method handlerMethod = handlerClass.getMethod(action.getControllerMethod(), paramTypes);
-
- Object[] paramValues = new Object[2];
- paramValues[0] = request;
- paramValues[1] = action.getJspName();
- viewName = (String) handlerMethod.invoke(handler, paramValues);
- } catch (Exception e) {
- logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
- + actionKey + "]. Exception: " + e.getMessage()));
- viewName = (new ErrorHandler()).processFatalError(request,
- new RaptorRuntimeException(
- "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
- + e.getMessage()));
-
- ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
- errorJSONRuntime.setErrormessage(e.toString());
- errorJSONRuntime.setStacktrace(getStackTrace(e));
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- String jsonInString = "";
- try {
- jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
- } catch (Exception ex) {
- ex.printStackTrace();
-
- }
- }
- return new ModelAndView(viewName, "model", null);
- }
-
- private String nvl(String s) {
- return (s == null) ? "" : s;
- }
-
- private String nvl(String s, String sDefault) {
- return nvl(s).equals("") ? sDefault : s;
- }
-
- public static String getStackTrace(Throwable aThrowable) {
- Writer result = new StringWriter();
- PrintWriter printWriter = new PrintWriter(result);
- aThrowable.printStackTrace(printWriter);
- return result.toString();
- }
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RaptorController.class);
+ private static final String IS_EMBEDDED = "isEmbedded";
+ private static final String ACTION_NOT_FOUND = "Action not found";
+
+ @RequestMapping(value = { "/report" }, method = RequestMethod.GET)
+ public ModelAndView report(HttpServletRequest request) {
+ request.getSession().setAttribute(IS_EMBEDDED, false);
+ return new ModelAndView("report");
+ }
+
+ @RequestMapping(value = { "/reportDS1" }, method = RequestMethod.GET)
+ public ModelAndView reportDS1(HttpServletRequest request) {
+ request.getSession().setAttribute(IS_EMBEDDED, false);
+ return new ModelAndView("reportDS1");
+ }
+
+ @RequestMapping(value = { "/report_embedded" }, method = RequestMethod.GET)
+ public ModelAndView reportEmbedded(HttpServletRequest request) {
+ request.getSession().setAttribute(IS_EMBEDDED, true);
+ return new ModelAndView("report_embedded");
+ }
+
+ @RequestMapping(value = { "/report_sample" }, method = RequestMethod.GET)
+ public ModelAndView reportSample(HttpServletRequest request) {
+ return new ModelAndView("report_sample");
+ }
+
+ @RequestMapping(value = { "/report_import.htm" }, method = RequestMethod.GET)
+ public ModelAndView reportImport(HttpServletRequest request) throws IOException {
+ String viewName = "report_import";
+ Action action = null;
+ String actionKey = "report.import";
+ ServletContext servletContext = request.getSession().getServletContext();
+ if (!Globals.isSystemInitialized()) {
+ Globals.initializeSystem(servletContext);
+ }
+ try {
+ action = Globals.getRaptorActionMapping().getAction(actionKey);
+ if (action == null)
+ throw new RaptorRuntimeException(ACTION_NOT_FOUND);
+ } catch (RaptorException e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
+ + actionKey + "]. RaptorException: " + e.getMessage()));
+ viewName = new ErrorHandler().processFatalError(request,
+ new RaptorRuntimeException("[Controller.processRequest]Invalid raptor action [" + actionKey
+ + "]. Exception: " + e.getMessage()));
+ }
+ return new ModelAndView(viewName, "model", null);
+ }
+
+ @RequestMapping(value = { "/report_wizard.htm" }, method = { RequestMethod.POST, RequestMethod.GET })
+ public ModelAndView reportWizard(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ String viewName = "";
+ String actionKey = nvl(request.getParameter(AppConstants.RI_ACTION), request.getParameter("action"));
+ actionKey = nvl(actionKey, "report.run");
+ Action action = null;
+ ServletContext servletContext = request.getSession().getServletContext();
+ if (!Globals.isSystemInitialized()) {
+ Globals.initializeSystem(servletContext);
+ }
+ try {
+ action = Globals.getRaptorActionMapping().getAction(actionKey);
+ if (action == null) {
+ throw new RaptorRuntimeException(ACTION_NOT_FOUND);
+ }
+ } catch (RaptorException e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
+ + actionKey + "]. RaptorException: " + e.getMessage()));
+ viewName = (new ErrorHandler()).processFatalError(request,
+ new RaptorRuntimeException("[Controller.processRequest]Invalid raptor action [" + actionKey
+ + "]. Exception: " + e.getMessage()));
+ ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
+ errorJSONRuntime.setErrormessage(e.toString());
+ errorJSONRuntime.setStacktrace(getStackTrace(e));
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ String jsonInString = "";
+ try {
+ jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
+ } catch (Exception ex) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Exception in JSON mapper", ex);
+ }
+ }
+
+ try {
+ Class<?>[] paramTypes = new Class[2];
+ paramTypes[0] = Class.forName("javax.servlet.http.HttpServletRequest");
+ paramTypes[1] = Class.forName("java.lang.String");
+
+ if (action != null) {
+ Class<?> handlerClass = Class.forName(action.getControllerClass());
+ Object handler = handlerClass.newInstance();
+ Method handlerMethod = handlerClass.getMethod(action.getControllerMethod(), paramTypes);
+
+ Object[] paramValues = new Object[2];
+ paramValues[0] = request;
+ paramValues[1] = action.getJspName();
+ viewName = (String) handlerMethod.invoke(handler, paramValues);
+ } else {
+ throw new RaptorRuntimeException(ACTION_NOT_FOUND);
+ }
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, ("[Controller.processRequest]Invalid raptor action ["
+ + actionKey + "]. Exception: " + e.getMessage()));
+ viewName = (new ErrorHandler()).processFatalError(request,
+ new RaptorRuntimeException(
+ "[Controller.processRequest] Unable to instantiate and invoke action handler. Exception: "
+ + e.getMessage()));
+
+ ErrorJSONRuntime errorJSONRuntime = new ErrorJSONRuntime();
+ errorJSONRuntime.setErrormessage(e.toString());
+ errorJSONRuntime.setStacktrace(getStackTrace(e));
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ String jsonInString = "";
+ try {
+ jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(errorJSONRuntime);
+ } catch (Exception ex) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "Exception in JSON mapper", ex);
+ }
+ }
+ return new ModelAndView(viewName, "model", null);
+ }
+
+ private String nvl(String s) {
+ return (s == null) ? "" : s;
+ }
+
+ private String nvl(String s, String sDefault) {
+ return nvl(s).equals("") ? sDefault : s;
+ }
+
+ public static String getStackTrace(Throwable aThrowable) {
+ Writer result = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(result);
+ aThrowable.printStackTrace(printWriter);
+ return result.toString();
+ }
}