com.vmware.xenon.common.Utils.toValidationErrorResponse()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中com.vmware.xenon.common.Utils.toValidationErrorResponse()方法的一些代码示例,展示了Utils.toValidationErrorResponse()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.toValidationErrorResponse()方法的具体详情如下:
包路径:com.vmware.xenon.common.Utils
类名称:Utils
方法名:toValidationErrorResponse

Utils.toValidationErrorResponse介绍

暂无

代码示例

代码示例来源:origin: vmware/admiral

protected ServiceErrorResponse getServiceErrorResponse(Throwable t) {
  Operation operation = null;
  if (locale != null) {
    operation = new Operation().addRequestHeader(Operation.ACCEPT_LANGUAGE_HEADER,
        locale);
  }
  return Utils.toValidationErrorResponse(t, operation);
}

代码示例来源:origin: vmware/admiral

private String toReadableErrorMessage(Throwable e, Operation op) {
  LocalizableValidationException localizedEx = null;
  if (e instanceof io.netty.handler.codec.DecoderException) {
    if (e.getMessage().contains("Received fatal alert: bad_certificate")) {
      localizedEx = new LocalizableValidationException("Check login credentials",
          "compute.check.credentials");
    }
  } else if (e instanceof IllegalStateException) {
    if (e.getMessage().contains("Socket channel closed:")) {
      localizedEx = new LocalizableValidationException("Check login credentials",
          "compute.check.credentials");
    }
  } else if (e.getCause() instanceof ConnectTimeoutException) {
    localizedEx = new LocalizableValidationException(e, "Connection timeout",
        "compute.connection.timeout");
  } else if (e.getCause() instanceof ProtocolException) {
    localizedEx = new LocalizableValidationException(e, "Protocol exception",
        "compute.protocol.exception");
  } else if (e instanceof IllegalArgumentException) {
    localizedEx = new LocalizableValidationException(e,
        "Illegal argument exception: " + e.getMessage(), "compute.illegal.argument",
        e.getMessage());
  }
  if (localizedEx == null) {
    localizedEx = new LocalizableValidationException(e,
        String.format("Unexpected error: %s", e.getMessage()),
        "compute.unexpected.error", e.getMessage());
  }
  return Utils.toValidationErrorResponse(localizedEx, op).message;
}

代码示例来源:origin: vmware/admiral

private void validatePlainHttpConnection(Service sender, HostSpec hostSpec, Operation op,
    Runnable callbackFunction) {
  boolean allowRegistryInsecureConnection = Boolean.valueOf(
      ConfigurationUtil.getProperty(ALLOW_REGISTRY_PLAIN_HTTP_CONNECTION_PROP_NAME));
  if (!hostSpec.isSecureScheme() && !allowRegistryInsecureConnection) {
    String message = String.format("Plain HTTP registry connections are not allowed.");
    LocalizableValidationException ex = new LocalizableValidationException(message,
        "compute.registry.plain.http.not.allowed");
    ServiceErrorResponse rsp = Utils.toValidationErrorResponse(ex, op);
    logSevere(rsp.message);
    op.setStatusCode(Operation.STATUS_CODE_BAD_REQUEST);
    op.fail(ex, rsp);
  } else {
    callbackFunction.run();
  }
}

代码示例来源:origin: vmware/admiral

"compute.unexpected.error", e.getMessage());
ServiceErrorResponse rsp = Utils.toValidationErrorResponse(localizedEx, op);

代码示例来源:origin: vmware/admiral

message, "compute.add.host.connection.error",
    hostSpec.uri.toString(), e.getMessage());
ServiceErrorResponse rsp = Utils.toValidationErrorResponse(ex, op);
logger.severe(rsp.message);
op.setStatusCode(o.getStatusCode());

代码示例来源:origin: vmware/xenon

if (Utils.isValidationError(e)) {
  this.statusCode = STATUS_CODE_BAD_REQUEST;
  rsp = Utils.toValidationErrorResponse(e, this);
} else {
  rsp = Utils.toServiceErrorResponse(e);

代码示例来源:origin: vmware/admiral

message, "compute.add.host.connection.error", cs.address,
    innerMessage);
ServiceErrorResponse rsp = Utils.toValidationErrorResponse(validationEx,
    op);

相关文章