ludc
2024-09-06 c67c8367ae83ad8304212f532994eb04e2fc215e
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
package com.vci.web.other;
 
import com.vci.corba.common.PLException;
 
import java.util.HashMap;
import java.util.Map;
 
/**
 * 下载文件的线程存储的信息
 */
public class VciFileDownloadInfo {
 
    static final Object syncObject = new Object();
 
    private static Map<String,Map<String,String>> downloadFileInfo = new HashMap<String, Map<String,String>>();
 
    /**
     * 添加信息
     * @param clientPath 临时文件夹的信息
     * @param fileOid 文件主键
     * @param errorInfo 错误信息
     */
    public  static void addDownloadFileInfo(String clientPath,String fileOid,String errorInfo){
        synchronized (syncObject) {
            Map<String,String> errorMap = new HashMap<String, String>();
            if(downloadFileInfo.containsKey(clientPath)){
                errorMap = downloadFileInfo.get(clientPath);
            }
            errorMap.put(fileOid,errorInfo);
            downloadFileInfo.put(clientPath, errorMap);
        }
    }
 
 
 
    /**
     * 移除错误信息
     * @param clientPath 临时文件夹的信息
     */
    public  static void removeDownloadFileInfo(String clientPath){
        synchronized (syncObject){
            downloadFileInfo.remove(clientPath);
        }
    }
 
    /**
     * 获取错误信息
     * @param clientPath 临时文件夹的信息
     * @return
     */
    public static Map<String,String> getDownloadFileInfo(String clientPath){
        return downloadFileInfo.get(clientPath);
    }
 
    /**
     * 是否有错误信息
     * @param clientPath
     * @return
     */
    public static boolean isHasErrorInfo(String clientPath){
        synchronized (syncObject){
            return downloadFileInfo.containsKey(clientPath);
        }
    }
 
    public static void getDownloadErrorInfo(String clientPath) throws PLException {
        Map<String,String> errorMap = getDownloadFileInfo(clientPath);
        String errorMsg = "";
        String[] errorArray = errorMap.values().toArray(new String[0]);
        VciFileDownloadInfo.removeDownloadFileInfo(clientPath);
        errorMsg = errorArray[0] +(errorArray.length>1?(";另有" + errorArray.length + "个文件也出现了错误"):"");
        throw new PLException(errorMsg,errorArray);
    }
 
}