From 876812fa33c97aa8b3e1f8c88f97520964365465 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Wed, 20 Dec 2023 11:54:36 +0100 Subject: [PATCH] Remove deprecated functionality (2.x) (#7) --- changes.xml | 9 ++ pom.xml | 40 ++--- src/main/java/io/wcm/handler/link/Link.java | 9 -- .../link/LinkComponentPropertyResolver.java | 13 -- .../wcm/handler/link/LinkNameConstants.java | 21 --- .../handler/link/SyntheticLinkResource.java | 22 --- .../handler/link/impl/LinkBuilderImpl.java | 20 +-- .../handler/link/impl/LinkHandlerImpl.java | 2 +- .../io/wcm/handler/link/package-info.java | 2 +- .../handler/link/type/ExternalLinkType.java | 15 -- .../type/InternalCrossContextLinkType.java | 15 -- .../link/type/InternalCrossScopeLinkType.java | 144 ------------------ .../handler/link/type/InternalLinkType.java | 15 -- .../wcm/handler/link/type/MediaLinkType.java | 15 -- .../wcm/handler/link/type/package-info.java | 2 +- src/site/markdown/index.md | 1 + .../io/wcm/handler/link/LinkRequestTest.java | 2 +- .../java/io/wcm/handler/link/LinkTest.java | 15 +- .../link/SyntheticLinkResourceTest.java | 25 --- .../testcontext/DummyLinkHandlerConfig.java | 6 +- .../link/type/ExternalLinkTypeTest.java | 10 -- .../InternalCrossContextLinkTypeTest.java | 10 -- .../type/InternalCrossScopeLinkTypeTest.java | 135 ---------------- ...lCrossScopeLinkTypeWithoutRequestTest.java | 34 ----- .../link/type/InternalLinkTypeTest.java | 10 -- .../handler/link/type/MediaLinkTypeTest.java | 10 -- 26 files changed, 32 insertions(+), 570 deletions(-) delete mode 100644 src/main/java/io/wcm/handler/link/type/InternalCrossScopeLinkType.java delete mode 100644 src/test/java/io/wcm/handler/link/type/InternalCrossScopeLinkTypeTest.java delete mode 100644 src/test/java/io/wcm/handler/link/type/InternalCrossScopeLinkTypeWithoutRequestTest.java diff --git a/changes.xml b/changes.xml index 6e5492f..d870bba 100644 --- a/changes.xml +++ b/changes.xml @@ -23,6 +23,15 @@ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd"> + + + Remove deprecated functionality. + + + Switch to AEM 6.5.17 as minimum version. + + + LinkNameConstants: Mark properties PN_LINK_WINDOW_WIDTH, PN_LINK_WINDOW_HEIGHT, PN_LINK_WINDOW_FEATURES as deprecated - they are not used. diff --git a/pom.xml b/pom.xml index 1f87b78..5658b20 100644 --- a/pom.xml +++ b/pom.xml @@ -25,13 +25,13 @@ io.wcm io.wcm.parent_toplevel - 2.2.8 + 2.3.0-SNAPSHOT io.wcm io.wcm.handler.link - 1.10.5-SNAPSHOT + 2.0.0-SNAPSHOT jar Link Handler @@ -63,19 +63,19 @@ io.wcm io.wcm.handler.commons - 1.4.4 + 2.0.0-SNAPSHOT compile io.wcm io.wcm.handler.url - 1.10.0 + 2.0.0-SNAPSHOT compile io.wcm io.wcm.handler.media - 1.13.2 + 2.0.0-SNAPSHOT compile @@ -88,36 +88,21 @@ io.wcm io.wcm.wcm.commons - 1.9.0 + 1.10.0 compile io.wcm io.wcm.sling.commons - 1.4.0 + 1.6.4 compile io.wcm io.wcm.wcm.ui.granite - 1.8.0 - compile - - - - com.adobe.cq.wcm - com.adobe.aem.wcm.seo - 1.0.6 + 1.10.0 compile - true - - org.apache.sling - org.apache.sling.sitemap - 1.0.2 - compile - true - org.apache.sling @@ -152,7 +137,7 @@ io.wcm io.wcm.testing.aem-mock.junit5 - 5.4.2 + 5.4.4 test @@ -164,7 +149,7 @@ org.apache.sling org.apache.sling.testing.caconfig-mock-plugin - 1.4.0 + 1.5.4 test @@ -182,7 +167,7 @@ io.wcm io.wcm.testing.wcm-io-mock.caconfig - 1.1.0 + 1.2.0 test @@ -218,9 +203,6 @@ sling=http://sling.apache.org/jcr/sling/1.0 Import-Package: \ - \ - com.adobe.aem.wcm.seo.sitemap.externalizer;resolution:=optional,\ - org.apache.sling.sitemap.spi.common;resolution:=optional,\ \ javax.annotation;version="[0.0,2)",\ * diff --git a/src/main/java/io/wcm/handler/link/Link.java b/src/main/java/io/wcm/handler/link/Link.java index caedcee..ab6f5c4 100644 --- a/src/main/java/io/wcm/handler/link/Link.java +++ b/src/main/java/io/wcm/handler/link/Link.java @@ -139,15 +139,6 @@ public Map getAnchorAttributes() { return attributes; } - /** - * @param anchor Anchor element - * @deprecated Use {@link #setAnchorBuilder(Function)} to build anchor on-demand - */ - @Deprecated - public void setAnchor(Anchor anchor) { - this.anchor = anchor; - } - /** * @param anchorBuilder Function that builds an anchor representation on demand */ diff --git a/src/main/java/io/wcm/handler/link/LinkComponentPropertyResolver.java b/src/main/java/io/wcm/handler/link/LinkComponentPropertyResolver.java index 3e22612..e4dcc0e 100644 --- a/src/main/java/io/wcm/handler/link/LinkComponentPropertyResolver.java +++ b/src/main/java/io/wcm/handler/link/LinkComponentPropertyResolver.java @@ -54,19 +54,6 @@ public LinkComponentPropertyResolver(@NotNull Resource resource, .componentPropertiesResolution(ComponentPropertyResolution.RESOLVE_INHERIT); } - /** - * @param resource Resource containing link properties - * @deprecated Please use {@link #LinkComponentPropertyResolver(Resource, ComponentPropertyResolverFactory)} - */ - @Deprecated - @SuppressWarnings("resource") - public LinkComponentPropertyResolver(@NotNull Resource resource) { - // resolve media component properties 1. from policies and 2. from component definition - resolver = new ComponentPropertyResolver(resource, true) - .contentPolicyResolution(ComponentPropertyResolution.RESOLVE) - .componentPropertiesResolution(ComponentPropertyResolution.RESOLVE_INHERIT); - } - /** * @return Link target URL fallback property name */ diff --git a/src/main/java/io/wcm/handler/link/LinkNameConstants.java b/src/main/java/io/wcm/handler/link/LinkNameConstants.java index ba304ed..fe6d696 100644 --- a/src/main/java/io/wcm/handler/link/LinkNameConstants.java +++ b/src/main/java/io/wcm/handler/link/LinkNameConstants.java @@ -87,27 +87,6 @@ private LinkNameConstants() { */ public static final @NotNull String PN_LINK_WINDOW_TARGET = "linkWindowTarget"; - /** - * Window width (px) - * @deprecated This property is no longer supported. - */ - @Deprecated(forRemoval = true) - public static final @NotNull String PN_LINK_WINDOW_WIDTH = "linkWindowWidth"; - - /** - * Window height (px) - * @deprecated This property is no longer supported. - */ - @Deprecated(forRemoval = true) - public static final @NotNull String PN_LINK_WINDOW_HEIGHT = "linkWindowHeight"; - - /** - * Window features - * @deprecated This property is no longer supported. - */ - @Deprecated(forRemoval = true) - public static final @NotNull String PN_LINK_WINDOW_FEATURES = "linkWindowFeatures"; - /** * Open media library item with download dialog */ diff --git a/src/main/java/io/wcm/handler/link/SyntheticLinkResource.java b/src/main/java/io/wcm/handler/link/SyntheticLinkResource.java index 3a1ac0d..c60ddf5 100644 --- a/src/main/java/io/wcm/handler/link/SyntheticLinkResource.java +++ b/src/main/java/io/wcm/handler/link/SyntheticLinkResource.java @@ -37,7 +37,6 @@ public final class SyntheticLinkResource extends SyntheticResource { private static final String RESOURCE_TYPE = "wcm-io/handler/link/synthetic/resource"; - private static final String LEGACY_DEFAULT_PATH = "/apps/wcm-io/handler/link/synthetic/resource"; private final ValueMap properties; @@ -67,27 +66,6 @@ public SyntheticLinkResource(@NotNull ResourceResolver resourceResolver, this.properties = new ValueMapDecorator(properties); } - /** - * Instantiate resource with static path/resource type - * @param resourceResolver Resource resolver - * @deprecated Please use {@link #SyntheticLinkResource(ResourceResolver, String)} - */ - @Deprecated - public SyntheticLinkResource(@NotNull ResourceResolver resourceResolver) { - this(resourceResolver, LEGACY_DEFAULT_PATH); - } - - /** - * Instantiate resource with static path/resource type - * @param resourceResolver Resource resolver - * @param properties Properties for resource - * @deprecated Please use {@link #SyntheticLinkResource(ResourceResolver, String, Map)} - */ - @Deprecated - public SyntheticLinkResource(@NotNull ResourceResolver resourceResolver, @NotNull Map properties) { - this(resourceResolver, LEGACY_DEFAULT_PATH, properties); - } - @Override @SuppressWarnings({ "unchecked", "null" }) public Type adaptTo(Class type) { diff --git a/src/main/java/io/wcm/handler/link/impl/LinkBuilderImpl.java b/src/main/java/io/wcm/handler/link/impl/LinkBuilderImpl.java index 80a2d81..9a60240 100644 --- a/src/main/java/io/wcm/handler/link/impl/LinkBuilderImpl.java +++ b/src/main/java/io/wcm/handler/link/impl/LinkBuilderImpl.java @@ -55,7 +55,7 @@ final class LinkBuilderImpl implements LinkBuilder { private static final Logger log = LoggerFactory.getLogger(LinkBuilderImpl.class); LinkBuilderImpl(@Nullable Resource resource, @NotNull LinkHandlerImpl linkHandler, - @Nullable ComponentPropertyResolverFactory componentPropertyResolverFactory) { + @NotNull ComponentPropertyResolverFactory componentPropertyResolverFactory) { this.resource = resource; this.page = null; this.reference = null; @@ -64,7 +64,7 @@ final class LinkBuilderImpl implements LinkBuilder { } LinkBuilderImpl(@NotNull LinkRequest linkRequest, @NotNull LinkHandlerImpl linkHandler, - @Nullable ComponentPropertyResolverFactory componentPropertyResolverFactory) { + @NotNull ComponentPropertyResolverFactory componentPropertyResolverFactory) { this.resource = linkRequest.getResource(); this.page = linkRequest.getPage(); this.reference = linkRequest.getReference(); @@ -88,13 +88,13 @@ final class LinkBuilderImpl implements LinkBuilder { this.linkHandler = linkHandler; } - private void resolveWindowTargetAndFallbackProperties(@Nullable ComponentPropertyResolverFactory componentPropertyResolverFactory) { + private void resolveWindowTargetAndFallbackProperties(@NotNull ComponentPropertyResolverFactory componentPropertyResolverFactory) { if (resource == null) { return; } // resolve default settings from content policies and component properties - try (LinkComponentPropertyResolver resolver = getLinkComponentPropertyResolver(resource, componentPropertyResolverFactory)) { + try (LinkComponentPropertyResolver resolver = new LinkComponentPropertyResolver(resource, componentPropertyResolverFactory)) { linkArgs.linkTargetUrlFallbackProperty(resolver.getLinkTargetUrlFallbackProperty()); linkArgs.linkTargetWindowTargetFallbackProperty(resolver.getLinkTargetWindowTargetFallbackProperty()); } @@ -106,18 +106,6 @@ private void resolveWindowTargetAndFallbackProperties(@Nullable ComponentPropert linkArgs.windowTarget(getWindowTargetFromResource(resource, linkArgs)); } - @SuppressWarnings("deprecation") - private static LinkComponentPropertyResolver getLinkComponentPropertyResolver(@NotNull Resource resource, - @Nullable ComponentPropertyResolverFactory componentPropertyResolverFactory) { - if (componentPropertyResolverFactory != null) { - return new LinkComponentPropertyResolver(resource, componentPropertyResolverFactory); - } - else { - // fallback mode if ComponentPropertyResolverFactory is not available - return new LinkComponentPropertyResolver(resource); - } - } - private static String getWindowTargetFromResource(@NotNull Resource resource, @NotNull LinkArgs linkArgs) { ValueMap props = resource.getValueMap(); String windowTarget = null; diff --git a/src/main/java/io/wcm/handler/link/impl/LinkHandlerImpl.java b/src/main/java/io/wcm/handler/link/impl/LinkHandlerImpl.java index 5974c0a..1b136f4 100644 --- a/src/main/java/io/wcm/handler/link/impl/LinkHandlerImpl.java +++ b/src/main/java/io/wcm/handler/link/impl/LinkHandlerImpl.java @@ -62,7 +62,7 @@ public final class LinkHandlerImpl implements LinkHandler { private LinkHandlerConfig linkHandlerConfig; @AemObject(injectionStrategy = InjectionStrategy.OPTIONAL) private Page currentPage; - @OSGiService(injectionStrategy = InjectionStrategy.OPTIONAL) + @OSGiService private ComponentPropertyResolverFactory componentPropertyResolverFactory; @Override diff --git a/src/main/java/io/wcm/handler/link/package-info.java b/src/main/java/io/wcm/handler/link/package-info.java index 7e82163..47086d9 100644 --- a/src/main/java/io/wcm/handler/link/package-info.java +++ b/src/main/java/io/wcm/handler/link/package-info.java @@ -20,5 +20,5 @@ /** * Link Handler API. */ -@org.osgi.annotation.versioning.Version("1.7.0") +@org.osgi.annotation.versioning.Version("2.0.0") package io.wcm.handler.link; diff --git a/src/main/java/io/wcm/handler/link/type/ExternalLinkType.java b/src/main/java/io/wcm/handler/link/type/ExternalLinkType.java index a500b2a..f62f6e4 100644 --- a/src/main/java/io/wcm/handler/link/type/ExternalLinkType.java +++ b/src/main/java/io/wcm/handler/link/type/ExternalLinkType.java @@ -133,21 +133,6 @@ public boolean accepts(@NotNull String linkRef) { return new SyntheticLinkResource(resourceResolver, path, map); } - /** - * Get synthetic link resource for this link type. - * @param resourceResolver Resource resolver - * @param url Link URL - * @return Synthetic link resource - * @deprecated Please use {@link #getSyntheticLinkResource(ResourceResolver, String, String)} - */ - @Deprecated - public static @NotNull Resource getSyntheticLinkResource(@NotNull ResourceResolver resourceResolver, @NotNull String url) { - Map map = new HashMap<>(); - map.put(LinkNameConstants.PN_LINK_TYPE, ID); - map.put(LinkNameConstants.PN_LINK_EXTERNAL_REF, url); - return new SyntheticLinkResource(resourceResolver, map); - } - @Override public String toString() { return ID; diff --git a/src/main/java/io/wcm/handler/link/type/InternalCrossContextLinkType.java b/src/main/java/io/wcm/handler/link/type/InternalCrossContextLinkType.java index b546ef0..34b3d52 100644 --- a/src/main/java/io/wcm/handler/link/type/InternalCrossContextLinkType.java +++ b/src/main/java/io/wcm/handler/link/type/InternalCrossContextLinkType.java @@ -135,21 +135,6 @@ public boolean accepts(@NotNull LinkRequest linkRequest) { return new SyntheticLinkResource(resourceResolver, path, map); } - /** - * Get synthetic link resource for this link type. - * @param resourceResolver Resource resolver - * @param pageRef Path to target page - * @return Synthetic link resource - * @deprecated Please use {@link #getSyntheticLinkResource(ResourceResolver, String, String)} - */ - @Deprecated - public static @NotNull Resource getSyntheticLinkResource(@NotNull ResourceResolver resourceResolver, @NotNull String pageRef) { - Map map = new HashMap<>(); - map.put(LinkNameConstants.PN_LINK_TYPE, ID); - map.put(LinkNameConstants.PN_LINK_CROSSCONTEXT_CONTENT_REF, pageRef); - return new SyntheticLinkResource(resourceResolver, map); - } - @Override public String toString() { return ID; diff --git a/src/main/java/io/wcm/handler/link/type/InternalCrossScopeLinkType.java b/src/main/java/io/wcm/handler/link/type/InternalCrossScopeLinkType.java deleted file mode 100644 index 3543808..0000000 --- a/src/main/java/io/wcm/handler/link/type/InternalCrossScopeLinkType.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * #%L - * wcm.io - * %% - * Copyright (C) 2014 wcm.io - * %% - * Licensed 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. - * #L% - */ -package io.wcm.handler.link.type; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.apache.sling.api.SlingHttpServletRequest; -import org.apache.sling.api.resource.Resource; -import org.apache.sling.api.resource.ResourceResolver; -import org.apache.sling.models.annotations.Model; -import org.apache.sling.models.annotations.injectorspecific.Self; -import org.jetbrains.annotations.NotNull; -import org.osgi.annotation.versioning.ProviderType; - -import io.wcm.handler.link.Link; -import io.wcm.handler.link.LinkNameConstants; -import io.wcm.handler.link.LinkRequest; -import io.wcm.handler.link.SyntheticLinkResource; -import io.wcm.handler.link.spi.LinkType; -import io.wcm.handler.link.type.helpers.InternalLinkResolver; -import io.wcm.handler.link.type.helpers.InternalLinkResolverOptions; - -/** - * Implementation of {@link io.wcm.handler.link.spi.LinkType} for internal links with supports - * links between different configuration scopes (which normally relates to different sites/languages). - * Internal links are links to content pages inside the CMS. - *

- * This link type ensures that links that are referenced from other configuration scopes (sites/languages) are resolved - * using the URL handler configuration of the target scope, e.g. with the Site URL from the other site. - *

- * @deprecated Please use {@link InternalCrossContextLinkType} instead. - */ -@Deprecated -@Model(adaptables = { - SlingHttpServletRequest.class, Resource.class -}) -@ProviderType -public final class InternalCrossScopeLinkType extends LinkType { - - /** - * Link type ID - */ - public static final @NotNull String ID = "internalCrossScope"; - - private final @NotNull InternalLinkResolverOptions resolverOptions = new InternalLinkResolverOptions() - .primaryLinkRefProperty(getPrimaryLinkRefProperty()) - .rewritePathToContext(false) - .useTargetContext(true); - - @Self - private InternalLinkResolver internalLinkResolver; - - /** - * @return Link type ID (is stored as identifier in repository) - */ - @Override - public @NotNull String getId() { - return ID; - } - - @Override - public String getPrimaryLinkRefProperty() { - return LinkNameConstants.PN_LINK_CONTENT_REF; - } - - @Override - public boolean accepts(@NotNull String linkRef) { - // accept as internal link if the ref starts with "/content/" - return StringUtils.startsWith(linkRef, "/content/") - && !MediaLinkType.isDefaultMediaContentPath(linkRef); - } - - @Override - public boolean accepts(@NotNull LinkRequest linkRequest) { - if (internalLinkResolver.acceptPage(linkRequest.getPage(), resolverOptions)) { - // support direct links to pages - return true; - } - // check for matching link type ID in link resource - return super.accepts(linkRequest); - } - - @Override - public @NotNull Link resolveLink(@NotNull Link link) { - return internalLinkResolver.resolveLink(link, resolverOptions); - } - - /** - * Get synthetic link resource for this link type. - * @param resourceResolver Resource resolver - * @param path Resource path. Can be a non-existing path, but the path should be located somewhere within the - * applications content paths to make sure the handler configuration looked up via context-aware services - * is the expected one. - * @param pageRef Path to target page - * @return Synthetic link resource - */ - public static @NotNull Resource getSyntheticLinkResource(@NotNull ResourceResolver resourceResolver, - @NotNull String path, @NotNull String pageRef) { - Map map = new HashMap<>(); - map.put(LinkNameConstants.PN_LINK_TYPE, ID); - map.put(LinkNameConstants.PN_LINK_CONTENT_REF, pageRef); - return new SyntheticLinkResource(resourceResolver, path, map); - } - - /** - * Get synthetic link resource for this link type. - * @param resourceResolver Resource resolver - * @param pageRef Path to target page - * @return Synthetic link resource - * @deprecated Please use {@link #getSyntheticLinkResource(ResourceResolver, String, String)} - */ - @Deprecated - public static @NotNull Resource getSyntheticLinkResource(@NotNull ResourceResolver resourceResolver, @NotNull String pageRef) { - Map map = new HashMap<>(); - map.put(LinkNameConstants.PN_LINK_TYPE, ID); - map.put(LinkNameConstants.PN_LINK_CONTENT_REF, pageRef); - return new SyntheticLinkResource(resourceResolver, map); - } - - @Override - public String toString() { - return ID; - } - -} diff --git a/src/main/java/io/wcm/handler/link/type/InternalLinkType.java b/src/main/java/io/wcm/handler/link/type/InternalLinkType.java index e840535..9d83125 100644 --- a/src/main/java/io/wcm/handler/link/type/InternalLinkType.java +++ b/src/main/java/io/wcm/handler/link/type/InternalLinkType.java @@ -137,21 +137,6 @@ public boolean accepts(@NotNull LinkRequest linkRequest) { return new SyntheticLinkResource(resourceResolver, path, map); } - /** - * Get synthetic link resource for this link type. - * @param resourceResolver Resource resolver - * @param pageRef Path to target page - * @return Synthetic link resource - * @deprecated Please use {@link #getSyntheticLinkResource(ResourceResolver, String, String)} - */ - @Deprecated - public static @NotNull Resource getSyntheticLinkResource(@NotNull ResourceResolver resourceResolver, @NotNull String pageRef) { - Map map = new HashMap<>(); - map.put(LinkNameConstants.PN_LINK_TYPE, ID); - map.put(LinkNameConstants.PN_LINK_CONTENT_REF, pageRef); - return new SyntheticLinkResource(resourceResolver, map); - } - @Override public String toString() { return ID; diff --git a/src/main/java/io/wcm/handler/link/type/MediaLinkType.java b/src/main/java/io/wcm/handler/link/type/MediaLinkType.java index d283854..d75281e 100644 --- a/src/main/java/io/wcm/handler/link/type/MediaLinkType.java +++ b/src/main/java/io/wcm/handler/link/type/MediaLinkType.java @@ -157,21 +157,6 @@ public static boolean isDefaultMediaContentPath(String path) { return new SyntheticLinkResource(resourceResolver, path, map); } - /** - * Get synthetic link resource for this link type. - * @param resourceResolver Resource resolver - * @param mediaRef Media asset reference - * @return Synthetic link resource - * @deprecated Please use {@link #getSyntheticLinkResource(ResourceResolver, String, String)} - */ - @Deprecated - public static @NotNull Resource getSyntheticLinkResource(@NotNull ResourceResolver resourceResolver, @NotNull String mediaRef) { - Map map = new HashMap<>(); - map.put(LinkNameConstants.PN_LINK_TYPE, ID); - map.put(LinkNameConstants.PN_LINK_MEDIA_REF, mediaRef); - return new SyntheticLinkResource(resourceResolver, map); - } - @Override public String toString() { return ID; diff --git a/src/main/java/io/wcm/handler/link/type/package-info.java b/src/main/java/io/wcm/handler/link/type/package-info.java index 85cb0d2..830756d 100644 --- a/src/main/java/io/wcm/handler/link/type/package-info.java +++ b/src/main/java/io/wcm/handler/link/type/package-info.java @@ -20,5 +20,5 @@ /** * Default link type implementations. */ -@org.osgi.annotation.versioning.Version("1.4.1") +@org.osgi.annotation.versioning.Version("2.0.0") package io.wcm.handler.link.type; diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index b066d2c..0a4ee53 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -32,6 +32,7 @@ Read the [general concepts][general-concepts] to get an overview of the function |Link Handler version |AEM version supported |---------------------|---------------------- +|2.0.x or higher |AEM 6.5.17+, AEMaaCS |1.9.4 or higher |AEM 6.5.7+, AEMaaCS |1.9.0 - 1.9.2 |AEM 6.5+, AEMaaCS |1.6.x - 1.8.x |AEM 6.4.5+, AEMaaCS diff --git a/src/test/java/io/wcm/handler/link/LinkRequestTest.java b/src/test/java/io/wcm/handler/link/LinkRequestTest.java index 2bc5de6..685a674 100644 --- a/src/test/java/io/wcm/handler/link/LinkRequestTest.java +++ b/src/test/java/io/wcm/handler/link/LinkRequestTest.java @@ -30,7 +30,7 @@ class LinkRequestTest { @Test void testToString() { LinkRequest request = new LinkRequest(null, null, new LinkArgs().urlMode(UrlModes.DEFAULT)); - assertEquals("LinkRequest[linkArgs=LinkArgs[urlMode=DEFAULT,dummyLink=false,disableSuffixSelector=false]]", request.toString()); + assertEquals("LinkRequest[linkArgs=LinkArgs[disableSuffixSelector=false,dummyLink=false,urlMode=DEFAULT]]", request.toString()); } } diff --git a/src/test/java/io/wcm/handler/link/LinkTest.java b/src/test/java/io/wcm/handler/link/LinkTest.java index 21d2938..afa7d14 100644 --- a/src/test/java/io/wcm/handler/link/LinkTest.java +++ b/src/test/java/io/wcm/handler/link/LinkTest.java @@ -66,19 +66,6 @@ void testLinkReferenceInvalid() { assertTrue(underTest.isLinkReferenceInvalid()); } - @Test - @SuppressWarnings("deprecation") - void testAnchor() { - assertNull(underTest.getAnchorAttributes()); - assertNull(underTest.getMarkup()); - - Anchor anchor = new Anchor("http://dummy"); - underTest.setAnchor(anchor); - assertSame(anchor, underTest.getAnchor()); - assertEquals("http://dummy", underTest.getAnchorAttributes().get("href")); - assertEquals("", underTest.getMarkup()); - } - @Test void testAnchorBuilder() { assertNull(underTest.getAnchorAttributes()); @@ -123,7 +110,7 @@ void testTargetRendition() { @Test void testToString() { - assertEquals("Link[linkType=linkType,linkRequest=LinkRequest[linkArgs=LinkArgs[dummyLink=false,disableSuffixSelector=false]],linkReferenceInvalid=false]", + assertEquals("Link[linkReferenceInvalid=false,linkRequest=LinkRequest[linkArgs=LinkArgs[disableSuffixSelector=false,dummyLink=false]],linkType=linkType]", underTest.toString()); } diff --git a/src/test/java/io/wcm/handler/link/SyntheticLinkResourceTest.java b/src/test/java/io/wcm/handler/link/SyntheticLinkResourceTest.java index 962a2b6..fb74a1d 100644 --- a/src/test/java/io/wcm/handler/link/SyntheticLinkResourceTest.java +++ b/src/test/java/io/wcm/handler/link/SyntheticLinkResourceTest.java @@ -63,29 +63,4 @@ void testAdaptTo() { assertNull(page); } - @Test - @SuppressWarnings("deprecation") - void testSimpleConstructor_Deprecated() { - Resource underTest = new SyntheticLinkResource(resourceResolver); - ValueMap props = underTest.getValueMap(); - assertTrue(props.isEmpty()); - } - - @Test - @SuppressWarnings("deprecation") - void testWithMap_Deprecated() { - ValueMap givenProps = ImmutableValueMap.of("prop1", "value1"); - Resource underTest = new SyntheticLinkResource(resourceResolver, givenProps); - ValueMap props = underTest.getValueMap(); - assertEquals(givenProps, ImmutableValueMap.copyOf(props)); - } - - @Test - @SuppressWarnings("deprecation") - void testAdaptTo_Deprecated() { - Resource underTest = new SyntheticLinkResource(resourceResolver); - Page page = underTest.adaptTo(Page.class); - assertNull(page); - } - } diff --git a/src/test/java/io/wcm/handler/link/testcontext/DummyLinkHandlerConfig.java b/src/test/java/io/wcm/handler/link/testcontext/DummyLinkHandlerConfig.java index 449a9ef..671627a 100644 --- a/src/test/java/io/wcm/handler/link/testcontext/DummyLinkHandlerConfig.java +++ b/src/test/java/io/wcm/handler/link/testcontext/DummyLinkHandlerConfig.java @@ -30,23 +30,21 @@ import io.wcm.handler.link.spi.LinkType; import io.wcm.handler.link.type.ExternalLinkType; import io.wcm.handler.link.type.InternalCrossContextLinkType; -import io.wcm.handler.link.type.InternalCrossScopeLinkType; import io.wcm.handler.link.type.InternalLinkType; import io.wcm.handler.link.type.MediaLinkType; /** * Dummy link configuration */ -@SuppressWarnings({ "null", "deprecation" }) +@SuppressWarnings("null") public class DummyLinkHandlerConfig extends LinkHandlerConfig { private static final List> LINK_TYPES = List.of( InternalLinkType.class, InternalCrossContextLinkType.class, - InternalCrossScopeLinkType.class, ExternalLinkType.class, MediaLinkType.class - ); + ); @Override public List> getLinkTypes() { diff --git a/src/test/java/io/wcm/handler/link/type/ExternalLinkTypeTest.java b/src/test/java/io/wcm/handler/link/type/ExternalLinkTypeTest.java index c63017a..8ec3a13 100644 --- a/src/test/java/io/wcm/handler/link/type/ExternalLinkTypeTest.java +++ b/src/test/java/io/wcm/handler/link/type/ExternalLinkTypeTest.java @@ -100,16 +100,6 @@ void testGetSyntheticLinkResource() { assertEquals(expected, ImmutableValueMap.copyOf(resource.getValueMap())); } - @Test - @SuppressWarnings("deprecation") - void testGetSyntheticLinkResource_Deprecated() { - Resource resource = ExternalLinkType.getSyntheticLinkResource(context.resourceResolver(), - "http://dummy"); - ValueMap expected = ImmutableValueMap.of(LinkNameConstants.PN_LINK_TYPE, ExternalLinkType.ID, - LinkNameConstants.PN_LINK_EXTERNAL_REF, "http://dummy"); - assertEquals(expected, ImmutableValueMap.copyOf(resource.getValueMap())); - } - @Test void testAccepts() throws Exception { LinkType underTest = AdaptTo.notNull(adaptable(), ExternalLinkType.class); diff --git a/src/test/java/io/wcm/handler/link/type/InternalCrossContextLinkTypeTest.java b/src/test/java/io/wcm/handler/link/type/InternalCrossContextLinkTypeTest.java index a807450..7304b8d 100644 --- a/src/test/java/io/wcm/handler/link/type/InternalCrossContextLinkTypeTest.java +++ b/src/test/java/io/wcm/handler/link/type/InternalCrossContextLinkTypeTest.java @@ -122,14 +122,4 @@ void testGetSyntheticLinkResource() { assertEquals(expected, ImmutableValueMap.copyOf(resource.getValueMap())); } - @Test - @SuppressWarnings("deprecation") - void testGetSyntheticLinkResource_Deprecated() { - Resource resource = InternalCrossContextLinkType.getSyntheticLinkResource(context.resourceResolver(), - "/page/ref"); - ValueMap expected = ImmutableValueMap.of(LinkNameConstants.PN_LINK_TYPE, InternalCrossContextLinkType.ID, - LinkNameConstants.PN_LINK_CROSSCONTEXT_CONTENT_REF, "/page/ref"); - assertEquals(expected, ImmutableValueMap.copyOf(resource.getValueMap())); - } - } diff --git a/src/test/java/io/wcm/handler/link/type/InternalCrossScopeLinkTypeTest.java b/src/test/java/io/wcm/handler/link/type/InternalCrossScopeLinkTypeTest.java deleted file mode 100644 index 182ac77..0000000 --- a/src/test/java/io/wcm/handler/link/type/InternalCrossScopeLinkTypeTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * #%L - * wcm.io - * %% - * Copyright (C) 2014 wcm.io - * %% - * Licensed 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. - * #L% - */ -package io.wcm.handler.link.type; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import org.apache.sling.api.adapter.Adaptable; -import org.apache.sling.api.resource.Resource; -import org.apache.sling.api.resource.ValueMap; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import com.day.cq.wcm.api.Page; - -import io.wcm.handler.link.Link; -import io.wcm.handler.link.LinkHandler; -import io.wcm.handler.link.LinkNameConstants; -import io.wcm.handler.link.SyntheticLinkResource; -import io.wcm.handler.link.testcontext.AppAemContext; -import io.wcm.handler.link.testcontext.DummyAppTemplate; -import io.wcm.sling.commons.adapter.AdaptTo; -import io.wcm.sling.commons.resource.ImmutableValueMap; -import io.wcm.testing.mock.aem.junit5.AemContext; -import io.wcm.testing.mock.aem.junit5.AemContextExtension; - -/** - * Test InternalCrossScopeLinkType methods. - * Most of the test cases are identical to {@link InternalLinkTypeTest}, so they are not duplicated here. - */ -@ExtendWith(AemContextExtension.class) -@SuppressWarnings("deprecation") -class InternalCrossScopeLinkTypeTest { - - final AemContext context = AppAemContext.newAemContext(); - - private Page targetPage; - - protected Adaptable adaptable() { - return context.request(); - } - - @BeforeEach - void setUp() throws Exception { - - // create current page in site context - context.currentPage(context.create().page("/content/unittest/de_test/brand/de/section/page", - DummyAppTemplate.CONTENT.getTemplatePath())); - - // create internal pages for unit tests - targetPage = context.create().page("/content/unittest/de_test/brand/de/section/content", - DummyAppTemplate.CONTENT.getTemplatePath()); - context.create().page("/content/unittest/en_test/brand/en/section/content", - DummyAppTemplate.CONTENT.getTemplatePath()); - - } - - @Test - void testTargetPage() { - LinkHandler linkHandler = AdaptTo.notNull(adaptable(), LinkHandler.class); - - SyntheticLinkResource linkResource = new SyntheticLinkResource(context.resourceResolver(), - "/content/dummy-path", - ImmutableValueMap.builder() - .put(LinkNameConstants.PN_LINK_TYPE, InternalCrossScopeLinkType.ID) - .put(LinkNameConstants.PN_LINK_CONTENT_REF, targetPage.getPath()) - .build()); - - Link link = linkHandler.get(linkResource).build(); - - assertTrue(link.isValid(), "link valid"); - assertFalse(link.isLinkReferenceInvalid(), "link ref invalid"); - assertEquals("http://www.dummysite.org/content/unittest/de_test/brand/de/section/content.html", link.getUrl(), "link url"); - assertNotNull(link.getAnchor(), "anchor"); - } - - @Test - void testTargetPageOtherSite() { - LinkHandler linkHandler = AdaptTo.notNull(adaptable(), LinkHandler.class); - - SyntheticLinkResource linkResource = new SyntheticLinkResource(context.resourceResolver(), - "/content/dummy-path", - ImmutableValueMap.builder() - .put(LinkNameConstants.PN_LINK_TYPE, InternalCrossScopeLinkType.ID) - .put(LinkNameConstants.PN_LINK_CONTENT_REF, "/content/unittest/en_test/brand/en/section/content") - .build()); - - Link link = linkHandler.get(linkResource).build(); - - assertTrue(link.isValid(), "link valid"); - assertEquals("http://en.dummysite.org/content/unittest/en_test/brand/en/section/content.html", - link.getUrl(), "link url"); - assertNotNull(link.getAnchor(), "anchor"); - } - - @Test - void testGetSyntheticLinkResource() { - Resource resource = InternalCrossScopeLinkType.getSyntheticLinkResource(context.resourceResolver(), - "/content/dummy-path", - "/page/ref"); - ValueMap expected = ImmutableValueMap.of(LinkNameConstants.PN_LINK_TYPE, InternalCrossScopeLinkType.ID, - LinkNameConstants.PN_LINK_CONTENT_REF, "/page/ref"); - assertEquals(expected, ImmutableValueMap.copyOf(resource.getValueMap())); - } - - @Test - void testGetSyntheticLinkResource_Deprecated() { - Resource resource = InternalCrossScopeLinkType.getSyntheticLinkResource(context.resourceResolver(), - "/page/ref"); - ValueMap expected = ImmutableValueMap.of(LinkNameConstants.PN_LINK_TYPE, InternalCrossScopeLinkType.ID, - LinkNameConstants.PN_LINK_CONTENT_REF, "/page/ref"); - assertEquals(expected, ImmutableValueMap.copyOf(resource.getValueMap())); - } - -} diff --git a/src/test/java/io/wcm/handler/link/type/InternalCrossScopeLinkTypeWithoutRequestTest.java b/src/test/java/io/wcm/handler/link/type/InternalCrossScopeLinkTypeWithoutRequestTest.java deleted file mode 100644 index a656f2c..0000000 --- a/src/test/java/io/wcm/handler/link/type/InternalCrossScopeLinkTypeWithoutRequestTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * #%L - * wcm.io - * %% - * Copyright (C) 2014 wcm.io - * %% - * Licensed 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. - * #L% - */ -package io.wcm.handler.link.type; - -import org.apache.sling.api.adapter.Adaptable; - -/** - * Test InternalCrossScopeLinkType methods. - */ -class InternalCrossScopeLinkTypeWithoutRequestTest extends InternalCrossScopeLinkTypeTest { - - @Override - protected Adaptable adaptable() { - return context.currentResource(); - } - -} diff --git a/src/test/java/io/wcm/handler/link/type/InternalLinkTypeTest.java b/src/test/java/io/wcm/handler/link/type/InternalLinkTypeTest.java index d22cba0..5c8d610 100644 --- a/src/test/java/io/wcm/handler/link/type/InternalLinkTypeTest.java +++ b/src/test/java/io/wcm/handler/link/type/InternalLinkTypeTest.java @@ -536,16 +536,6 @@ void testGetSyntheticLinkResource() { assertEquals(expected, ImmutableValueMap.copyOf(resource.getValueMap())); } - @Test - @SuppressWarnings("deprecation") - void testGetSyntheticLinkResource_Deprecated() { - Resource resource = InternalLinkType.getSyntheticLinkResource(context.resourceResolver(), - "/page/ref"); - ValueMap expected = ImmutableValueMap.of(LinkNameConstants.PN_LINK_TYPE, InternalLinkType.ID, - LinkNameConstants.PN_LINK_CONTENT_REF, "/page/ref"); - assertEquals(expected, ImmutableValueMap.copyOf(resource.getValueMap())); - } - @Test void testReferenceAutoDetection() { LinkHandler linkHandler = AdaptTo.notNull(adaptable(), LinkHandler.class); diff --git a/src/test/java/io/wcm/handler/link/type/MediaLinkTypeTest.java b/src/test/java/io/wcm/handler/link/type/MediaLinkTypeTest.java index 740c399..ab56c5b 100644 --- a/src/test/java/io/wcm/handler/link/type/MediaLinkTypeTest.java +++ b/src/test/java/io/wcm/handler/link/type/MediaLinkTypeTest.java @@ -166,16 +166,6 @@ void testGetSyntheticLinkResource() { assertEquals(expected, ImmutableValueMap.copyOf(resource.getValueMap())); } - @Test - @SuppressWarnings("deprecation") - void testGetSyntheticLinkResource_Deprecated() { - Resource resource = MediaLinkType.getSyntheticLinkResource(context.resourceResolver(), - "/media/ref"); - ValueMap expected = ImmutableValueMap.of(LinkNameConstants.PN_LINK_TYPE, MediaLinkType.ID, - LinkNameConstants.PN_LINK_MEDIA_REF, "/media/ref"); - assertEquals(expected, ImmutableValueMap.copyOf(resource.getValueMap())); - } - @Test void testReferenceAutoDetection() { LinkHandler linkHandler = AdaptTo.notNull(adaptable(), LinkHandler.class);