lyh
2026-03-23 533ae8a2dc71edeff73f1e0c62d23718d3ff059b
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
package com.lxzn.activiti.service;
 
import com.eetrust.label.LabelOperator;
import com.lxzn.framework.exception.ExceptionCast;
import com.lxzn.framework.model.response.CommonCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
 
/**
 * @Description:
 * @Author: zhangherong
 * @Date: Created in 2021/5/26 16:17
 * @Version: 1.0
 * @Modified By:
 */
@Component
@Slf4j
public class SecureDocService {
    @Value("${securedoc.serverIp}")
    private String serverIp;
    @Value("${securedoc.serverPort}")
    private int serverPort;
    @Value("${securedoc.identifier}")
    private String identifier;
    @Value("${securedoc.binFileLabel}")
    private String binFileLabel;
    @Value("${securedoc.editFileLabel}")
    private String editFileLabel;
 
    public void binByFileLable(String fileName){
        LabelOperator labelOperator = new LabelOperator(serverIp,serverPort);
        //默认不开启  //fase 远程调用MB服务  //true 调用本地MB服务
        labelOperator.setLocalService(false);
        //设置本地工程编码格式(UTF_8、GBK),默认为UTF_8
        //labelOperator.setCharacter(CharacterEnums.UTF_8);
        short fileFrom = 0;
        int bindFileLabel = labelOperator.bindFileLabel(identifier, fileName , binFileLabel ,fileFrom);
        if(bindFileLabel == 0){
            log.info("文件预定密成功,{}", fileName);
        }else{
            ExceptionCast.cast(CommonCode.SECURE_DOC_BIN_LABEL_ERROR);
        }
    }
 
    public void editLabelByPath(String path){
        LabelOperator labelOperator = new LabelOperator(serverIp,serverPort);
        //设置本地工程编码格式(UTF_8、GBK),默认为UTF_8
        //labelOperator.setCharacter(CharacterEnums.UTF_8);
 
        //默认不开启  //fase 远程调用MB服务  //true 调用本地MB服务
        labelOperator.setLocalService(false);
        log.info("editFileLabel={},identifier={},path={}", editFileLabel, identifier, path);
        int modifyFileLabel = labelOperator.modifyFileLabel(identifier,path,editFileLabel);
        if(modifyFileLabel == 0){
            log.info("文件正式定密成功,{}", path);
        }else{
            ExceptionCast.cast(CommonCode.SECURE_DOC_EDIT_LABEL_ERROR);
        }
    }
}