-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add artifact metadata update event and artifact delete event
- Loading branch information
1 parent
826fef7
commit 5d4261b
Showing
12 changed files
with
188 additions
and
30 deletions.
There are no files selected for viewing
26 changes: 15 additions & 11 deletions
26
...try/storage/dto/ArtifactCreatedEvent.java → ...urio/registry/events/ArtifactCreated.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 |
---|---|---|
@@ -1,42 +1,46 @@ | ||
package io.apicurio.registry.storage.dto; | ||
package io.apicurio.registry.events; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import io.apicurio.registry.storage.dto.ArtifactMetaDataDto; | ||
import io.apicurio.registry.storage.dto.OutboxEvent; | ||
|
||
import java.util.UUID; | ||
|
||
import static io.apicurio.registry.storage.StorageEventType.ARTIFACT_CREATED; | ||
|
||
public class ArtifactCreatedEvent extends OutboxEvent { | ||
public class ArtifactCreated extends OutboxEvent { | ||
|
||
private static final ObjectMapper mapper = new ObjectMapper(); | ||
|
||
private final JsonNode designPayload; | ||
private final JsonNode eventPayload; | ||
|
||
private ArtifactCreatedEvent(String id, String aggregateId, JsonNode designPayload) { | ||
super(id, aggregateId, ARTIFACT_CREATED.name()); | ||
this.designPayload = designPayload; | ||
private ArtifactCreated(String id, String aggregateId, JsonNode eventPayload) { | ||
super(id, aggregateId); | ||
this.eventPayload = eventPayload; | ||
} | ||
|
||
public static ArtifactCreatedEvent of(ArtifactMetaDataDto artifactMetaDataDto) { | ||
public static ArtifactCreated of(ArtifactMetaDataDto artifactMetaDataDto) { | ||
String id = UUID.randomUUID().toString(); | ||
// TODO here we have to define the internal structure of the event, maybe use cloudevents? | ||
ObjectNode asJson = mapper.createObjectNode().put("id", id) | ||
.put("artifactId", artifactMetaDataDto.getArtifactId()) | ||
.put("name", artifactMetaDataDto.getName()) | ||
.put("description", artifactMetaDataDto.getDescription()); | ||
.put("description", artifactMetaDataDto.getDescription()) | ||
.put("eventType", ARTIFACT_CREATED.name()); | ||
|
||
return new ArtifactCreatedEvent(id, artifactMetaDataDto.getArtifactId(), asJson); | ||
return new ArtifactCreated(id, | ||
artifactMetaDataDto.getGroupId() + "-" + artifactMetaDataDto.getArtifactId(), asJson); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return getEventType(); | ||
return ARTIFACT_CREATED.name(); | ||
} | ||
|
||
@Override | ||
public JsonNode getPayload() { | ||
return designPayload; | ||
return eventPayload; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/src/main/java/io/apicurio/registry/events/ArtifactDeleted.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,41 @@ | ||
package io.apicurio.registry.events; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import io.apicurio.registry.storage.dto.OutboxEvent; | ||
|
||
import java.util.UUID; | ||
|
||
import static io.apicurio.registry.storage.StorageEventType.ARTIFACT_DELETED; | ||
|
||
public class ArtifactDeleted extends OutboxEvent { | ||
|
||
private static final ObjectMapper mapper = new ObjectMapper(); | ||
|
||
private final JsonNode eventPayload; | ||
|
||
private ArtifactDeleted(String id, String aggregateId, JsonNode eventPayload) { | ||
super(id, aggregateId); | ||
this.eventPayload = eventPayload; | ||
} | ||
|
||
public static ArtifactDeleted of(String groupId, String artifactId) { | ||
String id = UUID.randomUUID().toString(); | ||
// TODO here we have to define the internal structure of the event, maybe use cloudevents? | ||
ObjectNode asJson = mapper.createObjectNode().put("id", id).put("groupId", groupId) | ||
.put("artifactId", artifactId).put("eventType", ARTIFACT_DELETED.name()); | ||
|
||
return new ArtifactDeleted(id, groupId + "-" + artifactId, asJson); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return ARTIFACT_DELETED.name(); | ||
} | ||
|
||
@Override | ||
public JsonNode getPayload() { | ||
return eventPayload; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
app/src/main/java/io/apicurio/registry/events/ArtifactMetadataUpdated.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,46 @@ | ||
package io.apicurio.registry.events; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import io.apicurio.registry.storage.dto.EditableArtifactMetaDataDto; | ||
import io.apicurio.registry.storage.dto.OutboxEvent; | ||
|
||
import java.util.UUID; | ||
|
||
import static io.apicurio.registry.storage.StorageEventType.ARTIFACT_METADATA_UPDATED; | ||
|
||
public class ArtifactMetadataUpdated extends OutboxEvent { | ||
|
||
private static final ObjectMapper mapper = new ObjectMapper(); | ||
|
||
private final JsonNode eventPayload; | ||
|
||
private ArtifactMetadataUpdated(String id, String aggregateId, JsonNode eventPayload) { | ||
super(id, aggregateId); | ||
this.eventPayload = eventPayload; | ||
} | ||
|
||
public static ArtifactMetadataUpdated of(String groupId, String artifactId, | ||
EditableArtifactMetaDataDto artifactMetaDataDto) { | ||
String id = UUID.randomUUID().toString(); | ||
// TODO here we have to define the internal structure of the event, maybe use cloudevents? | ||
ObjectNode asJson = mapper.createObjectNode().put("id", id).put("groupId", groupId) | ||
.put("artifactId", artifactId).put("name", artifactMetaDataDto.getName()) | ||
.put("owner", artifactMetaDataDto.getOwner()) | ||
.put("description", artifactMetaDataDto.getDescription()) | ||
.put("eventType", ARTIFACT_METADATA_UPDATED.name()); | ||
|
||
return new ArtifactMetadataUpdated(id, groupId + "-" + artifactId, asJson); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return ARTIFACT_METADATA_UPDATED.name(); | ||
} | ||
|
||
@Override | ||
public JsonNode 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
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
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
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
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