• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java QueryExceptionHTTP类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.jena.sparql.engine.http.QueryExceptionHTTP的典型用法代码示例。如果您正苦于以下问题:Java QueryExceptionHTTP类的具体用法?Java QueryExceptionHTTP怎么用?Java QueryExceptionHTTP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



QueryExceptionHTTP类属于org.apache.jena.sparql.engine.http包,在下文中一共展示了QueryExceptionHTTP类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: isPerson

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
private boolean isPerson(String uri){
	if(personTypes.isEmpty()){
		return true;
	} else {
		//g et types of URI
		Set<String> types = new HashSet<>();
		try {
			String query = "SELECT ?type WHERE {<" + uri + "> a ?type.}";
			try(QueryExecution qe = qef.createQueryExecution(query)) {
				ResultSet rs = qe.execSelect();
				while(rs.hasNext()){
					types.add(rs.next().getResource("type").getURI());
				}
			}
		} catch (Exception e) {
			int code = ((QueryExceptionHTTP)e.getCause()).getResponseCode();
			logger.warn("SPARQL query execution failed: " + code + " - " + HttpSC.getCode(code).getMessage());
		}
		// check for overlap between types of entity and person types
		return !Sets.intersection(personTypes, types).isEmpty();
	}
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:23,代码来源:TypeAwareGenderDetector.java


示例2: isPerson

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
private boolean isPerson(String uri) {
	if (personTypes.isEmpty()) {
		return true;
	} else {
		// g et types of URI
		Set<String> types = new HashSet<>();
		try {
			String query = "SELECT ?type WHERE {<" + uri + "> a ?type.}";
			try (QueryExecution qe = qef.createQueryExecution(query)) {
				ResultSet rs = qe.execSelect();
				while (rs.hasNext()) {
					types.add(rs.next().getResource("type").getURI());
				}
			}
		} catch (Exception e) {
			int code = ((QueryExceptionHTTP) e.getCause()).getResponseCode();
			logger.warn("SPARQL query execution failed: " + code + " - " + HttpSC.getCode(code).getMessage());
		}
		// check for overlap between types of entity and person types
		return !Sets.intersection(personTypes, types).isEmpty();
	}
}
 
开发者ID:dice-group,项目名称:BENGAL,代码行数:23,代码来源:TypeAwareGenderDetector.java


示例3: fuseki_stop_start

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
@Test
public void fuseki_stop_start() {
    PatchLogServer patchLogServer = patchLogServer();
    FusekiServer server1 = fuseki1();
    try { 
        server1.stop();
        
        RDFConnection conn1 = RDFConnectionFactory.connect("http://localhost:"+F1_PORT+ds1) ;
        QueryExecution qExec = conn1.query("ASK{}");
        try { qExec.execAsk(); fail(); } catch(QueryExceptionHTTP ex) {} 
        // Restart, same port.
        server1 = fuseki1();
        QueryExecution qExec1 = conn1.query("ASK{}");
        qExec1.execAsk();
    } finally {
        server1.stop();
        patchLogServer.stop();
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:20,代码来源:TestDeltaFusekiBad.java


示例4: toResponse

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
@Override
public Response toResponse(QueryExceptionHTTP ex)
{        
    if (ex.getResponseCode() > 0)
        return com.atomgraph.core.model.impl.Response.fromRequest(getRequest()).
            getResponseBuilder(toResource(ex, Response.Status.fromStatusCode(ex.getResponseCode()),
                    ResourceFactory.createResource("http://www.w3.org/2011/http-statusCodes#InternalServerError")).
                getModel(), getVariants()).
            status(ex.getResponseCode()).
            build();
    else
        return com.atomgraph.core.model.impl.Response.fromRequest(getRequest()).
            getResponseBuilder(toResource(ex, Response.Status.INTERNAL_SERVER_ERROR,
                    ResourceFactory.createResource("http://www.w3.org/2011/http-statusCodes#InternalServerError")).
                getModel(), getVariants()).
            status(Response.Status.INTERNAL_SERVER_ERROR).
            build();
}
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:19,代码来源:QueryExceptionHTTPMapper.java


示例5: executeQuery

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
private void executeQuery() throws Exception {
	query = getSparqlQuery(offset, limit);
	final AtomicInteger found = new AtomicInteger();
	Exception currentException = null;
	for (int i = 0; i <= retry; i++) {
		try {
			getSparqlClient().select(query, new ResultSetConsumer() {
				public void useResultSet(ResultSet rs) {
					while (rs.hasNext()) {				
						currentResearcherProcessors.add(getResearcherProcessor(rs.next()));
						found.incrementAndGet();
					}	
				}
			});				
			offset += found.get();
			return;
		}
		catch (QueryExceptionHTTP e) {
			currentException = e;
			LOG.log(Level.WARNING, "Try #" + i, e);			
		}			
	}
	if (currentException != null) {
		throw currentException;
	}
}
 
开发者ID:CTSIatUCSF,项目名称:Crosslinks,代码行数:27,代码来源:SparqlProcessor.java


示例6: getLabelFromKnowledgebase

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
private String getLabelFromKnowledgebase(String iri){
	ParameterizedSparqlString query = new ParameterizedSparqlString(
			"SELECT ?label WHERE {" +
					"?s ?p1 ?o ." +
					"optional {" +
					"		?s ?p ?label. " +
					"		FILTER (LANGMATCHES(LANG(?label),'" + language + "' ))" +
					"	}" +
					"optional {" +
					"     ?s ?p ?label" +
					"   }" +
					"} " +
					"ORDER BY DESC(?label) LIMIT 1");
	query.setIri("s", iri);
	// for each label property
	for (String labelProperty : labelProperties) {
		query.setIri("p", labelProperty);
		try (QueryExecution qe = qef.createQueryExecution(query.toString())){
			ResultSet rs = qe.execSelect();
			if(rs.hasNext()){
				return rs.next().getLiteral("label").getLexicalForm();
			}
		} catch (Exception e) {
			e.printStackTrace();
			int code = -1;
			//cached exception is wrapped in a RuntimeException
			if(e.getCause() instanceof QueryExceptionHTTP){
				code = ((QueryExceptionHTTP)e.getCause()).getResponseCode();
			} else if(e instanceof QueryExceptionHTTP){
				code = ((QueryExceptionHTTP) e).getResponseCode();
			}
			logger.warn("Getting label of " + iri + " from SPARQL endpoint failed: " + code + " - " + HttpSC.getCode(code).getMessage());
		}
	}
	return null;
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:37,代码来源:DefaultIRIConverter.java


示例7: getLabelFromKnowledgebase

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
private String getLabelFromKnowledgebase(String iri) {
	ParameterizedSparqlString query = new ParameterizedSparqlString("SELECT ?label WHERE {" + "?s ?p1 ?o ."
			+ "optional {" + "		?s ?p ?label. " + "		FILTER (LANGMATCHES(LANG(?label),'" + language + "' ))"
			+ "	}" + "optional {" + "     ?s ?p ?label" + "   }" + "} " + "ORDER BY DESC(?label) LIMIT 1");
	query.setIri("s", iri);
	// for each label property
	for (String labelProperty : labelProperties) {
		query.setIri("p", labelProperty);
		try (QueryExecution qe = qef.createQueryExecution(query.toString())) {
			ResultSet rs = qe.execSelect();
			if (rs.hasNext()) {
				return rs.next().getLiteral("label").getLexicalForm();
			}
		} catch (Exception e) {
			e.printStackTrace();
			int code = -1;
			// cached exception is wrapped in a RuntimeException
			if (e.getCause() instanceof QueryExceptionHTTP) {
				code = ((QueryExceptionHTTP) e.getCause()).getResponseCode();
			} else if (e instanceof QueryExceptionHTTP) {
				code = ((QueryExceptionHTTP) e).getResponseCode();
			}
			logger.warn("Getting label of " + iri + " from SPARQL endpoint failed: " + code + " - "
					+ HttpSC.getCode(code).getMessage());
		}
	}
	return null;
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:29,代码来源:DefaultIRIConverterFrench.java


示例8: getLabelFromKnowledgebase

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
private String getLabelFromKnowledgebase(String iri) {
	ParameterizedSparqlString query = new ParameterizedSparqlString("SELECT ?label WHERE {" + "?s ?p1 ?o ."
			+ "optional {" + "		?s ?p ?label. " + "		FILTER (LANGMATCHES(LANG(?label),'" + language + "' ))"
			+ "	}" + "optional {" + "     ?s ?p ?label" + "   }" + "} " + "ORDER BY DESC(?label) LIMIT 1");
	query.setIri("s", iri);
	// for each label property
	for (String labelProperty : labelProperties) {
		query.setIri("p", labelProperty);
		try (QueryExecution qe = qef.createQueryExecution(query.toString())) {
			ResultSet rs = qe.execSelect();
			if (rs.hasNext()) {
				return rs.next().getLiteral("label").getLexicalForm();
			}
		} catch (Exception e) {
			//e.printStackTrace();
			int code = -1;
			// cached exception is wrapped in a RuntimeException
			if (e.getCause() instanceof QueryExceptionHTTP) {
				code = ((QueryExceptionHTTP) e.getCause()).getResponseCode();
			} else if (e instanceof QueryExceptionHTTP) {
				code = ((QueryExceptionHTTP) e).getResponseCode();
			}
			logger.debug("Getting label of " + iri + " from SPARQL endpoint failed: " + code + " - "
					+ HttpSC.getCode(code).getMessage());
		}
	}
	return null;
}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:29,代码来源:DefaultIRIConverterPortuguese.java


示例9: fuseki_stop

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
@Test(expected=QueryExceptionHTTP.class)
public void fuseki_stop() {
    PatchLogServer patchLogServer = patchLogServer();
    FusekiServer server1 = fuseki1();
    try { 
        server1.stop();
        RDFConnection conn1 = RDFConnectionFactory.connect("http://localhost:"+F1_PORT+ds1) ;
        QueryExecution qExec = conn1.query("ASK{}");
        qExec.execAsk();
    } finally {
        patchLogServer.stop();
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:14,代码来源:TestDeltaFusekiBad.java


示例10: categorizeHttpError

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
/**
 * Categorizes a HTTP error based on the status code
 * <p>
 * Where possible this will use specific error categories such as
 * {@link #AUTHENTICATION} or {@link #HTTP_NOT_FOUND} however many possible
 * HTTP status codes are not specifically categorized and will be bucketed
 * into {@link #HTTP_CLIENT_ERROR} or {@link #HTTP_SERVER_ERROR} as
 * appropriate.
 * </p>
 * 
 * @param status
 *            Status Code
 * @return Most appropriate error category
 */
public static int categorizeHttpError(int status) {
    // Specific categories
    switch (status) {
    case -1:
    case QueryExceptionHTTP.noResponseCode:
        // Unknown HTTP status so categorize as an Execution error
        return EXECUTION;
    case HttpStatus.SC_UNAUTHORIZED:
    case HttpStatus.SC_PAYMENT_REQUIRED:
    case HttpStatus.SC_FORBIDDEN:
    case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
    case 419: // 419 - Authentication Timeout - Non-standard
    case 440: // 440 - Login Timeout - Non-standard
        // These are all authentication specific errors
        return AUTHENTICATION;
    case HttpStatus.SC_REQUEST_TIMEOUT:
        // Request timed out
        return TIMEOUT;
    case HttpStatus.SC_NOT_FOUND:
    case HttpStatus.SC_GONE:
        // Resource not found
        return HTTP_NOT_FOUND;
    }

    // General categories
    if (status >= 400 && status < 500) {
        return HTTP_CLIENT_ERROR;
    } else if (status >= 500 && status < 600) {
        return HTTP_SERVER_ERROR;
    } else {
        // Assume some other execution error
        return EXECUTION;
    }
}
 
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:49,代码来源:ErrorCategories.java


示例11: executeSingleTest

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
@Override
protected Collection<TestCaseResult> executeSingleTest(TestSource testSource, TestCase testCase) {

    TestCaseResultStatus status = TestCaseResultStatus.Error;


    try (QueryExecution qe = testSource.getExecutionFactory().createQueryExecution(queryGenerationFactory.getSparqlQuery(testCase))) {
        boolean fail = qe.execAsk();

        if (fail) {
            status = TestCaseResultStatus.Fail;
        } else {
            status = TestCaseResultStatus.Success;
        }

    } catch (QueryExceptionHTTP e) {
        // No need to throw exception here, class supports status
        if (SparqlUtils.checkStatusForTimeout(e)) {
            status = TestCaseResultStatus.Timeout;
        } else {
            status = TestCaseResultStatus.Error;
        }

    }

    return Collections.singletonList(new StatusTestCaseResultImpl(testCase, status));
}
 
开发者ID:AKSW,项目名称:RDFUnit,代码行数:28,代码来源:StatusTestExecutor.java


示例12: executeSingleTest

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
@Override
protected Collection<TestCaseResult> executeSingleTest(TestSource testSource, TestCase testCase) throws TestCaseExecutionException {

    Collection<TestCaseResult> testCaseResults = new ArrayList<>();


    try (QueryExecution qe = testSource.getExecutionFactory().createQueryExecution(queryGenerationFactory.getSparqlQuery(testCase)))
    {

        qe.execSelect().forEachRemaining( qs -> {

            RDFNode focusNode = qs.get("this");
            String message = testCase.getResultMessage();
            if (qs.contains("message")) {
                message = qs.get("message").toString();
            }
            RLOGLevel logLevel = testCase.getLogLevel();

            testCaseResults.add(new ShaclLiteTestCaseResultImpl(testCase.getTestURI(), logLevel, message, focusNode));
        });
    } catch (QueryExceptionHTTP e) {
        checkQueryResultStatus(e);
    }

    return testCaseResults;

}
 
开发者ID:AKSW,项目名称:RDFUnit,代码行数:28,代码来源:ShaclSimpleTestExecutor.java


示例13: checkQueryResultStatus

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
protected void checkQueryResultStatus(QueryExceptionHTTP e) throws TestCaseExecutionException {
    if (SparqlUtils.checkStatusForTimeout(e)) {
        throw new TestCaseExecutionException(TestCaseResultStatus.Timeout, e);
    } else {
        throw new TestCaseExecutionException(TestCaseResultStatus.Error, e);
    }
}
 
开发者ID:AKSW,项目名称:RDFUnit,代码行数:8,代码来源:ShaclSimpleTestExecutor.java


示例14: checkStatusForTimeout

import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; //导入依赖的package包/类
public static boolean checkStatusForTimeout(QueryExceptionHTTP e) {
    int httpCode = e.getResponseCode();

    // 408,504,524 timeout codes from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
    return httpCode == 408 || httpCode == 504 || httpCode == 524;
}
 
开发者ID:AKSW,项目名称:RDFUnit,代码行数:7,代码来源:SparqlUtils.java



注:本文中的org.apache.jena.sparql.engine.http.QueryExceptionHTTP类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LongDigest类代码示例发布时间:2022-05-22
下一篇:
Java ServiceCall类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap