-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Web Optimized Image Delivery (part of Next Generation…
… Dynamic Media)
- Loading branch information
1 parent
7575b83
commit ed1f965
Showing
5 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...va/io/wcm/handler/mediasource/dam/impl/dynamicmedia/WebOptimizedImageDeliveryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* #%L | ||
* wcm.io | ||
* %% | ||
* Copyright (C) 2024 wcm.io | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
package io.wcm.handler.mediasource.dam.impl.dynamicmedia; | ||
|
||
/** | ||
* Supports rendering asset renditions from stored in AEMaaCS sites instance via Next Generation Dynamic Media | ||
* "Web Optimized Image Delivery", rendering the renditions on the edge. | ||
* This is not available in AEM 6.5 or AEMaaCS SDK. | ||
*/ | ||
public interface WebOptimizedImageDeliveryService { | ||
|
||
/** | ||
* @return Whether AEM AssetDelivery service is available and the support is enabled. | ||
*/ | ||
boolean isEnabled(); | ||
|
||
} |
67 changes: 67 additions & 0 deletions
67
...o/wcm/handler/mediasource/dam/impl/dynamicmedia/WebOptimizedImageDeliveryServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* #%L | ||
* wcm.io | ||
* %% | ||
* Copyright (C) 2024 wcm.io | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
package io.wcm.handler.mediasource.dam.impl.dynamicmedia; | ||
|
||
import org.osgi.service.component.annotations.Activate; | ||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.Reference; | ||
import org.osgi.service.component.annotations.ReferenceCardinality; | ||
import org.osgi.service.component.annotations.ReferencePolicyOption; | ||
import org.osgi.service.metatype.annotations.AttributeDefinition; | ||
import org.osgi.service.metatype.annotations.Designate; | ||
import org.osgi.service.metatype.annotations.ObjectClassDefinition; | ||
|
||
import com.adobe.cq.wcm.spi.AssetDelivery; | ||
|
||
/** | ||
* Implements {@link WebOptimizedImageDeliveryService}. | ||
*/ | ||
@Component(service = WebOptimizedImageDeliveryService.class, immediate = true) | ||
@Designate(ocd = WebOptimizedImageDeliveryServiceImpl.Config.class) | ||
public class WebOptimizedImageDeliveryServiceImpl implements WebOptimizedImageDeliveryService { | ||
|
||
@ObjectClassDefinition( | ||
name = "wcm.io Web Optimized Image Delivery Support", | ||
description = "Support for Next Generation Dynamic Media Web Optimized Image Delivery capabilites.") | ||
@interface Config { | ||
|
||
@AttributeDefinition( | ||
name = "Enabled", | ||
description = "Enable support for Web Optimized Delivery (if available).") | ||
boolean enabled() default true; | ||
|
||
} | ||
|
||
@Reference(cardinality = ReferenceCardinality.OPTIONAL, policyOption = ReferencePolicyOption.GREEDY) | ||
private AssetDelivery assetDelivery; | ||
|
||
private boolean enabled; | ||
|
||
@Activate | ||
private void activate(Config config) { | ||
this.enabled = config.enabled(); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return enabled && this.assetDelivery != null; | ||
} | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
...m/handler/mediasource/dam/impl/dynamicmedia/WebOptimizedImageDeliveryServiceImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* #%L | ||
* wcm.io | ||
* %% | ||
* Copyright (C) 2024 wcm.io | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
package io.wcm.handler.mediasource.dam.impl.dynamicmedia; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import io.wcm.handler.media.testcontext.AppAemContext; | ||
import io.wcm.testing.mock.aem.dam.MockAssetDelivery; | ||
import io.wcm.testing.mock.aem.junit5.AemContext; | ||
import io.wcm.testing.mock.aem.junit5.AemContextExtension; | ||
|
||
@ExtendWith(AemContextExtension.class) | ||
class WebOptimizedImageDeliveryServiceImplTest { | ||
|
||
private final AemContext context = AppAemContext.newAemContext(); | ||
|
||
@Test | ||
void testEnabled_AssetDeliveryNotPresent() { | ||
WebOptimizedImageDeliveryService underTest = context.registerInjectActivateService(WebOptimizedImageDeliveryServiceImpl.class); | ||
assertFalse(underTest.isEnabled()); | ||
} | ||
|
||
@Test | ||
void testEnabled_AssetDeliveryPresent() { | ||
context.registerInjectActivateService(MockAssetDelivery.class); | ||
WebOptimizedImageDeliveryService underTest = context.registerInjectActivateService(WebOptimizedImageDeliveryServiceImpl.class); | ||
assertTrue(underTest.isEnabled()); | ||
} | ||
|
||
@Test | ||
void testEnabled_AssetDeliveryPresent_Disabled() { | ||
context.registerInjectActivateService(MockAssetDelivery.class); | ||
WebOptimizedImageDeliveryService underTest = context.registerInjectActivateService(WebOptimizedImageDeliveryServiceImpl.class, | ||
"enabled", false); | ||
assertFalse(underTest.isEnabled()); | ||
} | ||
|
||
} |