當前位置: 首頁>>代碼示例>>Java>>正文


Java StatusType.getFamily方法代碼示例

本文整理匯總了Java中javax.ws.rs.core.Response.StatusType.getFamily方法的典型用法代碼示例。如果您正苦於以下問題:Java StatusType.getFamily方法的具體用法?Java StatusType.getFamily怎麽用?Java StatusType.getFamily使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.ws.rs.core.Response.StatusType的用法示例。


在下文中一共展示了StatusType.getFamily方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toResponse

import javax.ws.rs.core.Response.StatusType; //導入方法依賴的package包/類
@Override
public Response toResponse(@NonNull Exception exception) {
	ResponseBuilder builder;
	StatusType statusInfo;
	if (exception instanceof WebApplicationException) {
		Response response = ((WebApplicationException) exception).getResponse();
		builder = Response.fromResponse(response);
		statusInfo = response.getStatusInfo();
	} else {
		builder = Response.serverError();
		statusInfo = Status.INTERNAL_SERVER_ERROR;
	}

	SimpleExceptionJson simpleExceptionJson = new SimpleExceptionJson(statusInfo.getReasonPhrase(),
			statusInfo.getStatusCode(), exception.getMessage());
	builder.entity(simpleExceptionJson);
	builder.type("application/problem+json");

	if (statusInfo.getFamily() == Family.CLIENT_ERROR) {
		log.debug("Got client Exception", exception);
	} else {
		log.error("Sending error to client", exception);
	}

	return builder.build();
}
 
開發者ID:Mercateo,項目名稱:rest-jersey-utils,代碼行數:27,代碼來源:RFCExceptionMapper.java

示例2: httpErrorContent

import javax.ws.rs.core.Response.StatusType; //導入方法依賴的package包/類
/**
 * Creates an ErrorContent for a HTTP {@link ErrorSource#CLIENT_ERROR client}- or
 * {@link ErrorSource#SERVER_ERROR server} error.
 *
 * @param position the content position
 * @param response the HTTP response. This must either by a client-error response or a server-error response.
 * @param startedTs the timestamp when fetching the content has started.
 * @return ErrorContent
 * @throws IllegalArgumentException if the response is not a client- or server error response.
 */
public static ErrorContent httpErrorContent(final String source,
                                            final Position position,
                                            final Response response,
                                            final long startedTs) {
    final StatusType statusInfo = response.getStatusInfo();
    final Family family = statusInfo.getFamily();

    checkArgument(HTTP_ERRORS.contains(family),
            "Response is not a HTTP client or server error");

    final ErrorSource errorSource = family == CLIENT_ERROR
            ? ErrorSource.CLIENT_ERROR
            : ErrorSource.SERVER_ERROR;

    return new ErrorContent(source, position, statusInfo.getReasonPhrase(), errorSource, startedTs);
}
 
開發者ID:otto-de,項目名稱:rx-composer,代碼行數:27,代碼來源:ErrorContent.java

示例3: status

import javax.ws.rs.core.Response.StatusType; //導入方法依賴的package包/類
static void status(final StatusType statusInfo, final Family expectedFamily,
                   final Status... expectedStatuses) {
    requireNonNull(statusInfo, "null statusInfo");
    final Family actualFamily = statusInfo.getFamily();
    final int statusCode = statusInfo.getStatusCode();
    final String reasonPhrase = statusInfo.getReasonPhrase();
    logger.debug("-> response.status: {} {}", statusCode, reasonPhrase);
    if (expectedFamily != null) {
        assertEquals(actualFamily, expectedFamily);
    }
    if (expectedStatuses != null && expectedStatuses.length > 0) {
        assertTrue(
                Stream.of(expectedStatuses).map(Status::getStatusCode)
                .filter(v -> v == statusCode)
                .findAny()
                .isPresent()
        );
    }
}
 
開發者ID:jinahya,項目名稱:kt-ucloud-storage-client,代碼行數:20,代碼來源:StorageClientWsRsITs.java

示例4: setStatusInfo

import javax.ws.rs.core.Response.StatusType; //導入方法依賴的package包/類
public void setStatusInfo(final StatusType statusInfo) {
    if (statusInfo != null) {
        statusCode = statusInfo.getStatusCode();
        family = statusInfo.getFamily();
        reasonPhrase = statusInfo.getReasonPhrase();
    } else {
        setStatusInfo(Status.OK);
    }
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:10,代碼來源:MinijaxStatusInfo.java

示例5: assertSuccesfulAuthentication

import javax.ws.rs.core.Response.StatusType; //導入方法依賴的package包/類
@Override
protected int assertSuccesfulAuthentication(final Response response) {
    final StatusType statusInfo = response.getStatusInfo();
    final Family family = statusInfo.getFamily();
    final int statusCode = statusInfo.getStatusCode();
    final String reasonPhrase = statusInfo.getReasonPhrase();
    assertEquals(family, SUCCESSFUL,
                 "status: " + statusCode + " " + reasonPhrase);
    return statusCode;
}
 
開發者ID:jinahya,項目名稱:kt-ucloud-storage-client,代碼行數:11,代碼來源:StorageClientWsRsIT.java

示例6: assertSuccessful

import javax.ws.rs.core.Response.StatusType; //導入方法依賴的package包/類
public static void assertSuccessful(Response response) {

    final StatusType responseStatus = response.getStatusInfo();
    if (responseStatus.getFamily() != Status.Family.SUCCESSFUL) {

      final StringBuilder sb = new StringBuilder();
      sb.append("Response ").append(responseStatus.getStatusCode()).append(" ").append(responseStatus.getReasonPhrase());
      if (response.hasEntity()) {
        sb.append(", Response: ").append(response.readEntity(String.class));
      }
      throw new AssertionError(sb);
    }
  }
 
開發者ID:atgse,項目名稱:sam,代碼行數:14,代碼來源:TestHelper.java

示例7: checkResponseAndGetOutput

import javax.ws.rs.core.Response.StatusType; //導入方法依賴的package包/類
/**
 * Check the response code. If successful, return the entity with the given return type,
 * otherwise throw an exception.
 * @param response
 * @param returnType
 * @return The entity from the given {@link ClientResponse} if available
 */
protected <T> T checkResponseAndGetOutput(String httpMethod, Builder builder, Response response, Class<T> returnType) {
	StatusType status = response.getStatusInfo();
	if ( status != null && status.getFamily() == Family.SUCCESSFUL ) {
		return getSuccessfulResponse(response, returnType, status);
	} else {
		throw getUnsuccesfulResponseException(response);
	}
}
 
開發者ID:fod-dev,項目名稱:FoDBugTrackerUtility,代碼行數:16,代碼來源:RestConnection.java


注:本文中的javax.ws.rs.core.Response.StatusType.getFamily方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。