Skip to content

Commit

Permalink
Add work item support to WebHookManager (#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
ParkerMc authored Dec 24, 2024
1 parent 7f6aa16 commit 28f43e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gitlab4j-api/src/main/java/org/gitlab4j/api/WebHookManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.gitlab4j.api.webhook.TagPushEvent;
import org.gitlab4j.api.webhook.WebHookListener;
import org.gitlab4j.api.webhook.WikiPageEvent;
import org.gitlab4j.api.webhook.WorkItemEvent;

/**
* This class provides a handler for processing GitLab WebHook callouts.
Expand Down Expand Up @@ -186,6 +187,7 @@ public void handleEvent(Event event) throws GitLabApiException {
case WikiPageEvent.OBJECT_KIND:
case ReleaseEvent.OBJECT_KIND:
case DeploymentEvent.OBJECT_KIND:
case WorkItemEvent.OBJECT_KIND:
fireEvent(event);
break;

Expand Down Expand Up @@ -270,6 +272,10 @@ public void fireEvent(Event event) throws GitLabApiException {
fireDeploymentEvent((DeploymentEvent) event);
break;

case WorkItemEvent.OBJECT_KIND:
fireWorkItemEvent((WorkItemEvent) event);
break;

default:
String message = "Unsupported event object_kind, object_kind=" + event.getObjectKind();
LOGGER.warning(message);
Expand Down Expand Up @@ -337,6 +343,12 @@ protected void fireDeploymentEvent(DeploymentEvent deploymentEvent) {
}
}

protected void fireWorkItemEvent(WorkItemEvent workItemEvent) {
for (WebHookListener listener : webhookListeners) {
listener.onWorkItemEvent(workItemEvent);
}
}

protected void fireReleaseEvent(ReleaseEvent releaseEvent) {
for (WebHookListener listener : webhookListeners) {
listener.onReleaseEvent(releaseEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ default void onWikiPageEvent(WikiPageEvent wikiEvent) {}
*/
default void onDeploymentEvent(DeploymentEvent deploymentEvent) {}

/**
* This method is called when a WebHook work item event has been received.
*
* @param workItemEvent the WorkItemEvent instance
*/
default void onWorkItemEvent(WorkItemEvent workItemEvent) {}

/**
* This method is called when a WebHook release event has been received.
*
Expand Down

0 comments on commit 28f43e5

Please sign in to comment.