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 49ed3c3b..29e93070 100644 --- a/bubble-server/src/main/java/bubble/service/dbfilter/EntityIterator.java +++ b/bubble-server/src/main/java/bubble/service/dbfilter/EntityIterator.java @@ -77,18 +77,21 @@ public abstract class EntityIterator implements Iterator { } } - public void addEntities(Class c, + public void addEntities(boolean fullCopy, + Class c, List entities, BubbleNetwork network, BubbleNode node, List planApps) { if (CloudService.class.isAssignableFrom(c)) { - entities.forEach(e -> add(setLocalStoragePath((CloudService) e))); + entities.stream() + .filter(cloud -> fullCopy || notPaymentCloud((CloudService) cloud)) + .forEach(e -> add(setLocalStoragePath((CloudService) e))); } else if (AccountSshKey.class.isAssignableFrom(c)) { entities.forEach(e -> add(setInstallKey((AccountSshKey) e, network))); - } else if (planApps != null && BubbleApp.class.isAssignableFrom(c)) { + } else if (!fullCopy && planApps != null && BubbleApp.class.isAssignableFrom(c)) { // only copy enabled apps, make them templates entities.stream().filter(app -> planAppEnabled(((BubbleApp) app).getTemplateApp(), planApps)) .map(app -> ((BubbleApp) app).setTemplate(true)) @@ -97,7 +100,7 @@ public abstract class EntityIterator implements Iterator { // save these for later, we will need them when copying BubblePlanApps below userApps = (List) entities; - } else if (planApps != null && BubblePlanApp.class.isAssignableFrom(c)) { + } else if (!fullCopy && planApps != null && BubblePlanApp.class.isAssignableFrom(c)) { // the only BubblePlanApps we will see here are the ones associated with the system BubblePlans // and the system/template BubbleApps. // But for this new node, the BubbleApps that are associated with the first user (admin of new node) @@ -124,7 +127,7 @@ public abstract class EntityIterator implements Iterator { } } - } else if (planApps != null && AccountTemplate.class.isAssignableFrom(c)) { + } else if (!fullCopy && planApps != null && AccountTemplate.class.isAssignableFrom(c)) { // only copy app-related entities for enabled apps, make them all templates entities.stream() .map(app -> (AccountTemplate) ((AccountTemplate) app).setTemplate(true)) @@ -135,6 +138,8 @@ public abstract class EntityIterator implements Iterator { } } + private boolean notPaymentCloud(CloudService cloud) { return !cloud.getDriverClass().contains(".payment."); } + private boolean planAppEnabled(String appUuid, List planApps) { return planApps == null || planApps.stream().anyMatch(planApp -> planApp.getApp().equals(appUuid)); } diff --git a/bubble-server/src/main/java/bubble/service/dbfilter/FilteredEntityIterator.java b/bubble-server/src/main/java/bubble/service/dbfilter/FilteredEntityIterator.java index 708ce33e..9b00d802 100644 --- a/bubble-server/src/main/java/bubble/service/dbfilter/FilteredEntityIterator.java +++ b/bubble-server/src/main/java/bubble/service/dbfilter/FilteredEntityIterator.java @@ -80,7 +80,7 @@ public class FilteredEntityIterator extends EntityIterator { final List entities = aoDAO.dbFilterIncludeAll() ? aoDAO.findAll() : aoDAO.findByAccount(account.getUuid()); - addEntities(c, entities, network, node, planApps); + addEntities(false, c, entities, network, node, planApps); } }); diff --git a/bubble-server/src/main/java/bubble/service/dbfilter/FullEntityIterator.java b/bubble-server/src/main/java/bubble/service/dbfilter/FullEntityIterator.java index b5e03025..ac122994 100644 --- a/bubble-server/src/main/java/bubble/service/dbfilter/FullEntityIterator.java +++ b/bubble-server/src/main/java/bubble/service/dbfilter/FullEntityIterator.java @@ -22,7 +22,7 @@ public class FullEntityIterator extends EntityIterator { protected void iterate() { config.getEntityClasses().forEach(c -> { - addEntities(c, config.getDaoForEntityClass(c).findAll(), network, null, null); + addEntities(true, c, config.getDaoForEntityClass(c).findAll(), network, null, null); }); log.info("iterate: completed"); }