Skip to content

Commit

Permalink
onDelete MetadataInterceptor (#582)
Browse files Browse the repository at this point in the history
* onDelete metadata interceptor, use for deleting definitionMetadata

* wip

* clean up comments

* call onDelete in user metadata svc

---------

Co-authored-by: Amanda Bozigian <[email protected]>
  • Loading branch information
amboz and Amanda Bozigian authored Apr 15, 2024
1 parent 06e703c commit ae08316
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public interface MetadataInterceptor {

/**
* apply business rules before retrieving back. These rules may change or overriding existing
* Apply business rules before retrieving back. These rules may change or override existing
* business metadata.
*
* @param userMetadataService user metadata service
Expand All @@ -47,14 +47,25 @@ default void onRead(final UserMetadataService userMetadataService,
}

/**
* Valide ObjectNode before storing it.
* Validate ObjectNode before storing it.
* @param userMetadataService user metadata service
* @param name qualified name
* @param objectNode input metadata object node
* @param name qualified name
* @param objectNode input metadata object node
* @throws InvalidMetadataException business validation exception
*/
default void onWrite(final UserMetadataService userMetadataService,
final QualifiedName name, final ObjectNode objectNode)
throws InvalidMetadataException {
}

/**
* Validate ObjectNode before deleting it.
* @param userMetadataService user metadata service
* @param name qualified name
* @throws InvalidMetadataException business validation exception
*/
default void onDelete(final UserMetadataService userMetadataService,
final QualifiedName name)
throws InvalidMetadataException {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ private void _deleteDefinitionMetadata(
@Nullable final List<QualifiedName> names
) {
if (names != null && !names.isEmpty()) {
for (QualifiedName name : names) {
this.metadataInterceptor.onDelete(this, name);
}
final SqlParameterValue[] aNames = names.stream().filter(name -> !name.isPartitionDefinition())
.map(n -> new SqlParameterValue(Types.VARCHAR, n))
.toArray(SqlParameterValue[]::new);
Expand Down Expand Up @@ -599,7 +602,7 @@ public void saveDefinitionMetadata(
name.toString());

} else {
//apply interceptor to change the object node
// apply interceptor to change the object node
if (metadata.isPresent()) {
this.metadataInterceptor.onWrite(this, name, metadata.get());
}
Expand Down

0 comments on commit ae08316

Please sign in to comment.