ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
package com.vci.server.volume.uitls;
 
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
 
 
public class VolumeProperties {
    private static String fileName = "properties/volume.properties";
    private static Properties confProperties = null;
 
    static {
        try {
            File file = new File(fileName);
            if (file.exists()) {
                FileInputStream confPropertiesStream = new FileInputStream(fileName);
                confProperties = new Properties();
                confProperties.load(confPropertiesStream);
            }
            else
            {
                VolumeWithLog4j.logger.error("没找到卷配置文件:" + file.getPath());
            }
        } catch(Exception ee) {
            ee.printStackTrace();
            VolumeWithLog4j.logger.error("初始化卷配置文件出错,请检查文件后重新启动", ee);
        }
    }
    
 
    /*
     * 获取指定项卷服务名称
     */
    public static String VolumeServiceName()
    {
        String strKey = "volume.service.name";
        return getStrPro(strKey);
    }
 
 
    public static int blockLength(){
        int size =  getIntPro("blockLength");
        if (size <= 0)
            size = 32;
        
        return size;
    }
    
    public static boolean isFileEncry(){
        String encry = getStrPro("isFileEncry");
        if (encry.compareToIgnoreCase("true") == 0){
            return true;
        }
        return false;
    }
    
    public static boolean isReadOnly(){
        String encry = getStrPro("isReadOnly");
        if (encry.compareToIgnoreCase("true") == 0){
            return true;
        }
        return false;
    }
    
    public static int historyCopyCount(){
        return getIntPro("historyCopyCount");
    }
    
 
    /*
     * 私有方法,获取字符创配置
     */
    private static String getStrPro(String key){
        String rs = null;
        try{
            if (confProperties != null){
                rs = confProperties.getProperty(key);
            }
        }catch(Exception e){
            rs = "";
        } finally {
            if (rs == null) {
                rs = "";
            }
        }
        return rs;
    }
    
    private static int getIntPro(String key){
        try{
            return Integer.valueOf(getStrPro(key)).intValue();
        }catch(Exception e){
            return -1;
        }
    }
 
}