Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.3.8.12 #1160

Merged
merged 19 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
3bf9a8c
Bump org.apache.jackrabbit:filevault-package-maven-plugin
dependabot[bot] Jul 1, 2024
ed4409b
Bump org.apache.maven.plugins:maven-install-plugin from 3.1.1 to 3.1.2
dependabot[bot] Jul 1, 2024
0dedbf6
Bump org.apache.maven.plugins:maven-compiler-plugin
dependabot[bot] Jul 1, 2024
2a1a5f6
Merge pull request #1153 from adobe/dependabot/maven/org.apache.maven…
davidjgonzalez Jul 8, 2024
79dfcc2
Merge pull request #1152 from adobe/dependabot/maven/org.apache.maven…
davidjgonzalez Jul 8, 2024
5bd7171
Merge pull request #1150 from adobe/dependabot/maven/org.apache.jackr…
davidjgonzalez Jul 8, 2024
1dc1bb5
Bump org.sonatype.plugins:nexus-staging-maven-plugin
dependabot[bot] Jul 15, 2024
c70498a
Bump org.apache.maven.plugins:maven-surefire-plugin from 3.1.2 to 3.3.1
dependabot[bot] Jul 15, 2024
52e0a18
Bump com.github.spotbugs:spotbugs-maven-plugin from 4.7.3.4 to 4.8.6.2
dependabot[bot] Jul 15, 2024
1e54730
Added missing image support to search results
davidjgonzalez Jul 22, 2024
8e6aabc
Added test
davidjgonzalez Jul 22, 2024
21f216d
Added Cloud Manager build flags for cloud
davidjgonzalez Jul 22, 2024
cdacc14
Fixed data-asset-share-missing-image attribute name
davidjgonzalez Jul 22, 2024
eb9854c
Added asset format null check
davidjgonzalez Jul 22, 2024
64747ab
Added tests to cover missing dc:format cases
davidjgonzalez Jul 22, 2024
e4f452b
Merge pull request #1159 from davidjgonzalez/oft
davidjgonzalez Jul 22, 2024
0cb0940
Merge pull request #1158 from adobe/dependabot/maven/com.github.spotb…
davidjgonzalez Jul 22, 2024
e198853
Merge pull request #1157 from adobe/dependabot/maven/org.apache.maven…
davidjgonzalez Jul 22, 2024
bca44dd
Merge pull request #1156 from adobe/dependabot/maven/org.sonatype.plu…
davidjgonzalez Jul 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
<id>cloud</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>env.CM_BUILD</name>
</property>
</activation>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,13 @@ public boolean accepts(AssetModel assetModel, String renditionName) {
final String assetFormat = StringUtils.lowerCase(assetModel.getProperties().get(DamConstants.DC_FORMAT, String.class));

// Return true if assetFormat matches any regex in ALLOWED_MIME_TYPES
return Arrays.stream(ACCEPTED_MIME_TYPES).anyMatch(regex -> assetFormat.matches(regex));
if (StringUtils.isBlank(assetFormat)) {
// If the asset format is not set, we can't determine if it's an image or document, so we can't use Asset Delivery
return false;
} else {
// Otherwise, check if the asset format is an image or document
return Arrays.stream(ACCEPTED_MIME_TYPES).anyMatch(regex -> assetFormat.matches(regex));
}
}

protected String evaluateExpression(final SlingHttpServletRequest request, String expression) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package com.adobe.aem.commons.assetshare.content.renditions.impl.dispatchers;

import com.adobe.aem.commons.assetshare.content.AssetModel;
import com.adobe.aem.commons.assetshare.content.impl.AssetModelImpl;
import com.adobe.aem.commons.assetshare.content.renditions.AssetRenditionDispatcher;
import com.adobe.aem.commons.assetshare.content.renditions.impl.AssetRenditionsImpl;
import com.adobe.aem.commons.assetshare.testing.MockAssetModels;
import com.adobe.aem.commons.assetshare.testing.RequireAemMock;
import com.adobe.aem.commons.assetshare.util.ExpressionEvaluator;
import com.adobe.aem.commons.assetshare.util.RequireAem;
import com.adobe.aem.commons.assetshare.util.impl.ExpressionEvaluatorImpl;
import com.adobe.cq.dam.download.api.DownloadTarget;
import com.adobe.cq.wcm.spi.AssetDelivery;
import io.wcm.testing.mock.aem.junit.AemContext;
import org.apache.sling.commons.mime.MimeTypeService;
import org.apache.sling.models.factory.ModelFactory;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

@RunWith(MockitoJUnitRunner.class)
public class AssetDeliveryRenditionDispatcherImplTest {
@Rule
public AemContext ctx = new AemContext();

@Mock
MimeTypeService mimeTypeService;

@Mock
DownloadTarget downloadTarget;

@Mock
ModelFactory modelFactory;

@Mock
AssetDelivery assetDelivery;

@Before
public void setUp() throws Exception {
ctx.load().json(getClass().getResourceAsStream("AssetDeliveryRenditionDispatcherImplTest.json"), "/content");

RequireAemMock.setAem(ctx,
RequireAem.Distribution.CLOUD_READY,
RequireAem.ServiceType.AUTHOR);

ctx.addModelsForClasses(AssetModelImpl.class);

MockAssetModels.mockModelFactory(ctx, modelFactory, "/content/dam/test.png");
MockAssetModels.mockModelFactory(ctx, modelFactory, "/content/dam/test.oft");

ctx.registerService(ModelFactory.class, modelFactory, org.osgi.framework.Constants.SERVICE_RANKING,
Integer.MAX_VALUE);


ctx.registerService(AssetDelivery.class, assetDelivery);
ctx.registerService(MimeTypeService.class, mimeTypeService);
ctx.registerService(ExpressionEvaluator.class, new ExpressionEvaluatorImpl());

ctx.registerInjectActivateService(new AssetRenditionsImpl());

ctx.registerInjectActivateService(new AssetDeliveryRenditionDispatcherImpl(), "rendition.mappings", new String[]{"test=foo"});
}

@Test
public void testAccepts_True() throws Exception {
ctx.currentResource("/content/dam/test.png");
AssetModel assetModel = ctx.request().adaptTo(AssetModel.class);

AssetRenditionDispatcher dispatcher = ctx.getService(AssetRenditionDispatcher.class);

assertTrue("PNG should be accepted", dispatcher.accepts(assetModel, "test"));
}

@Test
public void testAccepts_False() throws Exception {
ctx.currentResource("/content/dam/test.oft");
AssetModel assetModel = ctx.request().adaptTo(AssetModel.class);

AssetRenditionDispatcher dispatcher = ctx.getService(AssetRenditionDispatcher.class);

assertFalse("OFT should not be accepted", dispatcher.accepts(assetModel, "test"));
}


@Test
public void testAccepts_NoDcFormat_False() {
ctx.currentResource("/content/dam/test.no-dc-format");
AssetModel assetModel = ctx.request().adaptTo(AssetModel.class);

AssetRenditionDispatcher dispatcher = ctx.getService(AssetRenditionDispatcher.class);

assertFalse("Missing dc:format should not be accepted", dispatcher.accepts(assetModel, "test"));
}


@Test
public void testAccepts_BlankDcFormat_False() {
ctx.currentResource("/content/dam/test.blank-dc-format");
AssetModel assetModel = ctx.request().adaptTo(AssetModel.class);

AssetRenditionDispatcher dispatcher = ctx.getService(AssetRenditionDispatcher.class);

assertFalse("Blank dc:format should not be accepted", dispatcher.accepts(assetModel, "test"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"dam": {
"test.png": {
"jcr:primaryType": "dam:Asset",
"jcr:content": {
"jcr:primaryType": "nt:unstructured",
"metadata": {
"jcr:primaryType": "nt:unstructured",
"dc:format": "image/png"
},
"renditions": {
"jcr:primaryType": "nt:unstructured",
"cq5dam.web.1280.1280.png": {
"jcr:primaryType": "nt:file",
"jcr:content": {
"jcr:primaryType": "oak:Resource",
"jcr:mimeType": "image/png"
}
}
}
}
},
"test.oft": {
"jcr:primaryType": "dam:Asset",
"jcr:content": {
"jcr:primaryType": "nt:unstructured",
"metadata": {
"jcr:primaryType": "nt:unstructured",
"dc:format": "application/vnd.oasis.opendocument.text"
},
"renditions": {
"jcr:primaryType": "nt:unstructured",
"cq5dam.web.1280.1280.png": {
"jcr:primaryType": "nt:file",
"jcr:content": {
"jcr:primaryType": "oak:Resource",
"jcr:mimeType": "image/png"
}
}
}
}
},
"test.no-dc-format": {
"jcr:primaryType": "dam:Asset",
"jcr:content": {
"jcr:primaryType": "nt:unstructured",
"metadata": {
"jcr:primaryType": "nt:unstructured"
},
"renditions": {
"jcr:primaryType": "nt:unstructured",
"cq5dam.web.1280.1280.png": {
"jcr:primaryType": "nt:file",
"jcr:content": {
"jcr:primaryType": "oak:Resource",
"jcr:mimeType": "image/png"
}
}
}
}
},
"test.blank-dc-format": {
"jcr:primaryType": "dam:Asset",
"jcr:content": {
"jcr:primaryType": "nt:unstructured",
"metadata": {
"jcr:primaryType": "nt:unstructured",
"dc:format": " "
},
"renditions": {
"jcr:primaryType": "nt:unstructured",
"cq5dam.web.1280.1280.png": {
"jcr:primaryType": "nt:file",
"jcr:content": {
"jcr:primaryType": "oak:Resource",
"jcr:mimeType": "image/png"
}
}
}
}
}
}
}
18 changes: 12 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,19 @@ Bundle-DocURL: https://opensource.adobe.com/asset-share-commons/
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.13.0</version>
</plugin>
<!-- Maven Installer Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.2</version>
</plugin>
<!-- Maven Surefire Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<version>3.3.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
Expand Down Expand Up @@ -334,7 +334,7 @@ Bundle-DocURL: https://opensource.adobe.com/asset-share-commons/
<plugin>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>filevault-package-maven-plugin</artifactId>
<version>1.3.4</version>
<version>1.3.6</version>
<extensions>true</extensions>
<configuration>
<filterSource>src/main/content/META-INF/vault/filter.xml</filterSource>
Expand Down Expand Up @@ -499,7 +499,7 @@ Bundle-DocURL: https://opensource.adobe.com/asset-share-commons/
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.7.3.4</version>
<version>4.8.6.2</version>
</plugin>
<!-- Maven Checkstyle Plugin -->
<plugin>
Expand Down Expand Up @@ -540,7 +540,7 @@ Bundle-DocURL: https://opensource.adobe.com/asset-share-commons/
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<version>1.7.0</version>
</plugin>
<!-- checks for vulnerabilities in dependencies -->
<plugin>
Expand Down Expand Up @@ -897,6 +897,12 @@ Bundle-DocURL: https://opensource.adobe.com/asset-share-commons/
the ones for AEM on prem are always built -->
<profile>
<id>cloud</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>env.CM_BUILD</name>
</property>
</activation>
<modules>
<module>core.cloud</module>
</modules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,14 @@
style="height:${height @ context = 'styleToken'}px;"
controls controlsList="nodownload"
data-sly-test.height="${properties['height']}">
<source src="${video.src}"
type="video/webm"/>
<source src="${video.src}"
type="video/mp4"/>

<source src="${video.src}" />
</video>

<!--/* Video element without a max height */-->
<video class="ui centered image cmp-image"
poster="${properties['posterImage']}" controls controlsList="nodownload"
data-sly-test="${!height}">
<source src="${video.src}"
type="video/webm"/>
<source src="${video.src}"
type="video/mp4" />
<source src="${video.src}"/>
</video>

</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#base=js

scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
document.addEventListener('DOMContentLoaded', function() {
const images = document.querySelectorAll('img[data-asset-share-missing-image]');
images.forEach(img => {
img.onerror = function() {
this.src = this.getAttribute('data-asset-share-missing-image');
Dismissed Show dismissed Hide dismissed
};
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
class="cmp-image--card"
width="237px"
height="175px"
data-asset-share-missing-image="${properties['missingImage']}"
alt="${asset.properties['title']}"/>
</a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<a class="cmp-card__link" href="${assetDetails.url @ suffix = asset.path}">
<img src="${asset.properties['rendition?name=card'] || properties['missingImage'] @ context = 'attribute'}"
class="cmp-card__image"
data-asset-share-missing-image="${properties['missingImage']}"
alt="${asset.properties['title']}"/>
</a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<td class="image">
<a href="${assetDetails.fullUrl}"><img src="${asset.properties['rendition?name=list'] || properties['missingImage'] @ context = 'attribute'}"
width="98px"
data-assets-share-missing-image="${properties['missingImage']}"
alt="${asset.properties['title']}"/></a>
</td>
<td class="header">
Expand Down
Loading