/** * Returns the default repository of the current environment. * Implemented by calling {@link #getRepository(Map)} with a * <code>null</code> parameter map. * * @see RepositoryFactory#getRepository(Map) * @return default repository * @throws RepositoryException if a default repository is not available * or can not be accessed */ public static Repository getRepository() throws RepositoryException { return getRepository((Map<String, String>) null); }
/** * Returns the default repository of the current environment. * Implemented by calling {@link #getRepository(Map)} with a * <code>null</code> parameter map. * * @see RepositoryFactory#getRepository(Map) * @return default repository * @throws RepositoryException if a default repository is not available * or can not be accessed */ public static Repository getRepository() throws RepositoryException { return getRepository((Map<String, String>) null); }
/** * Returns the default repository of the current environment. * Implemented by calling {@link #getRepository(Map)} with a * <code>null</code> parameter map. * * @see RepositoryFactory#getRepository(Map) * @return default repository * @throws RepositoryException if a default repository is not available * or can not be accessed */ public static Repository getRepository() throws RepositoryException { return getRepository((Map<String, String>) null); }
@Override protected Repository createRepository() throws Exception { final URL remoteUrl = new URL("http", remoteHost, remotePort, contextRoot); LOG.info("Creating remote repository for {}", remoteUrl); return JcrUtils.getRepository(remoteUrl.toString()); }
/** * Returns the proxied repository. Subclasses can override this * method to implement custom repository access mechanisms. * * @return repository * @throws RepositoryException if the repository can not be accessed */ protected Repository getRepository() throws RepositoryException { if (factory != null) { return factory.getRepository(); } else { return JcrUtils.getRepository(parameters); } }
/** * Returns the proxied repository. Subclasses can override this * method to implement custom repository access mechanisms. * * @return repository * @throws RepositoryException if the repository can not be accessed */ protected Repository getRepository() throws RepositoryException { if (factory != null) { return factory.getRepository(); } else { return JcrUtils.getRepository(parameters); } }
/** * Returns the proxied repository. Subclasses can override this * method to implement custom repository access mechanisms. * * @return repository * @throws RepositoryException if the repository can not be accessed */ protected Repository getRepository() throws RepositoryException { if (factory != null) { return factory.getRepository(); } else { return JcrUtils.getRepository(parameters); } }
/** * Create repository. * * @param parameters repository parameters * @return repository instance */ public synchronized Repository createRepository( Map<String, String> parameters) throws RepositoryException { Repository repository = repositories.get(parameters); if (repository == null) { if (parameters.containsKey(JcrUtils.REPOSITORY_URI)) { repository = JcrUtils.getRepository(parameters); } else { repository = createNonTransientRepository(parameters); } repositories.put(parameters, repository); } return repository; }
@Override public Repository getRepository(Map<String, String> properties) throws Exception { if (properties.containsKey(JcrUtils.REPOSITORY_URI) && "transient".equalsIgnoreCase(properties.get(JcrUtils.REPOSITORY_URI))) { Properties props = new Properties(); for(Map.Entry<String, String> entry : properties.entrySet()) { if(!JcrUtils.REPOSITORY_URI.equals(entry.getKey())) { props.setProperty(entry.getKey(), entry.getValue()); } } return new TransientRepository(props); } else { Repository repository = JcrUtils.getRepository(properties); if (repository != null) { return repository; } return null; } } }
/** * Create repository. * * @param parameters repository parameters * @return repository instance */ public synchronized Repository createRepository( Map<String, String> parameters) throws RepositoryException { Repository repository = repositories.get(parameters); if (repository == null) { if (parameters.containsKey(JcrUtils.REPOSITORY_URI)) { repository = JcrUtils.getRepository(parameters); } else { repository = createNonTransientRepository(parameters); } repositories.put(parameters, repository); } return repository; }
@Override public Repository getRepository(Map<String, String> properties) throws Exception { if (properties.containsKey(JcrUtils.REPOSITORY_URI) && "transient".equalsIgnoreCase(properties.get(JcrUtils.REPOSITORY_URI))) { Properties props = new Properties(); for(Map.Entry<String, String> entry : properties.entrySet()) { if(!JcrUtils.REPOSITORY_URI.equals(entry.getKey())) { props.setProperty(entry.getKey(), entry.getValue()); } } return new TransientRepository(props); } else { Repository repository = JcrUtils.getRepository(properties); if (repository != null) { return repository; } return null; } } }
/** * Checks if multiple {@link RepositoryFactory#getRepository(Map)} calls * return the same repository instance. * * @throws RepositoryException if an error occurs. */ public void testMultipleConnect() throws RepositoryException { setProperties(); repo = JcrUtils.getRepository(); checkRepository(repo); assertSame(repo, JcrUtils.getRepository()); }
@Override public Session get() { if (session == null || !session.isLive()) { try { Repository repository = JcrUtils.getRepository(properties.getIp() + "/crx/server"); SimpleCredentials credentials = new SimpleCredentials(properties.getLogin(), properties.getPassword().toCharArray()); session = repository.login(credentials); } catch (RepositoryException e) { LOG.error("Can't connect with jcr repository", e); } } return session; } }
/** * Checks if a repository can be obtained by specifying JNDI parameters * on {@link RepositoryFactory#getRepository(Map)}. * * @throws Exception if an error occurs. */ public void testJNDI() throws Exception { String name = "jackrabbit-repository"; Map<String, String> parameters = new HashMap<String, String>(); parameters.put(Context.INITIAL_CONTEXT_FACTORY, DummyInitialContextFactory.class.getName()); parameters.put(Context.PROVIDER_URL, "localhost"); InitialContext context = new InitialContext(new Hashtable<String, String>(parameters)); RegistryHelper.registerRepository(context, name, REPO_CONF.getAbsolutePath(), REPO_HOME.getAbsolutePath(), false); try { parameters.put(JndiRepositoryFactory.JNDI_NAME, name); repo = JcrUtils.getRepository(parameters); checkRepository(repo); } finally { RegistryHelper.unregisterRepository(context, name); } }
/** * Checks if a default repository is returned. * * @throws RepositoryException if an error occurs. */ public void testDefaultRepository() throws RepositoryException { setProperties(); repo = JcrUtils.getRepository(); checkRepository(repo); }
/** * Checks if multiple {@link RepositoryFactory#getRepository(Map)} calls * return the same repository instance. * * @throws RepositoryException if an error occurs. */ public void testMultipleConnectWithParameters() throws RepositoryException { resetProperties(); repo = JcrUtils.getRepository(getParamters()); checkRepository(repo); assertSame(repo, JcrUtils.getRepository(getParamters())); }
@Test(timeout = 60 * 1000) public void testRepositoryService() throws Exception{ Map<String,String> config = new HashMap<String, String>(); config.put("org.apache.jackrabbit.repository.home", tmpFolder.getRoot().getAbsolutePath()); config.put("org.apache.jackrabbit.oak.repository.configFile", path("oak-base-config.json")+","+path("oak-tar-config.json")); Repository repository = JcrUtils.getRepository(config); assertNotNull(repository); ((JackrabbitRepository)repository).shutdown(); }
@Before public void setUp() throws Exception { jackrabbitRepository = JcrUtils.getRepository( new File("target", "jackrabbit").toURI().toURL().toString()); oakRepository = new Jcr().createRepository(); writeSessions.add((JackrabbitSession) jackrabbitRepository.login(new SimpleCredentials("admin", "admin".toCharArray()))); writeSessions.add((JackrabbitSession) oakRepository.login(new SimpleCredentials("admin", "admin".toCharArray()))); setupAuthorizables(); setupContent(); readSessions.add(jackrabbitRepository.login(new SimpleCredentials(userId, userId.toCharArray()))); readSessions.add(oakRepository.login(new SimpleCredentials(userId, userId.toCharArray()))); }
/** * Checks if a repository is returned for the given parameters. * * @throws RepositoryException if an error occurs. */ public void testWithParameters() throws RepositoryException { resetProperties(); repo = JcrUtils.getRepository(getParamters()); checkRepository(repo); }
/** * Checks if {@link RepositoryFactory#getRepository(Map)} returns a repository * that can be used even after a previously retrieved repository had been * {@link JackrabbitRepository#shutdown() shutdown}. * * @throws RepositoryException if an error occurs. */ public void testShutdown() throws RepositoryException { setProperties(); for (int i = 0; i < 2; i++) { repo = JcrUtils.getRepository(); checkRepository(repo); ((JackrabbitRepository) repo).shutdown(); } }