1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rest.internal.resources.wikis; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import javax.inject.Named; |
25 |
|
|
26 |
|
import org.xwiki.component.annotation.Component; |
27 |
|
import org.xwiki.rest.XWikiRestException; |
28 |
|
import org.xwiki.rest.internal.Utils; |
29 |
|
import org.xwiki.rest.internal.resources.BaseSearchResult; |
30 |
|
import org.xwiki.rest.model.jaxb.SearchResults; |
31 |
|
import org.xwiki.rest.resources.wikis.WikiSearchResource; |
32 |
|
|
33 |
|
@Component |
34 |
|
@Named("org.xwiki.rest.internal.resources.wikis.WikiSearchResourceImpl") |
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 3 |
Complexity Density: 0.33 |
|
35 |
|
public class WikiSearchResourceImpl extends BaseSearchResult implements WikiSearchResource |
36 |
|
{ |
|
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
37 |
25 |
@Override... |
38 |
|
public SearchResults search(String wikiName, String keywords, List<String> searchScopeStrings, Integer number, |
39 |
|
Integer start, String orderField, String order, Boolean withPrettyNames) throws XWikiRestException |
40 |
|
{ |
41 |
25 |
try { |
42 |
25 |
SearchResults searchResults = objectFactory.createSearchResults(); |
43 |
25 |
searchResults.setTemplate(String.format("%s?%s", |
44 |
|
Utils.createURI(uriInfo.getBaseUri(), WikiSearchResource.class, wikiName).toString(), |
45 |
|
SEARCH_TEMPLATE_INFO)); |
46 |
|
|
47 |
25 |
if (wikiName != null) { |
48 |
25 |
Utils.getXWikiContext(componentManager).setWikiId(wikiName); |
49 |
|
} |
50 |
|
|
51 |
25 |
List<SearchScope> searchScopes = parseSearchScopeStrings(searchScopeStrings); |
52 |
|
|
53 |
25 |
searchResults.getSearchResults().addAll( |
54 |
|
search(searchScopes, keywords, getXWikiContext().getWikiId(), null, Utils.getXWiki(componentManager) |
55 |
|
.getRightService().hasProgrammingRights(Utils.getXWikiContext(componentManager)), number, start, |
56 |
|
true, orderField, order, withPrettyNames)); |
57 |
|
|
58 |
25 |
return searchResults; |
59 |
|
} catch (Exception e) { |
60 |
0 |
throw new XWikiRestException(e); |
61 |
|
} |
62 |
|
} |
63 |
|
} |