Search in sources :

Example 6 with RepositoryConfigException

use of org.eclipse.rdf4j.repository.config.RepositoryConfigException in project rdf4j by eclipse.

the class RemoteRepositoryManager method removeRepository.

@Override
public boolean removeRepository(String repositoryID) throws RepositoryException, RepositoryConfigException {
    boolean existingRepo = hasRepositoryConfig(repositoryID);
    if (existingRepo) {
        try (RDF4JProtocolSession httpClient = getSesameClient().createRDF4JProtocolSession(serverURL)) {
            httpClient.setUsernameAndPassword(username, password);
            httpClient.deleteRepository(repositoryID);
        } catch (IOException e) {
            logger.warn("error while deleting remote repository", e);
            throw new RepositoryConfigException(e);
        }
    }
    return existingRepo;
}
Also used : RDF4JProtocolSession(org.eclipse.rdf4j.http.client.RDF4JProtocolSession) IOException(java.io.IOException) RepositoryConfigException(org.eclipse.rdf4j.repository.config.RepositoryConfigException)

Example 7 with RepositoryConfigException

use of org.eclipse.rdf4j.repository.config.RepositoryConfigException in project rdf4j by eclipse.

the class SystemRepository method createDelegate.

/*---------*
	 * Methods *
	 *---------*/
private Repository createDelegate() {
    RepositoryConfig repoConfig = getSystemConfig();
    if (repoConfig == null) {
        throw new RepositoryConfigException("Could not find SYSTEM configuration");
    }
    repoConfig.validate();
    RepositoryImplConfig config = repoConfig.getRepositoryImplConfig();
    RepositoryFactory factory = RepositoryRegistry.getInstance().get(config.getType()).orElseThrow(() -> new RepositoryConfigException("Repository type not in classpath: " + config.getType()));
    return factory.getRepository(config);
}
Also used : RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) RepositoryImplConfig(org.eclipse.rdf4j.repository.config.RepositoryImplConfig) RepositoryFactory(org.eclipse.rdf4j.repository.config.RepositoryFactory) RepositoryConfigException(org.eclipse.rdf4j.repository.config.RepositoryConfigException)

Example 8 with RepositoryConfigException

use of org.eclipse.rdf4j.repository.config.RepositoryConfigException in project rdf4j by eclipse.

the class SystemRepository method initialize.

@Override
public void initialize() throws RepositoryException {
    super.initialize();
    RepositoryConnection con = getConnection();
    try {
        if (con.isEmpty()) {
            logger.debug("Initializing empty {} repository", ID);
            con.begin();
            con.setNamespace("rdf", RDF.NAMESPACE);
            con.setNamespace("sys", RepositoryConfigSchema.NAMESPACE);
            con.commit();
            RepositoryConfig repConfig = new RepositoryConfig(ID, TITLE, new SystemRepositoryConfig());
            RepositoryConfigUtil.updateRepositoryConfigs(con, repConfig);
        }
    } catch (RepositoryConfigException e) {
        throw new RepositoryException(e.getMessage(), e);
    } finally {
        con.close();
    }
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) RepositoryConfigException(org.eclipse.rdf4j.repository.config.RepositoryConfigException)

Example 9 with RepositoryConfigException

use of org.eclipse.rdf4j.repository.config.RepositoryConfigException in project rdf4j by eclipse.

the class HTTPRepositoryFactory method getRepository.

public Repository getRepository(RepositoryImplConfig config) throws RepositoryConfigException {
    HTTPRepository result = null;
    if (config instanceof HTTPRepositoryConfig) {
        HTTPRepositoryConfig httpConfig = (HTTPRepositoryConfig) config;
        result = new HTTPRepository(httpConfig.getURL());
    // result.setUsernameAndPassword(httpConfig.getUsername(), httpConfig.getPassword());
    } else {
        throw new RepositoryConfigException("Invalid configuration class: " + config.getClass());
    }
    return result;
}
Also used : HTTPRepository(org.eclipse.rdf4j.repository.http.HTTPRepository) RepositoryConfigException(org.eclipse.rdf4j.repository.config.RepositoryConfigException)

Example 10 with RepositoryConfigException

use of org.eclipse.rdf4j.repository.config.RepositoryConfigException in project rdf4j by eclipse.

the class SPARQLRepositoryConfig method parse.

@Override
public void parse(Model m, Resource implNode) throws RepositoryConfigException {
    super.parse(m, implNode);
    try {
        Models.objectIRI(m.filter(implNode, QUERY_ENDPOINT, null)).ifPresent(iri -> setQueryEndpointUrl(iri.stringValue()));
        Models.objectIRI(m.filter(implNode, UPDATE_ENDPOINT, null)).ifPresent(iri -> setUpdateEndpointUrl(iri.stringValue()));
    } catch (ModelException e) {
        throw new RepositoryConfigException(e.getMessage(), e);
    }
}
Also used : ModelException(org.eclipse.rdf4j.model.util.ModelException) RepositoryConfigException(org.eclipse.rdf4j.repository.config.RepositoryConfigException)

Aggregations

RepositoryConfigException (org.eclipse.rdf4j.repository.config.RepositoryConfigException)12 IOException (java.io.IOException)4 File (java.io.File)3 RepositoryConfig (org.eclipse.rdf4j.repository.config.RepositoryConfig)3 Model (org.eclipse.rdf4j.model.Model)2 TreeModel (org.eclipse.rdf4j.model.impl.TreeModel)2 ModelException (org.eclipse.rdf4j.model.util.ModelException)2 RepositoryFactory (org.eclipse.rdf4j.repository.config.RepositoryFactory)2 RepositoryImplConfig (org.eclipse.rdf4j.repository.config.RepositoryImplConfig)2 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 URISyntaxException (java.net.URISyntaxException)1 HttpClientDependent (org.eclipse.rdf4j.http.client.HttpClientDependent)1 RDF4JProtocolSession (org.eclipse.rdf4j.http.client.RDF4JProtocolSession)1 SessionManagerDependent (org.eclipse.rdf4j.http.client.SessionManagerDependent)1 IRI (org.eclipse.rdf4j.model.IRI)1 Value (org.eclipse.rdf4j.model.Value)1 FederatedServiceResolverClient (org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolverClient)1