mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
Merged V2.0 to HEAD
5464: Standalone ModuleManagementTool 5465: Manual port of distribution targets git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5486 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
0570c77f46
commit
9a6a22b511
@ -24,16 +24,18 @@
|
||||
*/
|
||||
package org.alfresco.repo.module.tool;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.alfresco.service.cmr.module.ModuleInstallState;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.doomdark.uuid.UUIDGenerator;
|
||||
|
||||
import de.schlichtherle.io.DefaultRaesZipDetector;
|
||||
import de.schlichtherle.io.File;
|
||||
@ -52,9 +54,6 @@ import de.schlichtherle.io.ZipWarningException;
|
||||
*/
|
||||
public class ModuleManagementTool
|
||||
{
|
||||
/** Logger */
|
||||
public static Logger logger = Logger.getLogger("org.alfresco.repo.extension.ModuleManagementTool");
|
||||
|
||||
/** Location of the default mapping properties file */
|
||||
private static final String DEFAULT_FILE_MAPPING_PROPERTIES = "org/alfresco/repo/module/tool/default-file-mapping.properties";
|
||||
|
||||
@ -230,7 +229,7 @@ public class ModuleManagementTool
|
||||
}
|
||||
String backupLocation = warFileLocation + "-" + System.currentTimeMillis() + ".bak";
|
||||
java.io.File backup = new java.io.File(backupLocation);
|
||||
FileCopyUtils.copy(warFile, backup);
|
||||
copyFile(warFile, backup);
|
||||
|
||||
outputMessage("WAR has been backed up to '" + backupLocation + "'");
|
||||
}
|
||||
@ -429,7 +428,7 @@ public class ModuleManagementTool
|
||||
else
|
||||
{
|
||||
// Backup file about to be updated
|
||||
backupLocation = BACKUP_DIR + "/" + GUID.generate() + ".bin";
|
||||
backupLocation = BACKUP_DIR + "/" + generateGuid() + ".bin";
|
||||
if (preview == false)
|
||||
{
|
||||
File backupFile = new File(warFileLocation + backupLocation, defaultDetector);
|
||||
@ -575,10 +574,6 @@ public class ModuleManagementTool
|
||||
{
|
||||
System.out.println(message);
|
||||
}
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -658,6 +653,45 @@ public class ModuleManagementTool
|
||||
outputUsage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a GUID, avoiding undesired imports.
|
||||
*/
|
||||
private static String generateGuid()
|
||||
{
|
||||
return UUIDGenerator.getInstance().generateTimeBasedUUID().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Code borrowed directly from the Springframework FileCopyUtils.
|
||||
*/
|
||||
private static void copyFile(java.io.File in, java.io.File out) throws IOException
|
||||
{
|
||||
InputStream is = new BufferedInputStream(new FileInputStream(in));
|
||||
OutputStream os = new BufferedOutputStream(new FileOutputStream(out));
|
||||
try
|
||||
{
|
||||
int byteCount = 0;
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead = -1;
|
||||
while ((bytesRead = is.read(buffer)) != -1) {
|
||||
os.write(buffer, 0, bytesRead);
|
||||
byteCount += bytesRead;
|
||||
}
|
||||
os.flush();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (is != null)
|
||||
{
|
||||
try { is.close(); } catch (Throwable e) { e.printStackTrace(); }
|
||||
}
|
||||
if (os != null)
|
||||
{
|
||||
try { os.close(); } catch (Throwable e) { e.printStackTrace(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the module management tool usage
|
||||
|
2
source/meta-inf/mmt-manifest.mf
Normal file
2
source/meta-inf/mmt-manifest.mf
Normal file
@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: org.alfresco.repo.module.tool.ModuleManagementTool
|
Loading…
x
Reference in New Issue
Block a user