public boolean dropNamespace(Namespace namespace) throws NamespaceNotEmptyException {
    checkNamespaceIsValid(namespace);
    getRef().checkMutable();
    ContentKey key = ContentKey.of(namespace.levels());
    try {
      Map<ContentKey, Content> contentMap =
          api.getContent().reference(getReference()).key(key).get();
      Content existing = contentMap.get(key);
      if (existing != null && !existing.getType().equals(Content.Type.NAMESPACE)) {
        throw new NoSuchNamespaceException(
            "Content object with name '%s' is not a namespace.", namespace);
      }
      try {
        commitRetry("drop namespace " + key, Operation.Delete.of(key));
        return true;
      } catch (NessieReferenceConflictException e) {
        Optional<Conflict> conflict =
            NessieUtil.extractSingleConflict(
                e,
                EnumSet.of(
                    Conflict.ConflictType.KEY_DOES_NOT_EXIST,
                    Conflict.ConflictType.NAMESPACE_NOT_EMPTY));
        if (conflict.isPresent()) {
          Conflict.ConflictType conflictType = conflict.get().conflictType();
          switch (conflictType) {
            case KEY_DOES_NOT_EXIST:
              return false;
            case NAMESPACE_NOT_EMPTY:
              throw new NamespaceNotEmptyException(e, "Namespace '%s' is not empty.", namespace);
          }
        }
        throw new RuntimeException(
            String.format("Cannot drop namespace '%s': %s", namespace, e.getMessage()));
      }
    } catch (NessieNotFoundException e) {
      LOG.error(
          "Cannot drop namespace '{}': ref '{}' is no longer valid.",
          namespace,
          getRef().getName(),
          e);
    } catch (BaseNessieClientServerException e) {
      throw new RuntimeException(
          String.format("Cannot drop namespace '%s': %s", namespace, e.getMessage()), e);
    }
    return false;
  }
@Test
  public void testDropNamespace() throws NessieConflictException, NessieNotFoundException {
    String branch = "dropNamespaceBranch";
    createBranch(branch);
    Map<String, String> catalogOptions =
        Map.of(
            CatalogProperties.USER, "iceberg-user",
            CatalogProperties.APP_ID, "iceberg-nessie");
    NessieIcebergClient client = new NessieIcebergClient(api, branch, null, catalogOptions);

    Namespace parent = Namespace.of("a");
    Namespace child = Namespace.of("a", "b");

    assertThat(client.dropNamespace(parent)).isFalse();
    assertThat(client.dropNamespace(child)).isFalse();

    client.createNamespace(parent, Map.of());
    client.createNamespace(child, Map.of());

    assertThat(client.dropNamespace(child)).isTrue();
    assertThat(client.dropNamespace(parent)).isTrue();

    List<LogResponse.LogEntry> entries = api.getCommitLog().refName(branch).get().getLogEntries();
    assertThat(entries)
        .isNotEmpty()
        .extracting(LogResponse.LogEntry::getCommitMeta)
        .satisfies(
            meta -> {
              assertThat(meta.getMessage()).contains("drop namespace a");
              assertThat(meta.getAuthor()).isEqualTo("iceberg-user");
              assertThat(meta.getProperties())
                  .containsEntry(NessieUtil.APPLICATION_TYPE, "iceberg")
                  .containsEntry(CatalogProperties.APP_ID, "iceberg-nessie");
            },
            Index.atIndex(0))
        .satisfies(
            meta -> {
              assertThat(meta.getMessage()).contains("drop namespace a.b");
              assertThat(meta.getAuthor()).isEqualTo("iceberg-user");
              assertThat(meta.getProperties())
                  .containsEntry(NessieUtil.APPLICATION_TYPE, "iceberg")
                  .containsEntry(CatalogProperties.APP_ID, "iceberg-nessie");
            },
            Index.atIndex(1));
  }