final AtomicReference<RepositoryConfiguration> config = new AtomicReference<>(RepositoryConfiguration.read(res.getURL())); EditableDocument original = config.get().edit(); EditableDocument added = updatedConfigWithIndexes.edit(); original.merge(added); RepositoryConfiguration updatedConfig = new RepositoryConfiguration(original, config.get().getName()); log.debug("Original ModeShape configuration: {}", config.toString()); log.debug("ModeShape indexing configuration: {}", updatedConfigWithIndexes.toString()); log.debug("Updated ModeShape configuration: {}", updatedConfig.toString()); config.set(updatedConfig); log.info("ModeShape indexing configured"); }); Problems problems = config.get().validate(); if (problems.hasErrors()) { log.error("Problems with the ModeShape repository configuration: \n{}", problems);
/*** * Validate this configuration if the supplied changes were made to this. Note that this does <i>not</i> actually change this * configuration. * * @param changes the proposed changes to this configuration's underlying document; never null * @return the validation results; never null * @see #edit() * @see #validate() */ public Problems validate( Changes changes ) { // Create a copy of this configuration ... Editor copy = edit(); copy.apply(changes); RepositoryConfiguration updated = new RepositoryConfiguration(copy.unwrap(), this.getName()); return updated.validate(); }
/** * Resolve the supplied URL to a JSON document, read the contents, and parse into a {@link RepositoryConfiguration}. * * @param url the URL; may not be null * @return the parsed repository configuration; never null * @throws ParsingException if the content could not be parsed as a valid JSON document */ public static RepositoryConfiguration read( URL url ) throws ParsingException { CheckArg.isNotNull(url, "url"); Document doc = Json.read(url); return new RepositoryConfiguration(doc, withoutExtension(url.getFile())); }
URL configUrl = getClass().getClassLoader().getResource("config/repo-config.json"); engine.start(); config = RepositoryConfiguration.read(configUrl).with(environment); JcrRepository repository = engine.deploy(config); Editor editor = repository.getConfiguration().edit(); EditableDocument sequencing = editor.getDocument(FieldName.SEQUENCING); EditableDocument sequencers = sequencing.getDocument(FieldName.SEQUENCERS); engine.update(config.getName(), changes).get(); // don't forget to wait! RepositoryConfiguration config2 = engine.getRepositoryConfiguration(config.getName()); Document sequencerA2 = (Document)config2.getDocument() .getDocument(FieldName.SEQUENCING) .getDocument(FieldName.SEQUENCERS)
/** * Create a Repository instance given the {@link RepositoryConfiguration configuration}. * * @param configuration the repository configuration; may not be null * @throws ConfigurationException if there is a problem with the configuration */ protected JcrRepository( RepositoryConfiguration configuration ) throws ConfigurationException { ModeShape.getName(); // force log message right up front this.config.set(configuration); RepositoryConfiguration config = this.config.get(); // Validate the configuration to make sure there are no errors ... Problems results = configuration.validate(); setConfigurationProblems(results); if (results.hasErrors()) { String msg = JcrI18n.errorsInRepositoryConfiguration.text(this.repositoryName, results.errorCount(), results.toString()); throw new ConfigurationException(results, msg); } this.repositoryName.set(config.getName()); this.logger = Logger.getLogger(getClass()); this.logger.debug("Activating '{0}' repository", this.repositoryName); // Set up the descriptors ... this.descriptors = new HashMap<String, Object>(); initializeDescriptors(); }
RepositoryConfiguration config = RepositoryConfiguration.read( "{'name':'" + repoName + "', 'jndiName':'', 'storage':{'cacheName':'" + tableName + "','binaryStorage':{'type':'cache','dataCacheName':'" + tableName + "','metadataCacheName':'" + tableName + "'}},'clustering':{'clusterName':'" + repoName + "', 'channelConfiguration':'openl-jgroups-insp-config.xml'}}"); config = config.with(environment); Problems problems = config.validate(); if (problems.hasErrors()) { String message = "Problems in the Modeshape configuration";
} else { this.statistics = other != null ? other.statistics : new RepositoryStatistics(tempContext); if (this.config.getMonitoring().enabled()) { this.defaultWorkspaceName = config.getDefaultWorkspaceName(); BinaryStorage binaryStorage = config.getBinaryStorage(); this.cache.setLargeStringLength(binaryStorage.getMinimumBinarySizeInBytes()); this.context.getBinaryStore().setMinimumBinarySizeInBytes(binaryStorage.getMinimumBinarySizeInBytes()); for (String workspaceName : config.getPredefinedWorkspaceNames()) { this.cache.createWorkspace(workspaceName); this.internalWorkerContext = other.internalWorkerContext; this.nodeTypes = other.nodeTypes.with(this, true, true); this.lockManager = other.lockManager.with(this, other.config.getGarbageCollection()); this.schematicDb = environment().getDb(config.getPersistenceConfiguration()); this.txMgrLookup = config.getTransactionManagerLookup(); this.txnMgr = this.txMgrLookup.getTransactionManager(); this.transactions = createTransactions(this.txnMgr, schematicDb); this.connectors = new Connectors(this, config.getFederation(), problems); RepositoryConfiguration.Clustering clustering = config.getClustering(); long lockTimeoutMillis = config.getLockTimeoutMillis(); if (clustering.isEnabled()) { final String clusterName = clustering.getClusterName(); BinaryStorage binaryStorageConfig = config.getBinaryStorage();
@Override protected RepositoryConfiguration createRepositoryConfiguration(String repositoryName) throws Exception { return RepositoryConfiguration.read("config/backup-repo-config.json"); }
@Test public void shouldNotConfigureAnonymousIfNoRolesAreSpecified() throws Exception { RepositoryConfiguration config = RepositoryConfiguration.read("{ \"security\" : { \"anonymous\" : { \"roles\" : [] } } }"); Security security = config.getSecurity(); AnonymousSecurity anon = security.getAnonymous(); assertThat(anon, is(nullValue())); }
private Repository deployRepository( String uri ) throws ResourceException { if (engine == null) { engine = ra.getEngine(); if (engine == null) { throw new ResourceException("Engine not started by resource adapter!"); } } // load configuration RepositoryConfiguration config = null; try { URL url = isAbsolutePath(uri) ? getClass().getClassLoader().getResource(uri) : new URL(uri); config = RepositoryConfiguration.read(url); } catch (Exception e) { throw new ResourceException(e); } // check configuration Problems problems = config.validate(); if (problems.hasErrors()) { throw new ResourceException(problems.toString()); } try { return engine.deploy(config); } catch (RepositoryException e) { throw new ResourceException(e); } }
public final String repositoryName() { return repositoryConfiguration.getName(); }
@Test public void shouldNotEnableClusteringIfMissingDocument() throws Exception { RepositoryConfiguration config = RepositoryConfiguration.read("{ 'name' = 'nm', 'storage' : {}}"); RepositoryConfiguration.Clustering clusteringConfiguration = config.getClustering(); assertFalse(clusteringConfiguration.isEnabled()); }
@Test public void shouldUseDefaultLockingTimeout() throws Exception { RepositoryConfiguration config = RepositoryConfiguration.read("{ 'name' = 'nm', 'storage' : {}}"); assertEquals(Default.LOCK_TIMEOUT, config.getLockTimeoutMillis()); }
protected RepositoryConfiguration assertValid( RepositoryConfiguration config ) { Problems results = config.validate(); assertThat(results.toString(), results.hasProblems(), is(false)); return config; }
@Test public void shouldNotReplaceBlankValuesWithNull() throws Exception { RepositoryConfiguration config = RepositoryConfiguration.read("{ 'name' : 'Repo', 'jndiName' : '' }"); assertThat(config.getJndiName(), is("")); }
EditableDocument config = Schematic.newDocument(repositoryConfiguration.getDocument()); config.getOrCreateDocument(FieldName.STORAGE).setDocument(FieldName.BINARY_STORAGE, binaryConfig); Problems problems = repositoryConfiguration.validate(); if (!problems.isEmpty()) { LOG.debugv("Problems with configuration for '{0}' repository: {1}", repositoryName, problems); RepositoryConfiguration updatedConfiguration = new RepositoryConfiguration(config, repositoryName); engine.deploy(updatedConfiguration.with(this)); } catch (Exception e) { throw new StartException(e);
@Test public void shouldLoadDatabaseFromConfiguration() throws Exception { String pathToStorage = "target/repo/Library/content"; FileUtil.delete(pathToStorage); // Create the repository configuration ... String configFilePath = "config/repo-config-inmemory-local-environment.json"; InputStream configFileStream = getClass().getClassLoader().getResourceAsStream(configFilePath); RepositoryConfiguration repositoryConfiguration = RepositoryConfiguration.read(configFileStream, "doesn't matter"); LocalEnvironment environment = new LocalEnvironment(); assertNotNull(environment.getDb(repositoryConfiguration.getPersistenceConfiguration())); }
protected static void startRepository( RepositoryConfiguration configuration ) throws Exception { TestingEnvironment environment = new TestingEnvironment(); RepositoryConfiguration config = configuration != null ? new RepositoryConfiguration(configuration.getDocument(), configuration.getName(), environment) : new RepositoryConfiguration(REPO_NAME, environment); repository = new JcrRepository(config); repository.start(); session = repository.login(); }