class UpgradeCatalog252 extends AbstractUpgradeCatalog {

  @Override
  protected void updateKerberosDescriptorArtifact(ArtifactDAO artifactDAO, ArtifactEntity artifactEntity) throws AmbariException {
    if (artifactEntity != null) {
      Map<String, Object> data = artifactEntity.getArtifactData();

      if (data != null) {
        final KerberosDescriptor kerberosDescriptor = new KerberosDescriptorFactory().createInstance(data);

        if (kerberosDescriptor != null) {
          boolean updated = false;

          // Find and remove configuration specifications for <code>livy-conf/livy.superusers</code>
          // in SPARK since this logic has been moved to the relevant stack/service advisors
          if(removeConfigurationSpecifications(kerberosDescriptor.getService("SPARK"),
              Collections.<String, Collection<String>>singletonMap("livy-conf", Collections.singleton("livy.superusers")))) {
            updated = true;
          }

          // Find and remove configuration specifications for <code>livy-conf2/livy.superusers</code>
          // in SPARK2 since this logic has been moved to the relevant stack/service advisors
          if(removeConfigurationSpecifications(kerberosDescriptor.getService("SPARK2"),
              Collections.<String, Collection<String>>singletonMap("livy2-conf", Collections.singleton("livy.superusers")))) {
            updated = true;
          }

          // Find and remove configuration specifications for the following configurations in KNOX/KNOX_GATEWAY
          // since they are invalid due to static "knox" embedded in the property name:
          // * oozie-site/oozie.service.ProxyUserService.proxyuser.knox.groups
          // * oozie-site/oozie.service.ProxyUserService.proxyuser.knox.hosts
          // * webhcat-site/webhcat.proxyuser.knox.groups
          // * webhcat-site/webhcat.proxyuser.knox.hosts
          // * core-site/hadoop.proxyuser.knox.groups
          // * core-site/hadoop.proxyuser.knox.hosts
          // * falcon-runtime.properties/*.falcon.service.ProxyUserService.proxyuser.knox.groups
          // * falcon-runtime.properties/*.falcon.service.ProxyUserService.proxyuser.knox.hosts
          KerberosServiceDescriptor knoxKerberosDescriptor = kerberosDescriptor.getService("KNOX");
          if(knoxKerberosDescriptor != null) {
            KerberosComponentDescriptor knoxGatewayKerberosDescriptor = knoxKerberosDescriptor.getComponent("KNOX_GATEWAY");
            if (knoxGatewayKerberosDescriptor != null) {
              Map<String, Collection<String>> configsToRemove = new HashMap<>();
              configsToRemove.put("oozie-site",
                  Arrays.asList("oozie.service.ProxyUserService.proxyuser.knox.groups", "oozie.service.ProxyUserService.proxyuser.knox.hosts"));
              configsToRemove.put("webhcat-site",
                  Arrays.asList("webhcat.proxyuser.knox.groups", "webhcat.proxyuser.knox.hosts"));
              configsToRemove.put("core-site",
                  Arrays.asList("hadoop.proxyuser.knox.groups", "hadoop.proxyuser.knox.hosts"));
              configsToRemove.put("falcon-runtime.properties",
                  Arrays.asList("*.falcon.service.ProxyUserService.proxyuser.knox.groups", "*.falcon.service.ProxyUserService.proxyuser.knox.hosts"));
              if (removeConfigurationSpecifications(knoxGatewayKerberosDescriptor, configsToRemove)) {
                updated = true;
              }
            }
          }

          if (updated) {
            artifactEntity.setArtifactData(kerberosDescriptor.toMap());
            artifactDAO.merge(artifactEntity);
          }
        }
      }
    }
  }

  @Inject public  UpgradeCatalog252(Injector injector);

}