diff --git a/src/main/java/com/marklogic/appdeployer/command/forests/DeployCustomForestsCommand.java b/src/main/java/com/marklogic/appdeployer/command/forests/DeployCustomForestsCommand.java index 6c01948a..c29ecef0 100644 --- a/src/main/java/com/marklogic/appdeployer/command/forests/DeployCustomForestsCommand.java +++ b/src/main/java/com/marklogic/appdeployer/command/forests/DeployCustomForestsCommand.java @@ -49,28 +49,19 @@ public DeployCustomForestsCommand() { @Override public void execute(CommandContext context) { - Configuration configuration = null; - if (context.getAppConfig().getCmaConfig().isDeployForests()) { - configuration = new Configuration(); - } - for (ConfigDir configDir : context.getAppConfig().getConfigDirs()) { File dir = new File(configDir.getBaseDir(), customForestsPath); if (dir != null && dir.exists()) { payloadParser = new PayloadParser(); for (File f : dir.listFiles()) { if (f.isDirectory()) { - processDirectory(f, context, configuration); + processDirectory(f, context); } } } else { logResourceDirectoryNotFound(dir); } } - - if (configuration != null) { - deployConfiguration(context, configuration); - } } /** @@ -79,7 +70,7 @@ public void execute(CommandContext context) { * @param dir * @param context */ - protected void processDirectory(File dir, CommandContext context, Configuration configuration) { + protected void processDirectory(File dir, CommandContext context) { if (logger.isInfoEnabled()) { logger.info("Processing custom forest files in directory: " + dir.getAbsolutePath()); } @@ -91,6 +82,11 @@ protected void processDirectory(File dir, CommandContext context, Configuration } String payload = readResourceFromFile(context, f); + // As of 4.6.1, create a CMA request per file so that the user has control over how many forests are + // submitted in a single request, thus avoiding potential timeouts. + Configuration configuration = context.getAppConfig().getCmaConfig().isDeployForests() ? + new Configuration() : null; + if (payloadParser.isJsonPayload(payload)) { if (configuration != null) { addForestsToCmaConfiguration(context, payload, configuration); @@ -104,6 +100,10 @@ protected void processDirectory(File dir, CommandContext context, Configuration mgr.save(payload); } } + + if (configuration != null) { + deployConfiguration(context, configuration); + } } } diff --git a/src/test/java/com/marklogic/appdeployer/command/forests/DeployCustomForestsTest.java b/src/test/java/com/marklogic/appdeployer/command/forests/DeployCustomForestsTest.java index 751eb062..49f3e8ff 100644 --- a/src/test/java/com/marklogic/appdeployer/command/forests/DeployCustomForestsTest.java +++ b/src/test/java/com/marklogic/appdeployer/command/forests/DeployCustomForestsTest.java @@ -51,9 +51,12 @@ public void test() { assertTrue(mgr.exists("sample-app-content-custom-3")); } + /** + * Can examine logging to verify that one request is made per forest. + */ @Test - public void deployWithCma() { - appConfig.getCmaConfig().enableAll(); + public void deployWithoutCMA() { + appConfig.getCmaConfig().setDeployForests(false); test(); } }