| 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.spaces; |
| 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.spaces.SpaceSearchResource; |
| 32 |
|
|
| 33 |
|
@Component |
| 34 |
|
@Named("org.xwiki.rest.internal.resources.spaces.SpaceSearchResourceImpl") |
| |
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 35 |
|
public class SpaceSearchResourceImpl extends BaseSearchResult implements SpaceSearchResource |
| 36 |
|
{ |
| |
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 37 |
11 |
@Override... |
| 38 |
|
public SearchResults search(String wikiName, String spaceName, String keywords, List<String> searchScopeStrings, |
| 39 |
|
Integer number, Integer start, String orderField, String order, Boolean withPrettyNames) |
| 40 |
|
throws XWikiRestException |
| 41 |
|
{ |
| 42 |
11 |
List<String> spaces = parseSpaceSegments(spaceName); |
| 43 |
|
|
| 44 |
11 |
try { |
| 45 |
11 |
SearchResults searchResults = objectFactory.createSearchResults(); |
| 46 |
11 |
searchResults.setTemplate(String.format("%s?%s", Utils.createURI(uriInfo.getBaseUri(), |
| 47 |
|
SpaceSearchResource.class, wikiName, spaces).toString(), SEARCH_TEMPLATE_INFO)); |
| 48 |
|
|
| 49 |
11 |
List<SearchScope> searchScopes = parseSearchScopeStrings(searchScopeStrings); |
| 50 |
|
|
| 51 |
11 |
searchResults.getSearchResults().addAll( |
| 52 |
|
search(searchScopes, keywords, wikiName, Utils.getLocalSpaceId(spaces), |
| 53 |
|
Utils.getXWiki(componentManager).getRightService().hasProgrammingRights( |
| 54 |
|
Utils.getXWikiContext(componentManager)), number, start, true, orderField, order, |
| 55 |
|
withPrettyNames)); |
| 56 |
|
|
| 57 |
11 |
return searchResults; |
| 58 |
|
} catch (Exception e) { |
| 59 |
0 |
throw new XWikiRestException(e); |
| 60 |
|
} |
| 61 |
|
} |
| 62 |
|
} |