mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
java: replace the previous implementation of formats
This commit is contained in:
@ -19,13 +19,14 @@
|
||||
package helpers;
|
||||
|
||||
import entities.FileType;
|
||||
import format.FormatManager;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class FileUtility {
|
||||
private static FormatManager formatManager = new FormatManager();
|
||||
|
||||
private FileUtility() { }
|
||||
|
||||
@ -33,50 +34,24 @@ public final class FileUtility {
|
||||
public static FileType getFileType(final String fileName) {
|
||||
String ext = getFileExtension(fileName).toLowerCase();
|
||||
|
||||
// word type for document extensions
|
||||
if (extsDocument.contains(ext)) {
|
||||
return FileType.Word;
|
||||
}
|
||||
|
||||
// cell type for spreadsheet extensions
|
||||
if (extsSpreadsheet.contains(ext)) {
|
||||
return FileType.Cell;
|
||||
}
|
||||
|
||||
// slide type for presentation extensions
|
||||
if (extsPresentation.contains(ext)) {
|
||||
return FileType.Slide;
|
||||
try {
|
||||
if (FileUtility.formatManager.documentExtensions().contains(ext)) {
|
||||
return FileType.Word;
|
||||
}
|
||||
if (FileUtility.formatManager.spreadsheetExtensions().contains(ext)) {
|
||||
return FileType.Cell;
|
||||
}
|
||||
if (FileUtility.formatManager.presentationExtensions().contains(ext)) {
|
||||
return FileType.Slide;
|
||||
}
|
||||
} catch (Exception error) {
|
||||
error.printStackTrace();
|
||||
}
|
||||
|
||||
// default file type is word
|
||||
return FileType.Word;
|
||||
}
|
||||
|
||||
// document extensions
|
||||
private static List<String> extsDocument = Arrays.asList(
|
||||
".doc", ".docx", ".docm",
|
||||
".dot", ".dotx", ".dotm",
|
||||
".odt", ".fodt", ".ott", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht", ".xml",
|
||||
".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps", ".oform"
|
||||
);
|
||||
|
||||
// spreadsheet extensions
|
||||
private static List<String> extsSpreadsheet = Arrays.asList(
|
||||
".xls", ".xlsx", ".xlsm", ".xlsb",
|
||||
".xlt", ".xltx", ".xltm",
|
||||
".ods", ".fods", ".ots", ".csv"
|
||||
);
|
||||
|
||||
// presentation extensions
|
||||
private static List<String> extsPresentation = Arrays.asList(
|
||||
".pps", ".ppsx", ".ppsm",
|
||||
".ppt", ".pptx", ".pptm",
|
||||
".pot", ".potx", ".potm",
|
||||
".odp", ".fodp", ".otp"
|
||||
);
|
||||
|
||||
|
||||
// get file name from the url
|
||||
public static String getFileName(final String url) {
|
||||
if (url == null) {
|
||||
|
||||
@ -3,10 +3,6 @@ version=1.6.0
|
||||
filesize-max=5242880
|
||||
storage-folder=app_data
|
||||
|
||||
files.docservice.fill-docs=.docx|.oform
|
||||
files.docservice.viewed-docs=.djvu|.oxps|.pdf|.xps
|
||||
files.docservice.edited-docs=.csv|.docm|.docx|.docxf|.dotm|.dotx|.epub|.fb2|.html|.odp|.ods|.odt|.otp|.ots|.ott|.potm|.potx|.ppsm|.ppsx|.pptm|.pptx|.rtf|.txt|.xlsm|.xlsx|.xltm|.xltx
|
||||
files.docservice.convert-docs=.doc|.dot|.dps|.dpt|.epub|.et|.ett|.fb2|.fodp|.fods|.fodt|.htm|.html|.mht|.mhtml|.odp|.ods|.odt|.otp|.ots|.ott|.pot|.pps|.ppt|.rtf|.stw|.sxc|.sxi|.sxw|.wps|.wpt|.xls|.xlsb|.xlt|.xml
|
||||
files.docservice.timeout=120000
|
||||
|
||||
files.docservice.url.site=http://documentserver/
|
||||
|
||||
Reference in New Issue
Block a user