Example usage for org.apache.solr.core SolrResourceLoader normalizeDir

List of usage examples for org.apache.solr.core SolrResourceLoader normalizeDir

Introduction

In this page you can find the example usage for org.apache.solr.core SolrResourceLoader normalizeDir.

Prototype

public static String normalizeDir(String path) 

Source Link

Document

Ensures a directory name always ends with a '/'.

Usage

From source file:org.alfresco.solr.content.SolrContentStore.java

License:Open Source License

/**
 * Constructor.//from   ww  w. j a va 2s . c  o m
 * @param solrHome
 */
public SolrContentStore(String solrHome) {
    if (solrHome == null || solrHome.isEmpty()) {
        throw new RuntimeException("Path to SOLR_HOME is required");
    }

    File solrHomeFile = new File(SolrResourceLoader.normalizeDir(solrHome));
    if (!solrHomeFile.exists()) {
        //Its very unlikely that solrHome would not exist so we will log an error
        //but continue because solr.content.dir may be specified, so it keeps working
        log.error(solrHomeFile.getAbsolutePath() + " does not exist.");
    }

    String path = solrHomeFile.getParent() + "/" + CONTENT_STORE;
    log.warn(path + " will be used as a default path if " + SOLR_CONTENT_DIR + " property is not defined");
    File rootFile = new File(ConfigUtil.locateProperty(SOLR_CONTENT_DIR, path));

    try {
        FileUtils.forceMkdir(rootFile);
    } catch (Exception e) {
        throw new RuntimeException("Failed to create directory for content store: " + rootFile, e);
    }
    this.root = rootFile.getAbsolutePath();
}

From source file:org.alfresco.solr.tracker.ModelTracker.java

License:Open Source License

public ModelTracker(String solrHome, Properties p, SOLRAPIClient client, String coreName,
        InformationServer informationServer) {
    super(p, client, coreName, informationServer, Tracker.Type.Model);
    String normalSolrHome = SolrResourceLoader.normalizeDir(solrHome);
    alfrescoModelDir = new File(ConfigUtil.locateProperty("solr.model.dir", normalSolrHome + "alfrescoModels"));
    log.info("Alfresco Model dir " + alfrescoModelDir);
    if (!alfrescoModelDir.exists()) {
        alfrescoModelDir.mkdir();//  w  ww .j  av  a 2  s.co  m
    }

    loadPersistedModels();
}