Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -60,6 +60,18 @@
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-messaging-kafka</artifactId>
<exclusions>
<!-- Overriding kafka-clients to fix a vulnerability.
This exclusion can be removed when Quarkus will contain kafka-clients in at least version 3.9.1. -->
<exclusion>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.reactivemessaging.http</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-messaging-kafka</artifactId>
<exclusions>
<!-- Overriding kafka-clients to fix a vulnerability.
This exclusion can be removed when Quarkus will contain kafka-clients in at least version 3.9.1. -->
<exclusion>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-messaging-kafka</artifactId>
<exclusions>
<!-- Overriding kafka-clients to fix a vulnerability.
This exclusion can be removed when Quarkus will contain kafka-clients in at least version 3.9.1. -->
<exclusion>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-messaging-kafka</artifactId>
<exclusions>
<!-- Overriding kafka-clients to fix a vulnerability.
This exclusion can be removed when Quarkus will contain kafka-clients in at least version 3.9.1. -->
<exclusion>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
Expand Down
102 changes: 102 additions & 0 deletions data-index/data-index-common-addons/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>data-index</artifactId>
<groupId>org.kie.kogito</groupId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>data-index-common-addons</artifactId>
<name>Kogito Apps :: Kogito Data Index Add-Ons Common</name>

<properties>
<java.module.name>org.kie.kogito.index.addons.common</java.module.name>
</properties>

<dependencies>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>data-index-common</artifactId>
</dependency>

<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-api</artifactId>
</dependency>

<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-services</artifactId>
</dependency>

<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-events-core</artifactId>
</dependency>

<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>jbpm-flow</artifactId>
</dependency>

<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-addons-process-svg</artifactId>
</dependency>

<dependency>
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.smallrye</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<executions>
<execution>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.eclipse.microprofile.context.ManagedExecutor;
import org.kie.kogito.Application;
import org.kie.kogito.Model;
import org.kie.kogito.index.api.ExecuteArgs;
Expand All @@ -38,8 +38,9 @@
import org.kie.kogito.index.model.ProcessInstance;
import org.kie.kogito.index.model.Timer;
import org.kie.kogito.index.model.UserTaskInstance;
import org.kie.kogito.index.quarkus.service.api.KogitoRuntimeCommonClient;
import org.kie.kogito.index.service.DataIndexServiceException;
import org.kie.kogito.index.service.KogitoRuntimeCommonClient;
import org.kie.kogito.index.service.auth.DataIndexAuthTokenReader;
import org.kie.kogito.internal.process.runtime.KogitoWorkflowProcess;
import org.kie.kogito.jackson.utils.JsonObjectUtils;
import org.kie.kogito.process.Process;
Expand All @@ -52,17 +53,15 @@

import com.fasterxml.jackson.databind.JsonNode;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import io.vertx.core.Vertx;

import static java.util.stream.Collectors.toMap;
import static org.kie.kogito.index.DependencyInjectionUtils.getInstance;
import static org.kie.kogito.jackson.utils.JsonObjectUtils.convertValue;
import static org.kie.kogito.jackson.utils.JsonObjectUtils.fromString;
import static org.kie.kogito.jackson.utils.JsonObjectUtils.fromValue;

@ApplicationScoped
public class KogitoAddonRuntimeClientImpl extends KogitoRuntimeCommonClient implements KogitoRuntimeClient {
public class KogitoAddonRuntimeClient extends KogitoRuntimeCommonClient implements KogitoRuntimeClient {

private static String SUCCESSFULLY_OPERATION_MESSAGE = "Successfully performed: %s";

Expand All @@ -74,20 +73,24 @@ public class KogitoAddonRuntimeClientImpl extends KogitoRuntimeCommonClient impl

private Application application;

@Inject
public KogitoAddonRuntimeClientImpl(Instance<ProcessSvgService> processSvgService,
SourceFilesProvider sourceFilesProvider,
Instance<Processes> processesInstance,
Instance<Application> application) {
this.processSvgService = processSvgService.isResolvable() ? processSvgService.get() : null;
this.sourceFilesProvider = sourceFilesProvider;
this.processes = processesInstance.isResolvable() ? processesInstance.get() : null;
this.application = application.isResolvable() ? application.get() : null;
private Executor managedExecutor;

public KogitoAddonRuntimeClient(Optional<String> gatewayUrl,
DataIndexAuthTokenReader authTokenReader,
Vertx vertx,
Iterable<ProcessSvgService> processSvgServices,
Iterable<SourceFilesProvider> sourceFilesProviders,
Iterable<Processes> processesInstance,
Iterable<Application> application,
Executor managedExecutor) {
super(gatewayUrl, authTokenReader, vertx);
this.processSvgService = getInstance(processSvgServices);
this.sourceFilesProvider = getInstance(sourceFilesProviders);
this.processes = getInstance(processesInstance);
this.application = getInstance(application);
this.managedExecutor = managedExecutor;
}

@Inject
ManagedExecutor managedExecutor;

static <T> CompletableFuture<T> throwUnsupportedException() {
return CompletableFuture.failedFuture(new UnsupportedOperationException("Unsupported operation using Data Index addon"));
}
Expand Down Expand Up @@ -162,6 +165,9 @@ public CompletableFuture<String> getProcessInstanceDiagram(String serviceURL, Pr

@Override
public CompletableFuture<String> getProcessDefinitionSourceFileContent(String serviceURL, String processId) {
if (sourceFilesProvider == null) {
return CompletableFuture.completedFuture(null);
}
return CompletableFuture.supplyAsync(() -> sourceFilesProvider.getProcessSourceFile(processId)
.map(sourceFile -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.kie.kogito.index.addon;
package org.kie.kogito.index.addon.event;

import java.io.IOException;
import java.io.UncheckedIOException;
Expand Down Expand Up @@ -44,8 +44,12 @@ public class DataIndexEventPublisher implements EventPublisher {

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

private final IndexingService indexingService;

@Inject
IndexingService indexingService;
public DataIndexEventPublisher(IndexingService indexingService) {
this.indexingService = indexingService;
}

@Override
@Transactional
Expand Down Expand Up @@ -85,11 +89,8 @@ public void publish(DataEvent<?> event) {
}

@Override
@Transactional
public void publish(Collection<DataEvent<?>> events) {
events.forEach(this::publish);
}

protected void setIndexingService(IndexingService indexingService) {
this.indexingService = indexingService;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
4 changes: 4 additions & 0 deletions data-index/data-index-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-client</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.kie.kogito.index;

import java.util.Iterator;
import java.util.function.Supplier;

public class DependencyInjectionUtils {

private DependencyInjectionUtils() {
// Utils class, no instantiable
}

public static <T> T getInstance(Iterable<T> iterable) {
return getInstanceOrDefault(iterable, () -> null);
}

public static <T> T getInstanceOrDefault(Iterable<T> iterable, Supplier<T> defaultValue) {
Iterator<T> iterator = iterable.iterator();
if (iterator.hasNext()) {
return iterator.next();
} else {
return defaultValue.get();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ public class IndexingService {

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

@Inject
DataIndexStorageService manager;

@Inject
public IndexingService(DataIndexStorageService manager) {
this.manager = manager;
}

public void indexProcessInstanceEvent(ProcessInstanceDataEvent<?> event) {
ProcessInstanceStorage storage = manager.getProcessInstanceStorage();
if (event instanceof MultipleProcessInstanceDataEvent) {
Expand Down
Loading
Loading