本文整理汇总了Java中org.apache.jena.atlas.web.HttpException.getResponseCode方法的典型用法代码示例。如果您正苦于以下问题:Java HttpException.getResponseCode方法的具体用法?Java HttpException.getResponseCode怎么用?Java HttpException.getResponseCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.atlas.web.HttpException
的用法示例。
在下文中一共展示了HttpException.getResponseCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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.
}
示例2: 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.
}
}
示例3: 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;
}
}
示例4: 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;
}
}
示例5: 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;
}
}
示例6: 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;
}
}
示例7: 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);
}