Skip to content

Conversation

@schaefa
Copy link

@schaefa schaefa commented Aug 23, 2019

…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

…jector (with default Provider) and an unit test
Copy link
Contributor

@paul-bjorkstrand paul-bjorkstrand left a 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
Copy link
Contributor

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.

Copy link
Author

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()
Copy link
Contributor

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.

Copy link
Author

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) {
Copy link
Contributor

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.

Copy link
Author

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
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

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

Done

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.

2 participants