use of org.alfresco.repo.virtual.ref.Protocol in project alfresco-repository by Alfresco.
the class TemplateVirtualizationMethod method newVirtualReference.
/**
* @param env the environment in which the virtualization takes place
* @param actualNodeRef the node that is virtualized using the given
* template
* @param templateSystemPath system path string of the template used in
* virtualizing the given NodeRef
* @return a {@link Reference} correspondent of the given {@link NodeRef}
* according to the rules defined by the given template
* @throws VirtualizationException
* @deprecated all template system path functionality should be replaced by
* plain encoded references
*/
protected Reference newVirtualReference(ActualEnvironment env, NodeRef actualNodeRef, String templateSystemPath) throws VirtualizationException {
final char systemToken = templateSystemPath.charAt(0);
if (systemToken == VirtualProtocol.NODE_TEMPLATE_PATH_TOKEN) {
// create node based reference
return newVirtualReference(env, actualNodeRef, new NodeRef(templateSystemPath.substring(1)));
}
String templateName = retrieveTemplateContentName(env, templateSystemPath);
if (!templateName.isEmpty()) {
Protocol protocol = protocolFormName(templateName);
return protocol.dispatch(new NewVirtualReferenceMethod(templateSystemPath, PATH_SEPARATOR, actualNodeRef, vanillaProcessorClasspath), null);
} else {
// default branch - invalid virtual node
throw new VirtualizationException("Invalid virtualization : missing template name for " + templateSystemPath);
}
}
use of org.alfresco.repo.virtual.ref.Protocol 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;
}
}
Aggregations