Project

General

Profile

Revision 8018

allow running the Harvester client without a source code checkout. (D. Blankman comments)

View differences:

src/edu/ucsb/nceas/metacat/harvesterClient/Harvester.java
37 37
import java.text.SimpleDateFormat;
38 38
import java.util.Date;
39 39

  
40
import org.apache.log4j.Logger;
41
import org.apache.log4j.PropertyConfigurator;
42

  
43 40
import edu.ucsb.nceas.metacat.client.Metacat;
44 41
import edu.ucsb.nceas.metacat.client.MetacatFactory;
45 42
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException;
46 43
import edu.ucsb.nceas.metacat.properties.PropertyService;
47
import edu.ucsb.nceas.metacat.shared.ServiceException;
48 44
import edu.ucsb.nceas.metacat.util.SystemUtil;
49 45
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
50 46

  
......
60 56
  /*
61 57
   * Class fields
62 58
   */
63
  private static final String CONFIG_DIR = "../../build/war/WEB-INF";
64
  private static final String CONFIG_DIR_TEST = "./build/war/WEB-INF";
65
//  private static final String CONFIG_NAME = "metacat.properties";
66
  private static final String LOG_CONFIG_NAME = "../../build/war/WEB-INF/log4j.properties";
59

  
67 60
  public static final String filler = "*";
68 61
  private static boolean keepRunning = true;
69 62
  public static final String marker =
......
87 80
  /**
88 81
   * Loads Harvester options from a configuration file.
89 82
   */
90
  public static void loadProperties(boolean commandLineMode, boolean test) {
91
    String configDir = test ? CONFIG_DIR_TEST : CONFIG_DIR;    
83
  public static void loadProperties(String metacatContextDir) {
92 84

  
93 85
    try {
94
      if (commandLineMode) {
95
        PropertyService.getInstance(configDir);
96
      }
97
      else {
98
        PropertyService.getInstance();
99
      }
86
    	PropertyService.getInstance(metacatContextDir + "/WEB-INF");
100 87
    } 
101
    catch (ServiceException e) {
88
    catch (Exception e) {
102 89
      System.out.println("Error in loading properties: " + e.getMessage());
90
      System.exit(1);
103 91
    }
104 92
  }
105 93
  
......
120 108
	 * @throws ParserConfigurationException
121 109
	 */
122 110
	public static void main(String[] args) {
123
	    boolean commandLineMode = true;
124
	    boolean test = false;   // set to true for JUnit testing
125 111

  
126 112
	    Integer delayDefault = new Integer(0); // Default number of hours delay
127 113
		int delay = delayDefault.intValue(); // Delay in hours before first
......
142 128
		Integer p; // Used in determining the period
143 129
		long startTime; // time that a harvest run starts
144 130
		
131
		String metacatContextDir = null;
132

  
145 133
		if ((args.length > 0) && (args[0] != null)) {
146
		  if (args[0].equals("false")) {
147
		    commandLineMode = false;
148
		  }
149
		  else {
150
		    // If commandLineMode is true, initialize log4j properties
151
	        PropertyConfigurator.configureAndWatch(LOG_CONFIG_NAME);
152
		  }
134
			metacatContextDir = args[0];
153 135
		}
154 136

  
155 137
		/*
......
168 150

  
169 151
		System.out.println(marker);
170 152
		System.out.println("Starting Harvester");
171
		Harvester.loadProperties(commandLineMode, test);
153
		Harvester.loadProperties(metacatContextDir);
172 154

  
173 155
		// Parse the delay property. Use default if necessary.
174 156
		try {
docs/user/metacat/source/harvester.rst
561 561
Running Harvester in a Command Window
562 562
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
563 563

  
564
To run Harvester in a Command Window (requires source code distribution):
564
To run Harvester in a Command Window:
565 565
 
566 566
1. Open a system command window or terminal window. 
567 567
2. Set the ``METACAT_HOME`` environment variable to the value of the 
568
   Metacat installation directory. 
568
   Metacat webapp deployment directory. 
569 569

  
570 570
   On Windows: 
571 571

  
......
599 599

  
600 600
   ::
601 601
   
602
     runHarvester.bat
602
     runHarvester.bat %METACAT_HOME%
603 603

  
604 604
   On Linux/Unix: 
605 605

  
606 606
   ::
607 607
   
608
     sh runHarvester.sh
608
     sh runHarvester.sh $METACAT_HOME
609 609

  
610 610
The Harvester application will start executing. The first harvest will occur 
611 611
after the number of hours specified in the ``metacat.properties file``. The 

Also available in: Unified diff