Project

General

Profile

« Previous | Next » 

Revision 8872

Added by Jing Tao over 9 years ago

Add code to determine if a id exists in a solr server.

View differences:

SolrQueryServiceController.java
21 21
import java.io.IOException;
22 22
import java.io.InputStream;
23 23
import java.net.MalformedURLException;
24
import java.util.List;
24 25
import java.util.Map;
25 26
import java.util.Set;
26 27

  
......
30 31
import org.apache.solr.client.solrj.SolrServerException;
31 32
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
32 33
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
34
import org.apache.solr.client.solrj.response.QueryResponse;
33 35
import org.apache.solr.common.params.SolrParams;
34 36
import org.apache.solr.core.CoreContainer;
35 37
import org.apache.solr.schema.IndexSchema;
......
37 39
import org.dataone.service.exceptions.NotFound;
38 40
import org.dataone.service.exceptions.NotImplemented;
39 41
import org.dataone.service.exceptions.UnsupportedType;
42
import org.dataone.service.types.v1.Identifier;
40 43
import org.dataone.service.types.v1.Subject;
41 44
import org.xml.sax.SAXException;
42 45

  
......
158 161
        }
159 162
       
160 163
    }
164
    
165
    /**
166
     * If the solr client was configured as an embedded solr server.
167
     * @return true if it is; false otherwise.
168
     */
169
    public boolean isEmbeddedSolrServer() {
170
    	return isEmbeddedSolrServer;
171
    }
172
    
173
    
174
    /**
175
     * If the solr server has at least one solr doc for the given id.
176
     * @param id
177
     * @return true if the server has at lease one solr doc; false otherwise.
178
     */
179
    public boolean hasSolrDoc(Identifier id) throws ParserConfigurationException, SolrServerException, IOException, SAXException{
180
    	 if(isEmbeddedSolrServer) {
181
             return embeddedQueryService.hasSolrDoc(id);
182
         } else{
183
             return httpQueryService.hasSolrDoc(id);
184
         }
185
    }
161 186

  
162 187
    
163 188
}

Also available in: Unified diff