@Override public Iterator<Resource> iterateResources(String startPath, boolean recursive) { // Collect paths for substituted packages List<String> importedPaths = new ArrayList<String>(); BundleWiring wiring = hostRev.getBundle().adapt(BundleWiring.class); List<BundleRequirement> preqs = wiring != null ? wiring.getRequirements(PackageNamespace.PACKAGE_NAMESPACE) : null; if (preqs != null) { for (BundleRequirement req : preqs) { XPackageRequirement preq = (XPackageRequirement) req; String packageName = preq.getPackageName(); importedPaths.add(packageName.replace('.', '/')); } } Iterator<Resource> itres = delegate.iterateResources(startPath, recursive); if (importedPaths.isEmpty()) { return itres; } // Filter substituted packages List<Resource> filteredResources = new ArrayList<Resource>(); while (itres.hasNext()) { Resource res = itres.next(); String pathname = res.getName(); int lastIndex = pathname.lastIndexOf('/'); String respath = lastIndex > 0 ? pathname.substring(0, lastIndex) : pathname; if (!importedPaths.contains(respath)) { filteredResources.add(res); } } return filteredResources.iterator(); }
private BundleWiringDTO.NodeDTO getBundleWiringNodeDTO(BundleWiring wiring) { if (wiring == null) { return null; } BundleWiringDTO.NodeDTO dto = wiringnodes.get(wiring); if (dto != null) { return dto; } dto = new BundleWiringDTO.NodeDTO(); dto.id = identifier(wiring); wiringnodes.put(wiring, dto); dto.current = wiring.isCurrent(); dto.inUse = wiring.isInUse(); dto.resource = getResourceId(wiring.getRevision()); dto.capabilities = getListCapabilityRefDTO(wiring.getCapabilities(null)); dto.requirements = getListRequirementRefDTO(wiring.getRequirements(null)); dto.providedWires = getListBundleWireDTO(wiring.getProvidedWires(null)); dto.requiredWires = getListBundleWireDTO(wiring.getRequiredWires(null)); return dto; }