| 310 | } |
| 311 | |
| 312 | std::vector<Bundle> |
| 313 | BundleRegistry::Install0(std::string const& location, |
| 314 | std::shared_ptr<BundleResourceContainer> const& resCont, |
| 315 | std::vector<std::string> const& alreadyInstalled, |
| 316 | cppmicroservices::AnyMap const& bundleManifest) |
| 317 | { |
| 318 | namespace cppms = cppmicroservices; |
| 319 | using cppms::any_cast; |
| 320 | using cppms::any_map; |
| 321 | using cppms::AnyMap; |
| 322 | |
| 323 | std::vector<Bundle> installedBundles; |
| 324 | std::vector<std::shared_ptr<BundleArchive>> barchives; |
| 325 | std::unordered_set<std::string> exclude { alreadyInstalled.begin(), alreadyInstalled.end() }; |
| 326 | try |
| 327 | { |
| 328 | // Create a BundleArchive for each entry in the resource container... that is, top level entries |
| 329 | // (symbolic names) in the zip file for the bundle at 'location'. |
| 330 | // |
| 331 | // Note: We MUST use the values from "GetTopLevelDirs()" because eventhough the keys in the |
| 332 | // "bundleManifest" are also the "SymbolicNames", bundleManifest can be empty and will only |
| 333 | // contain the symbolicName entries if it's not. |
| 334 | auto entries = resCont->GetTopLevelDirs(); |
| 335 | for (auto const& symbolicName : entries) |
| 336 | { |
| 337 | // only install non-excluded entries |
| 338 | if (0 == exclude.count(symbolicName)) |
| 339 | { |
| 340 | #ifndef US_BUILD_SHARED_LIBS |
| 341 | // The system bundle is already installed, so skip it. |
| 342 | if (Constants::SYSTEM_BUNDLE_SYMBOLICNAME == symbolicName) |
| 343 | { |
| 344 | continue; |
| 345 | } |
| 346 | #endif |
| 347 | |
| 348 | // Either use the manifest found in the passed in bundleManifest list for the current entry, |
| 349 | // or construct an empty one |
| 350 | auto manifest = (0 != bundleManifest.count(symbolicName) |
| 351 | ? any_cast<AnyMap>(bundleManifest.at(symbolicName)) |
| 352 | : AnyMap(any_map::UNORDERED_MAP_CASEINSENSITIVE_KEYS)); |
| 353 | |
| 354 | // Now, create a BundleArchive with the given manifest at 'entry' in the |
| 355 | // BundleResourceContainer, and remember the created BundleArchive here for later |
| 356 | // processing, including purging any items created if an exception is thrown. |
| 357 | barchives.push_back(coreCtx->storage->CreateAndInsertArchive(resCont, symbolicName, manifest)); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | // Now, create a BundlePrivate for each BundleArchive, and then add a Bundle to the results |
| 362 | // that are returned, one for each BundlePrivate that's created. |
| 363 | for (auto const& ba : barchives) |
| 364 | { |
| 365 | auto d = std::make_shared<BundlePrivate>(coreCtx, ba); |
| 366 | installedBundles.emplace_back(MakeBundle(d)); |
| 367 | } |
| 368 | |
| 369 | // For each bundle that we created, add into the map of location->bundle, completing the |
nothing calls this directly
no test coverage detected