From a61a391eb11828244ce4e824daf65014b2d3efbc Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Wed, 3 Jul 2024 14:16:13 +0200 Subject: [PATCH 01/10] [Fix #3569] Fixing windows path issue --- .../kogito/serverless/workflow/io/ClassPathContentLoader.java | 4 +--- .../kie/kogito/serverless/workflow/io/FileContentLoader.java | 2 +- .../serverless/workflow/io/URIContentLoaderFactory.java | 4 +--- .../kogito/serverless/workflow/io/URIContentLoaderTest.java | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java index 413c199a674..56b80a8beba 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java @@ -24,8 +24,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.net.URLDecoder; -import java.nio.charset.Charset; import java.nio.file.Path; import java.util.Optional; @@ -42,7 +40,7 @@ public class ClassPathContentLoader extends CachedContentLoader { static String getPath(URI uri) { final String classPathPrefix = "classpath:"; - String str = URLDecoder.decode(uri.toString(), Charset.defaultCharset()); + String str = uri.toString(); if (str.toLowerCase().startsWith(classPathPrefix)) { str = str.substring(classPathPrefix.length()); while (str.startsWith("/")) { diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java index 336efe012f0..c8015a2e6f3 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java @@ -31,7 +31,7 @@ public class FileContentLoader extends CachedContentLoader { FileContentLoader(URI uri, URIContentLoader... fallbackContentLoaders) { super(uri, fallbackContentLoaders); - this.path = Path.of(getPath(uri)); + this.path = uri.getScheme() == null ? Path.of(getPath(uri)) : Path.of(uri); } @Override diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java index 6e5b806594a..002174e876a 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java @@ -23,8 +23,6 @@ import java.io.UncheckedIOException; import java.net.URI; import java.net.URISyntaxException; -import java.net.URLEncoder; -import java.nio.charset.Charset; import java.util.Optional; import org.kie.kogito.serverless.workflow.parser.ParserContext; @@ -93,7 +91,7 @@ public static Builder builder(URI uri) { } public static Builder builder(String uri) { - return new Builder(URI.create(URLEncoder.encode(uri, Charset.defaultCharset()))); + return new Builder(URI.create(uri)); } public static class Builder { diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java index e3c2ec36962..807758ea256 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java @@ -52,7 +52,7 @@ void testNotExistingFile() { @Test void testNotExistingClasspath() { Builder builder = builder("classpath:/noPepe.txt"); - assertThatExceptionOfType(UncheckedIOException.class).isThrownBy(() -> readString(builder)); + assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> readString(builder)); } @Test From 6ece5f89ddec47128efa0744d0687d46fe597246 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Wed, 3 Jul 2024 15:09:36 +0200 Subject: [PATCH 02/10] [Fix #3569] Switching from URI to String --- .../pom.xml | 7 ++ .../workflow/io/CachedContentLoader.java | 23 +++++-- .../workflow/io/ClassPathContentLoader.java | 23 ++----- .../workflow/io/FileContentLoader.java | 11 ++-- .../workflow/io/HttpContentLoader.java | 18 +++-- .../serverless/workflow/io/ResourceCache.java | 5 +- .../workflow/io/ResourceCacheFactory.java | 9 ++- .../workflow/io/URIContentLoader.java | 3 - .../workflow/io/URIContentLoaderFactory.java | 57 ++++++---------- .../workflow/io/URIContentLoaderType.java | 66 +++++++++++++------ .../AbstractWorkflowOperationIdFactory.java | 9 ++- .../FileNameWorkflowOperationIdFactory.java | 3 +- .../FunctionWorkflowOperationIdFactory.java | 3 +- .../URIWorkflowOperationIdFactory.java | 7 +- .../operationid/WorkflowOperationId.java | 8 +-- .../workflow/parser/JsonSchemaReader.java | 9 ++- .../parser/ServerlessWorkflowParser.java | 2 +- .../utils/ServerlessWorkflowUtils.java | 5 +- .../io/ClassPathContentLoaderTest.java | 3 +- .../workflow/io/ResourceCacheFactoryTest.java | 15 ++--- .../workflow/io/URIContentLoaderTest.java | 17 +++-- .../FileNameWorkflowOperationIdTest.java | 9 --- .../SpecWorkflowOperationIdFactory.java | 3 +- .../workflow/utils/OpenAPIFactory.java | 3 +- .../rest/DescriptorRestOperationHandler.java | 3 +- 25 files changed, 156 insertions(+), 165 deletions(-) diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/pom.xml b/kogito-serverless-workflow/kogito-serverless-workflow-builder/pom.xml index 0d7ae54d492..49a5e44d15d 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/pom.xml +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/pom.xml @@ -106,6 +106,13 @@ org.kie.kogito kogito-jq-expression + + org.apache.kie.sonataflow + + sonataflow-addons-quarkus-camel-deployment + + 999-SNAPSHOT + \ No newline at end of file diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/CachedContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/CachedContentLoader.java index ad2c78948c4..8379890f51a 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/CachedContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/CachedContentLoader.java @@ -20,7 +20,6 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.net.URI; import java.nio.file.Path; import java.util.Optional; @@ -48,10 +47,10 @@ public synchronized byte[] readAllBytes() { } } - private final URI uri; + protected final String uri; private URIContentLoader[] fallbackContentLoaders; - protected CachedContentLoader(URI uri, URIContentLoader... fallbackContentLoaders) { + protected CachedContentLoader(String uri, URIContentLoader... fallbackContentLoaders) { this.uri = uri; this.fallbackContentLoaders = fallbackContentLoaders; } @@ -91,10 +90,20 @@ public InputStream getInputStream() { } } - protected abstract byte[] loadURI(URI uri); + protected static String trimScheme(String uri, String scheme) { + String str = uri; + if (str.toLowerCase().startsWith(scheme)) { + str = str.substring(scheme.length()); + } + return str; + } - @Override - public URI uri() { - return uri; + protected static String removeSlash(String str) { + while (str.startsWith("/")) { + str = str.substring(1); + } + return str; } + + protected abstract byte[] loadURI(); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java index 56b80a8beba..b08b8cd827b 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; -import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; @@ -32,24 +31,12 @@ public class ClassPathContentLoader extends CachedContentLoader { private final Optional resource; private final String classpath; - ClassPathContentLoader(URI uri, Optional cl, URIContentLoader... fallbackContentLoaders) { + ClassPathContentLoader(String uri, Optional cl, URIContentLoader... fallbackContentLoaders) { super(uri, fallbackContentLoaders); - this.classpath = getPath(uri); + this.classpath = uriToPath(uri); this.resource = Optional.ofNullable(cl.orElse(Thread.currentThread().getContextClassLoader()).getResource(classpath)); } - static String getPath(URI uri) { - final String classPathPrefix = "classpath:"; - String str = uri.toString(); - if (str.toLowerCase().startsWith(classPathPrefix)) { - str = str.substring(classPathPrefix.length()); - while (str.startsWith("/")) { - str = str.substring(1); - } - } - return str; - } - public Optional getResource() { return resource; } @@ -72,7 +59,7 @@ private static Path fromURL(URL url) { } @Override - protected byte[] loadURI(URI uri) { + protected byte[] loadURI() { return resource.map(this::loadBytes).orElseThrow(() -> new IllegalArgumentException("cannot find classpath resource " + classpath)); } @@ -84,6 +71,10 @@ private byte[] loadBytes(URL r) { } } + static String uriToPath(String uri) { + return removeSlash(trimScheme(uri, URIContentLoaderType.CLASSPATH.scheme())); + } + @Override public URIContentLoaderType type() { return URIContentLoaderType.CLASSPATH; diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java index c8015a2e6f3..ef86e1d2aeb 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.io.UncheckedIOException; -import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; import java.util.Optional; @@ -29,9 +28,9 @@ public class FileContentLoader extends CachedContentLoader { private final Path path; - FileContentLoader(URI uri, URIContentLoader... fallbackContentLoaders) { + FileContentLoader(String uri, URIContentLoader... fallbackContentLoaders) { super(uri, fallbackContentLoaders); - this.path = uri.getScheme() == null ? Path.of(getPath(uri)) : Path.of(uri); + this.path = Path.of(uriToPath(uri)); } @Override @@ -45,7 +44,7 @@ protected Optional internalGetPath() { } @Override - protected byte[] loadURI(URI uri) { + protected byte[] loadURI() { try { return Files.readAllBytes(path); } catch (IOException io) { @@ -53,7 +52,7 @@ protected byte[] loadURI(URI uri) { } } - static String getPath(URI uri) { - return uri.getPath(); + static String uriToPath(String uri) { + return trimScheme(uri, URIContentLoaderType.FILE.scheme()); } } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/HttpContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/HttpContentLoader.java index 195fcdabd41..21b9c178a16 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/HttpContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/HttpContentLoader.java @@ -22,6 +22,7 @@ import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URI; +import java.net.URL; import java.util.Base64; import java.util.Collection; import java.util.HashMap; @@ -50,17 +51,19 @@ class HttpContentLoader extends CachedContentLoader { private Optional workflow; private String authRef; + private final URIContentLoaderType type; - HttpContentLoader(URI uri, Optional workflow, String authRef) { + HttpContentLoader(String uri, Optional workflow, String authRef, URIContentLoaderType type) { super(uri); this.workflow = workflow; this.authRef = authRef; + this.type = type; } @Override - protected byte[] loadURI(URI u) { + protected byte[] loadURI() { try { - HttpURLConnection conn = (HttpURLConnection) u.toURL().openConnection(); + HttpURLConnection conn = (HttpURLConnection) new URL(uri).openConnection(); // some http servers required specific accept header (*/* is specified for those we do not care about accept) conn.setRequestProperty("Accept", "application/json,application/yaml,application/yml,application/text,text/*,*/*"); workflow.map(Workflow::getAuth).map(Auth::getAuthDefs).stream().flatMap(Collection::stream) @@ -74,7 +77,7 @@ protected byte[] loadURI(URI u) { } else { try (InputStream is = conn.getErrorStream()) { throw new IllegalArgumentException(String.format( - "Failed to fetch remote file: %s. Status code is %d and response: %n %s", u, code, is == null ? "" : new String(is.readAllBytes()))); + "Failed to fetch remote file: %s. Status code is %d and response: %n %s", uri, code, is == null ? "" : new String(is.readAllBytes()))); } } } catch (IOException io) { @@ -147,6 +150,11 @@ private String encode(String str) { @Override public URIContentLoaderType type() { - return URIContentLoaderType.HTTP; + return type; } + + static String uriToPath(String uri) { + return URI.create(uri).getPath(); + } + } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCache.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCache.java index 85f3581ba80..dee2d22f1d1 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCache.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCache.java @@ -18,9 +18,8 @@ */ package org.kie.kogito.serverless.workflow.io; -import java.net.URI; -import java.util.function.Function; +import java.util.function.Supplier; public interface ResourceCache { - byte[] get(URI uri, Function retrieveCall); + byte[] get(String uri, Supplier retrieveCall); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactory.java index 9352508a6cd..2e49f4fa398 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactory.java @@ -18,12 +18,11 @@ */ package org.kie.kogito.serverless.workflow.io; -import java.net.URI; import java.util.Collections; import java.util.Map; import java.util.WeakHashMap; import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Function; +import java.util.function.Supplier; public class ResourceCacheFactory { private static final AtomicReference cache = new AtomicReference<>(new LocalResourceCache()); @@ -33,11 +32,11 @@ public static ResourceCache getCache() { } private static class LocalResourceCache implements ResourceCache { - private final Map map = Collections.synchronizedMap(new WeakHashMap<>()); + private final Map map = Collections.synchronizedMap(new WeakHashMap<>()); @Override - public byte[] get(URI uri, Function retrieveCall) { - return map.computeIfAbsent(uri, retrieveCall); + public byte[] get(String uri, Supplier retrieveCall) { + return map.computeIfAbsent(uri, u -> retrieveCall.get()); } } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoader.java index 41b17ab3d0c..121d82450e9 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoader.java @@ -19,14 +19,11 @@ package org.kie.kogito.serverless.workflow.io; import java.io.InputStream; -import java.net.URI; import java.nio.file.Path; import java.util.Optional; public interface URIContentLoader { - URI uri(); - InputStream getInputStream(); URIContentLoaderType type(); diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java index 002174e876a..0a284b595f3 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java @@ -22,7 +22,6 @@ import java.io.InputStream; import java.io.UncheckedIOException; import java.net.URI; -import java.net.URISyntaxException; import java.util.Optional; import org.kie.kogito.serverless.workflow.parser.ParserContext; @@ -49,29 +48,17 @@ public static String readString(URIContentLoader loader) { return new String(readAllBytes(loader)); } - public static String getFileName(URI uri) { + public static String getFileName(String uri) { URIContentLoaderType type = URIContentLoaderType.from(uri); - String path = uriToPath(type, uri); + String path = type.uriToPath(uri); return type.lastPart(path); } - private static String uriToPath(URIContentLoaderType type, URI uri) { - switch (type) { - case CLASSPATH: - return ClassPathContentLoader.getPath(uri); - case FILE: - return FileContentLoader.getPath(uri); - case HTTP: - default: - return uri.getPath(); - } - } - public static String readString(Builder builder) { return readString(builder.build()); } - public static URIContentLoader buildLoader(URI uri, Workflow workflow, Optional context, String authRef) { + public static URIContentLoader buildLoader(String uri, Workflow workflow, Optional context, String authRef) { Builder builder = new Builder(uri).withWorkflow(workflow).withAuthRef(authRef); context.map(c -> c.getContext().getClassLoader()).ifPresent(builder::withClassloader); getBaseURI(workflow).ifPresent(builder::withBaseURI); @@ -83,7 +70,7 @@ public static byte[] readBytes(String uriStr, Workflow workflow, ParserContext p } public static byte[] readBytes(String uriStr, Workflow workflow, Optional parserContext) { - return readAllBytes(buildLoader(URI.create(uriStr), workflow, parserContext, null)); + return readAllBytes(buildLoader(uriStr, workflow, parserContext, null)); } public static Builder builder(URI uri) { @@ -95,13 +82,17 @@ public static Builder builder(String uri) { } public static class Builder { - private URI uri; + private String uri; private ClassLoader cl; private Workflow workflow; private String authRef; - private URI baseURI; + private String baseURI; private Builder(URI uri) { + this.uri = uri.toString(); + } + + private Builder(String uri) { this.uri = uri; } @@ -120,19 +111,21 @@ public Builder withAuthRef(String authRef) { return this; } - public Builder withBaseURI(URI baseURI) { + public Builder withBaseURI(String baseURI) { this.baseURI = baseURI; return this; } public URIContentLoader build() { - final URI finalURI = baseURI != null ? compoundURI(baseURI, uri) : uri; + final String finalURI = baseURI != null ? compoundURI(baseURI, uri) : uri; switch (URIContentLoaderType.from(finalURI)) { default: case FILE: return new FileContentLoader(finalURI, new ClassPathContentLoader(uri, Optional.ofNullable(cl))); case HTTP: - return new HttpContentLoader(finalURI, Optional.ofNullable(workflow), authRef); + return new HttpContentLoader(finalURI, Optional.ofNullable(workflow), authRef, URIContentLoaderType.HTTP); + case HTTPS: + return new HttpContentLoader(finalURI, Optional.ofNullable(workflow), authRef, URIContentLoaderType.HTTPS); case CLASSPATH: Optional optionalCl = Optional.ofNullable(cl); return finalURI == uri ? new ClassPathContentLoader(finalURI, optionalCl) : new ClassPathContentLoader(finalURI, optionalCl, new ClassPathContentLoader(uri, optionalCl)); @@ -140,24 +133,12 @@ public URIContentLoader build() { } } - public static URI compoundURI(URI baseURI, URI uri) { - if (uri.getScheme() != null) { + public static String compoundURI(String baseURI, String uri) { + if (URIContentLoaderType.scheme(uri).isPresent()) { return uri; } - URIContentLoaderType type = URIContentLoaderType.from(baseURI); - String basePath = type.trimLast(uriToPath(type, baseURI)); - String additionalPath = uriToPath(type, uri); - String path; - if (type.isAbsolutePath(additionalPath)) { - path = additionalPath; - } else { - path = type.concat(basePath, additionalPath); - } - try { - return new URI(type.toString().toLowerCase(), baseURI.getAuthority(), path, uri.getQuery(), uri.getFragment()); - } catch (URISyntaxException e) { - throw new IllegalArgumentException(e.getMessage(), e); - } + final URIContentLoaderType baseType = URIContentLoaderType.from(baseURI); + return baseType.addScheme(baseType.isAbsolutePath(uri) ? uri : baseType.concat(baseType.trimLast(baseType.uriToPath(baseURI)), uri)); } private URIContentLoaderFactory() { diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderType.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderType.java index 5b9ed8dbc37..d845ef9abef 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderType.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderType.java @@ -19,35 +19,50 @@ package org.kie.kogito.serverless.workflow.io; import java.io.File; -import java.net.URI; +import java.util.Optional; +import java.util.function.Function; public enum URIContentLoaderType { - CLASSPATH(), - FILE(File.separatorChar), - HTTP(); + CLASSPATH(ClassPathContentLoader::uriToPath), + FILE(FileContentLoader::uriToPath, File.separatorChar), + HTTP(HttpContentLoader::uriToPath), + HTTPS(HttpContentLoader::uriToPath); private final char[] additionalSeparators; + private final Function getPathFunction; - private URIContentLoaderType(char... additionalSeparators) { + private final String scheme = name().toLowerCase() + ':'; + + private URIContentLoaderType(Function getPathFunction, char... additionalSeparators) { + this.getPathFunction = getPathFunction; this.additionalSeparators = additionalSeparators; } - public static URIContentLoaderType from(URI uri) { - String scheme = uri.getScheme(); - if (scheme == null) { - return FILE; - } - switch (uri.getScheme().toLowerCase()) { - case "file": - return FILE; - case "classpath": - return CLASSPATH; - case "http": - case "https": - return HTTP; - default: - throw new IllegalArgumentException("Unrecognized uri protocol " + uri); - } + public static Optional scheme(String uri) { + int indexOf = uri.indexOf(":"); + return indexOf == -1 ? Optional.empty() : Optional.of(uri.substring(0, indexOf).toLowerCase()); + } + + public static URIContentLoaderType from(String uri) { + return scheme(uri).map(scheme -> { + switch (scheme) { + case "file": + return FILE; + case "classpath": + return CLASSPATH; + case "http": + return HTTP; + case "https": + return HTTPS; + default: + throw new IllegalArgumentException("Unrecognized protocol " + scheme + "for uri " + uri); + } + }).orElse(FILE); + } + + public String addScheme(String path) { + String lowerCasePath = path.toLowerCase(); + return lowerCasePath.startsWith(scheme) ? path : scheme + path; } public boolean isAbsolutePath(String path) { @@ -80,6 +95,14 @@ public String lastPart(String path) { return indexOf != -1 ? path.substring(indexOf + 1) : path; } + public String scheme() { + return scheme; + } + + public String uriToPath(String uri) { + return getPathFunction.apply(uri); + } + private int lastIndexOf(String path) { int indexOf = path.lastIndexOf('/'); int i = 0; @@ -92,4 +115,5 @@ private int lastIndexOf(String path) { private char separator() { return additionalSeparators.length > 0 ? additionalSeparators[0] : '/'; } + } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/AbstractWorkflowOperationIdFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/AbstractWorkflowOperationIdFactory.java index 7fefb0f2a8d..5f4278c92d6 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/AbstractWorkflowOperationIdFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/AbstractWorkflowOperationIdFactory.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.io.UncheckedIOException; -import java.net.URI; import java.util.Optional; import org.kie.kogito.jackson.utils.ObjectMapperFactory; @@ -47,13 +46,13 @@ public abstract class AbstractWorkflowOperationIdFactory implements WorkflowOper public WorkflowOperationId from(Workflow workflow, FunctionDefinition function, Optional context) { ActionResource actionResource = ActionResourceFactory.getActionResource(function); Optional convertedUri = convertURI(workflow, context, actionResource.getUri()); - final URI uri; final String fileName; + final String uri; if (convertedUri.isPresent()) { - uri = URI.create(convertedUri.get()); + uri = convertedUri.get(); fileName = actionResource.getUri(); } else { - uri = URI.create(actionResource.getUri()); + uri = actionResource.getUri(); fileName = getFileName(workflow, function, context, uri, actionResource.getOperation(), actionResource.getService()); } if (fileName == null || fileName.isBlank()) { @@ -88,5 +87,5 @@ private JsonNode getUriDefinitions(Workflow workflow, Optional co return definitions; } - protected abstract String getFileName(Workflow workflow, FunctionDefinition function, Optional context, URI uri, String operation, String service); + protected abstract String getFileName(Workflow workflow, FunctionDefinition function, Optional context, String uri, String operation, String service); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdFactory.java index 0348f9df43e..3a3e3253b29 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdFactory.java @@ -18,7 +18,6 @@ */ package org.kie.kogito.serverless.workflow.operationid; -import java.net.URI; import java.util.Optional; import java.util.Set; @@ -33,7 +32,7 @@ public class FileNameWorkflowOperationIdFactory extends AbstractWorkflowOperatio public static final String FILE_PROP_VALUE = "FILE_NAME"; @Override - public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, URI uri, String operation, String service) { + public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, String uri, String operation, String service) { return URIContentLoaderFactory.getFileName(uri); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FunctionWorkflowOperationIdFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FunctionWorkflowOperationIdFactory.java index 90ce8f093c9..b81c3127350 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FunctionWorkflowOperationIdFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FunctionWorkflowOperationIdFactory.java @@ -18,7 +18,6 @@ */ package org.kie.kogito.serverless.workflow.operationid; -import java.net.URI; import java.util.Optional; import java.util.Set; @@ -31,7 +30,7 @@ public class FunctionWorkflowOperationIdFactory extends AbstractWorkflowOperatio public static final String FUNCTION_PROP_VALUE = "FUNCTION_NAME"; @Override - public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, URI uri, String operation, String service) { + public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, String uri, String operation, String service) { return workflow.getId() + '_' + function.getName(); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/URIWorkflowOperationIdFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/URIWorkflowOperationIdFactory.java index d15a557b63b..ab7e9ced876 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/URIWorkflowOperationIdFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/URIWorkflowOperationIdFactory.java @@ -18,11 +18,10 @@ */ package org.kie.kogito.serverless.workflow.operationid; -import java.net.URI; -import java.nio.file.Path; import java.util.Optional; import java.util.Set; +import org.kie.kogito.serverless.workflow.io.URIContentLoaderType; import org.kie.kogito.serverless.workflow.parser.ParserContext; import io.serverlessworkflow.api.Workflow; @@ -33,8 +32,8 @@ public class URIWorkflowOperationIdFactory extends AbstractWorkflowOperationIdFa public static final String URI_PROP_VALUE = "FULL_URI"; @Override - public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, URI uri, String operation, String service) { - return Path.of(uri.getPath()).toString(); + public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, String uri, String operation, String service) { + return URIContentLoaderType.from(uri).uriToPath(uri).toString(); } @Override diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/WorkflowOperationId.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/WorkflowOperationId.java index c32be6e22c6..258f60a2bb8 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/WorkflowOperationId.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/WorkflowOperationId.java @@ -18,16 +18,14 @@ */ package org.kie.kogito.serverless.workflow.operationid; -import java.net.URI; - public class WorkflowOperationId { - private final URI uri; + private final String uri; private final String operation; private final String fileName; private final String packageName; private final String service; - WorkflowOperationId(URI uri, String operation, String service, String fileName, String packageName) { + WorkflowOperationId(String uri, String operation, String service, String fileName, String packageName) { this.uri = uri; this.operation = operation; this.service = service; @@ -35,7 +33,7 @@ public class WorkflowOperationId { this.packageName = packageName; } - public URI getUri() { + public String getUri() { return uri; } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/JsonSchemaReader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/JsonSchemaReader.java index 5fe1027a851..81e47771caf 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/JsonSchemaReader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/JsonSchemaReader.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.io.UncheckedIOException; -import java.net.URI; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -62,12 +61,12 @@ private static String getId(JsonNode schemaContent, Counter counter) { } } - static JsonNode read(URI baseURI, byte[] content) { + static JsonNode read(String baseURI, byte[] content) { try { ObjectNode node = ObjectMapperFactory.get().readValue(content, ObjectNode.class); JsonNode id = node.get("$id"); if (id != null) { - baseURI = URI.create(id.asText()); + baseURI = id.asText(); } Objects.requireNonNull(baseURI, "BaseURI must not be null"); Map schemas = new HashMap<>(); @@ -88,7 +87,7 @@ private static JsonNode fillDefs(Map schemas) { return node; } - private static void replaceRefsWithDefs(JsonNode node, URI baseURI, Map schemas, Counter counter) { + private static void replaceRefsWithDefs(JsonNode node, String baseURI, Map schemas, Counter counter) { if (node.isArray()) { node.elements().forEachRemaining(n -> replaceRefsWithDefs(n, baseURI, schemas, counter)); } else if (node.isObject()) { @@ -103,7 +102,7 @@ private static void replaceRefsWithDefs(JsonNode node, URI baseURI, Map parseProcess() { private Optional modelValidator(ParserContext parserContext, Optional schema) { return schema.map(s -> new JsonSchemaValidatorSupplier(JsonSchemaReader.read( - getBaseURI(workflow).map(u -> compoundURI(u, URI.create(s.getSchema()))).orElseGet(() -> URI.create(s.getSchema())), + getBaseURI(workflow).map(u -> compoundURI(u, s.getSchema())).orElseGet(() -> s.getSchema()), readBytes(s.getSchema(), workflow, parserContext)), s.isFailOnValidationErrors())); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/utils/ServerlessWorkflowUtils.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/utils/ServerlessWorkflowUtils.java index 9a85a798e86..e21330ef2e1 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/utils/ServerlessWorkflowUtils.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/utils/ServerlessWorkflowUtils.java @@ -22,7 +22,6 @@ import java.io.InputStreamReader; import java.io.Reader; import java.io.Writer; -import java.net.URI; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; @@ -141,8 +140,8 @@ public static void writeWorkflow(Workflow workflow, Writer writer, WorkflowForma objectMapper.writeValue(writer, workflow); } - public static Optional getBaseURI(Workflow workflow) { - return Optional.ofNullable(getMetadata(workflow).get(BASE_URI)).map(URI::create); + public static Optional getBaseURI(Workflow workflow) { + return Optional.ofNullable(getMetadata(workflow).get(BASE_URI)); } public static Workflow withBaseURI(Workflow workflow, String baseURI) { diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoaderTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoaderTest.java index 4c317433b50..5f732566b16 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoaderTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoaderTest.java @@ -18,7 +18,6 @@ */ package org.kie.kogito.serverless.workflow.io; -import java.net.URI; import java.util.Optional; import org.junit.jupiter.api.Test; @@ -45,7 +44,7 @@ void testPrefixSlashPath() { } void testPath(String prefix) { - ClassPathContentLoader contentLoader = new ClassPathContentLoader(URI.create(prefix + PATH), Optional.empty()); + ClassPathContentLoader contentLoader = new ClassPathContentLoader(prefix + PATH, Optional.empty()); assertThat(contentLoader.classpath()).isEqualTo(PATH); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactoryTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactoryTest.java index 76d419bed84..a995d3d4cb4 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactoryTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/ResourceCacheFactoryTest.java @@ -18,11 +18,10 @@ */ package org.kie.kogito.serverless.workflow.io; -import java.net.URI; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Function; +import java.util.function.Supplier; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -31,13 +30,13 @@ public class ResourceCacheFactoryTest { - private URI uri; + private String uri; private AtomicInteger counter; @BeforeEach void setup() { - uri = URI.create("http:://www.google.com"); + uri = "http:://www.google.com"; counter = new AtomicInteger(); } @@ -62,11 +61,11 @@ void testCustomResourceCache() { } private static class TestResourceCache implements ResourceCache { - private Map map = new ConcurrentHashMap<>(); + private Map map = new ConcurrentHashMap<>(); @Override - public byte[] get(URI uri, Function retrieveCall) { - return map.computeIfAbsent(uri, retrieveCall); + public byte[] get(String uri, Supplier retrieveCall) { + return map.computeIfAbsent(uri, u -> retrieveCall.get()); } } @@ -77,7 +76,7 @@ private void callIt(int numOfTimes) { } } - private byte[] called(URI uri) { + private byte[] called() { return new byte[] { (byte) counter.incrementAndGet() }; } } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java index 807758ea256..33ff48c3351 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java @@ -19,7 +19,6 @@ package org.kie.kogito.serverless.workflow.io; import java.io.UncheckedIOException; -import java.net.URI; import java.net.URISyntaxException; import org.junit.jupiter.api.Test; @@ -57,13 +56,13 @@ void testNotExistingClasspath() { @Test void testCompoundURI() { - assertThat(compoundURI(URI.create("classpath:pepe.json"), URI.create("pepa.json"))).isEqualTo(URI.create("classpath:/pepa.json")); - assertThat(compoundURI(URI.create("classpath:pepe.json"), URI.create("file:///pepa.json"))).isEqualTo(URI.create("file:///pepa.json")); - assertThat(compoundURI(URI.create("classpath:schema/pepe.json"), URI.create("/pepa.json"))).isEqualTo(URI.create("classpath:/pepa.json")); - assertThat(compoundURI(URI.create("classpath:schema/pepe.json"), URI.create("pepa.json"))).isEqualTo(URI.create("classpath:/schema/pepa.json")); - assertThat(compoundURI(URI.create("pepe.json"), URI.create("pepa.json"))).isEqualTo(URI.create("file:///pepa.json")); - assertThat(compoundURI(URI.create("schema/pepe.json"), URI.create("pepa.json"))).isEqualTo(URI.create("file:///schema/pepa.json")); - assertThat(compoundURI(URI.create("schema/pepe.json"), URI.create("/pepa.json"))).isEqualTo(URI.create("file:///pepa.json")); - assertThat(compoundURI(URI.create("pepe.json"), URI.create("classpath:pepa.json"))).isEqualTo(URI.create("classpath:pepa.json")); + assertThat(compoundURI("classpath:pepe.json", "pepa.json")).isEqualTo("classpath:/pepa.json"); + assertThat(compoundURI("classpath:pepe.json", "file:///pepa.json")).isEqualTo("file:///pepa.json"); + assertThat(compoundURI("classpath:schema/pepe.json", "/pepa.json")).isEqualTo("classpath:/pepa.json"); + assertThat(compoundURI("classpath:schema/pepe.json", "pepa.json")).isEqualTo("classpath:/schema/pepa.json"); + assertThat(compoundURI("pepe.json", "pepa.json")).isEqualTo("file:/pepa.json"); + assertThat(compoundURI("schema/pepe.json", "pepa.json")).isEqualTo("file:/schema/pepa.json"); + assertThat(compoundURI("schema/pepe.json", "/pepa.json")).isEqualTo("file:/pepa.json"); + assertThat(compoundURI("pepe.json", "classpath:pepa.json")).isEqualTo("classpath:pepa.json"); } } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdTest.java index e9606a5093f..336cb8ae143 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdTest.java @@ -28,7 +28,6 @@ import io.serverlessworkflow.api.functions.FunctionDefinition.Type; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; class FileNameWorkflowOperationIdTest { @@ -67,12 +66,4 @@ void testOperationIdWithService() { assertThat(id.getUri()).hasToString("http://myserver.com/spec/PePE1.yaml"); assertThat(id.getService()).isEqualTo("service"); } - - @Test - void testEmptyFileName() { - definition.setType(Type.REST); - definition.setOperation("file://wrongUri.yaml#doSomething"); - assertThatThrownBy(() -> factory.from(workflow, definition, Optional.empty())).isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Empty file name"); - } } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/operationid/SpecWorkflowOperationIdFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/operationid/SpecWorkflowOperationIdFactory.java index 0561f95b7d7..bbe9466ab97 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/operationid/SpecWorkflowOperationIdFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/operationid/SpecWorkflowOperationIdFactory.java @@ -18,7 +18,6 @@ */ package org.kie.kogito.serverless.workflow.operationid; -import java.net.URI; import java.util.Optional; import java.util.Set; @@ -32,7 +31,7 @@ public class SpecWorkflowOperationIdFactory extends AbstractWorkflowOperationIdF public static final String SPEC_PROP_VALUE = "SPEC_TITLE"; @Override - public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, URI uri, String operation, String service) { + public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, String uri, String operation, String service) { return OpenAPIFactory.getOpenAPI(uri, workflow, function, context).getInfo() .getTitle(); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/utils/OpenAPIFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/utils/OpenAPIFactory.java index 5d49f07e71f..6f6835d5f4a 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/utils/OpenAPIFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-openapi-common/src/main/java/org/kie/kogito/serverless/workflow/utils/OpenAPIFactory.java @@ -18,7 +18,6 @@ */ package org.kie.kogito.serverless.workflow.utils; -import java.net.URI; import java.util.Optional; import org.kie.kogito.serverless.workflow.parser.ParserContext; @@ -41,7 +40,7 @@ public class OpenAPIFactory { private OpenAPIFactory() { } - public static OpenAPI getOpenAPI(URI uri, Workflow workflow, FunctionDefinition function, Optional context) { + public static OpenAPI getOpenAPI(String uri, Workflow workflow, FunctionDefinition function, Optional context) { SwaggerParseResult result = new OpenAPIParser().readContents(readString(buildLoader(uri, workflow, context, function.getAuthRef())), null, null); OpenAPI openAPI = result.getOpenAPI(); diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-openapi-parser/src/main/java/org/kie/kogito/serverless/workflow/parser/rest/DescriptorRestOperationHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-openapi-parser/src/main/java/org/kie/kogito/serverless/workflow/parser/rest/DescriptorRestOperationHandler.java index dd46b0b4279..82a63c7cb20 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-openapi-parser/src/main/java/org/kie/kogito/serverless/workflow/parser/rest/DescriptorRestOperationHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-openapi-parser/src/main/java/org/kie/kogito/serverless/workflow/parser/rest/DescriptorRestOperationHandler.java @@ -18,7 +18,6 @@ */ package org.kie.kogito.serverless.workflow.parser.rest; -import java.net.URI; import java.util.ArrayList; import java.util.Collection; import java.util.Optional; @@ -86,7 +85,7 @@ public class DescriptorRestOperationHandler extends OpenAPITypeHandler { private > WorkItemNodeFactory addOpenApiParameters(WorkItemNodeFactory node, Workflow workflow, FunctionDefinition function, ParserContext parserContext, WorkflowOperationId operationId) { - URI uri = operationId.getUri(); + String uri = operationId.getUri(); String serviceName = replaceNonAlphanumeric(operationId.getFileName()); // although OpenAPIParser has built in support to load uri, it messes up when using contextclassloader, so using our retrieval apis to get the content OpenAPI openAPI = OpenAPIFactory.getOpenAPI(uri, workflow, function, Optional.of(parserContext)); From 41d5ee2f827ef664278081cd93fac3e57be97f4b Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 3 Jul 2024 18:25:34 +0200 Subject: [PATCH 03/10] [Fix #3569] Refining for windows --- .../pom.xml | 7 ----- .../workflow/io/FileContentLoader.java | 19 +++++++++++- .../workflow/io/URIContentLoaderFactory.java | 10 ++----- .../workflow/io/URIContentLoaderType.java | 29 +++++++------------ .../workflow/io/URIContentLoaderTest.java | 17 ++++++----- .../resources/{pepe.txt => pepe a pepa.txt} | 0 .../rpc/WorkflowRPCCodeGenProvider.java | 3 +- .../workflow/io/QuarkusResourceCache.java | 7 ++--- 8 files changed, 46 insertions(+), 46 deletions(-) rename kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/resources/{pepe.txt => pepe a pepa.txt} (100%) diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/pom.xml b/kogito-serverless-workflow/kogito-serverless-workflow-builder/pom.xml index 49a5e44d15d..0d7ae54d492 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/pom.xml +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/pom.xml @@ -106,13 +106,6 @@ org.kie.kogito kogito-jq-expression - - org.apache.kie.sonataflow - - sonataflow-addons-quarkus-camel-deployment - - 999-SNAPSHOT - \ No newline at end of file diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java index ef86e1d2aeb..aabd9b1258b 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/FileContentLoader.java @@ -20,17 +20,23 @@ import java.io.IOException; import java.io.UncheckedIOException; +import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class FileContentLoader extends CachedContentLoader { private final Path path; + private static final Logger logger = LoggerFactory.getLogger(FileContentLoader.class); + FileContentLoader(String uri, URIContentLoader... fallbackContentLoaders) { super(uri, fallbackContentLoaders); - this.path = Path.of(uriToPath(uri)); + this.path = obtainPath(uri); } @Override @@ -38,6 +44,17 @@ public URIContentLoaderType type() { return URIContentLoaderType.FILE; } + private static Path obtainPath(String uri) { + if (uri.startsWith(URIContentLoaderType.FILE.scheme())) { + try { + return Path.of(URI.create(uri)); + } catch (Exception ex) { + logger.info("URI {} is not valid one according to Java, trying alternative approach", uri, ex); + } + } + return Path.of(uriToPath(uri)); + } + @Override protected Optional internalGetPath() { return Files.exists(path) ? Optional.of(path) : Optional.empty(); diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java index 0a284b595f3..9e44087b36f 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java @@ -74,11 +74,11 @@ public static byte[] readBytes(String uriStr, Workflow workflow, Optional scheme(String uri) { public static URIContentLoaderType from(String uri) { return scheme(uri).map(scheme -> { switch (scheme) { + default: case "file": return FILE; case "classpath": @@ -54,17 +55,10 @@ public static URIContentLoaderType from(String uri) { return HTTP; case "https": return HTTPS; - default: - throw new IllegalArgumentException("Unrecognized protocol " + scheme + "for uri " + uri); } }).orElse(FILE); } - public String addScheme(String path) { - String lowerCasePath = path.toLowerCase(); - return lowerCasePath.startsWith(scheme) ? path : scheme + path; - } - public boolean isAbsolutePath(String path) { if (!path.isBlank()) { char firstChar = path.trim().charAt(0); @@ -78,16 +72,19 @@ public boolean isAbsolutePath(String path) { } public String concat(String basePath, String additionalPath) { - char separator = separator(); - if (!basePath.isBlank() && !isAbsolutePath(basePath)) { - basePath = separator + basePath; + if (isAbsolutePath(additionalPath)) { + return keepSchemaIfPresent(basePath, additionalPath); + } + int indexOf = lastIndexOf(basePath); + if (indexOf != -1) { + return keepSchemaIfPresent(basePath, basePath.substring(0, indexOf + 1) + additionalPath); + } else { + return keepSchemaIfPresent(basePath, additionalPath); } - return basePath + separator + additionalPath; } - public String trimLast(String path) { - int indexOf = lastIndexOf(path); - return indexOf != -1 ? path.substring(0, indexOf) : ""; + private String keepSchemaIfPresent(String basePath, String resultPath) { + return basePath.startsWith(scheme) && !resultPath.startsWith(scheme) ? scheme + resultPath : resultPath; } public String lastPart(String path) { @@ -112,8 +109,4 @@ private int lastIndexOf(String path) { return indexOf; } - private char separator() { - return additionalSeparators.length > 0 ? additionalSeparators[0] : '/'; - } - } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java index 33ff48c3351..551b9c22fbc 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderTest.java @@ -34,12 +34,12 @@ class URIContentLoaderTest { @Test void testExistingFile() throws URISyntaxException { - assertThat(readString(builder(Thread.currentThread().getContextClassLoader().getResource("pepe.txt").toURI()))).isEqualTo("my name is javierito"); + assertThat(readString(builder(Thread.currentThread().getContextClassLoader().getResource("pepe a pepa.txt").toURI()))).isEqualTo("my name is javierito"); } @Test void testExistingClasspath() { - assertThat(readString(builder("classpath:pepe.txt"))).isEqualTo("my name is javierito"); + assertThat(readString(builder("classpath:pepe a pepa.txt"))).isEqualTo("my name is javierito"); } @Test @@ -56,13 +56,14 @@ void testNotExistingClasspath() { @Test void testCompoundURI() { - assertThat(compoundURI("classpath:pepe.json", "pepa.json")).isEqualTo("classpath:/pepa.json"); - assertThat(compoundURI("classpath:pepe.json", "file:///pepa.json")).isEqualTo("file:///pepa.json"); + assertThat(compoundURI("classpath:pepe.json", "pepa.json")).isEqualTo("classpath:pepa.json"); + assertThat(compoundURI("classpath:pepe.json", "file:/pepa.json")).isEqualTo("file:/pepa.json"); assertThat(compoundURI("classpath:schema/pepe.json", "/pepa.json")).isEqualTo("classpath:/pepa.json"); - assertThat(compoundURI("classpath:schema/pepe.json", "pepa.json")).isEqualTo("classpath:/schema/pepa.json"); - assertThat(compoundURI("pepe.json", "pepa.json")).isEqualTo("file:/pepa.json"); - assertThat(compoundURI("schema/pepe.json", "pepa.json")).isEqualTo("file:/schema/pepa.json"); - assertThat(compoundURI("schema/pepe.json", "/pepa.json")).isEqualTo("file:/pepa.json"); + assertThat(compoundURI("classpath:schema/pepe.json", "pepa.json")).isEqualTo("classpath:schema/pepa.json"); + assertThat(compoundURI("pepe.json", "pepa.json")).isEqualTo("pepa.json"); + assertThat(compoundURI("schema/pepe.json", "pepa.json")).isEqualTo("schema/pepa.json"); + assertThat(compoundURI("schema/pepe.json", "/pepa.json")).isEqualTo("/pepa.json"); assertThat(compoundURI("pepe.json", "classpath:pepa.json")).isEqualTo("classpath:pepa.json"); } + } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/resources/pepe.txt b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/resources/pepe a pepa.txt similarity index 100% rename from kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/resources/pepe.txt rename to kogito-serverless-workflow/kogito-serverless-workflow-builder/src/test/resources/pepe a pepa.txt diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/rpc/WorkflowRPCCodeGenProvider.java b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/rpc/WorkflowRPCCodeGenProvider.java index 8c35dcc7bf7..59afcdc0f1d 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/rpc/WorkflowRPCCodeGenProvider.java +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/rpc/WorkflowRPCCodeGenProvider.java @@ -72,7 +72,8 @@ public boolean trigger(CodeGenContext context) throws CodeGenException { } ProtocUtils.generateDescriptor(protoFiles, context); return true; - } catch (IOException io) { + } catch (Exception io) { + logger.error("Exception generating RPC code", io); throw new CodeGenException(io); } } diff --git a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/serverless/workflow/io/QuarkusResourceCache.java b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/serverless/workflow/io/QuarkusResourceCache.java index 310dedb1d6b..17beb1d815b 100644 --- a/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/serverless/workflow/io/QuarkusResourceCache.java +++ b/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-deployment/src/main/java/org/kie/kogito/serverless/workflow/io/QuarkusResourceCache.java @@ -18,8 +18,7 @@ */ package org.kie.kogito.serverless.workflow.io; -import java.net.URI; -import java.util.function.Function; +import java.util.function.Supplier; import io.quarkus.cache.Cache; import io.quarkus.cache.CacheName; @@ -40,7 +39,7 @@ void init() { ResourceCacheFactory.setResourceCache(this::get); } - private byte[] get(URI uri, Function retrieveCall) { - return cache.get(uri, retrieveCall).await().indefinitely(); + private byte[] get(String uri, Supplier retrieveCall) { + return cache.get(uri, u -> retrieveCall.get()).await().indefinitely(); } } From dcead23a482ee33e8780794313132e7be9eef43c Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Thu, 11 Jul 2024 16:44:31 +0200 Subject: [PATCH 04/10] [Fix_#3569] Refining uriToPath usage --- .../kogito/serverless/workflow/io/CachedContentLoader.java | 7 ------- .../serverless/workflow/io/ClassPathContentLoader.java | 7 +++++++ .../serverless/workflow/io/URIContentLoaderFactory.java | 6 ------ .../operationid/FileNameWorkflowOperationIdFactory.java | 5 +++-- .../operationid/URIWorkflowOperationIdFactory.java | 2 +- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/CachedContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/CachedContentLoader.java index 8379890f51a..d8ff0935d24 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/CachedContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/CachedContentLoader.java @@ -98,12 +98,5 @@ protected static String trimScheme(String uri, String scheme) { return str; } - protected static String removeSlash(String str) { - while (str.startsWith("/")) { - str = str.substring(1); - } - return str; - } - protected abstract byte[] loadURI(); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java index b08b8cd827b..dc940f398ad 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/ClassPathContentLoader.java @@ -75,6 +75,13 @@ static String uriToPath(String uri) { return removeSlash(trimScheme(uri, URIContentLoaderType.CLASSPATH.scheme())); } + private static String removeSlash(String str) { + while (str.startsWith("/")) { + str = str.substring(1); + } + return str; + } + @Override public URIContentLoaderType type() { return URIContentLoaderType.CLASSPATH; diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java index 9e44087b36f..5c3f82c725f 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/io/URIContentLoaderFactory.java @@ -48,12 +48,6 @@ public static String readString(URIContentLoader loader) { return new String(readAllBytes(loader)); } - public static String getFileName(String uri) { - URIContentLoaderType type = URIContentLoaderType.from(uri); - String path = type.uriToPath(uri); - return type.lastPart(path); - } - public static String readString(Builder builder) { return readString(builder.build()); } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdFactory.java index 3a3e3253b29..3cbb9bd79de 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/FileNameWorkflowOperationIdFactory.java @@ -21,7 +21,7 @@ import java.util.Optional; import java.util.Set; -import org.kie.kogito.serverless.workflow.io.URIContentLoaderFactory; +import org.kie.kogito.serverless.workflow.io.URIContentLoaderType; import org.kie.kogito.serverless.workflow.parser.ParserContext; import io.serverlessworkflow.api.Workflow; @@ -33,7 +33,8 @@ public class FileNameWorkflowOperationIdFactory extends AbstractWorkflowOperatio @Override public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, String uri, String operation, String service) { - return URIContentLoaderFactory.getFileName(uri); + URIContentLoaderType type = URIContentLoaderType.from(uri); + return type.lastPart(type.uriToPath(uri)); } @Override diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/URIWorkflowOperationIdFactory.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/URIWorkflowOperationIdFactory.java index ab7e9ced876..e75cdd1a9ef 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/URIWorkflowOperationIdFactory.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/operationid/URIWorkflowOperationIdFactory.java @@ -33,7 +33,7 @@ public class URIWorkflowOperationIdFactory extends AbstractWorkflowOperationIdFa @Override public String getFileName(Workflow workflow, FunctionDefinition function, Optional context, String uri, String operation, String service) { - return URIContentLoaderType.from(uri).uriToPath(uri).toString(); + return URIContentLoaderType.from(uri).uriToPath(uri); } @Override From 24eb3c02db5c3dca8f7c333f12dd8186ff0b7533 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Fri, 12 Jul 2024 18:24:13 +0200 Subject: [PATCH 05/10] [Fix #3569] Temporary commit to debug CI issue --- .github/workflows/pr-kogito-runtimes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-kogito-runtimes.yml b/.github/workflows/pr-kogito-runtimes.yml index 0114e835947..b2d3515ee78 100644 --- a/.github/workflows/pr-kogito-runtimes.yml +++ b/.github/workflows/pr-kogito-runtimes.yml @@ -63,7 +63,7 @@ jobs: with: annotations-prefix: ${{ runner.os }}-${{ matrix.java-version }}/${{ matrix.maven-version }} github-token: "${{ secrets.GITHUB_TOKEN }}" - definition-file: https://raw.githubusercontent.com/${GROUP:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/pull-request-config.yaml + definition-file: https://raw.githubusercontent.com/fjtirado/incubator-kie-kogito-pipelines/main/.ci/pull-request-config.yaml env: BUILD_MVN_OPTS_CURRENT: '-Dreproducible -Dvalidate-formatting' - name: Junit Report From b7ec88bdf24319f03f46b425f4501e25721fd155 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Mon, 15 Jul 2024 17:32:34 +0200 Subject: [PATCH 06/10] Revert "[Fix #3569] Temporary commit to debug CI issue" This reverts commit 24eb3c02db5c3dca8f7c333f12dd8186ff0b7533. --- .github/workflows/pr-kogito-runtimes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-kogito-runtimes.yml b/.github/workflows/pr-kogito-runtimes.yml index b2d3515ee78..0114e835947 100644 --- a/.github/workflows/pr-kogito-runtimes.yml +++ b/.github/workflows/pr-kogito-runtimes.yml @@ -63,7 +63,7 @@ jobs: with: annotations-prefix: ${{ runner.os }}-${{ matrix.java-version }}/${{ matrix.maven-version }} github-token: "${{ secrets.GITHUB_TOKEN }}" - definition-file: https://raw.githubusercontent.com/fjtirado/incubator-kie-kogito-pipelines/main/.ci/pull-request-config.yaml + definition-file: https://raw.githubusercontent.com/${GROUP:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/pull-request-config.yaml env: BUILD_MVN_OPTS_CURRENT: '-Dreproducible -Dvalidate-formatting' - name: Junit Report From c2565a943b39dcbc55dc91529905c2ffab049360 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Wed, 17 Jul 2024 16:38:29 +0200 Subject: [PATCH 07/10] [Fix #3569] Disable reproducible comparison for spring boot integration --- springboot/integration-tests/pom.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/springboot/integration-tests/pom.xml b/springboot/integration-tests/pom.xml index 8079ddab7b8..6502ca15f71 100644 --- a/springboot/integration-tests/pom.xml +++ b/springboot/integration-tests/pom.xml @@ -187,6 +187,20 @@ + + org.apache.maven.plugins + maven-artifact-plugin + + + compare + + compare + + + + + + From 118ff4b44cf88228f9b601579cc72b0b59fd065b Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Mon, 22 Jul 2024 13:19:22 +0200 Subject: [PATCH 08/10] [Fix #3569] Skip module --- pom.xml | 2 +- springboot/integration-tests/pom.xml | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 51c1a4f9b58..de291abce46 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ UTF-8 2024-01-16T00:00:00Z - 3.4.1 + 3.5.1 0.16.1 3.6.2 diff --git a/springboot/integration-tests/pom.xml b/springboot/integration-tests/pom.xml index 6502ca15f71..27b8e3fa185 100644 --- a/springboot/integration-tests/pom.xml +++ b/springboot/integration-tests/pom.xml @@ -190,16 +190,11 @@ org.apache.maven.plugins maven-artifact-plugin - - - compare - - compare - - - - - + + + kogito-serverless-workflow-openapi-common + + From 68f970276024b505f172694eb1a077d8b07c39e1 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Mon, 22 Jul 2024 16:08:45 +0200 Subject: [PATCH 09/10] Revert "[Fix #3569] Skip module" This reverts commit 118ff4b44cf88228f9b601579cc72b0b59fd065b. --- pom.xml | 2 +- springboot/integration-tests/pom.xml | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index de291abce46..51c1a4f9b58 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ UTF-8 2024-01-16T00:00:00Z - 3.5.1 + 3.4.1 0.16.1 3.6.2 diff --git a/springboot/integration-tests/pom.xml b/springboot/integration-tests/pom.xml index 27b8e3fa185..6502ca15f71 100644 --- a/springboot/integration-tests/pom.xml +++ b/springboot/integration-tests/pom.xml @@ -190,11 +190,16 @@ org.apache.maven.plugins maven-artifact-plugin - - - kogito-serverless-workflow-openapi-common - - + + + compare + + compare + + + + + From 9355464435af679d3b4e10edfac0e01f9b0044c2 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Fri, 26 Jul 2024 17:59:43 +0200 Subject: [PATCH 10/10] Revert "[Fix #3569] Disable reproducible comparison for spring boot integration" This reverts commit c2565a943b39dcbc55dc91529905c2ffab049360. --- springboot/integration-tests/pom.xml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/springboot/integration-tests/pom.xml b/springboot/integration-tests/pom.xml index 6502ca15f71..8079ddab7b8 100644 --- a/springboot/integration-tests/pom.xml +++ b/springboot/integration-tests/pom.xml @@ -187,20 +187,6 @@ - - org.apache.maven.plugins - maven-artifact-plugin - - - compare - - compare - - - - - -