Search in sources :

Example 6 with GetActualNodeRefMethod

use of org.alfresco.repo.virtual.ref.GetActualNodeRefMethod in project alfresco-repository by Alfresco.

the class VirtualStoreImpl method nodeProtocolNodeRef.

private NodeRef nodeProtocolNodeRef(NodeRef nodeRef) throws ProtocolMethodException, ReferenceParseException, ReferenceEncodingException {
    NodeRef theNodeRef = nodeRef;
    Reference ref = Reference.fromNodeRef(theNodeRef);
    if (ref != null) {
        if (Protocols.NODE.protocol.equals(ref.getProtocol())) {
            theNodeRef = ref.execute(new GetActualNodeRefMethod(environment));
        }
    }
    return theNodeRef;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) Reference(org.alfresco.repo.virtual.ref.Reference) GetActualNodeRefMethod(org.alfresco.repo.virtual.ref.GetActualNodeRefMethod)

Example 7 with GetActualNodeRefMethod

use of org.alfresco.repo.virtual.ref.GetActualNodeRefMethod in project alfresco-repository by Alfresco.

the class VirtualNodeServiceExtension method getPrimaryParent.

@Override
public ChildAssociationRef getPrimaryParent(NodeRef nodeRef) {
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference != null) {
        Reference parent = reference.execute(new GetParentReferenceMethod());
        if (parent == null) {
            return getTrait().getPrimaryParent(reference.execute(new GetActualNodeRefMethod(environment)));
        } else {
            Reference parentsParent = parent.execute(new GetParentReferenceMethod());
            NodeRef parentNodeRef = parent.toNodeRef();
            if (parentsParent == null) {
                parentNodeRef = parent.execute(new GetActualNodeRefMethod(environment));
            }
            NodeRef referenceNodeRef = reference.toNodeRef();
            Map<QName, Serializable> refProperties = smartStore.getProperties(reference);
            Serializable childName = refProperties.get(ContentModel.PROP_NAME);
            QName childAssocQName = QName.createQNameWithValidLocalName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI, childName.toString());
            ChildAssociationRef assoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, parentNodeRef, childAssocQName, referenceNodeRef, true, -1);
            return assoc;
        }
    } else {
        return getTrait().getPrimaryParent(nodeRef);
    }
}
Also used : GetParentReferenceMethod(org.alfresco.repo.virtual.ref.GetParentReferenceMethod) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) Reference(org.alfresco.repo.virtual.ref.Reference) QName(org.alfresco.service.namespace.QName) GetActualNodeRefMethod(org.alfresco.repo.virtual.ref.GetActualNodeRefMethod) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 8 with GetActualNodeRefMethod

use of org.alfresco.repo.virtual.ref.GetActualNodeRefMethod in project alfresco-repository by Alfresco.

the class GetPathMethod method execute.

@Override
public Path execute(VirtualProtocol virtualProtocol, Reference reference) throws ProtocolMethodException {
    try {
        NodeRef actualNodeRef = reference.execute(new GetActualNodeRefMethod(environment));
        Path path = null;
        if (actualNodeRef == null) {
            // Although not a feature yet, pure-virtual-references should
            // use an empty path as root since pure-virtual-references have
            // no actual peer to use.
            path = new Path();
        } else {
            path = environment.getPath(actualNodeRef);
        }
        Path virtualPath = smartStore.getPath(reference);
        return path.append(virtualPath);
    } catch (ReferenceEncodingException e) {
        throw new ProtocolMethodException(e);
    }
}
Also used : Path(org.alfresco.service.cmr.repository.Path) NodeRef(org.alfresco.service.cmr.repository.NodeRef) ProtocolMethodException(org.alfresco.repo.virtual.ref.ProtocolMethodException) ReferenceEncodingException(org.alfresco.repo.virtual.ref.ReferenceEncodingException) GetActualNodeRefMethod(org.alfresco.repo.virtual.ref.GetActualNodeRefMethod)

Example 9 with GetActualNodeRefMethod

use of org.alfresco.repo.virtual.ref.GetActualNodeRefMethod in project alfresco-repository by Alfresco.

the class VirtualStoreImpl method getProperties.

@Override
public Map<QName, Serializable> getProperties(Reference reference) throws VirtualizationException {
    final Protocol protocol = reference.getProtocol();
    if (Protocols.VIRTUAL.protocol.equals(protocol) || Protocols.VANILLA.protocol.equals(protocol)) {
        VirtualFolderDefinition folderDefinition = resolveVirtualFolderDefinition(reference);
        Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
        // We first set default property values. They might be overridden by
        // folder definition properties.
        properties.put(ContentModel.PROP_NAME, folderDefinition.getName());
        StoreRef storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
        properties.put(ContentModel.PROP_STORE_IDENTIFIER, storeRef.getIdentifier());
        properties.put(ContentModel.PROP_STORE_PROTOCOL, storeRef.getProtocol());
        properties.put(ContentModel.PROP_LOCALE, Locale.UK.toString());
        properties.put(ContentModel.PROP_MODIFIED, new Date());
        properties.put(ContentModel.PROP_MODIFIER, AuthenticationUtil.SYSTEM_USER_NAME);
        properties.put(ContentModel.PROP_CREATED, new Date());
        properties.put(ContentModel.PROP_CREATOR, AuthenticationUtil.SYSTEM_USER_NAME);
        properties.put(ContentModel.PROP_NODE_DBID, 0);
        properties.put(ContentModel.PROP_DESCRIPTION, folderDefinition.getDescription());
        // ACE-5303 : ContentModel.PROP_TITLE remains unset
        // We add virtual folder definition structure properties. They might
        // override the above defaults.
        Map<String, String> nodeProperties = folderDefinition.getProperties();
        if (nodeProperties != null) {
            Set<Entry<String, String>> propertyEntries = nodeProperties.entrySet();
            NamespacePrefixResolver nsPrefixResolver = environment.getNamespacePrefixResolver();
            for (Entry<String, String> propertyValueEntry : propertyEntries) {
                QName propertyQName = QName.createQName(propertyValueEntry.getKey(), nsPrefixResolver);
                properties.put(propertyQName, propertyValueEntry.getValue().toString());
            }
        }
        return properties;
    } else {
        NodeRef actual = reference.execute(new GetActualNodeRefMethod(environment));
        Map<QName, Serializable> properties = environment.getProperties(actual);
        properties.put(VirtualContentModel.PROP_ACTUAL_NODE_REF, actual.toString());
        return properties;
    }
}
Also used : StoreRef(org.alfresco.service.cmr.repository.StoreRef) Serializable(java.io.Serializable) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) Date(java.util.Date) NodeRef(org.alfresco.service.cmr.repository.NodeRef) NodePermissionEntry(org.alfresco.repo.security.permissions.NodePermissionEntry) Entry(java.util.Map.Entry) NamespacePrefixResolver(org.alfresco.service.namespace.NamespacePrefixResolver) GetActualNodeRefMethod(org.alfresco.repo.virtual.ref.GetActualNodeRefMethod) Protocol(org.alfresco.repo.virtual.ref.Protocol) VirtualFolderDefinition(org.alfresco.repo.virtual.template.VirtualFolderDefinition)

Example 10 with GetActualNodeRefMethod

use of org.alfresco.repo.virtual.ref.GetActualNodeRefMethod in project alfresco-repository by Alfresco.

the class GetChildAssocsMethod method execute.

@Override
public List<ChildAssociationRef> execute(NodeProtocol protocol, Reference reference) throws ProtocolMethodException {
    NodeRef actualNodeRef = reference.execute(new GetActualNodeRefMethod(null));
    NodeRef nodeRefReference = reference.toNodeRef();
    List<ChildAssociationRef> referenceAssociations = new LinkedList<>();
    if (!environment.isSubClass(environment.getType(nodeRefReference), ContentModel.TYPE_FOLDER)) {
        List<ChildAssociationRef> actualAssociations = environment.getChildAssocs(actualNodeRef, typeQNamePattern, qnamePattern, maxResults, preload);
        for (ChildAssociationRef actualAssoc : actualAssociations) {
            ChildAssociationRef referenceChildAssocRef = new ChildAssociationRef(actualAssoc.getTypeQName(), nodeRefReference, actualAssoc.getQName(), actualAssoc.getChildRef(), actualAssoc.isPrimary(), actualAssoc.getNthSibling());
            referenceAssociations.add(referenceChildAssocRef);
        }
    }
    return referenceAssociations;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) GetActualNodeRefMethod(org.alfresco.repo.virtual.ref.GetActualNodeRefMethod) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) LinkedList(java.util.LinkedList)

Aggregations

GetActualNodeRefMethod (org.alfresco.repo.virtual.ref.GetActualNodeRefMethod)12 NodeRef (org.alfresco.service.cmr.repository.NodeRef)12 Reference (org.alfresco.repo.virtual.ref.Reference)8 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)5 Serializable (java.io.Serializable)4 QName (org.alfresco.service.namespace.QName)4 VirtualizationIntegrationTest (org.alfresco.repo.virtual.VirtualizationIntegrationTest)3 Test (org.junit.Test)3 GetParentReferenceMethod (org.alfresco.repo.virtual.ref.GetParentReferenceMethod)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Entry (java.util.Map.Entry)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 NodeServiceTrait (org.alfresco.repo.node.db.traitextender.NodeServiceTrait)1 NodePermissionEntry (org.alfresco.repo.security.permissions.NodePermissionEntry)1 PermissionReference (org.alfresco.repo.security.permissions.PermissionReference)1 VirtualizationException (org.alfresco.repo.virtual.VirtualizationException)1