Project

General

Profile

« Previous | Next » 

Revision 8164

Added by Jing Tao about 11 years ago

If the pathquery engine is disabled, the xml path index queue will be disabled as well.

View differences:

src/edu/ucsb/nceas/metacat/IndexingQueue.java
33 33
import java.util.HashMap;
34 34
import java.lang.Comparable;
35 35

  
36
import edu.ucsb.nceas.metacat.common.query.EnabledQueryEngines;
36 37
import edu.ucsb.nceas.metacat.database.DBConnection;
37 38
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
38 39
import edu.ucsb.nceas.metacat.properties.PropertyService;
......
65 66
	}
66 67

  
67 68
    private IndexingQueue() {
69
        if(!EnabledQueryEngines.getInstance().isEnabled(EnabledQueryEngines.PATHQUERYENGINE)) {
70
            return;
71
        }
68 72
	    for (int i = 0; i < NUMBEROFINDEXINGTHREADS; i++) {
69 73
	    	IndexingTask thread = new IndexingTask();
70 74
	    	thread.start();
......
80 84
	}//getInstance
81 85

  
82 86
    public void add(String docid, String rev) {
87
        if(!EnabledQueryEngines.getInstance().isEnabled(EnabledQueryEngines.PATHQUERYENGINE)) {
88
            return;
89
        }
83 90
    	add(new IndexingQueueObject(docid, rev, 0));
84 91
    }
85 92
    
......
103 110
	}
104 111
	
105 112
	public void setMetacatRunning(boolean metacatRunning){
113
	    if(!EnabledQueryEngines.getInstance().isEnabled(EnabledQueryEngines.PATHQUERYENGINE)) {
114
            return;
115
        }
106 116
		this.metacatRunning = metacatRunning;
107 117
		
108 118
		if(!metacatRunning){
......
143 153
     * @param rev the docid's rev (ignored)
144 154
     */
145 155
    public void remove(String docid, String rev) {
156
        if(!EnabledQueryEngines.getInstance().isEnabled(EnabledQueryEngines.PATHQUERYENGINE)) {
157
            return;
158
        }
146 159
		synchronized (indexingMap) {
147 160
			if (indexingMap.containsKey(docid)) {
148 161
				logMetacat.debug("Removing indexing queue task for docid: " + docid);
src/edu/ucsb/nceas/metacat/IndexingTimerTask.java
33 33
import java.util.Vector;
34 34
import java.util.Iterator;
35 35

  
36
import edu.ucsb.nceas.metacat.common.query.EnabledQueryEngines;
36 37
import edu.ucsb.nceas.metacat.database.DBConnection;
37 38
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
38 39
import edu.ucsb.nceas.metacat.database.DatabaseService;
......
55 56
	     */
56 57
	    public void run()
57 58
	    {
59
	        if(!EnabledQueryEngines.getInstance().isEnabled(EnabledQueryEngines.PATHQUERYENGINE)) {
60
	            return;
61
	        }
58 62
	    	DBConnection dbConn = null;
59 63
	    	int serialNumber = 0;
60 64
	    	try{
src/edu/ucsb/nceas/metacat/DocumentImpl.java
62 62
import edu.ucsb.nceas.utilities.access.AccessControlInterface;
63 63
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlList;
64 64
import edu.ucsb.nceas.metacat.client.InsufficientKarmaException;
65
import edu.ucsb.nceas.metacat.common.query.EnabledQueryEngines;
65 66
import edu.ucsb.nceas.metacat.database.DBConnection;
66 67
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
67 68
import edu.ucsb.nceas.metacat.database.DatabaseService;
......
1705 1706
	 */
1706 1707
    public void buildIndex() throws McdbException
1707 1708
    {
1709
        //if the pathquery option is off, we don't need to build the index.
1710
        if(!EnabledQueryEngines.getInstance().isEnabled(EnabledQueryEngines.PATHQUERYENGINE)) {
1711
            return;
1712
        }
1708 1713
    	logMetacat.info("DocumentImpl.buildIndex - building index for docid " + docid);
1709 1714
    	double start = System.currentTimeMillis()/1000;
1710 1715
        TreeSet<NodeRecord> nodeRecordLists = getNodeRecordList(rootnodeid);
src/edu/ucsb/nceas/metacat/MetacatHandler.java
84 84
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlList;
85 85
import edu.ucsb.nceas.metacat.cart.CartManager;
86 86
import edu.ucsb.nceas.metacat.client.InsufficientKarmaException;
87
import edu.ucsb.nceas.metacat.common.query.EnabledQueryEngines;
87 88
import edu.ucsb.nceas.metacat.database.DBConnection;
88 89
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
89 90
import edu.ucsb.nceas.metacat.dataone.SystemMetadataFactory;
......
2537 2538
        try {
2538 2539
            response.setContentType("text/xml");
2539 2540
            PrintWriter out = response.getWriter();
2541
            if(!EnabledQueryEngines.getInstance().isEnabled(EnabledQueryEngines.PATHQUERYENGINE)) {
2542
                out.print("<error>");
2543
                out.print(DBQuery.XPATHQUERYOFFINFO);
2544
                out.print("</error>");
2545
                return;
2546
            }
2540 2547
            
2541 2548
            // Check that the user is authenticated as an administrator account
2542 2549
            if (!AuthUtil.isAdministrator(username, groups)) {
......
2690 2697
     * @param out the PrintWriter to which output is printed
2691 2698
     */
2692 2699
    private void buildDocumentIndex(String docid, PrintWriter out) {
2700
        //if the pathquery option is off, we don't need to build index.
2701
        if(!EnabledQueryEngines.getInstance().isEnabled(EnabledQueryEngines.PATHQUERYENGINE)) {
2702
            return;
2703
        }
2693 2704
        try {
2694 2705
            DocumentImpl doc = new DocumentImpl(docid, false);
2695 2706
            doc.buildIndex();
src/edu/ucsb/nceas/metacat/DBQuery.java
88 88
public class DBQuery
89 89
{
90 90

  
91
    public static final String XPATHQUERYOFFINFO = "The Metacat Path Query Engine is turned off. If you want to turn it on, please contact the administrator.";
91 92
    static final int ALL = 1;
92 93

  
93 94
    static final int WRITE = 2;
......
340 341
              String output = "";
341 342
              output += "<?xml version=\"1.0\"?>";
342 343
              output += "<error>";
343
              output += "The Metacat Path Query is turned off. If you want to turn it on, please contact the administrator.";
344
              output += XPATHQUERYOFFINFO;
344 345
              output += "</error>";
345 346
              out.write(output);
346 347
              out.close();

Also available in: Unified diff