rem: app.invokeAsync(null, function() { var log = new java.io.FileWriter("apps/antville/conversion.log"); var rows, max, amount, data, counter, ref; var id = 0; main: for each (table in ["TEXT"]) {  db.executeCommand(getSql("create")); rows = db.executeRetrieval(getSql("max")); rows.next(); max = rows.getColumnItem("max"); amount = rows.getColumnItem("amount"); rows.release(); counter = 0; while (id < max) { rows = db.executeRetrieval(getSql("list", id)); while (rows && rows.next()) { id = rows.getColumnItem(table + "_ID"); if (rows.getColumnItem("new")) { continue; } else { app.debug(id + " has no new data, yet!"); continue; } try { data = rows.getColumnItem("old"); data = data.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f]/g, ""); data = Xml.readFromString(data); db.executeCommand(getSql("update", id, data.toSource().replace(/\\/g, "\\\\").replace(/'/g, "\\'"))); } catch (x) { ref = Story.getById(id) || Comment.getById(id); log.write(ref.href() + "\n"); log.write(x + "\n"); log.write("***\n"); log.flush();    } } rows && rows.release(); counter += chunkSize; app.logger.info("Converted " + table + " " + counter + " of " + amount + " records"); app.logger.info("Current ID: " + id + " of " + max); 
add: forEachRow(function(rows) { var id = rows.getColumnItem("id"); var metadata = eval(rows.getColumnItem("metadata")); metadata.email = rows.getColumnItem("site_email"); metadata.title = rows.getColumnItem("title"); /* metadata.lastUpdate = rows.getColumnItem("site_lastupdate"); metadata.pageSize = metadata.days || 3; metadata.pageMode = "days"; metadata.timeZone = metadata.timezone || "CET"; metadata.archiveMode = metadata.archive ? "online" : "offline"; metadata.commentsMode = metadata.discussions ? "online" : "offline"; metadata.shortDateFormat = metadata.shortdateformat; metadata.longDateFormat = metadata.longdateformat; metadata.offlineSince = rows.getColumnItem("site_lastoffline"); metadata.notifiedOfBlocking = rows.getColumnItem("site_lastblockwarn"); metadata.notifiedOfDeletion = rows.getColumnItem("site_lastdelwarn"); metadata.webHookEnabled = rows.getColumnItem("site_enableping"); metadata.webHookLastUpdate = rows.getColumnItem("site_lastping"); if (metadata.country) { metadata.locale += "_" + metadata.country; } */ var mode = metadata.usercontrib ? 'open' : rows.getColumnItem("mode"); for each (var key in ["enableping", "usercontrib", "archive", "discussions", "days", "shortdateformat", "longdateformat", "linkcolor", "alinkcolor", "vlinkcolor", "smallcolor", "titlecolor", "titlefont", "textfont", "textcolor", "smallsize", "smallfont", "textsize", "titlesize", "timezone", "bgcolor", "country"]) { delete metadata[key]; 
context:    app.invokeAsync(null, function() {      var log = new java.io.FileWriter("apps/antville/conversion.log");      var rows, max, amount, data, counter, ref;      var id = 0;      main:      for each (table in ["TEXT"]) {      //for each (table in ["TEXT", "SITE", "LAYOUT"]) {         db.executeCommand(getSql("create"));         rows = db.executeRetrieval(getSql("max"));         rows.next();         max = rows.getColumnItem("max");         amount = rows.getColumnItem("amount");         rows.release();         counter = 0;         while (id < max) {            rows = db.executeRetrieval(getSql("list", id));            while (rows && rows.next()) {               id = rows.getColumnItem(table + "_ID");               if (rows.getColumnItem("new")) {                  continue;               } else {                  app.debug(id + " has no new data, yet!");                  continue;               }               try {                  data = rows.getColumnItem("old");                  data = data.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f]/g, "");                  data = Xml.readFromString(data);                  db.executeCommand(getSql("update", id,                        data.toSource().replace(/\\/g,                         "\\\\").replace(/'/g, "\\'")));               } catch (x) {                  ref = Story.getById(id) || Comment.getById(id);                  log.write(ref.href() + "\n");                  log.write(x + "\n");                  log.write("***\n");                  log.flush();                  //app.logger.error("!!! Error in XML data of TEXT_ID " + id);                  //app.logger.error(x);                  //break main;               }            }            rows && rows.release();            counter += chunkSize;            app.logger.info("Converted " + table + " " + counter + " of " +                   amount + " records");            app.logger.info("Current ID: " + id + " of " + max);         }         //db.executeCommand(getSql("rename"));         //db.executeCommand(getSql("drop"));      }      log.write("### Finished conversion with ID " + id);      log.close();   }, [], -1); 
meta: 993	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/993/d46237ae5555045222f493137c5c51dbcd7b4033/conversion.js/clean/compatibility/Global/conversion.js