public static DeferredResult<Void> handlePatch(Service service, Operation op) {
ResourcePoolState patchState = op.getBody(ResourcePoolState.class);
Operation getOp = Operation.createGet(op.getUri()).setReferer(service.getUri());
return service.getHost().sendWithDeferredResult(getOp, ResourcePoolState.class)
.thenCompose(currentState -> {
AssertUtil.assertNotNull(currentState, "currentState");
ResourcePoolState rp = new ResourcePoolState();
rp.customProperties = PropertyUtils.mergeCustomProperties(
currentState.customProperties, patchState.customProperties);
if (PlacementZoneUtil.isSchedulerPlacementZone(rp)) {
try {
AssertUtil.assertEmpty(currentState.tagLinks, "tagLinks");
AssertUtil.assertEmpty(patchState.tagLinks, "tagLinks");
} catch (LocalizableValidationException ex) {
return DeferredResult.failed(ex);
}
return verifyZoneContainsSingleSchedulerOrNoHost(
currentState.documentSelfLink, op, service);
} else {
return verifyZoneContainsNoSchedulers(currentState.documentSelfLink, op,
service);
}
}).thenAccept(ignore -> {
});
}