Search in sources :

Example 11 with VirtualFolderDefinition

use of org.alfresco.repo.virtual.template.VirtualFolderDefinition in project alfresco-repository by Alfresco.

the class VirtualStoreImpl method getPath.

@Override
public Path getPath(Reference reference) throws VirtualizationException {
    Reference virtualPathElement = reference;
    Reference virtualPathParent = reference.execute(new GetParentReferenceMethod());
    Path virtualPath = new Path();
    while (virtualPathElement != null && virtualPathParent != null) {
        NodeRef parentNodeRef;
        parentNodeRef = virtualPathParent.toNodeRef();
        NodeRef parent = parentNodeRef;
        NodeRef virtualPathNodeRef = virtualPathElement.toNodeRef();
        // TODO: extract node reference name into protocol method in order
        // to enforce path processing code reuse and consistency
        String templatePath = virtualPathElement.execute(new GetTemplatePathMethod()).trim();
        final String pathSeparator = "/";
        if (pathSeparator.equals(templatePath)) {
            // found root
            break;
        } else if (templatePath.endsWith(pathSeparator)) {
            templatePath = templatePath.substring(0, templatePath.length() - 1);
        }
        int lastSeparator = templatePath.lastIndexOf(pathSeparator);
        String childId = templatePath.substring(lastSeparator + 1);
        VirtualFolderDefinition structure = resolveVirtualFolderDefinition(virtualPathParent);
        VirtualFolderDefinition child = structure.findChildById(childId);
        if (child == null) {
            throw new VirtualizationException("Invalid reference: " + reference.encode());
        }
        String childName = child.getName();
        QName childQName = QName.createQName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI, childName);
        ChildAssociationRef assocRef = new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, parent, childQName, virtualPathNodeRef, true, -1);
        ChildAssocElement assocRefElement = new ChildAssocElement(assocRef);
        virtualPath.prepend(assocRefElement);
        virtualPathElement = virtualPathParent;
        virtualPathParent = virtualPathParent.execute(new GetParentReferenceMethod());
    }
    return virtualPath;
}
Also used : GetParentReferenceMethod(org.alfresco.repo.virtual.ref.GetParentReferenceMethod) Path(org.alfresco.service.cmr.repository.Path) NodeRef(org.alfresco.service.cmr.repository.NodeRef) GetTemplatePathMethod(org.alfresco.repo.virtual.ref.GetTemplatePathMethod) ChildAssocElement(org.alfresco.service.cmr.repository.Path.ChildAssocElement) PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) Reference(org.alfresco.repo.virtual.ref.Reference) QName(org.alfresco.service.namespace.QName) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) NamePatternPropertyValueConstraint(org.alfresco.repo.virtual.template.NamePatternPropertyValueConstraint) PropertyValueConstraint(org.alfresco.repo.virtual.template.PropertyValueConstraint) FilesFoldersConstraint(org.alfresco.repo.virtual.template.FilesFoldersConstraint) VirtualQueryConstraint(org.alfresco.repo.virtual.template.VirtualQueryConstraint) BasicConstraint(org.alfresco.repo.virtual.template.BasicConstraint) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition) VirtualizationException(org.alfresco.repo.virtual.VirtualizationException)

Example 12 with VirtualFolderDefinition

use of org.alfresco.repo.virtual.template.VirtualFolderDefinition in project alfresco-repository by Alfresco.

the class GetSetPermissionsMethod method execute.

@Override
public NodePermissionEntry 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)

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