Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Mar 13, 2024
2 parents 30f5c00 + b364032 commit f2fbced
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bundles/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<parent>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.wcm.core.components.parent</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm</groupId>
<artifactId>io.wcm.wcm.core.components</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<packaging>jar</packaging>

<name>WCM Core Components</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 6 additions & 0 deletions changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<body>

<release version="2.0.2-2.23.2" date="2024-03-13">
<action type="fix" dev="sseifert" issue="20">
Download (v1/v2): Don't display file size if it is not available.
</action>
</release>

<release version="2.0.0-2.23.2" date="2024-01-26">
<action type="update" dev="sseifert"><![CDATA[
Version 2.0.0-2.23.2 requires Handler 2.x, See <a href=https://wcm-io.atlassian.net/wiki/x/AYBxsw">Migrate from wcm.io Handler 1.x to 2.x</a> for details.
Expand Down
6 changes: 3 additions & 3 deletions examples/bundles/examples-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<parent>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.wcm.core.components.parent</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm.samples</groupId>
<artifactId>io.wcm.wcm.core.components.examples-core</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<packaging>jar</packaging>

<name>WCM Core Components Examples Core</name>
Expand All @@ -44,7 +44,7 @@
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.wcm.core.components</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<scope>compile</scope>
</dependency>

Expand Down
6 changes: 3 additions & 3 deletions examples/content-packages/examples-libs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<parent>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.wcm.core.components.parent</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm.samples</groupId>
<artifactId>io.wcm.wcm.core.components.examples-libs</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<packaging>content-package</packaging>

<name>WCM Core Components Examples wcm.io Libraries</name>
Expand All @@ -42,7 +42,7 @@
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.wcm.core.components</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<scope>compile</scope>
</dependency>

Expand Down
4 changes: 2 additions & 2 deletions examples/content-packages/examples-sample-content/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<parent>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.wcm.core.components.parent</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm.samples</groupId>
<artifactId>io.wcm.wcm.core.components.examples-sample-content</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<packaging>content-package</packaging>

<name>WCM Core Components Examples Content</name>
Expand Down
6 changes: 3 additions & 3 deletions examples/content-packages/examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<parent>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.wcm.core.components.parent</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm.samples</groupId>
<artifactId>io.wcm.wcm.core.components.examples</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<packaging>content-package</packaging>

<name>WCM Core Components Examples</name>
Expand All @@ -42,7 +42,7 @@
<dependency>
<groupId>io.wcm.samples</groupId>
<artifactId>io.wcm.wcm.core.components.examples-core</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<scope>compile</scope>
</dependency>

Expand Down
4 changes: 2 additions & 2 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<parent>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.wcm.core.components.parent</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm.samples</groupId>
<artifactId>io.wcm.wcm.core.components.examples.root</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<packaging>pom</packaging>

<modules>
Expand Down
4 changes: 2 additions & 2 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<groupId>io.wcm</groupId>
<artifactId>io.wcm.wcm.core.components.parent</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<packaging>pom</packaging>

<name>WCM Core Components</name>
Expand All @@ -54,7 +54,7 @@
<sling.publish.url>http://localhost:4503</sling.publish.url>

<!-- Enable reproducible builds -->
<project.build.outputTimestamp>2024-01-26T20:12:08Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2024-03-13T09:40:21Z</project.build.outputTimestamp>
</properties>

<dependencyManagement>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<parent>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.wcm.core.components.parent</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<relativePath>parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm</groupId>
<artifactId>io.wcm.wcm.core.components.root</artifactId>
<version>2.0.0-2.23.2</version>
<version>2.0.2-2.23.2</version>
<packaging>pom</packaging>
<url>${site.url}/${site.url.module.prefix}/</url>

Expand Down

0 comments on commit f2fbced

Please sign in to comment.