use of com.vmware.photon.controller.model.adapters.util.TaskManager in project photon-model by vmware.
the class VSphereDiskService method handlePatch.
@Override
public void handlePatch(Operation op) {
if (!op.hasBody()) {
op.fail(new IllegalArgumentException("body is required"));
return;
}
DiskInstanceRequest request = op.getBody(DiskInstanceRequest.class);
try {
validateInputRequest(request);
} catch (Exception e) {
op.fail(e);
return;
}
op.setStatusCode(Operation.STATUS_CODE_CREATED);
op.complete();
TaskManager taskManager = new TaskManager(this, request.taskReference, request.resourceLink());
DiskContext.populateContextThen(this, createInitialContext(taskManager, request, op), ctx -> {
switch(request.requestType) {
case CREATE:
handleCreateDisk(ctx);
break;
case DELETE:
handleDeleteDisk(ctx);
break;
default:
Throwable error = new IllegalStateException("Unsupported requestType " + request.requestType);
ctx.fail(error);
}
});
}
Aggregations