当前位置: 首页>>代码示例>>Java>>正文


Java HttpException类代码示例

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


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


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