+ if (wrappers.size() > 0)
+ return wrappers.values().iterator();
+ else
+ return osgiNameVersions();
+ }
+
+ @SuppressWarnings("resource")
+ protected Iterator<? extends NameVersion> osgiNameVersions() {
+ List<CategorizedNameVersion> nvs = new ArrayList<CategorizedNameVersion>();
+
+ Session distSession = null;
+ ZipInputStream zin = null;
+ try {
+ distSession = osgiFactory.openDistSession();
+
+ Node distNode = osgiFactory.getDist(distSession, uri);
+ zin = new ZipInputStream(distNode.getNode(Node.JCR_CONTENT)
+ .getProperty(Property.JCR_DATA).getBinary().getStream());
+
+ ZipEntry zentry = null;
+ entries: while ((zentry = zin.getNextEntry()) != null) {
+ String name = zentry.getName();
+ // log.debug(name);
+ for (String exclude : excludes)
+ if (pathMatcher.match(exclude, name))
+ continue entries;
+
+ for (String include : includes.keySet()) {
+ if (pathMatcher.match(include, name)) {
+ String groupId = includes.get(include);
+ JarInputStream jis = new JarInputStream(zin);
+ NameVersion nv = RepoUtils.readNameVersion(jis
+ .getManifest());
+ if (nv != null) {
+ if (nv.getName().endsWith(".source"))
+ continue entries;
+ CategorizedNameVersion cnv = new OsgiCategorizedNV(
+ groupId, nv.getName(), nv.getVersion(),
+ this);
+ nvs.add(cnv);
+ }
+ }
+ }
+ }
+ return nvs.iterator();
+ } catch (Exception e) {
+ throw new SlcException("Cannot wrap distribution " + uri, e);
+ } finally {
+ IOUtils.closeQuietly(zin);
+ JcrUtils.logoutQuietly(distSession);
+ }