Search in sources :

Example 71 with XWikiRestException

use of org.xwiki.rest.XWikiRestException in project xwiki-platform by xwiki.

the class WikiSearchResourceImpl method search.

@Override
public SearchResults search(String wikiName, String keywords, List<String> searchScopeStrings, Integer number, Integer start, String orderField, String order, Boolean withPrettyNames) throws XWikiRestException {
    try {
        SearchResults searchResults = objectFactory.createSearchResults();
        searchResults.setTemplate(String.format("%s?%s", Utils.createURI(uriInfo.getBaseUri(), WikiSearchResource.class, wikiName).toString(), SEARCH_TEMPLATE_INFO));
        if (wikiName != null) {
            Utils.getXWikiContext(componentManager).setWikiId(wikiName);
        }
        List<SearchScope> searchScopes = parseSearchScopeStrings(searchScopeStrings);
        searchResults.getSearchResults().addAll(search(searchScopes, keywords, getXWikiContext().getWikiId(), null, Utils.getXWiki(componentManager).getRightService().hasProgrammingRights(Utils.getXWikiContext(componentManager)), number, start, true, orderField, order, withPrettyNames));
        return searchResults;
    } catch (Exception e) {
        throw new XWikiRestException(e);
    }
}
Also used : XWikiRestException(org.xwiki.rest.XWikiRestException) WikiSearchResource(org.xwiki.rest.resources.wikis.WikiSearchResource) SearchResults(org.xwiki.rest.model.jaxb.SearchResults) XWikiRestException(org.xwiki.rest.XWikiRestException)

Aggregations

XWikiRestException (org.xwiki.rest.XWikiRestException)71 XWikiException (com.xpn.xwiki.XWikiException)46 Document (com.xpn.xwiki.api.Document)40 WebApplicationException (javax.ws.rs.WebApplicationException)26 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)15 Link (org.xwiki.rest.model.jaxb.Link)12 QueryException (org.xwiki.query.QueryException)8 BaseObject (com.xpn.xwiki.objects.BaseObject)7 RangeIterable (org.xwiki.rest.internal.RangeIterable)7 XWikiContext (com.xpn.xwiki.XWikiContext)6 Object (org.xwiki.rest.model.jaxb.Object)5 Property (org.xwiki.rest.model.jaxb.Property)5 Date (java.util.Date)4 Test (org.junit.Test)4 ClassPropertyReference (org.xwiki.model.reference.ClassPropertyReference)4 Objects (org.xwiki.rest.model.jaxb.Objects)4 XWikiRCSNodeId (com.xpn.xwiki.doc.rcs.XWikiRCSNodeId)3 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)3 URI (java.net.URI)3 URL (java.net.URL)3