use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class TemplateFilingRuleTest method testFilingPath_specialCharacters.
@Test
public void testFilingPath_specialCharacters() throws Exception {
NodeRef vfNodeRef = createVirtualizedFolder(testRootFolder.getNodeRef(), "Template 6 With Spaces", TEST_TEMPLATE_5_JSON_SYS_PATH);
NodeRef sfpNodeRef = nodeService.getChildByName(vfNodeRef, ContentModel.ASSOC_CONTAINS, "SpecialFilingPath4");
Reference sfpReference = Reference.fromNodeRef(sfpNodeRef);
ApplyTemplateMethod applyTemplateMethod = new ApplyTemplateMethod(environment);
VirtualFolderDefinition structure = sfpReference.execute(applyTemplateMethod);
FilingRule filingRule = structure.getFilingRule();
assertTrue(filingRule instanceof TemplateFilingRule);
NodeRef fn = filingRule.filingNodeRefFor(new FilingParameters(sfpReference));
assertNotNull(fn);
}
use of org.alfresco.repo.virtual.ref.Reference 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);
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualNodeServiceExtension method getChildAssocsWithoutParentAssocsOfType.
@Override
public Collection<ChildAssociationRef> getChildAssocsWithoutParentAssocsOfType(NodeRef nodeRef, QName assocTypeQName) {
NodeServiceTrait theTrait = getTrait();
boolean canVirtualize = canVirtualizeAssocNodeRef(nodeRef);
if (canVirtualize) {
Reference reference = smartStore.virtualize(nodeRef);
Collection<ChildAssociationRef> virtualAssociations = smartStore.getChildAssocsWithoutParentAssocsOfType(reference, assocTypeQName);
List<ChildAssociationRef> associations = new LinkedList<>(virtualAssociations);
if (smartStore.canMaterialize(reference)) {
NodeRef materialReference = smartStore.materialize(reference);
Collection<ChildAssociationRef> actualAssociations = theTrait.getChildAssocsWithoutParentAssocsOfType(materialReference, assocTypeQName);
associations.addAll(actualAssociations);
}
return associations;
} else {
return theTrait.getChildAssocsWithoutParentAssocsOfType(nodeRef, assocTypeQName);
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualNodeServiceExtension method getChildByName.
@Override
public NodeRef getChildByName(NodeRef nodeRef, QName assocTypeQName, String childName) {
if (smartStore.canVirtualize(nodeRef)) {
Reference virtualNode = smartStore.virtualize(nodeRef);
Reference theChild = smartStore.getChildByName(virtualNode, assocTypeQName, childName);
if (theChild != null) {
NodeRef childNodeRef = theChild.toNodeRef();
return childNodeRef;
}
if (smartStore.isVirtual(nodeRef)) {
return null;
}
}
// TODO: add virtualizable enabler
nodeRef = materializeIfPossible(nodeRef);
return getTrait().getChildByName(nodeRef, assocTypeQName, childName);
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualCheckOutCheckInServiceExtension method virtualizeOriginalIfNeeded.
private NodeRef virtualizeOriginalIfNeeded(NodeRef workingCopyNodeRef, NodeRef materialOriginalNode) {
Reference workingCopyReference = Reference.fromNodeRef(workingCopyNodeRef);
if ((materialOriginalNode != null) && (workingCopyReference != null)) {
Reference parentReference = workingCopyReference.execute(new GetParentReferenceMethod());
Reference originalReference = NodeProtocol.newReference(materialOriginalNode, parentReference);
return originalReference.toNodeRef(materialOriginalNode.getStoreRef());
} else {
return materialOriginalNode;
}
}
Aggregations