use of org.eclipse.rdf4j.repository.RepositoryException 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.RepositoryException in project rdf4j by eclipse.
the class RepositoryManager method removeRepositoryConfig.
/**
* Removes the configuration for the specified repository from the manager's system repository if such a
* configuration is present. Returns <tt>true</tt> if the system repository actually contained the
* specified repository configuration.
*
* @param repositoryID
* The ID of the repository whose configuration needs to be removed.
* @throws RepositoryException
* If the manager failed to update it's system repository.
* @throws RepositoryConfigException
* If the manager doesn't know how to remove a configuration due to inconsistent configuration
* data in the system repository. For example, this happens when there are multiple existing
* configurations with the concerning ID.
* @deprecated since 2.6.7. Use {@link #removeRepository(String repositoryID)} instead.
*/
@Deprecated
public boolean removeRepositoryConfig(String repositoryID) throws RepositoryException, RepositoryConfigException {
logger.debug("Removing repository configuration for {}.", 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.RepositoryException in project rdf4j by eclipse.
the class HTTPRepositoryConnection method setNamespace.
public void setNamespace(String prefix, String name) throws RepositoryException {
if (prefix == null) {
throw new NullPointerException("prefix must not be null");
}
if (name == null) {
throw new NullPointerException("name must not be null");
}
if (this.getRepository().useCompatibleMode()) {
boolean localTransaction = startLocalTransaction();
txn.add(new SetNamespaceOperation(prefix, name));
conditionalCommit(localTransaction);
return;
}
try {
client.setNamespacePrefix(prefix, name);
} catch (IOException e) {
throw new RepositoryException(e);
}
}
use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.
the class HTTPGraphQuery method evaluate.
/*
* public GraphQueryResult evaluate() throws QueryEvaluationException { HTTPClient client =
* httpCon.getRepository().getHTTPClient(); try { return client.sendGraphQuery(queryLanguage, queryString,
* baseURI, dataset, includeInferred, maxQueryTime, getBindingsArray()); } catch (IOException e) { throw
* new HTTPQueryEvaluationException(e.getMessage(), e); } catch (RepositoryException e) { throw new
* HTTPQueryEvaluationException(e.getMessage(), e); } catch (MalformedQueryException e) { throw new
* HTTPQueryEvaluationException(e.getMessage(), e); } }
*/
public void evaluate(RDFHandler handler) throws QueryEvaluationException, RDFHandlerException {
SPARQLProtocolSession client = getHttpClient();
try {
conn.flushTransactionState(Protocol.Action.QUERY);
client.sendGraphQuery(queryLanguage, queryString, baseURI, dataset, includeInferred, getMaxExecutionTime(), handler, getBindingsArray());
} catch (IOException e) {
throw new HTTPQueryEvaluationException(e.getMessage(), e);
} catch (RepositoryException e) {
throw new HTTPQueryEvaluationException(e.getMessage(), e);
} catch (MalformedQueryException e) {
throw new HTTPQueryEvaluationException(e.getMessage(), e);
}
}
use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.
the class RepositoryConfigUtil method getRepositoryConfig.
@Deprecated
public static RepositoryConfig getRepositoryConfig(Repository repository, String repositoryID) throws RepositoryConfigException, RepositoryException {
RepositoryConnection con = repository.getConnection();
try {
Statement idStatement = getIDStatement(con, repositoryID);
if (idStatement == null) {
// No such config
return null;
}
Resource repositoryNode = idStatement.getSubject();
Resource context = idStatement.getContext();
if (context == null) {
throw new RepositoryException("No configuration context for repository " + repositoryID);
}
Model contextGraph = QueryResults.asModel(con.getStatements(null, null, null, true, context));
return RepositoryConfig.create(contextGraph, repositoryNode);
} finally {
con.close();
}
}
Aggregations