diff --git a/source/java/org/alfresco/repo/content/transform/MediaWikiContentTransformerTest.java b/source/java/org/alfresco/repo/content/transform/MediaWikiContentTransformerTest.java
index b69b281d09..eb7ba7215c 100644
--- a/source/java/org/alfresco/repo/content/transform/MediaWikiContentTransformerTest.java
+++ b/source/java/org/alfresco/repo/content/transform/MediaWikiContentTransformerTest.java
@@ -20,6 +20,7 @@ package org.alfresco.repo.content.transform;
import java.io.BufferedReader;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.FileReader;
import org.alfresco.repo.content.MimetypeMap;
@@ -30,8 +31,6 @@ import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.util.TempFileProvider;
-import de.schlichtherle.io.FileOutputStream;
-
/**
* @see org.alfresco.repo.content.transform.MediaWikiContentTransformer
*
diff --git a/source/java/org/alfresco/repo/module/tool/InstalledFiles.java b/source/java/org/alfresco/repo/module/tool/InstalledFiles.java
index 5a5e469be7..634884b5c1 100644
--- a/source/java/org/alfresco/repo/module/tool/InstalledFiles.java
+++ b/source/java/org/alfresco/repo/module/tool/InstalledFiles.java
@@ -21,15 +21,14 @@ package org.alfresco.repo.module.tool;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import de.schlichtherle.io.File;
-import de.schlichtherle.io.FileInputStream;
-import de.schlichtherle.io.FileOutputStream;
+import de.schlichtherle.truezip.file.TFile;
+import de.schlichtherle.truezip.file.TFileOutputStream;
+import de.schlichtherle.truezip.file.TFileReader;
/**
* Details of the files installed during a module installation into a WAR
@@ -74,12 +73,12 @@ public class InstalledFiles
*/
public void load()
{
- File file = new File(getFileLocation(), ModuleManagementTool.DETECTOR_AMP_AND_WAR);
+ TFile file = new TFile(getFileLocation());
if (file.exists() == true)
{
try
{
- BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+ BufferedReader reader = new BufferedReader(new TFileReader(file));
try
{
String line = reader.readLine();
@@ -130,12 +129,12 @@ public class InstalledFiles
{
try
{
- File file = new File(getFileLocation(), ModuleManagementTool.DETECTOR_AMP_AND_WAR);
+ TFile file = new TFile(getFileLocation());
if (file.exists() == false)
{
file.createNewFile();
}
- FileOutputStream os = new FileOutputStream(file);
+ TFileOutputStream os = new TFileOutputStream(file);
try
{
for (String add : this.adds)
diff --git a/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java b/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java
index 3a8f5f6b14..3fb5a1c3d6 100644
--- a/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java
+++ b/source/java/org/alfresco/repo/module/tool/ModuleDetailsHelper.java
@@ -18,6 +18,7 @@
*/
package org.alfresco.repo.module.tool;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -26,9 +27,9 @@ import java.util.Properties;
import org.alfresco.repo.module.ModuleDetailsImpl;
import org.alfresco.service.cmr.module.ModuleDetails;
-import de.schlichtherle.io.File;
-import de.schlichtherle.io.FileInputStream;
-import de.schlichtherle.io.FileOutputStream;
+import de.schlichtherle.truezip.file.TFile;
+import de.schlichtherle.truezip.file.TFileInputStream;
+import de.schlichtherle.truezip.file.TFileOutputStream;
/**
* Module details helper used by the module mangement tool
@@ -62,23 +63,35 @@ public class ModuleDetailsHelper
*
* @param location file location
* @return Returns the module details or null if the location points to nothing
+ * @throws IOException
*/
- public static ModuleDetails createModuleDetailsFromPropertyLocation(String location)
+ public static ModuleDetails createModuleDetailsFromPropertyLocation(String location) throws IOException
{
ModuleDetails result = null;
+ TFileInputStream is;
try
{
- File file = new File(location, ModuleManagementTool.DETECTOR_AMP_AND_WAR);
- if (file.exists())
- {
- InputStream is = new FileInputStream(file);
- result = createModuleDetailsFromPropertiesStream(is);
- }
+ is = new TFileInputStream(location);
+ }
+ catch (FileNotFoundException error)
+ {
+ throw new ModuleManagementToolException("Unable to load module details from property file.", error);
+ }
+
+ try
+ {
+ result = createModuleDetailsFromPropertiesStream(is);
}
catch (IOException exception)
{
- throw new ModuleManagementToolException("Unable to load module details from property file.", exception);
+ throw new ModuleManagementToolException(
+ "Unable to load module details from property file.", exception);
}
+ finally
+ {
+ is.close(); // ALWAYS close the stream!
+ }
+
return result;
}
@@ -89,8 +102,9 @@ public class ModuleDetailsHelper
* @param moduleId the module id
* @return Returns the module details for the given module ID as it occurs in the WAR, or null
* if there are no module details available.
+ * @throws IOException
*/
- public static ModuleDetails createModuleDetailsFromWarAndId(String warLocation, String moduleId)
+ public static ModuleDetails createModuleDetailsFromWarAndId(String warLocation, String moduleId) throws IOException
{
String modulePropertiesFileLocation = ModuleDetailsHelper.getModulePropertiesFileLocation(warLocation, moduleId);
return ModuleDetailsHelper.createModuleDetailsFromPropertyLocation(modulePropertiesFileLocation);
@@ -102,10 +116,10 @@ public class ModuleDetailsHelper
* @return Returns a file handle to the module properties file within the given WAR.
* The file may or may not exist.
*/
- public static File getModuleDetailsFileFromWarAndId(String warLocation, String moduleId)
+ public static TFile getModuleDetailsFileFromWarAndId(String warLocation, String moduleId)
{
String location = ModuleDetailsHelper.getModulePropertiesFileLocation(warLocation, moduleId);
- File file = new File(location, ModuleManagementTool.DETECTOR_AMP_AND_WAR);
+ TFile file = new TFile(location);
return file;
}
@@ -143,7 +157,7 @@ public class ModuleDetailsHelper
try
{
String modulePropertiesFileLocation = getModulePropertiesFileLocation(warLocation, moduleId);
- File file = new File(modulePropertiesFileLocation, ModuleManagementTool.DETECTOR_AMP_AND_WAR);
+ TFile file = new TFile(modulePropertiesFileLocation);
if (file.exists() == false)
{
file.createNewFile();
@@ -151,7 +165,7 @@ public class ModuleDetailsHelper
// Get all the module properties
Properties moduleProperties = moduleDetails.getProperties();
- OutputStream os = new FileOutputStream(file);
+ OutputStream os = new TFileOutputStream(file);
try
{
moduleProperties.store(os, null);
diff --git a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java
index 21d8d4b7fe..08db070b63 100644
--- a/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java
+++ b/source/java/org/alfresco/repo/module/tool/ModuleManagementTool.java
@@ -19,11 +19,8 @@
package org.alfresco.repo.module.tool;
import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.util.Date;
import java.util.Map;
import java.util.Map.Entry;
@@ -35,12 +32,13 @@ import org.alfresco.service.cmr.module.ModuleInstallState;
import org.alfresco.util.VersionNumber;
import org.safehaus.uuid.UUIDGenerator;
-import de.schlichtherle.io.DefaultRaesZipDetector;
-import de.schlichtherle.io.File;
-import de.schlichtherle.io.FileInputStream;
-import de.schlichtherle.io.ZipControllerException;
-import de.schlichtherle.io.ZipDetector;
-import de.schlichtherle.io.ZipWarningException;
+import de.schlichtherle.truezip.file.TArchiveDetector;
+import de.schlichtherle.truezip.file.TConfig;
+import de.schlichtherle.truezip.file.TFile;
+import de.schlichtherle.truezip.file.TFileInputStream;
+import de.schlichtherle.truezip.file.TVFS;
+import de.schlichtherle.truezip.fs.archive.zip.ZipDriver;
+import de.schlichtherle.truezip.socket.sl.IOPoolLocator;
/**
* Module management tool.
@@ -83,9 +81,6 @@ public class ModuleManagementTool implements LogOutput
private static final int ERROR_EXIT_CODE = 1;
private static final int SUCCESS_EXIT_CODE = 0;
- /** Default zip detector */
- public static final ZipDetector DETECTOR_AMP_AND_WAR = new DefaultRaesZipDetector("amp|war");
-
/** File mapping properties */
private Properties defaultFileMappingProperties;
@@ -99,6 +94,9 @@ public class ModuleManagementTool implements LogOutput
*/
public ModuleManagementTool()
{
+ TConfig config = TConfig.get();
+ config.setArchiveDetector(new TArchiveDetector("war|amp", new ZipDriver(IOPoolLocator.SINGLETON)));
+
// Load the default file mapping properties
this.defaultFileMappingProperties = new Properties();
InputStream is = this.getClass().getClassLoader().getResourceAsStream(DEFAULT_FILE_MAPPING_PROPERTIES);
@@ -134,21 +132,22 @@ public class ModuleManagementTool implements LogOutput
/**
* 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)
+ public void installModules(String directory, String warFileLocation) throws IOException
{
installModules(directory, warFileLocation, false, false, true);
}
- public void installModules(String directoryLocation, String warFileLocation, boolean preview, boolean forceInstall, boolean backupWAR)
+ 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(warFileLocation,true);
+ backupWar(new TFile(warFileLocation),true);
backupWAR = false; //Set it to false so a backup doesn't occur again.
}
installModules(dir, warFileLocation, preview, forceInstall,backupWAR);
@@ -207,21 +206,20 @@ public class ModuleManagementTool implements LogOutput
try
{
outputVerboseMessage("Installing AMP '" + ampFileLocation + "' into WAR '" + warFileLocation + "'");
-
- java.io.File theWar = new File(warFileLocation, DETECTOR_AMP_AND_WAR);
- if (!theWar.exists())
+ TFile warFile = new TFile(warFileLocation);
+ if (!warFile.exists())
{
- throw new ModuleManagementToolException("The war file '" + warFileLocation + "' does not exist.");
+ throw new ModuleManagementToolException("The war file '" + warFile + "' does not exist.");
}
if (preview == false)
{
// Make sure the module and backup directory exisits in the WAR file
- File moduleDir = new File(warFileLocation + WarHelper.MODULE_NAMESPACE_DIR, DETECTOR_AMP_AND_WAR);
+ TFile moduleDir = new TFile(warFileLocation + WarHelper.MODULE_NAMESPACE_DIR);
if (moduleDir.exists() == false)
{
moduleDir.mkdir();
}
- backupWar(warFileLocation, backupWAR);
+ backupWar(warFile, backupWAR);
}
// Get the details of the installing module
@@ -235,12 +233,12 @@ public class ModuleManagementTool implements LogOutput
VersionNumber installingVersion = installingModuleDetails.getVersion();
//A series of checks
- warHelper.checkCompatibleVersion(theWar, installingModuleDetails);
- warHelper.checkCompatibleEdition(theWar, installingModuleDetails);
- warHelper.checkModuleDependencies(theWar, installingModuleDetails);
+ warHelper.checkCompatibleVersion(warFile, installingModuleDetails);
+ warHelper.checkCompatibleEdition(warFile, installingModuleDetails);
+ warHelper.checkModuleDependencies(warFile, installingModuleDetails);
// Try to find an installed module by the ID
- ModuleDetails installedModuleDetails = warHelper.getModuleDetailsOrAlias(theWar, installingModuleDetails);
+ ModuleDetails installedModuleDetails = warHelper.getModuleDetailsOrAlias(warFile, installingModuleDetails);
uninstallIfNecessary(warFileLocation, installedModuleDetails, preview, forceInstall, installingVersion);
@@ -256,12 +254,9 @@ public class ModuleManagementTool implements LogOutput
{
for (Entry