diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index c85498c1..fc4f02da 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -20,7 +20,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - java: [11, 17] + java: [11, 17, 21] os: [ubuntu-latest] distribution: [temurin] diff --git a/.github/workflows/maven-deploy.yml b/.github/workflows/maven-deploy.yml index 30b8e546..c709b1cc 100644 --- a/.github/workflows/maven-deploy.yml +++ b/.github/workflows/maven-deploy.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Configure GIT run: | diff --git a/.github/workflows/release-from-tag.yml b/.github/workflows/release-from-tag.yml index 53c567c7..40c2cd7c 100644 --- a/.github/workflows/release-from-tag.yml +++ b/.github/workflows/release-from-tag.yml @@ -12,7 +12,7 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ncipollo/release-action@v1 with: body: 'Changes: https://wcm.io/wcm/core-components/changes-report.html' diff --git a/build-deploy_aem65.sh b/build-deploy_aem65.sh index 0c4f88f4..c82018ac 100644 --- a/build-deploy_aem65.sh +++ b/build-deploy_aem65.sh @@ -26,7 +26,7 @@ fi # install AEM 6.5 with service pack mvn --non-recursive wcmio-content-package:install \ --activate-profiles=${MAVEN_PROFILES} \ - -Dvault.artifact=adobe.binary.aem.65.servicepack:aem-service-pkg:zip:6.5.18.0 \ + -Dvault.artifact=adobe.binary.aem.65.servicepack:aem-service-pkg:zip:6.5.19.0 \ -Dvault.delayAfterInstallSec=30 if [ "$?" -ne "0" ]; then diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml index 347f2bca..36d889c1 100644 --- a/bundles/core/pom.xml +++ b/bundles/core/pom.xml @@ -25,13 +25,13 @@ io.wcm io.wcm.wcm.core.components.parent - 1.14.0-2.23.2 + 2.0.0-2.23.2 ../../parent/pom.xml io.wcm io.wcm.wcm.core.components - 1.14.0-2.23.2 + 2.0.0-2.23.2 jar WCM Core Components @@ -154,6 +154,11 @@ org.apache.sling.testing.logging-mock test + + com.adobe.cq + core.wcm.components.testing.aem-mock-plugin + test + org.apache.sling org.apache.sling.testing.caconfig-mock-plugin diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/commons/link/LinkWrapper.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/commons/link/LinkWrapper.java index d1cf7cf3..03f7ef1d 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/commons/link/LinkWrapper.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/commons/link/LinkWrapper.java @@ -79,7 +79,11 @@ public boolean isValid() { @JsonSerialize(using = LinkHtmlAttributesSerializer.class) @JsonProperty("attributes") public @NotNull Map getHtmlAttributes() { - return link.getAnchorAttributes(); + Map result = link.getAnchorAttributes(); + if (result == null) { + result = Map.of(); + } + return result; } @Override diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/AbstractComponentImpl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/AbstractComponentImpl.java index fee23ecd..74357bf9 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/AbstractComponentImpl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/AbstractComponentImpl.java @@ -29,6 +29,7 @@ /** * Abstract class that can be used as a base class for {@link Component} implementations. */ +@SuppressWarnings("java:S2176") // accept duplicate class name public abstract class AbstractComponentImpl extends com.adobe.cq.wcm.core.components.util.AbstractComponentImpl implements ComponentExporter { @Override diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV1Impl.java index 6278eeef..6bb0364f 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV1Impl.java @@ -33,12 +33,12 @@ /** * Implementation of {@link ImageArea}. */ -public class ImageAreaV1Impl extends ImageAreaV2Impl { +public final class ImageAreaV1Impl extends ImageAreaV2Impl { /** * @param delegate Delegate */ - public ImageAreaV1Impl(ImageMapArea delegate) { + public ImageAreaV1Impl(ImageMapArea delegate) { super(delegate); } diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV2Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV2Impl.java index 3e4beba6..e263e353 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV2Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV2Impl.java @@ -38,15 +38,15 @@ */ public class ImageAreaV2Impl implements ImageArea { - private final ImageMapArea delegate; + private final ImageMapArea delegate; private final LinkWrapper link; /** * @param delegate Delegate */ - public ImageAreaV2Impl(ImageMapArea delegate) { + public ImageAreaV2Impl(ImageMapArea delegate) { this.delegate = delegate; - io.wcm.handler.link.Link delegateLink = delegate.getLink(); + io.wcm.handler.link.Link delegateLink = toLink(delegate.getLink()); if (delegateLink != null) { this.link = new LinkWrapper(delegateLink); } @@ -55,6 +55,15 @@ public ImageAreaV2Impl(ImageMapArea delegate) { } } + private io.wcm.handler.link.Link toLink(Object linkObject) { + if (linkObject instanceof io.wcm.handler.link.Link) { + return (io.wcm.handler.link.Link)linkObject; + } + else { + return null; + } + } + @Override public String getShape() { return delegate.getShape(); diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LanguageNavigationItemV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LanguageNavigationItemV1Impl.java index 75133b03..d1d975ef 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LanguageNavigationItemV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LanguageNavigationItemV1Impl.java @@ -37,6 +37,7 @@ /** * {@link LanguageNavigationItem} implementation. */ +@SuppressWarnings("java:S110") // class hierarchy levels public class LanguageNavigationItemV1Impl extends NavigationItemV1Impl implements LanguageNavigationItem { private final Page page; @@ -56,6 +57,7 @@ public class LanguageNavigationItemV1Impl extends NavigationItemV1Impl implement * @param parentId Parent ID * @param parentComponent The component that contains this list item */ + @SuppressWarnings("java:S107") // number of parameters public LanguageNavigationItemV1Impl(@NotNull Page page, @NotNull Link link, int level, boolean active, boolean current, @NotNull List children, @Nullable String title, @Nullable String parentId, @Nullable Component parentComponent) { diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LanguageNavigationItemV2Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LanguageNavigationItemV2Impl.java index 05b2a8b5..729522f2 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LanguageNavigationItemV2Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LanguageNavigationItemV2Impl.java @@ -37,6 +37,7 @@ /** * {@link LanguageNavigationItem} implementation. */ +@SuppressWarnings("java:S110") // class hierarchy levels public class LanguageNavigationItemV2Impl extends NavigationItemV2Impl implements LanguageNavigationItem { private final Page page; @@ -56,6 +57,7 @@ public class LanguageNavigationItemV2Impl extends NavigationItemV2Impl implement * @param parentId Parent ID * @param parentComponent The component that contains this list item */ + @SuppressWarnings("java:S107") // number of parameters public LanguageNavigationItemV2Impl(@NotNull Page page, @NotNull Link link, int level, boolean active, boolean current, @NotNull List children, @Nullable String title, @Nullable String parentId, @Nullable Component parentComponent) { diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LinkListItemV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LinkListItemV1Impl.java index 25c74afa..9d958e57 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LinkListItemV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LinkListItemV1Impl.java @@ -58,7 +58,7 @@ public LinkListItemV1Impl(@NotNull String title, @NotNull LinkWrapper link, @Not /** * @deprecated Deprecated in API */ - @Deprecated + @Deprecated(forRemoval = true) @Override @JsonIgnore public com.adobe.cq.wcm.core.components.commons.link.Link getLink() { @@ -70,7 +70,7 @@ public com.adobe.cq.wcm.core.components.commons.link.Link getLink() { * @deprecated Deprecated in API */ @Override - @Deprecated + @Deprecated(forRemoval = true) @JsonIgnore(false) public String getURL() { return super.getURL(); diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LinkListItemV2Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LinkListItemV2Impl.java index 4c5ede18..a15ce4af 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LinkListItemV2Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/LinkListItemV2Impl.java @@ -75,7 +75,7 @@ public LinkListItemV2Impl(@NotNull String title, @NotNull LinkWrapper link, @Not * @deprecated Deprecated in API */ @Override - @Deprecated + @Deprecated(forRemoval = true) @JsonIgnore public String getURL() { return link.getURL(); @@ -97,7 +97,7 @@ protected String getItemIdPrefix() { protected @NotNull PageData getComponentData() { return DataLayerBuilder.extending(super.getComponentData()).asPage() .withTitle(this::getTitle) - .withLinkUrl(this::getURL) + .withLinkUrl(link::getURL) .build(); } diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/NavigationItemV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/NavigationItemV1Impl.java index 46be7ac2..6940d4a2 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/NavigationItemV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/NavigationItemV1Impl.java @@ -34,6 +34,7 @@ /** * {@link NavigationItem} implementation. */ +@SuppressWarnings("java:S110") // class hierarchy levels public class NavigationItemV1Impl extends PageListItemV1Impl implements NavigationItem { private final Page page; @@ -52,6 +53,7 @@ public class NavigationItemV1Impl extends PageListItemV1Impl implements Navigati * @param parentId Parent ID * @param parentComponent The component that contains this list item */ + @SuppressWarnings("java:S107") // number of parameters public NavigationItemV1Impl(@NotNull Page page, @NotNull Link link, int level, boolean active, boolean current, @NotNull List children, @Nullable String parentId, @Nullable Component parentComponent) { @@ -67,7 +69,7 @@ public NavigationItemV1Impl(@NotNull Page page, @NotNull Link link, * @deprecated Deprecated in API */ @Override - @Deprecated + @Deprecated(forRemoval = true) @JsonIgnore public Page getPage() { return page; diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/NavigationItemV2Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/NavigationItemV2Impl.java index f4893bcb..fbb2c816 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/NavigationItemV2Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/NavigationItemV2Impl.java @@ -34,6 +34,7 @@ /** * {@link NavigationItem} implementation. */ +@SuppressWarnings("java:S110") // class hierarchy levels public class NavigationItemV2Impl extends PageListItemV2Impl implements NavigationItem { private final Page page; @@ -52,6 +53,7 @@ public class NavigationItemV2Impl extends PageListItemV2Impl implements Navigati * @param parentId Parent ID * @param parentComponent The component that contains this list item */ + @SuppressWarnings("java:S107") // number of parameters public NavigationItemV2Impl(@NotNull Page page, @NotNull Link link, int level, boolean active, boolean current, @NotNull List children, @Nullable String parentId, @Nullable Component parentComponent) { @@ -67,7 +69,7 @@ public NavigationItemV2Impl(@NotNull Page page, @NotNull Link link, * @deprecated Deprecated in API */ @Override - @Deprecated + @Deprecated(forRemoval = true) @JsonIgnore public Page getPage() { return page; diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/PageListItemV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/PageListItemV1Impl.java index 4d5a4427..71c937a3 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/PageListItemV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/PageListItemV1Impl.java @@ -33,6 +33,7 @@ /** * {@link ListItem} implementation for page links. */ +@SuppressWarnings("java:S110") // class hierarchy levels public class PageListItemV1Impl extends PageListItemV2Impl implements LinkMixin { /** @@ -63,7 +64,7 @@ public PageListItemV1Impl(@NotNull Page page, @NotNull Link link, * @deprecated Deprecated in API */ @Override - @Deprecated + @Deprecated(forRemoval = true) @JsonIgnore(false) public String getURL() { return super.getURL(); diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/PageListItemV4Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/PageListItemV4Impl.java index 5d0fd5b6..e0f59633 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/PageListItemV4Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/PageListItemV4Impl.java @@ -106,7 +106,7 @@ public PageListItemV4Impl(@NotNull Page page, @NotNull Link link, * @deprecated Deprecated in API */ @Override - @Deprecated(since = "1.9.0-2.17.2") + @Deprecated(forRemoval = true, since = "1.9.0-2.17.2") @JsonIgnore public String getURL() { return link.getURL(); diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/ButtonV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/ButtonV1Impl.java index c4e84c9d..627b1b15 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/ButtonV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/ButtonV1Impl.java @@ -58,7 +58,7 @@ public class ButtonV1Impl extends ButtonV2Impl implements LinkMixin { /** * @deprecated Deprecated in API */ - @Deprecated + @Deprecated(forRemoval = true) @Override @JsonIgnore public com.adobe.cq.wcm.core.components.commons.link.Link getButtonLink() { @@ -70,7 +70,7 @@ public com.adobe.cq.wcm.core.components.commons.link.Link getButtonLink() { * @deprecated Deprecated in API */ @Override - @Deprecated + @Deprecated(forRemoval = true) @JsonIgnore(false) public String getLink() { return super.getLink(); diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/LayoutContainerV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/LayoutContainerV1Impl.java index b6a33bb8..a0cca294 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/LayoutContainerV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/LayoutContainerV1Impl.java @@ -74,7 +74,7 @@ public class LayoutContainerV1Impl extends AbstractContainerImpl implements Layo */ @Override @JsonIgnore - @Deprecated(since = "1.13.0-2.22.6") + @Deprecated(forRemoval = true, since = "1.13.0-2.22.6") public @NotNull List getItems() { return delegate.getItems(); } diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/TeaserV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/TeaserV1Impl.java index 7afbd93a..48cf5da5 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/TeaserV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/TeaserV1Impl.java @@ -70,7 +70,7 @@ public com.adobe.cq.wcm.core.components.commons.link.Link getLink() { * @deprecated Deprecated in API */ @Override - @Deprecated + @Deprecated(forRemoval = true) @JsonIgnore(false) @JsonProperty("linkURL") public String getLinkURL() { diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/BreadcrumbV2ItemImpl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/BreadcrumbV2ItemImpl.java index 215d87b0..4b0a1ce8 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/BreadcrumbV2ItemImpl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/BreadcrumbV2ItemImpl.java @@ -40,6 +40,7 @@ @JsonIgnoreProperties({ "page", "children", "level", "description", "lastModified", PROPERTY_PATH }) +@SuppressWarnings("java:S110") // class hierarchy levels public class BreadcrumbV2ItemImpl extends NavigationItemV1Impl implements NavigationItem { /** diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/ButtonV2Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/ButtonV2Impl.java index 865a3e57..408335ae 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/ButtonV2Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/ButtonV2Impl.java @@ -93,7 +93,7 @@ public Link getButtonLink() { * @deprecated Deprecated in API */ @Override - @Deprecated + @Deprecated(forRemoval = true) @JsonIgnore public String getLink() { return link.getURL(); diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/ImageV2Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/ImageV2Impl.java index ec7693bd..6065fbfe 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/ImageV2Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/ImageV2Impl.java @@ -37,6 +37,7 @@ import io.wcm.handler.link.Link; import io.wcm.handler.media.Media; +import io.wcm.handler.media.Rendition; import io.wcm.wcm.core.components.impl.models.helpers.ImageAreaV1Impl; import io.wcm.wcm.core.components.impl.models.v3.ImageV3Impl; import io.wcm.wcm.core.components.impl.servlets.ImageWidthProxyServlet; @@ -89,7 +90,11 @@ protected List buildAreas() { */ @Override protected List buildRenditionWidths() { - long maxWidth = media.getRendition().getWidth(); + Rendition rendition = media.getRendition(); + if (rendition == null) { + return List.of(); + } + long maxWidth = rendition.getWidth(); String[] configuredWidths = currentStyle.get(PN_DESIGN_ALLOWED_RENDITION_WIDTHS, new String[0]); return Arrays.stream(configuredWidths) .map(NumberUtils::toLong) diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/NavigationV2Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/NavigationV2Impl.java index 1c429905..918c6eff 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/NavigationV2Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/NavigationV2Impl.java @@ -267,8 +267,9 @@ private boolean isCurrent(@NotNull Page page, @NotNull Link link) { } private boolean currentPageIsRedirectTarget(@NotNull Link link) { - return link.getTargetPage() != null - && StringUtils.equals(getCurrentPage().getPath(), link.getTargetPage().getPath()); + Page targetPage = link.getTargetPage(); + return targetPage != null + && StringUtils.equals(getCurrentPage().getPath(), targetPage.getPath()); } protected NavigationItem newNavigationItem(@NotNull Page page, @NotNull Link link, diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/TeaserV2Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/TeaserV2Impl.java index 8e967d68..31f78c14 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/TeaserV2Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/TeaserV2Impl.java @@ -104,6 +104,7 @@ public class TeaserV2Impl extends AbstractComponentImpl implements Teaser, Media private boolean titleLinkHidden; @PostConstruct + @SuppressWarnings({ "java:S3776", "java:S6541" }) // ignore complexity private void activate() { ValueMap properties = resource.getValueMap(); @@ -215,7 +216,7 @@ public Link getLink() { * @deprecated Deprecated in API */ @Override - @Deprecated + @Deprecated(forRemoval = true) @JsonIgnore public String getLinkURL() { return link.getURL(); @@ -261,7 +262,7 @@ public String getTitleType() { protected @NotNull ComponentData getComponentData() { return DataLayerBuilder.extending(super.getComponentData()).asComponent() .withTitle(this::getTitle) - .withLinkUrl(this::getLinkURL) + .withLinkUrl(link::getURL) .withDescription(this::getDescription) .build(); } diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/TitleV2Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/TitleV2Impl.java index c701d86c..2376b06c 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/TitleV2Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v2/TitleV2Impl.java @@ -67,7 +67,7 @@ public com.adobe.cq.wcm.core.components.commons.link.Link getLink() { * @deprecated Deprecated in API */ @Override - @Deprecated + @Deprecated(forRemoval = true) @JsonIgnore(false) @JsonProperty("linkURL") public String getLinkURL() { diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/BreadcrumbV3ItemImpl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/BreadcrumbV3ItemImpl.java index eb4ff353..eaa99f9c 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/BreadcrumbV3ItemImpl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/BreadcrumbV3ItemImpl.java @@ -40,6 +40,7 @@ @JsonIgnoreProperties({ "page", "children", "level", "description", "lastModified", PROPERTY_PATH }) +@SuppressWarnings("java:S110") // class hierarchy levels public class BreadcrumbV3ItemImpl extends NavigationItemV2Impl implements NavigationItem { /** diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java index 22a10616..335eafab 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3Impl.java @@ -60,6 +60,7 @@ import io.wcm.handler.media.UriTemplate; import io.wcm.handler.media.UriTemplateType; import io.wcm.handler.media.format.Ratio; +import io.wcm.handler.mediasource.inline.InlineMediaSource; import io.wcm.handler.url.UrlHandler; import io.wcm.sling.models.annotations.AemObject; import io.wcm.wcm.core.components.commons.link.LinkWrapper; @@ -147,8 +148,9 @@ private void activate() { // resolve media and properties from DAM asset media = buildMedia(altFromAsset); + Rendition rendition = media.getRendition(); - if (media.isValid() && !media.getRendition().isImage()) { + if (media.isValid() && (rendition == null || !rendition.isImage())) { // no image asset selected (cannot be rendered) - set to invalid media = mediaHandler.invalid(); } @@ -185,14 +187,16 @@ protected List buildAreas() { private void initPropertiesFromDamAsset(ValueMap properties) { Asset asset = media.getAsset(); if (asset != null) { + if (!StringUtils.equals(media.getMediaSource().getId(), InlineMediaSource.ID)) { + fileReference = asset.getPath(); + } + alt = asset.getAltText(); + com.day.cq.dam.api.Asset damAsset = asset.adaptTo(com.day.cq.dam.api.Asset.class); if (damAsset != null) { boolean titleFromAsset = properties.get(PN_TITLE_VALUE_FROM_DAM, currentStyle.get(PN_TITLE_VALUE_FROM_DAM, true)); boolean uuidDisabled = currentStyle.get(PN_UUID_DISABLED, false); - fileReference = damAsset.getPath(); - alt = asset.getAltText(); - if (!uuidDisabled) { uuid = damAsset.getID(); } @@ -213,9 +217,13 @@ private void initPropertiesFromDamAsset(ValueMap properties) { * @return Widths */ protected List buildRenditionWidths() { - double primaryRatio = media.getRendition().getRatio(); + Rendition rendition = media.getRendition(); + if (rendition == null) { + return List.of(); + } + double primaryRatio = rendition.getRatio(); return media.getRenditions().stream() - .filter(rendition -> Ratio.matches(rendition.getRatio(), primaryRatio)) + .filter(item -> Ratio.matches(item.getRatio(), primaryRatio)) .map(Rendition::getWidth) .distinct() .sorted() @@ -228,7 +236,7 @@ protected List buildRenditionWidths() { */ protected String buildSrcPattern() { Rendition rendition = media.getRendition(); - if (!rendition.isImage() || rendition.isVectorImage()) { + if (rendition == null || !rendition.isImage() || rendition.isVectorImage()) { return null; } UriTemplate uriTempalte = rendition.getUriTemplate(UriTemplateType.SCALE_WIDTH); diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/TitleV3Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/TitleV3Impl.java index 527f6cc5..b4164a79 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/TitleV3Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v3/TitleV3Impl.java @@ -84,7 +84,7 @@ private void activate() { * @deprecated Deprecated in API */ @Override - @Deprecated + @Deprecated(forRemoval = true) @JsonIgnore public String getLinkURL() { return link.getURL(); diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java index f0854be1..1a624b25 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java @@ -59,6 +59,8 @@ import io.wcm.handler.media.Media; import io.wcm.handler.media.MediaHandler; import io.wcm.handler.media.MediaNameConstants; +import io.wcm.handler.media.Rendition; +import io.wcm.handler.mediasource.inline.InlineMediaSource; import io.wcm.sling.commons.adapter.AdaptTo; import io.wcm.sling.models.annotations.AemObject; import io.wcm.wcm.core.components.impl.models.helpers.AbstractComponentImpl; @@ -126,8 +128,9 @@ private void activate() { .mediaHandlerProperty("data-cmp-hook-image", "image") .mediaHandlerProperty(MediaNameConstants.PROP_CSS_CLASS, "cmp-wcmio-responsiveimage__image") .buildMedia(); + Rendition rendition = media.getRendition(); - if (media.isValid() && !media.getRendition().isImage()) { + if (media.isValid() && (rendition == null || !rendition.isImage())) { // no image asset selected (cannot be rendered) - set to invalid media = mediaHandler.invalid(); } @@ -150,14 +153,16 @@ private void activate() { private void initPropertiesFromDamAsset(ValueMap properties) { Asset asset = media.getAsset(); if (asset != null) { + if (!StringUtils.equals(media.getMediaSource().getId(), InlineMediaSource.ID)) { + fileReference = asset.getPath(); + } + alt = asset.getAltText(); + com.day.cq.dam.api.Asset damAsset = asset.adaptTo(com.day.cq.dam.api.Asset.class); if (damAsset != null) { boolean titleFromAsset = properties.get(PN_TITLE_VALUE_FROM_DAM, currentStyle.get(PN_TITLE_VALUE_FROM_DAM, true)); boolean uuidDisabled = currentStyle.get(PN_UUID_DISABLED, false); - fileReference = damAsset.getPath(); - alt = asset.getAltText(); - if (!uuidDisabled) { uuid = damAsset.getID(); } @@ -173,7 +178,7 @@ private void initPropertiesFromDamAsset(ValueMap properties) { } @SuppressWarnings("unchecked") - private static void setImageTitle(HtmlElement element, String title) { + private static void setImageTitle(HtmlElement element, String title) { if (element == null) { return; } @@ -181,8 +186,8 @@ private static void setImageTitle(HtmlElement element, String title) { element.setTitle(title); } else { - List> children = (List)element.getChildren(); - for (HtmlElement child : children) { + List children = (List)element.getChildren(); + for (HtmlElement child : children) { setImageTitle(child, title); } } diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/servlets/ImageWidthProxyServlet.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/servlets/ImageWidthProxyServlet.java index ee8b4be4..ef616da3 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/servlets/ImageWidthProxyServlet.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/servlets/ImageWidthProxyServlet.java @@ -18,6 +18,7 @@ import org.apache.sling.commons.mime.MimeTypeService; import org.apache.sling.servlets.annotations.SlingServletResourceTypes; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; @@ -27,6 +28,7 @@ import io.wcm.handler.media.MediaArgs; import io.wcm.handler.media.MediaBuilder; import io.wcm.handler.media.MediaHandler; +import io.wcm.handler.media.Rendition; import io.wcm.handler.media.impl.ImageFileServlet; import io.wcm.sling.commons.adapter.AdaptTo; import io.wcm.wcm.commons.contenttype.ContentType; @@ -78,15 +80,17 @@ protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHtt } // if media url used ImageFileServlet forward request - if (usesImageFileServlet(media.getUrl())) { - log.debug("Forward to {}", media.getUrl()); - request.getRequestDispatcher(media.getUrl()).forward(request, response); + String url = media.getUrl(); + Rendition rendition = media.getRendition(); + if (usesImageFileServlet(url)) { + log.debug("Forward to {}", url); + request.getRequestDispatcher(url).forward(request, response); } - else { + else if (rendition != null) { // otherwise it points directly to a binary in repository, stream it directly - log.debug("Stream binary content from {}", media.getRendition().getPath()); + log.debug("Stream binary content from {}", rendition.getPath()); response.setContentType(getMimeType(request)); - Resource resource = AdaptTo.notNull(media.getRendition(), Resource.class); + Resource resource = AdaptTo.notNull(rendition, Resource.class); try (InputStream is = resource.adaptTo(InputStream.class)) { BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream()); IOUtils.copy(is, bos); @@ -113,7 +117,7 @@ private Media buildMedia(SlingHttpServletRequest request, long width) { return builder.build(); } - private boolean usesImageFileServlet(String mediaUrl) { + private boolean usesImageFileServlet(@Nullable String mediaUrl) { return StringUtils.contains(mediaUrl, "." + ImageFileServlet.SELECTOR + "."); } diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/util/CoreResourceWrapper.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/util/CoreResourceWrapper.java index 76d6588f..c28ebff7 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/util/CoreResourceWrapper.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/util/CoreResourceWrapper.java @@ -40,7 +40,7 @@ * Additionally supports overwriting and hiding some properties. */ @Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION) -public class CoreResourceWrapper extends ResourceWrapper { +public final class CoreResourceWrapper extends ResourceWrapper { private ValueMap valueMap; private String overriddenResourceType; diff --git a/bundles/core/src/main/webapp/app-root/components/image/v3/image.json b/bundles/core/src/main/webapp/app-root/components/image/v3/image.json index e0b4576b..787d3ff7 100644 --- a/bundles/core/src/main/webapp/app-root/components/image/v3/image.json +++ b/bundles/core/src/main/webapp/app-root/components/image/v3/image.json @@ -8,69 +8,7 @@ "wcmio:linkTargetUrlFallbackProperty": "linkURL", "cq:editConfig": { - "jcr:primaryType": "cq:EditConfig", - "cq:inherit": true, - /* - * Overwrite inplace edit config to: - * - Disable cropping on inline toolbar as it does not support predefined ratios - * - Remove default ratios as they are fetched from assigned media formats - * - Remove image/webp support - */ - "cq:inplaceEditing": { - "jcr:primaryType": "cq:InplaceEditingConfig", - "editorType": "image", - "active": true, - "configPath": "inplaceEditingConfig", - "inplaceEditingConfig": { - "jcr:primaryType": "nt:unstructured", - "plugins": { - "crop": { - "features": "*", - "supportedMimeTypes": ["image/jpeg", "image/png", "image/tiff"] - }, - "flip": { - "features": "-", - "supportedMimeTypes": ["image/jpeg", "image/png", "image/tiff"] - }, - "map": { - "features": "*", - "supportedMimeTypes": ["image/jpeg", "image/png", "image/tiff", "image/svg+xml"] - }, - "rotate": { - "features": "*", - "supportedMimeTypes": ["image/jpeg", "image/png", "image/tiff"] - }, - "zoom": { - "features": "*", - "supportedMimeTypes": ["image/jpeg", "image/png", "image/tiff", "image/svg+xml"] - } - }, - "ui": { - "inline": { - "toolbar": ["rotate#right", "history#undo", "history#redo", "fullscreen#fullscreen", "control#close", "control#finish"], - "replacementToolbars": { - "crop": ["crop#identifier", "crop#unlaunch", "crop#confirm"] - } - }, - "fullscreen": { - "toolbar": { - "left": ["crop#launchwithratio", "rotate#right", "map#launch", "flip#horizontal", "flip#vertical", "zoom#reset100", "zoom#popupslider"], - "right": ["history#undo", "history#redo", "fullscreen#fullscreenexit"] - }, - "replacementToolbars": { - "crop": { - "left": ["crop#identifier"], - "right": ["crop#unlaunch", "crop#confirm"] - }, - "map": { - "left": ["map#rectangle", "map#circle", "map#polygon"], - "right": ["map#unlaunch", "map#confirm"] - } - } - } - } - } - } + "jcr:primaryType": "cq:EditConfig" }, "cq:dialog": { diff --git a/bundles/core/src/main/webapp/app-root/components/wcmio/commons/mediaAltTextInclude/v1.json b/bundles/core/src/main/webapp/app-root/components/wcmio/commons/mediaAltTextInclude/v1.json new file mode 100644 index 00000000..bdf9f6f5 --- /dev/null +++ b/bundles/core/src/main/webapp/app-root/components/wcmio/commons/mediaAltTextInclude/v1.json @@ -0,0 +1,3 @@ +{ + "jcr:primaryType": "sling:Folder" +} diff --git a/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage/responsiveimage.html b/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage/responsiveimage.html index 0ce440be..c9583f1a 100644 --- a/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage/responsiveimage.html +++ b/bundles/core/src/main/webapp/app-root/components/wcmio/responsiveimage/v1/responsiveimage/responsiveimage.html @@ -3,6 +3,7 @@ data-cmp-is="wcmio-responsiveimage" data-asset="${image.fileReference}" data-asset-id="${image.uuid}" + data-cmp-filereference="${image.fileReference}" data-title="${image.title || image.alt}" id="${image.id}" data-cmp-data-layer="${image.data.json}" diff --git a/bundles/core/src/test/java/io/wcm/wcm/core/components/commons/link/LinkWrapperTest.java b/bundles/core/src/test/java/io/wcm/wcm/core/components/commons/link/LinkWrapperTest.java index 67b5c571..a5d6db80 100644 --- a/bundles/core/src/test/java/io/wcm/wcm/core/components/commons/link/LinkWrapperTest.java +++ b/bundles/core/src/test/java/io/wcm/wcm/core/components/commons/link/LinkWrapperTest.java @@ -48,7 +48,6 @@ import io.wcm.testing.mock.aem.junit5.AemContext; import io.wcm.testing.mock.aem.junit5.AemContextExtension; import io.wcm.wcm.commons.contenttype.ContentType; -import io.wcm.wcm.core.components.commons.link.LinkWrapper; import io.wcm.wcm.core.components.testcontext.AppAemContext; @ExtendWith(AemContextExtension.class) @@ -67,7 +66,6 @@ void setUp() { } @Test - @SuppressWarnings("unused") void testInvalid() { LinkWrapper underTest = new LinkWrapper(linkHandler.invalid()); @@ -75,7 +73,7 @@ void testInvalid() { assertNull(underTest.getURL()); assertNull(underTest.getMappedURL()); assertNull(underTest.getExternalizedURL()); - assertNull(underTest.getHtmlAttributes()); + assertEquals(Map.of(), underTest.getHtmlAttributes()); assertNull(underTest.getReference()); assertNotNull(underTest.getLinkObject()); diff --git a/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v1/NavigationV1ImplTest.java b/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v1/NavigationV1ImplTest.java index bfe0b567..4ac49199 100644 --- a/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v1/NavigationV1ImplTest.java +++ b/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v1/NavigationV1ImplTest.java @@ -54,6 +54,7 @@ import io.wcm.wcm.core.components.testcontext.AppAemContext; @ExtendWith(AemContextExtension.class) +@SuppressWarnings("java:S5976") // similar tests class NavigationV1ImplTest { private final AemContext context = AppAemContext.newAemContext(); diff --git a/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v2/NavigationV2ImplTest.java b/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v2/NavigationV2ImplTest.java index 1a57a3ad..1a82b90b 100644 --- a/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v2/NavigationV2ImplTest.java +++ b/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v2/NavigationV2ImplTest.java @@ -54,6 +54,7 @@ import io.wcm.wcm.core.components.testcontext.AppAemContext; @ExtendWith(AemContextExtension.class) +@SuppressWarnings("java:S5976") // similar tests class NavigationV2ImplTest { private final AemContext context = AppAemContext.newAemContext(); diff --git a/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3ImplTest.java b/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3ImplTest.java index 1606748e..06ad7c9e 100644 --- a/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3ImplTest.java +++ b/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v3/ImageV3ImplTest.java @@ -192,7 +192,7 @@ void testWithAssetImage_SVG() { Image underTest = AdaptTo.notNull(context.request(), Image.class); - String expectedMediaUrl = DAM_ROOT + "/sample.svg/_jcr_content/renditions/original./sample.svg"; + String expectedMediaUrl = DAM_ROOT + "/sample.svg/_jcr_content/renditions/original.media_file.file/sample.svg"; assertEquals(expectedMediaUrl, underTest.getSrc()); assertNull(underTest.getSrcUriTemplate()); diff --git a/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1ImplTest.java b/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1ImplTest.java index b5826159..5f61a24d 100644 --- a/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1ImplTest.java +++ b/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1ImplTest.java @@ -131,6 +131,7 @@ void testInvalidAssetReference() { } @Test + @SuppressWarnings("null") void testWithAssetImage() { context.currentResource(context.create().resource(page.getContentResource().getPath() + "/image", PROPERTY_RESOURCE_TYPE, RESOURCE_TYPE, @@ -289,6 +290,7 @@ void testWithNoImageAsset() { } @Test + @SuppressWarnings("null") void testDisplayPopupTitle() { context.currentResource(context.create().resource(page.getContentResource().getPath() + "/image", PROPERTY_RESOURCE_TYPE, RESOURCE_TYPE, @@ -349,6 +351,7 @@ void testUUID_Disabled() { } @Test + @SuppressWarnings("null") void testAreas() { context.currentResource(context.create().resource(page.getContentResource().getPath() + "/image", PROPERTY_RESOURCE_TYPE, RESOURCE_TYPE, diff --git a/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/util/ComponentFeatureImageResolverTest.java b/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/util/ComponentFeatureImageResolverTest.java index fa64cb8d..002d0286 100644 --- a/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/util/ComponentFeatureImageResolverTest.java +++ b/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/util/ComponentFeatureImageResolverTest.java @@ -104,6 +104,7 @@ void testInvalidImage() { } @Test + @SuppressWarnings("null") void testComponentImage() { Resource component = context.create().resource(page1, "comp1", PROPERTY_RESOURCE_TYPE, COMPONENT_RESOURCE_TYPE, @@ -119,6 +120,7 @@ void testComponentImage() { } @Test + @SuppressWarnings("null") void testComponentImage_Decorative() { Resource component = context.create().resource(page1, "comp1", PROPERTY_RESOURCE_TYPE, COMPONENT_RESOURCE_TYPE, @@ -135,6 +137,7 @@ void testComponentImage_Decorative() { } @Test + @SuppressWarnings("null") void testComponentImage_Decorative_Policy() { context.contentPolicyMapping(COMPONENT_RESOURCE_TYPE, PN_MEDIA_IS_DECORATIVE_STANDARD, true); @@ -182,6 +185,7 @@ void testComponentImageFromPage_NoFeatureImage() { } @Test + @SuppressWarnings("null") void testComponentImageFromPage() { Resource component = context.create().resource(page1, "comp1", PROPERTY_RESOURCE_TYPE, COMPONENT_RESOURCE_TYPE, @@ -205,6 +209,7 @@ void testComponentImageFromPage() { } @Test + @SuppressWarnings("null") void testComponentImageFromPage_FallbackCurrentPage() { Resource component = context.create().resource(page1, "comp1", PROPERTY_RESOURCE_TYPE, COMPONENT_RESOURCE_TYPE, diff --git a/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/AppAemContext.java b/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/AppAemContext.java index 7c4276be..f77a5186 100644 --- a/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/AppAemContext.java +++ b/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/AppAemContext.java @@ -19,6 +19,7 @@ */ package io.wcm.wcm.core.components.testcontext; +import static com.adobe.cq.wcm.core.components.testing.mock.ContextPlugins.CORE_COMPONENTS; import static com.day.cq.commons.jcr.JcrConstants.JCR_LANGUAGE; import static com.day.cq.commons.jcr.JcrConstants.JCR_TITLE; import static io.wcm.testing.mock.wcmio.caconfig.ContextPlugins.WCMIO_CACONFIG; @@ -33,8 +34,6 @@ import org.apache.sling.api.resource.PersistenceException; import org.jetbrains.annotations.NotNull; -import com.adobe.cq.wcm.core.components.internal.link.DefaultPathProcessor; - import io.wcm.handler.media.spi.MediaFormatProvider; import io.wcm.handler.media.spi.MediaHandlerConfig; import io.wcm.handler.url.spi.UrlHandlerConfig; @@ -62,7 +61,7 @@ private AppAemContext() { public static AemContext newAemContext() { return new AemContextBuilder() .plugin(CACONFIG) - .plugin(WCMIO_SLING, WCMIO_WCM, WCMIO_CACONFIG, WCMIO_HANDLER) + .plugin(CORE_COMPONENTS, WCMIO_SLING, WCMIO_WCM, WCMIO_CACONFIG, WCMIO_HANDLER) .afterSetUp(SETUP_CALLBACK) .build(); } @@ -82,9 +81,6 @@ public void execute(@NotNull AemContext context) throws PersistenceException, IO context.registerService(MediaHandlerConfig.class, new MediaHandlerConfigImpl()); context.registerService(MediaFormatProvider.class, new MediaFormatProviderImpl()); - // core components link handling services - context.registerInjectActivateService(DefaultPathProcessor.class); - // create template context.create().resource(TEMPLATE_PATH, JCR_TITLE, "Template #1"); diff --git a/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/ImageAreaTestData.java b/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/ImageAreaTestData.java index 2728d4e4..6e18b9c0 100644 --- a/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/ImageAreaTestData.java +++ b/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/ImageAreaTestData.java @@ -68,7 +68,7 @@ public static List getExpectedAreasV1(AemContext context) { private static ImageArea areaV1(@NotNull String shape, @NotNull String coordinates, @Nullable String relativeCoordinates, @Nullable Link link, @NotNull String linkUrl, @Nullable String linkWindowTarget, @Nullable String altText) { - return new ImageAreaV1Impl(new ImageMapAreaImpl(shape, coordinates, relativeCoordinates, + return new ImageAreaV1Impl(new ImageMapAreaImpl(shape, coordinates, relativeCoordinates, link, linkUrl, linkWindowTarget, altText)); } diff --git a/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/TestUtils.java b/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/TestUtils.java index 20c990a9..992d8cfb 100644 --- a/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/TestUtils.java +++ b/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/TestUtils.java @@ -45,6 +45,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import io.wcm.handler.media.Rendition; import io.wcm.testing.mock.aem.junit5.AemContext; import io.wcm.wcm.core.components.models.mixin.LinkMixin; import io.wcm.wcm.core.components.models.mixin.MediaMixin; @@ -116,7 +117,8 @@ public static void assertValidMedia(Object object, String mediaUrl) { MediaMixin mediaMixin = (MediaMixin)object; assertTrue(mediaMixin.isMediaValid()); assertEquals(mediaUrl, mediaMixin.getMediaURL()); - if (mediaMixin.getMediaObject().getRendition().isImage()) { + Rendition rendition = mediaMixin.getMediaObject().getRendition(); + if (rendition != null && rendition.isImage()) { assertNotNull(mediaMixin.getMediaMarkup()); } } diff --git a/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/UrlHandlerConfigImpl.java b/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/UrlHandlerConfigImpl.java index 5f9b57c0..7a682eb8 100644 --- a/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/UrlHandlerConfigImpl.java +++ b/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/UrlHandlerConfigImpl.java @@ -22,6 +22,7 @@ import static io.wcm.wcm.core.components.testcontext.AppAemContext.ROOT_LEVEL; import org.apache.sling.api.resource.Resource; +import org.jetbrains.annotations.Nullable; import io.wcm.handler.url.spi.UrlHandlerConfig; @@ -31,7 +32,7 @@ class UrlHandlerConfigImpl extends UrlHandlerConfig { @Override - public int getSiteRootLevel(Resource contextResource) { + public int getSiteRootLevel(@Nullable Resource contextResource) { return ROOT_LEVEL; } diff --git a/changes.xml b/changes.xml index c6cb2273..5c1f0523 100644 --- a/changes.xml +++ b/changes.xml @@ -23,6 +23,18 @@ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd"> + + Migrate from wcm.io Handler 1.x to 2.x for details. + ]]> + + Explicitly define folder type for JSON files with "nt:unstructured" as root node to circumvent SLING-12197. + + + Image (v3): Remove support for inline image editing, as the Adobe Image V3 component has removed support for that as well. + + + Add Image (v3). diff --git a/examples/bundles/examples-core/pom.xml b/examples/bundles/examples-core/pom.xml index 77211dee..dc38ce5e 100644 --- a/examples/bundles/examples-core/pom.xml +++ b/examples/bundles/examples-core/pom.xml @@ -25,13 +25,13 @@ io.wcm io.wcm.wcm.core.components.parent - 1.14.0-2.23.2 + 2.0.0-2.23.2 ../../../parent/pom.xml io.wcm.samples io.wcm.wcm.core.components.examples-core - 1.14.0-2.23.2 + 2.0.0-2.23.2 jar WCM Core Components Examples Core @@ -44,7 +44,7 @@ io.wcm io.wcm.wcm.core.components - 1.14.0-2.23.2 + 2.0.0-2.23.2 compile diff --git a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/io.wcm.handler.media.impl.InlineImageAuthorPreviewServlet-wcmiocmpsmp.cfg.json b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/io.wcm.handler.media.impl.InlineImageAuthorPreviewServlet-wcmiocmpsmp.cfg.json new file mode 100644 index 00000000..bfbb5b89 --- /dev/null +++ b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/io.wcm.handler.media.impl.InlineImageAuthorPreviewServlet-wcmiocmpsmp.cfg.json @@ -0,0 +1,5 @@ +{ + "sling.servlet.resourceTypes": [ + "wcm-io/wcm/core/components/wcmio/responsiveimage/v1/responsiveimage" + ] +} diff --git a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/io.wcm.handler.media.impl.InlineImageAuthorPreviewServlet-wcmiocmpsmp.config b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/io.wcm.handler.media.impl.InlineImageAuthorPreviewServlet-wcmiocmpsmp.config deleted file mode 100644 index 8804ea82..00000000 --- a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/io.wcm.handler.media.impl.InlineImageAuthorPreviewServlet-wcmiocmpsmp.config +++ /dev/null @@ -1 +0,0 @@ -sling.servlet.resourceTypes=["wcm-io/wcm/core/components/wcmio/responsiveimage/v1/responsiveimage"] \ No newline at end of file diff --git a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl.cfg.json b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl.cfg.json new file mode 100644 index 00000000..8686fa1f --- /dev/null +++ b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl.cfg.json @@ -0,0 +1,3 @@ +{ + "instance.type": "author" +} diff --git a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl.config b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl.config deleted file mode 100644 index 412644f5..00000000 --- a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl.config +++ /dev/null @@ -1 +0,0 @@ -instance.type="author" \ No newline at end of file diff --git a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-handler.cfg.json b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-handler.cfg.json new file mode 100644 index 00000000..9b09012c --- /dev/null +++ b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-handler.cfg.json @@ -0,0 +1,5 @@ +{ + "user.mapping": [ + "io.wcm.handler.media:dam-rendition-metadata=[dam-writer-service]" + ] +} diff --git a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-handler.config b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-handler.config deleted file mode 100644 index 4e995cd2..00000000 --- a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.author/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-handler.config +++ /dev/null @@ -1 +0,0 @@ -user.mapping=["io.wcm.handler.media:dam-rendition-metadata\=[dam-writer-service]"] diff --git a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.publish/io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl.cfg.json b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.publish/io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl.cfg.json new file mode 100644 index 00000000..48f86519 --- /dev/null +++ b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.publish/io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl.cfg.json @@ -0,0 +1,3 @@ +{ + "instance.type": "publish" +} diff --git a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.publish/io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl.config b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.publish/io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl.config deleted file mode 100644 index d01a0617..00000000 --- a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config.publish/io.wcm.wcm.commons.instancetype.impl.InstanceTypeServiceImpl.config +++ /dev/null @@ -1 +0,0 @@ -instance.type="publish" \ No newline at end of file diff --git a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-dm.cfg.json b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-dm.cfg.json new file mode 100644 index 00000000..eb322b7e --- /dev/null +++ b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-dm.cfg.json @@ -0,0 +1,5 @@ +{ + "user.mapping": [ + "io.wcm.handler.media:dynamic-media-support=[configuration-reader-service]" + ] +} diff --git a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-dm.config b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-dm.config deleted file mode 100644 index 192be33a..00000000 --- a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-dm.config +++ /dev/null @@ -1 +0,0 @@ -user.mapping=["io.wcm.handler.media:dynamic-media-support\=[configuration-reader-service]"] \ No newline at end of file diff --git a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-wcm.cfg.json b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-wcm.cfg.json new file mode 100644 index 00000000..dece9e4f --- /dev/null +++ b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-wcm.cfg.json @@ -0,0 +1,6 @@ +{ + "user.mapping": [ + "io.wcm.handler.url:clientlibs-service=[sling-scripting]", + "io.wcm.wcm.commons:component-properties=[sling-scripting]" + ] +} diff --git a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-wcm.config b/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-wcm.config deleted file mode 100644 index 6c5069b8..00000000 --- a/examples/content-packages/examples-libs/jcr_root/apps/wcm-io-samples/wcm-core-components-libs/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-wcmiocmpsmp-wcm.config +++ /dev/null @@ -1 +0,0 @@ -user.mapping=["io.wcm.handler.url:clientlibs-service\=[sling-scripting]","io.wcm.wcm.commons:component-properties\=[sling-scripting]"] \ No newline at end of file diff --git a/examples/content-packages/examples-libs/pom.xml b/examples/content-packages/examples-libs/pom.xml index 33f4521d..591e6f41 100644 --- a/examples/content-packages/examples-libs/pom.xml +++ b/examples/content-packages/examples-libs/pom.xml @@ -25,13 +25,13 @@ io.wcm io.wcm.wcm.core.components.parent - 1.14.0-2.23.2 + 2.0.0-2.23.2 ../../../parent/pom.xml io.wcm.samples io.wcm.wcm.core.components.examples-libs - 1.14.0-2.23.2 + 2.0.0-2.23.2 content-package WCM Core Components Examples wcm.io Libraries @@ -42,7 +42,7 @@ io.wcm io.wcm.wcm.core.components - 1.14.0-2.23.2 + 2.0.0-2.23.2 compile @@ -143,7 +143,7 @@ io.wcm io.wcm.caconfig.editor - 1.15.6 + 1.15.8 io.wcm @@ -158,27 +158,27 @@ io.wcm io.wcm.handler.commons - 1.5.0 + 2.0.0 io.wcm io.wcm.handler.url - 1.10.2 + 2.0.0 io.wcm io.wcm.handler.link - 1.10.2 + 2.0.0 io.wcm io.wcm.handler.media - 1.15.8 + 2.0.0 io.wcm io.wcm.handler.richtext - 1.6.4 + 2.0.0 io.wcm @@ -188,7 +188,7 @@ io.wcm io.wcm.wcm.ui.granite - 1.9.14 + 1.10.2 diff --git a/examples/content-packages/examples-sample-content/pom.xml b/examples/content-packages/examples-sample-content/pom.xml index 466e5e38..71deadd9 100644 --- a/examples/content-packages/examples-sample-content/pom.xml +++ b/examples/content-packages/examples-sample-content/pom.xml @@ -25,13 +25,13 @@ io.wcm io.wcm.wcm.core.components.parent - 1.14.0-2.23.2 + 2.0.0-2.23.2 ../../../parent/pom.xml io.wcm.samples io.wcm.wcm.core.components.examples-sample-content - 1.14.0-2.23.2 + 2.0.0-2.23.2 content-package WCM Core Components Examples Content diff --git a/examples/content-packages/examples/pom.xml b/examples/content-packages/examples/pom.xml index 09e30268..352c9637 100644 --- a/examples/content-packages/examples/pom.xml +++ b/examples/content-packages/examples/pom.xml @@ -25,13 +25,13 @@ io.wcm io.wcm.wcm.core.components.parent - 1.14.0-2.23.2 + 2.0.0-2.23.2 ../../../parent/pom.xml io.wcm.samples io.wcm.wcm.core.components.examples - 1.14.0-2.23.2 + 2.0.0-2.23.2 content-package WCM Core Components Examples @@ -42,7 +42,7 @@ io.wcm.samples io.wcm.wcm.core.components.examples-core - 1.14.0-2.23.2 + 2.0.0-2.23.2 compile diff --git a/examples/pom.xml b/examples/pom.xml index e3036b35..6c77a401 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -25,13 +25,13 @@ io.wcm io.wcm.wcm.core.components.parent - 1.14.0-2.23.2 + 2.0.0-2.23.2 ../parent/pom.xml io.wcm.samples io.wcm.wcm.core.components.examples.root - 1.14.0-2.23.2 + 2.0.0-2.23.2 pom diff --git a/parent/pom.xml b/parent/pom.xml index 24543a44..e86998c0 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -25,13 +25,13 @@ io.wcm io.wcm.parent_toplevel - 2.2.2 + 2.3.0 io.wcm io.wcm.wcm.core.components.parent - 1.14.0-2.23.2 + 2.0.0-2.23.2 pom WCM Core Components @@ -54,20 +54,12 @@ http://localhost:4503 - 2023-09-08T14:17:30Z + 2024-01-26T20:12:08Z - - io.wcm.maven - io.wcm.maven.aem-dependencies - 6.5.17.0001 - pom - import - - com.adobe.cq @@ -123,27 +115,27 @@ io.wcm io.wcm.handler.commons - 1.5.0 + 2.0.0 io.wcm io.wcm.handler.url - 1.10.2 + 2.0.0 io.wcm io.wcm.handler.link - 1.10.2 + 2.0.0 io.wcm io.wcm.handler.media - 1.15.6 + 2.0.0 io.wcm io.wcm.handler.richtext - 1.6.4 + 2.0.0 io.wcm @@ -153,24 +145,29 @@ io.wcm io.wcm.wcm.ui.granite - 1.9.14 + 1.10.0 io.wcm io.wcm.testing.aem-mock.junit5 - 5.3.0 + 5.5.0 org.apache.sling org.apache.sling.testing.logging-mock 2.0.0 + + com.adobe.cq + core.wcm.components.testing.aem-mock-plugin + ${core.wcm.components.version} + org.apache.sling org.apache.sling.testing.caconfig-mock-plugin - 1.5.2 + 1.5.4 io.wcm @@ -190,7 +187,7 @@ io.wcm io.wcm.testing.wcm-io-mock.handler - 1.4.0 + 2.0.0 diff --git a/pom.xml b/pom.xml index 5aa565d3..e88db5ea 100644 --- a/pom.xml +++ b/pom.xml @@ -25,13 +25,13 @@ io.wcm io.wcm.wcm.core.components.parent - 1.14.0-2.23.2 + 2.0.0-2.23.2 parent/pom.xml io.wcm io.wcm.wcm.core.components.root - 1.14.0-2.23.2 + 2.0.0-2.23.2 pom ${site.url}/${site.url.module.prefix}/ diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index 1faa4332..2eac6413 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -35,6 +35,7 @@ There is currently no added wcm.io support for the Core Component AMP extensions |wcm.io WCM Core Components version | AEM Sites Core Component version | AEM version supported |-----------------------------------|----------------------------------|--------------------------------------------- +| 2.0.0-2.23.2 | 2.23.2 and up | AEM 6.5.17, AEMaaCS | 1.14.0-2.23.2 | 2.23.2 and up | AEM 6.5.17, AEMaaCS | 1.13.0-2.22.6 | 2.22.6 and up | AEM 6.5.14, AEMaaCS | 1.12.0-2.20.0 | 2.20.0 and up | AEM 6.5.13, AEMaaCS