* the PrintWriter
* @throws Exception
*/
public void migrateData(RequestContext context, PrintWriter out)
throws Exception {
DatabaseReference fromDbRef = null;
Connection fromConn = null;
try {
ServletRequest request = context.getServletRequest();
fromDbRef = new DatabaseReference();
fromDbRef.setReferenceName("gpt");
fromDbRef.setDirectDriverClassName(chkStr(request
.getParameter("jdbcDriver")));
fromDbRef.setDirectUrl(chkStr(request.getParameter("jdbcUrl")));
fromDbRef.setDirectUsername(chkStr(request.getParameter("dbUserName")));
fromDbRef.setDirectPassword(chkStr(request.getParameter("dbPassword")));
fromDbRef.setIsJndiBased(false);
HashMap<String, Object> parameters = new HashMap<String, Object>();
String dbSchema = chkStr(request.getParameter("dbSchemaName"));
String tablePrefix = chkStr(request.getParameter("tablePrefix"));
if(dbSchema.length() > 0){
tablePrefix = dbSchema + "." + tablePrefix;
}
parameters.put("fromTablePrefix",tablePrefix);
parameters.put("version",
chkStr(request.getParameter("geoportalVersion")));
parameters.put("metadataServer", chkStr(request
.getParameter("useMetadataServer")));
parameters.put("toTablePrefix", context.getCatalogConfiguration()
.getTablePrefix());
parameters.put("metaDataTableName", chkStr(request
.getParameter("metaDataTableName")));
parameters.put("geoportalUserName", chkStr(request
.getParameter("geoportalUserName")));
parameters.put("geoportalPassword", chkStr(request
.getParameter("geoportalPassword")));
parameters.put("serviceUrl", chkStr(request.getParameter("serviceUrl")));
parameters.put("context", context);
ManagedConnection mc = returnConnection(context);
Connection toConn = mc.getJdbcConnection();
boolean autoCommit = toConn.getAutoCommit();
toConn.setAutoCommit(false);
fromConn = fromDbRef.openConnection();
/*
* IClobMutator toCM = mc.getClobMutator(); parameters.put("toCM", toCM);
*/
String dbType = findDbType(fromConn);
boolean fromClob = isClobData(fromConn);
parameters.put("toConn", toConn);
parameters.put("fromConn", fromConn);
parameters.put("fromClob", fromClob);
parameters.put("dbType", dbType);
out
.write("<img style=\"z-index:1; background: #450200 url(../skins/themes/red/images/banner.jpg) no-repeat scroll 0pt 0px;height: 65px;position: relative;width:100%;\"/>");
out
.write("<div style=\"z-index:2; position: absolute;top: 10px;left: 10px;font-size: 2em;font-family: 'Trebuchet MS',Helvetica,Arial,Geneva,sans-serif;color: #FFF;text-decoration: none !important;\">Geoportal 10 - Data Migration</div>");
out.write("<br>========== Migration Status =========");
out.write("<br>Data Migration Started at ="
+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar
.getInstance().getTime()));
out.write("<br>Migrating user table data...");
migrateUsersData(parameters, out);
out.write("<br>" + userCount + " records migrated from user table");
out.write("<br>Migrating Harvesting_History table data...");
int harvestingHistoryCount = migrateHarvestHistoryData(parameters, out);
out.write("<br>" + harvestingHistoryCount
+ " records migrated from harvesting_history table");
out.write("<br>Migrating Search table data...");
int searchCount = migrateSearchData(parameters, out);
out.write("<br>" + searchCount + " records migrated from search table");
out.write("<br>Migrating Harvesting table data...");
int harvestingCount = migrateHarvestData(parameters, out);
out.write("<br>" + harvestingCount
+ " records migrated from harvesting table");
out.write("<br>Migrating admin and Metadata table data...");
int adminCount = migrateMetadata(parameters, out);
out.write("<br>" + adminCount
+ " records migrated from admin and metadata table");
out.write("<br>========== Migration Summary =========");
out.write("<br>Total metadata record migrated ="
+ (adminCount + harvestingCount));
out.write("<br>Total search table record migrated =" + searchCount);
out.write("<br>Total user table record migrated =" + userCount);
out.write("<br>Data Migration Completed at ="
+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar
.getInstance().getTime()));
if (toConn != null) {
toConn.setAutoCommit(autoCommit);
}
} finally {
fromDbRef.closeConnection(fromConn);
}
}