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 {
|
allow running the Harvester client without a source code checkout. (D. Blankman comments)