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:
Brian Remmington
2011-12-02 09:58:45 +00:00
parent 002c09faac
commit 26e0b0a765
3 changed files with 22 additions and 11 deletions

View File

@@ -183,7 +183,8 @@ public class ImporterActionExecuter extends ActionExecuterAbstractBase
// NOTE: This encoding allows us to workaround bug: // NOTE: This encoding allows us to workaround bug:
// http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807 // http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807
// We also try to use the extra encoding information if present // 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 // 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 // also use the long life temp folder as large ZIP files can take a while

View File

@@ -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.ExportPackageHandler;
import org.alfresco.service.cmr.view.ExporterException; import org.alfresco.service.cmr.view.ExporterException;
import org.alfresco.util.TempFileProvider; import org.alfresco.util.TempFileProvider;
import org.apache.tools.zip.ZipEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.tools.zip.ZipOutputStream; 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 contentDir;
protected File tempDataFile; protected File tempDataFile;
protected OutputStream tempDataFileStream; protected OutputStream tempDataFileStream;
protected ZipOutputStream zipStream; protected ZipArchiveOutputStream zipStream;
protected int iFileCnt = 0; protected int iFileCnt = 0;
protected boolean exportAsFolders; protected boolean exportAsFolders;
@@ -145,10 +146,14 @@ public class ACPExportPackageHandler
*/ */
public void startExport() public void startExport()
{ {
zipStream = new ZipOutputStream(outputStream); // ALF-2016
zipStream = new ZipArchiveOutputStream(outputStream);
// NOTE: This encoding allows us to workaround bug... // NOTE: This encoding allows us to workaround bug...
// http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807 // 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) /* (non-Javadoc)
@@ -215,8 +220,9 @@ public class ACPExportPackageHandler
try try
{ {
ZipEntry zipEntry = new ZipEntry(file.getPath()); // ALF-2016
zipStream.putNextEntry(zipEntry); ZipArchiveEntry zipEntry=new ZipArchiveEntry(file.getPath());
zipStream.putArchiveEntry(zipEntry);
// copy export stream to zip // copy export stream to zip
copyStream(zipStream, content); copyStream(zipStream, content);
@@ -242,15 +248,19 @@ public class ACPExportPackageHandler
} }
// add data file to zip stream // add data file to zip stream
ZipEntry zipEntry = new ZipEntry(dataFilePath); // ALF-2016
ZipArchiveEntry zipEntry=new ZipArchiveEntry(dataFilePath);
try try
{ {
// close data file stream and place temp data file into zip output stream // close data file stream and place temp data file into zip output stream
tempDataFileStream.close(); tempDataFileStream.close();
zipStream.putNextEntry(zipEntry); // ALF-2016
zipStream.putArchiveEntry(zipEntry);
InputStream dataFileStream = new FileInputStream(tempDataFile); InputStream dataFileStream = new FileInputStream(tempDataFile);
copyStream(zipStream, dataFileStream); copyStream(zipStream, dataFileStream);
// ALF-2016
zipStream.closeArchiveEntry();
dataFileStream.close(); dataFileStream.close();
} }
catch (IOException e) catch (IOException e)

View File

@@ -70,7 +70,7 @@ public class ACPImportPackageHandler
{ {
// NOTE: This encoding allows us to workaround bug... // NOTE: This encoding allows us to workaround bug...
// http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807 // 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) catch(IOException e)
{ {