use of org.jboss.vfs.VirtualFileFilter in project flyway by flyway.
the class JBossVFSv3ClassPathLocationScanner method findResourceNames.
public Set<String> findResourceNames(String location, URL locationUrl) throws IOException {
String filePath = UrlUtils.toFilePath(locationUrl);
String classPathRootOnDisk = filePath.substring(0, filePath.length() - location.length());
if (!classPathRootOnDisk.endsWith("/")) {
classPathRootOnDisk = classPathRootOnDisk + "/";
}
LOG.debug("Scanning starting at classpath root on JBoss VFS: " + classPathRootOnDisk);
Set<String> resourceNames = new TreeSet<String>();
List<VirtualFile> files = VFS.getChild(filePath).getChildrenRecursively(new VirtualFileFilter() {
public boolean accepts(VirtualFile file) {
return file.isFile();
}
});
for (VirtualFile file : files) {
resourceNames.add(file.getPathName().substring(classPathRootOnDisk.length()));
}
return resourceNames;
}
use of org.jboss.vfs.VirtualFileFilter in project wildfly-camel by wildfly-extras.
the class CamelContextDescriptorsProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
final String runtimeName = depUnit.getName();
CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
if (depSettings.isDisabledByJbossAll() || !depSettings.isDeploymentValid() || runtimeName.endsWith(".ear")) {
return;
}
try {
if (runtimeName.endsWith(CamelConstants.CAMEL_CONTEXT_FILE_SUFFIX)) {
URL fileURL = depUnit.getAttachment(Attachments.DEPLOYMENT_CONTENTS).asFileURL();
addConditionally(depUnit, fileURL);
} else {
VirtualFileFilter filter = new VirtualFileFilter() {
public boolean accepts(VirtualFile child) {
return child.isFile() && child.getName().endsWith(CamelConstants.CAMEL_CONTEXT_FILE_SUFFIX);
}
};
VirtualFile rootFile = depUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
for (VirtualFile vfile : rootFile.getChildrenRecursively(filter)) {
addConditionally(depUnit, vfile.asFileURL());
}
}
if (!depSettings.getCamelContextUrls().isEmpty()) {
LOGGER.info("Camel context descriptors found");
}
} catch (IOException ex) {
throw new IllegalStateException("Cannot create camel context: " + runtimeName, ex);
}
}
use of org.jboss.vfs.VirtualFileFilter in project wildfly by wildfly.
the class JdrTestCase method testWildcardFilterSuffixGlob.
@Test
public void testWildcardFilterSuffixGlob() throws Exception {
VirtualFileFilter filter = Filters.wildcard("/this/is*");
VirtualFile good = VFS.getChild("/this/is/a/test.txt");
VirtualFile bad = VFS.getChild("/that/is/a/test.txt");
VirtualFile wingood = VFS.getChild("/C:/this/is/a/test.txt");
VirtualFile winbad = VFS.getChild("/C:/that/is/a/test.txt");
assertTrue(filter.accepts(good));
assertFalse(filter.accepts(bad));
assertTrue(filter.accepts(wingood));
assertFalse(filter.accepts(winbad));
}
use of org.jboss.vfs.VirtualFileFilter in project wildfly by wildfly.
the class JdrTestCase method testBlackListFilter.
@Test
public void testBlackListFilter() {
VirtualFileFilter blf = Filters.regexBlackList();
assertFalse(blf.accepts(VFS.getChild("/foo/bar/baz/mgmt-users.properties")));
assertFalse(blf.accepts(VFS.getChild("/foo/bar/baz/application-users.properties")));
}
use of org.jboss.vfs.VirtualFileFilter in project camunda-bpm-platform by camunda.
the class VfsProcessApplicationScanner method scanRoot.
protected void scanRoot(VirtualFile processArchiveRoot, final String[] additionalResourceSuffixes, Map<String, byte[]> resources) {
try {
List<VirtualFile> processes = processArchiveRoot.getChildrenRecursively(new VirtualFileFilter() {
public boolean accepts(VirtualFile file) {
return file.isFile() && ProcessApplicationScanningUtil.isDeployable(file.getName(), additionalResourceSuffixes);
}
});
for (final VirtualFile process : processes) {
addResource(process, processArchiveRoot, resources);
// find diagram(s) for process
List<VirtualFile> diagrams = process.getParent().getChildren(new VirtualFileFilter() {
public boolean accepts(VirtualFile file) {
return ProcessApplicationScanningUtil.isDiagram(file.getName(), process.getName());
}
});
for (VirtualFile diagram : diagrams) {
addResource(diagram, processArchiveRoot, resources);
}
}
} catch (IOException e) {
LOG.cannotScanVfsRoot(processArchiveRoot, e);
}
}
Aggregations