From 009b49e1f08693c4b0958e61222d859636f489df Mon Sep 17 00:00:00 2001 From: Cristiano Nicolai <570894+cristianonicolai@users.noreply.github.com> Date: Fri, 21 Jul 2023 00:51:07 -0300 Subject: [PATCH] KOGITO-9611 - Track user identity in Kogito event --- .../test/java/org/kie/kogito/index/TestUtils.java | 4 ++-- .../index/addon/DataIndexEventPublisherTest.java | 2 +- .../kogito/jobs/service/events/JobDataEvent.java | 13 ++++++++++--- .../embedded/stream/EventPublisherJobStreams.java | 8 +++++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/data-index/data-index-common/src/test/java/org/kie/kogito/index/TestUtils.java b/data-index/data-index-common/src/test/java/org/kie/kogito/index/TestUtils.java index 103b0568fa..b98819762e 100644 --- a/data-index/data-index-common/src/test/java/org/kie/kogito/index/TestUtils.java +++ b/data-index/data-index-common/src/test/java/org/kie/kogito/index/TestUtils.java @@ -132,7 +132,7 @@ public static ProcessInstanceDataEvent getProcessCloudEvent(String processId, St .build() : null) .build(); - return new ProcessInstanceDataEvent(URI.create("http://localhost:8080/" + processId).toString(), "jobs-management,prometheus-monitoring,process-management", body.metaData(), body); + return new ProcessInstanceDataEvent(URI.create("http://localhost:8080/" + processId).toString(), "jobs-management,prometheus-monitoring,process-management", null, body.metaData(), body); } public static ProcessInstance getProcessInstance(String processId, String processInstanceId, Integer status, String rootProcessInstanceId, String rootProcessId) { @@ -229,7 +229,7 @@ public static UserTaskInstanceDataEvent getUserTaskCloudEvent(String taskId, Str .outputs(emptyMap()) .build(); - return new UserTaskInstanceDataEvent(URI.create("http://localhost:8080/" + processId).toString(), null, body.metaData(), body); + return new UserTaskInstanceDataEvent(URI.create("http://localhost:8080/" + processId).toString(), null, null, body.metaData(), body); } public static AttachmentEventBody getTaskAttachment(String id, String user, String name, String content) { diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/runtime/src/test/java/org/kie/kogito/index/addon/DataIndexEventPublisherTest.java b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/runtime/src/test/java/org/kie/kogito/index/addon/DataIndexEventPublisherTest.java index 7afb99e1f7..c5061a1db9 100644 --- a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/runtime/src/test/java/org/kie/kogito/index/addon/DataIndexEventPublisherTest.java +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/runtime/src/test/java/org/kie/kogito/index/addon/DataIndexEventPublisherTest.java @@ -130,7 +130,7 @@ public TestingDataEvent(String type, String kogitoProcessId, String kogitoRootProcessId) { super(type, source, data, kogitoProcessInstanceId, kogitoRootProcessInstanceId, kogitoProcessId, - kogitoRootProcessId, null); + kogitoRootProcessId, null, null); } } diff --git a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/events/JobDataEvent.java b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/events/JobDataEvent.java index 3cf1fcbdcb..5000e29f21 100644 --- a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/events/JobDataEvent.java +++ b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/events/JobDataEvent.java @@ -28,7 +28,7 @@ public class JobDataEvent extends AbstractDataEvent { public static final String JOB_EVENT_TYPE = "JobEvent"; - public JobDataEvent(String source, ScheduledJob data) { + public JobDataEvent(String source, String identity, ScheduledJob data) { super(JOB_EVENT_TYPE, source, data, @@ -36,7 +36,8 @@ public JobDataEvent(String source, ScheduledJob data) { data.getRootProcessInstanceId(), data.getProcessId(), data.getRootProcessId(), - null); + null, + identity); } @JsonIgnore @@ -49,19 +50,25 @@ public static class JobDataEventBuilder { private String source; private ScheduledJob data; + private String identity; public JobDataEventBuilder source(String source) { this.source = source; return this; } + public JobDataEventBuilder identity(String identity) { + this.identity = identity; + return this; + } + public JobDataEventBuilder data(ScheduledJob data) { this.data = data; return this; } public JobDataEvent build() { - return new JobDataEvent(source, data); + return new JobDataEvent(source, identity, data); } } } diff --git a/jobs-service/kogito-addons-jobs-service/kogito-addons-quarkus-jobs-service-embedded/runtime/src/main/java/org/kie/kogito/addons/quarkus/jobs/service/embedded/stream/EventPublisherJobStreams.java b/jobs-service/kogito-addons-jobs-service/kogito-addons-quarkus-jobs-service-embedded/runtime/src/main/java/org/kie/kogito/addons/quarkus/jobs/service/embedded/stream/EventPublisherJobStreams.java index dc848c0fd6..3e64c6df7a 100644 --- a/jobs-service/kogito-addons-jobs-service/kogito-addons-quarkus-jobs-service-embedded/runtime/src/main/java/org/kie/kogito/addons/quarkus/jobs/service/embedded/stream/EventPublisherJobStreams.java +++ b/jobs-service/kogito-addons-jobs-service/kogito-addons-quarkus-jobs-service-embedded/runtime/src/main/java/org/kie/kogito/addons/quarkus/jobs/service/embedded/stream/EventPublisherJobStreams.java @@ -87,7 +87,8 @@ public void onJobStatusChange(JobDetails jobDetails) { scheduledJob.getProcessInstanceId(), scheduledJob.getRootProcessInstanceId(), scheduledJob.getProcessId(), - scheduledJob.getRootProcessId()); + scheduledJob.getRootProcessId(), + null); try { eventPublisher.publish(event); } catch (Exception e) { @@ -103,9 +104,10 @@ public EventPublisherJobDataEvent(String type, String kogitoProcessInstanceId, String kogitoRootProcessInstanceId, String kogitoProcessId, - String kogitoRootProcessId) { + String kogitoRootProcessId, + String kogitoIdentity) { super(type, source, data, kogitoProcessInstanceId, kogitoRootProcessInstanceId, kogitoProcessId, - kogitoRootProcessId, null); + kogitoRootProcessId, null, kogitoIdentity); } } }