-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### What changes were proposed in this pull request? Implemented pre-event handling for all tag-related operations, including: - listTags - listTagsInfo - getTag - createTag - alterTag - deleteTag - listMetadataObjectsForTag - listTagsForMetadataObject - listTagsInfoForMetadataObject - associateTagsForMetadataObject - getTagForMetadataObject ### Why are the changes needed? Fix: #5900 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? add UT
- Loading branch information
1 parent
e50e00e
commit a84fd18
Showing
15 changed files
with
868 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
core/src/main/java/org/apache/gravitino/listener/api/event/AlterTagPreEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.gravitino.listener.api.event; | ||
|
||
import org.apache.gravitino.annotation.DeveloperApi; | ||
import org.apache.gravitino.tag.TagChange; | ||
import org.apache.gravitino.utils.NameIdentifierUtil; | ||
|
||
/** Represents an event triggered before altering a tag. */ | ||
@DeveloperApi | ||
public class AlterTagPreEvent extends TagPreEvent { | ||
|
||
private final TagChange[] changes; | ||
|
||
/** | ||
* Constructs a new AlterTagPreEvent instance. | ||
* | ||
* @param user The user responsible for the operation. | ||
* @param metalake The namespace of the tag. | ||
* @param name The name of the tag being altered. | ||
* @param changes The changes being applied to the tag. | ||
*/ | ||
public AlterTagPreEvent(String user, String metalake, String name, TagChange[] changes) { | ||
super(user, NameIdentifierUtil.ofTag(metalake, name)); | ||
this.changes = changes; | ||
} | ||
|
||
/** | ||
* Returns the changes being applied to the tag. | ||
* | ||
* @return An array of {@link TagChange}. | ||
*/ | ||
public TagChange[] changes() { | ||
return changes; | ||
} | ||
|
||
/** | ||
* Returns the operation type for this event. | ||
* | ||
* @return The operation type {@link OperationType#ALTER_TAG}. | ||
*/ | ||
@Override | ||
public OperationType operationType() { | ||
return OperationType.ALTER_TAG; | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
.../java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectPreEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.gravitino.listener.api.event; | ||
|
||
import org.apache.gravitino.MetadataObject; | ||
import org.apache.gravitino.annotation.DeveloperApi; | ||
import org.apache.gravitino.utils.MetadataObjectUtil; | ||
|
||
/** Represents an event triggered before associating tags with a specific metadata object. */ | ||
@DeveloperApi | ||
public class AssociateTagsForMetadataObjectPreEvent extends TagPreEvent { | ||
private final String[] tagsToAdd; | ||
private final String[] tagsToRemove; | ||
|
||
/** | ||
* Constructs the pre-event with user, metalake, metadata object, tags to add, and tags to remove. | ||
* | ||
* @param user The user initiating the operation. | ||
* @param metalake The metalake environment name. | ||
* @param metadataObject The metadata object for which tags will be associated. | ||
* @param tagsToAdd Tags to be added to the metadata object. | ||
* @param tagsToRemove Tags to be removed from the metadata object. | ||
*/ | ||
public AssociateTagsForMetadataObjectPreEvent( | ||
String user, | ||
String metalake, | ||
MetadataObject metadataObject, | ||
String[] tagsToAdd, | ||
String[] tagsToRemove) { | ||
super(user, MetadataObjectUtil.toEntityIdent(metalake, metadataObject)); | ||
this.tagsToAdd = tagsToAdd; | ||
this.tagsToRemove = tagsToRemove; | ||
} | ||
|
||
/** | ||
* Returns the tags to be added. | ||
* | ||
* @return Array of tag names to be added. | ||
*/ | ||
public String[] tagsToAdd() { | ||
return tagsToAdd; | ||
} | ||
|
||
/** | ||
* Returns the tags to be removed. | ||
* | ||
* @return Array of tag names to be removed. | ||
*/ | ||
public String[] tagsToRemove() { | ||
return tagsToRemove; | ||
} | ||
|
||
/** | ||
* Returns the operation type for this event. | ||
* | ||
* @return The operation type, which is ASSOCIATE_TAGS_FOR_METADATA_OBJECT. | ||
*/ | ||
@Override | ||
public OperationType operationType() { | ||
return OperationType.ASSOCIATE_TAGS_FOR_METADATA_OBJECT; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagPreEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.gravitino.listener.api.event; | ||
|
||
import org.apache.gravitino.annotation.DeveloperApi; | ||
import org.apache.gravitino.listener.api.info.TagInfo; | ||
import org.apache.gravitino.utils.NameIdentifierUtil; | ||
|
||
/** Represents an event triggered before the creation of a tag. */ | ||
@DeveloperApi | ||
public class CreateTagPreEvent extends TagPreEvent { | ||
private final TagInfo tagInfo; | ||
|
||
/** | ||
* Constructs a new {@code CreateTagPreEvent} instance. | ||
* | ||
* @param user The user who initiated the tag creation operation. | ||
* @param metalake The metalake name where the tag resides. | ||
* @param tagInfo The information about the tag to be created. | ||
*/ | ||
public CreateTagPreEvent(String user, String metalake, TagInfo tagInfo) { | ||
super(user, NameIdentifierUtil.ofTag(metalake, tagInfo.name())); | ||
this.tagInfo = tagInfo; | ||
} | ||
|
||
/** | ||
* Returns the information about the tag. | ||
* | ||
* @return the tag information | ||
*/ | ||
public TagInfo tagInfo() { | ||
return tagInfo; | ||
} | ||
|
||
/** | ||
* Returns the type of operation. | ||
* | ||
* @return the operation type. | ||
*/ | ||
@Override | ||
public OperationType operationType() { | ||
return OperationType.CREATE_TAG; | ||
} | ||
} |
Oops, something went wrong.