Project

General

Profile

« Previous | Next » 

Revision 7712

Added by Jing Tao over 11 years ago

Use the sepcified exceptions to replace the Exception.

View differences:

metacat-common/src/main/java/edu/ucsb/nceas/metacat/common/SolrServerFactory.java
27 27
package edu.ucsb.nceas.metacat.common;
28 28

  
29 29
import java.io.File;
30
import java.io.IOException;
30 31

  
32
import javax.xml.parsers.ParserConfigurationException;
33

  
31 34
import org.apache.commons.logging.Log;
32 35
import org.apache.commons.logging.LogFactory;
33 36
import org.apache.solr.client.solrj.SolrServer;
......
35 38
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
36 39
import org.apache.solr.core.CoreContainer;
37 40
import org.dataone.configuration.Settings;
41
import org.dataone.service.exceptions.UnsupportedType;
42
import org.xml.sax.SAXException;
38 43

  
39 44
/**
40 45
 * A factory for creating SolrServer implementations based on
......
69 74
	private static SolrServer solrServer = null;
70 75
	//private static String solrServerBaseURL = null;
71 76

  
72
	public static SolrServer createSolrServer() throws Exception {
77
	public static SolrServer createSolrServer() throws ParserConfigurationException, IOException, SAXException, UnsupportedType   {
73 78
	    if(solrServer == null) {
74 79
	        String className = Settings.getConfiguration().getString(SOLR_SERVER_CLASSNAME_PROPERTY_NAME);
75 80
	        if (className != null && className.equals(EMBEDDEDSERVERCLASS)) {
......
78 83
	            String solrServerBaseURL = Settings.getConfiguration().getString(SOLR_ENPOINT_PROPERTY_NAME);
79 84
	            solrServer = new CommonsHttpSolrServer(solrServerBaseURL);
80 85
	        } else {
81
	            throw new Exception("SolrServerFactory.createSolrServer - MetacatIndex doesn't support this solr server type: "+className);
86
	            throw new UnsupportedType("0000","SolrServerFactory.createSolrServer - MetacatIndex doesn't support this solr server type: "+className);
82 87
	        }
83 88
	    }
84 89
        return solrServer;
85 90
	}
86 91
	
87
	private static void generateEmbeddedServer() throws Exception {
92
	private static void generateEmbeddedServer() throws ParserConfigurationException, IOException, SAXException  {
88 93
	    String solrHomeDir = Settings.getConfiguration().getString(SOLR_HOME_PROPERTY_NAME);
89 94
        log.info("The configured solr home from properties is " + solrHomeDir);
90 95
        String configFileName = Settings.getConfiguration().getString(SOLR_CONFIG_FILE_NAME_PROPERTY_NAME);
......
98 103
	/**
99 104
	 * Get the the CoreContainer of the generated EmbeddedSolrServer.
100 105
	 * @return it may return null if the solr is configured as the SolrHttpServer
106
	 * @throws SAXException 
107
	 * @throws IOException 
108
	 * @throws ParserConfigurationException 
109
	 * @throws UnsupportedType 
101 110
	 * @throws Exception 
102 111
	 */
103
	public static CoreContainer getCoreContainer() throws Exception {
112
	public static CoreContainer getCoreContainer() throws UnsupportedType, ParserConfigurationException, IOException, SAXException  {
104 113
	    if(coreContainer == null) {
105 114
	        createSolrServer();
106 115
	    }

Also available in: Unified diff