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

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

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

Utils.toServiceErrorResponse介绍

暂无

代码示例

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

private void patchTask(MockDockerHostAdapterImageService.MockAdapterRequest state,
    Throwable exception) {
  patchTaskErrorResponse(state,
      exception == null ? null : Utils.toServiceErrorResponse(exception));
}

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

public TaskState validateMock() {
    TaskState taskInfo = new TaskState();
    try {
      validate();
    } catch (Exception e) {
      taskInfo.stage = TaskStage.FAILED;
      taskInfo.failure = Utils.toServiceErrorResponse(e);
    }
    return taskInfo;
  }
}

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

public TaskState validateMock() {
    TaskState taskInfo = new TaskState();
    try {
      validate();
    } catch (Exception e) {
      taskInfo.stage = TaskStage.FAILED;
      taskInfo.failure = Utils.toServiceErrorResponse(e);
    }
    return taskInfo;
  }
}

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

public TaskState validateMock() {
    TaskState taskInfo = new TaskState();
    try {
      validate();
    } catch (Exception e) {
      taskInfo.stage = TaskState.TaskStage.FAILED;
      taskInfo.failure = Utils.toServiceErrorResponse(e);
    }
    return taskInfo;
  }
}

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

public TaskState validateMock() {
    TaskState taskInfo = new TaskState();
    try {
      validate();
    } catch (Exception e) {
      taskInfo.stage = TaskStage.FAILED;
      taskInfo.failure = Utils.toServiceErrorResponse(e);
    }
    return taskInfo;
  }
}

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

public TaskState validateMock() {
    TaskState taskInfo = new TaskState();
    try {
      validate();
    } catch (Exception e) {
      taskInfo.stage = TaskStage.FAILED;
      taskInfo.failure = Utils.toServiceErrorResponse(e);
    }
    return taskInfo;
  }
}

代码示例来源:origin: com.vmware.photon.controller/photon-model-tasks

private void failTask(Throwable e, String messageFormat, Object... args) {
  String message = String.format(messageFormat, args);
  logWarning(() -> message);
  ResourceIPDeallocationTaskState body = new ResourceIPDeallocationTaskState();
  body.taskInfo = new TaskState();
  body.taskInfo.stage = TaskState.TaskStage.FAILED;
  body.taskInfo.failure = Utils.toServiceErrorResponse(e);
  sendSelfPatch(body);
}

代码示例来源:origin: com.vmware.photon.controller/photon-model-tasks

private void sendSelfPatch(TaskState.TaskStage nextStage, Throwable error) {
  SnapshotTaskState body = new SnapshotTaskState();
  body.taskInfo = new TaskState();
  if (error != null) {
    body.taskInfo.stage = TaskState.TaskStage.FAILED;
    body.taskInfo.failure = Utils.toServiceErrorResponse(error);
  } else {
    body.taskInfo.stage = nextStage;
  }
  sendSelfPatch(body);
}

代码示例来源:origin: com.vmware.photon.controller/photon-model-tasks

private void failTask(Throwable e, String messageFormat, Object... args) {
  String message = String.format(messageFormat, args);
  logWarning(() -> message);
  IPAddressAllocationTaskState body = new IPAddressAllocationTaskState();
  body.taskInfo = new TaskState();
  body.taskInfo.stage = TaskState.TaskStage.FAILED;
  body.taskInfo.failure = Utils.toServiceErrorResponse(e);
  sendSelfPatch(body);
}

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

public static void failTask(Operation get, Throwable ex) {
  QueryTask t = new QueryTask();
  t.taskInfo.stage = TaskState.TaskStage.FAILED;
  t.taskInfo.failure = Utils.toServiceErrorResponse(ex);
  get.setBody(t).fail(ex);
}

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

private EndpointRemovalTaskState createPatchSubStageTask(TaskState.TaskStage stage,
    SubStage subStage,
    Throwable e) {
  EndpointRemovalTaskState body = new EndpointRemovalTaskState();
  body.taskInfo = new TaskState();
  body.taskInfo.stage = stage;
  body.taskSubStage = subStage;
  if (e != null) {
    body.taskInfo.failure = Utils.toServiceErrorResponse(e);
    logWarning(() -> String.format("Patching to failed: %s", Utils.toString(e)));
  }
  return body;
}

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

private void sendSelfPatch(TaskState.TaskStage nextStage, Throwable error) {
  SnapshotTaskState body = new SnapshotTaskState();
  body.taskInfo = new TaskState();
  if (error != null) {
    body.taskInfo.stage = TaskState.TaskStage.FAILED;
    body.taskInfo.failure = Utils.toServiceErrorResponse(error);
  } else {
    body.taskInfo.stage = nextStage;
  }
  sendSelfPatch(body);
}

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

public static void fail(Operation request, int statusCode, int errorCode, Throwable e) {
  request.setStatusCode(statusCode);
  ServiceErrorResponse r = Utils.toServiceErrorResponse(e);
  r.statusCode = statusCode;
  r.errorCode = errorCode;
  if (e instanceof ServiceNotFoundException) {
    r.stackTrace = null;
  }
  request.setContentType(Operation.MEDIA_TYPE_APPLICATION_JSON).fail(e, r);
}

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

private void sendSelfPatch(TaskState.TaskStage stage, Throwable e) {
    ProvisionNetworkTaskState body = new ProvisionNetworkTaskState();
    body.taskInfo = new TaskState();
    if (e == null) {
      body.taskInfo.stage = stage;
    } else {
      body.taskInfo.stage = TaskState.TaskStage.FAILED;
      body.taskInfo.failure = Utils.toServiceErrorResponse(e);
      logWarning(() -> String.format("Patching to failed: %s", Utils.toString(e)));
    }

    sendSelfPatch(body);
  }
}

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

private void sendSelfPatch(TaskState.TaskStage stage, Throwable e) {
  ProvisionSecurityGroupTaskState body = new ProvisionSecurityGroupTaskState();
  body.taskInfo = new TaskState();
  if (e == null) {
    body.taskInfo.stage = stage;
  } else {
    body.taskInfo.stage = TaskState.TaskStage.FAILED;
    body.taskInfo.failure = Utils.toServiceErrorResponse(e);
    logWarning(() -> String.format("Patching to failed: %s", Utils.toString(e)));
  }
  sendSelfPatch(body);
}

代码示例来源:origin: com.vmware.photon.controller/photon-model-tasks

private void sendSelfPatch(TaskState.TaskStage stage, Throwable e) {
    ProvisionLoadBalancerTaskState body = new ProvisionLoadBalancerTaskState();
    body.taskInfo = new TaskState();
    if (e == null) {
      body.taskInfo.stage = stage;
    } else {
      body.taskInfo.stage = TaskState.TaskStage.FAILED;
      body.taskInfo.failure = Utils.toServiceErrorResponse(e);
      logWarning(() -> String.format("Patching to failed: %s", Utils.toString(e)));
    }

    sendSelfPatch(body);
  }
}

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

private void failTask(Throwable e, Operation directOp, CompletionHandler c) {
  QueryTask t = new QueryTask();
  // self patch to failure
  t.taskInfo.stage = TaskStage.FAILED;
  t.taskInfo.failure = Utils.toServiceErrorResponse(e);
  if (directOp != null) {
    directOp.setBody(t).fail(e);
    return;
  }
  sendRequest(Operation.createPatch(getUri()).setBody(t).setCompletion(c));
}

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

private void failTask(Throwable e, Operation directOp, Operation.CompletionHandler c) {
  QueryTask t = new QueryTask();
  // self patch to failure
  t.taskInfo.stage = TaskState.TaskStage.FAILED;
  t.taskInfo.failure = Utils.toServiceErrorResponse(e);
  if (directOp != null) {
    directOp.setBody(t).fail(e);
    return;
  }
  sendRequest(Operation.createPatch(getUri()).setBody(t).setCompletion(c));
}

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

private void sendStageUpdate(TaskState.TaskStage stage, Throwable e) {
  State fail = new State();
  fail.taskInfo = new TaskState();
  fail.taskInfo.stage = stage;
  if (e != null) {
    fail.taskInfo.failure = Utils.toServiceErrorResponse(e);
  }
  this.sendSelfPatch(fail, TestProperty.DISABLE_CONTEXT_ID_VALIDATION.toString(), null);
}

代码示例来源:origin: com.vmware.xenon/xenon-common

private void sendStageUpdate(TaskState.TaskStage stage, Throwable e) {
  State fail = new State();
  fail.taskInfo = new TaskState();
  fail.taskInfo.stage = stage;
  if (e != null) {
    fail.taskInfo.failure = Utils.toServiceErrorResponse(e);
  }
  this.sendSelfPatch(fail, TestProperty.DISABLE_CONTEXT_ID_VALIDATION.toString(), null);
}

相关文章