27 |
27 |
package edu.ucsb.nceas.metacat.admin;
|
28 |
28 |
|
29 |
29 |
import java.io.File;
|
|
30 |
import java.io.FileFilter;
|
30 |
31 |
import java.util.Vector;
|
31 |
32 |
|
32 |
33 |
import javax.servlet.http.HttpServletRequest;
|
33 |
34 |
import javax.servlet.http.HttpServletResponse;
|
34 |
35 |
|
|
36 |
import org.apache.commons.io.FileUtils;
|
|
37 |
import org.apache.commons.io.filefilter.AndFileFilter;
|
|
38 |
import org.apache.commons.io.filefilter.DirectoryFileFilter;
|
|
39 |
import org.apache.commons.io.filefilter.OrFileFilter;
|
|
40 |
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
35 |
41 |
import org.apache.log4j.Logger;
|
36 |
|
import org.dataone.client.CNode;
|
37 |
|
import org.dataone.client.D1Client;
|
38 |
|
import org.dataone.client.auth.CertificateManager;
|
39 |
|
import org.dataone.service.exceptions.IdentifierNotUnique;
|
40 |
|
import org.dataone.service.exceptions.InvalidRequest;
|
41 |
|
import org.dataone.service.exceptions.NotAuthorized;
|
42 |
|
import org.dataone.service.exceptions.NotImplemented;
|
43 |
|
import org.dataone.service.exceptions.ServiceFailure;
|
44 |
|
import org.dataone.service.types.v1.Node;
|
45 |
|
import org.dataone.service.types.v1.NodeReference;
|
46 |
|
import org.dataone.service.types.v1.Session;
|
47 |
42 |
|
48 |
43 |
import edu.ucsb.nceas.metacat.MetacatVersion;
|
49 |
44 |
import edu.ucsb.nceas.metacat.database.DBVersion;
|
50 |
|
import edu.ucsb.nceas.metacat.dataone.MNodeService;
|
51 |
45 |
import edu.ucsb.nceas.metacat.properties.PropertyService;
|
52 |
46 |
import edu.ucsb.nceas.metacat.service.ServiceService;
|
53 |
47 |
import edu.ucsb.nceas.metacat.shared.MetacatUtilException;
|
... | ... | |
57 |
51 |
import edu.ucsb.nceas.utilities.FileUtil;
|
58 |
52 |
import edu.ucsb.nceas.utilities.GeneralPropertyException;
|
59 |
53 |
import edu.ucsb.nceas.utilities.PropertiesMetaData;
|
60 |
|
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
|
61 |
54 |
import edu.ucsb.nceas.utilities.SortedProperties;
|
62 |
55 |
import edu.ucsb.nceas.utilities.UtilException;
|
63 |
56 |
|
... | ... | |
141 |
134 |
externalDir + FileUtil.getFS() + "temporary");
|
142 |
135 |
PropertyService.setPropertyNoPersist("replication.logdir",
|
143 |
136 |
externalDir + FileUtil.getFS() + "logs");
|
|
137 |
PropertyService.setPropertyNoPersist("solr.homeDir",
|
|
138 |
externalDir + FileUtil.getFS() + "solr-home");
|
144 |
139 |
|
145 |
140 |
PropertyService.persistProperties();
|
146 |
141 |
|
... | ... | |
264 |
259 |
validationErrors.add(errorString);
|
265 |
260 |
}
|
266 |
261 |
|
|
262 |
// Try to create and initialize the solr-home directory if necessary.
|
|
263 |
String solrHomePath = PropertyService.getProperty("solr.homeDir");
|
|
264 |
String indexContext = PropertyService.getProperty("index.context");
|
|
265 |
boolean solrHomeExists = new File(solrHomePath).exists();
|
|
266 |
if (!solrHomeExists) {
|
|
267 |
try {
|
|
268 |
FileUtil.createDirectory(solrHomePath);
|
|
269 |
String metacatWebInf = ServiceService.getRealConfigDir();
|
|
270 |
String metacatIndexSolrHome = metacatWebInf + "/../../" + indexContext + "/WEB-INF/classes/solr-home";
|
|
271 |
OrFileFilter fileFilter = new OrFileFilter();
|
|
272 |
fileFilter.addFileFilter(DirectoryFileFilter.DIRECTORY);
|
|
273 |
fileFilter.addFileFilter(new WildcardFileFilter("*"));
|
|
274 |
FileUtils.copyDirectory(new File(metacatIndexSolrHome), new File(solrHomePath), fileFilter );
|
|
275 |
} catch (Exception ue) {
|
|
276 |
String errorString = "PropertiesAdmin.configureProperties - Could not initialize directory: " + solrHomePath +
|
|
277 |
" : " + ue.getMessage();
|
|
278 |
logMetacat.error(errorString);
|
|
279 |
validationErrors.add(errorString);
|
|
280 |
}
|
|
281 |
} else {
|
|
282 |
// check it
|
|
283 |
if (!FileUtil.isDirectory(solrHomePath)) {
|
|
284 |
String errorString = "PropertiesAdmin.configureProperties - SOLR home is not a directory: " + solrHomePath;
|
|
285 |
logMetacat.error(errorString);
|
|
286 |
validationErrors.add(errorString);
|
|
287 |
}
|
|
288 |
}
|
|
289 |
|
267 |
290 |
// write the backup properties to a location outside the
|
268 |
291 |
// application directories so they will be available after
|
269 |
292 |
// the next upgrade
|
initialize the SOLR home directory if it does not already exist.