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

Parameterized renditions #1029

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

davidjgonzalez
Copy link
Contributor

@davidjgonzalez davidjgonzalez commented Oct 27, 2023

Description

This adds parameter support to Asset Rendtions.

So now, instead of only passing in the renditionName, you can pass in the rendtionName as well as arbitrary parameters.

HTTP API

HTTP GET /content/dam/test.png.renditions/my-parameterized-rendition-name/asset.rendition?param1=foo@param2=bar

Or for downloads, pass in the renditionName HTTP POST form value:

my-parameterized-rendition-name?param1=foo@param2=bar

This requires an OSGi config for the appropriate Asset Rendition dispatcher to be created that has a mapping of the my-parameterized-rendition-name` whose value has placeholders corresponding to the provided params.

For examples:

com.adobe.aem.commons.assetshare.content.renditions.impl.dispatchers.StaticRenditionDispatcherImpl-parameterized.cfg.json

{
  "service.ranking:Integer": -10001,
  "label": "Static Image Renditions User Defined",
  "name": "asset-share-commons-parameterized-static-image-renditions",
  "types": [
    "image"
  ],
  "rendition.mappings": [
    "my-parameterized-rendition-name=(.*)${param1}(.*)"
  ],
  "hidden": true
}

would look for static renditions that match the regex (.*)foo(.*) ...

This can be used in any of the OOTB rendition dispatchers (External, Asset Delivery, etc.)

It is recommended that each definition uses a unique rendition name (left side of the renditionName=mapping rule in the OSGi config). It is also recommended to use this with hidden: true in the OSGI config as none of the OOTB ASC components have anyway to provide extra parameters, so they shouldnt be selectable by authors in these components.

THese are best use "hardcoded" into code to serve images, w/ params specified using some custom logic, or via custom dialogs that accept the expected params.

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link

codecov bot commented Dec 18, 2023

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (101d373) 27.59% compared to head (cb99e06) 27.86%.
Report is 9 commits behind head on develop.

❗ Current head cb99e06 differs from pull request most recent head 51948ba. Consider uploading reports for the commit 51948ba to get more accurate results

Files Patch % Lines
...e/content/renditions/AssetRenditionParameters.java 79.48% 5 Missing and 3 partials ⚠️
...nc/impl/NamedRenditionDownloadTargetProcessor.java 0.00% 6 Missing ⚠️
...patchers/AssetDeliveryRenditionDispatcherImpl.java 0.00% 5 Missing ⚠️
.../assetshare/util/impl/ExpressionEvaluatorImpl.java 71.42% 0 Missing and 2 partials ⚠️
...hare/components/actions/impl/ActionHelperImpl.java 0.00% 0 Missing and 1 partial ⚠️
...content/renditions/impl/AssetRenditionServlet.java 66.66% 0 Missing and 1 partial ⚠️
...chers/ExternalRedirectRenditionDispatcherImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #1029      +/-   ##
=============================================
+ Coverage      27.59%   27.86%   +0.27%     
- Complexity       535      539       +4     
=============================================
  Files            179      179              
  Lines           4657     4704      +47     
  Branches         658      663       +5     
=============================================
+ Hits            1285     1311      +26     
- Misses          3189     3206      +17     
- Partials         183      187       +4     
Flag Coverage Δ
unittests 27.86% <69.62%> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@davidjgonzalez davidjgonzalez marked this pull request as ready for review December 18, 2023 18:48
@davidjgonzalez davidjgonzalez added this to the 4.0.0 milestone Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant