Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/Deploy.java =================================================================== diff -u -r1e0112c787e72a7240ef2aea57fabd73babda639 -rff3f79a41e224643f7126174cba605cf031c81fe --- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/Deploy.java (.../Deploy.java) (revision 1e0112c787e72a7240ef2aea57fabd73babda639) +++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/Deploy.java (.../Deploy.java) (revision ff3f79a41e224643f7126174cba605cf031c81fe) @@ -41,7 +41,7 @@ * Only use forceDB for development - not designed for production. If forceDB is set, * then toolSignature and toolTablesDeleteScriptPath are needed. * - * @author Chris Perfect, modifications by Fiona Malikoff + * @author Chris Perfect, modifications by Fiona Malikoff, Luke Foxton */ public class Deploy { @@ -64,7 +64,12 @@ "\nforceDB deletes the old database entries before creating the new entries." + "\nSo it should be set to false for production and true for development"); } + Boolean forceDB = Boolean.FALSE; + if ( args.length == 2 && args[1] != null) { + forceDB = new Boolean(args[1]); + } + System.out.println("Starting Tool Deploy"); try { @@ -88,15 +93,42 @@ dbUpdater.setToolSignature(config.getToolSignature()); dbUpdater.setToolVersion(config.getToolVersion()); dbUpdater.checkInstalledVersion(); - if (dbUpdater.getToolExists()) + if (dbUpdater.getToolExists() && forceDB==false) { if (dbUpdater.getToolNewer()) { System.out.println("Updating tool: " +toolSignature+ " with version " +toolVersionStr); - // TODO copy the .jar and .war from build/deploy - // TODO update scripts + + // Disabling the tool while update takes place + dbUpdater.activateTool(toolSignature, 0); + + // updates the lams_tool table with the lams_version dbUpdater.execute(); - System.exit(0); + + // TODO update scripts + + // deploy the jar and war files + System.out.println("Deploying files to ear"); + DeployFilesTask deployFilesTask = new DeployFilesTask(); + deployFilesTask.setLamsEarPath(config.getLamsEarPath()); + deployFilesTask.setDeployFiles(config.getDeployFiles()); + deployFilesTask.execute(); + + // deploy the language files + List files = config.getLanguageFiles(); + if ( files != null && files.size() > 0 ) { + DeployLanguageFilesTask deployLanguageFilesTask = new DeployLanguageFilesTask(); + deployLanguageFilesTask.setLamsEarPath(config.getLamsEarPath()); + deployLanguageFilesTask.setDictionaryPacket(config.getLanguageFilesPackage()); + deployLanguageFilesTask.setDeployFiles(config.getLanguageFiles()); + deployLanguageFilesTask.execute(); + } + + // Enabling the tool so it can now be used by LAMS + dbUpdater.activateTool(toolSignature, 1); + + System.out.println("Tool update completed"); + System.exit(0); } else { @@ -112,12 +144,6 @@ } - - Boolean forceDB = Boolean.FALSE; - if ( args.length == 2 && args[1] != null) { - forceDB = new Boolean(args[1]); - } - if ( forceDB.booleanValue() ) { System.out.println("Removing old tool entries from database"); ToolDBRemoveToolEntriesTask dbRemoveTask = new ToolDBRemoveToolEntriesTask(); Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/ToolDBUpdater.java =================================================================== diff -u -r1e0112c787e72a7240ef2aea57fabd73babda639 -rff3f79a41e224643f7126174cba605cf031c81fe --- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/ToolDBUpdater.java (.../ToolDBUpdater.java) (revision 1e0112c787e72a7240ef2aea57fabd73babda639) +++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/ToolDBUpdater.java (.../ToolDBUpdater.java) (revision ff3f79a41e224643f7126174cba605cf031c81fe) @@ -64,11 +64,27 @@ } /** - * Updates the lams_tool table and the learning library + * Updates the lams_tool table + * TODO: possibly add a update_date collumn for system admin use */ public void execute() { - + Connection conn = getConnection(); + PreparedStatement stmt = null; + try + { + System.out.println("TEST: UPDATE lams_tool SET tool_version = \"" +toolVersion+ "\" WHERE tool_signature = \"" +toolSignature+ "\""); + stmt = conn.prepareStatement("UPDATE lams_tool SET tool_version = \"" +toolVersion+ "\" WHERE tool_signature = \"" +toolSignature+ "\""); + stmt.execute(); + } + catch (SQLException sqlex) + { + throw new DeployException("Could not set tool version", sqlex); + } + finally + { + DbUtils.closeQuietly(stmt); + } } /** @@ -121,6 +137,31 @@ } } + /** + * Activates/de-activates tool in db based on the flag + * @param toolSig The signature of the tool to activate/de-activate + * @param flag Set to 1 for activate, 0 for de-activate + * @throws SQLException + */ + public void activateTool(String toolSig, int flag) throws SQLException + { + Connection conn = getConnection(); + PreparedStatement stmt = null; + try + { + stmt = conn.prepareStatement("UPDATE lams_tool SET valid_flag = "+flag+" WHERE tool_signature = \"" +toolSig+ "\""); + stmt.execute(); + } + catch (SQLException se) + { + throw new DeployException("Could not activate/de-activate tool for update"); + } + finally + { + DbUtils.closeQuietly(stmt); + } + } +