org.modeshape.jcr

## Class RepositoryConfiguration

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

-     @Immutable
      public class RepositoryConfiguration
      extends Object

  A representation of the configuration for a `JCR Repository`.

  Each repository configuration is loaded from a JSON document. A `valid` repository configuration requires that the JSON document validates using the ModeShape repository configuration JSON Schema.

  Variables may appear anywhere within the document's string field values. If a variable is to be used within a non-string field, simply use a string field within the JSON document. When a RepositoryConfiguration instance is created from a JSON document, these variables will be replaced with the System properties of the same name, and any resulting fields that are expected to be non-string values will be converted into the expected field type. As expected, use `validate()` to ensure the configuration is valid.

  Variables take the form:

          variable := '${' variableNames [ ':' defaultValue ] '}'

          variableNames := variableName [ ',' variableNames ]

          variableName := /* any characters except ',' and ':' and '}'

          defaultValue := /* any characters except

  Note that variableName is the name used to look up a System property via `System.getProperty(String)`. Notice that the syntax supports multiple variables. The logic will process the variables from let to right, until an existing System property is found. And at that point, it will stop and will not attempt to find values for the other variables.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `RepositoryConfiguration.AnonymousSecurity` The configuration of the use of the built-in anonymous authentication and authorization provider.
    `class` | `RepositoryConfiguration.BinaryStorage` The binary-storage-related configuration information.
    `class` | `RepositoryConfiguration.Component`
    `static class` | `RepositoryConfiguration.Default`
    `class` | `RepositoryConfiguration.DocumentOptimization`
    `class` | `RepositoryConfiguration.Federation` The federation-related configuration information.
    `static class` | `RepositoryConfiguration.FieldName`
    `static class` | `RepositoryConfiguration.FieldValue`
    `class` | `RepositoryConfiguration.GarbageCollection`
    `class` | `RepositoryConfiguration.Indexes` The index-related configuration information.
    `class` | `RepositoryConfiguration.InitialContent`
    `class` | `RepositoryConfiguration.JaasSecurity` The configuration of the use of the built-in JAAS authentication and authorization provider.
    `class` | `RepositoryConfiguration.Journaling`
    `class` | `RepositoryConfiguration.MonitoringSystem` The query-related configuration information.
    `class` | `RepositoryConfiguration.ProjectionConfiguration` Object representation of a projection configuration within an external source
    `class` | `RepositoryConfiguration.Security` The security-related configuration information.
    `class` | `RepositoryConfiguration.Sequencing` The security-related configuration information.
    `class` | `RepositoryConfiguration.TextExtraction`
    `static class` | `RepositoryConfiguration.TransactionMode` Possible options for rebuilding the indexes upon startup.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static Pattern` | `COLUMN_DEFN_PATTERN`
    `protected static String` | `COLUMN_DEFN_PATTERN_STRING` The regular expression used to capture the index column definition property name and type.
    `protected static Set<String>` | `COMPONENT_SKIP_PROPERTIES` The set of field names that should be skipped when `instantiating a component`.
    `protected static Map<String,String>` | `CONNECTOR_ALIASES`
    `static String` | `DEFAULT_JNDI_PREFIX_OF_NAME` The default JNDI location for repositories is "java:jcr/local/<name>", where "<name>" is the name of the repository.
    `protected static Set<List<String>>` | `DEPRECATED_FIELDS`
    `protected static Document` | `EMPTY`
    `protected static Map<String,String>` | `EXTRACTOR_ALIASES`
    `static Pattern` | `INDEX_COLUMN_DEFINITIONS_PATTERN`
    `protected static Map<String,String>` | `INDEX_PROVIDER_ALIASES`
    `protected static Set<String>` | `INDEX_PROVIDER_FIELDS`
    `static String` | `JSON_SCHEMA_RESOURCE_PATH`
    `static String` | `JSON_SCHEMA_URI`
    `static Pattern` | `PROJECTION_PATH_EXPRESSION_PATTERN`
    `protected static Map<String,String>` | `PROVIDER_ALIASES`
    `static String` | `ROOT_NODE_ID` The standard identifier of the root node is '"/" '.
    `protected static SchemaLibrary` | `SCHEMA_LIBRARY`
    `protected static Map<String,String>` | `SEQUENCER_ALIASES`
    `static String` | `SYSTEM_WORKSPACE_NAME` The name of the 'system' workspace.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RepositoryConfiguration()`
    `RepositoryConfiguration(Document document, String documentName)`
    `RepositoryConfiguration(Document document, String documentName, Environment environment)`
    `RepositoryConfiguration(String name)`
    `RepositoryConfiguration(String name, Environment environment)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Editor` | `edit()` Make a clone of this configuration and return an editor for changing that clone.
    `protected Environment` | `environment()`
    `Set<String>` | `getAllWorkspaceNames()` Obtain all of the workspace names specified by this repository, including the `predefined workspaces` and the `default workspace`.
    `RepositoryConfiguration.BinaryStorage` | `getBinaryStorage()`
    `static String` | `getBuiltInAuthenticationProviderClassName(String alias)` Returns a fully qualified built-in authentication provider class name mapped to the given alias, or `null` if there isn't such a mapping
    `static String` | `getBuiltInIndexProviderClassName(String alias)` Returns a fully qualified built-in index provider class name mapped to the given alias, or `null` if there isn't such a mapping
    `static String` | `getBuiltInSequencerClassName(String alias)` Returns a fully qualified built-in sequencer class name mapped to the given alias, or `null` if there isn't such a mapping
    `static String` | `getBuiltInTextExtractorClassName(String alias)` Returns a fully qualified built-in text extractor class name mapped to the given alias, or `null` if there isn't such a mapping
    `String` | `getCacheConfiguration()`
    `protected CacheContainer` | `getCacheContainer(String config)`
    `String` | `getCacheName()`
    `String` | `getDefaultWorkspaceName()` Get the name of the workspace that should be used for sessions where the client does not specify the name of the workspace.
    `Document` | `getDocument()`
    `RepositoryConfiguration.DocumentOptimization` | `getDocumentOptimization()` Get the configuration for the document optimization for this repository.
    `RepositoryConfiguration.Federation` | `getFederation()` Get the configuration for the federation-related aspects of this repository.
    `RepositoryConfiguration.GarbageCollection` | `getGarbageCollection()` Get the configuration for the garbage collection aspects of this repository.
    `RepositoryConfiguration.Indexes` | `getIndexes()` Get the configuration for the indexes used by this repository.
    `List<RepositoryConfiguration.Component>` | `getIndexProviders()` Get the ordered list of index providers defined in the configuration.
    `RepositoryConfiguration.InitialContent` | `getInitialContent()` Returns the initial content configuration for this repository configuration
    `String` | `getJndiName()`
    `RepositoryConfiguration.Journaling` | `getJournaling()` Returns the journaling configuration
    `RepositoryConfiguration.MonitoringSystem` | `getMonitoring()` Get the configuration for the monitoring-related aspects of this repository.
    `String` | `getName()`
    `List<String>` | `getNodeTypes()` Returns a list with the cnd files which should be loaded at startup.
    `Set<String>` | `getPredefinedWorkspaceNames()` Obtain the names of the workspaces that were listed as being predefined.
    `RepositoryConfiguration.Security` | `getSecurity()` Get the configuration for the security-related aspects of this repository.
    `RepositoryConfiguration.Sequencing` | `getSequencing()` Get the configuration for the sequencing-related aspects of this repository.
    `String` | `getStoreName()`
    `RepositoryConfiguration.TextExtraction` | `getTextExtraction()` Get the configuration for the text extraction aspects of this repository.
    `RepositoryConfiguration.TransactionMode` | `getTransactionMode()`
    `String` | `getWorkspaceCacheConfiguration()`
    `protected boolean` | `hasIndexProvider(String name)`
    `boolean` | `isCreatingWorkspacesAllowed()`
    `protected Context` | `jndiContext()`
    `static RepositoryConfiguration` | `read(File file)` Read the supplied JSON file and parse into a `RepositoryConfiguration`.
    `static RepositoryConfiguration` | `read(InputStream stream, String name)` Read the supplied stream containing a JSON file, and parse into a `RepositoryConfiguration`.
    `static RepositoryConfiguration` | `read(String resourcePathOrJsonContentString)` Read the repository configuration given by the supplied path to a file on the file system, the path a classpath resource file, or a string containg the actual JSON content.
    `static RepositoryConfiguration` | `read(URL url)` Resolve the supplied URL to a JSON document, read the contents, and parse into a `RepositoryConfiguration`.
    `protected List<RepositoryConfiguration.Component>` | `readComponents(Document doc, String fieldName, String aliasFieldName, Map<String,String> classnamesByAlias, Problems problems)`
    `protected Map<String,Object>` | `readProperties(Document document, String... skipFieldNames)`
    `protected static Document` | `replaceSystemPropertyVariables(Document doc)` Utility method to replace all system property variables found within the specified document.
    `String` | `toString()`
    `Problems` | `validate()` Validate this configuration against the JSON Schema.
    `Problems` | `validate(Changes changes)` Validate this configuration if the supplied changes were made to this.
    `protected void` | `validateIndexProviders(Problems problems)`
    `protected void` | `warnUseOfDeprecatedFields(SimpleProblems problems)`
    `RepositoryConfiguration` | `with(Environment environment)` Create a copy of this configuration that uses the supplied Infinispan `CacheContainer` instance.
    `RepositoryConfiguration` | `withName(String docName)` Create a copy of this configuration that uses the supplied document name.

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

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

- - ### Field Detail

    - #### ROOT_NODE_ID

          public static final String ROOT_NODE_ID

      The standard identifier of the root node is '"/" '.
      See Also:
        Constant Field Values

    - #### SYSTEM_WORKSPACE_NAME

          public static final String SYSTEM_WORKSPACE_NAME

      The name of the 'system' workspace.
      See Also:
        Constant Field Values

    - #### DEFAULT_JNDI_PREFIX_OF_NAME

          public static final String DEFAULT_JNDI_PREFIX_OF_NAME

      The default JNDI location for repositories is "java:jcr/local/<name>", where "<name>" is the name of the repository.
      See Also:
        Constant Field Values

    - #### PROJECTION_PATH_EXPRESSION_PATTERN

          public static final Pattern PROJECTION_PATH_EXPRESSION_PATTERN

    - #### INDEX_COLUMN_DEFINITIONS_PATTERN

          public static final Pattern INDEX_COLUMN_DEFINITIONS_PATTERN

    - #### EMPTY

          protected static final Document EMPTY

    - #### PROVIDER_ALIASES

          protected static final Map<String,String> PROVIDER_ALIASES

    - #### SEQUENCER_ALIASES

          protected static final Map<String,String> SEQUENCER_ALIASES

    - #### INDEX_PROVIDER_ALIASES

          protected static final Map<String,String> INDEX_PROVIDER_ALIASES

    - #### EXTRACTOR_ALIASES

          protected static final Map<String,String> EXTRACTOR_ALIASES

    - #### CONNECTOR_ALIASES

          protected static final Map<String,String> CONNECTOR_ALIASES

    - #### SCHEMA_LIBRARY

          protected static SchemaLibrary SCHEMA_LIBRARY

    - #### JSON_SCHEMA_URI

          public static final String JSON_SCHEMA_URI

      See Also:
        Constant Field Values

    - #### JSON_SCHEMA_RESOURCE_PATH

          public static final String JSON_SCHEMA_RESOURCE_PATH

      See Also:
        Constant Field Values

    - #### DEPRECATED_FIELDS

          protected static final Set<List<String>> DEPRECATED_FIELDS

    - #### COMPONENT_SKIP_PROPERTIES

          protected static final Set<String> COMPONENT_SKIP_PROPERTIES

      The set of field names that should be skipped when `instantiating a component`.

    - #### COLUMN_DEFN_PATTERN_STRING

          protected static final String COLUMN_DEFN_PATTERN_STRING

      The regular expression used to capture the index column definition property name and type. The expression is " `([^(,]+)[(]([^),]+)[)]`".
      See Also:
        Constant Field Values

    - #### COLUMN_DEFN_PATTERN

          protected static final Pattern COLUMN_DEFN_PATTERN

    - #### INDEX_PROVIDER_FIELDS

          protected static final Set<String> INDEX_PROVIDER_FIELDS

  - ### Constructor Detail

    - #### RepositoryConfiguration

          public RepositoryConfiguration()

    - #### RepositoryConfiguration

          public RepositoryConfiguration(String name)

    - #### RepositoryConfiguration

          public RepositoryConfiguration(Document document,
                                 String documentName)

    - #### RepositoryConfiguration

          public RepositoryConfiguration(String name,
                                 Environment environment)

    - #### RepositoryConfiguration

          public RepositoryConfiguration(Document document,
                                 String documentName,
                                 Environment environment)

  - ### Method Detail

    - #### replaceSystemPropertyVariables

          protected static Document replaceSystemPropertyVariables(Document doc)

      Utility method to replace all system property variables found within the specified document.
      Parameters:
        `doc` - the document; may not be null
      Returns:
        the modified document if system property variables were found, or the `doc` instance if no such variables were found

    - #### read

          public static RepositoryConfiguration read(URL url)
                                              throws ParsingException

      Resolve the supplied URL to a JSON document, read the contents, and parse into a `RepositoryConfiguration`.
      Parameters:
        `url` - the URL; may not be null
      Returns:
        the parsed repository configuration; never null
      Throws:
        `ParsingException` - if the content could not be parsed as a valid JSON document

    - #### read

          public static RepositoryConfiguration read(File file)
                                              throws ParsingException,
                                                     FileNotFoundException

      Read the supplied JSON file and parse into a `RepositoryConfiguration`.
      Parameters:
        `file` - the file; may not be null
      Returns:
        the parsed repository configuration; never null
      Throws:
        `ParsingException` - if the content could not be parsed as a valid JSON document
        `FileNotFoundException` - if the file could not be found

    - #### read

          public static RepositoryConfiguration read(InputStream stream,
                                     String name)
                                              throws ParsingException,
                                                     FileNotFoundException

      Read the supplied stream containing a JSON file, and parse into a `RepositoryConfiguration`.
      Parameters:
        `stream` - the file; may not be null
        `name` - the name of the resource; may not be null
      Returns:
        the parsed repository configuration; never null
      Throws:
        `ParsingException` - if the content could not be parsed as a valid JSON document
        `FileNotFoundException` - if the file could not be found

    - #### read

          public static RepositoryConfiguration read(String resourcePathOrJsonContentString)
                                              throws ParsingException,
                                                     FileNotFoundException

      Read the repository configuration given by the supplied path to a file on the file system, the path a classpath resource file, or a string containg the actual JSON content.
      Parameters:
        `resourcePathOrJsonContentString` - the path to a file on the file system, the path to a classpath resource file or the JSON content string; may not be null
      Returns:
        the parsed repository configuration; never null
      Throws:
        `ParsingException` - if the content could not be parsed as a valid JSON document
        `FileNotFoundException` - if the file could not be found

    - #### environment

          protected Environment environment()

    - #### getName

          public String getName()

    - #### getDocument

          public Document getDocument()

    - #### getJndiName

          public String getJndiName()

    - #### getStoreName

          public String getStoreName()

    - #### getCacheName

          public String getCacheName()

    - #### getCacheConfiguration

          public String getCacheConfiguration()

    - #### getWorkspaceCacheConfiguration

          public String getWorkspaceCacheConfiguration()

    - #### getCacheContainer

          protected CacheContainer getCacheContainer(String config)
                                              throws IOException,
                                                     NamingException

      Throws:
        `IOException`
        `NamingException`

    - #### getBinaryStorage

          public RepositoryConfiguration.BinaryStorage getBinaryStorage()

    - #### getJournaling

          public RepositoryConfiguration.Journaling getJournaling()

      Returns the journaling configuration
      Returns:
        a `RepositoryConfiguration.Journaling` instance, never `null`

    - #### getInitialContent

          public RepositoryConfiguration.InitialContent getInitialContent()

      Returns the initial content configuration for this repository configuration
      Returns:
        a `non-null` `RepositoryConfiguration.InitialContent`

    - #### getNodeTypes

          public List<String> getNodeTypes()

      Returns a list with the cnd files which should be loaded at startup.
      Returns:
        a `non-null` string list

    - #### getBuiltInSequencerClassName

          public static String getBuiltInSequencerClassName(String alias)

      Returns a fully qualified built-in sequencer class name mapped to the given alias, or `null` if there isn't such a mapping
      Parameters:
        `alias` - the alias
      Returns:
        the name of the sequencer class, or null if the alias did not correspond to a built-in class

    - #### getBuiltInIndexProviderClassName

          public static String getBuiltInIndexProviderClassName(String alias)

      Returns a fully qualified built-in index provider class name mapped to the given alias, or `null` if there isn't such a mapping
      Parameters:
        `alias` - the alias
      Returns:
        the name of the index provider class, or null if the alias did not correspond to a built-in class

    - #### getBuiltInTextExtractorClassName

          public static String getBuiltInTextExtractorClassName(String alias)

      Returns a fully qualified built-in text extractor class name mapped to the given alias, or `null` if there isn't such a mapping
      Parameters:
        `alias` - the alias
      Returns:
        the name of the text extractor class, or null if the alias did not correspond to a built-in class

    - #### getBuiltInAuthenticationProviderClassName

          public static String getBuiltInAuthenticationProviderClassName(String alias)

      Returns a fully qualified built-in authentication provider class name mapped to the given alias, or `null` if there isn't such a mapping
      Parameters:
        `alias` - the alias
      Returns:
        the name of the authentication provider class, or null if the alias did not correspond to a built-in class

    - #### isCreatingWorkspacesAllowed

          public boolean isCreatingWorkspacesAllowed()

    - #### getTransactionMode

          public RepositoryConfiguration.TransactionMode getTransactionMode()

    - #### getDefaultWorkspaceName

          public String getDefaultWorkspaceName()

      Get the name of the workspace that should be used for sessions where the client does not specify the name of the workspace.
      Returns:
        the default workspace name; never null

    - #### getPredefinedWorkspaceNames

          public Set<String> getPredefinedWorkspaceNames()

      Obtain the names of the workspaces that were listed as being predefined. This includes the name `default workspace`.
      Returns:
        the set of predefined (non-system) workspace names; never null

    - #### getAllWorkspaceNames

          public Set<String> getAllWorkspaceNames()

      Obtain all of the workspace names specified by this repository, including the `predefined workspaces` and the `default workspace`. The result does not contain the names of any dynamically-created workspaces (e.g., those not specified in the configuration).
      Returns:
        the set of all workspace names defined by the configuration; never null

    - #### getSecurity

          public RepositoryConfiguration.Security getSecurity()

      Get the configuration for the security-related aspects of this repository.
      Returns:
        the security configuration; never null

    - #### getMonitoring

          public RepositoryConfiguration.MonitoringSystem getMonitoring()

      Get the configuration for the monitoring-related aspects of this repository.
      Returns:
        the monitoring configuration; never null

    - #### getIndexProviders

          public List<RepositoryConfiguration.Component> getIndexProviders()

      Get the ordered list of index providers defined in the configuration.
      Returns:
        the immutable list of provider components; never null but possibly empty

    - #### validateIndexProviders

          protected void validateIndexProviders(Problems problems)

    - #### getIndexes

          public RepositoryConfiguration.Indexes getIndexes()

      Get the configuration for the indexes used by this repository.
      Returns:
        the index-related configuration; never null

    - #### hasIndexProvider

          protected boolean hasIndexProvider(String name)

    - #### getTextExtraction

          public RepositoryConfiguration.TextExtraction getTextExtraction()

      Get the configuration for the text extraction aspects of this repository.
      Returns:
        the text extraction configuration; never null

    - #### getSequencing

          public RepositoryConfiguration.Sequencing getSequencing()

      Get the configuration for the sequencing-related aspects of this repository.
      Returns:
        the sequencing configuration; never null

    - #### getFederation

          public RepositoryConfiguration.Federation getFederation()

      Get the configuration for the federation-related aspects of this repository.
      Returns:
        the federation configuration; never null

    - #### getGarbageCollection

          public RepositoryConfiguration.GarbageCollection getGarbageCollection()

      Get the configuration for the garbage collection aspects of this repository.
      Returns:
        the garbage collection configuration; never null

    - #### getDocumentOptimization

          public RepositoryConfiguration.DocumentOptimization getDocumentOptimization()

      Get the configuration for the document optimization for this repository.
      Returns:
        the document optimization configuration; never null

    - #### readComponents

          protected List<RepositoryConfiguration.Component> readComponents(Document doc,
                                                               String fieldName,
                                                               String aliasFieldName,
                                                               Map<String,String> classnamesByAlias,
                                                               Problems problems)

    - #### readProperties

          protected Map<String,Object> readProperties(Document document,
                                          String... skipFieldNames)

    - #### jndiContext

          protected Context jndiContext()
                                 throws NamingException

      Throws:
        `NamingException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`
      See Also:
        `Object.toString()`

    - #### edit

          public Editor edit()

      Make a clone of this configuration and return an editor for changing that clone. As the editor is used to alter the cloned configuration, the editor records the `changes`. After all changes are completed, the editor (which represents the newly modified configuration) can be used to create a `new RepositoryConfiguration`, or the `editor's changes` can be used to update an already deployed (and running) repository.

      For example, the following code shows how an existing RepositoryConfiguration instance can be used to create a second configuration that is a slightly-modified copy of the original.

      Also, the following code shows how an existing RepositoryConfiguration instance for a deployed repository can be updated:

             ModeShapeEngine engine = ...
             Repository deployed = engine.getRepository("repo");
             RepositoryConfiguration deployedConfig = deployed.getConfiguration();

             // Create an editor ...
             Editor editor = deployedConfig.edit();

             // Modify the copy of the configuration (we'll do something trivial here) ...
             editor.setNumber(FieldName.LARGE_VALUE_SIZE_IN_BYTES,8096);

             // Get the changes and validate them ...
             Changes changes = editor.getChanges();
             Results validationResults = deployedConfig.validate(changes);
             if ( validationResults.hasErrors() ) {
                 // do something
             } else {
                 // Update the deployed repository's configuration with these changes ...
                 engine.update("repo",changes);
             }

      Returns:
        an editor for modifying a copy of this repository configuration.
      See Also:
        `validate(Changes)`

    - #### validate

          public Problems validate()

      Validate this configuration against the JSON Schema.
      Returns:
        the validation results; never null
      See Also:
        `validate(Changes)`

    - #### validate

          public Problems validate(Changes changes)

      Validate this configuration if the supplied changes were made to this. Note that this does not actually change this configuration.
      Parameters:
        `changes` - the proposed changes to this configuration's underlying document; never null
      Returns:
        the validation results; never null
      See Also:
        `edit()`, `validate()`

    - #### with

          public RepositoryConfiguration with(Environment environment)

      Create a copy of this configuration that uses the supplied Infinispan `CacheContainer` instance.
      Parameters:
        `environment` - the environment that should be used for the repository; may be null
      Returns:
        the new configuration; never null

    - #### withName

          public RepositoryConfiguration withName(String docName)

      Create a copy of this configuration that uses the supplied document name.
      Parameters:
        `docName` - the new document name; may be null
      Returns:
        the new configuration; never null

    - #### warnUseOfDeprecatedFields

          protected void warnUseOfDeprecatedFields(SimpleProblems problems)

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