@@ -49,28 +49,19 @@ public DeployCustomForestsCommand() {
4949
5050 @ Override
5151 public void execute (CommandContext context ) {
52- Configuration configuration = null ;
53- if (context .getAppConfig ().getCmaConfig ().isDeployForests ()) {
54- configuration = new Configuration ();
55- }
56-
5752 for (ConfigDir configDir : context .getAppConfig ().getConfigDirs ()) {
5853 File dir = new File (configDir .getBaseDir (), customForestsPath );
5954 if (dir != null && dir .exists ()) {
6055 payloadParser = new PayloadParser ();
6156 for (File f : dir .listFiles ()) {
6257 if (f .isDirectory ()) {
63- processDirectory (f , context , configuration );
58+ processDirectory (f , context );
6459 }
6560 }
6661 } else {
6762 logResourceDirectoryNotFound (dir );
6863 }
6964 }
70-
71- if (configuration != null ) {
72- deployConfiguration (context , configuration );
73- }
7465 }
7566
7667 /**
@@ -79,7 +70,7 @@ public void execute(CommandContext context) {
7970 * @param dir
8071 * @param context
8172 */
82- protected void processDirectory (File dir , CommandContext context , Configuration configuration ) {
73+ protected void processDirectory (File dir , CommandContext context ) {
8374 if (logger .isInfoEnabled ()) {
8475 logger .info ("Processing custom forest files in directory: " + dir .getAbsolutePath ());
8576 }
@@ -91,6 +82,11 @@ protected void processDirectory(File dir, CommandContext context, Configuration
9182 }
9283 String payload = readResourceFromFile (context , f );
9384
85+ // As of 4.6.1, create a CMA request per file so that the user has control over how many forests are
86+ // submitted in a single request, thus avoiding potential timeouts.
87+ Configuration configuration = context .getAppConfig ().getCmaConfig ().isDeployForests () ?
88+ new Configuration () : null ;
89+
9490 if (payloadParser .isJsonPayload (payload )) {
9591 if (configuration != null ) {
9692 addForestsToCmaConfiguration (context , payload , configuration );
@@ -104,6 +100,10 @@ protected void processDirectory(File dir, CommandContext context, Configuration
104100 mgr .save (payload );
105101 }
106102 }
103+
104+ if (configuration != null ) {
105+ deployConfiguration (context , configuration );
106+ }
107107 }
108108 }
109109
0 commit comments