From 8cba93e9f5d8a7e25e3c6c58a4bef0c65632dcf7 Mon Sep 17 00:00:00 2001 From: Michele Santoro Date: Thu, 19 Oct 2023 11:21:04 +0200 Subject: [PATCH] Migrate all validation related imports to Jakarta --- pom.xml | 6 ++++++ .../ame/exceptions/model/ErrorResponse.java | 3 +-- .../strategy/LocalFolderResolverStrategy.java | 8 +++----- .../strategy/ModelResolverStrategy.java | 3 +-- .../utils/LocalFolderResolverUtils.java | 17 ++++++----------- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index 93e3cf79..035a0838 100644 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,7 @@ 22.3.0 2.0.5 6.0.0 + 3.0.2 0.9.19 1.3 2.6.0 @@ -234,6 +235,11 @@ ${jakarta-version} provided + + jakarta.validation + jakarta.validation-api + ${validation-api-version} + org.graalvm.buildtools native-maven-plugin diff --git a/src/main/java/org/eclipse/esmf/ame/exceptions/model/ErrorResponse.java b/src/main/java/org/eclipse/esmf/ame/exceptions/model/ErrorResponse.java index b17b4998..7f88553b 100644 --- a/src/main/java/org/eclipse/esmf/ame/exceptions/model/ErrorResponse.java +++ b/src/main/java/org/eclipse/esmf/ame/exceptions/model/ErrorResponse.java @@ -13,13 +13,12 @@ package org.eclipse.esmf.ame.exceptions.model; -import javax.validation.constraints.NotEmpty; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotEmpty; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/org/eclipse/esmf/ame/repository/strategy/LocalFolderResolverStrategy.java b/src/main/java/org/eclipse/esmf/ame/repository/strategy/LocalFolderResolverStrategy.java index 1b4a2fb1..5b6b48da 100644 --- a/src/main/java/org/eclipse/esmf/ame/repository/strategy/LocalFolderResolverStrategy.java +++ b/src/main/java/org/eclipse/esmf/ame/repository/strategy/LocalFolderResolverStrategy.java @@ -15,9 +15,7 @@ import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.nio.channels.FileChannel; -import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.FileSystem; import java.nio.file.Files; @@ -32,8 +30,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.Nonnull; - import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; @@ -55,6 +51,7 @@ import io.vavr.Tuple; import io.vavr.Tuple2; +import jakarta.annotation.Nonnull; @Service public class LocalFolderResolverStrategy implements ModelResolverStrategy { @@ -278,7 +275,8 @@ private List getListOfAspectModels( final List f final String[] arg = transformToValidModelDirectory( path ).split( ":" ); final String namespace = arg[0] + ":" + arg[1]; final String fileName = arg[2]; - String aspectModel = LocalFolderResolverUtils.readString( importFileSystem.getPath( path ), StandardCharsets.UTF_8 ); + String aspectModel = LocalFolderResolverUtils.readString( importFileSystem.getPath( path ), + StandardCharsets.UTF_8 ); return new AspectModelInformation( namespace, fileName, aspectModel ); } catch ( IOException e ) { throw new FileNotFoundException( "Cannot find in-memory file to create package information", e ); diff --git a/src/main/java/org/eclipse/esmf/ame/repository/strategy/ModelResolverStrategy.java b/src/main/java/org/eclipse/esmf/ame/repository/strategy/ModelResolverStrategy.java index d65c1b27..5123f602 100644 --- a/src/main/java/org/eclipse/esmf/ame/repository/strategy/ModelResolverStrategy.java +++ b/src/main/java/org/eclipse/esmf/ame/repository/strategy/ModelResolverStrategy.java @@ -18,12 +18,11 @@ import java.util.Map; import java.util.Optional; -import javax.annotation.Nonnull; - import org.eclipse.esmf.ame.model.repository.AspectModelInformation; import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn; import io.vavr.Tuple2; +import jakarta.annotation.Nonnull; public interface ModelResolverStrategy { diff --git a/src/main/java/org/eclipse/esmf/ame/repository/strategy/utils/LocalFolderResolverUtils.java b/src/main/java/org/eclipse/esmf/ame/repository/strategy/utils/LocalFolderResolverUtils.java index bfb0fb41..895e40f4 100644 --- a/src/main/java/org/eclipse/esmf/ame/repository/strategy/utils/LocalFolderResolverUtils.java +++ b/src/main/java/org/eclipse/esmf/ame/repository/strategy/utils/LocalFolderResolverUtils.java @@ -13,24 +13,18 @@ package org.eclipse.esmf.ame.repository.strategy.utils; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Objects; -import javax.annotation.Nonnull; - -import org.apache.commons.io.FileUtils; -import org.eclipse.esmf.ame.exceptions.FileNotFoundException; -import org.eclipse.esmf.ame.exceptions.InvalidAspectModelException; import org.eclipse.esmf.ame.model.resolver.FolderStructure; -import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import jakarta.annotation.Nonnull; + public class LocalFolderResolverUtils { private static final Logger LOG = LoggerFactory.getLogger( LocalFolderResolverUtils.class ); @@ -82,12 +76,13 @@ public static String buildFilePath( final String namespace, final String fileNam * @param path The path to the file to be read. * @param charset The character encoding to be used for decoding the file content. * @return The content of the file as a string decoded with the specified character encoding. + * * @throws IOException If an I/O error occurs while reading the file. */ - public static String readString( Path path, Charset charset) throws IOException { - try ( InputStream inputStream = Files.newInputStream(path)) { + public static String readString( Path path, Charset charset ) throws IOException { + try ( InputStream inputStream = Files.newInputStream( path ) ) { byte[] bytes = inputStream.readAllBytes(); - return new String(bytes, charset); + return new String( bytes, charset ); } } }