Skip to content

JSPWIKI-1310 Add the page name suggestions and the list of plugins to the REST API version 1 - #590

Open
arturobernalg wants to merge 18 commits into
apache:masterfrom
arturobernalg:feature/JSPWIKI-1310-plugins-suggestions
Open

arturobernalg wants to merge 18 commits into
apache:masterfrom
arturobernalg:feature/JSPWIKI-1310-plugins-suggestions

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

Stacked on #589: until that one is merged, the first two commits are the ones of that pull request, and the one of this pull request is the last one.

Second step of https://issues.apache.org/jira/browse/JSPWIKI-1310. It adds GET /api/v1/search/suggestions, with the query parameters query and max, and GET /api/v1/plugins, to the contract openapi.yaml and to ApiV1Servlet. Both answer as the search does: 401 to an anonymous caller without permission, 403 to a logged in one, and 400 with a JSON body when query is missing or max is not a positive integer.

The suggestions leave out the pages the caller may not view. The suggestions of /ajax/search/suggestions do not do that, and the question was open on dev@, so I took the safe side for the new endpoint. For that, SearchManager has a new method, suggestPages(text, max, session). The algorithm moved from the Ajax service to a private method that both use, and the Ajax service calls it without a filter, so its behaviour does not change.

The plugins are sorted by display name for the locale of the request, as in /ajax/plugins/plugins, but on a copy of the list of the plugin manager, because the Ajax service sorts the list of the manager itself.

The test compares each answer with openapi.yaml, as for the search. Checked locally: jspwiki-main 1055 tests pass, 7 of them new; making the suggestions ignore the permission makes the test fail; and on a running war (Tomcat 10.1) with three pages, one of them with [{ALLOW view Admin}], the anonymous caller does not get that one, max works, and the plugins come sorted. Not tested: login, logout and /pages/{page}, which are not implemented yet, and the integration tests. The ChangeLog entry comes in a separate commit with the number of this pull request.

…o feature/JSPWIKI-1310-plugins-suggestions

# Conflicts:
#	ChangeLog.md
#	jspwiki-main/src/main/java/org/apache/wiki/search/DefaultSearchManager.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants