当前位置: 首页>>代码示例>>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;未经允许,请勿转载。