public Optional processEntry()

in src/main/java/com/google/cloud/solutions/autotokenize/datacatalog/DataCatalogWriter.java [189:217]


      public Optional<Entry> processEntry() {
        var existingEntry = getExistingEntry();

        if (existingEntry.isEmpty() && sourceType.equals(SourceType.BIGQUERY_TABLE)) {
          throw new UnsupportedOperationException("Missing BigQuery Table entry");
        }

        if (existingEntry.isPresent()
            && (sourceType.equals(SourceType.BIGQUERY_TABLE) || !forceUpdate())) {
          return existingEntry;
        }

        if (entryToCreate != null) {

          if (existingEntry.isPresent() && forceUpdate()) {
            catalogClient.deleteEntry(existingEntry.get().getName());
          }

          return Optional.of(
              catalogClient.createEntry(
                  CreateEntryRequest.newBuilder()
                      .setParent(entryGroupId())
                      .setEntryId(makeNonBigQueryEntryId())
                      .setEntry(entryToCreate)
                      .build()));
        }

        return Optional.empty();
      }