class PutHandler implements KubernetesCrudDispatcherHandler {

  private final KubernetesCrudPersistence persistence;

  public PutHandler(KubernetesCrudPersistence persistence) {
    this.persistence = persistence;
  }

  @Override
  public MockResponse handle(String path, String contentType, String requestBody) throws KubernetesCrudDispatcherException {<FILL_FUNCTION_BODY>}
}

    GenericKubernetesResource resource = validateRequestBody(requestBody);
    final AttributeSet attributes = persistence.getKey(path);

    final Map.Entry<AttributeSet, String> currentResourceEntry = persistence.findResource(attributes);
    if (currentResourceEntry == null) {
      return new MockResponse().setResponseCode(HttpURLConnection.HTTP_NOT_FOUND);
    }

    // Delete the resource if it is marked for deletion and has no finalizers.
    if (resource.isMarkedForDeletion() && resource.getFinalizers().isEmpty()) {
      persistence.processEvent(path, attributes, currentResourceEntry.getKey(), null, null);
      return new MockResponse().setResponseCode(HttpURLConnection.HTTP_OK);
    }

    final JsonNode currentResource = persistence.asNode(currentResourceEntry);
    final JsonNode updatedResource;
    if (isStatusPath(path)) {
      updatedResource = currentResource.deepCopy();
      setStatus(updatedResource, persistence.asNode(requestBody).get(STATUS));
    } else {
      updatedResource = persistence.asNode(requestBody);
      // preserve original status (PUT requests to the custom resource ignore changes to the status stanza)
      if (persistence.isStatusSubresourceEnabledForResource(path)) {
        setStatus(updatedResource, currentResource.get(STATUS));
      }
    }
    validatePath(attributes, updatedResource);
    validateResourceVersion(currentResource, updatedResource);

    persistence.preserveMetadata(currentResource, updatedResource);
    if (!isStatusPath(path)) {
      persistence.touchGeneration(currentResource, updatedResource);
    }
    persistence.touchResourceVersion(currentResource, updatedResource);
    final String response = Serialization.asJson(updatedResource);
    persistence.processEvent(path, attributes, currentResourceEntry.getKey(), null, response);
    return new MockResponse().setResponseCode(HttpURLConnection.HTTP_OK).setBody(response);
  
<no_super_class>