[MAGNOLIA-5656] MutliSite applicable regex based VirtualURIMapping needed. Created: 06/Feb/14 Updated: 06/May/14 Resolved: 28/Feb/14 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | core |
| Affects Version/s: | 4.5.15, 5.2.2 |
| Fix Version/s: | 4.5.17, 5.2.3 |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Christian Ringele | Assignee: | Roman Kovařík |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | maintenance, support | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||
| Date of First Response: | |||||||||
| Description |
|
Situation: The RegexpVirtualURIMapping implementation is not very applicable, as no selector in the URL can be used for applying the pattern only for a certain site. The handle prefix is mapped away by the domain. The possibility of using a HostBasedVirtualURIMapping solves the problem of reacting to the mapped domain as selector. But the HostBasedVirtualURIMapping is not regex capable. So fort redirecting the parameters as described in this support ticket SUPPORT-3223 is not a usable solution. A new kind of VirtualURIMApping which is either hostbased & regex capable or uses some other sort of site definition mapping/selector would help in many multi site situations. |
| Comments |
| Comment by Jan Haderka [ 06/Feb/14 ] |
|
HostBasedVirtualURIMapping: public void setFromURI(String fromURI) { this.fromURI = fromURI; this.pattern = new SimpleUrlPattern(fromURI); } public MappingResult mapURI(String uri) { String destination = toURI; if (pattern != null && pattern.match(uri)) { ... SimpleUrlPattern: /**
* @see info.magnolia.cms.util.UrlPattern#match(java.lang.String)
*/
@Override
public boolean match(String str) {
return this.pattern.matcher(str).matches();
}
SimpleUrlPattern compiles fromURI into a pattern and performs regex matching. So I'm not sure what is the perceived shortcoming. Do you want to be able to match multiple domain names w/ pattern? That is indeed not available, you need to list all domain names for which you want mapping to be applied. |
| Comment by Christian Ringele [ 06/Feb/14 ] |
|
HostBasedVirtualURIMapping: public MappingResult mapURI(String uri) The uri does not contain parameters. The RegexpVirtualURIMapping provides for this a second method with the parameter queryString which contains the parameters. @Override public MappingResult mapURI(final String uri, String queryString) { Where the queryString is used for the matcher: if(queryString != null){ matcher = regexp.matcher(uri + "?" + queryString); } In HostBasedVirtualURIMapping the matcher of the pattern won't take parameters into account: boolean match = pattern.match(uri);
-> The HostBasedVirtualURIMapping should be queryString aware as the RegexpVirtualURIMapping is. Even with this addition of queryString awareness I think using the HostBasedVirtualURIMapping is not as flexible for multisite behavior:
|
| Comment by Joerg von Frantzius [ 13/Feb/14 ] |
|
BTW the same problem exists with DefaultVirtualURIMapping: it's not possible to define a mapping that matches only for a given site. If e.g. you have two sites greatshoes.com and greatshirts.com, and you want to have two different VirtualURIMappings greatshoes.com/offer and greatshirts.com/offer that each map to a different page within their respective sites, you have to program a custom VirtualURIMapping. |
| Comment by Jan Haderka [ 13/Feb/14 ] |
|
@Joerg this should be doable with HostBasedVirtualURIMapping out of the box. |
| Comment by Joerg von Frantzius [ 13/Feb/14 ] |
|
@Jan yes you're totally right, thanks! |
| Comment by Roman Kovařík [ 19/Feb/14 ] |
|
Commited on 4.5.x branch for review. |
| Comment by Richard Unger [ 29/Apr/14 ] |
|
After looking over these solutions, I coded a solution by subclassing MultiSiteFilter. Doing it in multisitefilter has several advantages:
I will try to share the solution on the wiki. |