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


Java IOService.newDirectoryStream方法代码示例

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


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

示例1: scanDirectories

import org.uberfire.io.IOService; //导入方法依赖的package包/类
public Collection<ScanResult> scanDirectories(IOService ioService, Path rootPath, final boolean includeRoot, final boolean recursiveScan/*, final Map<Path, Path> scannedCache*/) throws IOException {
    final Collection<ScanResult> results = new ArrayList<ScanResult>();
    final List<Path> childDirectories = new ArrayList<Path>();

    if (rootPath != null) {
        if (Files.isDirectory(rootPath) /* && !scannedCache.containsKey(rootPath)*/) {
            //scannedCache.put(rootPath, rootPath);
            if (includeRoot) results.add(new ScanResult(rootPath));



            final DirectoryStream<Path> children = ioService.newDirectoryStream(rootPath);
            //finally
            if (recursiveScan) {
                for (Path child : children) {
                    results.addAll( scanDirectories(ioService, child, true, recursiveScan/*, scannedCache*/) );
                }
            }
        }
    }
    return results;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:23,代码来源:FileUtils.java

示例2: isDeleteableDir

import org.uberfire.io.IOService; //导入方法依赖的package包/类
public DirDescriptor isDeleteableDir(final IOService ioService, Path dirPath, List<String> deleteableFiles) throws IOException {
    DirDescriptor dirDescriptor = new DirDescriptor(dirPath);
    boolean deleteable = false;

    final DirectoryStream<Path> children = ioService.newDirectoryStream(dirPath);
    if (children == null) {
        deleteable = true;
    } else {
        Iterator<Path> iterator = children.iterator();
        if (iterator == null) {
            deleteable = true;
        } else {
            deleteable = true;
            for (Path child : children) {
                if (Files.isDirectory(child)) {
                    dirDescriptor.setDeleteable(false);
                    return dirDescriptor;
                }
                for (String deleteableFile : deleteableFiles) {
                    if (!child.getFileName().endsWith(deleteableFile)) {
                        dirDescriptor.setDeleteable(false);
                        return dirDescriptor;
                    } else {
                        dirDescriptor.addChild(child);
                    }
                }
            }
        }
    }

    dirDescriptor.setDeleteable(deleteable);
    return dirDescriptor;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:34,代码来源:FileUtils.java

示例3: isEmpty

import org.uberfire.io.IOService; //导入方法依赖的package包/类
public boolean isEmpty(final IOService ioService, Path dirPath) throws IOException {
    if (dirPath == null) return true;

    final DirectoryStream<Path> children = ioService.newDirectoryStream(dirPath);
    if (children == null) return true;
    Iterator<Path> iterator = children.iterator();
    return iterator == null || !iterator.hasNext();
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:9,代码来源:FileUtils.java

示例4: migrate

import org.uberfire.io.IOService; //导入方法依赖的package包/类
public static void migrate(Path dir, IOService ioService, XStream xs, KieServerTemplateStorage templateStorage) {

        logger.debug("Attempting to find and migrate 6.2 type kie server templates inside directory '{}'...", dir);
        try {
            ioService.startBatch(dir.getFileSystem());
            for (final Path path : ioService.newDirectoryStream(dir, new DirectoryStream.Filter<Path>() {
                @Override
                public boolean accept(Path entry) throws IOException {
                    return entry.toString().endsWith("-info.xml");
                }
            })) {

                logger.debug("Found 6.2 type kie server template file '{}', migrating it...", path);
                try {
                    final KieServerInstance kieServerInstance = (KieServerInstance) xs.fromXML(ioService.readAllString(path));

                    logger.debug("Loaded KieServerInstance {}", kieServerInstance);
                    ServerTemplate serverTemplate = new ServerTemplate();
                    serverTemplate.setId(kieServerInstance.getIdentifier());
                    serverTemplate.setName(kieServerInstance.getName());

                    KieServerSetup serverSetup = kieServerInstance.getKieServerSetup();
                    if (serverSetup != null) {
                        Set<KieContainerResource> containerResources = kieServerInstance.getKieServerSetup().getContainers();
                        logger.debug("Server with id {} has containers {}", kieServerInstance.getIdentifier(), containerResources);
                        if (containerResources != null) {
                            for (KieContainerResource containerRef : containerResources) {

                                ContainerSpec containerSpec = new ContainerSpec(containerRef.getContainerId(),
                                        containerRef.getContainerId(),
                                        serverTemplate,
                                        containerRef.getReleaseId(),
                                        containerRef.getStatus(),
                                        new HashMap<Capability, ContainerConfig>());

                                logger.debug("Migrating container '{}' to container spec '{}'", containerRef, containerSpec);
                                serverTemplate.addContainerSpec(containerSpec);
                            }
                        }

                    }
                    Set<KieServerInstanceInfo> instanceInfos = kieServerInstance.getManagedInstances();
                    if (instanceInfos != null) {
                        logger.debug("Server with id {} has server instances {}", kieServerInstance.getIdentifier(), instanceInfos);
                        for (KieServerInstanceInfo instanceInfo : instanceInfos) {

                            logger.debug("Migrating server instance '{}'", instanceInfo);
                            serverTemplate.addServerInstance(ModelFactory.newServerInstanceKey(serverTemplate.getId(), instanceInfo.getLocation()));

                            serverTemplate.setCapabilities(instanceInfo.getCapabilities());
                        }
                    }
                    logger.debug("About to store migrated server template {}", serverTemplate);
                    // store migrated information
                    templateStorage.store(serverTemplate);
                    logger.info("Server template {} migrated successfully, removing old version...", serverTemplate);
                    // delete old to do not attempt second time migration
                    try {
                        ioService.startBatch(path.getFileSystem());
                        ioService.delete(path);
                    } finally {
                        ioService.endBatch();
                    }
                    logger.debug("Old version of server template '{}' has been removed", kieServerInstance);
                } catch (Exception ex) {
                    logger.error("Error while migrating old version (6.2.) of kie server instance from path {}", path, ex);
                }
            }

        } catch ( final NotDirectoryException ignore ) {
            logger.debug("No directory found, ignoring migration of kie server templates");
        } finally {
            ioService.endBatch();
        }
    }
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:76,代码来源:ServerTemplateMigration.java

示例5: scan

import org.uberfire.io.IOService; //导入方法依赖的package包/类
private Collection<ScanResult> scan(IOService ioService, Path rootPath, final Collection<String> fileTypes, final boolean recursiveScan, final Map<Path, Path> scannedCache) throws IOException {
    final Collection<ScanResult> results = new ArrayList<ScanResult>();
    final List<Path> childDirectories = new ArrayList<Path>();

    if (rootPath != null) {
        if (Files.isDirectory(rootPath) && !scannedCache.containsKey(rootPath)) {
            scannedCache.put(rootPath, rootPath);

            final DirectoryStream<Path> foundFiles = ioService.newDirectoryStream( rootPath ,
                    new DirectoryStream.Filter<Path>() {

                        @Override
                        public boolean accept( final Path entry ) throws IOException {

                            boolean include = false;

                            if ( Files.isDirectory( entry ) && recursiveScan) {
                                //use this check iteration to additionally remember child directories
                                childDirectories.add(entry);
                            } else {
                                if (fileTypes == null) {
                                    include = true;
                                } else {
                                    include = isFromType( entry, fileTypes );
                                        }
                                    }
                            return include;
                    }
            } );

            if (foundFiles != null) {
                for (Path acceptedFile : foundFiles) {
                    results.add(new ScanResult(acceptedFile));
                }
            }
            
            //finally
            if (recursiveScan) {
                for (Path child : childDirectories) {
                    results.addAll( scan(ioService, child, fileTypes, recursiveScan, scannedCache) );
                }
            }
        }
    }
    return results;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:47,代码来源:FileUtils.java


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