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
|
* The importer service
|
||||||
*/
|
*/
|
||||||
private ImporterService importerService;
|
private ImporterService importerService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The node service
|
* The node service
|
||||||
*/
|
*/
|
||||||
@@ -110,10 +110,10 @@ public class ImporterActionExecuter extends ActionExecuterAbstractBase
|
|||||||
*
|
*
|
||||||
* @param importerService The ImporterService
|
* @param importerService The ImporterService
|
||||||
*/
|
*/
|
||||||
public void setImporterService(ImporterService importerService)
|
public void setImporterService(ImporterService importerService)
|
||||||
{
|
{
|
||||||
this.importerService = importerService;
|
this.importerService = importerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the NodeService to use
|
* Sets the NodeService to use
|
||||||
@@ -213,14 +213,14 @@ public class ImporterActionExecuter extends ActionExecuterAbstractBase
|
|||||||
String encoding = (String) ruleAction.getParameterValue(PARAM_ENCODING);
|
String encoding = (String) ruleAction.getParameterValue(PARAM_ENCODING);
|
||||||
if (encoding == null)
|
if (encoding == null)
|
||||||
{
|
{
|
||||||
encoding = "UTF-8";
|
encoding = "UTF-8";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (encoding.equalsIgnoreCase("default"))
|
if (encoding.equalsIgnoreCase("default"))
|
||||||
{
|
{
|
||||||
encoding = null;
|
encoding = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zipFile = new ZipFile(tempFile, encoding, true);
|
zipFile = new ZipFile(tempFile, encoding, 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
|
||||||
@@ -331,108 +331,108 @@ public class ImporterActionExecuter extends ActionExecuterAbstractBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
* @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,
|
paramList.add(new ParameterDefinitionImpl(PARAM_DESTINATION_FOLDER, DataTypeDefinition.NODE_REF,
|
||||||
true, getParamDisplayLabel(PARAM_DESTINATION_FOLDER)));
|
true, getParamDisplayLabel(PARAM_DESTINATION_FOLDER)));
|
||||||
paramList.add(new ParameterDefinitionImpl(PARAM_ENCODING, DataTypeDefinition.TEXT,
|
paramList.add(new ParameterDefinitionImpl(PARAM_ENCODING, DataTypeDefinition.TEXT,
|
||||||
false, getParamDisplayLabel(PARAM_ENCODING)));
|
false, getParamDisplayLabel(PARAM_ENCODING)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract the file and folder structure of a ZIP file into the specified directory
|
* Extract the file and folder structure of a ZIP file into the specified directory
|
||||||
*
|
*
|
||||||
* @param archive The ZIP archive to extract
|
* @param archive The ZIP archive to extract
|
||||||
* @param extractDir The directory to extract into
|
* @param extractDir The directory to extract into
|
||||||
*/
|
*/
|
||||||
public static void extractFile(ZipFile archive, String extractDir)
|
public static void extractFile(ZipFile archive, String extractDir)
|
||||||
{
|
{
|
||||||
String fileName;
|
String fileName;
|
||||||
String destFileName;
|
String destFileName;
|
||||||
byte[] buffer = new byte[BUFFER_SIZE];
|
byte[] buffer = new byte[BUFFER_SIZE];
|
||||||
extractDir = extractDir + File.separator;
|
extractDir = extractDir + File.separator;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (Enumeration e = archive.getEntries(); e.hasMoreElements();)
|
for (Enumeration e = archive.getEntries(); e.hasMoreElements();)
|
||||||
{
|
{
|
||||||
ZipArchiveEntry entry = (ZipArchiveEntry) e.nextElement();
|
ZipArchiveEntry entry = (ZipArchiveEntry) e.nextElement();
|
||||||
if (!entry.isDirectory())
|
if (!entry.isDirectory())
|
||||||
{
|
{
|
||||||
fileName = entry.getName();
|
fileName = entry.getName();
|
||||||
fileName = fileName.replace('/', File.separatorChar);
|
fileName = fileName.replace('/', File.separatorChar);
|
||||||
|
|
||||||
if (fileName.startsWith("/") || fileName.indexOf(":" + File.separator) == 1 || fileName.contains(".." + File.separator))
|
if (fileName.startsWith("/") || fileName.indexOf(":" + File.separator) == 1 || fileName.contains(".." + File.separator))
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException(ARCHIVE_CONTAINS_SUSPICIOUS_PATHS_ERROR);
|
throw new AlfrescoRuntimeException(ARCHIVE_CONTAINS_SUSPICIOUS_PATHS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
destFileName = extractDir + fileName;
|
destFileName = extractDir + fileName;
|
||||||
File destFile = new File(destFileName);
|
File destFile = new File(destFileName);
|
||||||
String parent = destFile.getParent();
|
String parent = destFile.getParent();
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
{
|
{
|
||||||
File parentFile = new File(parent);
|
File parentFile = new File(parent);
|
||||||
if (!parentFile.exists()) parentFile.mkdirs();
|
if (!parentFile.exists()) parentFile.mkdirs();
|
||||||
}
|
}
|
||||||
InputStream in = new BufferedInputStream(archive.getInputStream(entry), BUFFER_SIZE);
|
InputStream in = new BufferedInputStream(archive.getInputStream(entry), BUFFER_SIZE);
|
||||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(destFileName), BUFFER_SIZE);
|
OutputStream out = new BufferedOutputStream(new FileOutputStream(destFileName), BUFFER_SIZE);
|
||||||
int count;
|
int count;
|
||||||
while ((count = in.read(buffer)) != -1)
|
while ((count = in.read(buffer)) != -1)
|
||||||
{
|
{
|
||||||
out.write(buffer, 0, count);
|
out.write(buffer, 0, count);
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
File newdir = new File(extractDir + entry.getName());
|
File newdir = new File(extractDir + entry.getName());
|
||||||
newdir.mkdirs();
|
newdir.mkdirs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ZipException e)
|
catch (ZipException e)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException e)
|
catch (FileNotFoundException e)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively delete a dir of files and directories
|
* Recursively delete a dir of files and directories
|
||||||
*
|
*
|
||||||
* @param dir directory to delete
|
* @param dir directory to delete
|
||||||
*/
|
*/
|
||||||
public static void deleteDir(File dir)
|
public static void deleteDir(File dir)
|
||||||
{
|
{
|
||||||
if (dir != null)
|
if (dir != null)
|
||||||
{
|
{
|
||||||
File elenco = new File(dir.getPath());
|
File elenco = new File(dir.getPath());
|
||||||
|
|
||||||
// listFiles can return null if the path is invalid i.e. already been deleted,
|
// listFiles can return null if the path is invalid i.e. already been deleted,
|
||||||
// therefore check for null before using in loop
|
// therefore check for null before using in loop
|
||||||
File[] files = elenco.listFiles();
|
File[] files = elenco.listFiles();
|
||||||
if (files != null)
|
if (files != null)
|
||||||
{
|
{
|
||||||
for (File file : files)
|
for (File file : files)
|
||||||
{
|
{
|
||||||
if (file.isFile()) file.delete();
|
if (file.isFile()) file.delete();
|
||||||
else deleteDir(file);
|
else deleteDir(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete provided directory
|
// delete provided directory
|
||||||
dir.delete();
|
dir.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user