Project

General

Profile

Revision 7772

Added by Jing Tao almost 8 years ago

Use some contants from the EnabledQueryEngines.

View differences:

src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
105 105
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
106 106
import edu.ucsb.nceas.metacat.MetaCatServlet;
107 107
import edu.ucsb.nceas.metacat.MetacatHandler;
108

  
109
import edu.ucsb.nceas.metacat.common.query.EnabledQueryEngines;
108 110
import edu.ucsb.nceas.metacat.common.query.stream.ContentTypeByteArrayInputStream;
109 111
import edu.ucsb.nceas.metacat.dataone.hazelcast.HazelcastService;
110 112
import edu.ucsb.nceas.metacat.index.MetacatSolrEngineDescriptionHandler;
......
145 147
public class MNodeService extends D1NodeService 
146 148
    implements MNAuthorization, MNCore, MNRead, MNReplication, MNStorage, MNQuery {
147 149

  
148
    private static final String PATHQUERY = "pathquery";
150
    //private static final String PATHQUERY = "pathquery";
149 151
	private static final String UUID_SCHEME = "UUID";
150 152
	private static final String DOI_SCHEME = "DOI";
151 153
	private static final String UUID_PREFIX = "urn:uuid:";
......
1409 1411
	public QueryEngineDescription getQueryEngineDescription(String engine)
1410 1412
			throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented,
1411 1413
			NotFound {
1412
	    if(engine != null && engine.equals(PATHQUERY)) {
1414
	    if(engine != null && engine.equals(EnabledQueryEngines.PATHQUERYENGINE)) {
1413 1415
	        QueryEngineDescription qed = new QueryEngineDescription();
1414
	        qed.setName(PATHQUERY);
1416
	        qed.setName(EnabledQueryEngines.PATHQUERYENGINE);
1415 1417
	        qed.setQueryEngineVersion("1.0");
1416 1418
	        qed.addAdditionalInfo("This is the traditional structured query for Metacat");
1417 1419
	        Vector<String> pathsForIndexing = null;
......
1433 1435
	            qed.addQueryField(field);
1434 1436
	        }
1435 1437
	        return qed;
1436
	    } else if (engine != null && engine.equals(MetacatSolrIndex.SOLRQUERY)) {
1438
	    } else if (engine != null && engine.equals(EnabledQueryEngines.SOLRENGINE)) {
1439
	        /*if(!EnabledQueryEngines.getInstance().isEnabled(EnabledQueryEngines.SOLRENGINE)) {
1440
                throw new NotImplemented("0000", "MNodeService.getQueryEngineDescription - the query engine "+engine +" hasn't been implemented or has been disabled.");
1441
            }*/
1437 1442
	        try {
1438 1443
	            QueryEngineDescription qed = MetacatSolrEngineDescriptionHandler.getInstance().getQueryEngineDescritpion();
1439 1444
	            return qed;
......
1451 1456
	public QueryEngineList listQueryEngines() throws InvalidToken,
1452 1457
			ServiceFailure, NotAuthorized, NotImplemented {
1453 1458
		QueryEngineList qel = new QueryEngineList();
1454
		// support pathquery initially
1455
		qel.addQueryEngine(PATHQUERY);
1456
		qel.addQueryEngine(MetacatSolrIndex.SOLRQUERY);
1459
		qel.addQueryEngine(EnabledQueryEngines.PATHQUERYENGINE);
1460
		qel.addQueryEngine(EnabledQueryEngines.SOLRENGINE);
1461
		/*List<String> enables = EnabledQueryEngines.getInstance().getEnabled();
1462
		for(String name : enables) {
1463
		    qel.addQueryEngine(name);
1464
		}*/
1457 1465
		return qel;
1458 1466
	}
1459 1467

  
......
1483 1491
        }
1484 1492
        //System.out.println("====== user is "+user);
1485 1493
        //System.out.println("====== groups are "+groups);
1486
		if (engine != null && engine.equals(PATHQUERY)) {
1494
		if (engine != null && engine.equals(EnabledQueryEngines.PATHQUERYENGINE)) {
1487 1495
			try {
1488 1496
				DBQuery queryobj = new DBQuery();
1489 1497
				
......
1496 1504
				throw new ServiceFailure("Pathquery error", e.getMessage());
1497 1505
			}
1498 1506
			
1499
		} else if (engine != null && engine.equals(MetacatSolrIndex.SOLRQUERY)) {
1507
		} else if (engine != null && engine.equals(EnabledQueryEngines.SOLRENGINE)) {
1508
		    /*if(!EnabledQueryEngines.getInstance().isEnabled(EnabledQueryEngines.SOLRENGINE)) {
1509
		        throw new NotImplemented("0000", "MNodeService.query - the query engine "+engine +" hasn't been implemented or has been disabled.");
1510
		    }*/
1500 1511
		    logMetacat.info("The query is ==================================== \n"+query);
1501 1512
		    try {
1502 1513
		        
src/edu/ucsb/nceas/metacat/index/MetacatSolrEngineDescriptionHandler.java
53 53
import org.xml.sax.SAXException;
54 54

  
55 55
import edu.ucsb.nceas.metacat.common.SolrServerFactory;
56
import edu.ucsb.nceas.metacat.common.query.EnabledQueryEngines;
56 57
import edu.ucsb.nceas.metacat.common.query.SolrQueryServiceController;
57 58
import edu.ucsb.nceas.metacat.properties.PropertyService;
58 59
import edu.ucsb.nceas.utilities.FileUtil;
......
115 116
    private void init() throws IOException, UnsupportedType, NotFound, ParserConfigurationException, SAXException {
116 117
        Map<String, String>fieldDescriptions = loadSchemaFieldDescriptions();
117 118
        qed = new QueryEngineDescription();
118
        qed.setName(MetacatSolrIndex.SOLRQUERY);
119
        qed.setName(EnabledQueryEngines.SOLRENGINE);
119 120
        //setSchemaVersionFromPropertiesFile(qed);
120 121
        setSolrVersion();
121 122

  
src/edu/ucsb/nceas/metacat/index/MetacatSolrIndex.java
65 65
public class MetacatSolrIndex {
66 66
    
67 67
    
68
    public static final String SOLRQUERY = "solr";
69
    public static final String SOLR_HOME_PROPERTY_NAME = "solr.homeDir";
70
    public static final String SOLR_CONFIG_FILE_NAME_PROPERTY_NAME = "solr.configFileName";
71
    public static final String SOLR_COLLECTION_NAME_PROPERTY_NAME = "solr.collectionName";
72
    public static final String SOLR_SERVER_CLASSNAME_PROPERTY_NAME = "solr.server.classname";
68
    //public static final String SOLRQUERY = "solr";
69
    //public static final String SOLR_HOME_PROPERTY_NAME = "solr.homeDir";
70
    //public static final String SOLR_CONFIG_FILE_NAME_PROPERTY_NAME = "solr.configFileName";
71
    //public static final String SOLR_COLLECTION_NAME_PROPERTY_NAME = "solr.collectionName";
72
    //public static final String SOLR_SERVER_CLASSNAME_PROPERTY_NAME = "solr.server.classname";
73 73
   
74 74
    
75 75
    private static Log log = LogFactory.getLog(MetacatSolrIndex.class);

Also available in: Unified diff