Skip to content

Commit

Permalink
spotlessApply
Browse files Browse the repository at this point in the history
  • Loading branch information
TungYuChiang committed Dec 25, 2024
1 parent 3953e4e commit aba70be
Show file tree
Hide file tree
Showing 15 changed files with 749 additions and 710 deletions.
292 changes: 161 additions & 131 deletions core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
package org.apache.gravitino.listener;

import java.util.Map;

import org.apache.gravitino.MetadataObject;
import org.apache.gravitino.exceptions.NoSuchTagException;
import org.apache.gravitino.listener.api.event.AlterTagEvent;
import org.apache.gravitino.listener.api.event.AssociateTagsForMetadataObjectEvent;
import org.apache.gravitino.listener.api.event.CreateTagEvent;
import org.apache.gravitino.listener.api.event.DeleteTagEvent;
Expand All @@ -30,7 +30,6 @@
import org.apache.gravitino.listener.api.event.ListMetadataObjectsForTagEvent;
import org.apache.gravitino.listener.api.event.ListTagEvent;
import org.apache.gravitino.listener.api.event.ListTagInfoEvent;
import org.apache.gravitino.listener.api.event.AlterTagEvent;
import org.apache.gravitino.listener.api.event.ListTagsForMetadataObjectEvent;
import org.apache.gravitino.listener.api.event.ListTagsInfoForMetadataObjectEvent;
import org.apache.gravitino.listener.api.info.TagInfo;
Expand All @@ -46,156 +45,187 @@
* of tag operations.
*/
public class TagEventDispatcher implements TagDispatcher {
private final EventBus eventBus;
private final TagDispatcher dispatcher;
private final EventBus eventBus;
private final TagDispatcher dispatcher;

public TagEventDispatcher(EventBus eventBus, TagDispatcher dispatcher) {
this.eventBus = eventBus;
this.dispatcher = dispatcher;
}
public TagEventDispatcher(EventBus eventBus, TagDispatcher dispatcher) {
this.eventBus = eventBus;
this.dispatcher = dispatcher;
}

@Override
public String[] listTags(String metalake) {
// TODO: listTagsPreEvent
try {
String[] tagNames = dispatcher.listTags(metalake);
eventBus.dispatchEvent(new ListTagEvent(PrincipalUtils.getCurrentUserName(), metalake));
return tagNames;
} catch (Exception e) {
// TODO: listTagFailureEvent
throw e;
}
@Override
public String[] listTags(String metalake) {
// TODO: listTagsPreEvent
try {
String[] tagNames = dispatcher.listTags(metalake);
eventBus.dispatchEvent(new ListTagEvent(PrincipalUtils.getCurrentUserName(), metalake));
return tagNames;
} catch (Exception e) {
// TODO: listTagFailureEvent
throw e;
}
}

@Override
public Tag[] listTagsInfo(String metalake) {
// TODO: listTagsInfoPreEvent
try {
Tag[] tags = dispatcher.listTagsInfo(metalake);
eventBus.dispatchEvent(new ListTagInfoEvent(PrincipalUtils.getCurrentUserName(), metalake, tags));
return tags;
} catch (Exception e) {
// TODO: listTagsInfoFailureEvent
throw e;
}
@Override
public Tag[] listTagsInfo(String metalake) {
// TODO: listTagsInfoPreEvent
try {
Tag[] tags = dispatcher.listTagsInfo(metalake);
eventBus.dispatchEvent(
new ListTagInfoEvent(PrincipalUtils.getCurrentUserName(), metalake, tags));
return tags;
} catch (Exception e) {
// TODO: listTagsInfoFailureEvent
throw e;
}
}

@Override
public Tag getTag(String metalake, String name) throws NoSuchTagException {
// TODO: getTagPreEvent
try {
// TODO: getTagEvent
Tag tag = dispatcher.getTag(metalake, name);
eventBus.dispatchEvent(new GetTagEvent(PrincipalUtils.getCurrentUserName(), metalake, name, tag));
return tag;
} catch (NoSuchTagException e) {
// TODO: getTagFailureEvent
throw e;
}
@Override
public Tag getTag(String metalake, String name) throws NoSuchTagException {
// TODO: getTagPreEvent
try {
// TODO: getTagEvent
Tag tag = dispatcher.getTag(metalake, name);
eventBus.dispatchEvent(
new GetTagEvent(PrincipalUtils.getCurrentUserName(), metalake, name, tag));
return tag;
} catch (NoSuchTagException e) {
// TODO: getTagFailureEvent
throw e;
}
}

@Override
public Tag createTag(String metalake, String name, String comment, Map<String, String> properties) {
// TODO: createTagPreEvent
try {
Tag tag = dispatcher.createTag(metalake, name, comment, properties);
eventBus.dispatchEvent(new CreateTagEvent(PrincipalUtils.getCurrentUserName(), metalake, new TagInfo(tag.name(), tag.comment(), tag.properties())));
return tag;
} catch (Exception e) {
// TODO: createTagFailureEvent
throw e;
}
@Override
public Tag createTag(
String metalake, String name, String comment, Map<String, String> properties) {
// TODO: createTagPreEvent
try {
Tag tag = dispatcher.createTag(metalake, name, comment, properties);
eventBus.dispatchEvent(
new CreateTagEvent(
PrincipalUtils.getCurrentUserName(),
metalake,
new TagInfo(tag.name(), tag.comment(), tag.properties())));
return tag;
} catch (Exception e) {
// TODO: createTagFailureEvent
throw e;
}
}

@Override
public Tag alterTag(String metalake, String name, TagChange... changes) {
// TODO: alterTagPreEvent
try {
Tag tag = dispatcher.alterTag(metalake, name, changes);
eventBus.dispatchEvent(new AlterTagEvent(PrincipalUtils.getCurrentUserName(), metalake, changes, new TagInfo(tag.name(), tag.comment(), tag.properties())));
return tag;
} catch (Exception e) {
// TODO: alterTagFailureEvent
throw e;
}
@Override
public Tag alterTag(String metalake, String name, TagChange... changes) {
// TODO: alterTagPreEvent
try {
Tag tag = dispatcher.alterTag(metalake, name, changes);
eventBus.dispatchEvent(
new AlterTagEvent(
PrincipalUtils.getCurrentUserName(),
metalake,
changes,
new TagInfo(tag.name(), tag.comment(), tag.properties())));
return tag;
} catch (Exception e) {
// TODO: alterTagFailureEvent
throw e;
}
}

@Override
public boolean deleteTag(String metalake, String name) {
// TODO: deleteTagPreEvent
try {
boolean isExists = dispatcher.deleteTag(metalake, name);
eventBus.dispatchEvent(new DeleteTagEvent(PrincipalUtils.getCurrentUserName(), metalake, isExists));
return isExists;
} catch (Exception e) {
// TODO: deleteTagFailureEvent
throw e;
}
@Override
public boolean deleteTag(String metalake, String name) {
// TODO: deleteTagPreEvent
try {
boolean isExists = dispatcher.deleteTag(metalake, name);
eventBus.dispatchEvent(
new DeleteTagEvent(PrincipalUtils.getCurrentUserName(), metalake, isExists));
return isExists;
} catch (Exception e) {
// TODO: deleteTagFailureEvent
throw e;
}
}

@Override
public MetadataObject[] listMetadataObjectsForTag(String metalake, String name) {
// TODO: listMetadataObjectsForTagPreEvent
try {
// TODO: listMetadataObjectsForTagEvent
MetadataObject[] metadataObjects = dispatcher.listMetadataObjectsForTag(metalake, name);
eventBus.dispatchEvent(new ListMetadataObjectsForTagEvent(PrincipalUtils.getCurrentUserName(), metalake, name, metadataObjects));
return metadataObjects;
} catch (Exception e) {
// TODO: listMetadataObjectsForTagFailureEvent
throw e;
}
@Override
public MetadataObject[] listMetadataObjectsForTag(String metalake, String name) {
// TODO: listMetadataObjectsForTagPreEvent
try {
// TODO: listMetadataObjectsForTagEvent
MetadataObject[] metadataObjects = dispatcher.listMetadataObjectsForTag(metalake, name);
eventBus.dispatchEvent(
new ListMetadataObjectsForTagEvent(
PrincipalUtils.getCurrentUserName(), metalake, name, metadataObjects));
return metadataObjects;
} catch (Exception e) {
// TODO: listMetadataObjectsForTagFailureEvent
throw e;
}
}

@Override
public String[] listTagsForMetadataObject(String metalake, MetadataObject metadataObject) {
// TODO: listTagsForMetadataObjectPreEvent
try {
String[] tags = dispatcher.listTagsForMetadataObject(metalake, metadataObject);
eventBus.dispatchEvent(new ListTagsForMetadataObjectEvent(PrincipalUtils.getCurrentUserName(), metalake, metadataObject, tags));
return tags;
} catch (Exception e) {
// TODO: listTagsForMetadataObjectFailureEvent
throw e;
}
@Override
public String[] listTagsForMetadataObject(String metalake, MetadataObject metadataObject) {
// TODO: listTagsForMetadataObjectPreEvent
try {
String[] tags = dispatcher.listTagsForMetadataObject(metalake, metadataObject);
eventBus.dispatchEvent(
new ListTagsForMetadataObjectEvent(
PrincipalUtils.getCurrentUserName(), metalake, metadataObject, tags));
return tags;
} catch (Exception e) {
// TODO: listTagsForMetadataObjectFailureEvent
throw e;
}
}

@Override
public Tag[] listTagsInfoForMetadataObject(String metalake, MetadataObject metadataObject) {
// TODO: listTagsInfoForMetadataObjectPreEvent
try {
Tag[] tags = dispatcher.listTagsInfoForMetadataObject(metalake, metadataObject);
eventBus.dispatchEvent(new ListTagsInfoForMetadataObjectEvent(PrincipalUtils.getCurrentUserName(), metalake, metadataObject, tags));
return tags;
} catch (Exception e) {
// TODO: listTagsInfoForMetadataObjectFailureEvent
throw e;
}
@Override
public Tag[] listTagsInfoForMetadataObject(String metalake, MetadataObject metadataObject) {
// TODO: listTagsInfoForMetadataObjectPreEvent
try {
Tag[] tags = dispatcher.listTagsInfoForMetadataObject(metalake, metadataObject);
eventBus.dispatchEvent(
new ListTagsInfoForMetadataObjectEvent(
PrincipalUtils.getCurrentUserName(), metalake, metadataObject, tags));
return tags;
} catch (Exception e) {
// TODO: listTagsInfoForMetadataObjectFailureEvent
throw e;
}
}

@Override
public String[] associateTagsForMetadataObject(String metalake, MetadataObject metadataObject, String[] tagsToAdd, String[] tagsToRemove) {
// TODO: associateTagsForMetadataObjectPreEvent
try {
String[] associatedTags = dispatcher.associateTagsForMetadataObject(metalake, metadataObject, tagsToAdd, tagsToRemove);
eventBus.dispatchEvent(new AssociateTagsForMetadataObjectEvent(PrincipalUtils.getCurrentUserName(), metalake, metadataObject, tagsToAdd, tagsToRemove, associatedTags));
return associatedTags;
} catch (Exception e) {
// TODO: associateTagsForMetadataObjectFailureEvent
throw e;
}
@Override
public String[] associateTagsForMetadataObject(
String metalake, MetadataObject metadataObject, String[] tagsToAdd, String[] tagsToRemove) {
// TODO: associateTagsForMetadataObjectPreEvent
try {
String[] associatedTags =
dispatcher.associateTagsForMetadataObject(
metalake, metadataObject, tagsToAdd, tagsToRemove);
eventBus.dispatchEvent(
new AssociateTagsForMetadataObjectEvent(
PrincipalUtils.getCurrentUserName(),
metalake,
metadataObject,
tagsToAdd,
tagsToRemove,
associatedTags));
return associatedTags;
} catch (Exception e) {
// TODO: associateTagsForMetadataObjectFailureEvent
throw e;
}
}

@Override
public Tag getTagForMetadataObject(String metalake, MetadataObject metadataObject, String name) {
// TODO: getTagForMetadataObjectPreEvent
try {
Tag tag = dispatcher.getTagForMetadataObject(metalake, metadataObject, name);
eventBus.dispatchEvent(new GetTagForMetadataObjectEvent(PrincipalUtils.getCurrentUserName(), metalake, metadataObject, name, tag));
return tag;
} catch (Exception e) {
// TODO: getTagForMetadataObjectFailureEvent
throw e;
}
@Override
public Tag getTagForMetadataObject(String metalake, MetadataObject metadataObject, String name) {
// TODO: getTagForMetadataObjectPreEvent
try {
Tag tag = dispatcher.getTagForMetadataObject(metalake, metadataObject, name);
eventBus.dispatchEvent(
new GetTagForMetadataObjectEvent(
PrincipalUtils.getCurrentUserName(), metalake, metadataObject, name, tag));
return tag;
} catch (Exception e) {
// TODO: getTagForMetadataObjectFailureEvent
throw e;
}
}
}
Loading

0 comments on commit aba70be

Please sign in to comment.