Java Code Examples for org.apache.commons.io.filefilter.FileFilterUtils

The following examples show how to use org.apache.commons.io.filefilter.FileFilterUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ghidra   Source File: PatternStats.java    License: Apache License 2.0 6 votes vote down vote up
protected void runSummary(File dir) throws FileNotFoundException, IOException, SAXException {
	HashMap<DittedBitSequence, PatternAccumulate> hashMap =
		new HashMap<>();

	Iterator<File> iterator = FileUtils.iterateFiles(dir,
		FileFilterUtils.prefixFileFilter("pat_"), FalseFileFilter.INSTANCE);

	while (iterator.hasNext()) {
		File f = iterator.next();
		accumulateFile(hashMap, new ResourceFile(f));
	}

	println("     Total FalseWith   FalseNo  Pattern");
	for (PatternAccumulate accum : hashMap.values()) {
		StringBuffer buf = new StringBuffer();
		accum.displaySummary(buf);
		println(buf.toString());
	}
}
 
Example 2
Source Project: canal-1.1.3   Source File: ApplicationConfigMonitor.java    License: Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    File confDir = Util.getConfDirPath();
    try {
        FileAlterationObserver observer = new FileAlterationObserver(confDir,
            FileFilterUtils.and(FileFilterUtils.fileFileFilter(),
                FileFilterUtils.prefixFileFilter("application"),
                FileFilterUtils.suffixFileFilter("yml")));
        FileListener listener = new FileListener();
        observer.addListener(listener);
        fileMonitor = new FileAlterationMonitor(3000, observer);
        fileMonitor.start();

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example 3
Source Project: javaccPlugin   Source File: CompiledJavaccFile.java    License: MIT License 6 votes vote down vote up
private File scanSourceFiles(String compiledJavaccFilePackage, Collection<File> sourceFiles) {
    for (File sourceFile : sourceFiles) {
        logger.debug("Scanning source file [{}] looking for a file named [{}] in package [{}]", sourceFile, compiledJavaccFile.getName(), compiledJavaccFilePackage);
        if (sourceFile.isDirectory()) {
            Collection<File> childFiles = FileUtils.listFiles(sourceFile, FileFilterUtils.suffixFileFilter(".java"), TrueFileFilter.TRUE);
            File matchingChildFile = scanSourceFiles(compiledJavaccFilePackage, childFiles);
            if (matchingChildFile != null) {
                return matchingChildFile;
            }
        } else {
            if (FilenameUtils.isExtension(sourceFile.getName(), "java") && compiledJavaccFile.getName().equals(sourceFile.getName())) {
                String packageName = getPackageName(sourceFile);

                if (compiledJavaccFilePackage.equals(packageName)) {
                    return sourceFile;
                }
            }
        }
    }

    return null;
}
 
Example 4
Source Project: canal-1.1.3   Source File: RdbConfigMonitor.java    License: Apache License 2.0 6 votes vote down vote up
public void init(String key, RdbAdapter rdbAdapter, Properties envProperties) {
    this.key = key;
    this.rdbAdapter = rdbAdapter;
    this.envProperties = envProperties;
    File confDir = Util.getConfDirPath(adapterName);
    try {
        FileAlterationObserver observer = new FileAlterationObserver(confDir,
            FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.suffixFileFilter("yml")));
        FileListener listener = new FileListener();
        observer.addListener(listener);
        fileMonitor = new FileAlterationMonitor(3000, observer);
        fileMonitor.start();

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example 5
Source Project: canal-1.1.3   Source File: ESConfigMonitor.java    License: Apache License 2.0 6 votes vote down vote up
public void init(ESAdapter esAdapter, Properties envProperties) {
        this.esAdapter = esAdapter;
        this.envProperties = envProperties;
        File confDir = Util.getConfDirPath(adapterName);
        try {
            FileAlterationObserver observer = new FileAlterationObserver(confDir,
                FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.suffixFileFilter("yml")));
//            文件变化监听采用的common io的类库
            FileListener listener = new FileListener();
            observer.addListener(listener);
            fileMonitor = new FileAlterationMonitor(3000, observer);
            fileMonitor.start();

        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }
 
Example 6
Source Project: canal   Source File: RdbConfigMonitor.java    License: Apache License 2.0 6 votes vote down vote up
public void init(String key, RdbAdapter rdbAdapter, Properties envProperties) {
    this.key = key;
    this.rdbAdapter = rdbAdapter;
    this.envProperties = envProperties;
    File confDir = Util.getConfDirPath(adapterName);
    try {
        FileAlterationObserver observer = new FileAlterationObserver(confDir,
            FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.suffixFileFilter("yml")));
        FileListener listener = new FileListener();
        observer.addListener(listener);
        fileMonitor = new FileAlterationMonitor(3000, observer);
        fileMonitor.start();

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example 7
Source Project: proctor   Source File: SvnWorkspaceProviderImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    try {
        if (!shutdown.get()) {
            LOGGER.info("Actively cleaning up directories older than " + TimeUnit.MILLISECONDS.toHours(cleanupAgeMillis) + " hours");
            final IOFileFilter olderThanFilter = FileFilterUtils.asFileFilter(olderThanFileFilter(cleanupAgeMillis));
            final IOFileFilter tempDirFilter =
                FileFilterUtils.prefixFileFilter(prefix);

            /*
             * Delete directories that are:
             * older than [clean up age millis]
             * starts with temp-dir-prefix
             */
            final IOFileFilter deleteAfterMillisFilter = FileFilterUtils.makeDirectoryOnly(
                FileFilterUtils.andFileFilter(olderThanFilter, tempDirFilter)
            );
            deleteUserDirectories(rootDirectory, deleteAfterMillisFilter);
        } else {
            LOGGER.info("Currently shutdown, skipping older-than directory cleanup");
        }
    } catch (Exception e) {
        LOGGER.error("Unhandled Exception during directory cleanup", e);
    }
}
 
Example 8
Source Project: util4j   Source File: FileMonitor.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 只监控文件发送变化,如果是子目录的文件改变,则目录会变,由于没有过滤目录发生变化,则目录下的文件改变不会监控到
 * @param dir
 * @throws Exception 
 */
public void check1(String dir) throws Exception
{
	File directory = new File(dir);
    // 轮询间隔 5 秒
    long interval = TimeUnit.SECONDS.toMillis(5);
    // 创建一个文件观察器用于处理文件的格式
    IOFileFilter filter=FileFilterUtils.or(FileFilterUtils.suffixFileFilter(".class"),
    		FileFilterUtils.suffixFileFilter(".jar"));
    FileAlterationObserver observer = new FileAlterationObserver(directory,filter);
    //设置文件变化监听器
    observer.addListener(new MyFileListener());
    FileAlterationMonitor monitor = new FileAlterationMonitor(interval);
    monitor.addObserver(observer);//文件观察
    monitor.start();
}
 
Example 9
Source Project: japi   Source File: ProjectImpl.java    License: MIT License 6 votes vote down vote up
@Override
public List<IPackage> getPackages() {
    String masterProjectActionPath = JapiClient.getConfig().getPrefixPath() + JapiClient.getConfig().getProjectJavaPath() + JapiClient.getConfig().getPostfixPath() + "/" + JapiClient.getConfig().getActionReletivePath();
    File actionFold = new File(masterProjectActionPath);
    if (!actionFold.exists()) {
        throw new JapiException(masterProjectActionPath + " fold not exists.");
    }
    final IOFileFilter dirFilter = FileFilterUtils.asFileFilter(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.isDirectory();
        }
    });
    Collection<File> folds = FileUtils.listFilesAndDirs(actionFold, dirFilter, TrueFileFilter.INSTANCE);
    List<IPackage> packages = new ArrayList<>(folds.size());
    for (File fold : folds) {
        if (!fold.getAbsolutePath().equals(actionFold.getAbsolutePath())) {
            PackageImpl packageImpl = new PackageImpl();
            packageImpl.setPackageFold(fold);
            packages.add(packageImpl);
        }
    }
    return packages;
}
 
Example 10
Source Project: japi   Source File: PackageImpl.java    License: MIT License 6 votes vote down vote up
@Override
public List<IAction> getActions() {
    final IOFileFilter dirFilter = FileFilterUtils.asFileFilter(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.getName().endsWith(".java") && !pathname.getName().equals("package-info.java");
        }
    });
    Collection<File> actionFiles = FileUtils.listFiles(packageFold, dirFilter, null);
    List<IAction> actions = new ArrayList<>();
    for (File actionFile : actionFiles) {
        ActionImpl action = new ActionImpl();
        action.setActionFile(actionFile);
        actions.add(action);
    }
    return actions;
}
 
Example 11
Source Project: proctor   Source File: AbstractProctorMojo.java    License: Apache License 2.0 6 votes vote down vote up
void createTotalSpecifications(final File dir, final String packageDirectory) throws MojoExecutionException {

        if (dir.equals(null)) {
            throw new MojoExecutionException("Could not read from directory " + dir.getPath());
        }
        final File[] files = dir.listFiles();
        if (files == null) {
            return;
        }
        final File[] providedContextFiles = dir.listFiles((java.io.FileFilter) FileFilterUtils.andFileFilter(FileFilterUtils.fileFileFilter(), FileFilterUtils.nameFileFilter("providedcontext.json")));
        if (providedContextFiles.length == 1) {
            final File parent = providedContextFiles[0].getParentFile();
            final File outputDir = new File(getSpecificationOutput() + File.separator + packageDirectory.substring(0,packageDirectory.lastIndexOf(File.separator)));
            outputDir.mkdirs();
            try {
                generateTotalSpecification(parent, outputDir);
            } catch (final CodeGenException e) {
                throw new MojoExecutionException("Couldn't create total specification",e);
            }
        }
        for (final File entry : dir.listFiles()) {
            if (entry.isDirectory()) {
                createTotalSpecifications(entry, (packageDirectory == null) ? entry.getName() : packageDirectory + File.separator + entry.getName());
            }
        }
    }
 
Example 12
Source Project: roboconf-platform   Source File: TemplateWatcher.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onStart( final FileAlterationObserver observer ) {

	if( this.alreadyStarted.getAndSet( true ))
		return;

	this.logger.fine("Initial provisioning of templates...");
	final Collection<File> templateFiles = FileUtils.listFiles(
			this.templateDir,

			// Find readable template files.
			FileFilterUtils.and(
					FileFilterUtils.suffixFileFilter( ".tpl" ),
					CanReadFileFilter.CAN_READ),

			// Directory filter: go through the root template directory and its direct children.
			new TemplateDirectoryFileFilter( this.templateDir ));

	process( templateFiles );
}
 
Example 13
Source Project: api-mining   Source File: FilesetSplit.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param args
 */
public static void main(final String[] args) {
	if (args.length < 7) {
		System.err
				.println("Usage fromDirectory toDirectory fileSuffix <<segmentName_i> <weight_i> ...>");
		System.exit(-1);
	}

	final File fromDirectory = new File(args[0]);
	final File toDirectory = new File(args[1]);

	final IOFileFilter fileFilter = FileFilterUtils
			.suffixFileFilter(args[2]);

	final Map<String, Double> segments = Maps.newHashMap();

	for (int i = 3; i < args.length; i += 2) {
		segments.put(args[i], Double.valueOf(args[i + 1]));
	}

	LOGGER.info("Splitting files in segments " + segments);
	splitFiles(fromDirectory, toDirectory, segments, fileFilter,
			UNIFORM_FILE_WEIGHT);
}
 
Example 14
Source Project: celerio   Source File: IOUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Recurse in the folder to get the list all files and folders
 * <ul>
 * <li>do not recurse in svn folder</li>
 * <li>do not recurse in cvs folder</li>
 * <li>do not match .bak files</li>
 * <li>do not match .old files</li>
 * </ul>
 *
 * @param folder       the folder to parse
 * @param ioFileFilter additionnal IOFilter
 */
@SuppressWarnings("unchecked")
public Collection<String> listFiles(File folder, IOFileFilter ioFileFilter) {
    if (ioFileFilter == null) {
        ioFileFilter = FileFilterUtils.fileFileFilter();
    }
    OrFileFilter oldFilesFilter = new OrFileFilter();
    for (String exclude : DEFAULT_EXCLUDES_SUFFIXES) {
        oldFilesFilter.addFileFilter(FileFilterUtils.suffixFileFilter(exclude));
    }
    IOFileFilter notOldFilesFilter = FileFilterUtils.notFileFilter(oldFilesFilter);

    Collection<File> files = FileUtils.listFiles(folder, FileFilterUtils.andFileFilter(ioFileFilter, notOldFilesFilter),
            FileFilterUtils.makeSVNAware(FileFilterUtils.makeCVSAware(null)));
    Collection<String> ret = newArrayList();
    for (File file : files) {
        ret.add(file.getAbsolutePath());
    }
    return ret;
}
 
Example 15
/**
 * {@inheritDoc}
 */
public String compileCUT(GameClass cut) throws CompileException {
    AntProcessResult result = runAntTarget("compile-cut", null, null, cut, null, forceLocalExecution);

    logger.info("Compile New CUT, Compilation result: {}", result);

    String pathCompiledClassName = null;
    if (result.compiled()) {
        // If the input stream returned a 'successful build' message, the CUT compiled correctly
        logger.info("Compiled uploaded CUT successfully");
        File f = Paths.get(CUTS_DIR, cut.getAlias()).toFile();
        final String compiledClassName = FilenameUtils.getBaseName(cut.getJavaFile()) + Constants.JAVA_CLASS_EXT;
        LinkedList<File> matchingFiles = (LinkedList<File>) FileUtils.listFiles(f, FileFilterUtils.nameFileFilter(compiledClassName), FileFilterUtils.trueFileFilter());
        if (!matchingFiles.isEmpty())
            pathCompiledClassName = matchingFiles.get(0).getAbsolutePath();
    } else {
        // Otherwise the CUT failed to compile
        String message = result.getCompilerOutput();
        logger.error("Failed to compile uploaded CUT: {}", message);
        throw new CompileException(message);
    }
    return pathCompiledClassName;
}
 
Example 16
Source Project: canal   Source File: HbaseConfigMonitor.java    License: Apache License 2.0 6 votes vote down vote up
public void init(HbaseAdapter hbaseAdapter, Properties envProperties) {
    this.hbaseAdapter = hbaseAdapter;
    this.envProperties = envProperties;
    File confDir = Util.getConfDirPath(adapterName);
    try {
        FileAlterationObserver observer = new FileAlterationObserver(confDir,
            FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.suffixFileFilter("yml")));
        FileListener listener = new FileListener();
        observer.addListener(listener);
        fileMonitor = new FileAlterationMonitor(3000, observer);
        fileMonitor.start();

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example 17
Source Project: tassal   Source File: FilesetSplit.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param args
 */
public static void main(final String[] args) {
	if (args.length < 7) {
		System.err
				.println("Usage fromDirectory toDirectory fileSuffix <<segmentName_i> <weight_i> ...>");
		System.exit(-1);
	}

	final File fromDirectory = new File(args[0]);
	final File toDirectory = new File(args[1]);

	final IOFileFilter fileFilter = FileFilterUtils
			.suffixFileFilter(args[2]);

	final Map<String, Double> segments = Maps.newHashMap();

	for (int i = 3; i < args.length; i += 2) {
		segments.put(args[i], Double.valueOf(args[i + 1]));
	}

	LOGGER.info("Splitting files in segments " + segments);
	splitFiles(fromDirectory, toDirectory, segments, fileFilter,
			UNIFORM_FILE_WEIGHT);
}
 
Example 18
protected IOFileFilter getPathBasedFileFilter() {
    List<File> selectedFiles = getSelectedDirectories(getSelectedPaths());
    if (selectedFiles.isEmpty()) {
        return null;
    }
    IOFileFilter fileFilter = null;
    for (File selectedFile : selectedFiles) {
        IOFileFilter subFilter = new SubDirectoryFileFilter(selectedFile);
        if (fileFilter == null) {
            fileFilter = subFilter;
        }
        else {
            fileFilter = FileFilterUtils.orFileFilter(fileFilter, subFilter);
        }
    }
    return fileFilter;
}
 
Example 19
Source Project: canal   Source File: ApplicationConfigMonitor.java    License: Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    File confDir = Util.getConfDirPath();
    try {
        FileAlterationObserver observer = new FileAlterationObserver(confDir,
            FileFilterUtils.and(FileFilterUtils.fileFileFilter(),
                FileFilterUtils.prefixFileFilter("application"),
                FileFilterUtils.suffixFileFilter("yml")));
        FileListener listener = new FileListener();
        observer.addListener(listener);
        fileMonitor = new FileAlterationMonitor(3000, observer);
        fileMonitor.start();

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example 20
public static void unlockLockedFilesOnQueue() {
final PropertyHandler propertyHandler = PropertyHandler.getInstance();
    if (propertyHandler.hasProperty("MESSAGE_QUEUE_FOLDER")) {
        String messageQueueFolderPath = propertyHandler.getProperty("MESSAGE_QUEUE_FOLDER");
        File messageQueueFolder = new File(messageQueueFolderPath);
        if (messageQueueFolder.exists()) {
            String lockedFileSuffix = "_LOCK";
            SuffixFileFilter suffixFileFilter = new SuffixFileFilter(lockedFileSuffix);

            Integer numberOfMinutes = propertyHandler.getIntegerProperty("locked.file.retention", "2");

            AgeFileFilter ageFileFilter = new AgeFileFilter(System.currentTimeMillis() - (numberOfMinutes * 60 * 1000));

            Collection<File> lockedFiles = FileUtils.listFiles(messageQueueFolder, FileFilterUtils.and(suffixFileFilter, ageFileFilter), TrueFileFilter.INSTANCE);
            for (File file : lockedFiles) {
                String lockedFileName = file.getAbsolutePath();
                File unlockedFile = new File(StringUtils.remove(lockedFileName, lockedFileSuffix));
                file.setLastModified(new Date().getTime());
                Boolean succesFullyUnlocked = file.renameTo(unlockedFile);
                if (succesFullyUnlocked) {
                    LOG.info("File: " + lockedFileName + " successfully unlocked.");
                }
            }
        } else {
            LOG.info("No directory found on location: " + messageQueueFolderPath + ". No files unlocked");
        }
    } else {
        LOG.info("No MESSAGE_QUEUE_FOLDER property in properties file. No files unlocked.");
    }
}
 
Example 21
public static void unlockLockedFilesOnQueue() {
   PropertyHandler propertyHandler = PropertyHandler.getInstance();
   if (propertyHandler.hasProperty("MESSAGE_QUEUE_FOLDER")) {
      String messageQueueFolderPath = propertyHandler.getProperty("MESSAGE_QUEUE_FOLDER");
      File messageQueueFolder = new File(messageQueueFolderPath);
      if (messageQueueFolder.exists()) {
         String lockedFileSuffix = "_LOCK";
         SuffixFileFilter suffixFileFilter = new SuffixFileFilter(lockedFileSuffix);
         Integer numberOfMinutes = propertyHandler.getIntegerProperty("locked.file.retention", "2");
         AgeFileFilter ageFileFilter = new AgeFileFilter(System.currentTimeMillis() - (long)(numberOfMinutes.intValue() * 60 * 1000));
         Collection<File> lockedFiles = FileUtils.listFiles(messageQueueFolder, FileFilterUtils.and(suffixFileFilter, ageFileFilter), TrueFileFilter.INSTANCE);
         Iterator var9 = lockedFiles.iterator();

         while(var9.hasNext()) {
            File file = (File)var9.next();
            String lockedFileName = file.getAbsolutePath();
            File unlockedFile = new File(StringUtils.remove(lockedFileName, lockedFileSuffix));
            file.setLastModified((new Date()).getTime());
            Boolean succesFullyUnlocked = file.renameTo(unlockedFile);
            if (succesFullyUnlocked.booleanValue()) {
               LOG.info("File: " + lockedFileName + " successfully unlocked.");
            }
         }
      } else {
         LOG.info("No directory found on location: " + messageQueueFolderPath + ". No files unlocked");
      }
   } else {
      LOG.info("No MESSAGE_QUEUE_FOLDER property in properties file. No files unlocked.");
   }

}
 
Example 22
public static void unlockLockedFilesOnQueue() {
final PropertyHandler propertyHandler = PropertyHandler.getInstance();
    if (propertyHandler.hasProperty("MESSAGE_QUEUE_FOLDER")) {
        String messageQueueFolderPath = propertyHandler.getProperty("MESSAGE_QUEUE_FOLDER");
        File messageQueueFolder = new File(messageQueueFolderPath);
        if (messageQueueFolder.exists()) {
            String lockedFileSuffix = "_LOCK";
            SuffixFileFilter suffixFileFilter = new SuffixFileFilter(lockedFileSuffix);

            Integer numberOfMinutes = propertyHandler.getIntegerProperty("locked.file.retention", "2");

            AgeFileFilter ageFileFilter = new AgeFileFilter(System.currentTimeMillis() - (numberOfMinutes * 60 * 1000));

            Collection<File> lockedFiles = FileUtils.listFiles(messageQueueFolder, FileFilterUtils.and(suffixFileFilter, ageFileFilter), TrueFileFilter.INSTANCE);
            for (File file : lockedFiles) {
                String lockedFileName = file.getAbsolutePath();
                File unlockedFile = new File(StringUtils.remove(lockedFileName, lockedFileSuffix));
                file.setLastModified(new Date().getTime());
                Boolean succesFullyUnlocked = file.renameTo(unlockedFile);
                if (succesFullyUnlocked) {
                    LOG.info("File: " + lockedFileName + " successfully unlocked.");
                }
            }
        } else {
            LOG.info("No directory found on location: " + messageQueueFolderPath + ". No files unlocked");
        }
    } else {
        LOG.info("No MESSAGE_QUEUE_FOLDER property in properties file. No files unlocked.");
    }
}
 
Example 23
public static void unlockLockedFilesOnQueue() {
final PropertyHandler propertyHandler = PropertyHandler.getInstance();
    if (propertyHandler.hasProperty("MESSAGE_QUEUE_FOLDER")) {
        String messageQueueFolderPath = propertyHandler.getProperty("MESSAGE_QUEUE_FOLDER");
        File messageQueueFolder = new File(messageQueueFolderPath);
        if (messageQueueFolder.exists()) {
            String lockedFileSuffix = "_LOCK";
            SuffixFileFilter suffixFileFilter = new SuffixFileFilter(lockedFileSuffix);

            Integer numberOfMinutes = propertyHandler.getIntegerProperty("locked.file.retention", "2");

            AgeFileFilter ageFileFilter = new AgeFileFilter(System.currentTimeMillis() - (numberOfMinutes * 60 * 1000));

            Collection<File> lockedFiles = FileUtils.listFiles(messageQueueFolder, FileFilterUtils.and(suffixFileFilter, ageFileFilter), TrueFileFilter.INSTANCE);
            for (File file : lockedFiles) {
                String lockedFileName = file.getAbsolutePath();
                File unlockedFile = new File(StringUtils.remove(lockedFileName, lockedFileSuffix));
                file.setLastModified(new Date().getTime());
                Boolean succesFullyUnlocked = file.renameTo(unlockedFile);
                if (succesFullyUnlocked) {
                    LOG.info("File: " + lockedFileName + " successfully unlocked.");
                }
            }
        } else {
            LOG.info("No directory found on location: " + messageQueueFolderPath + ". No files unlocked");
        }
    } else {
        LOG.info("No MESSAGE_QUEUE_FOLDER property in properties file. No files unlocked.");
    }
}
 
Example 24
Source Project: dashbuilder   Source File: MavenProjectHelper.java    License: Apache License 2.0 5 votes vote down vote up
public static List<File> getSourceFolders(File root) {
    List<File> javaFolders = getFolders(root, FileFilterUtils.nameFileFilter(JAVA_FOLDER));
    List<File> result = new ArrayList<File>();
    for (File javaFolder : javaFolders) {
        List<File> _folders = getFolders(javaFolder, null);
        result.add(javaFolder);
        result.addAll(_folders);
    }
    return result;
}
 
Example 25
Source Project: aion-germany   Source File: DataLoader.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method is supposed to be called from subclass to initialize data loading process.<br>
 * <br>
 * This method is using file given in the constructor to load the data and there are two possibilities:
 * <ul>
 * <li>Given file is file is in deed the <b>file</b> then it's forwarded to {@link #loadFile(File)} method</li>
 * <li>Given file is a <b>directory</b>, then this method is obtaining list of all visible .txt files in this directory and subdirectiores ( except hidden ones and those named "new" ) and call
 * {@link #loadFile(File)} for each of these files.
 * </ul>
 */
@SuppressWarnings("deprecation")
protected void loadData() {
	if (dataFile.isDirectory()) {
		Collection<?> files = FileUtils.listFiles(dataFile, FileFilterUtils.andFileFilter(FileFilterUtils.andFileFilter(FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("new")), FileFilterUtils.suffixFileFilter(".txt")), HiddenFileFilter.VISIBLE), HiddenFileFilter.VISIBLE);

		for (Object file1 : files) {
			File f = (File) file1;
			loadFile(f);
		}
	}
	else {
		loadFile(dataFile);
	}
}
 
Example 26
Source Project: sailfish-core   Source File: FileServiceStorage.java    License: Apache License 2.0 5 votes vote down vote up
public FileServiceStorage(String path, IWorkspaceDispatcher dispatcher, IStaticServiceManager manager, IMessageStorage storage) {
    this.path = Objects.requireNonNull(path, "path cannot be null");
    this.dispatcher = Objects.requireNonNull(dispatcher, "dispatcher cannot be null");
    this.manager = Objects.requireNonNull(manager, "manager cannot be null");
    this.storage = Objects.requireNonNull(storage, "storage cannot be null");

    try {
        if(!dispatcher.exists(FolderType.ROOT, path, SERVICES_DIR)) {
            return;
        }

        Set<String> fileNames = dispatcher.listFiles(FileFilterUtils.fileFileFilter(), FolderType.ROOT, path, SERVICES_DIR);

        for(String fileName : fileNames) {
            File file = dispatcher.getWritableFile(FolderType.ROOT, path, SERVICES_DIR, fileName);
            ServiceDescription description = serializer.deserialize(file);
            ServiceName serviceName = new ServiceName(description.getEnvironment(), description.getName());
            List<FileServiceEvent> events = new ServiceEventList(Paths.get(path, EVENTS_DIR, serviceName.toString()).toString(), dispatcher);

            descriptionMap.put(serviceName, description);
            eventsMap.put(serviceName, events);
            flusherMap.put(serviceName, new ObjectFlusher<>(new ListFlushProvider<>(events), BUFFER_SIZE, MAX_STORAGE_QUEUE_SIZE));
        }

        for(IObjectFlusher<FileServiceEvent> flusher : flusherMap.values()) {
            flusher.start();
        }
    } catch(Exception e) {
        throw new StorageException("Failed to load services", e);
    }
}
 
Example 27
Source Project: proctor   Source File: SvnWorkspaceProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void close() {
    if (shutdown.compareAndSet(false, true)) {
        LOGGER.info("[shutdown] started: deleting all working directories in " + rootDirectory);
        final long start = System.currentTimeMillis();
        // Delete any directories in the root directory that start with prefix
        deleteUserDirectories(rootDirectory, FileFilterUtils.makeDirectoryOnly(FileFilterUtils.prefixFileFilter(prefix)));
        LOGGER.info("[shutdown] complete: deleted working directories in " + (System.currentTimeMillis() - start) + " ms");
    }
}
 
Example 28
Source Project: util4j   Source File: DefaultClassSource.java    License: Apache License 2.0 5 votes vote down vote up
protected IOFileFilter buildFilterBySuffixs(String directory,String ...suffixs)
{
    IOFileFilter iOFileFilter=FileFilterUtils.directoryFileFilter(); //子目录变化
	for(String suffix:suffixs)
	{//后缀过滤器
		iOFileFilter=FileFilterUtils.or(iOFileFilter,FileFilterUtils.suffixFileFilter(suffix));
	}
    return iOFileFilter;
}
 
Example 29
Source Project: util4j   Source File: DefaultClassSource.java    License: Apache License 2.0 5 votes vote down vote up
protected IOFileFilter buildFilterByNames(String directory,String ...fileName)
{
    IOFileFilter iOFileFilter=FileFilterUtils.directoryFileFilter(); //子目录变化
	for(String name:fileName)
	{//名字过滤器
		iOFileFilter=FileFilterUtils.or(iOFileFilter,FileFilterUtils.nameFileFilter(name));
	}
    return iOFileFilter;
}
 
Example 30
Source Project: util4j   Source File: DefaultScriptSource.java    License: Apache License 2.0 5 votes vote down vote up
protected FileAlterationObserver buildFileAlterationObserver(String directory)
{
    //后缀过滤器
    IOFileFilter suffixFileFilter=FileFilterUtils.or(FileFilterUtils.suffixFileFilter(".class"),FileFilterUtils.suffixFileFilter(".jar"));
    //子目录变化
    IOFileFilter rootAndSubFilefilter=FileFilterUtils.or(FileFilterUtils.directoryFileFilter(),suffixFileFilter);
    return new FileAlterationObserver(directory,rootAndSubFilefilter);
}