Java Code Examples for org.alfresco.service.cmr.security.PermissionService#CREATE_CHILDREN

The following examples show how to use org.alfresco.service.cmr.security.PermissionService#CREATE_CHILDREN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VirtualPermissionServiceExtensionTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testReadonlyNodeHasPermission() throws Exception
{

    // virtual permission should override actual permissions
    NodeRef aVFTestTemplate2 = createVirtualizedFolder(testRootFolder.getNodeRef(),
                                                       "aVFTestTemplate2",
                                                       TEST_TEMPLATE_2_JSON_SYS_PATH);
    NodeRef vf2Node2 = nodeService.getChildByName(aVFTestTemplate2,
                                                  ContentModel.ASSOC_CONTAINS,
                                                  "Node2");

    final String[] deniedReadOnly = new String[] { PermissionService.UNLOCK, PermissionService.CANCEL_CHECK_OUT,
                PermissionService.CHANGE_PERMISSIONS, PermissionService.CREATE_CHILDREN, PermissionService.DELETE,
                PermissionService.WRITE, PermissionService.DELETE_NODE, PermissionService.WRITE_PROPERTIES,
                PermissionService.WRITE_CONTENT, PermissionService.CREATE_ASSOCIATIONS };

    StringBuilder nonDeniedTrace = new StringBuilder();
    for (int i = 0; i < deniedReadOnly.length; i++)
    {
        AccessStatus accessStatus = hasPermissionAs(vf2Node2,
                                                    deniedReadOnly[i],
                                                    user1);
        if (!AccessStatus.DENIED.equals(accessStatus))
        {
            if (nonDeniedTrace.length() > 0)
            {
                nonDeniedTrace.append(",");
            }
            nonDeniedTrace.append(deniedReadOnly[i]);
        }
    }

    assertTrue("Non-denied permissions on RO virtual nodes : " + nonDeniedTrace,
               nonDeniedTrace.length() == 0);
}