private boolean validateUpdate(Operation request){
  if (hasOption(ServiceOption.CONCURRENT_UPDATE_HANDLING)) {
    return false;
  }
  if (request.isFromReplication()) {
    return false;
  }
  if (request.getRequestHeader(Operation.TRANSACTION_HEADER) != null) {
    return false;
  }
  if (!hasOption(ServiceOption.STRICT_UPDATE_CHECKING)) {
    return false;
  }
  ServiceDocument currentState=request.getLinkedState();
  Object body=request.getBodyRaw();
  if (body instanceof String) {
    body=request.getBody(ServiceDocument.class);
  }
 else   if (!(body instanceof ServiceDocument)) {
    request.fail(new IllegalArgumentException("request body must derive from ServiceDocument"));
    return true;
  }
  ServiceDocument sdBody=(ServiceDocument)body;
  boolean isVersionMatch=this.context.version == sdBody.documentVersion;
  String errorString=null;
  if (!isVersionMatch) {
    errorString=String.format("current version %d, update time %d. Request version %d, update time %d",currentState.documentVersion,currentState.documentUpdateTimeMicros,sdBody.documentVersion,sdBody.documentUpdateTimeMicros);
    request.fail(new IllegalArgumentException(errorString));
    return true;
  }
  return false;
}

private boolean validateUpdate ( Operation request ) { if ( hasOption ( ServiceOption . CONCURRENT_UPDATE_HANDLING ) ) { return false ; } if ( request . isFromReplication ( ) ) { return false ; } if ( request . getRequestHeader ( Operation . TRANSACTION_HEADER ) != null ) { return false ; } if ( ! hasOption ( ServiceOption . STRICT_UPDATE_CHECKING ) ) { return false ; } ServiceDocument currentState = request . getLinkedState ( ) ; Object body = request . getBodyRaw ( ) ; if ( body instanceof String ) { body = request . getBody ( ServiceDocument . class ) ; } else if ( ! ( body instanceof ServiceDocument ) ) { request . fail ( new IllegalArgumentException ( "request body must derive from ServiceDocument" ) ) ; return true ; } ServiceDocument sdBody = ( ServiceDocument ) body ; boolean isVersionMatch = this . context . version == sdBody . documentVersion ; String errorString = null ; if ( ! isVersionMatch ) { errorString = String . format ( "current version %d, update time %d. Request version %d, update time %d" , currentState . documentVersion , currentState . documentUpdateTimeMicros , sdBody . documentVersion , sdBody . documentUpdateTimeMicros ) ; request . fail ( new IllegalArgumentException ( errorString ) ) ; return true ; } return false ; }
if update checking is required we enforce version and signature equality in the incoming request body with that of the current state
