Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync main branch with main-apache branch #1

Merged
merged 36 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
81eb921
Bump jquery-ui to 1.13.2 (#3226)
jomarko Sep 20, 2023
d7251c6
Change jboss-parent to apache parent pom. (#3232)
baldimir Oct 4, 2023
b95593b
[KOGITO-9803] Upgrade open api releases (#3227)
fjtirado Oct 5, 2023
5620198
[KOGITO-9838] Improving error message (#3238)
fjtirado Oct 6, 2023
f485b62
[KOGITO-9861] Fixing compilation issues with nested classes and array…
fjtirado Oct 6, 2023
e73ba97
updating Quarkus to 2.6.11.Final to take CVE-2023-4853 fix (#3246)
mareknovotny Oct 7, 2023
c289690
[KOGITO-9844] Enhace jq validation to detect invalid functions (#3239)
fjtirado Oct 9, 2023
aaf2d48
kie-issues#622: explicitly provide startupTimeout in waitingFor call
Oct 9, 2023
994995f
KOGITO-9849 DataIndex is not processing well the http cloud events (#…
wmedvede Oct 10, 2023
dfbd63a
[KOGITO-9810] Supporting nested properties (#3229)
fjtirado Oct 10, 2023
811140b
[DROOLS-7555] move automatic rest endpoints generation from Kogito to…
mariofusco Oct 11, 2023
8ce1cd6
remove version when using kogito-addons-quarkus-microprofile-config-s…
rgdoliveira Oct 13, 2023
2858152
[kie-issues#628] Change JBoss Nexus to Apache Nexus. (#3251)
baldimir Oct 16, 2023
20b25f3
bump to Quarkus 2.16.12 (#3253)
mariofusco Oct 18, 2023
5a83d4e
[kie-issues-249] Data index improvements (#3241)
elguardian Oct 18, 2023
63169a3
fix compilation problems in kafak integration test
elguardian Oct 23, 2023
7128d11
[KOGITO-9785] Option to configure timeout error handler (#3255)
dmartinol Oct 24, 2023
b469c93
kie-issues#647: add writeJunitReport to invoker configuration (#3258)
jstastny-cz Oct 25, 2023
ff0b043
[DROOLS-6834] remove drl prefix from drools quarkus extension (#3261)
mariofusco Oct 25, 2023
5e7c29d
[KOGITO-9914] Setting LD_LIBRARY_PATH
fjtirado Oct 25, 2023
243c3a8
This tries to reduce the log file size of SWF IT
fjtirado Oct 26, 2023
c934709
NO_ISSUE: Overriding commons-compress version to fix CVE-2023-42503 p…
pefernan Oct 31, 2023
ec22f09
[KOGITO-9785] Handle event state error (#3270)
fjtirado Nov 2, 2023
afa07f0
Properly trace cloud events (#3271)
fjtirado Nov 6, 2023
0249510
[KOGITO-9811] Evaluating timeout duration as expression (#3250)
fjtirado Nov 7, 2023
e978ff3
Microprofile Config Service Catalog Addon throws exception at address…
wmedvede Nov 8, 2023
d239484
Fix #3280 New SWF sdk release (#3281)
fjtirado Nov 16, 2023
3b80d86
[KOGITO-9886] Add the support for the ProcessDefinitionDataEvent at r…
tiagodolphine Nov 23, 2023
f1bf4a8
[kie-issues#698] Fix SCA quality issue on generated code (#3287)
gitgabrio Nov 23, 2023
49ddfac
Add UserTaskInstanceDataEvent to eventsAPIReflexion to fix data-index…
nmirasch Nov 28, 2023
227fab4
Bump Openapi Generator to 1.13.4 (#3285)
gabriel-farache Dec 5, 2023
12309ac
Fix #3307 (#3309)
fjtirado Dec 5, 2023
e9d2e45
kie-issues#742: upgrade jacoco maven plugin to 0.8.11 (#3313)
jstastny-cz Dec 6, 2023
e183217
[KOGITO-9816] Adding ProcessDefinitionRegistration to springboot (#3310)
tiagodolphine Dec 6, 2023
af0a57c
kie-issues-3314: Add the missing extension information to the kogito-…
wmedvede Dec 12, 2023
86d225c
revert changes in .ci/jenkins/tests/pom.xml from commit 1e277258a0feb…
rgdoliveira Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@
package org.kie.kogito.events.mongodb;

import java.util.Collection;
import java.util.function.BooleanSupplier;

import org.bson.codecs.configuration.CodecRegistries;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.codecs.pojo.PojoCodecProvider;
import org.kie.kogito.event.DataEvent;
import org.kie.kogito.event.EventPublisher;
import org.kie.kogito.event.process.ProcessInstanceDataEvent;
import org.kie.kogito.event.process.UserTaskInstanceDataEvent;
import org.kie.kogito.event.process.VariableInstanceDataEvent;
import org.kie.kogito.event.usertask.UserTaskInstanceDataEvent;
import org.kie.kogito.events.mongodb.codec.EventMongoDBCodecProvider;
import org.kie.kogito.mongodb.transaction.AbstractTransactionManager;
import org.slf4j.Logger;
Expand All @@ -50,7 +48,6 @@ public abstract class MongoDBEventPublisher implements EventPublisher {

private MongoCollection<ProcessInstanceDataEvent> processInstanceDataEventCollection;
private MongoCollection<UserTaskInstanceDataEvent> userTaskInstanceDataEventCollection;
private MongoCollection<VariableInstanceDataEvent> variableInstanceDataEventCollection;

protected abstract MongoClient mongoClient();

Expand All @@ -60,54 +57,47 @@ public abstract class MongoDBEventPublisher implements EventPublisher {

protected abstract boolean userTasksEvents();

protected abstract boolean variablesEvents();

protected abstract String eventsDatabaseName();

protected abstract String processInstancesEventsCollection();

protected abstract String userTasksEventsCollection();

protected abstract String variablesEventsCollection();

protected void configure() {
CodecRegistry registry = CodecRegistries.fromRegistries(MongoClientSettings.getDefaultCodecRegistry(), fromProviders(new EventMongoDBCodecProvider(),
PojoCodecProvider.builder().automatic(true).build()));
MongoDatabase mongoDatabase = mongoClient().getDatabase(eventsDatabaseName()).withCodecRegistry(registry);
processInstanceDataEventCollection = mongoDatabase.getCollection(processInstancesEventsCollection(), ProcessInstanceDataEvent.class).withCodecRegistry(registry);
userTaskInstanceDataEventCollection = mongoDatabase.getCollection(userTasksEventsCollection(), UserTaskInstanceDataEvent.class).withCodecRegistry(registry);
variableInstanceDataEventCollection = mongoDatabase.getCollection(variablesEventsCollection(), VariableInstanceDataEvent.class).withCodecRegistry(registry);
}

@Override
public void publish(DataEvent<?> event) {
switch (event.getType()) {
case "ProcessInstanceEvent":
publishEvent(processInstanceDataEventCollection, (ProcessInstanceDataEvent) event, this::processInstancesEvents);
break;
case "UserTaskInstanceEvent":
publishEvent(userTaskInstanceDataEventCollection, (UserTaskInstanceDataEvent) event, this::userTasksEvents);
break;
case "VariableInstanceEvent":
publishEvent(variableInstanceDataEventCollection, (VariableInstanceDataEvent) event, this::variablesEvents);
break;
default:
logger.warn("Unknown type of event '{}', ignoring", event.getType());
if (this.processInstancesEvents() && event instanceof ProcessInstanceDataEvent) {
publishEvent(processInstanceDataEventCollection, (ProcessInstanceDataEvent) event);
return;
}

if (this.userTasksEvents() && event instanceof UserTaskInstanceDataEvent) {
publishEvent(userTaskInstanceDataEventCollection, (UserTaskInstanceDataEvent) event);
return;
}

logger.debug("Unknown type of event '{}', ignoring", event.getType());

}

private <T extends DataEvent<?>> void publishEvent(MongoCollection<T> collection, T event, BooleanSupplier enabled) {
if (enabled.getAsBoolean()) {
if (transactionManager().enabled()) {
collection.insertOne(transactionManager().getClientSession(), event);
// delete the event immediately from the outbox collection
collection.deleteOne(transactionManager().getClientSession(), Filters.eq(ID, event.getId()));
} else {
collection.insertOne(event);
// delete the event from the outbox collection
collection.deleteOne(Filters.eq(ID, event.getId()));
}
private <T extends DataEvent<?>> void publishEvent(MongoCollection<T> collection, T event) {
if (transactionManager().enabled()) {
collection.insertOne(transactionManager().getClientSession(), event);
// delete the event immediately from the outbox collection
collection.deleteOne(transactionManager().getClientSession(), Filters.eq(ID, event.getId()));
} else {
collection.insertOne(event);
// delete the event from the outbox collection
collection.deleteOne(Filters.eq(ID, event.getId()));
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,22 @@
import org.bson.codecs.configuration.CodecProvider;
import org.bson.codecs.configuration.CodecRegistry;
import org.kie.kogito.event.process.ProcessInstanceDataEvent;
import org.kie.kogito.event.process.UserTaskInstanceDataEvent;
import org.kie.kogito.event.process.VariableInstanceDataEvent;
import org.kie.kogito.event.usertask.UserTaskInstanceDataEvent;

public class EventMongoDBCodecProvider implements CodecProvider {

private static final ProcessInstanceDataEventCodec PROCESS_INSTANCE_DATA_EVENT_CODEC = new ProcessInstanceDataEventCodec();
private static final UserTaskInstanceDataEventCodec USER_TASK_INSTANCE_DATA_EVENT_CODEC = new UserTaskInstanceDataEventCodec();
private static final VariableInstanceDataEventCodec VARIABLE_INSTANCE_DATA_EVENT_CODEC = new VariableInstanceDataEventCodec();

@SuppressWarnings("unchecked")
@Override
public <T> Codec<T> get(Class<T> aClass, CodecRegistry codecRegistry) {
if (aClass == ProcessInstanceDataEvent.class) {
if (ProcessInstanceDataEvent.class.isAssignableFrom(aClass)) {
return (Codec<T>) PROCESS_INSTANCE_DATA_EVENT_CODEC;
}
if (aClass == UserTaskInstanceDataEvent.class) {
if (UserTaskInstanceDataEvent.class.isAssignableFrom(aClass)) {
return (Codec<T>) USER_TASK_INSTANCE_DATA_EVENT_CODEC;
}
if (aClass == VariableInstanceDataEvent.class) {
return (Codec<T>) VARIABLE_INSTANCE_DATA_EVENT_CODEC;
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.kie.kogito.events.mongodb.codec;

import java.util.stream.Collectors;

import org.bson.BsonReader;
import org.bson.BsonString;
import org.bson.BsonValue;
Expand All @@ -29,13 +27,19 @@
import org.bson.codecs.DecoderContext;
import org.bson.codecs.EncoderContext;
import org.kie.kogito.event.process.ProcessInstanceDataEvent;
import org.kie.kogito.event.process.ProcessInstanceEventBody;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import static org.kie.kogito.events.mongodb.codec.CodecUtils.codec;
import static org.kie.kogito.events.mongodb.codec.CodecUtils.encodeDataEvent;

public class ProcessInstanceDataEventCodec implements CollectibleCodec<ProcessInstanceDataEvent> {

private static final Logger LOGGER = LoggerFactory.getLogger(ProcessInstanceDataEventCodec.class);

@Override
public ProcessInstanceDataEvent generateIdIfAbsentFromDocument(ProcessInstanceDataEvent processInstanceDataEvent) {
return processInstanceDataEvent;
Expand All @@ -61,76 +65,16 @@ public ProcessInstanceDataEvent decode(BsonReader bsonReader, DecoderContext dec

@Override
public void encode(BsonWriter bsonWriter, ProcessInstanceDataEvent processInstanceDataEvent, EncoderContext encoderContext) {
Document doc = new Document();
encodeDataEvent(doc, processInstanceDataEvent);
doc.put("kogitoProcessType", processInstanceDataEvent.getKogitoProcessType());
doc.put("kogitoProcessInstanceVersion", processInstanceDataEvent.getKogitoProcessInstanceVersion());
doc.put("kogitoParentProcessinstanceId", processInstanceDataEvent.getKogitoParentProcessInstanceId());
doc.put("kogitoProcessinstanceState", processInstanceDataEvent.getKogitoProcessInstanceState());
doc.put("kogitoReferenceId", processInstanceDataEvent.getKogitoReferenceId());
doc.put("kogitoStartFromNode", processInstanceDataEvent.getKogitoStartFromNode());
doc.put("kogitoIdentity", processInstanceDataEvent.getKogitoIdentity());
doc.put("data", encodeData(processInstanceDataEvent.getData()));
codec().encode(bsonWriter, doc, encoderContext);
}

private Document encodeData(ProcessInstanceEventBody data) {
Document doc = new Document();
doc.put("id", data.getId());
doc.put("version", data.getVersion());
doc.put("parentInstanceId", data.getParentInstanceId());
doc.put("rootInstanceId", data.getRootInstanceId());
doc.put("processId", data.getProcessId());
doc.put("processType", data.getProcessType());
doc.put("rootProcessId", data.getRootProcessId());
doc.put("processName", data.getProcessName());
doc.put("startDate", data.getStartDate());
doc.put("endDate", data.getEndDate());
doc.put("state", data.getState());
doc.put("businessKey", data.getBusinessKey());
doc.put("roles", data.getRoles());
doc.put("identity", data.getIdentity());

if (data.getVariables() != null) {
doc.put("variables", new Document(data.getVariables()));
try {
ObjectMapper mapper = new ObjectMapper();
mapper.findAndRegisterModules();
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
Document document = Document.parse(mapper.writeValueAsString(processInstanceDataEvent));
document.put(CodecUtils.ID, processInstanceDataEvent.getId());
codec().encode(bsonWriter, document, encoderContext);
} catch (JsonProcessingException e) {
LOGGER.error("Could not process json event", e);
}

if (data.getNodeInstances() != null) {
doc.put("nodeInstances",
data.getNodeInstances().stream().map(ni -> {
Document niDoc = new Document();
niDoc.put("id", ni.getId());
niDoc.put("nodeId", ni.getNodeId());
niDoc.put("nodeDefinitionId", ni.getNodeDefinitionId());
niDoc.put("nodeName", ni.getNodeName());
niDoc.put("nodeType", ni.getNodeType());
niDoc.put("triggerTime", ni.getTriggerTime());
if (ni.getLeaveTime() != null) {
niDoc.put("leaveTime", ni.getLeaveTime());
}
return niDoc;
}).collect(Collectors.toSet()));
}

if (data.getError() != null) {
Document eDoc = new Document();
eDoc.put("errorMessage", data.getError().getErrorMessage());
eDoc.put("nodeDefinitionId", data.getError().getNodeDefinitionId());
doc.put("error", eDoc);
}

if (data.getMilestones() != null) {
doc.put("milestones",
data.getMilestones().stream().map(m -> {
Document mDoc = new Document();
mDoc.put("id", m.getId());
mDoc.put("name", m.getName());
mDoc.put("status", m.getStatus());
return mDoc;
}).collect(Collectors.toSet()));
}

return doc;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.kie.kogito.events.mongodb.codec;

import java.util.stream.Collectors;

import org.bson.BsonReader;
import org.bson.BsonString;
import org.bson.BsonValue;
Expand All @@ -28,16 +26,22 @@
import org.bson.codecs.CollectibleCodec;
import org.bson.codecs.DecoderContext;
import org.bson.codecs.EncoderContext;
import org.kie.kogito.event.process.UserTaskInstanceDataEvent;
import org.kie.kogito.event.process.UserTaskInstanceEventBody;
import org.kie.kogito.event.usertask.UserTaskInstanceDataEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import static org.kie.kogito.events.mongodb.codec.CodecUtils.codec;
import static org.kie.kogito.events.mongodb.codec.CodecUtils.encodeDataEvent;

public class UserTaskInstanceDataEventCodec implements CollectibleCodec<UserTaskInstanceDataEvent> {

private static final Logger LOGGER = LoggerFactory.getLogger(UserTaskInstanceDataEventCodec.class);

@Override
public UserTaskInstanceDataEvent generateIdIfAbsentFromDocument(UserTaskInstanceDataEvent userTaskInstanceDataEvent) {
public UserTaskInstanceDataEvent<?> generateIdIfAbsentFromDocument(UserTaskInstanceDataEvent userTaskInstanceDataEvent) {
return userTaskInstanceDataEvent;
}

Expand All @@ -61,64 +65,16 @@ public UserTaskInstanceDataEvent decode(BsonReader bsonReader, DecoderContext de

@Override
public void encode(BsonWriter bsonWriter, UserTaskInstanceDataEvent userTaskInstanceDataEvent, EncoderContext encoderContext) {
Document doc = new Document();
encodeDataEvent(doc, userTaskInstanceDataEvent);
doc.put("kogitoUserTaskinstanceId", userTaskInstanceDataEvent.getKogitoUserTaskinstanceId());
doc.put("kogitoUserTaskinstanceState", userTaskInstanceDataEvent.getKogitoUserTaskinstanceState());
doc.put("data", encodeData(userTaskInstanceDataEvent.getData()));
codec().encode(bsonWriter, doc, encoderContext);
}

private Document encodeData(UserTaskInstanceEventBody data) {
Document doc = new Document();
doc.put("id", data.getId());
doc.put("taskName", data.getTaskName());
doc.put("taskDescription", data.getTaskDescription());
doc.put("taskPriority", data.getTaskPriority());
doc.put("referenceName", data.getReferenceName());
doc.put("startDate", data.getStartDate());
doc.put("completeDate", data.getCompleteDate());
doc.put("state", data.getState());
doc.put("actualOwner", data.getActualOwner());
doc.put("potentialUsers", data.getPotentialUsers());
doc.put("potentialGroups", data.getPotentialGroups());
doc.put("excludedUsers", data.getExcludedUsers());
doc.put("adminUsers", data.getAdminUsers());
doc.put("adminGroups", data.getAdminGroups());
doc.put("inputs", new Document(data.getInputs()));
doc.put("outputs", new Document(data.getOutputs()));
doc.put("processInstanceId", data.getProcessInstanceId());
doc.put("rootProcessInstanceId", data.getRootProcessInstanceId());
doc.put("processId", data.getProcessId());
doc.put("rootProcessId", data.getRootProcessId());
doc.put("identity", data.getIdentity());

if (data.getComments() != null) {
doc.put("comments",
data.getComments().stream().map(c -> {
Document cDoc = new Document();
cDoc.put("id", c.getId());
cDoc.put("content", c.getContent());
cDoc.put("updatedAt", c.getUpdatedAt());
cDoc.put("updatedBy", c.getUpdatedBy());
return cDoc;
}).collect(Collectors.toSet()));
}

if (data.getAttachments() != null) {
doc.put("attachments",
data.getAttachments().stream().map(a -> {
Document aDoc = new Document();
aDoc.put("id", a.getId());
aDoc.put("content", a.getContent());
aDoc.put("updatedAt", a.getUpdatedAt());
aDoc.put("updatedBy", a.getUpdatedBy());
aDoc.put("name", a.getName());
return aDoc;
}).collect(Collectors.toSet()));
try {
ObjectMapper mapper = new ObjectMapper();
mapper.findAndRegisterModules();
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
Document document = Document.parse(mapper.writeValueAsString(userTaskInstanceDataEvent));
document.put(CodecUtils.ID, userTaskInstanceDataEvent.getId());
codec().encode(bsonWriter, document, encoderContext);
} catch (JsonProcessingException e) {
LOGGER.error("Could not process json event", e);
}

return doc;
}

@Override
Expand Down
Loading
Loading