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


Java Problem.getStatus方法代码示例

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


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

示例1: process

import org.zalando.problem.Problem; //导入方法依赖的package包/类
/**
 * Post-process Problem payload to add the message key for front-end if needed
 */
@Override
public ResponseEntity<Problem> process(@Nullable ResponseEntity<Problem> entity, NativeWebRequest request) {
    if (entity == null || entity.getBody() == null) {
        return entity;
    }
    Problem problem = entity.getBody();
    if (!(problem instanceof ConstraintViolationProblem || problem instanceof DefaultProblem)) {
        return entity;
    }
    ProblemBuilder builder = Problem.builder()
        .withType(Problem.DEFAULT_TYPE.equals(problem.getType()) ? ErrorConstants.DEFAULT_TYPE : problem.getType())
        .withStatus(problem.getStatus())
        .withTitle(problem.getTitle())
        .with("path", request.getNativeRequest(HttpServletRequest.class).getRequestURI());

    if (problem instanceof ConstraintViolationProblem) {
        builder
            .with("violations", ((ConstraintViolationProblem) problem).getViolations())
            .with("message", ErrorConstants.ERR_VALIDATION);
        return new ResponseEntity<>(builder.build(), entity.getHeaders(), entity.getStatusCode());
    } else {
        builder
            .withCause(((DefaultProblem) problem).getCause())
            .withDetail(problem.getDetail())
            .withInstance(problem.getInstance());
        problem.getParameters().forEach(builder::with);
        if (!problem.getParameters().containsKey("message") && problem.getStatus() != null) {
            builder.with("message", "error.http." + problem.getStatus().getStatusCode());
        }
        return new ResponseEntity<>(builder.build(), entity.getHeaders(), entity.getStatusCode());
    }
}
 
开发者ID:torgcrm,项目名称:TorgCRM-Server,代码行数:36,代码来源:ExceptionTranslator.java

示例2: write

import org.zalando.problem.Problem; //导入方法依赖的package包/类
private static void write(HttpServerResponse response, Problem problem) {
    int statusCode = problem.getStatus() != null ? problem.getStatus().getStatusCode() : Status.OK.getStatusCode();

    response.setChunked(true).putHeader("Content-Type", "application/problem+json");

    try {
        response
            .setStatusCode(statusCode)
            .write(Json.encode(problem));
    } catch (EncodeException e) {
        LOG.error("Error while writing problem to JSON", e);
        response
            .setStatusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode())
            .write(INTERNAL_SERVER_ERROR);
    } finally {
        response.end();
    }
}
 
开发者ID:valuelogic,项目名称:vertx-web-problem,代码行数:19,代码来源:ProblemHandlerImpl.java

示例3: isServerProblem

import org.zalando.problem.Problem; //导入方法依赖的package包/类
private static boolean isServerProblem(Problem problem) {
    return problem.getStatus() == null ||
            (problem.getStatus().getStatusCode() >= 500 && problem.getStatus().getStatusCode() < 600);
}
 
开发者ID:valuelogic,项目名称:vertx-web-problem,代码行数:5,代码来源:ProblemHandlerImpl.java


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