}
private void unThreadedUpdate(final File zip) {
LOGGER.info(" - Updating from ZIP");
WOJServer server = WOJServer.getInstance();
ModuleDescriptorDao mDao = server.getDataService().getModuleDescriptorDao();
try {
// Unzip file
LOGGER.debug(" -- Extracting zip : " + zip.getName());
ZipHelper.extract(zip, "", getFileContentService().getBaseDir());
LOGGER.debug(" -- Extraction done");
// Get dmp file
File dir = new File(getFileContentService().getBaseDir());
File[] dumps = dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".dmp");
}
});
if (dumps.length != 0) {
File dumpFile = dumps[0];
LOGGER.debug(" -- Parsing dump file : " + dumpFile.getName());
String dump = IOHelper.readEntirely(dumpFile);
String[] sqlLines = dump.split(";\n");
for (int i = 0; i < sqlLines.length; i++) {
String sqlLine = sqlLines[i];
// Replacing query params bu server id if necessary
sqlLine = SQLUtil.setValues(sqlLine, new Object[] {new Long(server.getId())});
try {
mDao.getJdbcTemplate().execute(sqlLine);
} catch (DataIntegrityViolationException e) {
LOGGER.warn(" -- Update file contains modules already updated, skipping it.", e);
}