Search in sources :

Example 1 with Protocol

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);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) NewVirtualReferenceMethod(org.alfresco.repo.virtual.ref.NewVirtualReferenceMethod) VirtualProtocol(org.alfresco.repo.virtual.ref.VirtualProtocol) Protocol(org.alfresco.repo.virtual.ref.Protocol) VirtualizationException(org.alfresco.repo.virtual.VirtualizationException)

Example 2 with Protocol

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

Aggregations

Protocol (org.alfresco.repo.virtual.ref.Protocol)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 Serializable (java.io.Serializable)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 NodePermissionEntry (org.alfresco.repo.security.permissions.NodePermissionEntry)1 VirtualizationException (org.alfresco.repo.virtual.VirtualizationException)1 GetActualNodeRefMethod (org.alfresco.repo.virtual.ref.GetActualNodeRefMethod)1 NewVirtualReferenceMethod (org.alfresco.repo.virtual.ref.NewVirtualReferenceMethod)1 VirtualProtocol (org.alfresco.repo.virtual.ref.VirtualProtocol)1 VirtualFolderDefinition (org.alfresco.repo.virtual.template.VirtualFolderDefinition)1 StoreRef (org.alfresco.service.cmr.repository.StoreRef)1 NamespacePrefixResolver (org.alfresco.service.namespace.NamespacePrefixResolver)1 QName (org.alfresco.service.namespace.QName)1