mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Remove tabs found during investigation
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@129834 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -89,7 +89,7 @@ public class ImporterActionExecuter extends ActionExecuterAbstractBase
|
||||
* The importer service
|
||||
*/
|
||||
private ImporterService importerService;
|
||||
|
||||
|
||||
/**
|
||||
* The node service
|
||||
*/
|
||||
@@ -110,10 +110,10 @@ public class ImporterActionExecuter extends ActionExecuterAbstractBase
|
||||
*
|
||||
* @param importerService The ImporterService
|
||||
*/
|
||||
public void setImporterService(ImporterService importerService)
|
||||
{
|
||||
this.importerService = importerService;
|
||||
}
|
||||
public void setImporterService(ImporterService importerService)
|
||||
{
|
||||
this.importerService = importerService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the NodeService to use
|
||||
@@ -213,14 +213,14 @@ public class ImporterActionExecuter extends ActionExecuterAbstractBase
|
||||
String encoding = (String) ruleAction.getParameterValue(PARAM_ENCODING);
|
||||
if (encoding == null)
|
||||
{
|
||||
encoding = "UTF-8";
|
||||
encoding = "UTF-8";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (encoding.equalsIgnoreCase("default"))
|
||||
{
|
||||
encoding = null;
|
||||
}
|
||||
if (encoding.equalsIgnoreCase("default"))
|
||||
{
|
||||
encoding = null;
|
||||
}
|
||||
}
|
||||
zipFile = new ZipFile(tempFile, encoding, true);
|
||||
// build a temp dir name based on the ID of the noderef we are importing
|
||||
@@ -331,108 +331,108 @@ public class ImporterActionExecuter extends ActionExecuterAbstractBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
*/
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_DESTINATION_FOLDER, DataTypeDefinition.NODE_REF,
|
||||
true, getParamDisplayLabel(PARAM_DESTINATION_FOLDER)));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_ENCODING, DataTypeDefinition.TEXT,
|
||||
false, getParamDisplayLabel(PARAM_ENCODING)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the file and folder structure of a ZIP file into the specified directory
|
||||
*
|
||||
* @param archive The ZIP archive to extract
|
||||
* @param extractDir The directory to extract into
|
||||
*/
|
||||
public static void extractFile(ZipFile archive, String extractDir)
|
||||
{
|
||||
String fileName;
|
||||
String destFileName;
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
extractDir = extractDir + File.separator;
|
||||
try
|
||||
{
|
||||
for (Enumeration e = archive.getEntries(); e.hasMoreElements();)
|
||||
{
|
||||
ZipArchiveEntry entry = (ZipArchiveEntry) e.nextElement();
|
||||
if (!entry.isDirectory())
|
||||
{
|
||||
fileName = entry.getName();
|
||||
fileName = fileName.replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the file and folder structure of a ZIP file into the specified directory
|
||||
*
|
||||
* @param archive The ZIP archive to extract
|
||||
* @param extractDir The directory to extract into
|
||||
*/
|
||||
public static void extractFile(ZipFile archive, String extractDir)
|
||||
{
|
||||
String fileName;
|
||||
String destFileName;
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
extractDir = extractDir + File.separator;
|
||||
try
|
||||
{
|
||||
for (Enumeration e = archive.getEntries(); e.hasMoreElements();)
|
||||
{
|
||||
ZipArchiveEntry entry = (ZipArchiveEntry) e.nextElement();
|
||||
if (!entry.isDirectory())
|
||||
{
|
||||
fileName = entry.getName();
|
||||
fileName = fileName.replace('/', File.separatorChar);
|
||||
|
||||
if (fileName.startsWith("/") || fileName.indexOf(":" + File.separator) == 1 || fileName.contains(".." + File.separator))
|
||||
{
|
||||
throw new AlfrescoRuntimeException(ARCHIVE_CONTAINS_SUSPICIOUS_PATHS_ERROR);
|
||||
}
|
||||
if (fileName.startsWith("/") || fileName.indexOf(":" + File.separator) == 1 || fileName.contains(".." + File.separator))
|
||||
{
|
||||
throw new AlfrescoRuntimeException(ARCHIVE_CONTAINS_SUSPICIOUS_PATHS_ERROR);
|
||||
}
|
||||
|
||||
destFileName = extractDir + fileName;
|
||||
File destFile = new File(destFileName);
|
||||
String parent = destFile.getParent();
|
||||
if (parent != null)
|
||||
{
|
||||
File parentFile = new File(parent);
|
||||
if (!parentFile.exists()) parentFile.mkdirs();
|
||||
}
|
||||
InputStream in = new BufferedInputStream(archive.getInputStream(entry), BUFFER_SIZE);
|
||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(destFileName), BUFFER_SIZE);
|
||||
int count;
|
||||
while ((count = in.read(buffer)) != -1)
|
||||
{
|
||||
out.write(buffer, 0, count);
|
||||
}
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
File newdir = new File(extractDir + entry.getName());
|
||||
newdir.mkdirs();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ZipException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
||||
}
|
||||
}
|
||||
destFileName = extractDir + fileName;
|
||||
File destFile = new File(destFileName);
|
||||
String parent = destFile.getParent();
|
||||
if (parent != null)
|
||||
{
|
||||
File parentFile = new File(parent);
|
||||
if (!parentFile.exists()) parentFile.mkdirs();
|
||||
}
|
||||
InputStream in = new BufferedInputStream(archive.getInputStream(entry), BUFFER_SIZE);
|
||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(destFileName), BUFFER_SIZE);
|
||||
int count;
|
||||
while ((count = in.read(buffer)) != -1)
|
||||
{
|
||||
out.write(buffer, 0, count);
|
||||
}
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
File newdir = new File(extractDir + entry.getName());
|
||||
newdir.mkdirs();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ZipException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively delete a dir of files and directories
|
||||
*
|
||||
* @param dir directory to delete
|
||||
*/
|
||||
public static void deleteDir(File dir)
|
||||
{
|
||||
if (dir != null)
|
||||
{
|
||||
File elenco = new File(dir.getPath());
|
||||
|
||||
// listFiles can return null if the path is invalid i.e. already been deleted,
|
||||
// therefore check for null before using in loop
|
||||
File[] files = elenco.listFiles();
|
||||
if (files != null)
|
||||
{
|
||||
for (File file : files)
|
||||
{
|
||||
if (file.isFile()) file.delete();
|
||||
else deleteDir(file);
|
||||
}
|
||||
}
|
||||
|
||||
// delete provided directory
|
||||
dir.delete();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Recursively delete a dir of files and directories
|
||||
*
|
||||
* @param dir directory to delete
|
||||
*/
|
||||
public static void deleteDir(File dir)
|
||||
{
|
||||
if (dir != null)
|
||||
{
|
||||
File elenco = new File(dir.getPath());
|
||||
|
||||
// listFiles can return null if the path is invalid i.e. already been deleted,
|
||||
// therefore check for null before using in loop
|
||||
File[] files = elenco.listFiles();
|
||||
if (files != null)
|
||||
{
|
||||
for (File file : files)
|
||||
{
|
||||
if (file.isFile()) file.delete();
|
||||
else deleteDir(file);
|
||||
}
|
||||
}
|
||||
|
||||
// delete provided directory
|
||||
dir.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user