mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Update to web repository web service to add association filter. Module management tool can now install AMP from a given directory.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5018 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -23,7 +23,6 @@ import java.util.Map;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.module.ModuleInstallState;
|
import org.alfresco.service.cmr.module.ModuleInstallState;
|
||||||
import org.alfresco.service.cmr.module.ModuleService;
|
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.util.FileCopyUtils;
|
import org.springframework.util.FileCopyUtils;
|
||||||
@@ -62,6 +61,7 @@ public class ModuleManagementTool
|
|||||||
private static final String OPTION_FORCE = "-force";
|
private static final String OPTION_FORCE = "-force";
|
||||||
private static final String OPTION_PREVIEW = "-preview";
|
private static final String OPTION_PREVIEW = "-preview";
|
||||||
private static final String OPTION_NOBACKUP = "-nobackup";
|
private static final String OPTION_NOBACKUP = "-nobackup";
|
||||||
|
private static final String OPTION_DIRECTORY = "-directory";
|
||||||
|
|
||||||
/** Default zip detector */
|
/** Default zip detector */
|
||||||
public static ZipDetector defaultDetector = new DefaultRaesZipDetector("amp|war");
|
public static ZipDetector defaultDetector = new DefaultRaesZipDetector("amp|war");
|
||||||
@@ -110,6 +110,64 @@ public class ModuleManagementTool
|
|||||||
this.verbose = verbose;
|
this.verbose = verbose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param directory
|
||||||
|
* @param warFileLocation
|
||||||
|
*/
|
||||||
|
public void installModules(String directory, String warFileLocation)
|
||||||
|
{
|
||||||
|
installModules(directory, warFileLocation, false, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param directoryLocation
|
||||||
|
* @param warFileLocation
|
||||||
|
* @param preview
|
||||||
|
* @param forceInstall
|
||||||
|
* @param backupWAR
|
||||||
|
*/
|
||||||
|
public void installModules(String directoryLocation, String warFileLocation, boolean preview, boolean forceInstall, boolean backupWAR)
|
||||||
|
{
|
||||||
|
java.io.File dir = new java.io.File(directoryLocation);
|
||||||
|
if (dir.exists() == true)
|
||||||
|
{
|
||||||
|
installModules(dir, warFileLocation, preview, forceInstall,backupWAR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ModuleManagementToolException("Invalid directory '" + directoryLocation + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param dir
|
||||||
|
* @param warFileLocation
|
||||||
|
* @param preview
|
||||||
|
* @param forceInstall
|
||||||
|
* @param backupWAR
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs a given AMP file into a given WAR file.
|
* Installs a given AMP file into a given WAR file.
|
||||||
*
|
*
|
||||||
@@ -534,6 +592,7 @@ public class ModuleManagementTool
|
|||||||
boolean forceInstall = false;
|
boolean forceInstall = false;
|
||||||
boolean previewInstall = false;
|
boolean previewInstall = false;
|
||||||
boolean backup = true;
|
boolean backup = true;
|
||||||
|
boolean directory = false;
|
||||||
|
|
||||||
if (args.length > 3)
|
if (args.length > 3)
|
||||||
{
|
{
|
||||||
@@ -551,16 +610,29 @@ public class ModuleManagementTool
|
|||||||
else if (OPTION_PREVIEW.equals(option) == true)
|
else if (OPTION_PREVIEW.equals(option) == true)
|
||||||
{
|
{
|
||||||
previewInstall = true;
|
previewInstall = true;
|
||||||
|
manager.setVerbose(true);
|
||||||
}
|
}
|
||||||
else if (OPTION_NOBACKUP.equals(option) == true)
|
else if (OPTION_NOBACKUP.equals(option) == true)
|
||||||
{
|
{
|
||||||
backup = false;
|
backup = false;
|
||||||
}
|
}
|
||||||
|
else if (OPTION_DIRECTORY.equals(option) == true)
|
||||||
|
{
|
||||||
|
directory = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Install the module
|
if (directory == false)
|
||||||
manager.installModule(aepFileLocation, warFileLocation, previewInstall, forceInstall, backup);
|
{
|
||||||
|
// Install the module
|
||||||
|
manager.installModule(aepFileLocation, warFileLocation, previewInstall, forceInstall, backup);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Install the modules from the directory
|
||||||
|
manager.installModules(aepFileLocation, warFileLocation, previewInstall, forceInstall, backup);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (OP_LIST.equals(operation) == true && args.length == 2)
|
else if (OP_LIST.equals(operation) == true && args.length == 2)
|
||||||
{
|
{
|
||||||
@@ -586,18 +658,18 @@ public class ModuleManagementTool
|
|||||||
{
|
{
|
||||||
System.out.println("Module managment tool available commands:");
|
System.out.println("Module managment tool available commands:");
|
||||||
System.out.println("-----------------------------------------------------------\n");
|
System.out.println("-----------------------------------------------------------\n");
|
||||||
System.out.println("install: Installs a AMP file into an Alfresco WAR file, updates if an older version is already installed.");
|
System.out.println("install: Installs a AMP file(s) into an Alfresco WAR file, updates if an older version is already installed.");
|
||||||
System.out.println("usage: install AMPFile WARFile options");
|
System.out.println("usage: install <AMPFileLocation> <WARFileLocation> [options]");
|
||||||
System.out.println("valid options: ");
|
System.out.println("valid options: ");
|
||||||
System.out.println(" -verbose : enable verbose output");
|
System.out.println(" -verbose : enable verbose output");
|
||||||
System.out.println(" -force : forces installation of AMP regardless of currently installed module version");
|
System.out.println(" -directory : indicates that the amp file location specified is a directory.");
|
||||||
System.out.println(" -preview : previews installation of AMP without modifying WAR file");
|
System.out.println(" All amp files found in the directory and its sub directories are installed.");
|
||||||
System.out.println(" -nobackup : indicates that no backup should be made of the WAR\n");
|
System.out.println(" -force : forces installation of AMP regardless of currently installed module version");
|
||||||
|
System.out.println(" -preview : previews installation of AMP without modifying WAR file");
|
||||||
|
System.out.println(" -nobackup : indicates that no backup should be made of the WAR\n");
|
||||||
System.out.println("-----------------------------------------------------------\n");
|
System.out.println("-----------------------------------------------------------\n");
|
||||||
System.out.println("list: Lists all the modules currently installed in an Alfresco WAR file.");
|
System.out.println("list: Lists all the modules currently installed in an Alfresco WAR file.");
|
||||||
System.out.println("usage: list WARFile\n");
|
System.out.println("usage: list <WARFileLocation>\n");
|
||||||
System.out.println("-----------------------------------------------------------\n");
|
System.out.println("-----------------------------------------------------------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -181,6 +181,31 @@ public class ModuleManagementToolTest extends TestCase
|
|||||||
this.manager.installModule(ampLocation, warLocation, false, true, false);
|
this.manager.installModule(ampLocation, warLocation, false, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testInstallFromDir()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
manager.setVerbose(true);
|
||||||
|
|
||||||
|
String warLocation = getFileLocation(".war", "module/test.war");
|
||||||
|
String ampLocation = getFileLocation(".amp", "module/test.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);
|
||||||
|
|
||||||
|
System.out.println(warLocation);
|
||||||
|
System.out.println(directoryLocation);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.manager.installModules(directoryLocation, warLocation);
|
||||||
|
}
|
||||||
|
catch (ModuleManagementToolException exception)
|
||||||
|
{
|
||||||
|
// ignore since we are expecting this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testList()
|
public void testList()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
@@ -199,6 +224,7 @@ public class ModuleManagementToolTest extends TestCase
|
|||||||
{
|
{
|
||||||
File file = File.createTempFile("moduleManagementToolTest-", extension);
|
File file = File.createTempFile("moduleManagementToolTest-", extension);
|
||||||
InputStream is = this.getClass().getClassLoader().getResourceAsStream(location);
|
InputStream is = this.getClass().getClassLoader().getResourceAsStream(location);
|
||||||
|
assertNotNull(is);
|
||||||
OutputStream os = new FileOutputStream(file);
|
OutputStream os = new FileOutputStream(file);
|
||||||
FileCopyUtils.copy(is, os);
|
FileCopyUtils.copy(is, os);
|
||||||
return file.getPath();
|
return file.getPath();
|
||||||
|
Reference in New Issue
Block a user