use of org.eclipse.rdf4j.model.util.ModelException in project rdf4j by eclipse.
the class AbstractRepositoryImplConfig method create.
/**
* Utility method to create a new {@link RepositoryImplConfig} by reading data from the supplied
* {@link Model}.
*
* @param model
* the {@link Model} to read configuration data from.
* @param implNode
* the subject {@link Resource} identifying the configuration data in the Model.
* @return a new {@link RepositoryImplConfig} initialized with the configuration from the input Model, or
* {@code null} if no {@link RepositoryConfigSchema#REPOSITORYTYPE} property was found in the
* configuration data..
* @throws RepositoryConfigException
* if an error occurred reading the configuration data from the model.
*/
public static RepositoryImplConfig create(Model model, Resource resource) throws RepositoryConfigException {
try {
// Literal typeLit = GraphUtil.getOptionalObjectLiteral(graph,
// implNode, REPOSITORYTYPE);
final Literal typeLit = Models.objectLiteral(model.filter(resource, REPOSITORYTYPE, null)).orElse(null);
if (typeLit != null) {
RepositoryFactory factory = RepositoryRegistry.getInstance().get(typeLit.getLabel()).orElseThrow(() -> new RepositoryConfigException("Unsupported repository type: " + typeLit.getLabel()));
RepositoryImplConfig implConfig = factory.getConfig();
implConfig.parse(model, resource);
return implConfig;
}
return null;
} catch (ModelException e) {
throw new RepositoryConfigException(e.getMessage(), e);
}
}
use of org.eclipse.rdf4j.model.util.ModelException in project rdf4j by eclipse.
the class HTTPRepositoryConfig method parse.
@Override
public void parse(Model model, Resource implNode) throws RepositoryConfigException {
super.parse(model, implNode);
try {
Models.objectIRI(model.filter(implNode, REPOSITORYURL, null)).ifPresent(iri -> setURL(iri.stringValue()));
Models.objectLiteral(model.filter(implNode, USERNAME, null)).ifPresent(username -> setUsername(username.getLabel()));
Models.objectLiteral(model.filter(implNode, PASSWORD, null)).ifPresent(password -> setPassword(password.getLabel()));
} catch (ModelException e) {
throw new RepositoryConfigException(e.getMessage(), e);
}
}
use of org.eclipse.rdf4j.model.util.ModelException 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);
}
}
Aggregations