%-- #RevizeProperties USE REVIZE MENU (DOCUMENT PROPERTIES) TO EDIT DATA BELOW:
status=new
options=
server=localhost:8080
projectName=calendar_app
label=
location=calendar_app/db/calendar_db_migrate.jsp
version=
docType=editpage
subType=list
moduleName=
fieldName=
channels=|
description=
--%><%-- #BeginRZ-PageHeader --%><%@
page language="java" %><%@
include file="/util/setup_editlist_header.jsp"
%><%-- #EndRZ-PageHeader --%><%--
___________________________________________________________________________________________________
Updates file extension used by calendar_db... templates to ".xml"
New templates publish into db folder (jsdb folder is depreciated).
SQL queries designed so they can be rerun; filenames will not change if previously changed.
After filenames in calendar_names and calendar_mapping modules are updated, all calendar pages
are then published via: /revize/debug/PublishCalendarTemplates.jsp
___________________________________________________________________________________________________
--%><%@ page import= "java.sql.*, revize.db.*, revize.db.sql.*, revize.db.jdbc.*,revize.log.LogManager" %><%
String status = "";
String stacktrace = "";
boolean isNew = request.getParameter("new") != null;
if (!isNew && request.getParameter("update") != null)
{
status = "updating";
Connection conn = null;
Statement stmt = null;
String sql = "";
Module module = null;
conn = ConnectionPool.getInstance().getConnection( rz.webspace );
boolean isPointbase = ConnectionFactory.getInstance().isPointBase();
try
{
stmt = conn.createStatement();
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* All the following queries designed so they can be rerun without harm *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//----- update calendar_names activemonths_filename & activeweeks_filename
module = rz.getModuleFromModuleList("calendar_names");
// ----------------------------------------------------------------
// activemonths_filename: _active... --> _activemonth_list.xml
// ----------------------------------------------------------------
sql = "update " + rz.webspace + ".rModule_ID"+ module.getID() + "_recs"
+ " set ractivemonths_filename=";
if (isPointbase)
sql += " substring(ractivemonths_filename from 1"
+ " for position('_active' in ractivemonths_filename))"
+ " || 'activemonth_list.xml'";
else
sql += " replace(ractivemonths_filename,'activemonths.html','activemonth_list.xml')";
out.println("
" + sql);
stmt.executeUpdate( sql );
// ----------------------------------------------------------------
// activeweeks_filename: _active... --> activeweek_list.xml
// ----------------------------------------------------------------
sql = "update " + rz.webspace + ".rModule_ID"+ module.getID() + "_recs"
+ " set ractiveweeks_filename";
if (isPointbase)
sql += "=substring(ractiveweeks_filename from 1"
+ " for position('_active' in ractiveweeks_filename))"
+ " || 'activeweek_list.xml'";
else
sql += "=replace(ractiveweeks_filename,'activeweeks.html','activeweek_list.xml')";
out.println("
" + sql);
stmt.executeUpdate( sql );
//----- update calendar_mapping activemonthsdata_filename & activeweeksdata_filename
module = rz.getModuleFromModuleList("calendar_mapping");
// ----------------------------------------------------------------
// activemonthsdata_filename (only update extension): .html --> .xml
// ----------------------------------------------------------------
sql = "update " + rz.webspace + ".rModule_ID"+ module.getID() + "_recs"
+ " set ractivemonthsdata_filename";
if (isPointbase)
sql += "=substring(ractivemonthsdata_filename from 1"
+ " for position('.' in ractivemonthsdata_filename))"
+ " || 'xml'";
else
sql += "=replace(ractivemonthsdata_filename,'html','xml')";
stmt.executeUpdate( sql );
out.println("
" + sql);
// ----------------------------------------------------------------
// activeweeksdata_filename (only update extension): .html --> .xml
// ----------------------------------------------------------------
sql = "update " + rz.webspace + ".rModule_ID"+ module.getID() + "_recs"
+ " set ractiveweeksdata_filename";
if (isPointbase)
sql += "=substring(ractiveweeksdata_filename from 1"
+ " for position('.' in ractiveweeksdata_filename))"
+ " || 'xml'";
else
sql += "=replace(ractiveweeksdata_filename,'html','xml')";
stmt.executeUpdate( sql );
out.println("
" + sql);
status = "db updated";
//throw new SQLException("Simulated exception for testing");
conn.commit();
status = "update done";
}
catch (SQLException se)
{
status = "exception";
stacktrace += StringUtils.convertStackTraceToString(se);
try
{
conn.rollback();
}
catch (SQLException se1)
{
status += " rollback failed";
String msg = "Could NOT rollback database changes";
stacktrace += StringUtils.convertStackTraceToString(msg,se1);
}
}
finally
{
try {
if (stmt != null)
stmt.close();
} catch (SQLException sqlExp) {
LogManager.getDatabaseLog().error("Could not close a statement: ", sqlExp);
}
ConnectionPool.getInstance().replaceConnection(conn);
}
}
//----- Determine migration state ------
boolean xml = false;
boolean json = false;
boolean some = false;
%>