diff options
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion')
3 files changed, 52 insertions, 17 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtils.java index 032b394b..fcff3183 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtils.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtils.java @@ -58,7 +58,13 @@ public class RemoteDbUtils implements RDbUtils{ public Connection getRemoteConnection(String dbKey) { - return raptorAdapter.getConnection(dbKey); + try { + org.onap.portalsdk.analytics.util.RemDbInfo remDbInfo = new org.onap.portalsdk.analytics.util.RemDbInfo(); + return remDbInfo.getDBConnection(dbKey); + } catch (Exception ex) { + ex.printStackTrace(); + return null; + } } public void clearConnection(Connection conn) { diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java index d54e0579..a03c9539 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java @@ -141,12 +141,10 @@ public class FileServletController { private void serveFile(HttpServletResponse response, File inFile) throws Exception { - OutputStream os = null; - InputStream is = null; - try { + + try(InputStream is = new BufferedInputStream(new FileInputStream(inFile)); + OutputStream os = new BufferedOutputStream(response.getOutputStream());) { response.reset(); - is = new BufferedInputStream(new FileInputStream(inFile)); - os = new BufferedOutputStream(response.getOutputStream()); response.setContentLength((int) inFile.length()); response.setContentType("application/octet-stream"); response.setHeader("Content-disposition", "attachment; filename=\"" @@ -154,16 +152,7 @@ public class FileServletController { copyStream(is, os); os.flush(); } catch (Exception ex) { - if (os == null) - throw new Exception("Could not open output stream for file "); - if (is == null) - throw new Exception("Could not open input stream for file "); - } finally { - if (os != null) { - os.close(); - } - if (is != null) - is.close(); + throw new Exception("Could not open input or output stream for file "); } } diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java index e06a1765..c761bdcc 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/web/RaptorControllerAsync.java @@ -96,6 +96,7 @@ import org.onap.portalsdk.analytics.model.runtime.ReportFormFields; import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; import org.onap.portalsdk.analytics.system.AppUtils; import org.onap.portalsdk.analytics.system.ConnectionUtils; +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; @@ -711,6 +712,24 @@ public class RaptorControllerAsync extends RestrictedBaseController { // } if (rdef != null) { + String dbInfo = definitionJSON.getDbInfo(); + rdef.setDBInfo(dbInfo); + //save dbType + String schemaSql = Globals.getRemoteDbSchemaSqlWithWhereClause(); + schemaSql = schemaSql.replace("[schema_id]", dbInfo); + String dbType = null; + DataSet ds = null; + try { + ds = DbUtils.executeQuery(schemaSql); + + String prefix = "", desc = ""; + + for (int i = 0; i < ds.getRowCount(); i++) { + dbType = ds.getItem(i, 2); + } + } + catch (Exception e) {} + rdef.setDBType(dbType); String reportName = definitionJSON.getReportName(); String errorString = ""; if (AppUtils.nvl(reportName).length() <= 0) @@ -1358,6 +1377,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { if (pathVariables.containsKey("id")) { id = pathVariables.get("id"); } + String detailId = ""; if (pathVariables.containsKey("detailId")) { detailId = pathVariables.get("detailId"); @@ -1467,6 +1487,26 @@ public class RaptorControllerAsync extends RestrictedBaseController { wizardJSON.setReportTitle((rdef != null) ? rdef.getReportTitle() : ""); wizardJSON.setReportSubTitle((rdef != null) ? rdef.getReportSubTitle() : ""); + + String schemaSql = Globals.getRemoteDbSchemaSql(); + DataSet ds = null; + ArrayList<IdNameBooleanJSON> dbInfoList = new ArrayList<IdNameBooleanJSON>(); + try { + ds = DbUtils.executeQuery(schemaSql); + + String prefix = "", desc = ""; + + for (int i = 0; i < ds.getRowCount(); i++) { + IdNameBooleanJSON dBNameJSON = new IdNameBooleanJSON(); + dBNameJSON.setId(ds.getItem(i, 0)); + dBNameJSON.setName(ds.getItem(i, 0)); + dBNameJSON.setSelected(false); + dbInfoList.add(dBNameJSON); + } + } + catch (Exception e) {} + wizardJSON.setDbInfoList(dbInfoList); + /*Robert add*/ wizardJSON.setOneTimeRec((rdef != null) ? rdef.getIsOneTimeScheduleAllowed() : "false"); wizardJSON.setHourlyRec((rdef != null) ? rdef.getIsHourlyScheduleAllowed() : "false"); @@ -1572,7 +1612,7 @@ public class RaptorControllerAsync extends RestrictedBaseController { try { response.setContentType("application/json"); - ds = ConnectionUtils.getDataSet(sql, "local", true); + ds = ConnectionUtils.getDataSet(sql, rdef.getDBInfo(), true); QueryResultJSON queryResultJSON = new QueryResultJSON(); queryResultJSON.setQuery(queryJSON.getQuery()); |