當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicPermissions類代碼示例

本文整理匯總了Java中org.apache.chemistry.opencmis.commons.BasicPermissions的典型用法代碼示例。如果您正苦於以下問題:Java BasicPermissions類的具體用法?Java BasicPermissions怎麽用?Java BasicPermissions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BasicPermissions類屬於org.apache.chemistry.opencmis.commons包,在下文中一共展示了BasicPermissions類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCreate

import org.apache.chemistry.opencmis.commons.BasicPermissions; //導入依賴的package包/類
public void testCreate()
{
    Session session = getSession("admin", "admin");
    
    String folderName = getRootFolderName();
    Folder root = session.getRootFolder();
    
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
    properties.put(PropertyIds.NAME, folderName);

    // create the folder
    Folder newFolder = root.createFolder(properties);
    
    for(int i = 0; i < 50; i++)
    {
        AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl("user"+i);
        List<String> permissions = new ArrayList<String>(1);
        permissions.add(BasicPermissions.READ);
        List<Ace> addAces = new ArrayList<Ace>(1);
        addAces.add(new AccessControlEntryImpl(principal, permissions));
        newFolder.addAcl(addAces, AclPropagation.PROPAGATE);
        
        Map<String, Object> updateProperties = new HashMap<String, Object>();
        updateProperties.put("cm:title", "Update title "+i);
        newFolder.updateProperties(properties);
        
        if(i % 10 == 0)
        {
            System.out.println("@ "+i);
        }
    }
    ItemIterable<QueryResult> result = session.query("select * from cmis:folder", false);
    assertTrue(result.getTotalNumItems() > 0);
    
    result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
    assertTrue(result.getTotalNumItems() > 0);
    
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:40,代碼來源:CMISDataCreatorTest.java

示例2: compileAcl

import org.apache.chemistry.opencmis.commons.BasicPermissions; //導入依賴的package包/類
/**
 * Compiles the ACL for a file or folder.
 */
private Acl compileAcl(File file) {
    AccessControlListImpl result = new AccessControlListImpl();
    result.setAces(new ArrayList<Ace>());

    for (Map.Entry<String, Boolean> ue : readWriteUserMap.entrySet()) {
        // create principal
        AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl(ue.getKey());

        // create ACE
        AccessControlEntryImpl entry = new AccessControlEntryImpl();
        entry.setPrincipal(principal);
        entry.setPermissions(new ArrayList<String>());
        entry.getPermissions().add(BasicPermissions.READ);
        if (!ue.getValue().booleanValue() && file.canWrite()) {
            entry.getPermissions().add(BasicPermissions.WRITE);
            entry.getPermissions().add(BasicPermissions.ALL);
        }

        entry.setDirect(true);

        // add ACE
        result.getAces().add(entry);
    }

    return result;
}
 
開發者ID:cmisdocs,項目名稱:ServerDevelopmentGuideV2,代碼行數:30,代碼來源:FileBridgeRepository.java

示例3: translatePermissionsFromCMIS

import org.apache.chemistry.opencmis.commons.BasicPermissions; //導入依賴的package包/類
private List<String> translatePermissionsFromCMIS(List<String> permissions)
{
    List<String> result = new ArrayList<String>();

    if (permissions == null)
    {
        return result;
    }

    for (String permission : permissions)
    {
        if (permission == null)
        {
            throw new CmisConstraintException("Invalid null permission!");
        }

        if (BasicPermissions.READ.equals(permission))
        {
            result.add(PermissionService.READ);
        }
        else if (BasicPermissions.WRITE.equals(permission))
        {
            result.add(PermissionService.WRITE);
        }
        else if (BasicPermissions.ALL.equals(permission))
        {
            result.add(PermissionService.ALL_PERMISSIONS);
        }
        else if (!permission.startsWith("{"))
        {
            result.add(permission);
        }
        else
        {
            int sepIndex = permission.lastIndexOf('.');
            if (sepIndex == -1)
            {
                result.add(permission);
            }
            else
            {
                result.add(permission.substring(sepIndex + 1));
            }
        }
    }

    return result;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:49,代碼來源:CMISConnector.java

示例4: testCreateLots

import org.apache.chemistry.opencmis.commons.BasicPermissions; //導入依賴的package包/類
public void testCreateLots() throws Exception
{
    Session session = getSession("admin", "admin");
    
    Folder root = session.getRootFolder();
    String folderNameBase = getRootFolderName();

    
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
    properties.put(PropertyIds.NAME, folderNameBase);
    
    Folder base = root.createFolder(properties);
    for(int i = 0; i < 10; i++)
    {
       AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl(""+i+i+i);
       List<String> permissions = new ArrayList<String>(1);
       permissions.add(BasicPermissions.ALL);
       List<Ace> addAces = new ArrayList<Ace>(1);
       addAces.add(new AccessControlEntryImpl(principal, permissions));
       base.addAcl(addAces, AclPropagation.PROPAGATE);
    }
    
    
    Thread last = null;
    
    for(int i = 0; i < 10; i++)
    {
        Creator creator = new Creator(base.getPath(), i);
        Thread thread = new Thread(creator);
        thread.start();
        last = thread;
    }
    
    if(last != null)
    {
        last.join();
    }
  
    ItemIterable<QueryResult> result = session.query("select * from cmis:folder", false);
    assertTrue(result.getTotalNumItems() > 0);
    
    //result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
    //assertTrue(result.getTotalNumItems() > 0);
    
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:47,代碼來源:CMISDataCreatorTest.java


注:本文中的org.apache.chemistry.opencmis.commons.BasicPermissions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。