in vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java [569:640]
private void extractSubpackages(@NotNull ImportOptions opts, @NotNull Set<PackageId> processed)
throws RepositoryException, PackageException, IOException {
final VaultPackage pack = getPackage();
final PackageId pId = pack.getId();
Archive a = pack.getArchive();
Archive.Entry packages = a.getEntry(ARCHIVE_PACKAGE_ROOT_PATH);
if (packages == null) {
return;
}
List<Archive.Entry> entries = new LinkedList<Archive.Entry>();
findSubPackageEntries(entries, packages);
if (entries.isEmpty()) {
log.debug("Package {} contains no sub-packages.", pId);
return;
}
// check if filter has root outside /etc/packages
boolean hasOwnContent = false;
for (PathFilterSet root: a.getMetaInf().getFilter().getFilterSets()) {
// todo: find better way to detect subpackages
if (!Text.isDescendantOrEqual(DEFAULT_PACKAGE_ROOT_PATH, root.getRoot())) {
log.debug("Package {}: contains content outside /etc/packages. Sub packages will have a dependency to it", pId);
hasOwnContent = true;
break;
}
}
// check if package has nodetype no installed in the repository
if (!hasOwnContent) {
DefaultNamePathResolver npResolver = new DefaultNamePathResolver(getNode().getSession());
NodeTypeManager ntMgr = getNode().getSession().getWorkspace().getNodeTypeManager();
loop0: for (NodeTypeSet cnd: a.getMetaInf().getNodeTypes()) {
for (Name name: cnd.getNodeTypes().keySet()) {
String jcrName;
try {
jcrName = npResolver.getJCRName(name);
} catch (NamespaceException e) {
// in case the uri is not registered. we also break here
log.debug("Package {}: contains namespace not installed in the repository: {}. Sub packages will have a dependency to it", pId, name.getNamespaceURI());
hasOwnContent = true;
break loop0;
}
if (!ntMgr.hasNodeType(jcrName)) {
log.debug("Package {}: contains nodetype not installed in the repository: {}. Sub packages will have a dependency to it", pId, jcrName);
hasOwnContent = true;
break loop0;
}
}
}
}
// process the discovered sub-packages
for (Archive.Entry e: entries) {
VaultInputSource in = a.getInputSource(e);
try (InputStream ins = in.getByteStream()) {
try {
PackageId id = extractSubpackage(pId, ins, opts, processed, hasOwnContent);
log.debug("Package {}: Extracted sub-package: {}", pId, id);
} catch (IOException e1) {
log.error("Package {}: Error while extracting subpackage {}: {}", pId, in.getSystemId(), e1);
}
}
}
// if no content, mark as installed
if (!entries.isEmpty() && !hasOwnContent) {
log.debug("Package {}: is pure container package. marking as installed.", pId);
getDefinition();
if (def != null && !opts.isDryRun()) {
def.touchLastUnpacked();
}
}
}