jcabrerizo commented on code in PR #1338:
URL: https://github.com/apache/brooklyn-server/pull/1338#discussion_r920970267


##########
rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java:
##########
@@ -609,30 +615,23 @@ public Response importPersistenceData(byte[] 
persistenceData) {
                     ((RebindManagerImpl)rebindManager).newExceptionHandler());
 
             // install bundles to active management context
-            for (Map.Entry<String, ByteSource> bundleJar : 
newMementoRawData.getBundleJars().entrySet()){
-                ManagedBundleMemento memento = 
mementoManifest.getBundle(bundleJar.getKey());
-                log.debug("Installing "+memento+" as part of persisted state 
import");
-                ReferenceWithError<OsgiBundleInstallationResult> 
bundleInstallResult = ((ManagementContextInternal)mgmt()).getOsgiManager().get()
-                        .install(InputStreamSource.of("Persistence import - 
bundle install - "+memento, bundleJar.getValue().read()), "", false, 
memento.getDeleteable());
-
-                if (bundleInstallResult.hasError()) {
-                    log.debug("Unable to create "+memento+", format '', 
throwing: "+bundleInstallResult.getError().getMessage(), 
bundleInstallResult.getError());
-                    String errorMsg = "";
-                    if (bundleInstallResult.getWithoutError()!=null) {
-                        errorMsg = 
bundleInstallResult.getWithoutError().getMessage();
-                    } else {
-                        errorMsg = 
Strings.isNonBlank(bundleInstallResult.getError().getMessage()) ? 
bundleInstallResult.getError().getMessage() : 
bundleInstallResult.getError().toString();
-                    }
-                    throw new Exception(errorMsg);
+            Map<VersionedName, CatalogInitialization.InstallableManagedBundle> 
bundles = new LinkedHashMap<>();
+            for (Map.Entry<String, ByteSource> bundleJar : 
newMementoRawData.getBundleJars().entrySet()) {
+                ManagedBundleMemento bundleMemento = 
mementoManifest.getBundle(bundleJar.getKey());
+                ManagedBundle b = 
RebindIteration.newManagedBundle(bundleMemento);
+                bundles.put(b.getVersionedName(), new 
RebindIteration.InstallableManagedBundleImpl(bundleMemento, b));
+                log.debug("Installing "+bundleMemento+" for "+b+" as part of 
persisted state import");

Review Comment:
   moving list line one line up  will help to see which bundle failed to 
install in case something goes wrong and also be more accurate



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brooklyn.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to