diff options
author | 2017-04-27 07:53:18 -0400 | |
---|---|---|
committer | 2017-04-27 08:31:27 -0400 | |
commit | 6beb446925c967aca92f5513adf36c5db77c00d6 (patch) | |
tree | 9392057ed0739de2445c5b2a2a8bee6dcdacbcf7 /ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/util/upgrade/SystemUpgrade.java | |
parent | 246b225194e3e8dc1926294de591a94fd9787fa7 (diff) |
[PORTAL-7] Rebase
This rebasing includes common libraries and common overlays projects
abstraction of components
Change-Id: Ia1efa4deacdc5701e6205104ac021a6c80ed60ba
Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/util/upgrade/SystemUpgrade.java')
-rw-r--r-- | ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/util/upgrade/SystemUpgrade.java | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/util/upgrade/SystemUpgrade.java b/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/util/upgrade/SystemUpgrade.java deleted file mode 100644 index 3c1f0dd4..00000000 --- a/ecomp-sdk/sdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/util/upgrade/SystemUpgrade.java +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * ================================================================================ - * eCOMP Portal SDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ================================================================================ - */ -package org.openecomp.portalsdk.analytics.util.upgrade; - -import java.sql.Connection; -import java.util.Iterator; -import java.util.StringTokenizer; - -import javax.servlet.http.HttpServletRequest; - -import org.openecomp.portalsdk.analytics.model.ReportLoader; -import org.openecomp.portalsdk.analytics.model.base.ReportWrapper; -import org.openecomp.portalsdk.analytics.model.definition.ReportDefinition; -import org.openecomp.portalsdk.analytics.system.AppUtils; -import org.openecomp.portalsdk.analytics.system.DbUtils; -import org.openecomp.portalsdk.analytics.util.DataSet; -import org.openecomp.portalsdk.analytics.xmlobj.DataColumnType; - -public class SystemUpgrade extends org.openecomp.portalsdk.analytics.RaptorObject { - private static final String upgradeFromVersion = "1.x"; - private static final String upgradeToVersion = "2.0"; - -/* This script upgrades the Raptor database to a newer version - Make sure you execute the "upgrade_v0_to_v1_0_before_java.sql" before running this - and "upgrade_v0_to_v1_0_after_java.sql" afterwards - - URL example: http://localhost:8082/databank/dispatcher?action=raptor&r_action=system_upgrade -*/ - public static String upgradeDB(HttpServletRequest request) { - request.setAttribute("system_message", "System upgrade disabled"); - return "raptor/blank.jsp"; - -/* try { - if(upgradeFromVersion.equals("1.x")&&upgradeToVersion.equals("2.0")) - upgrateFromV1ToV2_0(request); - else - throw new RuntimeException("Invalid version"); - - return "raptor/blank.jsp"; - } catch(Exception e) { - return (new ErrorHandler()).processFatalError(request, e); - }*/ - } // upgradeDB - - private static void upgrateFromV1ToV2_0(HttpServletRequest request) throws Exception { - StringBuffer log = new StringBuffer(); - log.append("Starting upgrade...<br>\n"); - - DataSet ds = DbUtils.executeQuery("SELECT cr.rep_id, cr.sched_mailto_user_ids FROM cr_report cr"); - for(int i=0; i<ds.getRowCount(); i++) { - String repId = ds.getString(i, 0); - log.append("<li>Processing report ["+repId+"]: "); - - Connection connection = DbUtils.startTransaction(); - String emailIds = nvls(ds.getString(i, 1)); - if(emailIds.length()>0) - try { - log.append("Converting emails "); - StringTokenizer st = new StringTokenizer(emailIds, ","); - while(st.hasMoreTokens()) { - String userId = nvls(st.nextToken()); - log.append(userId); - if(userId.length()>0) - DbUtils.executeUpdate(connection, "INSERT INTO cr_report_schedule_users (rep_id, user_id) VALUES ("+repId+", "+userId+")"); - log.append("-success, "); - } // while - log.append(" <font color=green>COMPLETED</font>; "); - } catch(Exception e) { - log.append("-<font color=red>FAILED</font>; "); - } - - String reportXML = ReportLoader.loadCustomReportXML(repId); - ReportDefinition rdef = ReportDefinition.unmarshal(reportXML, repId, request); - ReportWrapper rw = new ReportWrapper(rdef.cloneCustomReport(), repId, null, null, null, null, null, null, false); - - for(Iterator iter=rw.getAllColumns().iterator(); iter.hasNext(); ) { - DataColumnType col = (DataColumnType) iter.next(); - String drillDownURL = nvls(col.getDrillDownURL()); - if(drillDownURL.startsWith("dispatcher?action=custrep.run&c_master=")) { - drillDownURL = AppUtils.getReportExecuteActionURL()+drillDownURL.substring("dispatcher?action=custrep.run&c_master=".length()); - log.append("Drill-down processed; "); - col.setDrillDownURL(drillDownURL); - } - } // for - - reportXML = rw.marshal(); - - /*PrintWriter xmlOut = new PrintWriter(new BufferedWriter(new FileWriter(new File(AppUtils.getTempFolderPath()+AppUtils.getUserID(request))))); - xmlOut.println(reportXML); - xmlOut.close();*/ - - try { - ReportLoader.updateCustomReportRec(connection, rw, reportXML); - DbUtils.commitTransaction(connection); - log.append("<font color=green>REPORT UPDATED</font></li>\n"); - } catch(Exception e) { - log.append("<font color=red>REPORT UPDATE FAILED</font></li>\n"); - DbUtils.rollbackTransaction(connection); - } finally { - DbUtils.clearConnection(connection); - } - } // for - - log.append("<br>\nSystem upgrade successfully completed...<br>\n"); - request.setAttribute("system_message", log.toString()); - } // upgrateFromV1ToV2_0 - -} // SystemUpgrade |