From b152a992560904ac1283ebde8260b2788cf357cd Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Tue, 17 Mar 2020 14:28:36 -0400 Subject: [PATCH] fix population of app-dependent objects --- .../java/bubble/service/dbfilter/EntityIterator.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bubble-server/src/main/java/bubble/service/dbfilter/EntityIterator.java b/bubble-server/src/main/java/bubble/service/dbfilter/EntityIterator.java index ef6767fd..02b4b62b 100644 --- a/bubble-server/src/main/java/bubble/service/dbfilter/EntityIterator.java +++ b/bubble-server/src/main/java/bubble/service/dbfilter/EntityIterator.java @@ -19,11 +19,13 @@ import bubble.model.cloud.CloudService; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.cobbzilla.wizard.model.Identifiable; +import org.cobbzilla.wizard.model.IdentifiableBase; import java.util.*; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; import static bubble.cloud.NoopCloud.NOOP_CLOUD; import static bubble.cloud.storage.local.LocalStorageDriver.LOCAL_STORAGE_STANDARD_BASE_DIR; @@ -171,8 +173,11 @@ public abstract class EntityIterator implements Iterator { // Only copy app-related objects if the corresponding app is among the planApps // Make copied objects templates for (AppTemplateEntity e : (List) entities) { - if (planAppEnabled(e.getApp(), planApps)) { + if (userAppEnabled(e.getApp(), userApps)) { + log.info("addEntities: adding " + c.getSimpleName() + "/" + e.getUuid() + " (app="+e.getApp()+") as template"); add(e.setTemplate(true)); + } else { + log.info("addEntities: NOT adding " + c.getSimpleName() + "/" + e.getUuid() + " (app="+e.getApp()+"), app not enabled (planApps="+planApps.stream().map(IdentifiableBase::getUuid).collect(Collectors.joining(", "))+")"); } } @@ -193,6 +198,10 @@ public abstract class EntityIterator implements Iterator { return planApps == null || planApps.stream().anyMatch(planApp -> planApp.getApp().equals(appUuid)); } + private boolean userAppEnabled(String appUuid, List userApps) { + return userApps == null || userApps.stream().anyMatch(app -> app.getUuid().equals(appUuid)); + } + private AccountSshKey setInstallKey(AccountSshKey sshKey, BubbleNetwork network) { if (network == null) return sshKey; if (network.hasSshKey() && network.getSshKey().equals(sshKey.getUuid())) {