Last active
January 31, 2020 10:46
Star
You must be signed in to star a gist
Show all Magnolia Virtual URI mappings that matched a given URI and their associated weights
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Field private registry | |
| import groovy.transform.Field | |
| import info.magnolia.objectfactory.Components | |
| import info.magnolia.virtualuri.VirtualUriRegistry | |
| import static java.util.stream.Collectors.joining | |
| registry = Components.getComponent(VirtualUriRegistry.class) | |
| URI uri = new URI("/rssFeeds/karamba"); | |
| def allMatches = this.registry.allDefinitions.stream() | |
| .map { it.mapUri(uri) } | |
| .filter { it.present } | |
| .map { it.get() } | |
| .sorted { it.compareTo } | |
| .map { "$it.toUri (weight $it.weight) [${referenceId(it.mapping)}]" } | |
| .collect(joining("\n")) | |
| private referenceId(mapping) { | |
| registry.allProviders.stream() | |
| .filter { it.valid && it.get() == mapping } | |
| .map { it.metadata.referenceId } | |
| .findAny() | |
| .orElse("unknown") | |
| } | |
| print "URI mappings from $uri:\n$allMatches" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment