Index: lams_build/deploy-tool/lib/lams-tool-deploy.jar =================================================================== diff -u -r2926fd6ffb90b894cbb3da1e31d63a63a0d4eb5f -rc14c4cc678d3428c6086255c6f3fc108c229da5a Binary files differ Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/ToolDBUpdater.java =================================================================== diff -u -rb452ed99ebb69dffe8b05f0c5e5126e7bc073ecb -rc14c4cc678d3428c6086255c6f3fc108c229da5a --- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/ToolDBUpdater.java (.../ToolDBUpdater.java) (revision b452ed99ebb69dffe8b05f0c5e5126e7bc073ecb) +++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/ToolDBUpdater.java (.../ToolDBUpdater.java) (revision c14c4cc678d3428c6086255c6f3fc108c229da5a) @@ -198,6 +198,36 @@ } } + public String queryTool(String toolSig, String column) + { + Connection conn = getConnection(); + PreparedStatement stmt = null; + ResultSet results = null; + try + { + stmt = conn.prepareStatement("select " +column+ " from lams_tool where tool_signature= \""+toolSig+"\""); + System.out.println("SQL stmt: " + stmt ); + results = stmt.executeQuery(); + + if (results.first()) + { + return results.getString(column); + + } + } + catch (SQLException se) + { + + throw new DeployException("Could not get entry from lams_tool: " + column + "\n" + se.getMessage()); + + } + finally + { + DbUtils.closeQuietly(stmt); + } + return "ERROR"; + } + /** * set method for toolSignature * @param sig The toolSignature to be set Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/UpdateToolContextPath.java =================================================================== diff -u --- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/UpdateToolContextPath.java (revision 0) +++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/UpdateToolContextPath.java (revision c14c4cc678d3428c6086255c6f3fc108c229da5a) @@ -0,0 +1,105 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/** + * Helper program for updater.nsi + * + * Uses the InsertToolContextClasspath to change the context paths in the + * manifest and web.xmls for lams-learning.war, lams-central.war and + * lams-monitoring.war + * + * Instead of reading the context paths from the deploy.xml of each tool, this + * program reads from the db, so as not to overwrite existing entries for an + * update + * + * @author Luke Foxton + */ + +package org.lamsfoundation.lams.tool.deploy; + +import java.util.LinkedList; +import java.util.List; +public class UpdateToolContextPath { + public static void main(String[] args) throws Exception + { + if ((args.length < 1) || (args[0] == null)) + { + throw new IllegalArgumentException("Usage: UpdateToolContextPath "); + } + + try + { + DeployToolConfig config = new DeployToolConfig(args[0]); + + // the tool signature of this tool + String toolSig = config.getToolSignature(); + + + ToolDBUpdater dbUpdater = new ToolDBUpdater(); + dbUpdater.setDbUsername(config.getDbUsername()); + dbUpdater.setDbPassword(config.getDbPassword()); + dbUpdater.setDbDriverClass(config.getDbDriverClass()); + dbUpdater.setDbDriverUrl(config.getDbDriverUrl()); + dbUpdater.setToolSignature(toolSig); + + // the path to the existing ear + String lamsEar = config.getLamsEarPath(); + + // tool application context path + String appContextPath = dbUpdater.queryTool(toolSig, "context_file"); + + // tool jar file name + String jarFileName = dbUpdater.queryTool(toolSig, "classpath_addition"); + + + if ((appContextPath.equals("ERROR"))||(jarFileName.equals("ERROR"))) + { + throw new Exception("Could not read context details from lams_tool"); + } + + System.out.println("appContextpath: " + appContextPath); + System.out.println("jarFileName: " + jarFileName); + + + // the war files that need to be updated + List warFiles = new LinkedList(); + warFiles.add("lams-central.war"); + warFiles.add("lams-learning.war"); + warFiles.add("lams-monitoring.war"); + + // updater the conf files in the respective wars + InsertToolContextClasspathTask updateWebXmlTask = new InsertToolContextClasspathTask(); + updateWebXmlTask.setLamsEarPath(lamsEar); + updateWebXmlTask.setArchivesToUpdate(warFiles); + updateWebXmlTask.setApplicationContextPath(appContextPath); + updateWebXmlTask.setJarFileName(jarFileName); + updateWebXmlTask.execute(); + + } + catch (Exception e) + { + System.out.println("Unable to read deploy.xml: " + e.getMessage()); + } + + } +}