private void installModules(java.io.File dir, String warFileLocation, boolean preview, boolean forceInstall, boolean backupWAR) { java.io.File[] children = dir.listFiles(); if (children != null) { for (java.io.File child : children) { if (child.isFile() == true && child.getName().toLowerCase().endsWith(".amp") == true) { installModule(child.getPath(), warFileLocation, preview, forceInstall, backupWAR); } else { installModules(child, warFileLocation, preview, forceInstall, backupWAR); } } } }
outputVerboseMessage("WARNING: A later version of this module is already installed in the WAR. Installation skipped. "+ "You could force the installation by passing the -force option.",false); return; outputVerboseMessage("WARNING: The installation of this module is being forced. All files will be removed and replaced regardless of existing versions present.",false); outputVerboseMessage("WARNING: This version of this module is already installed in the WAR..upgrading.",false); outputVerboseMessage("Clearing out files relating to version '" + installedVersion + "' of module '" + installedId + "'",false); uninstallModule(installedId, warFileLocation, preview, true);
public void installModules(String directoryLocation, String warFileLocation, boolean preview, boolean forceInstall, boolean backupWAR) throws IOException { java.io.File dir = new java.io.File(directoryLocation); if (dir.exists() == true) { if (backupWAR) { backupWar(new TFile(warFileLocation),true); backupWAR = false; //Set it to false so a backup doesn't occur again. } installModules(dir, warFileLocation, preview, forceInstall,backupWAR); } else { throw new ModuleManagementToolException("Invalid directory '" + directoryLocation + "'"); } }
outputUsage(); System.exit(ERROR_EXIT_CODE); ModuleManagementTool manager = new ModuleManagementTool(); outputUsage(); System.exit(SUCCESS_EXIT_CODE); manager.setVerbose(true); manager.setVerbose(true); manager.installModule(aepFileLocation, warFileLocation, previewInstall, forceInstall, backup); manager.installModules(aepFileLocation, warFileLocation, previewInstall, forceInstall, backup); manager.listModules(warFileLocation); System.exit(SUCCESS_EXIT_CODE); manager.setVerbose(true); manager.setVerbose(true); manager.uninstallModule(moduleId, warLocation,preview, purge); System.exit(SUCCESS_EXIT_CODE); manager.outputErrorMessage("Usage error: " + e.getMessage()); outputUsage(); System.exit(ERROR_EXIT_CODE);
ModuleManagementTool mmt = new ModuleManagementTool(); mmt.setVerbose(verbose); getLog().info("Installing all AMPs from directory " + ampLocation.getAbsolutePath() + " into WAR/exploded webapp at " + warLocation.getAbsolutePath()); mmt.installModules(ampLocation.getAbsolutePath(), warLocation.getAbsolutePath(), false, // preview mmt.installModule(ampLocation.getAbsolutePath(), warLocation.getAbsolutePath(), false, // preview
public void testPreviewInstall() throws Exception { manager.setVerbose(true); String warLocation = getFileLocation(".war", "module/test.war"); String ampLocation = getFileLocation(".amp", "module/test_v1.amp"); // Initial install of module this.manager.installModule(ampLocation, warLocation, true, false, true); // TODO need to prove that the war file has not been updated in any way }
public void testUninstall() throws Exception { manager.setVerbose(true); String warLocation = getFileLocation(".war", "module/test.war"); String ampLocation = getFileLocation(".amp", "module/test_v1.amp"); // Initial install of module this.manager.installModule(ampLocation, warLocation, false, false, false); this.manager.listModules(warLocation); this.manager.uninstallModule("test", warLocation, false, false); List<String> files = new ArrayList<String>(10); files.add("/WEB-INF/classes/alfresco/module/test/module.properties"); files.add("/WEB-INF/classes/alfresco/module/test/modifications.install"); files.add("/WEB-INF/lib/test.jar"); files.add("/WEB-INF/classes/alfresco/module/test/module-context.xml"); checkForFileNonExistance(warLocation, files); }
ModuleManagementTool mmt = new ModuleManagementTool(); mmt.setVerbose(false); mmt.installModule( getSourceFile().getAbsolutePath(), destLocation.getAbsolutePath(),
public void testInstallFromDir() throws Exception { manager.setVerbose(true); String warLocation = getFileLocation(".war", "module/test.war"); String ampLocation = getFileLocation(".amp", "module/test_v1.amp"); String ampV2Location = getFileLocation(".amp", "module/test_v2.amp"); int index = ampV2Location.lastIndexOf(File.separator); System.out.println(index); String directoryLocation = ampV2Location.substring(0, index); try { this.manager.installModules(directoryLocation, warLocation); } catch (ModuleManagementToolException exception) { exception.printStackTrace(); System.out.println("Expected failure: " + exception.getMessage()); } }
/** * Installs a given AMP file into a given WAR file. * * @see ModuleManagementTool#installModule(String, String, boolean, boolean, boolean) * * @param ampFileLocation the location of the AMP file to be installed * @param warFileLocation the location of the WAR file into which the AMP file is to be installed */ public void installModule(String ampFileLocation, String warFileLocation) { installModule(ampFileLocation, warFileLocation, false, false, true); }
backupLocation = BACKUP_DIR + "/" + generateGuid() + ".bin"; if (preview == false) this.outputVerboseMessage("File '" + destinationDir + "/" + sourceChild.getName() + "' added to war from amp", true); this.outputMessage("WARNING: The file '" + destinationDir + "/" + sourceChild.getName() + "' is being overwritten by this module. The original has been backed-up to '" + backupLocation + "'", true); calculateCopyToWar(ampFileLocation, warFileLocation, sourceDir + "/" + sourceChild.getName(), destinationDir + "/" + sourceChild.getName(), installedFiles, preview, forceInstall); if (mkdir == true) this.outputVerboseMessage("Directory '" + destinationDir + "/" + sourceChild.getName() + "' added to war", true);
try outputVerboseMessage("Installing AMP '" + ampFileLocation + "' into WAR '" + warFileLocation + "'"); if (!warFile.exists()) backupWar(warFile, backupWAR); uninstallIfNecessary(warFileLocation, installedModuleDetails, preview, forceInstall, installingVersion); outputVerboseMessage("Adding files relating to version '" + installingVersion + "' of module '" + installingId + "'"); InstalledFiles installedFiles = new InstalledFiles(warFileLocation, installingId); Properties directoryChanges = calculateChanges(ampFileLocation, warFileLocation, preview, forceInstall, installedFiles);
/** * Installs all modules within a folder into the given WAR file. * @throws IOException * * @see #installModule(String, String, boolean, boolean, boolean) */ public void installModules(String directory, String warFileLocation) throws IOException { installModules(directory, warFileLocation, false, false, true); }
public void testBasicInstall() throws Exception { manager.setVerbose(true); String warLocation = getFileLocation(".war", "module/test.war"); String ampLocation = getFileLocation(".amp", "module/test_v1.amp"); String ampV2Location = getFileLocation(".amp", "module/test_v2.amp"); installerSharedTests(warLocation, ampLocation, ampV2Location); }
Properties customFileMappingProperties = getCustomFileMappings(ampFileLocation); if (customFileMappingProperties == null) calculateCopyToWar(ampFileLocation, warFileLocation, mappingSource, mappingTarget, installedFiles, preview, forceInstall);
public void testList() throws Exception { String warLocation = getFileLocation(".war", "module/test.war"); this.manager.listModules(warLocation); }
outputUsage(); System.exit(ERROR_EXIT_CODE); ModuleManagementTool manager = new ModuleManagementTool(); outputUsage(); System.exit(SUCCESS_EXIT_CODE); manager.setVerbose(true); manager.setVerbose(true); manager.installModule(aepFileLocation, warFileLocation, previewInstall, forceInstall, backup); manager.installModules(aepFileLocation, warFileLocation, previewInstall, forceInstall, backup); manager.listModules(warFileLocation); System.exit(SUCCESS_EXIT_CODE); manager.setVerbose(true); manager.setVerbose(true); manager.uninstallModule(moduleId, warLocation,preview, purge); System.exit(SUCCESS_EXIT_CODE); manager.outputErrorMessage("Usage error: " + e.getMessage()); outputUsage(); System.exit(ERROR_EXIT_CODE);
public void testWhiteSpaceInCustomMapping() throws Exception { manager.setVerbose(true); String warLocation = getFileLocation(".war", "module/test.war"); String ampLocation = getFileLocation(".amp", "module/test_v3.amp"); // Initial install of module this.manager.installModule(ampLocation, warLocation, false, false, true); List<String> files = new ArrayList<String>(10); files.add("/WEB-INF/classes/alfresco/module/test/module.properties"); files.add("/WEB-INF/classes/alfresco/module/test/modifications.install"); files.add("/WEB-INF/lib/test.jar"); files.add("/WEB-INF/classes/alfresco/module/test/module-context.xml"); files.add("/images/test.jpg"); files.add("/css/test.css"); files.add("/extra.txt"); checkForFileExistance(warLocation, files); }
/** * Installs a given AMP file into a given WAR file. * * @see ModuleManagementTool#installModule(String, String, boolean, boolean, boolean) * * @param ampFileLocation the location of the AMP file to be installed * @param warFileLocation the location of the WAR file into which the AMP file is to be installed */ public void installModule(String ampFileLocation, String warFileLocation) { installModule(ampFileLocation, warFileLocation, false, false, true); }
backupLocation = BACKUP_DIR + "/" + generateGuid() + ".bin"; if (preview == false) this.outputVerboseMessage("File '" + destinationDir + "/" + sourceChild.getName() + "' added to war from amp", true); this.outputMessage("WARNING: The file '" + destinationDir + "/" + sourceChild.getName() + "' is being overwritten by this module. The original has been backed-up to '" + backupLocation + "'", true); calculateCopyToWar(ampFileLocation, warFileLocation, sourceDir + "/" + sourceChild.getName(), destinationDir + "/" + sourceChild.getName(), installedFiles, preview, forceInstall); if (mkdir == true) this.outputVerboseMessage("Directory '" + destinationDir + "/" + sourceChild.getName() + "' added to war", true);