-
Notifications
You must be signed in to change notification settings - Fork 595
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
Redirect Manager: Support for context aware configurations #2564
Redirect Manager: Support for context aware configurations #2564
Conversation
# Conflicts: # bundle/src/main/java/com/adobe/acs/commons/redirects/filter/RedirectFilter.java # bundle/src/main/java/com/adobe/acs/commons/redirects/models/package-info.java
Here's my test Excel file with ~50k rows if its useful. |
private static final long serialVersionUID = -3564475196678277711L; | ||
|
||
@Reference | ||
private RedirectFilterMBean redirectFilter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private RedirectFilterMBean redirectFilter; | |
private transient RedirectFilterMBean redirectFilter; |
The PR is finally in a good shape to get reviewed and applied. @davidjgonzalez Thanks for the spreadsheet. The tool can now swallow it without chocking. I did some load testing using Apache Benchmark and didn't see any significant performance impact with the ~50K set. BTW, I see you are using the .html extension in the mappings, e.g.
this is not quite correct. So far the assumption was to use extension-less paths to match request, e.g. the rule below will work but yours won't:
I'm inclined to change it to support both versions, with and without .html. It's a very common habit to append the .html extension and the code should support both. |
@YegorKozlov awesome! im gonna try to find time this week to check this out! im pumped! Also, I used the format of the real customer w/ the 50k redirects to mock out the format of this file, FWIW. |
The patch introduces support for context aware configurations in Redirect Manager. Users can put their redirects in the default storage or create configurations per-context.
UI Changes.
The UI is split into two parts. ACS AEM Commons / Manage Redirects opens the list of redirect configurations, where each config represents a table of redirect rules:
The default storage is /conf/global/settings/redirects . This node is created by a repo-init script . The bucket name 'settings' and config name 'redirects' are configurable via OSGi.
Click on a configuration opens the old UI to edit rules. The only change here is that the storage is explicitly passed in the url:
Adding rules to the default storage will result in a structure like this;
This requires zero configuration in content sites. Just put your redirects in the global list, replicate them to publish and they will work.
However, there can be cases where user will want to have different configurations for each site, for example, we-retail and wknd would havevtheir own tables of redirects, any other site will fallback to /conf/global :
Redirects for /content/we-retail
Redirects for /content/wknd
Redirects for other sites
Configuration Resolution
The code leverages org.apache.sling.caconfig.resource.ConfigurationResourceResolver#getResource(Resource resource, String bucketName, String configName) to lookup configurations based on context. If context config is not set then /conf/global is used as a fallback. In order to resolve contextual configurations a request needs read access to it, e.g. web request to /content/geometrixx/page1 needs to read /conf/global/settings/redirects This is enabled in the repo-init script
Example:
Upgrade rules created with v5.0.4
The default storage in v5.0.4 was /conf/acs-commons/redirects which is not compatible with context aware configurations. This means redirects previously defined under /conf/acs-commons/redirects need to be moved to /conf/global/settings/redirects
This is done automatically on first load of the GUI. The redirects are moved and user sees a message:
we can reflect it in the release notes too.
Changes in the 'Until Date' field
In v5.0.4 the 'Until Date' field was saved a 'dd MMMM yyyy' string, e.g. '16 February 2001'. This implementation had two issues
This patch changes untilDate to be saved as a JCR Date. Any previously saved untilDate are converted. See RedirectManager: problems with non-english locale #2569
Paginated output
Each redirect on http://localhost:4502/apps/acs-commons/content/redirect-manager.html is rendered as a sly-resource which can result in a 'Too Many Includes' exception when the number of redirects is large (greater than 1500, configurable in org.apache.sling.engine.impl.SlingMainServlet) To avoid this error redirects are paginated . The pages size is 1000. If the number of redirects is less than 1000 then user will use the usual UI. If the number of redirects is greater than 100 the user will see the 1st page and a navigation bar below:
For now search works within the current page only.
New Optional "Notes" field
See #2571
The "Create Rule" dialog now includes a new optional field "Notes"