当前位置: 首页>>代码示例>>Java>>正文


Java FileSystemUtils.isHidden方法代码示例

本文整理汇总了Java中org.elasticsearch.common.io.FileSystemUtils.isHidden方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystemUtils.isHidden方法的具体用法?Java FileSystemUtils.isHidden怎么用?Java FileSystemUtils.isHidden使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.common.io.FileSystemUtils的用法示例。


在下文中一共展示了FileSystemUtils.isHidden方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getModuleBundles

import org.elasticsearch.common.io.FileSystemUtils; //导入方法依赖的package包/类
static List<Bundle> getModuleBundles(Path modulesDirectory) throws IOException {
    // damn leniency
    if (Files.notExists(modulesDirectory)) {
        return Collections.emptyList();
    }
    List<Bundle> bundles = new ArrayList<>();
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(modulesDirectory)) {
        for (Path module : stream) {
            if (FileSystemUtils.isHidden(module)) {
                continue; // skip over .DS_Store etc
            }
            PluginInfo info = PluginInfo.readFromProperties(module);
            Bundle bundle = new Bundle();
            bundle.plugins.add(info);
            // gather urls for jar files
            try (DirectoryStream<Path> jarStream = Files.newDirectoryStream(module, "*.jar")) {
                for (Path jar : jarStream) {
                    // normalize with toRealPath to get symlinks out of our hair
                    bundle.urls.add(jar.toRealPath().toUri().toURL());
                }
            }
            bundles.add(bundle);
        }
    }
    return bundles;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:PluginsService.java

示例2: addMappings

import org.elasticsearch.common.io.FileSystemUtils; //导入方法依赖的package包/类
private void addMappings(Map<String, Map<String, Object>> mappings, Path mappingsDir) throws IOException {
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(mappingsDir)) {
        for (Path mappingFile : stream) {
            final String fileName = mappingFile.getFileName().toString();
            if (FileSystemUtils.isHidden(mappingFile)) {
                continue;
            }
            int lastDotIndex = fileName.lastIndexOf('.');
            String mappingType = lastDotIndex != -1 ? mappingFile.getFileName().toString().substring(0, lastDotIndex) : mappingFile.getFileName().toString();
            try (BufferedReader reader = Files.newBufferedReader(mappingFile, Charsets.UTF_8)) {
                String mappingSource = Streams.copyToString(reader);
                if (mappings.containsKey(mappingType)) {
                    XContentHelper.mergeDefaults(mappings.get(mappingType), parseMapping(mappingSource));
                } else {
                    mappings.put(mappingType, parseMapping(mappingSource));
                }
            } catch (Exception e) {
                logger.warn("failed to read / parse mapping [" + mappingType + "] from location [" + mappingFile + "], ignoring...", e);
            }
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:MetaDataCreateIndexService.java

示例3: getModuleBundles

import org.elasticsearch.common.io.FileSystemUtils; //导入方法依赖的package包/类
static List<Bundle> getModuleBundles(Path modulesDirectory) throws IOException {
    // damn leniency
    if (Files.notExists(modulesDirectory)) {
        return Collections.emptyList();
    }
    List<Bundle> bundles = new ArrayList<>();
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(modulesDirectory)) {
        for (Path module : stream) {
            if (FileSystemUtils.isHidden(module)) {
                continue; // skip over .DS_Store etc
            }
            PluginInfo info = PluginInfo.readFromProperties(module);
            if (!info.isJvm()) {
                throw new IllegalStateException("modules must be jvm plugins: " + info);
            }
            if (!info.isIsolated()) {
                throw new IllegalStateException("modules must be isolated: " + info);
            }
            Bundle bundle = new Bundle();
            bundle.plugins.add(info);
            // gather urls for jar files
            try (DirectoryStream<Path> jarStream = Files.newDirectoryStream(module, "*.jar")) {
                for (Path jar : jarStream) {
                    // normalize with toRealPath to get symlinks out of our hair
                    bundle.urls.add(jar.toRealPath().toUri().toURL());
                }
            }
            bundles.add(bundle);
        }
    }
    return bundles;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:33,代码来源:PluginsService.java

示例4: getPluginBundles

import org.elasticsearch.common.io.FileSystemUtils; //导入方法依赖的package包/类
static List<Bundle> getPluginBundles(Path pluginsDirectory) throws IOException {
    Logger logger = Loggers.getLogger(PluginsService.class);

    // TODO: remove this leniency, but tests bogusly rely on it
    if (!isAccessibleDirectory(pluginsDirectory, logger)) {
        return Collections.emptyList();
    }

    List<Bundle> bundles = new ArrayList<>();

    try (DirectoryStream<Path> stream = Files.newDirectoryStream(pluginsDirectory)) {
        for (Path plugin : stream) {
            if (FileSystemUtils.isHidden(plugin)) {
                logger.trace("--- skip hidden plugin file[{}]", plugin.toAbsolutePath());
                continue;
            }
            logger.trace("--- adding plugin [{}]", plugin.toAbsolutePath());
            final PluginInfo info;
            try {
                info = PluginInfo.readFromProperties(plugin);
            } catch (IOException e) {
                throw new IllegalStateException("Could not load plugin descriptor for existing plugin ["
                    + plugin.getFileName() + "]. Was the plugin built before 2.0?", e);
            }

            List<URL> urls = new ArrayList<>();
            try (DirectoryStream<Path> jarStream = Files.newDirectoryStream(plugin, "*.jar")) {
                for (Path jar : jarStream) {
                    // normalize with toRealPath to get symlinks out of our hair
                    urls.add(jar.toRealPath().toUri().toURL());
                }
            }
            final Bundle bundle = new Bundle();
            bundles.add(bundle);
            bundle.plugins.add(info);
            bundle.urls.addAll(urls);
        }
    }

    return bundles;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:42,代码来源:PluginsService.java

示例5: handlePluginSite

import org.elasticsearch.common.io.FileSystemUtils; //导入方法依赖的package包/类
void handlePluginSite(HttpRequest request, HttpChannel channel) throws IOException {
    if (disableSites) {
        channel.sendResponse(new BytesRestResponse(FORBIDDEN));
        return;
    }
    if (request.method() == RestRequest.Method.OPTIONS) {
        // when we have OPTIONS request, simply send OK by default (with the Access Control Origin header which gets automatically added)
        channel.sendResponse(new BytesRestResponse(OK));
        return;
    }
    if (request.method() != RestRequest.Method.GET) {
        channel.sendResponse(new BytesRestResponse(FORBIDDEN));
        return;
    }
    // TODO for a "/_plugin" endpoint, we should have a page that lists all the plugins?

    String path = request.rawPath().substring("/_plugin/".length());
    int i1 = path.indexOf('/');
    String pluginName;
    String sitePath;
    if (i1 == -1) {
        pluginName = path;
        sitePath = null;
        // If a trailing / is missing, we redirect to the right page #2654
        String redirectUrl = request.rawPath() + "/";
        BytesRestResponse restResponse = new BytesRestResponse(RestStatus.MOVED_PERMANENTLY, "text/html", "<head><meta http-equiv=\"refresh\" content=\"0; URL=" + redirectUrl + "\"></head>");
        restResponse.addHeader("Location", redirectUrl);
        channel.sendResponse(restResponse);
        return;
    } else {
        pluginName = path.substring(0, i1);
        sitePath = path.substring(i1 + 1);
    }

    // we default to index.html, or what the plugin provides (as a unix-style path)
    // this is a relative path under _site configured by the plugin.
    if (sitePath.length() == 0) {
        sitePath = "index.html";
    } else {
        // remove extraneous leading slashes, its not an absolute path.
        while (sitePath.length() > 0 && sitePath.charAt(0) == '/') {
            sitePath = sitePath.substring(1);
        }
    }
    final Path siteFile = environment.pluginsFile().resolve(pluginName).resolve("_site");

    final String separator = siteFile.getFileSystem().getSeparator();
    // Convert file separators.
    sitePath = sitePath.replace("/", separator);
    
    Path file = siteFile.resolve(sitePath);

    // return not found instead of forbidden to prevent malicious requests to find out if files exist or dont exist
    if (!Files.exists(file) || FileSystemUtils.isHidden(file) || !file.toAbsolutePath().normalize().startsWith(siteFile.toAbsolutePath().normalize())) {
        channel.sendResponse(new BytesRestResponse(NOT_FOUND));
        return;
    }

    BasicFileAttributes attributes = Files.readAttributes(file, BasicFileAttributes.class);
    if (!attributes.isRegularFile()) {
        // If it's not a dir, we send a 403
        if (!attributes.isDirectory()) {
            channel.sendResponse(new BytesRestResponse(FORBIDDEN));
            return;
        }
        // We don't serve dir but if index.html exists in dir we should serve it
        file = file.resolve("index.html");
        if (!Files.exists(file) || FileSystemUtils.isHidden(file) || !Files.isRegularFile(file)) {
            channel.sendResponse(new BytesRestResponse(FORBIDDEN));
            return;
        }
    }

    try {
        byte[] data = Files.readAllBytes(file);
        channel.sendResponse(new BytesRestResponse(OK, guessMimeType(sitePath), data));
    } catch (IOException e) {
        channel.sendResponse(new BytesRestResponse(INTERNAL_SERVER_ERROR));
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:81,代码来源:HttpServer.java

示例6: getPluginBundles

import org.elasticsearch.common.io.FileSystemUtils; //导入方法依赖的package包/类
static List<Bundle> getPluginBundles(Path pluginsDirectory) throws IOException {
    ESLogger logger = Loggers.getLogger(PluginsService.class);

    // TODO: remove this leniency, but tests bogusly rely on it
    if (!isAccessibleDirectory(pluginsDirectory, logger)) {
        return Collections.emptyList();
    }

    List<Bundle> bundles = new ArrayList<>();
    // a special purgatory for plugins that directly depend on each other
    bundles.add(new Bundle());

    try (DirectoryStream<Path> stream = Files.newDirectoryStream(pluginsDirectory)) {
        for (Path plugin : stream) {
            if (FileSystemUtils.isHidden(plugin)) {
                logger.trace("--- skip hidden plugin file[{}]", plugin.toAbsolutePath());
                continue;
            }
            if (!FileSystemUtils.isAccessibleDirectory(plugin, logger)) {
                continue;
            }
            PluginInfo info;
            try {
                info = PluginInfo.readFromProperties(plugin);
            } catch (NoSuchFileException e) {
                // es plugin descriptor file not found, ignore, could be a Crate plugin
                logger.trace("--- plugin descriptor file not found, ignoring plugin [{}]", plugin.toAbsolutePath());
                continue;
            }
            logger.trace("--- adding plugin [{}]", plugin.toAbsolutePath());
            List<URL> urls = new ArrayList<>();
            if (info.isJvm()) {
                // a jvm plugin: gather urls for jar files
                try (DirectoryStream<Path> jarStream = Files.newDirectoryStream(plugin, "*.jar")) {
                    for (Path jar : jarStream) {
                        // normalize with toRealPath to get symlinks out of our hair
                        urls.add(jar.toRealPath().toUri().toURL());
                    }
                }
            }
            final Bundle bundle;
            if (info.isJvm() && info.isIsolated() == false) {
                bundle = bundles.get(0); // purgatory
            } else {
                bundle = new Bundle();
                bundles.add(bundle);
            }
            bundle.plugins.add(info);
            bundle.urls.addAll(urls);
        }
    }

    return bundles;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:55,代码来源:PluginsService.java


注:本文中的org.elasticsearch.common.io.FileSystemUtils.isHidden方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。