Search in sources :

Example 1 with VirtualFolderDefinition

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);
}
Also used : FilingParameters(org.alfresco.repo.virtual.template.FilingParameters) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition) FilingRule(org.alfresco.repo.virtual.template.FilingRule)

Example 2 with VirtualFolderDefinition

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);
}
Also used : FilingParameters(org.alfresco.repo.virtual.template.FilingParameters) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition) FilingRule(org.alfresco.repo.virtual.template.FilingRule)

Example 3 with VirtualFolderDefinition

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);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) ApplyTemplateMethod(org.alfresco.repo.virtual.template.ApplyTemplateMethod) ServiceRegistry(org.alfresco.service.ServiceRegistry) AlfrescoEnviroment(org.alfresco.repo.virtual.AlfrescoEnviroment) Map(java.util.Map) HashMap(java.util.HashMap) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition)

Example 4 with VirtualFolderDefinition

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;
}
Also used : PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) Reference(org.alfresco.repo.virtual.ref.Reference) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition) LinkedList(java.util.LinkedList) GetChildByIdMethod(org.alfresco.repo.virtual.ref.GetChildByIdMethod)

Example 5 with VirtualFolderDefinition

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;
}
Also used : VirtualQuery(org.alfresco.repo.virtual.template.VirtualQuery) PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) Reference(org.alfresco.repo.virtual.ref.Reference) FilesFoldersConstraint(org.alfresco.repo.virtual.template.FilesFoldersConstraint) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition)

Aggregations

VirtualFolderDefinition (org.alfresco.repo.virtual.template.VirtualFolderDefinition)12 PermissionReference (org.alfresco.repo.security.permissions.PermissionReference)6 Reference (org.alfresco.repo.virtual.ref.Reference)6 FilesFoldersConstraint (org.alfresco.repo.virtual.template.FilesFoldersConstraint)4 FilingParameters (org.alfresco.repo.virtual.template.FilingParameters)4 FilingRule (org.alfresco.repo.virtual.template.FilingRule)4 VirtualQuery (org.alfresco.repo.virtual.template.VirtualQuery)4 NamePatternPropertyValueConstraint (org.alfresco.repo.virtual.template.NamePatternPropertyValueConstraint)3 NodeRef (org.alfresco.service.cmr.repository.NodeRef)3 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 VirtualizationException (org.alfresco.repo.virtual.VirtualizationException)2 GetChildByIdMethod (org.alfresco.repo.virtual.ref.GetChildByIdMethod)2 PropertyValueConstraint (org.alfresco.repo.virtual.template.PropertyValueConstraint)2 VirtualQueryConstraint (org.alfresco.repo.virtual.template.VirtualQueryConstraint)2 QName (org.alfresco.service.namespace.QName)2 Serializable (java.io.Serializable)1 Date (java.util.Date)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1