Search in sources :

Example 11 with RepositoryImpl

use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit by apache.

the class DefaultLoginModuleTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    RepositoryConfig rc = ((RepositoryImpl) superuser.getRepository()).getConfig();
    String workspaceName = rc.getSecurityConfig().getSecurityManagerConfig().getWorkspaceName();
    if (workspaceName == null) {
        workspaceName = rc.getDefaultWorkspaceName();
    }
    securitySession = getHelper().getSuperuserSession(workspaceName);
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl)

Example 12 with RepositoryImpl

use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit by apache.

the class DbClusterTest method test.

public void test() throws RepositoryException {
    RepositoryImpl rep1 = RepositoryImpl.create(RepositoryConfig.create(new File("./target/dbClusterTest/node1")));
    RepositoryImpl rep2 = RepositoryImpl.create(RepositoryConfig.create(new File("./target/dbClusterTest/node2")));
    Session s1 = rep1.login(new SimpleCredentials("admin", "admin".toCharArray()));
    Session s2 = rep2.login(new SimpleCredentials("admin", "admin".toCharArray()));
    s1.getRootNode().addNode("test1");
    s2.getRootNode().addNode("test2");
    s1.save();
    s2.save();
    s1.refresh(true);
    s2.refresh(true);
    s1.getRootNode().getNode("test2");
    s2.getRootNode().getNode("test1");
    rep1.shutdown();
    rep2.shutdown();
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) File(java.io.File) Session(javax.jcr.Session)

Example 13 with RepositoryImpl

use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit-oak by apache.

the class RepeatedRepositoryUpgradeTest method upgradeRepository.

@Before
public synchronized void upgradeRepository() throws Exception {
    if (!upgradeComplete) {
        final File sourceDir = new File(getTestDirectory(), "jackrabbit2");
        sourceDir.mkdirs();
        RepositoryImpl source = createSourceRepository(sourceDir);
        Session session = source.login(CREDENTIALS);
        try {
            createSourceContent(session);
        } finally {
            session.save();
            session.logout();
            source.shutdown();
        }
        final NodeStore target = getTargetNodeStore();
        doUpgradeRepository(sourceDir, target, false);
        fileStore.flush();
        // re-create source repo
        source = createSourceRepository(sourceDir);
        session = source.login(CREDENTIALS);
        try {
            modifySourceContent(session);
        } finally {
            session.save();
            session.logout();
            source.shutdown();
        }
        doUpgradeRepository(sourceDir, target, true);
        fileStore.flush();
        upgradeComplete = true;
    }
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) File(java.io.File) Session(javax.jcr.Session) Before(org.junit.Before)

Example 14 with RepositoryImpl

use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit-oak by apache.

the class LongNameTest method prepareSourceRepository.

@BeforeClass
public static void prepareSourceRepository() throws RepositoryException, IOException, InterruptedException {
    crx2RepoDir = new File("target", "upgrade-" + Clock.SIMPLE.getTimeIncreasing());
    FileUtils.deleteQuietly(crx2RepoDir);
    sourceRepositoryConfig = createCrx2Config(crx2RepoDir);
    RepositoryContext ctx = RepositoryContext.create(sourceRepositoryConfig);
    RepositoryImpl sourceRepository = ctx.getRepository();
    Session session = sourceRepository.login(CREDENTIALS);
    try {
        Assert.assertTrue(TOO_LONG_NAME.getBytes().length > 150);
        Assert.assertTrue(NOT_TOO_LONG_NAME.getBytes().length < 150);
        Node longNameParent = createParent(session.getRootNode());
        Assert.assertTrue(longNameParent.getPath().length() >= 350);
        longNameParent.addNode(TOO_LONG_NAME);
        longNameParent.addNode(NOT_TOO_LONG_NAME);
        session.save();
        Assert.assertTrue(longNameParent.hasNode(TOO_LONG_NAME));
        Assert.assertTrue(longNameParent.hasNode(NOT_TOO_LONG_NAME));
    } finally {
        session.logout();
    }
    sourceRepository.shutdown();
}
Also used : RepositoryContext(org.apache.jackrabbit.core.RepositoryContext) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) Node(javax.jcr.Node) File(java.io.File) Session(javax.jcr.Session) BeforeClass(org.junit.BeforeClass)

Example 15 with RepositoryImpl

use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit-oak by apache.

the class AbstractRepositoryUpgradeTest method upgradeRepository.

@Before
public synchronized void upgradeRepository() throws Exception {
    if (targetNodeStore == null) {
        File directory = getTestDirectory();
        File source = new File(directory, "source");
        source.mkdirs();
        RepositoryImpl repository = createSourceRepository(source);
        Session session = repository.login(CREDENTIALS);
        try {
            createSourceContent(session);
        } finally {
            session.save();
            session.logout();
            repository.shutdown();
        }
        final NodeStore target = getTargetNodeStore();
        doUpgradeRepository(source, target);
        targetNodeStore = target;
    }
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) File(java.io.File) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) Before(org.junit.Before)

Aggregations

RepositoryImpl (org.apache.jackrabbit.core.RepositoryImpl)20 File (java.io.File)12 Session (javax.jcr.Session)9 RepositoryConfig (org.apache.jackrabbit.core.config.RepositoryConfig)6 RepositoryException (javax.jcr.RepositoryException)4 Node (javax.jcr.Node)3 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)3 Before (org.junit.Before)3 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 Properties (java.util.Properties)2 Repository (javax.jcr.Repository)2 SimpleCredentials (javax.jcr.SimpleCredentials)2 Query (javax.jcr.query.Query)2 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)2 RepositoryContext (org.apache.jackrabbit.core.RepositoryContext)2 SessionImpl (org.apache.jackrabbit.core.SessionImpl)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1