org.modeshape.jcr
Class SystemFunctions.VersionHistoryFunction

java.lang.Object
  extended by org.modeshape.graph.request.function.Function
      extended by org.modeshape.jcr.SystemFunctions.VersionHistoryFunction
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
SystemFunctions.CreateVersionNodeFunction, SystemFunctions.InitializeVersionHistoryFunction
Enclosing class:
SystemFunctions

@Immutable
public abstract static class SystemFunctions.VersionHistoryFunction
extends Function

An abstract Function subclass that contains some helper methods related to version storage and version history.

See Also:
Serialized Form

Constructor Summary
SystemFunctions.VersionHistoryFunction()
           
 
Method Summary
protected  Property createPropertyIfDifferent(Map<Name,Property> properties, Name name, Object expectedValue, PropertyFactory propFactory, ValueFactory<?> valueFactory)
          A utility method that will create a new Property instance if there is not already an existing single-valued property with the supplied name and expected values.
protected  Path initializeVersionStorage(UUID versionableNodeUuid, Name primaryTypeName, List<Name> mixinTypeNames, Location versionHistoryLocation, UUID originalVersionUuid, UUID rootVersionUuid, ExecutionContext context, RequestBuilder system, String workspace, DateTime now)
          Create and initialize the version history structure for a versionable node with the supplied UUID.
protected  Location versionHistoryLocationFor(Path versionHistoryPath, UUID possibleVersionHistoryUuid, RequestBuilder system, String workspace)
          Verify whether the version history exists within version storage, and if so return its actual Location.
 
Methods inherited from class org.modeshape.graph.request.function.Function
isReadOnly, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemFunctions.VersionHistoryFunction

public SystemFunctions.VersionHistoryFunction()
Method Detail

versionHistoryLocationFor

protected Location versionHistoryLocationFor(Path versionHistoryPath,
                                             UUID possibleVersionHistoryUuid,
                                             RequestBuilder system,
                                             String workspace)
Verify whether the version history exists within version storage, and if so return its actual Location. If a possible UUID is provided, this method first looks for a version history node with the specified UUID at the specified path; if none is found, then this method looks for a version history at the specified path (ignoring the supplied UUID).

Parameters:
versionHistoryPath - the path to the version history node; may not be null
possibleVersionHistoryUuid - the possible UUID for the existing version history node; may be null if this is not known
system - the builder for creating and executing requests against the connector; may not be null
workspace - the name of the system workspace
Returns:
the actual Location of the version history node, or null if no such version history node yet exists

createPropertyIfDifferent

protected Property createPropertyIfDifferent(Map<Name,Property> properties,
                                             Name name,
                                             Object expectedValue,
                                             PropertyFactory propFactory,
                                             ValueFactory<?> valueFactory)
A utility method that will create a new Property instance if there is not already an existing single-valued property with the supplied name and expected values.

Parameters:
properties - the existing properties, keyed by name; may not be null
name - the name of the property; may not be null
expectedValue - the expected value of the property; may not be null
propFactory - the factory for creating new Property instances; may not be null
valueFactory - the factory for transforming the existing value into an object that can be compared to the expected value
Returns:
the new Property if the expected value differs from the existing value (or if there is no existing property), or null if the existing property already has the expected value

initializeVersionStorage

protected Path initializeVersionStorage(UUID versionableNodeUuid,
                                        Name primaryTypeName,
                                        List<Name> mixinTypeNames,
                                        Location versionHistoryLocation,
                                        UUID originalVersionUuid,
                                        UUID rootVersionUuid,
                                        ExecutionContext context,
                                        RequestBuilder system,
                                        String workspace,
                                        DateTime now)
Create and initialize the version history structure for a versionable node with the supplied UUID. This method assumes that the version history node does not exist.

The initial version history structure for the versioned node with UUID "e41075cb-a09a-4910-87b1-90ce8b4ca9dd" is as follows:

  + jcr:system
    + jcr:versionStorage   {jcr:primaryType = mode:versionStorage}
      + e4   {jcr:primaryType = mode:versionHistoryFolder}
        + 10   {jcr:primaryType = mode:versionHistoryFolder}
          + 75   {jcr:primaryType = mode:versionHistoryFolder}
            + cb   {jcr:primaryType = nt:versionHistory}
              + a09a-4910-87b1-90ce8b4ca9dd  {jcr:primaryType = nt:versionHistory}
                + jcr:versionLabels  {jcr:primaryType = nt:versionLabels}
                + jcr:rootVersion  {jcr:primaryType = nt:version}
                  - jcr:uuid = ...
                  - jcr:created = ...
                  + jcr:frozenNode  {jcr:primaryType = nt:frozenNode}
                    - jcr:frozenUuid
                    - jcr:frozenPrimaryType
                    - jcr:frozenMixinTypes
 
Note that the path between "/jcr:system/jcr:versionStorage" and the "nt:versionHistory" node is shown as being hiearchical, but it is also possible to be flat (which is less efficient and generally slower performing:
  + jcr:system
    + jcr:versionStorage   {jcr:primaryType = mode:versionStorage}
      + e41075cb-a09a-4910-87b1-90ce8b4ca9dd  {jcr:primaryType = nt:versionHistory}
        + jcr:versionLabels  {jcr:primaryType = nt:versionLabels}
        + jcr:rootVersion  {jcr:primaryType = nt:version}
          - jcr:uuid = ...
          - jcr:created = ...
          + jcr:frozenNode  {jcr:primaryType = nt:frozenNode}
            - jcr:frozenUuid
            - jcr:frozenPrimaryType
            - jcr:frozenMixinTypes
 
The flat structure was used originally and was less efficient and slower performing with larger numbers of versionable nodes. The actual structure is set with the JcrRepository.Option.VERSION_HISTORY_STRUCTURE repository option, but now defaults to hierarchical.

Parameters:
versionableNodeUuid - the UUID of the versionable node for which the history is to be created; may not be null
primaryTypeName - the name of the primary type of the versionable node; may not be null
mixinTypeNames - the names of the mixin types for the versionable node; may be null or empty
versionHistoryLocation - the path and UUID of the version history node; may not be null
originalVersionUuid - the UUID of the original node from which the new versionable node was copied; may be null
rootVersionUuid - the UUID of the "jcr:rootVersion" node in the version history; may not be null
context - the execution context; may not be null
system - the RequestBuilder that can be used to create and execute additional requests; may not be null
workspace - the name of the workspace; may not be null
now - the current date time; may not be null
Returns:
the path of the highest node that was modified or created by this method


Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.