Skip to content

Conversation

@LSantha
Copy link
Collaborator

@LSantha LSantha commented Oct 7, 2021

  • added Sling rewriter for link transformation
  • added unit tests

Description

Create a TransformerFactory in the global rewriter pipeline to rewrite the anchor tags with a data-product-sku or data-categroy-uid attribute.

Related Issue

CIF-2388

How Has This Been Tested?

Manually, JUnit.

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 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 and the overall coverage did not decrease.
  • All unit tests pass on CircleCi.
  • I ran all tests locally and they pass.

 * added Sling rewriter for link transformation
 * added unit tests
@codecov
Copy link

codecov bot commented Oct 7, 2021

Codecov Report

Merging #712 (2797818) into master (b3ec424) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #712      +/-   ##
============================================
+ Coverage     88.77%   88.82%   +0.05%     
- Complexity     1657     1663       +6     
============================================
  Files           290      291       +1     
  Lines          7306     7340      +34     
  Branches       1073     1078       +5     
============================================
+ Hits           6486     6520      +34     
  Misses          615      615              
  Partials        205      205              
Flag Coverage Δ
integration 58.46% <41.17%> (-0.15%) ⬇️
jest 86.15% <ø> (ø)
karma 89.86% <ø> (ø)
unittests 89.24% <100.00%> (+0.08%) ⬆️

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

Impacted Files Coverage Δ
...rnal/services/CommerceLinksTransformerFactory.java 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b3ec424...2797818. Read the comment docs.

Copy link
Contributor

@mhaack mhaack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general though: why is this part of the CIF Core Components project? This relates to authoring functionality and therefor to me belongs to CIF authoring add-on.

immediate = true,
service = TransformerFactory.class,
property = {
"pipeline.type=ciflinks"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only naming but I would prefer commercelinks.

property = {
"pipeline.type=ciflinks"
})
public class CifLinksTransformerFactory implements TransformerFactory {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here either us Commerce as class name start or remove Cif at all this is already in the commerce package.

@buuhuu
Copy link
Contributor

buuhuu commented Oct 8, 2021

As a general though: why is this part of the CIF Core Components project? This relates to authoring functionality and therefor to me belongs to CIF authoring add-on.

Link rewriting is not an authoring functionality (e.g. the Link Checker, etc.). This implementation is in the CIF Core Components because it has a direct dependency to the UrlProvider.

if (newHref != null) {
String href = attributes.getValue(ATTR_HREF);
AttributesImpl attributesImpl;
if (StringUtils.isNotBlank(href)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not overwrite the href if it exists with a non bank value. Such a href should have precedence over the product/category link because it is an editors choice to set the href.

Also you should check this condition before you call the UrlProvider and (potentially) do a gql request.

@mhaack
Copy link
Contributor

mhaack commented Oct 8, 2021

This implementation is in the CIF Core Components because it has a direct dependency to the UrlProvider.

Yes you are right with that it must be part of this project. However it still has sort of API, at least a dependency since it works with the data attributes used by the RTE extension.

@buuhuu
Copy link
Contributor

buuhuu commented Oct 8, 2021

We defined this contract in the context of the associated content feature #647.

@mhaack
Copy link
Contributor

mhaack commented Oct 8, 2021

I know, we maybe just should put this somewhere more visible in the docs somewhere.

@LSantha
Copy link
Collaborator Author

LSantha commented Oct 8, 2021

I've renamed the transformer and also improved the transformation logic.

@mhaack mhaack added the enhancement New feature or request label Oct 12, 2021
LSantha and others added 4 commits October 12, 2021 12:54
 * added commerce links transformer to the global pipeline
 * added OSGi config to enable/disabled the transformer, enabled by default
 * updated unit test
 * fixing IT failure: commerce attributes should be preserved on the links
@laurentiumagureanu laurentiumagureanu merged commit 7ff61b2 into master Oct 15, 2021
@laurentiumagureanu laurentiumagureanu deleted the CIF-2388 branch October 15, 2021 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants