作者:楠楠2502858265 | 来源:互联网 | 2023-09-24 10:27
本文整理了Java中org.apache.olingo.odata2.api.ep.EntityProvider.readErrorDocument()方法的一些代码示
本文整理了Java中org.apache.olingo.odata2.api.ep.EntityProvider.readErrorDocument()
方法的一些代码示例,展示了EntityProvider.readErrorDocument()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EntityProvider.readErrorDocument()
方法的具体详情如下:
包路径:org.apache.olingo.odata2.api.ep.EntityProvider
类名称:EntityProvider
方法名:readErrorDocument
EntityProvider.readErrorDocument介绍
[英]Read (de-serialize) data from error document as InputStream and provide according ODataErrorContext.
[中]将错误文档中的数据作为InputStream读取(反序列化)并根据ODataErrorContext提供。
代码示例
代码示例来源:origin: org.apache.camel.component.olingo2/camel-olingo2-api
public static HttpStatusCodes checkStatus(HttpResponse response) throws ODataApplicationException {
final StatusLine statusLine = response.getStatusLine();
HttpStatusCodes httpStatusCode = HttpStatusCodes.fromStatusCode(statusLine.getStatusCode());
if (400 <= httpStatusCode.getStatusCode() && httpStatusCode.getStatusCode() <= 599) {
if (response.getEntity() != null) {
try {
final ContentType respOnseContentType= ContentType.parse(
response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
final String mimeType = responseContentType.getMimeType();
if (ODATA_MIME_TYPE.matcher(mimeType).matches()) {
final ODataErrorContext errorCOntext= EntityProvider.readErrorDocument(
response.getEntity().getContent(),
responseContentType.toString());
throw new ODataApplicationException(errorContext.getMessage(),
errorContext.getLocale(), httpStatusCode, errorContext.getErrorCode(),
errorContext.getException());
}
} catch (EntityProviderException e) {
throw new ODataApplicationException(e.getMessage(), response.getLocale(), httpStatusCode, e);
} catch (IOException e) {
throw new ODataApplicationException(e.getMessage(), response.getLocale(), httpStatusCode, e);
}
}
throw new ODataApplicationException(statusLine.getReasonPhrase(), response.getLocale(), httpStatusCode);
}
return httpStatusCode;
}
代码示例来源:origin: org.apache.camel/camel-olingo2-api
public static HttpStatusCodes checkStatus(HttpResponse response) throws ODataApplicationException {
final StatusLine statusLine = response.getStatusLine();
HttpStatusCodes httpStatusCode = HttpStatusCodes.fromStatusCode(statusLine.getStatusCode());
if (400 <= httpStatusCode.getStatusCode() && httpStatusCode.getStatusCode() <= 599) {
if (response.getEntity() != null) {
try {
final ContentType respOnseContentType= getContentTypeHeader(response);
final String mimeType = responseContentType.getMimeType();
if (ODATA_MIME_TYPE.matcher(mimeType).matches()) {
final ODataErrorContext errorCOntext= EntityProvider.readErrorDocument(
response.getEntity().getContent(),
responseContentType.toString());
throw new ODataApplicationException(errorContext.getMessage(),
errorContext.getLocale(), httpStatusCode, errorContext.getErrorCode(),
errorContext.getException());
}
} catch (EntityProviderException e) {
throw new ODataApplicationException(e.getMessage(), response.getLocale(), httpStatusCode, e);
} catch (IOException e) {
throw new ODataApplicationException(e.getMessage(), response.getLocale(), httpStatusCode, e);
}
}
throw new ODataApplicationException(statusLine.getReasonPhrase(), response.getLocale(), httpStatusCode);
}
return httpStatusCode;
}