mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/DEV/BELARUS/HEAD-2011_11_10/ to HEAD:
32413: ALF-2016: Use org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream and UTF-8 encoding instead of org.apache.tools.zip.ZipOutputStream and Cp437 encoding at export *.acp file. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32461 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -183,7 +183,8 @@ public class ImporterActionExecuter extends ActionExecuterAbstractBase
|
||||
// NOTE: This encoding allows us to workaround bug:
|
||||
// http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807
|
||||
// We also try to use the extra encoding information if present
|
||||
zipFile = new ZipFile(tempFile, "Cp437", true);
|
||||
// ALF-2016
|
||||
zipFile = new ZipFile(tempFile, "UTF-8", true);
|
||||
|
||||
// build a temp dir name based on the ID of the noderef we are importing
|
||||
// also use the long life temp folder as large ZIP files can take a while
|
||||
|
@@ -38,8 +38,9 @@ import org.alfresco.service.cmr.repository.Path.ChildAssocElement;
|
||||
import org.alfresco.service.cmr.view.ExportPackageHandler;
|
||||
import org.alfresco.service.cmr.view.ExporterException;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.apache.tools.zip.ZipEntry;
|
||||
import org.apache.tools.zip.ZipOutputStream;
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.UnicodeExtraFieldPolicy;
|
||||
|
||||
|
||||
/**
|
||||
@@ -60,7 +61,7 @@ public class ACPExportPackageHandler
|
||||
protected File contentDir;
|
||||
protected File tempDataFile;
|
||||
protected OutputStream tempDataFileStream;
|
||||
protected ZipOutputStream zipStream;
|
||||
protected ZipArchiveOutputStream zipStream;
|
||||
protected int iFileCnt = 0;
|
||||
protected boolean exportAsFolders;
|
||||
|
||||
@@ -145,10 +146,14 @@ public class ACPExportPackageHandler
|
||||
*/
|
||||
public void startExport()
|
||||
{
|
||||
zipStream = new ZipOutputStream(outputStream);
|
||||
// ALF-2016
|
||||
zipStream = new ZipArchiveOutputStream(outputStream);
|
||||
// NOTE: This encoding allows us to workaround bug...
|
||||
// http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807
|
||||
zipStream.setEncoding("Cp437");
|
||||
zipStream.setEncoding("UTF-8");
|
||||
zipStream.setCreateUnicodeExtraFields(UnicodeExtraFieldPolicy.ALWAYS);
|
||||
zipStream.setUseLanguageEncodingFlag(true);
|
||||
zipStream.setFallbackToUTF8(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -215,8 +220,9 @@ public class ACPExportPackageHandler
|
||||
|
||||
try
|
||||
{
|
||||
ZipEntry zipEntry = new ZipEntry(file.getPath());
|
||||
zipStream.putNextEntry(zipEntry);
|
||||
// ALF-2016
|
||||
ZipArchiveEntry zipEntry=new ZipArchiveEntry(file.getPath());
|
||||
zipStream.putArchiveEntry(zipEntry);
|
||||
|
||||
// copy export stream to zip
|
||||
copyStream(zipStream, content);
|
||||
@@ -242,15 +248,19 @@ public class ACPExportPackageHandler
|
||||
}
|
||||
|
||||
// add data file to zip stream
|
||||
ZipEntry zipEntry = new ZipEntry(dataFilePath);
|
||||
// ALF-2016
|
||||
ZipArchiveEntry zipEntry=new ZipArchiveEntry(dataFilePath);
|
||||
|
||||
try
|
||||
{
|
||||
// close data file stream and place temp data file into zip output stream
|
||||
tempDataFileStream.close();
|
||||
zipStream.putNextEntry(zipEntry);
|
||||
// ALF-2016
|
||||
zipStream.putArchiveEntry(zipEntry);
|
||||
InputStream dataFileStream = new FileInputStream(tempDataFile);
|
||||
copyStream(zipStream, dataFileStream);
|
||||
// ALF-2016
|
||||
zipStream.closeArchiveEntry();
|
||||
dataFileStream.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
|
@@ -70,7 +70,7 @@ public class ACPImportPackageHandler
|
||||
{
|
||||
// NOTE: This encoding allows us to workaround bug...
|
||||
// http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807
|
||||
zipFile = new ZipFile(file, "Cp437");
|
||||
zipFile = new ZipFile(file, "UTF-8");
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
|
Reference in New Issue
Block a user