如何使用DFC代码创建ACL

时间:2016-07-12 07:44:06

标签: documentum-dfc

请使用Documentum中的DFC代码发布代码示例以创建ACl(访问控制列表)。

谢谢, Asfaque

1 个答案:

答案 0 :(得分:0)

试试亲爱的朋友

  1. 主要课程

    public class Main {
    
        static LoginSession obj = null;
        static IDfSession idfSession = null;
    
        public static void main(String[] args) throws Exception {
            // TODO Auto-generated method stub
            String userName = "userName";
            String password = "password";
            String docbaseName = "repository";
    
            try {
                obj = new LoginSession();
                idfSession = obj.getDfSession(userName, password, docbaseName);         
    
                // Create ACL
                CreateACL createACL = new CreateACL();
                createACL.createACL(idfSession);        
    
    
            } finally {
                if (idfSession != null) {
                    obj.getiDfSessionManager().release(idfSession);
                    System.out.println("Session released");
                }
            }
        }
    }
    
  2. LoginSession

    public class LoginSession {
    private IDfSessionManager iDfSessionManager = null;
    private IDfSession idfsession = null;
    
    public IDfSessionManager getiDfSessionManager() {
        return iDfSessionManager;
    }
    
    public void setiDfSessionManager(IDfSessionManager iDfSessionManager) {
        this.iDfSessionManager = iDfSessionManager;
    }
    
    public IDfSession getIdfsession() {
        return idfsession;
    }
    
    public void setIdfsession(IDfSession idfsession) {
        this.idfsession = idfsession;
    }
    
    public IDfSession getDfSession(String userName, String password, String docbaseName) throws Exception {
        IDfLoginInfo loginInfo = new DfLoginInfo();
        loginInfo.setUser(userName);
        loginInfo.setPassword(password);
        IDfClient client = new DfClient();
    
        iDfSessionManager = client.newSessionManager();
        iDfSessionManager.setIdentity(docbaseName, loginInfo);
    
        idfsession = iDfSessionManager.getSession(docbaseName);
    
        if (idfsession != null)
        System.out.println("Session created successfully");
        return idfsession;
    }
    
    }
    
  3. ACL类

    public class CreateACL {
        String name = "bhuwan1_acl";
        String description = "bhuwan_acl_descrip";
    
        public void createACL(IDfSession idfSession) throws DfException {
            IDfACL acl = (IDfACL) idfSession.newObject("dm_acl");
            if (acl != null) {
                acl.setObjectName(name);
                acl.setDescription(description);
                acl.save();
            }
    
            IDfPermit permit = new DfPermit();
            if (permit != null) {
                permit.setAccessorName("Bhuwan User");
                permit.setPermitType(IDfPermit.DF_ACCESS_PERMIT);
                permit.setPermitValue(IDfACL.DF_PERMIT_READ_STR);
                acl.grantPermit(permit);
                acl.save();
            }
            System.out.println("ACL created");
        }
    }
    
相关问题