Search in sources :

Example 1 with RepositoryConfig

use of org.apache.jackrabbit.core.config.RepositoryConfig in project jackrabbit by apache.

the class SimpleSecurityManagerTest method setUp.

@Override
public void setUp() throws RepositoryException {
    String file = "src/test/resources/org/apache/jackrabbit/core/security/simple/simple_repository.xml";
    RepositoryConfig config = RepositoryConfig.create(file, "target/simple_repository");
    repository = RepositoryImpl.create(config);
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig)

Example 2 with RepositoryConfig

use of org.apache.jackrabbit.core.config.RepositoryConfig in project jackrabbit by apache.

the class StartJackrabbit method execute.

/**
     * {@inheritDoc}
     */
public boolean execute(Context ctx) throws Exception {
    String config = (String) ctx.get(this.configKey);
    String home = (String) ctx.get(this.homeKey);
    if (log.isDebugEnabled()) {
        log.debug("starting jackrabbit. config=" + config + " home=" + home);
    }
    RepositoryConfig conf = RepositoryConfig.create(config, home);
    Repository repo = RepositoryImpl.create(conf);
    CommandHelper.setRepository(ctx, repo, "local " + home);
    return false;
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) Repository(javax.jcr.Repository)

Example 3 with RepositoryConfig

use of org.apache.jackrabbit.core.config.RepositoryConfig in project jackrabbit by apache.

the class StartJackrabbitSingleton method execute.

/**
     * {@inheritDoc}
     */
public boolean execute(Context ctx) throws Exception {
    String config = (String) ctx.get(this.configKey);
    String home = (String) ctx.get(this.homeKey);
    if (log.isDebugEnabled()) {
        log.debug("starting jackrabbit. config=" + config + " home=" + home);
    }
    try {
        synchronized (cache) {
            String key = config + "@" + home;
            Repository repo = (Repository) cache.get(key);
            if (repo == null) {
                String msg = "Starting Jakrabbit instance";
                log.info(msg);
                RepositoryConfig conf = RepositoryConfig.create(config, home);
                repo = RepositoryImpl.create(conf);
                cache.put(key, repo);
            }
            CommandHelper.setRepository(ctx, repo, "local singleton " + home);
        }
    } catch (Exception e) {
        log.error("Unable to start jackrabbit", e);
        throw e;
    }
    return false;
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) Repository(javax.jcr.Repository)

Example 4 with RepositoryConfig

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

the class JackrabbitRepositoryFixture method setUpCluster.

@Override
public Repository[] setUpCluster(int n) throws Exception {
    if (n == 1) {
        String name = "Jackrabbit-" + System.currentTimeMillis();
        File directory = new File(base, name);
        Properties variables = new Properties(System.getProperties());
        variables.setProperty(REPOSITORY_HOME_VARIABLE, directory.getPath());
        variables.setProperty("bundleCacheSize", Integer.toString(bundleCacheSize));
        InputStream xml = getClass().getResourceAsStream("repository.xml");
        RepositoryConfig config = RepositoryConfig.create(new InputSource(xml), variables);
        // Prevent Derby from polluting the current directory
        System.setProperty("derby.stream.error.file", new File(directory, "derby.log").getPath());
        RepositoryImpl repository = RepositoryImpl.create(config);
        this.cluster = new RepositoryImpl[] { repository };
        return new Repository[] { repository };
    } else {
        throw new UnsupportedOperationException("TODO");
    }
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) InputSource(org.xml.sax.InputSource) Repository(javax.jcr.Repository) InputStream(java.io.InputStream) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) Properties(java.util.Properties) File(java.io.File)

Example 5 with RepositoryConfig

use of org.apache.jackrabbit.core.config.RepositoryConfig in project jackrabbit by apache.

the class MembershipCachePerfTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    FileUtils.deleteDirectory(new File(REPO_HOME));
    RepositoryConfig config = RepositoryConfig.create(getClass().getResourceAsStream("repository-membersplit.xml"), REPO_HOME);
    repo = RepositoryImpl.create(config);
    session = createSession();
    userMgr = session.getUserManager();
    cache = ((UserManagerImpl) userMgr).getMembershipCache();
    boolean autoSave = userMgr.isAutoSave();
    userMgr.autoSave(false);
    // create test users and groups
    System.out.printf("Creating %d users...\n", NUM_USERS);
    List<User> users = new ArrayList<User>();
    for (int i = 0; i < NUM_USERS; i++) {
        users.add(userMgr.createUser(TEST_USER_PREFIX + i, "secret"));
    }
    System.out.printf("Creating %d groups...\n", NUM_GROUPS);
    for (int i = 0; i < NUM_GROUPS; i++) {
        Group g = userMgr.createGroup(TEST_GROUP_PREFIX + i);
        for (int j = 0; j < NUM_USERS_PER_GROUP; j++) {
            g.addMember(users.get(j));
        }
        session.save();
        System.out.printf(".").flush();
    }
    userMgr.autoSave(autoSave);
    logger.info("Initial cache size: " + cache.getSize());
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) Group(org.apache.jackrabbit.api.security.user.Group) User(org.apache.jackrabbit.api.security.user.User) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

RepositoryConfig (org.apache.jackrabbit.core.config.RepositoryConfig)23 File (java.io.File)10 RepositoryContext (org.apache.jackrabbit.core.RepositoryContext)7 RepositoryImpl (org.apache.jackrabbit.core.RepositoryImpl)6 RepositoryException (javax.jcr.RepositoryException)5 InputStream (java.io.InputStream)4 Repository (javax.jcr.Repository)4 Session (javax.jcr.Session)4 OutputStream (java.io.OutputStream)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Group (org.apache.jackrabbit.api.security.user.Group)2 User (org.apache.jackrabbit.api.security.user.User)2 RepositoryInitializer (org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 Stopwatch (com.google.common.base.Stopwatch)1 FileOutputStream (java.io.FileOutputStream)1 Method (java.lang.reflect.Method)1 Properties (java.util.Properties)1 ZipFile (java.util.zip.ZipFile)1