zhuhongyu
2025-04-16 ad59479f9664b86cca6f408614762e565cc3336d
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
package tech.aiflowy.common.filestorage;
 
import com.amazonaws.services.s3.model.CannedAccessControlList;
 
 
/**
 * 桶访问策略配置
 *
 */
public enum AccessPolicyType {
 
    /**
     * private
     */
    PRIVATE(0, CannedAccessControlList.Private, PolicyType.WRITE),
 
    /**
     * public
     */
    PUBLIC(1, CannedAccessControlList.PublicRead, PolicyType.READ),
 
    /**
     * custom
     */
    CUSTOM(2, CannedAccessControlList.PublicRead, PolicyType.READ);
 
    /**
     * 桶 权限类型
     */
    private final Integer type;
 
    /**
     * 文件对象 权限类型
     */
    private final CannedAccessControlList acl;
 
    AccessPolicyType(Integer type, CannedAccessControlList acl, PolicyType policyType) {
        this.type = type;
        this.acl = acl;
        this.policyType = policyType;
    }
 
    /**
     * 桶策略类型
     */
    private final PolicyType policyType;
 
    public Integer getType() {
        return type;
    }
 
    public CannedAccessControlList getAcl() {
        return acl;
    }
 
    public PolicyType getPolicyType() {
        return policyType;
    }
 
    public static AccessPolicyType getByType(Integer type) {
        for (AccessPolicyType value : values()) {
            if (value.getType().equals(type)) {
                return value;
            }
        }
        return PUBLIC;
    }
 
}