1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.search.solr.internal.rest

File WikisSearchQueryResourceImpl.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

0
6
1
1
72
41
2
0.33
6
1
2

Classes

Class Line # Actions
WikisSearchQueryResourceImpl 40 6 0% 2 1
0.8571428785.7%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.search.solr.internal.rest;
21   
22    import javax.inject.Inject;
23    import javax.inject.Named;
24   
25    import org.xwiki.component.annotation.Component;
26    import org.xwiki.rest.XWikiRestException;
27    import org.xwiki.rest.internal.Utils;
28    import org.xwiki.rest.internal.resources.BaseSearchResult;
29    import org.xwiki.rest.internal.resources.search.SearchSource;
30    import org.xwiki.rest.model.jaxb.SearchResults;
31    import org.xwiki.rest.resources.wikis.WikisSearchQueryResource;
32   
33    /**
34    *
35    * @version $Id: 01e14ac6206bb51c2c6e2553b10ec632bce855c4 $
36    * @since 6.4M1
37    */
38    @Component
39    @Named("org.xwiki.search.solr.internal.rest.WikisSearchQueryResourceImpl")
 
40    public class WikisSearchQueryResourceImpl extends BaseSearchResult implements WikisSearchQueryResource
41    {
42    private static final String MULTIWIKI_QUERY_TEMPLATE_INFO =
43    "q={solrquery}(&number={number})(&start={start})(&orderField={fieldname}(&order={asc|desc}))(&distinct=1)(&prettyNames={false|true})(&wikis={wikis})(&className={classname})";
44   
45    @Inject
46    @Named("solr")
47    private SearchSource solrSearch;
48   
 
49  1 toggle @Override
50    public SearchResults search(String query, Integer number, Integer start, Boolean distinct, String searchWikis,
51    String orderField, String order, Boolean withPrettyNames, String className) throws XWikiRestException
52    {
53  1 try {
54  1 SearchResults searchResults = objectFactory.createSearchResults();
55  1 searchResults.setTemplate(String.format("%s?%s", uriInfo.getBaseUri().toString(),
56    MULTIWIKI_QUERY_TEMPLATE_INFO));
57   
58  1 searchResults.getSearchResults().addAll(
59    this.solrSearch.search(
60    query,
61    getXWikiContext().getWikiId(),
62    searchWikis,
63    Utils.getXWiki(componentManager).getRightService()
64    .hasProgrammingRights(Utils.getXWikiContext(componentManager)), orderField, order, distinct,
65    number, start, withPrettyNames, className, uriInfo));
66   
67  1 return searchResults;
68    } catch (Exception e) {
69  0 throw new XWikiRestException(e);
70    }
71    }
72    }