@ConsumerType public interface ExperienceFragmentLinkRewriterProvider
This is an extension point offered to clients in order to allow link rewriting for the Export to Target feature.
Services implementing this interface will be called during the Export To Target offer content generation for HTML.
When an Export to Target call is made in the AEM Experience Fragment console, the body of the HTML content is
generated through a request to an Experience Fragment with the selector
atoffer.html. However, before this
HTML content can be sent to Target, we would have to rewrite the links present throughout the content
in such a way so that they point to resources on the publish instance, where they can be accessed publicly.
We already rewrite these links using Externalizer, but if there is the need for more customization,
a service can implement this interface in order to take control of the link rewriting process.
For example, a call is made to
During the Sling Rewriter phase, Sling will parse each node of the HTML output (called tag).
At this time, if there is any service implementing this interface, the "shouldRewrite" method is called in order
to establish if the current Experience Fragment should have links rewritten. If the method returns true, then
our system doesn't make any more modifications to the link, but lets the service handle the rewriting through the
Currently, only one
ExperienceFragmentLinkRewriterProvider for an Experience Fragment is permitted.
If there are multiple providers for an Experience Fragment, only the one with the highest priority is chosen.
Priority is determined by the providers
getPriority() method. If there are several
ExperienceFragmentLinkRewriterProvider with the same priority, then only one will be chosen.
|Modifier and Type||Method and Description|
If there are several providers for which the
This method receives a String which represents the location of the resource on the author instance.
This method receives the Resource which represents the Experience Fragment that is currently being processed by the Sling Rewriter framework.
java.lang.String rewriteLink(java.lang.String link, java.lang.String tag, java.lang.String attribute)
The type of attributes that will be processed are the following:
-hrefin their name
-srcin their name
link this method receives is usually an URI in the form of
/path/to/resource. To note that in
some cases, the URI might differ, due to the effects of the
html selector on a component inside
the Experience Fragments. In other words, if there are custom components in your Experience Fragment, then
the link received in this method might be different, depending on its implementation. Our out-of-the-box components
are rendered as a path to the resource, as mentioned previously.
Besides the link, the method also receives the local attribute name, so that implementations can easily distinguish
what attributes from the above set is currently being processed (e.g. there can be
that an implementation might not want to change).
The last parameter is the tag name that is currently being processed, that can be helpful in the case some
resources should not be changed, such as
link attributes when the purpose is embedding inside another page.
The method should return a valid link to the resource, that can be accessed publicly. This link will be
then placed in the corresponding attribute and tag.
An example of an output for a regular case is the mapped public facing URL to a resource:
How the output should look like is an implementation detail left to the service that implements this interface.
The regular use case is that the Target Offer is embedded inside other HTML pages as a separate
then delivered to clients or used in other places, and as such all the links inside this Target Offer should be
able to be accessed by anyone.
If the method returns null, then no rewrite will be done and the link will remain the same.
link- - the value of the attribute, which is usually an internal URI (e.g. /path/to/resource)
tag- - the name of the node that is currently modified
attribute- - the name of the attribute that is currently modified
http[s]://[public_instance]/path/to/resource), or null
boolean shouldRewrite(ExperienceFragmentVariation experienceFragment)
Should return true if the service implementing this interface should be used on rewriting links for the experience fragment variation given.
experienceFragment- - the experience fragment that is currently processed
shouldRewritereturns true for a particular ExperienceFragmentVariation, then the one with the highest priority is used.
Copyright © 2010 - 2020 Adobe. All Rights Reserved