shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package com.walker.file;
 
import java.io.File;
import java.util.List;
 
@Deprecated
public interface FileEngine {
 
    /**
     * 文件存储方式:文件系统、数据库、内存等
     * @author shikeying
     *
     */
    @Deprecated
    public enum StoreType {
        FileSystem{
            public int getIndex(){
                return INDEX_FS;
            }
        },
        Database{
            public int getIndex(){
                return INDEX_DB;
            }
        },
        Memory{
            public int getIndex(){
                return INDEX_MM;
            }
        };
        
        static final int INDEX_FS = 0;
        static final int INDEX_DB = 1;
        static final int INDEX_MM = 2;
        
        public int getIndex(){
            throw new AbstractMethodError();
        }
        
        public static final StoreType getStoreType(int index){
            if(index == INDEX_FS){
                return FileSystem;
            } else if(index == INDEX_DB){
                return Database;
            } else {
                throw new UnsupportedOperationException();
            }
        }
    }
    
    /**
     * 返回存储文件的根路径,如:d:/file_store/
     * @return
     */
    String getFileStoreRootPath();
    
    /**
     * 读入上传的文件信息
     * @param request 请求对象
     * @param fileFormId 文件在界面上的ID
     * @param st 存储方式:数据库、文件等。
     * @return 返回生成的文件定义对象
     */
    List<FileMeta> readFiles(Object request, String fileFormId, StoreType st) throws FileOperateException;
    
    /**
     * 把得到的文件信息写入到持久化存储设备中,如:数据库或磁盘中。</p>
     * 此方法通常被应用系统在事务控制层中调用,以保持与数据库事务的一致性。
     * @param fileMetas 获取的文件集合
//     * @param thumb 是否缩略图
     * @return
     * @throws FileOperateException
     */
    List<String> writeFiles(List<FileMeta> fileMetas) throws FileOperateException;
    
//    /**
//     * 方法同上,仅仅返回参数不同。
//     * @param fileMetas
//     * @return
//     * @throws FileOperateException
//     */
//    List<FileMeta> writeFilesForMeta(List<FileMeta> fileMetas) throws FileOperateException;
    
    /**
     * 创建一个空的文件,此文件会存储到文件系统中,系统也会记录其信息。
     * @param filename 文件全名,如:abc.xls
     * @return 返回文件元数据对象
     */
    FileMeta createEmptyFile(String filename, String mimeType);
    
    /**
     * 根据文件ID集合,获取文件对象列表
     * @param ids 这些ID是系统在创建时自动生成的。
     * @return
     * @throws FileOperateException
     */
    List<FileMeta> listFiles(List<String> ids) throws FileOperateException;
    
    /**
     * 根据ID获得一个文件对象
     * @param id
     * @return
     */
    FileMeta getFile(String id);
    
    /**
     * 返回JAVA文件对象,此方法只有在'存储方式'为'文件系统时'才有效
     * @param filePath 相对文件路径,在数据库中存储的path字段
     * @return
     */
    File getFileObject(String filePath);
    
    /**
     * 从系统删除一个文件
     * @param id
     * @throws FileOperateException
     */
    void removeFile(String id) throws FileOperateException;
    
    /**
     * 设置使用文件系统存储文件时,根目录,如:d:/files/ or home/
     * @param rootPath
     */
    void setFileStoreRootPath(String rootPath);
    
    void setFileReader(FileReader reader);
}