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


Java ClientResponse.getResponseStatus方法代码示例

本文整理汇总了Java中org.jboss.resteasy.client.ClientResponse.getResponseStatus方法的典型用法代码示例。如果您正苦于以下问题:Java ClientResponse.getResponseStatus方法的具体用法?Java ClientResponse.getResponseStatus怎么用?Java ClientResponse.getResponseStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.resteasy.client.ClientResponse的用法示例。


在下文中一共展示了ClientResponse.getResponseStatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
public void handle(ClientResponse response) throws RuntimeException {
    try {
        BaseClientResponse r = (BaseClientResponse) response;

        InputStream stream = r.getStreamFactory().getInputStream();
        if (stream != null) {
            stream.reset();
        }
        if ((response.getResponseStatus() != null) && (response.getResponseStatus().getStatusCode() == 404)
            && !(r.getException() instanceof ItemNotFoundException)) {
            throw new WebApplicationException(Response
            .status(Response.Status.INTERNAL_SERVER_ERROR)
            .entity(new ApiError("Error at " + response.getHeaders().get("full-path")))
            .build());
        }

    } catch (IOException e){
        //...
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:21,代码来源:MyClientErrorInterceptor.java

示例2: execute

import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
public ClientResponse execute(ClientExecutionContext ctx) throws Exception {
    ClientRequest request = ctx.getRequest();
    ClientResponse response = null;

    response = ctx.proceed();
    if ((response.getResponseStatus() != null) && (response.getResponseStatus().getStatusCode() == 404)) {
        BaseClientResponse r = (BaseClientResponse) response;
        MultivaluedMap<String, String> headers = r.getHeaders();
        headers.add("full-path", request.getUri());
        r.setHeaders(headers);
    }
    return response;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:14,代码来源:MyClientExecutionInterceptor.java

示例3: handle

import org.jboss.resteasy.client.ClientResponse; //导入方法依赖的package包/类
@Override
public void handle(ClientResponse<?> response) throws RuntimeException {

    // Whatever the error is, let's nullify the current access token response.
    AuthTokenManager.this.accessTokenResponse = null;

    // Handle some of the common errors.
    String error = null;
    Exception exception = null;

    try {

        BaseClientResponse r = (BaseClientResponse) response;
        InputStream stream = r.getStreamFactory().getInputStream();
        stream.reset();

        if (Response.Status.FORBIDDEN.equals(response.getResponseStatus())) {
            error = "Error handling the Keycloak token, status is FORBIDDEN";
        } else if (Response.Status.UNAUTHORIZED.equals(response.getResponseStatus())) {
            error = "Error handling the Keycloak token, status is UNAUTHORIZED";
        } else if (Response.Status.BAD_REQUEST.equals(response.getResponseStatus())) {
            error = "Error handling the Keycloak token, status is BAD_REQUEST. Response data: " + getResponseData(r);
        } else if (Response.Status.NOT_FOUND.equals(response.getResponseStatus())) {
            error = "Error handling the Keycloak token, status is NOT_FOUND.";
        } else if (!Response.Status.OK.equals(response.getResponseStatus())) {
            error = "Error handling the Keycloak token. Response status is " + response.getResponseStatus() +
                    ". Response data: " + getResponseData(r);
        }
    } catch (IOException e) {

        error = "Error handling the Keycloak token.";
        exception = e;
    } finally {

        response.releaseConnection();
    }

    // If error is handled here, log it and throw the exception.
    // Otherwise, let's Resteasy do the generic work after a client error.
    if (null != error) {

        LOG.error(error);

        if (null != exception) {
            throw new RuntimeException(error,
                                       exception);
        } else {
            throw new RuntimeException(error);
        }
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:52,代码来源:AuthTokenManager.java


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