MNT-24883 removed doc filter.

This commit is contained in:
bsayan2 2025-05-28 12:44:37 +05:30
parent dfbde1c268
commit 89b273deaf
3 changed files with 5 additions and 24 deletions

View File

@ -55,7 +55,6 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.util.UriUtils; import org.springframework.web.util.UriUtils;
import org.alfresco.transform.base.logging.LogEntry; import org.alfresco.transform.base.logging.LogEntry;
import org.alfresco.transform.base.util.Util;
import org.alfresco.transform.common.ExtensionService; import org.alfresco.transform.common.ExtensionService;
import org.alfresco.transform.exceptions.TransformException; import org.alfresco.transform.exceptions.TransformException;
@ -81,7 +80,7 @@ public class FileManager
.map(Part::getSubmittedFileName) .map(Part::getSubmittedFileName)
.findFirst() .findFirst()
.orElse(null); .orElse(null);
file = (!StringUtils.isEmpty(submittedFileName) && Util.isDocFile(submittedFileName)) file = !StringUtils.isEmpty(submittedFileName)
? TempFileProvider.createTempDirForDocFile(submittedFileName) ? TempFileProvider.createTempDirForDocFile(submittedFileName)
: TempFileProvider.createTempFile("source_", extension); : TempFileProvider.createTempFile("source_", extension);
} }
@ -103,16 +102,12 @@ public class FileManager
} }
} }
public static File createSourceDocFileWithSameName(HttpServletRequest request, String sourceFileName, InputStream inputStream, String sourceMimetype) public static File createSourceDocFileWithSameName(String sourceFileName, InputStream inputStream)
{ {
try try
{ {
File file = TempFileProvider.createTempDirForDocFile(sourceFileName); File file = TempFileProvider.createTempDirForDocFile(sourceFileName);
Files.copy(inputStream, file.toPath(), REPLACE_EXISTING); Files.copy(inputStream, file.toPath(), REPLACE_EXISTING);
if (request != null)
{
request.setAttribute(SOURCE_FILE, file);
}
LogEntry.setSource(file.getName(), file.length()); LogEntry.setSource(file.getName(), file.length());
return file; return file;
} }

View File

@ -41,7 +41,6 @@ import org.springframework.stereotype.Component;
import org.alfresco.transform.base.TransformManager; import org.alfresco.transform.base.TransformManager;
import org.alfresco.transform.base.fs.FileManager; import org.alfresco.transform.base.fs.FileManager;
import org.alfresco.transform.base.util.OutputStreamLengthRecorder; import org.alfresco.transform.base.util.OutputStreamLengthRecorder;
import org.alfresco.transform.base.util.Util;
/** /**
* Manages the input and output streams and any temporary files that have been created. * Manages the input and output streams and any temporary files that have been created.
@ -177,9 +176,8 @@ public class TransformManagerImpl implements TransformManager
if (sourceFile == null) if (sourceFile == null)
{ {
boolean isDocFile = !StringUtils.isEmpty(this.sourceFileName) && Util.isDocFile(this.sourceFileName); sourceFile = request == null
sourceFile = isDocFile ? FileManager.createSourceDocFileWithSameName(sourceFileName, inputStream)
? FileManager.createSourceDocFileWithSameName(request, this.sourceFileName, inputStream, sourceMimetype)
: FileManager.createSourceFile(request, inputStream, sourceMimetype); : FileManager.createSourceFile(request, inputStream, sourceMimetype);
} }
return sourceFile; return sourceFile;
@ -226,7 +224,7 @@ public class TransformManagerImpl implements TransformManager
{ {
logger.error("Failed to delete temporary source file {}", sourceFile.getPath()); logger.error("Failed to delete temporary source file {}", sourceFile.getPath());
} }
if (sourceFile != null && Util.isDocFile(sourceFile.getPath())) if (sourceFile != null)
{ {
File parentDir = sourceFile.getParentFile(); File parentDir = sourceFile.getParentFile();
if (parentDir != null if (parentDir != null

View File

@ -66,16 +66,4 @@ public class Util
{ {
return param == null ? null : Long.parseLong(param); return param == null ? null : Long.parseLong(param);
} }
/**
* check if given file name is a doc file
*
* @param filename
* @return if file is .doc*
*/
public static boolean isDocFile(String filename)
{
String extension = filename.substring(filename.lastIndexOf('.'));
return extension.startsWith(".doc");
}
} }