-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Events): Fire event on state change (#5410)
* Fix a problem where getVersionMetaData API operation was not properly returning the modifiedOn * Fire an event when a version state changes * spotless:apply
- Loading branch information
1 parent
26880c0
commit 1656c7b
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
app/src/main/java/io/apicurio/registry/events/ArtifactVersionStateChanged.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,40 @@ | ||
package io.apicurio.registry.events; | ||
|
||
import io.apicurio.registry.storage.dto.OutboxEvent; | ||
import io.apicurio.registry.types.VersionState; | ||
import org.json.JSONObject; | ||
|
||
import java.util.UUID; | ||
|
||
import static io.apicurio.registry.storage.StorageEventType.ARTIFACT_VERSION_STATE_CHANGED; | ||
|
||
public class ArtifactVersionStateChanged extends OutboxEvent { | ||
|
||
private final JSONObject eventPayload; | ||
|
||
private ArtifactVersionStateChanged(String id, String aggregateId, JSONObject eventPayload) { | ||
super(id, aggregateId); | ||
this.eventPayload = eventPayload; | ||
} | ||
|
||
public static ArtifactVersionStateChanged of(String groupId, String artifactId, String version, | ||
VersionState oldState, VersionState newState) { | ||
String id = UUID.randomUUID().toString(); | ||
JSONObject jsonObject = new JSONObject(); | ||
jsonObject.put("id", id).put("groupId", groupId).put("artifactId", artifactId).put("version", version) | ||
.put("oldState", oldState.name()).put("newDate", newState.name()) | ||
.put("eventType", ARTIFACT_VERSION_STATE_CHANGED.name()); | ||
|
||
return new ArtifactVersionStateChanged(id, groupId + "-" + artifactId + "-" + version, jsonObject); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return ARTIFACT_VERSION_STATE_CHANGED.name(); | ||
} | ||
|
||
@Override | ||
public JSONObject getPayload() { | ||
return eventPayload; | ||
} | ||
} |
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
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