use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualVersionServiceExtension method virtualizeVersion.
private Version virtualizeVersion(Reference versionedReference, Version actualVersion) {
if (actualVersion == null) {
return null;
}
NodeRef frozenStateNodeRef = actualVersion.getFrozenStateNodeRef();
StoreRef frozenStoreRef = frozenStateNodeRef.getStoreRef();
Reference parentReference = versionedReference.execute(new GetParentReferenceMethod());
Reference virtualFrozenReference = NodeProtocol.newReference(frozenStateNodeRef, parentReference);
Map<String, Serializable> properties = actualVersion.getVersionProperties();
Map<String, Serializable> virtualProperties = new HashMap<String, Serializable>(properties);
// Switch VersionStore depending on configured impl
if (frozenStoreRef.getIdentifier().equals(Version2Model.STORE_ID)) {
// V2 version store (eg. workspace://version2Store)
NodeRef propFrozenNodeRef = (NodeRef) virtualProperties.get(Version2Model.PROP_FROZEN_NODE_REF);
Reference virtualPropFrozenReference = NodeProtocol.newReference(propFrozenNodeRef, parentReference);
virtualProperties.put(Version2Model.PROP_FROZEN_NODE_REF, virtualPropFrozenReference.toNodeRef(propFrozenNodeRef.getStoreRef()));
} else if (frozenStoreRef.getIdentifier().equals(VersionModel.STORE_ID)) {
// Deprecated V1 version store (eg.
// workspace://lightWeightVersionStore)
String frozenNodeStoreProtocol = (String) virtualProperties.get(VersionModel.PROP_FROZEN_NODE_STORE_PROTOCOL);
String frozenNodeStoreId = (String) virtualProperties.get(VersionModel.PROP_FROZEN_NODE_STORE_ID);
String frozenNodeId = (String) virtualProperties.get(VersionModel.PROP_FROZEN_NODE_ID);
StoreRef propFrozenStoreRef = new StoreRef(frozenNodeStoreProtocol, frozenNodeStoreId);
NodeRef propFrozenNode = new NodeRef(propFrozenStoreRef, frozenNodeId);
Reference virtualPropFrozenReference = NodeProtocol.newReference(propFrozenNode, parentReference);
NodeRef virtualPropFrozenNodeRef = virtualPropFrozenReference.toNodeRef(propFrozenStoreRef);
virtualProperties.put(VersionModel.PROP_FROZEN_NODE_STORE_PROTOCOL, propFrozenStoreRef.getProtocol());
virtualProperties.put(VersionModel.PROP_FROZEN_NODE_STORE_ID, propFrozenStoreRef.getIdentifier());
virtualProperties.put(VersionModel.PROP_FROZEN_NODE_ID, virtualPropFrozenNodeRef.getId());
}
return new VersionImpl(virtualProperties, virtualFrozenReference.toNodeRef(frozenStateNodeRef.getStoreRef()));
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualVersionServiceExtension method createVersion.
@Override
public Version createVersion(NodeRef nodeRef, Map<String, Serializable> versionProperties) throws ReservedVersionNameException, AspectMissingException {
VersionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
return theTrait.createVersion(nodeRef, versionProperties);
} else {
NodeRef materialNode = smartStore.materializeIfPossible(nodeRef);
Version actualVersion = theTrait.createVersion(materialNode, versionProperties);
return virtualizeVersion(reference, actualVersion);
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualVersionServiceExtension method getCurrentVersion.
@Override
public Version getCurrentVersion(NodeRef nodeRef) {
VersionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
return theTrait.getCurrentVersion(nodeRef);
} else {
NodeRef materialNode = smartStore.materialize(reference);
Reference versionedReference = Reference.fromNodeRef(nodeRef);
Version actualVersion = theTrait.getCurrentVersion(materialNode);
return virtualizeVersion(versionedReference, actualVersion);
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualVersionServiceExtension method materializeVersionIfReference.
private Version materializeVersionIfReference(Version virtualVersion) {
NodeRef frozenStateNodeRef = virtualVersion.getFrozenStateNodeRef();
StoreRef frozenStoreRef = frozenStateNodeRef.getStoreRef();
NodeRef materialFrozenNodeRef = frozenStateNodeRef;
Reference frozenReference = Reference.fromNodeRef(frozenStateNodeRef);
if (frozenReference != null) {
materialFrozenNodeRef = smartStore.materialize(frozenReference);
}
Map<String, Serializable> virtualProperties = virtualVersion.getVersionProperties();
Map<String, Serializable> actualProperties = new HashMap<>(virtualProperties);
if (frozenStoreRef.getIdentifier().equals(Version2Model.STORE_ID)) {
// V2 version store (eg. workspace://version2Store)
NodeRef propFrozenNode = (NodeRef) virtualProperties.get(Version2Model.PROP_FROZEN_NODE_REF);
NodeRef propActualFrozenNode = propFrozenNode;
Reference propFrozenReference = Reference.fromNodeRef(propFrozenNode);
if (propFrozenReference != null) {
propActualFrozenNode = smartStore.materialize(propFrozenReference);
}
actualProperties.put(Version2Model.PROP_FROZEN_NODE_REF, propActualFrozenNode);
} else if (frozenStoreRef.getIdentifier().equals(VersionModel.STORE_ID)) {
// Deprecated V1 version store (eg.
// workspace://lightWeightVersionStore)
String frozenNodeStoreProtocol = (String) virtualProperties.get(VersionModel.PROP_FROZEN_NODE_STORE_PROTOCOL);
String frozenNodeStoreId = (String) virtualProperties.get(VersionModel.PROP_FROZEN_NODE_STORE_ID);
String frozenNodeId = (String) virtualProperties.get(VersionModel.PROP_FROZEN_NODE_ID);
NodeRef propFrozenNode = new NodeRef(frozenNodeStoreProtocol, frozenNodeStoreId, frozenNodeId);
NodeRef propActualFrozenNode = propFrozenNode;
Reference propFrozenReference = Reference.fromNodeRef(propFrozenNode);
if (propFrozenReference != null) {
propActualFrozenNode = smartStore.materialize(propFrozenReference);
}
StoreRef propActualStoreRef = propFrozenNode.getStoreRef();
actualProperties.put(VersionModel.PROP_FROZEN_NODE_STORE_PROTOCOL, propActualStoreRef.getProtocol());
actualProperties.put(VersionModel.PROP_FROZEN_NODE_STORE_ID, propActualStoreRef.getIdentifier());
actualProperties.put(VersionModel.PROP_FROZEN_NODE_ID, propActualFrozenNode.getId());
}
Version actualVersion = new VersionImpl(actualProperties, materialFrozenNodeRef);
return actualVersion;
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualVersionServiceExtension method restore.
@Override
public NodeRef restore(NodeRef nodeRef, NodeRef parentNodeRef, QName assocTypeQName, QName assocQName) {
VersionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
return theTrait.restore(nodeRef, parentNodeRef, assocTypeQName, assocQName);
} else {
NodeRef materialNode = smartStore.materialize(reference);
return theTrait.restore(materialNode, parentNodeRef, assocTypeQName, assocQName);
}
}
Aggregations