use of org.alfresco.service.cmr.security.AccessPermission in project alfresco-repository by Alfresco.
the class PermissionServiceImpl method getAllSetPermissions.
@Override
@Extend(traitAPI = PermissionServiceTrait.class, extensionAPI = PermissionServiceExtension.class)
public Set<AccessPermission> getAllSetPermissions(NodeRef nodeRef) {
HashSet<AccessPermission> accessPermissions = new HashSet<AccessPermission>();
NodePermissionEntry nodePremissionEntry = getSetPermissions(nodeRef);
for (PermissionEntry pe : nodePremissionEntry.getPermissionEntries()) {
accessPermissions.add(new AccessPermissionImpl(getPermission(pe.getPermissionReference()), pe.getAccessStatus(), pe.getAuthority(), pe.getPosition()));
}
return accessPermissions;
}
use of org.alfresco.service.cmr.security.AccessPermission in project alfresco-repository by Alfresco.
the class PermissionServiceImpl method getAllSetPermissions.
@Override
@Extend(traitAPI = PermissionServiceTrait.class, extensionAPI = PermissionServiceExtension.class)
public Set<AccessPermission> getAllSetPermissions(StoreRef storeRef) {
HashSet<AccessPermission> accessPermissions = new HashSet<AccessPermission>();
NodePermissionEntry nodePremissionEntry = getSetPermissions(storeRef);
for (PermissionEntry pe : nodePremissionEntry.getPermissionEntries()) {
accessPermissions.add(new AccessPermissionImpl(getPermission(pe.getPermissionReference()), pe.getAccessStatus(), pe.getAuthority(), pe.getPosition()));
}
return accessPermissions;
}
use of org.alfresco.service.cmr.security.AccessPermission in project alfresco-repository by Alfresco.
the class SiteServiceImplTest method getAllowedPermissionsMap.
/**
* Gets the authorities and their allowed permissions for a node
*/
private Map<String, Set<String>> getAllowedPermissionsMap(NodeRef nodeRef) {
Map<String, Set<String>> perms = new HashMap<String, Set<String>>();
for (AccessPermission ap : permissionService.getAllSetPermissions(nodeRef)) {
if (ap.getAccessStatus() == AccessStatus.ALLOWED) {
Set<String> permsValue = perms.get(ap.getAuthority());
if (permsValue == null) {
permsValue = new HashSet<String>();
}
permsValue.add(ap.getPermission());
perms.put(ap.getAuthority(), permsValue);
}
}
return perms;
}
use of org.alfresco.service.cmr.security.AccessPermission in project alfresco-repository by Alfresco.
the class VirtualPermissionServiceExtension method getPermissions.
@Override
public Set<AccessPermission> getPermissions(NodeRef nodeRef) {
PermissionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
return theTrait.getPermissions(nodeRef);
} else {
Set<AccessPermission> virtualSetPermissions = smartStore.getAllSetPermissions(reference);
NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
Set<AccessPermission> mergedEntries = new HashSet<>(virtualSetPermissions);
if (nodeToAdhereTo != null) {
Set<AccessPermission> actualSetPermissions = theTrait.getPermissions(nodeToAdhereTo);
mergedEntries.addAll(actualSetPermissions);
}
return mergedEntries;
}
}
use of org.alfresco.service.cmr.security.AccessPermission in project alfresco-repository by Alfresco.
the class VirtualPermissionServiceExtension method getAllSetPermissions.
@Override
public Set<AccessPermission> getAllSetPermissions(NodeRef nodeRef) {
PermissionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
return theTrait.getAllSetPermissions(nodeRef);
} else {
Set<AccessPermission> virtualSetPermissions = smartStore.getAllSetPermissions(reference);
NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
Set<AccessPermission> actualSetPermissions;
if (nodeToAdhereTo != null) {
actualSetPermissions = theTrait.getAllSetPermissions(nodeToAdhereTo);
} else {
actualSetPermissions = Collections.emptySet();
}
Set<String> overridenPermissions = new HashSet<>();
Set<AccessPermission> mergedEntries = new HashSet<>();
for (AccessPermission permission : virtualSetPermissions) {
overridenPermissions.add(permission.getPermission());
mergedEntries.add(permission);
}
for (AccessPermission permission : actualSetPermissions) {
if (!overridenPermissions.contains(permission.getPermission())) {
mergedEntries.add(permission);
}
}
return mergedEntries;
}
}
Aggregations