public final String repositoryName() { return repositoryConfiguration.getName(); }
protected String repositoryName() { return config().getName(); }
public String getJndiName() { return doc.getString(FieldName.JNDI_NAME, DEFAULT_JNDI_PREFIX_OF_NAME + getName()); }
protected String repositoryName() { return config().getName(); }
public String getJndiName() { return doc.getString(FieldName.JNDI_NAME, DEFAULT_JNDI_PREFIX_OF_NAME + getName()); }
protected void bindIntoJndi() { if (jndiName != null && jndiName.trim().length() != 0) { try { InitialContext ic = new InitialContext(); ic.bind(jndiName, JcrRepository.this); } catch (NoInitialContextException e) { // No JNDI here ... logger.debug("No JNDI found, so not registering '{0}' repository", getName()); } catch (OperationNotSupportedException e) { warn(JcrI18n.jndiReadOnly, config.getName(), jndiName); } catch (NamingException e) { logger.error(e, JcrI18n.unableToBindToJndi, config.getName(), jndiName, e.getMessage()); } catch (Exception e) { logger.debug(e, "Error while registering the '{0}' repository from the '{1}' name in JNDI", config.getName(), jndiName); } } }
protected void unbindFromJndi() { if (jndiName != null && jndiName.trim().length() != 0) { try { InitialContext ic = new InitialContext(); ic.unbind(jndiName); } catch (NoInitialContextException e) { // No JNDI here ... logger.debug("No JNDI found, so not registering '{0}' repository", getName()); } catch (OperationNotSupportedException e) { warn(JcrI18n.jndiReadOnly, config.getName(), jndiName); } catch (Exception e) { logger.warn(JcrI18n.jndiReadOnly, config.getName(), jndiName); } } }
protected void bindIntoJndi() { if (jndiName != null && jndiName.trim().length() != 0) { try { InitialContext ic = new InitialContext(); ic.bind(jndiName, JcrRepository.this); } catch (NoInitialContextException e) { // No JNDI here ... logger.debug("No JNDI found, so not registering '{0}' repository", getName()); } catch (OperationNotSupportedException e) { warn(JcrI18n.jndiReadOnly, config.getName(), jndiName); } catch (NamingException e) { logger.error(e, JcrI18n.unableToBindToJndi, config.getName(), jndiName, e.getMessage()); } catch (Exception e) { logger.debug(e, "Error while registering the '{0}' repository from the '{1}' name in JNDI", config.getName(), jndiName); } } }
protected void unbindFromJndi() { if (jndiName != null && jndiName.trim().length() != 0) { try { InitialContext ic = new InitialContext(); ic.unbind(jndiName); } catch (NoInitialContextException e) { // No JNDI here ... logger.debug("No JNDI found, so not registering '{0}' repository", getName()); } catch (OperationNotSupportedException e) { warn(JcrI18n.jndiReadOnly, config.getName(), jndiName); } catch (Exception e) { logger.warn(JcrI18n.jndiReadOnly, config.getName(), jndiName); } } }
/** * 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(); }
/** * 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(); }
@Test public void shouldReplaceVariables() { RepositoryConfiguration config = assertValid("{ 'name' = '${os.name} Repository' }"); assertThat(config.getName(), is(System.getProperty("os.name") + " Repository")); System.out.println(config.getDocument()); }
/*** * 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(); }
/*** * 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(); }
protected JcrRepository repository( Map<?, ?> parameters, String repositoryURL ) throws RepositoryException { String repositoryName = repositoryNameFrom(repositoryURL, parameters); JcrRepository repository = lookForAlreadyDeployedRepositoryKey(repositoryURL); if (repository != null) { return repository; } RepositoryConfiguration configuration = loadRepositoryConfigurationFrom(repositoryURL); repository = lookForAlreadyDeployedRepositoryName(configuration.getName()); if (repository != null) { return StringUtil.isBlank(repositoryName) || configuration.getName().equalsIgnoreCase(repositoryName) ? repository : null; } // Now deploy the new repository ... try { repository = ENGINE.deploy(configuration); repository.start(); // The name might not match the configuration's name ... if (StringUtil.isBlank(repositoryName) || repository.getName().equals(repositoryName)) { return repository; } LOG.warn(JcrI18n.repositoryNotFound, repositoryName, repositoryURL, parameters); return null; } catch (RepositoryException re) { throw re; } catch (Exception e) { throw new RepositoryException(e); } }
protected JcrRepository repository( Map<?, ?> parameters, String repositoryURL ) throws RepositoryException { String repositoryName = repositoryNameFrom(repositoryURL, parameters); JcrRepository repository = lookForAlreadyDeployedRepositoryKey(repositoryURL); if (repository != null) { return repository; } RepositoryConfiguration configuration = loadRepositoryConfigurationFrom(repositoryURL); repository = lookForAlreadyDeployedRepositoryName(configuration.getName()); if (repository != null) { return StringUtil.isBlank(repositoryName) || configuration.getName().equalsIgnoreCase(repositoryName) ? repository : null; } // Now deploy the new repository ... try { repository = ENGINE.deploy(configuration); repository.start(); // The name might not match the configuration's name ... if (StringUtil.isBlank(repositoryName) || repository.getName().equals(repositoryName)) { return repository; } LOG.warn(JcrI18n.repositoryNotFound, repositoryName, repositoryURL, parameters); return null; } catch (RepositoryException re) { throw re; } catch (Exception e) { throw new RepositoryException(e); } }
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(); }