use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit by apache.
the class StopJackrabbit method execute.
/**
* {@inheritDoc}
*/
public boolean execute(Context ctx) throws Exception {
if (log.isDebugEnabled()) {
log.debug("stopping jackrabbit");
}
RepositoryImpl repo = (RepositoryImpl) CommandHelper.getRepository(ctx);
if (repo == null) {
throw new IllegalStateException("No current working repository");
}
repo.shutdown();
CommandHelper.setRepository(ctx, null, null);
return false;
}
use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit by apache.
the class SimpleSecurityManager method init.
//------------------------------------------< JackrabbitSecurityManager >---
/**
* @see JackrabbitSecurityManager#init(Repository, Session)
*/
public void init(Repository repository, Session systemSession) throws RepositoryException {
if (initialized) {
throw new IllegalStateException("already initialized");
}
if (!(repository instanceof RepositoryImpl)) {
throw new RepositoryException("RepositoryImpl expected");
}
this.systemSession = systemSession;
config = ((RepositoryImpl) repository).getConfig().getSecurityConfig();
// read the LoginModule configuration
LoginModuleConfig loginModConf = config.getLoginModuleConfig();
authCtxProvider = new AuthContextProvider(config.getAppName(), loginModConf);
if (authCtxProvider.isLocal()) {
log.info("init: using Repository LoginModule configuration for " + config.getAppName());
} else if (authCtxProvider.isJAAS()) {
log.info("init: using JAAS LoginModule configuration for " + config.getAppName());
} else {
String msg = "No valid LoginModule configuriation for " + config.getAppName();
log.error(msg);
throw new RepositoryException(msg);
}
Properties[] moduleConfig = authCtxProvider.getModuleConfig();
// retrieve default-ids (admin and anonymous) from login-module-configuration.
for (Properties aModuleConfig1 : moduleConfig) {
if (aModuleConfig1.containsKey(LoginModuleConfig.PARAM_ADMIN_ID)) {
adminID = aModuleConfig1.getProperty(LoginModuleConfig.PARAM_ADMIN_ID);
}
if (aModuleConfig1.containsKey(LoginModuleConfig.PARAM_ANONYMOUS_ID)) {
anonymID = aModuleConfig1.getProperty(LoginModuleConfig.PARAM_ANONYMOUS_ID);
}
}
// fallback:
if (adminID == null) {
log.debug("No adminID defined in LoginModule/JAAS config -> using default.");
adminID = SecurityConstants.ADMIN_ID;
}
if (anonymID == null) {
log.debug("No anonymousID defined in LoginModule/JAAS config -> using default.");
anonymID = SecurityConstants.ANONYMOUS_ID;
}
// most simple principal provider registry, that does not read anything
// from configuration
PrincipalProvider principalProvider = new SimplePrincipalProvider();
// skip init of provider (nop)
principalProviderRegistry = new ProviderRegistryImpl(principalProvider);
// register all configured principal providers.
for (Properties aModuleConfig : moduleConfig) {
principalProviderRegistry.registerProvider(aModuleConfig);
}
SecurityManagerConfig smc = config.getSecurityManagerConfig();
if (smc != null && smc.getWorkspaceAccessConfig() != null) {
workspaceAccessManager = smc.getWorkspaceAccessConfig().newInstance(WorkspaceAccessManager.class);
} else {
// fallback -> the default simple implementation
log.debug("No WorkspaceAccessManager configured; using default.");
workspaceAccessManager = new SimpleWorkspaceAccessManager();
}
workspaceAccessManager.init(systemSession);
initialized = true;
}
use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit by apache.
the class IndexingQueueTest method testReaderUpToDate.
/*
* Test case for JCR-2082
*/
public void testReaderUpToDate() throws Exception {
BlockingParser.block();
SearchIndex index = getSearchIndex();
File indexDir = new File(index.getPath());
// shutdown workspace
RepositoryImpl repo = (RepositoryImpl) session.getRepository();
session.logout();
session = null;
superuser.logout();
superuser = null;
TestHelper.shutdownWorkspace(getWorkspaceName(), repo);
// delete index
try {
FileUtil.delete(indexDir);
} catch (IOException e) {
fail("Unable to delete index directory");
}
BlockingParser.unblock();
// start workspace again by getting a session
session = getHelper().getSuperuserSession(getWorkspaceName());
qm = session.getWorkspace().getQueryManager();
Query q = qm.createQuery(testPath, Query.XPATH);
assertEquals(1, getSize(q.execute().getNodes()));
}
use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit by apache.
the class CustomPrivilegeTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
resolver = ((SessionImpl) superuser);
// setup the custom privilege file with cyclic references
fs = ((RepositoryImpl) superuser.getRepository()).getConfig().getFileSystem();
FileSystemResource resource = new FileSystemResource(fs, "/privileges/custom_privileges.xml");
if (!resource.exists()) {
resource.makeParentDirs();
}
privilegeRegistry = new PrivilegeRegistry(superuser.getWorkspace().getNamespaceRegistry(), fs);
}
use of org.apache.jackrabbit.core.RepositoryImpl in project jackrabbit by apache.
the class AbstractPerformanceTest method runTest.
private void runTest(AbstractTest test, String name, byte[] conf) {
if (repoPattern.matcher(name).matches() && testPattern.matcher(test.toString()).matches()) {
// Create the repository directory
File dir = new File(new File("target", "repository"), name + "-" + test);
dir.mkdirs();
try {
// Copy the configuration file into the repository directory
File xml = new File(dir, "repository.xml");
OutputStream output = FileUtils.openOutputStream(xml);
try {
output.write(conf, 0, conf.length);
} finally {
output.close();
}
// Create the repository
RepositoryImpl repository = createRepository(dir, xml);
try {
// Run the test
DescriptiveStatistics statistics = runTest(test, repository);
if (statistics.getN() > 0) {
writeReport(test.toString(), name, statistics);
}
} finally {
repository.shutdown();
}
} catch (Throwable t) {
System.out.println("Unable to run " + test + ": " + t.getMessage());
} finally {
FileUtils.deleteQuietly(dir);
}
}
}
Aggregations