Index: lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/libraryActivity/DeployLibrary.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/libraryActivity/DeployLibrary.java,v diff -u -r1.7 -r1.8 --- lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/libraryActivity/DeployLibrary.java 10 Jun 2008 06:48:52 -0000 1.7 +++ lams_tool_deploy/src/java/org/lamsfoundation/lams/tool/deploy/libraryActivity/DeployLibrary.java 28 Oct 2009 04:04:59 -0000 1.8 @@ -33,112 +33,101 @@ /** * @author mtruong - * - * Deployer for library activities that contain more than one tool activity. - * Currently, is only supported for the complex activity types: parallel, - * options, sequence * - * The main logic is adopted from Deploy.java - * See org.lamsfoundation.lams.tool.deploy.Deploy + * Deployer for library activities that contain more than one tool + * activity. Currently, is only supported for the complex activity + * types: parallel, options, sequence + * + * The main logic is adopted from Deploy.java See + * org.lamsfoundation.lams.tool.deploy.Deploy */ public class DeployLibrary { public DeployLibrary() { - + } - - - public static void main (String[] args) - { - if ((args.length < 1) || (args[0] == null)) - { - throw new IllegalArgumentException("Usage: Deployer ." ); - } - - System.out.println("Starting Library Deploy"); - - try - { - DeployLibraryConfig config= new DeployLibraryConfig(args[0],null); - LibraryDBDeployTask dbDeployTask = new LibraryDBDeployTask(config); - dbDeployTask.execute(); - System.out.println("Inserted activities into database"); - List libraries = dbDeployTask.getLearningLibraries(); - Iterator iter = libraries.iterator(); - while ( iter.hasNext() ) { + public static void main(String[] args) { + if ((args.length < 1) || (args[0] == null)) { + throw new IllegalArgumentException("Usage: Deployer ."); + } - LearningLibrary lib = (LearningLibrary) iter.next(); - String languageFileDirectory = lib.getLanguageFileDirectory(); - if ( languageFileDirectory != null ) { + System.out.println("Starting Library Deploy"); - // generate package names in which the language files are placed. - String packagePath = "org.lamsfoundation.lams.library.llid"+lib.getLearningLibraryId(); - - // copy the files to the lams-dictionary.jar - DeployLanguageFilesTask deployLanguageFilesTask = new DeployLanguageFilesTask(); - deployLanguageFilesTask.setLamsEarPath(config.getLamsEarPath()); - deployLanguageFilesTask.setDictionaryPacket(packagePath); - deployLanguageFilesTask.setDeployFiles(createLanguageFilesList(languageFileDirectory)); - deployLanguageFilesTask.execute(); + try { + DeployLibraryConfig config = new DeployLibraryConfig(args[0], null); + LibraryDBDeployTask dbDeployTask = new LibraryDBDeployTask(config); + dbDeployTask.execute(); + System.out.println("Inserted activities into database"); - System.out.println("Updating activity with the language file path"); - ActivityDBLanguageUpdateTask activityDBTask = new ActivityDBLanguageUpdateTask(); - activityDBTask.setDbUsername(config.getDbUsername()); - activityDBTask.setDbPassword(config.getDbPassword()); - activityDBTask.setDbDriverClass(config.getDbDriverClass()); - activityDBTask.setDbDriverUrl(config.getDbDriverUrl()); - activityDBTask.setActivityId(lib.getParentActivityId()); - activityDBTask.setLanguageFilename(packagePath+'.'+lib.getLanguageFileRoot()); - activityDBTask.execute(); - } + List libraries = dbDeployTask.getLearningLibraries(); + Iterator iter = libraries.iterator(); + while (iter.hasNext()) { - - System.out.println("Activating learning library "+lib.getLearningLibraryId()); - LibraryDBActivateTask libActivateTask = new LibraryDBActivateTask(); - libActivateTask.setDbUsername(config.getDbUsername()); - libActivateTask.setDbPassword(config.getDbPassword()); - libActivateTask.setDbDriverClass(config.getDbDriverClass()); - libActivateTask.setDbDriverUrl(config.getDbDriverUrl()); - libActivateTask.setLearningLibraryId(lib.getLearningLibraryId()); - libActivateTask.execute(); - - } - - - System.out.println("Library Deployed"); - - } - catch (Exception ex) - { - System.out.println("TOOL DEPLOY FAILED"); - ex.printStackTrace(); - } - - - + LearningLibrary lib = (LearningLibrary) iter.next(); + String languageFileDirectory = lib.getLanguageFileDirectory(); + if (languageFileDirectory != null) { + + // generate package names in which the language files are placed. + String packagePath = "org.lamsfoundation.lams.library.llid" + lib.getLearningLibraryId(); + + // copy the files to the lams-dictionary.jar + DeployLanguageFilesTask deployLanguageFilesTask = new DeployLanguageFilesTask(); + deployLanguageFilesTask.setLamsEarPath(config.getLamsEarPath()); + deployLanguageFilesTask.setDictionaryPacket(packagePath); + deployLanguageFilesTask.setDeployFiles(createLanguageFilesList(languageFileDirectory)); + deployLanguageFilesTask.execute(); + + System.out.println("Updating activity with the language file path"); + ActivityDBLanguageUpdateTask activityDBTask = new ActivityDBLanguageUpdateTask(); + activityDBTask.setDbUsername(config.getDbUsername()); + activityDBTask.setDbPassword(config.getDbPassword()); + activityDBTask.setDbDriverClass(config.getDbDriverClass()); + activityDBTask.setDbDriverUrl(config.getDbDriverUrl()); + activityDBTask.setActivityId(lib.getParentActivityId()); + activityDBTask.setLanguageFilename(packagePath + '.' + lib.getLanguageFileRoot()); + activityDBTask.execute(); + } + + System.out.println("Activating learning library " + lib.getLearningLibraryId()); + LibraryDBActivateTask libActivateTask = new LibraryDBActivateTask(); + libActivateTask.setDbUsername(config.getDbUsername()); + libActivateTask.setDbPassword(config.getDbPassword()); + libActivateTask.setDbDriverClass(config.getDbDriverClass()); + libActivateTask.setDbDriverUrl(config.getDbDriverUrl()); + libActivateTask.setLearningLibraryId(lib.getLearningLibraryId()); + libActivateTask.execute(); + + } + + System.out.println("Library Deployed"); + + } catch (Exception ex) { + System.out.println("TOOL DEPLOY FAILED"); + ex.printStackTrace(); + } + } - + /** * Sets the list of file paths to operate on. - * @param deployFiles New value of property deployFiles. + * + * @param deployFiles + * New value of property deployFiles. */ - private static List createLanguageFilesList(String path) - { - List deployFiles = new ArrayList(); - if ( path != null ) { - File dir = new File(path); - if ( ! dir.exists() || ! dir.isDirectory() || ! dir.canRead() ) { - System.err.println("Unable to copy language files - path is invalid: "+path); - } else { - for ( String filename: dir.list() ) { - deployFiles.add(path+File.separator+filename); - } - } - } - return deployFiles; + private static List createLanguageFilesList(String path) { + List deployFiles = new ArrayList(); + if (path != null) { + File dir = new File(path); + if (!dir.exists() || !dir.isDirectory() || !dir.canRead()) { + System.err.println("Unable to copy language files - path is invalid: " + path); + } else { + for (String filename : dir.list()) { + deployFiles.add(path + File.separator + filename); + } + } + } + return deployFiles; } - - }