AnsweredAssumed Answered

Webscripts url mapping behaves differently when written in Java vs. Javascript

Question asked by mathias.lin on Jul 28, 2015
Latest reply on Aug 2, 2015 by mathias.lin
I just noticed some behavior regarding web scripts. Maybe somebody has an idea why this happens or whether it's a bug in Alfresco.

I have two (GET) web scripts:

<strong>Webscript A</strong> has the following URL in it's descriptor:

<url>/api/v1/folders/{path}</url>


<strong>Webscript B</strong> has the following URL in it's descriptor:

<url>/api/v1/folders/{path}/files</url>


Note that the urls only differ with the "/files" in the end.


The strange thing now is that when both web scripts are written in javascript (thus also not needed to be registered in any xml context file), it's not possible to reach webscript B, because A already caught the requests falsely (because of the overlapping URL pattern, I assume, but without checking for further patterns that match better).
For example, I call the URL like:

GET /api/v1/folders/myFolderX/files


I would expect that the request would go to webscript B (due to the "/files" at the end), but instead it goes to webscript A, which throws an error due to mismatching business logic in there of course.

But: if I rewrite the web scripts in Java (and no changes to the descriptor or url pattern), register them in my xml context file, then everything works as expected and my request actually reaches webscript B.

Any idea why this is?


Outcomes