Project

General

Profile

1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A class that gets Accession Number, check for uniqueness
4
 *             and register it into db
5
 *  Copyright: 2000 Regents of the University of California and the
6
 *             National Center for Ecological Analysis and Synthesis
7
 *    Authors: Jivka Bojilova, Matt Jones
8
 *
9
 *   '$Author: tao $'
10
 *     '$Date: 2013-04-19 17:47:14 -0700 (Fri, 19 Apr 2013) $'
11
 * '$Revision: 7595 $'
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2 of the License, or
16
 * (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
 */
27
package edu.ucsb.nceas.metacat.common.query;
28

    
29
import java.util.List;
30

    
31
import org.dataone.configuration.Settings;
32

    
33
/**
34
 * A class represents the enable query engine type in the metacat
35
 * @author tao
36
 *
37
 */
38
public class EnabledQueryEngines {
39
    
40
    public static final String PATHQUERYENGINE = "pathquery";
41
    public static final String SOLRENGINE = "solr";
42
    private static final String ENABLED_ENGINES_PATH = "dbquery.enabledEngines";
43
    private static EnabledQueryEngines enabledEnginesObj = null;
44
    private List<String> enabledEngines = null;
45
    
46
    
47
    
48
    /*
49
     * Constructor. Read the enabled engines from the property file
50
     */
51
    private EnabledQueryEngines() {
52
        enabledEngines = Settings.getConfiguration().getList(ENABLED_ENGINES_PATH);
53
    }
54
    
55
    /**
56
     * Get the singleton instance
57
     * @return
58
     */
59
    public static EnabledQueryEngines getInstance() {
60
        if(enabledEnginesObj ==null) {
61
            enabledEnginesObj = new EnabledQueryEngines();
62
        }
63
        return enabledEnginesObj;
64
    }
65
    
66
    
67
    /**
68
     * Get the list of enabled engines. 
69
     * @return an empty list will be returned if there are no enabled engines.
70
     */
71
    public List<String> getEnabled() {
72
        return this.enabledEngines;
73
    }
74
    
75
    /**
76
     * If the the specified engine name is enabled. The name is not case sensitive.
77
     * @param engine  the specified engine name.
78
     * @return true if the specified name is enabled.
79
     */
80
    public boolean isEnabled(String engine) {
81
        boolean enabled = false;
82
        if(engine != null && !engine.trim().equals("") && enabledEngines != null) {
83
            for(String name : enabledEngines) {
84
                if(name != null && name.equalsIgnoreCase(engine)) {
85
                    enabled = true;
86
                    break;
87
                }
88
            }
89
        }
90
        return enabled;
91
    }
92
}
(2-2/7)