use of org.apache.jackrabbit.core.config.RepositoryConfig in project jackrabbit by apache.
the class JCARepositoryManager method createNonTransientRepository.
/**
* Creates a non transient Repository
*
* @param parameters
* @return Repository
* @throws RepositoryException
*/
private Repository createNonTransientRepository(Map<String, String> parameters) throws RepositoryException {
RepositoryConfig config = null;
String configFile = parameters.get(JCAManagedConnectionFactory.CONFIGFILE_KEY);
String homeDir = parameters.get(JCAManagedConnectionFactory.HOMEDIR_KEY);
if (configFile != null && configFile.startsWith(CLASSPATH_CONFIG_PREFIX)) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null) {
cl = this.getClass().getClassLoader();
}
InputStream configInputStream = cl.getResourceAsStream(configFile.substring(CLASSPATH_CONFIG_PREFIX.length()));
try {
config = RepositoryConfig.create(configInputStream, homeDir);
} finally {
if (configInputStream != null) {
try {
configInputStream.close();
} catch (IOException e) {
// ignore
}
}
}
} else if (configFile != null) {
config = RepositoryConfig.create(configFile, homeDir);
} else {
config = RepositoryConfig.create(new File(homeDir));
}
return RepositoryImpl.create(config);
}
use of org.apache.jackrabbit.core.config.RepositoryConfig in project jackrabbit by apache.
the class JackrabbitRepositoryStub method createRepository.
protected Repository createRepository(String dir, String xml) throws Exception {
new File(dir).mkdirs();
if (!new File(xml).exists()) {
InputStream input = getResource("repository.xml");
try {
OutputStream output = new FileOutputStream(xml);
try {
IOUtils.copy(input, output);
} finally {
output.close();
}
} finally {
input.close();
}
}
RepositoryConfig config = RepositoryConfig.create(xml, dir);
return RepositoryImpl.create(config);
}
use of org.apache.jackrabbit.core.config.RepositoryConfig in project jackrabbit by apache.
the class MembershipCacheTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
FileUtils.deleteDirectory(new File(REPO_HOME));
RepositoryConfig config = RepositoryConfig.create(getClass().getResourceAsStream("repository.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
List<User> users = new ArrayList<User>();
for (int i = 0; i < NUM_USERS; i++) {
users.add(userMgr.createUser(TEST_USER_PREFIX + i, "secret"));
}
for (int i = 0; i < NUM_GROUPS; i++) {
Group g = userMgr.createGroup("MembershipCacheTestGroup-" + i);
for (User u : users) {
g.addMember(u);
}
}
session.save();
userMgr.autoSave(autoSave);
logger.info("Initial cache size: " + cache.getSize());
}
use of org.apache.jackrabbit.core.config.RepositoryConfig in project jackrabbit-oak by apache.
the class LongNameTest method upgrade.
private static void upgrade(NodeStore target, boolean skipNameCheck, boolean filterLongNames) throws RepositoryException, IOException {
RepositoryConfig config = createCrx2Config(crx2RepoDir);
RepositoryContext context = RepositoryContext.create(config);
try {
RepositoryUpgrade upgrade = new RepositoryUpgrade(context, target);
upgrade.setCheckLongNames(skipNameCheck);
upgrade.setFilterLongNames(filterLongNames);
upgrade.copy(null);
} finally {
context.getRepository().shutdown();
}
}
use of org.apache.jackrabbit.core.config.RepositoryConfig in project jackrabbit-oak by apache.
the class CopyVersionHistoryTest method performCopy.
protected Session performCopy(VersionCopySetup setup) throws RepositoryException, IOException {
final RepositoryConfig sourceConfig = RepositoryConfig.create(source);
final RepositoryContext sourceContext = RepositoryContext.create(sourceConfig);
final NodeStore targetNodeStore = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
try {
final RepositoryUpgrade upgrade = new RepositoryUpgrade(sourceContext, targetNodeStore);
setup.setup(upgrade.versionCopyConfiguration);
upgrade.setEarlyShutdown(true);
upgrade.copy(null);
} finally {
sourceContext.getRepository().shutdown();
}
repository = (RepositoryImpl) new Jcr(new Oak(targetNodeStore)).createRepository();
Session s = repository.login(AbstractRepositoryUpgradeTest.CREDENTIALS);
sessions.add(s);
return s;
}
Aggregations