public VFSArchive(URL rootUrl, String descriptorLocation) throws URISyntaxException, IOException { this.rootUrl = rootUrl; this.descriptorLocation = descriptorLocation; root = VFS.getChild(rootUrl.toURI()); List<VirtualFile> children = root.getChildrenRecursively(new VirtualFileFilter() { @Override public boolean accepts(VirtualFile file) { return file.isFile(); } }); files = new HashMap<String, VirtualFile>(); for (VirtualFile file : children) { files.put(file.getPathNameRelativeTo(root), file); } }
private void findFiles(URL jarToScan, Set<String> filePatterns, Map<String, Set<NamedInputStream>> map, Set<NamedInputStream> result) { if (filePatterns.isEmpty()) { for (Set<NamedInputStream> nims : map.values()) result.addAll(nims); } else { VirtualFile root = null; for (String pattern : filePatterns) { Set<NamedInputStream> niss = map.get(pattern); if (niss == null) { if (root == null) root = getFile(jarToScan); try { List<VirtualFile> children = root.getChildrenRecursively(new HibernatePatternFilter(pattern)); niss = toNIS(children); } catch (IOException e) { throw new RuntimeException(e); } } if (niss != null) result.addAll(niss); } } }
public static void process(VirtualFile deploymentRoot) throws DeploymentUnitProcessingException { if (deploymentRoot == null || !deploymentRoot.exists()) return; final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH); if (!deploymentRootName.endsWith(".rar")) { return; } try { List<VirtualFile> libs = deploymentRoot.getChildrenRecursively(new LibraryFilter()); if (libs != null && libs.size() > 0) { for (VirtualFile vf : libs) { String fileName = vf.getName().toLowerCase(Locale.ENGLISH); ROOT_LOGGER.tracef("Processing library: %s", fileName); try { File f = vf.getPhysicalFile(); System.load(f.getAbsolutePath()); ROOT_LOGGER.debugf("Loaded library: %s", f.getAbsolutePath()); } catch (Throwable t) { ROOT_LOGGER.debugf("Unable to load library: %s", fileName); } } } } catch (Exception e) { throw ConnectorLogger.ROOT_LOGGER.failedToLoadNativeLibraries(e); } }
@Override public void execute() throws Exception { VirtualFile root = VFS.getChild(this.env.getJbossHome()); List<VirtualFile> matches = root.getChildrenRecursively(Filters.and(this.filter, this.blacklistFilter)); // order the files in some arbitrary way.. basically prep for the limiter so things like log files can // be gotten in chronological order. Keep in mind everything that might be collected per the filter for // this collector. If the filter is too broad, you may collect unrelated logs, sort them, and then // get some limit on that set, which probably would be wrong. if(sorter != null){ Collections.sort(matches, sorter); } // limit how much data we collect Limiter limiter = new Limiter(limit); Iterator<VirtualFile> iter = matches.iterator(); while(iter.hasNext() && !limiter.isDone()) { VirtualFile f = iter.next(); try (InputStream stream = limiter.limit(f)) { InputStream modifiedStream = stream; for (Sanitizer sanitizer : this.sanitizers) { if (sanitizer.accepts(f)) { modifiedStream = sanitizer.sanitize(modifiedStream); } } this.env.getZip().add(f, modifiedStream); } } }
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); } }
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); } }
/** * Get all the children recursively<p> * <p/> * This always uses {@link VisitorAttributes#RECURSE} * * @return the children * @throws IOException for any problem accessing the virtual file system * @throws IllegalStateException if the file is closed */ public List<VirtualFile> getChildrenRecursively() throws IOException { return getChildrenRecursively(null); }
public List<VirtualFile> getJarFiles(VirtualFile dir) throws IOException { return dir.getChildrenRecursively( JAR_FILTER ); }
/** * Get all the children recursively<p> * <p/> * This always uses {@link VisitorAttributes#RECURSE} * * @return the children * @throws IOException for any problem accessing the virtual file system */ public static List<VirtualFile> getChildrenRecursively() throws IOException { return getRootVirtualFile().getChildrenRecursively(null); }
/** * Get all the children recursively<p> * <p/> * This always uses {@link VisitorAttributes#RECURSE} * * @param filter to filter the children * @return the children * @throws IOException for any problem accessing the virtual file system */ public static List<VirtualFile> getChildrenRecursively(VirtualFileFilter filter) throws IOException { return getRootVirtualFile().getChildrenRecursively(filter); }
private List<org.jboss.vfs.VirtualFile> getMountedChildrenRecursively() throws IOException { ensureMounted(); return vfsFile.getChildrenRecursively(); }
VfsResourceIterator(final URL url) throws IOException { final VirtualFile vFile = (VirtualFile)url.getContent(); files = vFile.getChildrenRecursively(); }
VfsResourceIterator(final URL url) throws IOException { final VirtualFile vFile = (VirtualFile) url.getContent(); files = vFile.getChildrenRecursively(); }
public VFSArchive(URL rootUrl, String descriptorLocation) throws URISyntaxException, IOException { this.rootUrl = rootUrl; this.descriptorLocation = descriptorLocation; root = VFS.getChild(rootUrl.toURI()); List<VirtualFile> children = root.getChildrenRecursively(new VirtualFileFilter() { @Override public boolean accepts(VirtualFile file) { return file.isFile(); } }); files = new HashMap<String, VirtualFile>(); for (VirtualFile file : children) { files.put(file.getPathNameRelativeTo(root), file); } }
public VFSArchive(URL rootUrl, String descriptorLocation) throws URISyntaxException, IOException { this.rootUrl = rootUrl; this.descriptorLocation = descriptorLocation; root = VFS.getChild(rootUrl.toURI()); List<VirtualFile> children = root.getChildrenRecursively(new VirtualFileFilter() { @Override public boolean accepts(VirtualFile file) { return file.isFile(); } }); files = new HashMap<String, VirtualFile>(); for (VirtualFile file : children) { files.put(file.getPathNameRelativeTo(root), file); } }
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; }
public VDBResources(VirtualFile root, VDBMetaData vdb) throws IOException { LinkedHashMap<String, VDBResources.Resource> visibilityMap = new LinkedHashMap<String, VDBResources.Resource>(); for(VirtualFile f: root.getChildrenRecursively()) { if (f.isFile()) { // remove the leading vdb name from the entry String path = f.getPathName().substring(root.getPathName().length()); if (!path.startsWith("/")) { //$NON-NLS-1$ path = "/" + path; //$NON-NLS-1$ } visibilityMap.put(path, new VDBResources.Resource(f)); } } this.vdbEntries = visibilityMap; }
public VDBResources(VirtualFile root, VDBMetaData vdb) throws IOException { LinkedHashMap<String, VDBResources.Resource> visibilityMap = new LinkedHashMap<String, VDBResources.Resource>(); for(VirtualFile f: root.getChildrenRecursively()) { if (f.isFile()) { // remove the leading vdb name from the entry String path = f.getPathName().substring(root.getPathName().length()); if (!path.startsWith("/")) { //$NON-NLS-1$ path = "/" + path; //$NON-NLS-1$ } visibilityMap.put(path, new VDBResources.Resource(f)); } } this.vdbEntries = visibilityMap; }
public VDBResources(VirtualFile root, VDBMetaData vdb) throws IOException { LinkedHashMap<String, VDBResources.Resource> visibilityMap = new LinkedHashMap<String, VDBResources.Resource>(); for(VirtualFile f: root.getChildrenRecursively()) { if (f.isFile()) { // remove the leading vdb name from the entry String path = f.getPathName().substring(root.getPathName().length()); if (!path.startsWith("/")) { //$NON-NLS-1$ path = "/" + path; //$NON-NLS-1$ } visibilityMap.put(path, new VDBResources.Resource(f)); } } this.vdbEntries = visibilityMap; }
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; }