-
Notifications
You must be signed in to change notification settings - Fork 30
SLING-8655 - Updated dependency on API, provided Externalized Path In… #14
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
base: master
Are you sure you want to change the base?
Conversation
…jector (with default Provider) and an unit test
paul-bjorkstrand
left a comment
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.
Not to push this too far out of scope, but have you given any thought on modifying link URLs inside rich text?
| } | ||
|
|
||
| /** Fallback Implementation of the Externalized Path Provider that uses the Resource Resolver's map function **/ | ||
| private class DefaultExternalizedPathProvider |
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.
This should be at least a static class, as it does not use its enclosing class at all. I would probably move this into its own class and make it a proper @Component.
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.
Moved this to be an regular OSGi Component
| // The providers are sorted so that the one with the highest priority is the first entry | ||
| Collections.sort( | ||
| providerList, | ||
| Comparator.comparingInt(ExternalizedPathProvider::getPriority).reversed() |
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.
Instead of sorting based on a new field called priority, you should probably use service.ranking of the implementations. Perhaps you want to look at how ModelAdapterFactory uses ranked services.
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.
Used RankedServices as suggested
| } | ||
| if (element.isAnnotationPresent(ExternalizePath.class)) { | ||
| ValueMap properties = getValueMap(adaptable); | ||
| if(properties != ObjectUtils.NULL) { |
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.
nitpicky formatting on this if and the if on line 85 as well.
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.
Fixed that
| assertEquals("Wrong Provider was selected", mappedImagePath3, value); | ||
| } | ||
|
|
||
| private class TestExternalizedPathProvider |
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.
Similar to above, when you are not using the enclosing class data, the nested class should be static
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.
Done
…jector (with default Provider) and an unit test
This PR depends on PR of the Sling Models API: apache/sling-org-apache-sling-models-api#2