Hi Thomas,
I just already updated the branch adding some tests (and one peformance 
test) and a yaml-configuration option (using the jackson library).
My considerations are: 
- override parameters is only applied when mapping from URL, but not the 
other way around. This might be as expected, as "simpleurling" reads from 
the provided parameters and if implicit parameter are set might not allow 
to override a value, as this is the defined matcher. As a result override 
parameter is asymmetric and not applied when creating the url (mapToURL), 
but only when "reading" from it (mapFromURL). Ignore parameters take 
precedence over all others.
- I made the following small change: if calling mapToUrl more than once, I 
think it would be nice to be idempotent - to get the same mapped link back 
again (MappedTemplateLink will be as application tool in a velocity 
context) - might be relevant if used in velocity context more than once.
- Ignore-parameters in class URLMapentry is a Map, although only the keys 
are used, might be better an array, but for sake of simplicity having to 
care for only one XmlAdapter, this is not necessarily required.
- This works still in Java 16, but we should be aware of this:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by 
org.apache.turbine.services.urlmapper.TurbineURLMapperService to method 
java.util.regex.Pattern.namedGroups()
WARNING: Please consider reporting this to the maintainers of 
org.apache.turbine.services.urlmapper.TurbineURLMapperService
WARNING: Use --illegal-access=warn to enable warnings of further illegal 
reflective access operations
WARNING: All illegal access operations will be denied in a future release
And a simple question mark let's me think about what it does mean: 
(?<contextPath>\w+) and placeholders . Is it a valid pattern .. 
actually it's a pattern, if the entities are converted (&lt; to <, and 
&gt; to >), which are only there due to the fact that it's definition is 
xml wrapped. This is kind of a "marker" character as the question mark is 
masked (as the round bracket brackets) in the (meta) pattern, which reads 
this map pattern = namedGroupsPattern (where the group match is of course 
done as well).

I think, we should merge it with the trunk. 

The performance penalty when including it into the pipeline and in the 
velocity templates as application tool seems to be tolerable (but my 
performance test does not succeed with more than 1000 calls and I could 
not find the reason behind yet though ..).


Best regards, Georg




Von:    Thomas Vandahl <[email protected]>
An:     Turbine Developers List <[email protected]>
Datum:  05.01.2021 16:27
Betreff:        Need some help: was: svn commit: r1885148 - 
/turbine/core/branches/URLMapperService/



On 05.01.21 15:50, [email protected] wrote:
> Author: tv
> Date: Tue Jan  5 14:50:42 2021
> New Revision: 1885148
> 
> URL: http://svn.apache.org/viewvc?rev=1885148&view=rev
> Log:
> Experimental URL mapper implementation
> 
> Added:
>      turbine/core/branches/URLMapperService/
>        - copied from r1885147, turbine/core/trunk/
> 

Hi folks,

I've been carrying this with me for quite some time. The Liferay Portal 
supports a rule-based mapping of (almost) arbitrary URLs to sets of 
application parameters and vice-versa. (See 
https://help.liferay.com/hc/en-us/articles/360017880652-Making-URLs-Friendlier
)

Why not build something like this for Turbine?
So this is my first attempt on a possible implementation.

What does it do?
Say, you want to simplify your URLs to make them easier to read, type or 
remember.

- Instead of /context/app/template/Book.vm?id=1234
   Use /context/app/book/1234

- Instead of /context/app/template/Book.vm/action/BookSave
   Use /context/app/book/save

Say, you want to publish certain landing pages that map to a 
parametrized page in your app.

- Instead of /context/app/template/BookList.vm?sale=true
   Use /context/app/books-on-sale

You get the point. Some kind of mod_redirect, but *bi-directional*.

*If you think this may be for you, please help me testing.*

How do I use it?
I'm planning to write some documentation but for the time being, check 
out the branch turbine/core/branches/URLMapperService/ and have a look 
at the files
- conf/turbine-url-mapping.xml for some configuration examples
- conf/test/TurbineURLMapperServiceTest.properties for the service 
configuration
- 
src/test/org/apache/turbine/services/urlmapper/TurbineURLMapperServiceTest.java 

for some preliminary test cases.

Please check if this meets your needs, check your use-cases, 
corner-cases, performance etc.

I'm eager to get your feedback.

Bye, Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to