Long aclID = nodeService.getNodeAclId(nodeRef); if(aclID == null)
Long aclID = nodeService.getNodeAclId(nodeRef); if(aclID == null)
@Override public Long execute() throws Throwable { // Create a user if (authenticationService.authenticationExists(USER_MNT11107)) authenticationService.deleteAuthentication(USER_MNT11107); if (personService.personExists(USER_MNT11107)) personService.deletePerson(USER_MNT11107); authenticationService.createAuthentication(USER_MNT11107, "PWD".toCharArray()); PropertyMap personProperties = new PropertyMap(); personProperties.put(ContentModel.PROP_USERNAME, USER_MNT11107); personProperties.put(ContentModel.PROP_AUTHORITY_DISPLAY_NAME, "title" + USER_MNT11107); personProperties.put(ContentModel.PROP_FIRSTNAME, "firstName"); personProperties.put(ContentModel.PROP_LASTNAME, "lastName"); personProperties.put(ContentModel.PROP_EMAIL, USER_MNT11107 + "@example.com"); personProperties.put(ContentModel.PROP_JOBTITLE, "jobTitle"); NodeRef person = personService.createPerson(personProperties); NodeRef testUserHomeFolder = (NodeRef) nodeService.getProperty(person, ContentModel.PROP_HOMEFOLDER); assertNotNull("testUserHomeFolder is null", testUserHomeFolder); Long aclIdForUserHomeFolder = nodeService.getNodeAclId(testUserHomeFolder); Long inheritedAclId = aclDaoComponent.getInheritedAccessControlList(aclIdForUserHomeFolder); return inheritedAclId; } });
assertTrue(publicServiceAccessService.hasAccess("PermissionService", "hasPermission", rootNodeRef, PermissionService.READ_PERMISSIONS) == AccessStatus.ALLOWED); assertTrue(publicServiceAccessService.hasAccess("PermissionService", "hasReadPermission", rootNodeRef) == AccessStatus.ALLOWED); assertTrue(publicServiceAccessService.hasAccess("PermissionService", "getReaders", nodeService.getNodeAclId(rootNodeRef)) == AccessStatus.ALLOWED); assertTrue(publicServiceAccessService.hasAccess("PermissionService", "getPermissions", rootNodeRef) == AccessStatus.ALLOWED); assertTrue(publicServiceAccessService.hasAccess("PermissionService", "getAllSetPermissions", rootNodeRef) == AccessStatus.ALLOWED); assertTrue(publicServiceAccessService.hasAccess("PermissionService", "hasPermission", rootNodeRef, PermissionService.READ_PERMISSIONS) == AccessStatus.ALLOWED); assertTrue(publicServiceAccessService.hasAccess("PermissionService", "hasReadPermission", rootNodeRef) == AccessStatus.ALLOWED); assertTrue(publicServiceAccessService.hasAccess("PermissionService", "getReaders", nodeService.getNodeAclId(rootNodeRef)) == AccessStatus.DENIED); assertTrue(publicServiceAccessService.hasAccess("PermissionService", "getPermissions", rootNodeRef) == AccessStatus.DENIED); assertTrue(publicServiceAccessService.hasAccess("PermissionService", "getAllSetPermissions", rootNodeRef) == AccessStatus.DENIED);
NodeRef n2 = nodeService.createNode(n1, ContentModel.ASSOC_CONTAINS, QName.createQName("{namespace}two"), ContentModel.TYPE_FOLDER).getChildRef(); Long aclID = nodeService.getNodeAclId(n1); PermissionContext context = new PermissionContext(QName.createQName("{namespace}one")); assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(aclID, context, PermissionService.ALL_PERMISSIONS));