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


Java Status.fromStatusCode方法代码示例

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


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

示例1: apply

import javax.ws.rs.core.Response.Status; //导入方法依赖的package包/类
@Override
public Response apply(@NonNull ContainerRequestContext context) {
  String statusCode = context.getUriInfo().getPathParameters().getFirst(
      ErrorModule.SERVLET_ERROR_STATUS_CODE_PARAMETER);

  if (statusCode == null) {
    throw new IllegalArgumentException(String.format("Path parameter '%s' is required.",
        ErrorModule.SERVLET_ERROR_STATUS_CODE_PARAMETER));
  }

  Status responseStatus = Status.fromStatusCode(Integer.parseInt(statusCode));

  if (responseStatus == null) {
    throw new IllegalArgumentException(String.format("Status code '%s' is unknown.", statusCode));
  }

  return Response.status(responseStatus).type(MediaType.TEXT_PLAIN_TYPE).entity(
      responseStatus.getReasonPhrase()).build();
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:20,代码来源:ServletErrorHandler.java

示例2: convertExceptionToJsonResponse

import javax.ws.rs.core.Response.Status; //导入方法依赖的package包/类
public static ErrorResponse convertExceptionToJsonResponse(int status, WebApplicationException webAppException)
{
	final ErrorResponse err = new ErrorResponse();
	err.setCode(status);
	String msg = webAppException.getMessage();
	// if we happen to be using an 'unofficial' HTTP code, just repeat the
	// exception message
	String statusCodeErr = Status.fromStatusCode(status) != null ? Status.fromStatusCode(status).getReasonPhrase()
		: msg;
	err.setError(statusCodeErr);
	if( webAppException.getCause() != null )
	{
		msg = webAppException.getCause().getMessage();
	}
	err.setErrorDescription(msg);
	return err;
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:RestEasyExceptionMapper.java

示例3: buildAuthenticationErrorResponse

import javax.ws.rs.core.Response.Status; //导入方法依赖的package包/类
/**
 * Build an authentication error response
 * @param schemes Optional allowed authentication schemes
 * @param errorCode Optional error code
 * @param errorDescription Optional error description
 * @param statusCode HTTP status code
 * @param realmName Optional realm name
 * @return Authentication error response
 */
public static Response buildAuthenticationErrorResponse(String[] schemes, String errorCode, String errorDescription,
		int statusCode, String realmName) {

	// status
	Status status = Status.UNAUTHORIZED;
	if (statusCode > 0) {
		Status errorStatus = Status.fromStatusCode(statusCode);
		if (errorStatus != null) {
			status = errorStatus;
		}
	}

	// response
	ResponseBuilder responseBuilder = Response.status(status);

	if (schemes != null && schemes.length > 0) {
		for (String scheme : schemes) {
			responseBuilder.header(HttpHeaders.WWW_AUTHENTICATE,
					buildAuthenticationErrorHeader(scheme, errorCode, errorDescription, realmName));
		}
	}

	// response
	return responseBuilder.header(HttpHeaders.CACHE_CONTROL, "no-store").header(HttpHeaders.PRAGMA, "no-cache")
			.build();
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:36,代码来源:ResponseUtils.java

示例4: setStatusInfo

import javax.ws.rs.core.Response.Status; //导入方法依赖的package包/类
public void setStatusInfo(final int statusCode) {
    final Status status = Status.fromStatusCode(statusCode);
    if (status != null) {
        setStatusInfo(status);
    } else {
        setStatusCode(statusCode);
        setFamily(Status.Family.OTHER);
        setReasonPhrase(null);
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:11,代码来源:MinijaxStatusInfo.java


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