Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand All @@ -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());
}
Expand All @@ -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);
Expand All @@ -104,6 +100,10 @@ protected void processDirectory(File dir, CommandContext context, Configuration
mgr.save(payload);
}
}

if (configuration != null) {
deployConfiguration(context, configuration);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}