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);
|
}
|
|
}
|