use of org.eclipse.rdf4j.repository.Repository in project rdf4j by eclipse.
the class LocalRepositoryManager method createRepository.
@Override
protected Repository createRepository(String id) throws RepositoryConfigException, RepositoryException {
Repository repository = null;
RepositoryConfig repConfig = getRepositoryConfig(id);
if (repConfig != null) {
repConfig.validate();
repository = createRepositoryStack(repConfig.getRepositoryImplConfig());
repository.setDataDir(getRepositoryDir(id));
repository.initialize();
}
return repository;
}
use of org.eclipse.rdf4j.repository.Repository in project rdf4j by eclipse.
the class NotifyingTest method testRemove.
@Test
public void testRemove() throws Exception {
ValueFactory vf = SimpleValueFactory.getInstance();
final IRI uri = vf.createIRI("http://example.com/");
final RepositoryConnection stub = new RepositoryConnectionStub() {
protected void removeWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException {
}
};
Repository repo = stub.getRepository();
NotifyingRepositoryConnection con = new NotifyingRepositoryConnectionWrapper(repo, stub);
con.addRepositoryConnectionListener(new RepositoryConnectionListenerAdapter() {
public void remove(RepositoryConnection conn, Resource subject, IRI predicate, Value object, Resource... contexts) {
assertEquals(stub, conn);
assertEquals(uri, subject);
assertEquals(uri, predicate);
assertEquals(uri, object);
assertEquals(0, contexts.length);
}
});
con.remove(con.getValueFactory().createStatement(uri, uri, uri));
}
use of org.eclipse.rdf4j.repository.Repository in project rdf4j by eclipse.
the class RepositoryManager method removeRepository.
/**
* Removes the specified repository by deleting its configuration from the manager's system repository if
* such a configuration is present, and removing any persistent data associated with the repository.
* Returns <tt>true</tt> if the system repository actually contained the specified repository
* configuration. <strong>NB this operation can not be undone!</strong>
*
* @param repositoryID
* The ID of the repository that needs to be removed.
* @throws RepositoryException
* If the manager failed to update its system repository.
* @throws RepositoryConfigException
* If the manager doesn't know how to remove a repository due to inconsistent configuration data
* in the system repository. For example, this happens when there are multiple existing
* configurations with the concerning ID.
*/
public boolean removeRepository(String repositoryID) throws RepositoryException, RepositoryConfigException {
logger.debug("Removing repository {}.", repositoryID);
boolean isRemoved = hasRepositoryConfig(repositoryID);
synchronized (initializedRepositories) {
// update SYSTEM repository if there is one for 2.2 compatibility
Repository systemRepository = getSystemRepository();
if (systemRepository != null) {
RepositoryConfigUtil.removeRepositoryConfigs(systemRepository, repositoryID);
}
if (isRemoved) {
logger.debug("Shutdown repository {} after removal of configuration.", repositoryID);
Repository repository = initializedRepositories.remove(repositoryID);
if (repository != null && repository.isInitialized()) {
repository.shutDown();
}
try {
cleanUpRepository(repositoryID);
} catch (IOException e) {
throw new RepositoryException("Unable to clean up resources for removed repository " + repositoryID, e);
}
}
}
return isRemoved;
}
use of org.eclipse.rdf4j.repository.Repository in project rdf4j by eclipse.
the class RepositoryManager method getRepository.
/**
* Gets the repository that is known by the specified ID from this manager.
*
* @param identity
* A repository ID.
* @return An initialized Repository object, or <tt>null</tt> if no repository was known for the specified
* ID.
* @throws RepositoryConfigException
* If no repository could be created due to invalid or incomplete configuration data.
*/
@Override
public Repository getRepository(String identity) throws RepositoryConfigException, RepositoryException {
synchronized (initializedRepositories) {
updateInitializedRepositories();
Repository result = initializedRepositories.get(identity);
if (result != null && !result.isInitialized()) {
// repository exists but has been shut down. throw away the old
// object so we can re-read from the config.
initializedRepositories.remove(identity);
result = null;
}
if (result == null && SystemRepository.ID.equals(identity)) {
result = getSystemRepository();
}
if (result == null) {
// First call (or old object thrown away), create and initialize the
// repository.
result = createRepository(identity);
if (result != null) {
initializedRepositories.put(identity, result);
}
}
return result;
}
}
use of org.eclipse.rdf4j.repository.Repository in project rdf4j by eclipse.
the class RepositoryManager method getSystemRepository.
/**
* Gets the SYSTEM repository.
*/
@Deprecated
public Repository getSystemRepository() {
if (!isInitialized()) {
throw new IllegalStateException("Repository Manager is not initialized");
}
synchronized (initializedRepositories) {
Repository systemRepository = initializedRepositories.get(SystemRepository.ID);
if (systemRepository != null && systemRepository.isInitialized()) {
return systemRepository;
}
systemRepository = createSystemRepository();
if (systemRepository != null) {
initializedRepositories.put(SystemRepository.ID, systemRepository);
}
return systemRepository;
}
}
Aggregations