Search in sources :

Example 1 with VirtualFileFilter

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;
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) VirtualFileFilter(org.jboss.vfs.VirtualFileFilter) TreeSet(java.util.TreeSet)

Example 2 with VirtualFileFilter

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);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) VirtualFileFilter(org.jboss.vfs.VirtualFileFilter) IOException(java.io.IOException) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) URL(java.net.URL)

Example 3 with VirtualFileFilter

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));
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) VirtualFileFilter(org.jboss.vfs.VirtualFileFilter) Test(org.junit.Test)

Example 4 with VirtualFileFilter

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")));
}
Also used : VirtualFileFilter(org.jboss.vfs.VirtualFileFilter) Test(org.junit.Test)

Example 5 with VirtualFileFilter

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);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) VirtualFileFilter(org.jboss.vfs.VirtualFileFilter) IOException(java.io.IOException)

Aggregations

VirtualFileFilter (org.jboss.vfs.VirtualFileFilter)11 VirtualFile (org.jboss.vfs.VirtualFile)10 IOException (java.io.IOException)5 Test (org.junit.Test)5 TreeSet (java.util.TreeSet)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)2 URL (java.net.URL)1 SuffixMatchFilter (org.jboss.vfs.util.SuffixMatchFilter)1 UDFMetaData (org.teiid.deployers.UDFMetaData)1