Package org.alfresco.repo.virtual.ref
Class VirtualProtocol
- java.lang.Object
-
- org.alfresco.repo.virtual.ref.Protocol
-
- org.alfresco.repo.virtual.ref.VirtualProtocol
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
VanillaProtocol
public class VirtualProtocol extends Protocol
A protocol for encoding virtual artefacts.
Virtual artefacts are generated using a virtual folder templateindicated by the mainReferenceresource.
The virtual folder template defines a hierarchical structure of virtual nodes.
The template path (seegetTemplatePath(Reference)) indicates a path in this structure.
Virtual folders templates can be applied on actual repository nodes (seegetActualNodeLocation(Reference)) which should be passed as parameters to the virtual folder template.
The protocol implementation also handles virtual protocolReferencecreation and template path navigation.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intACTUAL_NODE_LOCATION_PARAM_INDEXActual nodeParameterindex.static java.lang.CharacterCLASS_TEMPLATE_PATH_TOKENClasspath system path token.static java.lang.CharacterNODE_TEMPLATE_PATH_TOKENRepository node path system path token.static intTEMPLATE_PATH_PARAM_INDEXTemplate pathParameterindex.-
Fields inherited from class org.alfresco.repo.virtual.ref.Protocol
DEFAULT_ENCODING, name
-
-
Constructor Summary
Constructors Constructor Description VirtualProtocol()VirtualProtocol(java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected ResourcecreateSystemPathResource(java.lang.String templateSysPath)Deprecated.In future system paths will be replaced with actual resources or string encoded references<R> Rdispatch(ProtocolMethod<R> method, Reference reference)ProtocolMethoddouble-dispatch/visitor protocol type selector.RepositoryLocationgetActualNodeLocation(Reference reference)java.lang.StringgetTemplatePath(Reference reference)ReferencenewReference(java.lang.String templateSysPath, java.lang.String templatePath, org.alfresco.service.cmr.repository.NodeRef actualNodeRef)Deprecated.In future system paths will be replaced with actual resources or string encoded referencesReferencenewReference(Encoding encoding, Resource templateResource, java.lang.String templatePath, Resource actualNodeResource, java.util.List<Parameter> extraParameters)ReferencenewReference(Resource templateResource, java.lang.String templatePath, org.alfresco.service.cmr.repository.NodeRef actualNodeRef, java.util.List<Parameter> extraParameters)ReferencenewReference(org.alfresco.service.cmr.repository.NodeRef templateNodeRef, java.lang.String templatePath, org.alfresco.service.cmr.repository.NodeRef actualNodeRef)ReferencereplaceTemplatePath(Reference reference, java.lang.String path)-
Methods inherited from class org.alfresco.repo.virtual.ref.Protocol
addParameter, addParameter, getParameter, propagateNodeRefMutations, replaceParameter, replaceParameter, toString
-
-
-
-
Field Detail
-
ACTUAL_NODE_LOCATION_PARAM_INDEX
public static final int ACTUAL_NODE_LOCATION_PARAM_INDEX
Actual nodeParameterindex.- See Also:
- Constant Field Values
-
TEMPLATE_PATH_PARAM_INDEX
public static final int TEMPLATE_PATH_PARAM_INDEX
Template pathParameterindex.- See Also:
- Constant Field Values
-
NODE_TEMPLATE_PATH_TOKEN
public static final java.lang.Character NODE_TEMPLATE_PATH_TOKEN
Repository node path system path token.
-
CLASS_TEMPLATE_PATH_TOKEN
public static final java.lang.Character CLASS_TEMPLATE_PATH_TOKEN
Classpath system path token.
-
-
Method Detail
-
dispatch
public <R> R dispatch(ProtocolMethod<R> method, Reference reference) throws ProtocolMethodException
Description copied from class:ProtocolProtocolMethoddouble-dispatch/visitor protocol type selector. Subclasses should override this method to select the appropriate type bound method.
This particular implementation calls the defaultProtocolMethod.execute(Protocol, Reference)default method implementation.- Overrides:
dispatchin classProtocol- Returns:
- the value returned by the type bond method
- Throws:
ProtocolMethodException
-
getTemplatePath
public java.lang.String getTemplatePath(Reference reference)
- Parameters:
reference-- Returns:
- the inner template path referenced by the given
Reference - See Also:
TEMPLATE_PATH_PARAM_INDEX
-
replaceTemplatePath
public Reference replaceTemplatePath(Reference reference, java.lang.String path)
- Parameters:
reference-path-- Returns:
- a
Referencecopy of the given reference parameter with the template path set to the given path parameter value - See Also:
TEMPLATE_PATH_PARAM_INDEX
-
getActualNodeLocation
public RepositoryLocation getActualNodeLocation(Reference reference)
- Parameters:
reference-- Returns:
- the repository location of the actual node that the virtual template should be applied on
- See Also:
ACTUAL_NODE_LOCATION_PARAM_INDEX
-
newReference
public Reference newReference(org.alfresco.service.cmr.repository.NodeRef templateNodeRef, java.lang.String templatePath, org.alfresco.service.cmr.repository.NodeRef actualNodeRef)
- Parameters:
templateNodeRef-NodeRefof the template content holding repository nodetemplatePath-actualNodeRef-- Returns:
- a new virtual protocol
Referencewith the given virtual protocol reference elements
-
newReference
public Reference newReference(Resource templateResource, java.lang.String templatePath, org.alfresco.service.cmr.repository.NodeRef actualNodeRef, java.util.List<Parameter> extraParameters)
- Parameters:
templateResource- template content holding resourcetemplatePath-actualNodeRef-- Returns:
- a new virtual protocol
Referencewith the given virtual protocol reference elements
-
newReference
public Reference newReference(Encoding encoding, Resource templateResource, java.lang.String templatePath, Resource actualNodeResource, java.util.List<Parameter> extraParameters)
-
newReference
public Reference newReference(java.lang.String templateSysPath, java.lang.String templatePath, org.alfresco.service.cmr.repository.NodeRef actualNodeRef) throws ProtocolMethodException
Deprecated.In future system paths will be replaced with actual resources or string encoded referencesCreates a resource based on the given template system-path that is used in creating a new virtual protocol reference.- Parameters:
templateSysPath- a template-system-path for the template holding content
Template-system-paths are classpaths paths or repository paths prefixed withCLASS_TEMPLATE_PATH_TOKENorNODE_TEMPLATE_PATH_TOKENrespectively.templatePath-actualNodeRef-- Returns:
- a new virtual protocol
Referencewith the given virtual protocol reference elements - Throws:
ProtocolMethodException
-
createSystemPathResource
protected Resource createSystemPathResource(java.lang.String templateSysPath)
Deprecated.In future system paths will be replaced with actual resources or string encoded referencesSystem path resource factory method.- Parameters:
templateSysPath- a classpath or a repository path prefixed withCLASS_TEMPLATE_PATH_TOKENorNODE_TEMPLATE_PATH_TOKENrespectively.- Returns:
- a
ClassPathResourceor aRepositoryResourcefor the given system path
-
-