mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
1) Do not import copied from references
2) ACP zip file now contains content files with appropriate extension for easy viewing of content git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2018 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,7 +26,9 @@ import java.io.OutputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.view.ExportPackageHandler;
|
||||
import org.alfresco.service.cmr.view.ExporterException;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
@@ -43,6 +45,7 @@ public class ACPExportPackageHandler
|
||||
/** ACP File Extension */
|
||||
public final static String ACP_EXTENSION = "acp";
|
||||
|
||||
protected MimetypeService mimetypeService;
|
||||
protected OutputStream outputStream;
|
||||
protected File dataFile;
|
||||
protected File contentDir;
|
||||
@@ -60,7 +63,7 @@ public class ACPExportPackageHandler
|
||||
* @param dataFile
|
||||
* @param contentDir
|
||||
*/
|
||||
public ACPExportPackageHandler(File destDir, File zipFile, File dataFile, File contentDir, boolean overwrite)
|
||||
public ACPExportPackageHandler(File destDir, File zipFile, File dataFile, File contentDir, boolean overwrite, MimetypeService mimetypeService)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -86,6 +89,7 @@ public class ACPExportPackageHandler
|
||||
this.outputStream = new FileOutputStream(absZipFile);
|
||||
this.dataFile = dataFile;
|
||||
this.contentDir = contentDir;
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
@@ -100,11 +104,12 @@ public class ACPExportPackageHandler
|
||||
* @param dataFile
|
||||
* @param contentDir
|
||||
*/
|
||||
public ACPExportPackageHandler(OutputStream outputStream, File dataFile, File contentDir)
|
||||
public ACPExportPackageHandler(OutputStream outputStream, File dataFile, File contentDir, MimetypeService mimetypeService)
|
||||
{
|
||||
this.outputStream = outputStream;
|
||||
this.dataFile = dataFile;
|
||||
this.contentDir = contentDir;
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -143,7 +148,23 @@ public class ACPExportPackageHandler
|
||||
{
|
||||
contentDirPath = contentDirPath.substring(0, contentDirPath.indexOf("."));
|
||||
}
|
||||
File file = new File(contentDirPath, "content" + iFileCnt++ + ".bin");
|
||||
String extension = "bin";
|
||||
if (mimetypeService != null)
|
||||
{
|
||||
String mimetype = contentData.getMimetype();
|
||||
if (mimetype != null && mimetype.length() > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
extension = mimetypeService.getExtension(mimetype);
|
||||
}
|
||||
catch(AlfrescoRuntimeException e)
|
||||
{
|
||||
// use default extension
|
||||
}
|
||||
}
|
||||
}
|
||||
File file = new File(contentDirPath, "content" + iFileCnt++ + "." + extension);
|
||||
|
||||
try
|
||||
{
|
||||
|
@@ -23,7 +23,9 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.view.ExportPackageHandler;
|
||||
import org.alfresco.service.cmr.view.ExporterException;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
@@ -37,6 +39,7 @@ import org.alfresco.util.TempFileProvider;
|
||||
public class FileExportPackageHandler
|
||||
implements ExportPackageHandler
|
||||
{
|
||||
protected MimetypeService mimetypeService = null;
|
||||
protected File contentDir;
|
||||
protected File absContentDir;
|
||||
protected File absDataFile;
|
||||
@@ -50,13 +53,15 @@ public class FileExportPackageHandler
|
||||
* @param dataFile filename of data file (relative to destDir)
|
||||
* @param packageDir directory for content (relative to destDir)
|
||||
* @param overwrite force overwrite of existing package directory
|
||||
* @param mimetypeService (optional) mimetype service
|
||||
*/
|
||||
public FileExportPackageHandler(File destDir, File dataFile, File contentDir, boolean overwrite)
|
||||
public FileExportPackageHandler(File destDir, File dataFile, File contentDir, boolean overwrite, MimetypeService mimetypeService)
|
||||
{
|
||||
this.contentDir = contentDir;
|
||||
this.absContentDir = new File(destDir, contentDir.getPath());
|
||||
this.absDataFile = new File(destDir, dataFile.getPath());
|
||||
this.overwrite = overwrite;
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -119,7 +124,23 @@ public class FileExportPackageHandler
|
||||
}
|
||||
|
||||
// Create file in package directory to hold exported content
|
||||
File outputFile = TempFileProvider.createTempFile("export", ".bin", absContentDir);
|
||||
String extension = "bin";
|
||||
if (mimetypeService != null)
|
||||
{
|
||||
String mimetype = contentData.getMimetype();
|
||||
if (mimetype != null && mimetype.length() > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
extension = mimetypeService.getExtension(mimetype);
|
||||
}
|
||||
catch(AlfrescoRuntimeException e)
|
||||
{
|
||||
// use default extension
|
||||
}
|
||||
}
|
||||
}
|
||||
File outputFile = TempFileProvider.createTempFile("export", "." + extension, absContentDir);
|
||||
|
||||
try
|
||||
{
|
||||
|
Reference in New Issue
Block a user