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

File AbstractSolrInstance.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart5.png
74% of files have more coverage

Code metrics

0
19
10
1
138
77
10
0.53
1.9
10
1

Classes

Class Line # Actions
AbstractSolrInstance 43 19 0% 10 17
0.4137931241.4%
 

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;
21   
22    import java.io.IOException;
23    import java.util.List;
24   
25    import javax.inject.Inject;
26   
27    import org.apache.solr.client.solrj.SolrClient;
28    import org.apache.solr.client.solrj.SolrServerException;
29    import org.apache.solr.client.solrj.StreamingResponseCallback;
30    import org.apache.solr.client.solrj.response.QueryResponse;
31    import org.apache.solr.common.SolrInputDocument;
32    import org.apache.solr.common.params.SolrParams;
33    import org.slf4j.Logger;
34    import org.xwiki.search.solr.internal.api.SolrInstance;
35   
36    /**
37    * Basic implementation for the wrapped instance.
38    *
39    * @see SolrInstance
40    * @version $Id: d88b35e6b821a26bbbd9e3251eb49d50a29365a7 $
41    * @since 4.3M2
42    */
 
43    public abstract class AbstractSolrInstance implements SolrInstance
44    {
45    /**
46    * Solr server instance corresponding, depending on the subclass.
47    */
48    protected SolrClient server;
49   
50    /**
51    * Logging framework.
52    */
53    @Inject
54    protected Logger logger;
55   
 
56  4031 toggle @Override
57    public void add(SolrInputDocument solrDocument) throws SolrServerException, IOException
58    {
59  4031 this.logger.debug("Add Solr document [{}] to index", solrDocument);
60   
61  4031 this.server.add(solrDocument);
62    }
63   
 
64  0 toggle @Override
65    public void add(List<SolrInputDocument> solrDocuments) throws SolrServerException, IOException
66    {
67  0 this.logger.debug("Add Solr documents [{}] to index", solrDocuments);
68   
69  0 this.server.add(solrDocuments);
70    }
71   
 
72  433 toggle @Override
73    public void delete(String id) throws SolrServerException, IOException
74    {
75  433 this.logger.debug("Delete Solr document [{}] from index", id);
76   
77  433 this.server.deleteById(id);
78    }
79   
 
80  0 toggle @Override
81    public void delete(List<String> ids) throws SolrServerException, IOException
82    {
83  0 this.logger.debug("Delete Solr documents [{}] from index", ids);
84   
85  0 this.server.deleteById(ids);
86    }
87   
 
88  0 toggle @Override
89    public void deleteByQuery(String query) throws SolrServerException, IOException
90    {
91  0 this.logger.debug("Delete Solr documents from index based on query [{}]", query);
92   
93  0 this.server.deleteByQuery(query);
94    }
95   
 
96  328 toggle @Override
97    public void commit() throws SolrServerException, IOException
98    {
99  328 this.logger.debug("Commit changes to Solr");
100   
101  328 this.server.commit();
102    }
103   
 
104  0 toggle @Override
105    public void rollback() throws SolrServerException, IOException
106    {
107  0 this.logger.debug("Rollback changes to Solr");
108   
109  0 this.server.rollback();
110    }
111   
 
112  1016 toggle @Override
113    public QueryResponse query(SolrParams solrParams) throws SolrServerException, IOException
114    {
115  1016 this.logger.debug("Execute Solr query [{}]", solrParams);
116   
117  1016 return this.server.query(solrParams);
118    }
119   
 
120  0 toggle @Override
121    public QueryResponse queryAndStreamResponse(SolrParams params, StreamingResponseCallback callback)
122    throws SolrServerException, IOException
123    {
124  0 this.logger.debug("Execute Solr query and stream response [{}]", params);
125   
126  0 return this.server.queryAndStreamResponse(params, callback);
127    }
128   
129    /**
130    * Useful when testing.
131    *
132    * @return the server
133    */
 
134  0 toggle protected SolrClient getServer()
135    {
136  0 return this.server;
137    }
138    }