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

Java HttpException类代码示例

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

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



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

示例1: writeJsonLd

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
private void writeJsonLd(final OutputStream output, final DatasetGraph graph, final IRI... profiles) {
    final String profile = getCustomJsonLdProfile(profiles);
    final RDFFormat format = nonNull(profile) && nonNull(cache) ? JSONLD_COMPACT_FLAT : getJsonLdProfile(profiles);
    final WriterDatasetRIOT writer = RDFDataMgr.createDatasetWriter(format);
    final PrefixMap pm = RiotLib.prefixMap(graph);
    final String base = null;
    final JsonLDWriteContext ctx = new JsonLDWriteContext();
    if (nonNull(profile) && nonNull(cache)) {
        LOGGER.debug("Setting JSON-LD context with profile: {}", profile);
        final String c = cache.get(profile, p -> {
            try (final TypedInputStream res = HttpOp.execHttpGet(profile)) {
                return IOUtils.toString(res.getInputStream(), UTF_8);
            } catch (final IOException | HttpException ex) {
                LOGGER.warn("Error fetching profile {}: {}", p, ex.getMessage());
                return null;
            }
        });
        if (nonNull(c)) {
            ctx.setJsonLDContext(c);
            ctx.setJsonLDContextSubstitution("\"" + profile + "\"");
        }
    }
    writer.write(output, graph, pm, base, ctx);
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:25,代码来源:JenaIOService.java


示例2: call

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
@Override
public UpdateRun call() throws Exception {
    UpdateRequest update = this.getUpdate();
    logger.debug("Running update:\n" + update.toString());

    // Create a remote update processor and configure it appropriately
    UpdateProcessor processor = this.createUpdateProcessor(update);
    this.customizeRequest(processor);

    long startTime = System.nanoTime();
    try {
        // Execute the update
        processor.execute();
    } catch (HttpException e) {
        // Make sure to categorize HTTP errors appropriately
        logger.error("{}", FormatUtils.formatException(e));
        return new UpdateRun(e.getMessage(), ErrorCategories.categorizeHttpError(e), System.nanoTime() - startTime);
    }

    if (this.isCancelled())
        return null;

    long endTime = System.nanoTime();
    return new UpdateRun(endTime - startTime);
}
 
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:26,代码来源:AbstractUpdateCallable.java


示例3: exec

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
@Override
protected void exec() {
    try { 
        dLink.register(clientId) ;
        try { execCmd() ; }
        finally {
            //if ( dLink.isRegistered() )
                dLink.deregister();
        }
    }
    catch (HttpException ex) { throw new CmdException(messageFromHttpException(ex)) ; }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:13,代码来源:DeltaCmd.java


示例4: handle

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
@Override
public void handle(Patch patch) { 
    IndentedLineBuffer x = new IndentedLineBuffer() ;
    RDFChanges scData = new RDFChangesWriteUpdate(x) ;
    patch.play(scData);
    x.flush();
    String reqStr = x.asString() ;
    updateEndpoints.forEach((ep)->{
        try { HttpOp.execHttpPost(ep, WebContent.contentTypeSPARQLUpdate, reqStr) ; }
        catch (HttpException ex) { DPS.LOG.warn("Failed to send to "+ep) ; }
    }) ;
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:13,代码来源:PHandlerGSP.java


示例5: getDLink

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
/** Actively ping the server */
/*package*/ boolean ping() {
    try {
        getDLink().ping();
        return true ;
    } catch (HttpException ex) { return false ; }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:8,代码来源:PatchServer.java


示例6: if

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
/** Run an action that contacts the patch log server.
 * Return true if the action succeeded. 
 * @param action
 * @return
 */
/*package*/ boolean exec(Consumer<DeltaLink> action) {
    if ( !connected() )
        return false;
    try {
        action.accept(getDLink());
        return true;
    } catch (HttpException ex) {
        // Registered?
        handleHttpException(ex);
        return false;
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:18,代码来源:PatchServer.java


示例7: handleHttpException

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
private void handleHttpException(HttpException ex) {
    if ( isConnectionProblem(ex) ) {
        LOG.info("Failed to connect to "+serverURL+" : "+ex.getMessage());
    } else {
        LOG.info("Unrecognized patchlog action problem: "+ex.getMessage(), ex);
    }
    // Broken.
    deltaLink.set(null);
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:10,代码来源:PatchServer.java


示例8: isConnectionProblem

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
private boolean isConnectionProblem(HttpException ex) {
    if ( ex instanceof HttpNotConnectedException ) 
        return true;
    
    if ( ex.getResponseCode() > 0 )
        // Some HTTP status code -> network worked   
        return false;
    if ( ex.getCause() instanceof ConnectException /*IOException*/ )
        return true;
    if ( ex.getCause() instanceof IOException )
        return true;
    LOG.warn("Unrecognized exception: "+ex.getMessage(), ex);
    return true;
    // Unknown.
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:16,代码来源:PatchServer.java


示例9: patchserver_stop_start

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
@Test
public void patchserver_stop_start() {
    PatchLogServer patchLogServer = patchLogServer();
    FusekiServer server1 = fuseki1();
    try { 
        patchLogServer.stop();
        patchLogServer = null;
        
        // Should fail
        try {
            RDFConnection conn0 = RDFConnectionFactory.connect("http://localhost:"+F1_PORT+ds1) ;
            conn0.update(PREFIX+"INSERT DATA { :s :p 'update_patchserver_stop_start' }");
            Assert.fail("Should not be able to update at the moment");
        } catch (HttpException ex) {
            assertEquals(503, ex.getResponseCode());
        }
        
        patchLogServer = patchLogServer(); 

        RDFConnection conn1 = RDFConnectionFactory.connect("http://localhost:"+F1_PORT+ds1) ;
        QueryExecution qExec = conn1.query("ASK{}");
        // 500 due to offline patchLogServer.
        qExec.execAsk();
    } finally {
        server1.stop();
        if ( patchLogServer != null )
            patchLogServer.stop();
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:30,代码来源:TestDeltaFusekiBad.java


示例10: retry

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
/** Perform a retryable operation. Retry only happen if HttpException happens. */
private <T> T retry(Action<T> callable, Supplier<Boolean> retryable, Supplier<String> retryMsg, Supplier<String> failureMsg) {
    for ( int i = 1 ; ; i++ ) {
        try {
            return callable.action();
        } catch (HttpException ex) {
            if ( ex.getResponseCode() == HttpSC.UNAUTHORIZED_401 ) {
                if ( retryable.get() && i < RETRIES_REGISTRATION ) {
                    if ( retryMsg != null  )
                        Delta.DELTA_HTTP_LOG.warn(retryMsg.get());
                    reregister();
                    // Retry.
                    continue;
                }
                if ( failureMsg != null )
                    throw new DeltaNotRegisteredException(failureMsg.get());
                else
                    throw new DeltaNotRegisteredException(ex.getMessage());
            }
            if ( failureMsg != null )
                // Other...
                Delta.DELTA_HTTP_LOG.warn(failureMsg.get());
            throw ex;
        }
        // Any tother exception - don't retry.
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:28,代码来源:DeltaLinkHTTP.java


示例11: fetchCommon

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
private RDFPatch fetchCommon(Id dsRef, String param, Object value, String valueLogStr) {
    checkLink();
    
    String url = remoteReceive;
    url = createURL(url, DeltaConst.paramDatasource, dsRef.asParam());
    url = appendURL(url, value.toString());
    url = addToken(url);
    final String s = url;
    FmtLog.info(Delta.DELTA_HTTP_LOG, "Fetch request: %s %s=%s [%s]", dsRef, param, valueLogStr, url);
    try { 
        return retry(()->{
            // [NET] Network point
            InputStream in = HttpOp.execHttpGet(s) ;
            if ( in == null )
                return null ;
            RDFPatchReaderText pr = new RDFPatchReaderText(in) ;
            RDFChangesCollector collector = new RDFChangesCollector();
            pr.apply(collector);
            return collector.getRDFPatch();
        }, ()->true, ()->"Retry fetch patch.", ()->"Failed to fetch patch.");
    }
    catch ( HttpException ex) {
        if ( ex.getResponseCode() == HttpSC.NOT_FOUND_404 )
            return null ; //throw new DeltaNotFoundException(ex.getMessage());
        throw ex;
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:28,代码来源:DeltaLinkHTTP.java


示例12: sync

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
public void sync() {
    try { 
        checkDeltaConnection();
        PatchLogInfo logInfo = getPatchLogInfo();
        sync(logInfo);
    } catch (HttpException ex) {
        if ( ex.getResponseCode() == -1 )
            throw new HttpException(HttpSC.SERVICE_UNAVAILABLE_503, HttpSC.getMessage(HttpSC.SERVICE_UNAVAILABLE_503), ex.getMessage());
        throw ex;
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:12,代码来源:DeltaConnection.java


示例13: toResponse

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
@Override
public Response toResponse(HttpException ex)
{
    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,代码行数:11,代码来源:HttpExceptionMapper.java


示例14: call

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
@Override
public Boolean call() throws Exception {
	final String ns = ModelFactory.createDefaultModel().createResource(uri).getNameSpace();
	if (ns404.contains(ns)) return false;
	
	try{
		return (RDFDataMgr.loadModel(uri).size() > 0);
	} catch (HttpException httpE){
		if (httpE.getResponseCode() == 404) ns404.add(ns);
		return false;
	} catch (Exception e){
		return false;
	}
}
 
开发者ID:diachron,项目名称:quality,代码行数:15,代码来源:LinkExternalDataProviders.java


示例15: call

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
@Override
public Boolean call() throws Exception {
	final String ns = ResourceBaseURIOracle.extractNameSpace(uri);
	if (ns404.contains(ns)) return false;
	
	try{
		return (RDFDataMgr.loadModel(uri).size() > 0);
	} catch (HttpException httpE){
		if (httpE.getResponseCode() == 404) ns404.add(ns);
		return false;
	} catch (Exception e){
		return false;
	}
}
 
开发者ID:diachron,项目名称:quality,代码行数:15,代码来源:EstimatedLinkExternalDataProviders.java


示例16: messageFromHttpException

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
protected String messageFromHttpException(HttpException ex) {
    Throwable ex2 = ex;
    if ( ex.getCause() != null )
        ex2 = ex.getCause();
    return ex2.getMessage();
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:7,代码来源:DeltaCmd.java


示例17: categorizeHttpError

import org.apache.jena.atlas.web.HttpException; //导入依赖的package包/类
/**
 * Categorizes a {@link HttpException}
 * <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 httpError
 *            HTTP error
 * @return Most appropriate error category
 */
public static int categorizeHttpError(HttpException httpError) {
    int status = httpError.getResponseCode();
    return categorizeHttpError(status);
}
 
开发者ID:rvesse,项目名称:sparql-query-bm,代码行数:19,代码来源:ErrorCategories.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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