Example usage for org.apache.solr.cloud ZkSolrResourceLoader getConfigSetZkPath

List of usage examples for org.apache.solr.cloud ZkSolrResourceLoader getConfigSetZkPath

Introduction

In this page you can find the example usage for org.apache.solr.cloud ZkSolrResourceLoader getConfigSetZkPath.

Prototype

public String getConfigSetZkPath() 

Source Link

Usage

From source file:alba.components.FilteredShowFileRequestHandler.java

License:Apache License

public static String getAdminFileFromZooKeeper(SolrQueryRequest req, SolrQueryResponse rsp,
        SolrZkClient zkClient, Set<String> hiddenFiles) throws KeeperException, InterruptedException {
    String adminFile = null;//w ww  .ja v a2s .  co m
    SolrCore core = req.getCore();

    final ZkSolrResourceLoader loader = (ZkSolrResourceLoader) core.getResourceLoader();
    String confPath = loader.getConfigSetZkPath();

    String fname = req.getParams().get("file", null);
    if (fname == null) {
        adminFile = confPath;
    } else {
        fname = fname.replace('\\', '/'); // normalize slashes
        if (isHiddenFile(req, rsp, fname, true, hiddenFiles)) {
            return null;
        }
        if (fname.startsWith("/")) { // Only files relative to conf are valid
            fname = fname.substring(1);
        }
        adminFile = confPath + "/" + fname;
    }

    // Make sure the file exists, is readable and is not a hidden file
    if (!zkClient.exists(adminFile, true)) {
        log.error("Can not find: " + adminFile);
        rsp.setException(new SolrException(SolrException.ErrorCode.NOT_FOUND, "Can not find: " + adminFile));
        return null;
    }

    return adminFile;
}