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;
}
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);
}
}
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);
}
}
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;
}
}
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;
}
Aggregations