Project

General

Profile

« Previous | Next » 

Revision 7694

initialize the SOLR home directory if it does not already exist.

View differences:

lib/metacat.properties.metadata.xml
295 295
		<helpFile>docs/metacat-properties.html#replication-logdir</helpFile>
296 296
	</config>
297 297
	
298
	<config>
299
		<key>index.context</key>
300
		<label>Index Context</label>
301
		<group>3</group>
302
		<index>10</index>
303
		<description>
304
			The context name for the deployed Metacat index webapp.
305
		</description>
306
		<helpFile>docs/metacat-properties.html#application-index-context</helpFile>
307
	</config>
308
	
309
	<config>
310
		<key>solr.homeDir</key>
311
		<label>SOLR Home directory</label>
312
		<group>3</group>
313
		<index>11</index>
314
		<description>
315
			The directory where replication log should be located.
316
		</description>
317
		<helpFile>docs/metacat-properties.html#application-solr-home</helpFile>
318
	</config>
319
	
298 320
	<!-- START Data Manager configuration -->
299 321
	<config>
300 322
		<key>datamanager.server</key>
lib/metacat.properties
583 583
#guid.ezid.doishoulder.3=doi:10.5072/FK2/PISCO/
584 584
#guid.ezid.doishoulder.6=doi:10.5072/FK2/LTER/
585 585

  
586
############# Index Section ###########################################
587
index.context=metacat-index
588

  
586 589
############# SOLR Search Section ###########################################
587
 #Embedded (default):
588
 solr.server.classname=org.apache.solr.client.solrj.embedded.EmbeddedSolrServer
589
 solr.homeDir=/var/metacat/solr-home
590
 solr.configFileName=solr.xml
591
 solr.collectionName=collection1
590
#Embedded (default):
591
solr.server.classname=org.apache.solr.client.solrj.embedded.EmbeddedSolrServer
592
solr.homeDir=/var/metacat/solr-home
593
solr.configFileName=solr.xml
594
solr.collectionName=collection1
592 595
  
593 596
#HTTP:
594
 #solr.server.classname=org.apache.solr.client.solrj.impl.CommonsHttpSolrServer
595
 solr.endpoint=http://localhost:8080/solr/
597
#solr.server.classname=org.apache.solr.client.solrj.impl.CommonsHttpSolrServer
598
solr.endpoint=http://localhost:8080/solr/
src/edu/ucsb/nceas/metacat/admin/PropertiesAdmin.java
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

Also available in: Unified diff