diff --git a/.github/workflows/maven-deploy.yml b/.github/workflows/maven-deploy.yml
index c709b1c..763171a 100644
--- a/.github/workflows/maven-deploy.yml
+++ b/.github/workflows/maven-deploy.yml
@@ -25,7 +25,7 @@ jobs:
git config --global user.name "${{ secrets.GH_SITE_DEPLOY_NAME }}"
- name: Setup JDK
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml
index 36d889c..17a912c 100644
--- a/bundles/core/pom.xml
+++ b/bundles/core/pom.xml
@@ -25,13 +25,13 @@
io.wcm
io.wcm.wcm.core.components.parent
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
../../parent/pom.xml
io.wcm
io.wcm.wcm.core.components
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
jar
WCM Core Components
diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/DownloadV1V2Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/DownloadV1V2Impl.java
index 8a87681..dd438c5 100644
--- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/DownloadV1V2Impl.java
+++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/v1/DownloadV1V2Impl.java
@@ -130,7 +130,7 @@ private void initPropertiesFromMedia() {
if (rendition != null) {
filename = rendition.getFileName();
format = rendition.getMimeType();
- size = FileUtils.byteCountToDisplaySize(rendition.getFileSize());
+ size = toDisplayFileSize(rendition.getFileSize());
extension = rendition.getFileExtension();
}
@@ -151,6 +151,13 @@ private void initPropertiesFromMedia() {
}
}
+ private static String toDisplayFileSize(long fileSize) {
+ if (fileSize > 0) {
+ return FileUtils.byteCountToDisplaySize(fileSize);
+ }
+ return null;
+ }
+
@Override
@NotNull
public Media getMediaObject() {
diff --git a/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v1/DownloadV1V2ImplTest.java b/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v1/DownloadV1V2ImplTest.java
index 7bc4f71..4fe8802 100644
--- a/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v1/DownloadV1V2ImplTest.java
+++ b/bundles/core/src/test/java/io/wcm/wcm/core/components/impl/models/v1/DownloadV1V2ImplTest.java
@@ -48,6 +48,8 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.io.ByteArrayInputStream;
+
import org.apache.sling.api.resource.Resource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -172,6 +174,26 @@ void testAssetReference_Inline(String resourceType) {
String expectedMediaUrl = "/content/dam/sample/file1.pdf/_jcr_content/renditions/original./file1.pdf";
assertEquals(expectedMediaUrl, underTest.getUrl());
+ assertEquals("15 KB", underTest.getSize());
+
+ assertValidMedia(underTest, expectedMediaUrl);
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = { RESOURCE_TYPE_V1, RESOURCE_TYPE_V2 })
+ void testAssetReference_Inline_0size(String resourceType) {
+ Asset asset = context.create().asset(DAM_ROOT + "/file1.pdf", new ByteArrayInputStream(new byte[0]), ContentType.PDF);
+
+ context.currentResource(context.create().resource(page, "download",
+ PROPERTY_RESOURCE_TYPE, resourceType,
+ PN_MEDIA_REF_STANDARD, asset.getPath(),
+ PN_INLINE, true));
+ Download underTest = AdaptTo.notNull(context.request(), Download.class);
+
+ String expectedMediaUrl = "/content/dam/sample/file1.pdf/_jcr_content/renditions/original./file1.pdf";
+
+ assertEquals(expectedMediaUrl, underTest.getUrl());
+ assertNull(underTest.getSize());
assertValidMedia(underTest, expectedMediaUrl);
}
diff --git a/changes.xml b/changes.xml
index 5c1f052..48c1ff8 100644
--- a/changes.xml
+++ b/changes.xml
@@ -23,6 +23,12 @@
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
+
+
+ Download (v1/v2): Don't display file size if it is not available.
+
+
+
Migrate from wcm.io Handler 1.x to 2.x for details.
diff --git a/examples/bundles/examples-core/pom.xml b/examples/bundles/examples-core/pom.xml
index dc38ce5..f5b386e 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
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
../../../parent/pom.xml
io.wcm.samples
io.wcm.wcm.core.components.examples-core
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
jar
WCM Core Components Examples Core
@@ -44,7 +44,7 @@
io.wcm
io.wcm.wcm.core.components
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
compile
diff --git a/examples/content-packages/examples-libs/pom.xml b/examples/content-packages/examples-libs/pom.xml
index 591e6f4..b3394ae 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
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
../../../parent/pom.xml
io.wcm.samples
io.wcm.wcm.core.components.examples-libs
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
content-package
WCM Core Components Examples wcm.io Libraries
@@ -42,7 +42,7 @@
io.wcm
io.wcm.wcm.core.components
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
compile
diff --git a/examples/content-packages/examples-sample-content/pom.xml b/examples/content-packages/examples-sample-content/pom.xml
index 71deadd..a9522ca 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
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
../../../parent/pom.xml
io.wcm.samples
io.wcm.wcm.core.components.examples-sample-content
- 2.0.0-2.23.2
+ 2.0.2-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 352c963..2187e8f 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
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
../../../parent/pom.xml
io.wcm.samples
io.wcm.wcm.core.components.examples
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
content-package
WCM Core Components Examples
@@ -42,7 +42,7 @@
io.wcm.samples
io.wcm.wcm.core.components.examples-core
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
compile
diff --git a/examples/pom.xml b/examples/pom.xml
index 6c77a40..1fcaf0d 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -25,13 +25,13 @@
io.wcm
io.wcm.wcm.core.components.parent
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
../parent/pom.xml
io.wcm.samples
io.wcm.wcm.core.components.examples.root
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
pom
diff --git a/parent/pom.xml b/parent/pom.xml
index e86998c..da650dc 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -31,7 +31,7 @@
io.wcm
io.wcm.wcm.core.components.parent
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
pom
WCM Core Components
@@ -54,7 +54,7 @@
http://localhost:4503
- 2024-01-26T20:12:08Z
+ 2024-03-13T09:40:21Z
diff --git a/pom.xml b/pom.xml
index e88db5e..f2dab6f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,13 +25,13 @@
io.wcm
io.wcm.wcm.core.components.parent
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
parent/pom.xml
io.wcm
io.wcm.wcm.core.components.root
- 2.0.0-2.23.2
+ 2.0.2-2.23.2
pom
${site.url}/${site.url.module.prefix}/