use of org.eclipse.rdf4j.repository.base.RepositoryConnectionWrapper in project inception by inception-project.
the class KnowledgeBaseServiceImpl method getConnection.
@Override
public RepositoryConnection getConnection(KnowledgeBase kb) {
assertRegistration(kb);
Repository repo = repoManager.getRepository(kb.getRepositoryId());
if (repo instanceof SPARQLRepository) {
SPARQLRepositoryConfig sparqlRepoConfig = (SPARQLRepositoryConfig) getKnowledgeBaseConfig(kb);
URI uri = URI.create(sparqlRepoConfig.getQueryEndpointUrl());
String userInfo = uri.getUserInfo();
if (StringUtils.isNotBlank(userInfo)) {
userInfo = userInfo.trim();
String username;
String password;
if (userInfo.contains(":")) {
username = substringBefore(userInfo, ":");
password = substringAfter(userInfo, ":");
} else {
username = userInfo;
password = "";
}
SPARQLRepository sparqlRepo = (SPARQLRepository) repo;
sparqlRepo.setUsernameAndPassword(username, password);
}
}
return new RepositoryConnectionWrapper(repo, repo.getConnection()) {
{
skipCertificateChecks(kb.isSkipSslValidation());
}
@Override
public void close() throws RepositoryException {
try {
super.close();
} finally {
restoreSslVerification();
}
}
};
}
Aggregations