From a4f711e4466d50c53c4eb3839e3c3b9674736bad Mon Sep 17 00:00:00 2001 From: eschleb Date: Mon, 23 Sep 2024 10:37:16 +0200 Subject: [PATCH] Update powernode to 2.1.1 --- .gitignore | 1 + custom-definitions-spring/pom.xml | 27 ++++++++++ ...CustomDefinitionBuildersConfiguration.java | 0 .../configuration/ImageSetConfiguration.java | 0 .../configuration/LinkSetConfiguration.java | 0 .../configuration/VideoSetConfiguration.java | 0 .../util/ExtendedLinkAnchorModifier.java | 1 - .../util/ExtendedLinkQueryParamModifier.java | 17 +++--- .../ExtendedLinkQueryParamModifierTest.java | 52 +++++++++++++++++++ pom.xml | 6 ++- 10 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 custom-definitions-spring/pom.xml rename {custom-definitions => custom-definitions-spring}/src/main/java/com/merkle/oss/magnolia/definition/custom/configuration/CustomDefinitionBuildersConfiguration.java (100%) rename {custom-definitions => custom-definitions-spring}/src/main/java/com/merkle/oss/magnolia/definition/custom/imageset/configuration/ImageSetConfiguration.java (100%) rename {custom-definitions => custom-definitions-spring}/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/configuration/LinkSetConfiguration.java (100%) rename {custom-definitions => custom-definitions-spring}/src/main/java/com/merkle/oss/magnolia/definition/custom/videoset/configuration/VideoSetConfiguration.java (100%) create mode 100644 custom-definitions/src/test/java/com/merkle/oss/magnolia/definition/custom/linkset/model/util/ExtendedLinkQueryParamModifierTest.java diff --git a/.gitignore b/.gitignore index 8bdc0a4..80d11b6 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ atlassian-ide-plugin.xml /magnolia-builders/target /custom-definitions/target +/custom-definitions-spring/target/ /key-generator/target diff --git a/custom-definitions-spring/pom.xml b/custom-definitions-spring/pom.xml new file mode 100644 index 0000000..9a222b1 --- /dev/null +++ b/custom-definitions-spring/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + com.namics.oss.magnolia + magnolia-definition-builders-parent + 1.2.2-SNAPSHOT + + + custom-definition-builders-spring + + + + + com.namics.oss.magnolia + custom-definition-builders + ${project.version} + + + org.springframework + spring-context + ${spring.version} + + + \ No newline at end of file diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/configuration/CustomDefinitionBuildersConfiguration.java b/custom-definitions-spring/src/main/java/com/merkle/oss/magnolia/definition/custom/configuration/CustomDefinitionBuildersConfiguration.java similarity index 100% rename from custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/configuration/CustomDefinitionBuildersConfiguration.java rename to custom-definitions-spring/src/main/java/com/merkle/oss/magnolia/definition/custom/configuration/CustomDefinitionBuildersConfiguration.java diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/imageset/configuration/ImageSetConfiguration.java b/custom-definitions-spring/src/main/java/com/merkle/oss/magnolia/definition/custom/imageset/configuration/ImageSetConfiguration.java similarity index 100% rename from custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/imageset/configuration/ImageSetConfiguration.java rename to custom-definitions-spring/src/main/java/com/merkle/oss/magnolia/definition/custom/imageset/configuration/ImageSetConfiguration.java diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/configuration/LinkSetConfiguration.java b/custom-definitions-spring/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/configuration/LinkSetConfiguration.java similarity index 100% rename from custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/configuration/LinkSetConfiguration.java rename to custom-definitions-spring/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/configuration/LinkSetConfiguration.java diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/videoset/configuration/VideoSetConfiguration.java b/custom-definitions-spring/src/main/java/com/merkle/oss/magnolia/definition/custom/videoset/configuration/VideoSetConfiguration.java similarity index 100% rename from custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/videoset/configuration/VideoSetConfiguration.java rename to custom-definitions-spring/src/main/java/com/merkle/oss/magnolia/definition/custom/videoset/configuration/VideoSetConfiguration.java diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/model/util/ExtendedLinkAnchorModifier.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/model/util/ExtendedLinkAnchorModifier.java index 4575978..fc570a5 100644 --- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/model/util/ExtendedLinkAnchorModifier.java +++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/model/util/ExtendedLinkAnchorModifier.java @@ -3,7 +3,6 @@ import com.google.common.base.Joiner; import com.merkle.oss.magnolia.definition.custom.linkset.model.Link; import com.merkle.oss.magnolia.definition.custom.linkset.model.LinkModel; -import org.springframework.stereotype.Component; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/model/util/ExtendedLinkQueryParamModifier.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/model/util/ExtendedLinkQueryParamModifier.java index 90ab832..3f3dd97 100644 --- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/model/util/ExtendedLinkQueryParamModifier.java +++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/linkset/model/util/ExtendedLinkQueryParamModifier.java @@ -1,10 +1,13 @@ package com.merkle.oss.magnolia.definition.custom.linkset.model.util; +import java.util.Collections; +import java.util.Map; + +import org.apache.http.client.utils.URIBuilder; + +import com.machinezoo.noexception.Exceptions; import com.merkle.oss.magnolia.definition.custom.linkset.model.Link; import com.merkle.oss.magnolia.definition.custom.linkset.model.LinkModel; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.Map; public class ExtendedLinkQueryParamModifier { @@ -28,11 +31,11 @@ private Link modify(final Link extendedLink, final Map queryPara } private String setQueryParams(final String href, final Map queryParams, final boolean replace) { - final UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(href); + final URIBuilder uriBuilder = Exceptions.wrap().get(() -> new URIBuilder(href)); if (replace) { - uriComponentsBuilder.replaceQuery(null); + uriBuilder.setParameters(Collections.emptyList()); } - queryParams.forEach(uriComponentsBuilder::queryParam); - return uriComponentsBuilder.toUriString(); + queryParams.forEach(uriBuilder::addParameter); + return Exceptions.wrap().get(uriBuilder::build).toString(); } } diff --git a/custom-definitions/src/test/java/com/merkle/oss/magnolia/definition/custom/linkset/model/util/ExtendedLinkQueryParamModifierTest.java b/custom-definitions/src/test/java/com/merkle/oss/magnolia/definition/custom/linkset/model/util/ExtendedLinkQueryParamModifierTest.java new file mode 100644 index 0000000..30c7131 --- /dev/null +++ b/custom-definitions/src/test/java/com/merkle/oss/magnolia/definition/custom/linkset/model/util/ExtendedLinkQueryParamModifierTest.java @@ -0,0 +1,52 @@ +package com.merkle.oss.magnolia.definition.custom.linkset.model.util; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.Map; + +import org.junit.jupiter.api.Test; + +import com.merkle.oss.magnolia.definition.custom.linkset.LinkTypes; +import com.merkle.oss.magnolia.definition.custom.linkset.model.Link; +import com.merkle.oss.magnolia.definition.custom.linkset.model.LinkModel; + +class ExtendedLinkQueryParamModifierTest { + private static final Link LINK = new LinkModel( + "linkText", + "/de/test?param1=42", + "https://someDomain.com/de/test?param1=42", + false, + false, + LinkTypes.INTERNAL + ); + + @Test + void withAppend() { + assertEquals( + new LinkModel( + "linkText", + "/de/test?param1=42¶m2=43", + "https://someDomain.com/de/test?param1=42¶m2=43", + false, + false, + LinkTypes.INTERNAL + ), + new ExtendedLinkQueryParamModifier().withAppend(LINK, Map.of("param2", "43")) + ); + } + + @Test + void withReplace() { + assertEquals( + new LinkModel( + "linkText", + "/de/test?param2=43", + "https://someDomain.com/de/test?param2=43", + false, + false, + LinkTypes.INTERNAL + ), + new ExtendedLinkQueryParamModifier().withReplace(LINK, Map.of("param2", "43")) + ); + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index d761fe1..0ae426e 100644 --- a/pom.xml +++ b/pom.xml @@ -30,14 +30,16 @@ magnolia-builders custom-definitions - key-generator - + key-generator + custom-definitions-spring + 6.3.0 6.0.8 + 5.3.39 2.1.1 1.12.1 3.0.2