org.modeshape.jcr

## Class SystemContent

- java.lang.Object
- - org.modeshape.jcr.SystemContent

-     public class SystemContent
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `GENERATED_PREFIX`
    `protected static Pattern` | `GENERATED_PREFIX_PATTERN`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Iterable<?>` | `all(CachedNode node, Name propertyName)`
    `SessionCache` | `cache()`
    `protected Object` | `first(CachedNode node, Name propertyName)`
    `protected Object` | `first(CachedNode node, Name propertyName, Object defaultValue)`
    `boolean` | `hasVersionHistory(NodeKey versionableNodeKey)`
    `NodeKey` | `indexesKey()`
    `CachedNode` | `indexesNode()`
    `protected MutableCachedNode` | `initializeVersionStorage(NodeKey versionableNodeKey, NodeKey versionHistoryKey, NodeKey versionKey, Name primaryTypeName, Set<Name> mixinTypeNames, Path versionHistoryPath, NodeKey originalVersionKey, DateTime now)` Create and initialize the version history structure for a versionable node with the supplied UUID.
    `protected NodeKey` | `keyForNamespaceUri(String namespaceUri)`
    `NodeKey` | `locksKey()`
    `CachedNode` | `locksNode()`
    `MutableCachedNode` | `mutableIndexesNode()`
    `MutableCachedNode` | `mutableLocksNode()`
    `MutableCachedNode` | `mutableNamespacesNode()`
    `MutableCachedNode` | `mutableNodeTypesNode()`
    `MutableCachedNode` | `mutableSystemNode()`
    `MutableCachedNode` | `mutableVersionStorageNode()`
    `NodeKey` | `namespacesKey()`
    `CachedNode` | `namespacesNode()`
    `protected Name` | `nextNameForVersionNode(Property predecessors, ChildReferences historyChildren)` Compute the name for the next version node in the given history.
    `NodeKey` | `nodeTypesKey()`
    `CachedNode` | `nodeTypesNode()`
    `protected int` | `propertyType(Object value)`
    `List<IndexDefinition>` | `readAllIndexDefinitions(Set<String> providerNames)` Read from system storage the index definitions.
    `Collection<NamespaceRegistry.Namespace>` | `readAllNamespaces()`
    `List<NodeTypeDefinition>` | `readAllNodeTypes()` Read from system storage all of the node type definitions.
    `protected NodeDefinition` | `readChildNodeDefinition(CachedNode childDefn)`
    `IndexColumnDefinition` | `readIndexColumnDefinition(CachedNode indexColumnDefn)`
    `IndexDefinition` | `readIndexDefinition(CachedNode indexDefn, Name providerName)`
    `String` | `readNamespacePrefix(String namespaceUri, boolean generateIfMissing)`
    `NodeTypeDefinition` | `readNodeTypeDefinition(CachedNode nodeType)`
    `List<NodeTypeDefinition>` | `readNodeTypes(Set<Name> nodeTypesToRefresh)` Read from system storage the node type definitions with the supplied names.
    `protected PropertyDefinition` | `readPropertyDefinition(CachedNode propDefn)`
    `MutableCachedNode` | `recordNewVersion(CachedNode versionableNode, SessionCache cacheForVersionableNode, Path versionHistoryPath, NodeKey originalVersionKey, Collection<Property> versionableProperties, DateTime now, AtomicReference<MutableCachedNode> frozenNodeOutput)` The method efficiently updates the JCR version history and storage with a new version of a node being checked in.
    `Set<String>` | `registerNamespaces(Map<String,String> newUrisByPrefix)`
    `void` | `remove(IndexDefinition indexDefn)`
    `void` | `save()`
    `void` | `store(IndexDefinition indexDefn, boolean updateExisting)`
    `void` | `store(Iterable<org.modeshape.jcr.JcrNodeType> nodeTypes, boolean updateExisting)` Stores the node types in the system area under `/jcr:system/jcr:nodeTypes`.
    `void` | `store(org.modeshape.jcr.JcrNodeType nodeType, boolean updateExisting)` Stores the node type in the system area under `/jcr:system/jcr:nodeTypes`.
    `NodeKey` | `systemKey()`
    `CachedNode` | `systemNode()`
    `protected boolean` | `unregisterNamespace(String namespaceUri)`
    `protected void` | `unregisterNodeTypes(org.modeshape.jcr.JcrNodeType... nodeTypes)`
    `NodeKey` | `versionHistoryNodeKeyFor(NodeKey versionableNodeKey)`
    `NodeKey` | `versionStorageKey()`
    `CachedNode` | `versionStorageNode()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### GENERATED_PREFIX

          public static final String GENERATED_PREFIX

      See Also:
        Constant Field Values

    - #### GENERATED_PREFIX_PATTERN

          protected static final Pattern GENERATED_PREFIX_PATTERN

  - ### Method Detail

    - #### save

          public void save()

    - #### cache

          public final SessionCache cache()

    - #### systemKey

          public NodeKey systemKey()

    - #### nodeTypesKey

          public NodeKey nodeTypesKey()

    - #### indexesKey

          public NodeKey indexesKey()

    - #### namespacesKey

          public NodeKey namespacesKey()

    - #### locksKey

          public NodeKey locksKey()

    - #### versionStorageKey

          public NodeKey versionStorageKey()

    - #### systemNode

          public CachedNode systemNode()

    - #### nodeTypesNode

          public CachedNode nodeTypesNode()

    - #### namespacesNode

          public CachedNode namespacesNode()

    - #### indexesNode

          public CachedNode indexesNode()

    - #### locksNode

          public CachedNode locksNode()

    - #### versionStorageNode

          public CachedNode versionStorageNode()

    - #### mutableNodeTypesNode

          public MutableCachedNode mutableNodeTypesNode()

    - #### mutableNamespacesNode

          public MutableCachedNode mutableNamespacesNode()

    - #### mutableIndexesNode

          public MutableCachedNode mutableIndexesNode()

    - #### mutableLocksNode

          public MutableCachedNode mutableLocksNode()

    - #### mutableVersionStorageNode

          public MutableCachedNode mutableVersionStorageNode()

    - #### mutableSystemNode

          public MutableCachedNode mutableSystemNode()

    - #### store

          public void store(Iterable<org.modeshape.jcr.JcrNodeType> nodeTypes,
                   boolean updateExisting)

      Stores the node types in the system area under `/jcr:system/jcr:nodeTypes`.

      For each node type, a node is created with primary type of `nt:nodeType` and a name that corresponds to the node type's name. All other properties and child nodes for the newly created node are added in a manner consistent with the guidance provided in section 6.7.22 of the JCR 1.0 specification and section 4.7.24 of the JCR 2.0 specification where possible.

      Parameters:
        `nodeTypes` - the node types to write out; may not be null
        `updateExisting` - a boolean flag denoting whether the new node type definition should be overwrite an existing node type definition

    - #### store

          public void store(org.modeshape.jcr.JcrNodeType nodeType,
                   boolean updateExisting)

      Stores the node type in the system area under `/jcr:system/jcr:nodeTypes`.

      The stored content will contain a node with a primary type of `nt:nodeType` and a name that corresponds to the node type's name. All other properties and child nodes for the newly created node are added in a manner consistent with the guidance provided in section 6.7.22 of the JCR 1.0 specification and section 4.7.24 of the JCR 2.0 specification where possible.

      Parameters:
        `nodeType` - the node type to write; may not be null
        `updateExisting` - a boolean flag denoting whether the new node type definition should be overwrite an existing node type definition

    - #### readIndexDefinition

          public IndexDefinition readIndexDefinition(CachedNode indexDefn,
                                            Name providerName)

    - #### readIndexColumnDefinition

          public IndexColumnDefinition readIndexColumnDefinition(CachedNode indexColumnDefn)

    - #### readAllIndexDefinitions

          public List<IndexDefinition> readAllIndexDefinitions(Set<String> providerNames)

      Read from system storage the index definitions. If the names of the providers are providers, then the resulting index definitions will each be `enabled` only if the definition's named provider is in the supplied set; otherwise, the definition will be marked as disabled.
      Parameters:
        `providerNames` - the names of the providers that should be used to determine which index definitions are `enabled`; may be null if not known and all index definitions will be `enabled`
      Returns:
        the index definitions as read from the system storage

    - #### remove

          public void remove(IndexDefinition indexDefn)

    - #### store

          public void store(IndexDefinition indexDefn,
                   boolean updateExisting)

    - #### readNodeTypes

          public List<NodeTypeDefinition> readNodeTypes(Set<Name> nodeTypesToRefresh)

      Read from system storage the node type definitions with the supplied names.
      Parameters:
        `nodeTypesToRefresh` -
      Returns:
        the node types as read from the system storage

    - #### readAllNodeTypes

          public List<NodeTypeDefinition> readAllNodeTypes()

      Read from system storage all of the node type definitions.
      Returns:
        the node types as read from the system storage

    - #### readNodeTypeDefinition

          public NodeTypeDefinition readNodeTypeDefinition(CachedNode nodeType)

    - #### readPropertyDefinition

          protected PropertyDefinition readPropertyDefinition(CachedNode propDefn)
                                                       throws ConstraintViolationException

      Throws:
        `ConstraintViolationException`

    - #### readChildNodeDefinition

          protected NodeDefinition readChildNodeDefinition(CachedNode childDefn)
                                                    throws ConstraintViolationException

      Throws:
        `ConstraintViolationException`

    - #### propertyType

          protected final int propertyType(Object value)

    - #### all

          protected final Iterable<?> all(CachedNode node,
                        Name propertyName)

    - #### first

          protected final Object first(CachedNode node,
                     Name propertyName)

    - #### first

          protected final Object first(CachedNode node,
                     Name propertyName,
                     Object defaultValue)

    - #### readAllNamespaces

          public Collection<NamespaceRegistry.Namespace> readAllNamespaces()

    - #### registerNamespaces

          public Set<String> registerNamespaces(Map<String,String> newUrisByPrefix)

    - #### readNamespacePrefix

          public String readNamespacePrefix(String namespaceUri,
                                   boolean generateIfMissing)

    - #### unregisterNamespace

          protected boolean unregisterNamespace(String namespaceUri)

    - #### unregisterNodeTypes

          protected void unregisterNodeTypes(org.modeshape.jcr.JcrNodeType... nodeTypes)

    - #### keyForNamespaceUri

          protected final NodeKey keyForNamespaceUri(String namespaceUri)

    - #### versionHistoryNodeKeyFor

          public NodeKey versionHistoryNodeKeyFor(NodeKey versionableNodeKey)

    - #### hasVersionHistory

          public boolean hasVersionHistory(NodeKey versionableNodeKey)

    - #### initializeVersionStorage

          protected MutableCachedNode initializeVersionStorage(NodeKey versionableNodeKey,
                                                   NodeKey versionHistoryKey,
                                                   NodeKey versionKey,
                                                   Name primaryTypeName,
                                                   Set<Name> mixinTypeNames,
                                                   Path versionHistoryPath,
                                                   NodeKey originalVersionKey,
                                                   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.

      Given a NodeKey for a node that has an identifier part of "fae2b929-c5ef-4ce5-9fa1-514779ca0ae3", the SHA-1 hash of this identifier part is "b46dde8905f76361779339fa3ccacc4f47664255". The path to the version history for this node is as follows:

            + jcr:system
              + jcr:versionStorage   {jcr:primaryType = mode:versionStorage}
                + b4   {jcr:primaryType = mode:versionHistoryFolder}
                  + 6d   {jcr:primaryType = mode:versionHistoryFolder}
                    + de   {jcr:primaryType = mode:versionHistoryFolder}
                      + 298905f76361779339fa3ccacc4f47664255   {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`.
      Parameters:
        `versionableNodeKey` - the identifier of the versionable node for which the history is to be created; may not be null
        `versionHistoryKey` - the key to the version history node; may not be null
        `versionKey` - the key to be used for the initial version; may be null if the key should be generated
        `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
        `versionHistoryPath` - the path of the version history node; may not be null
        `originalVersionKey` - the key of the original node from which the new versionable node was copied; may be null
        `now` - the current date time; may not be null
      Returns:
        the history node; never null

    - #### recordNewVersion

          public MutableCachedNode recordNewVersion(CachedNode versionableNode,
                                           SessionCache cacheForVersionableNode,
                                           Path versionHistoryPath,
                                           NodeKey originalVersionKey,
                                           Collection<Property> versionableProperties,
                                           DateTime now,
                                           AtomicReference<MutableCachedNode> frozenNodeOutput)

      The method efficiently updates the JCR version history and storage with a new version of a node being checked in. However, it does not update the versionable node with the "mix:versionable" properties.

      Note that this method will initialize the version history for the node if the version history does not already exist.

      The names of the different versions has changed since 2.x, and now follows the same convention and algorithm as used in the reference implementation. See `nextNameForVersionNode(org.modeshape.jcr.value.Property, org.modeshape.jcr.cache.ChildReferences)` for details.

      Parameters:
        `versionableNode` - the versionable node for which a new version is to be created in the node's version history; may not be null
        `cacheForVersionableNode` - the cache used to access the versionable node and any descendants; may not be null
        `versionHistoryPath` - the path of the version history node; may not be null
        `originalVersionKey` - the key of the original node from which the new versionable node was copied; may be null
        `versionableProperties` - the versionable node's properties that should be record in the version history (on the frozen node); may be null or empty
        `now` - the current date time; may not be null
        `frozenNodeOutput` - the reference that should be set upon successful completion to the frozen node created under the new version; may not be null
      Returns:
        the version node in the version history; never null

    - #### nextNameForVersionNode

          protected Name nextNameForVersionNode(Property predecessors,
                                    ChildReferences historyChildren)

      Compute the name for the next version node in the given history. Note that the naming convention has changed since 2.x, and now follows the same convention and algorithm as used in the reference implementation. See org.apache.jackrabbit.core.version.InternalVersionManagerBase.calculateCheckinVersionName(...) for the original.

      The basic rules are as follows:

      - first the predecessor version with the shortest name is searched.
      - if that predecessor version is the root version, the new version gets the name "{number of successors}+1" + ".0"
      - if that predecessor version has no successor, the last digit of it's version number is incremented.
      - if that predecessor version has successors but the incremented name does not exist, that name is used.
      - otherwise a ".0" is added to the name until a non conflicting name is found.
        Example Graph:

             jcr:rootVersion
              |     |
             1.0   2.0
              |
             1.1
              |
             1.2 ---\  ------\
              |      \        \
             1.3   1.2.0   1.2.0.0
              |      |
             1.4   1.2.1 ----\
              |      |        \
             1.5   1.2.2   1.2.1.0
              |      |        |
             1.6     |     1.2.1.1
              |------/
             1.7

      Parameters:
        `predecessors` - the 'jcr:predecessors' property; may not be null
        `historyChildren` - the child references under the version history for the node
      Returns:
        the next name

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