use of org.alfresco.repo.virtual.template.VirtualFolderDefinition in project alfresco-repository by Alfresco.
the class GetAllSetPermissionsMethod method execute.
@Override
public Set<AccessPermission> execute(VirtualProtocol virtualProtocol, Reference reference) throws ProtocolMethodException {
Set<String> toAllow = userPermissions.getAllowSmartNodes();
Set<String> toDeny = userPermissions.getDenySmartNodes();
VirtualFolderDefinition definition = resolver.resolveVirtualFolderDefinition(reference);
FilingRule filingRule = definition.getFilingRule();
boolean readonly = filingRule.isNullFilingRule() || filingRule.filingNodeRefFor(new FilingParameters(reference)) == null;
if (readonly) {
Set<String> deniedPermissions = userPermissions.getDenyReadonlySmartNodes();
toDeny = new HashSet<>(toDeny);
toDeny.addAll(deniedPermissions);
toAllow.add(PermissionService.READ);
}
return execute(reference, toAllow, toDeny);
}
use of org.alfresco.repo.virtual.template.VirtualFolderDefinition in project alfresco-repository by Alfresco.
the class HasPermissionMethod method execute.
@Override
public AccessStatus execute(VirtualProtocol virtualProtocol, Reference reference) throws ProtocolMethodException {
VirtualFolderDefinition definition = resolver.resolveVirtualFolderDefinition(reference);
FilingRule filingRule = definition.getFilingRule();
boolean readonly = filingRule.isNullFilingRule() || filingRule.filingNodeRefFor(new FilingParameters(reference)) == null;
if (readonly) {
Set<String> deniedPermissions = userPermissions.getDenyReadonlySmartNodes();
if (deniedPermissions.contains(permissionToCheck)) {
return AccessStatus.DENIED;
}
if (PermissionService.READ.equals(permissionToCheck)) {
return AccessStatus.ALLOWED;
}
}
return userPermissions.hasVirtualNodePermission(permissionToCheck, readonly);
}
use of org.alfresco.repo.virtual.template.VirtualFolderDefinition in project alfresco-repository by Alfresco.
the class VirtualStoreImpl method resolveVirtualFolderDefinition.
public VirtualFolderDefinition resolveVirtualFolderDefinition(final Reference reference) throws VirtualizationException {
ServiceRegistry serviceRegistry = ((AlfrescoEnviroment) environment).getServiceRegistry();
RetryingTransactionHelper transactionHelper = serviceRegistry.getRetryingTransactionHelper();
return transactionHelper.doInTransaction(new RetryingTransactionCallback<VirtualFolderDefinition>() {
@Override
public VirtualFolderDefinition execute() throws Throwable {
NodeRef key = reference.toNodeRef();
Map<NodeRef, VirtualFolderDefinition> definitionsCache = TransactionalResourceHelper.getMap(VIRTUAL_FOLDER_DEFINITION);
VirtualFolderDefinition virtualFolderDefinition = definitionsCache.get(key);
if (virtualFolderDefinition == null) {
virtualFolderDefinition = reference.execute(new ApplyTemplateMethod(environment));
definitionsCache.put(key, virtualFolderDefinition);
}
return virtualFolderDefinition;
}
}, true, false);
}
use of org.alfresco.repo.virtual.template.VirtualFolderDefinition in project alfresco-repository by Alfresco.
the class VirtualStoreImpl method createChildReferences.
private List<Reference> createChildReferences(Reference parent, VirtualFolderDefinition structure) throws ProtocolMethodException {
List<VirtualFolderDefinition> structureChildren = structure.getChildren();
List<Reference> childReferences = new LinkedList<Reference>();
for (VirtualFolderDefinition child : structureChildren) {
childReferences.add(parent.execute(new GetChildByIdMethod(child.getId())));
}
return childReferences;
}
use of org.alfresco.repo.virtual.template.VirtualFolderDefinition in project alfresco-repository by Alfresco.
the class VirtualStoreImpl method list.
@Override
public List<Reference> list(Reference reference) throws VirtualizationException {
VirtualFolderDefinition structure = resolveVirtualFolderDefinition(reference);
List<Reference> result = createChildReferences(reference, structure);
final VirtualQuery query = structure.getQuery();
if (query != null) {
PagingResults<Reference> queryNodes = query.perform(environment, new FilesFoldersConstraint(BasicConstraint.INSTANCE, true, true), null, reference);
result.addAll(queryNodes.getPage());
}
return result;
}
Aggregations