arturobernalg opened a new pull request, #589:
URL: https://github.com/apache/jspwiki/pull/589

   First step of https://issues.apache.org/jira/browse/JSPWIKI-1310, following 
the discussion on dev@. It adds GET /api/v1/search, with the query parameters 
query and max and JSON answers, described by a hand written OpenAPI file 
(openapi.yaml in org.apache.wiki.rest). It is registered in web.xml as 
ApiV1Servlet on /api/v1/*, and adds no runtime dependency.
   
   An anonymous caller without permission gets 401 and a logged in one gets 
403. A missing query, a max that is not a positive integer and a query Lucene 
cannot parse are 400. Before the Lucene index exists, which is the first minute 
after the start, the answer is 503: LuceneSearchProvider.findPages logs the 
failure and returns null, and the servlet handles that. To tell the broken 
query apart, ProviderException has a constructor with a cause now, and the 
Lucene provider keeps the ParseException as the cause.
   
   A test compares the status, the content type and the shape of the body of 
each answer with openapi.yaml. It reads the file with snakeyaml, a new 
dependency with test scope only.
   
   Checked locally: jspwiki-main 1048 tests pass, 11 of them new; and on a 
running war (Tomcat 10.1) with two indexed pages, the results, max, an empty 
result, 400 and 503. Not tested: login, logout and /pages/{page}, which are not 
implemented yet, and the integration tests.
   
   One open point: the permission checked is view on all pages, as in /ajax/. 
With a policy that grants view only on some pages, those users get 401 or 403 
even if they can see some pages. The ChangeLog entry comes in a separate commit 
with the number of this pull request.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to