Search in sources :

Example 21 with Repository

use of javax.jcr.Repository in project jackrabbit by apache.

the class RepositoryFactoryImplTest method testGetSpi2davexRepository.

public void testGetSpi2davexRepository() throws RepositoryException {
    Map<String, String> parameters = Collections.singletonMap("org.apache.jackrabbit.spi.RepositoryServiceFactory", "org.apache.jackrabbit.spi2davex.Spi2davexRepositoryServiceFactory");
    try {
        Repository repo = factory.getRepository(parameters);
        assertNotNull(repo);
    } catch (RepositoryException e) {
        // factory is working correctly, it is safe to ignore them.
        if (!(ConnectException.class.isInstance(e.getCause()) || DavException.class.isInstance(e.getCause()))) {
            throw e;
        }
    }
}
Also used : Repository(javax.jcr.Repository) RepositoryException(javax.jcr.RepositoryException)

Example 22 with Repository

use of javax.jcr.Repository in project jackrabbit by apache.

the class RepositoryFactoryImplTest method testGetDefaultRepository.

public void testGetDefaultRepository() throws RepositoryException {
    Repository repo = factory.getRepository(null);
    assertNotNull(repo);
    assertEquals("Jackrabbit", repo.getDescriptor(Repository.REP_NAME_DESC));
}
Also used : Repository(javax.jcr.Repository)

Example 23 with Repository

use of javax.jcr.Repository in project jackrabbit by apache.

the class RepositoryFactoryImplTest method testGetRepositoryFromServiceFactory.

public void testGetRepositoryFromServiceFactory() throws RepositoryException {
    Map<String, RepositoryServiceFactory> parameters = Collections.singletonMap("org.apache.jackrabbit.spi.RepositoryServiceFactory", RepositoryServiceFactoryImpl.INSTANCE);
    Repository repo = factory.getRepository(parameters);
    assertNotNull(repo);
}
Also used : Repository(javax.jcr.Repository) RepositoryServiceFactory(org.apache.jackrabbit.spi.RepositoryServiceFactory)

Example 24 with Repository

use of javax.jcr.Repository in project jackrabbit by apache.

the class RepositoryFactoryImplTest method testGetRepositoryFromRepositoryConfig.

public void testGetRepositoryFromRepositoryConfig() throws RepositoryException {
    Map<String, RepositoryConfig> parameters = Collections.singletonMap("org.apache.jackrabbit.jcr2spi.RepositoryConfig", RepositoryConfigImpl.INSTANCE);
    Repository repo = factory.getRepository(parameters);
    assertNotNull(repo);
}
Also used : RepositoryConfig(org.apache.jackrabbit.jcr2spi.config.RepositoryConfig) Repository(javax.jcr.Repository)

Example 25 with Repository

use of javax.jcr.Repository in project jackrabbit by apache.

the class FilterRepositoryFactory method getRepository.

/**
     * Looks up and returns a repository bound in the servlet context of
     * the given filter.
     *
     * @return repository from servlet context
     * @throws RepositoryException if the repository is not available
     */
public Repository getRepository() throws RepositoryException {
    String name = config.getInitParameter(Repository.class.getName());
    if (name == null) {
        name = Repository.class.getName();
    }
    ServletContext context = config.getServletContext();
    Object repository = context.getAttribute(name);
    if (repository instanceof Repository) {
        return (Repository) repository;
    } else if (repository != null) {
        throw new RepositoryException("Invalid repository: Attribute " + name + " in servlet context " + context.getServletContextName() + " is an instance of " + repository.getClass().getName());
    } else {
        throw new RepositoryException("Repository not found: Attribute " + name + " does not exist in servlet context " + context.getServletContextName());
    }
}
Also used : Repository(javax.jcr.Repository) ServletContext(javax.servlet.ServletContext) RepositoryException(javax.jcr.RepositoryException)

Aggregations

Repository (javax.jcr.Repository)107 Session (javax.jcr.Session)31 RepositoryException (javax.jcr.RepositoryException)26 SimpleCredentials (javax.jcr.SimpleCredentials)15 Test (org.junit.Test)13 HashMap (java.util.HashMap)12 Node (javax.jcr.Node)12 DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)10 SlingRepository (org.apache.sling.jcr.api.SlingRepository)10 JackrabbitRepository (org.apache.jackrabbit.api.JackrabbitRepository)9 Oak (org.apache.jackrabbit.oak.Oak)7 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)7 IOException (java.io.IOException)6 Map (java.util.Map)6 InitialContext (javax.naming.InitialContext)6 NamingException (javax.naming.NamingException)6 ServletContext (javax.servlet.ServletContext)5 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)5 File (java.io.File)4 OutputStreamWriter (java.io.OutputStreamWriter)4