1919import com .fasterxml .jackson .databind .ObjectMapper ;
2020import com .marklogic .appdeployer .AppConfig ;
2121import com .marklogic .appdeployer .command .Command ;
22- import com .marklogic .appdeployer .command .alert .DeployAlertActionsCommand ;
23- import com .marklogic .appdeployer .command .alert .DeployAlertConfigsCommand ;
24- import com .marklogic .appdeployer .command .alert .DeployAlertRulesCommand ;
22+ import com .marklogic .appdeployer .command .CommandMapBuilder ;
2523import com .marklogic .appdeployer .command .appservers .DeployOtherServersCommand ;
26- import com .marklogic .appdeployer .command .cpf .DeployCpfConfigsCommand ;
27- import com .marklogic .appdeployer .command .cpf .DeployDomainsCommand ;
28- import com .marklogic .appdeployer .command .cpf .DeployPipelinesCommand ;
29- import com .marklogic .appdeployer .command .flexrep .DeployConfigsCommand ;
30- import com .marklogic .appdeployer .command .flexrep .DeployFlexrepCommand ;
31- import com .marklogic .appdeployer .command .flexrep .DeployTargetsCommand ;
32- import com .marklogic .appdeployer .command .forests .ConfigureForestReplicasCommand ;
33- import com .marklogic .appdeployer .command .groups .DeployGroupsCommand ;
3424import com .marklogic .appdeployer .command .mimetypes .DeployMimetypesCommand ;
35- import com .marklogic .appdeployer .command .schemas .LoadSchemasCommand ;
36- import com .marklogic .appdeployer .command .security .*;
37- import com .marklogic .appdeployer .command .tasks .DeployScheduledTasksCommand ;
38- import com .marklogic .appdeployer .command .triggers .DeployTriggersCommand ;
39- import com .marklogic .appdeployer .command .viewschemas .DeployViewSchemasCommand ;
4025import com .marklogic .appdeployer .impl .SimpleAppDeployer ;
4126import com .marklogic .client .DatabaseClient ;
4227import com .marklogic .client .FailedRequestException ;
7459import java .nio .file .attribute .BasicFileAttributes ;
7560import java .util .ArrayList ;
7661import java .util .List ;
62+ import java .util .Map ;
7763import java .util .regex .Pattern ;
7864
7965public class DataHub {
@@ -309,107 +295,43 @@ public JsonNode validateUserModules() {
309295 return ev .validate ();
310296 }
311297
312- public List <Command > getCommands () {
298+ public List <Command > getCommandList () {
299+ Map <String , List <Command >> commandMap = getCommands ();
313300 List <Command > commands = new ArrayList <>();
301+ for (String name : commandMap .keySet ()) {
302+ commands .addAll (commandMap .get (name ));
303+ }
304+ return commands ;
305+ }
306+ public Map <String , List <Command >> getCommands () {
307+ Map <String , List <Command >> commandMap = new CommandMapBuilder ().buildCommandMap ();
314308
315- // Security
316- List <Command > securityCommands = new ArrayList <>();
317- securityCommands .add (new DeployRolesCommand ());
318- securityCommands .add (new DeployUsersCommand ());
319- securityCommands .add (new DeployAmpsCommand ());
320- securityCommands .add (new DeployCertificateTemplatesCommand ());
321- securityCommands .add (new DeployCertificateAuthoritiesCommand ());
322- securityCommands .add (new DeployExternalSecurityCommand ());
323- securityCommands .add (new DeployPrivilegesCommand ());
324- securityCommands .add (new DeployProtectedCollectionsCommand ());
325- commands .addAll (securityCommands );
326-
327- // Databases
328309 List <Command > dbCommands = new ArrayList <>();
329-
330- // deploy hub databases (staging, final, job, trace)
331310 dbCommands .add (new DeployHubDatabasesCommand (hubConfig ));
332-
333- // deploy user databases in user-config dir
334311 dbCommands .add (new DeployHubOtherDatabasesCommand (hubConfig ));
335-
336- // depoloy triggers database
337312 dbCommands .add (new DeployHubTriggersDatabaseCommand (hubConfig ));
338-
339- // depoloy schemas database
340313 dbCommands .add (new DeployHubSchemasDatabaseCommand (hubConfig ));
341- commands .addAll (dbCommands );
342-
343- // Schemas
344- LoadSchemasCommand lsc = new LoadSchemasCommand ();
345- commands .add (lsc );
314+ commandMap .put ("mlDatabaseCommands" , dbCommands );
346315
347- // App servers
348- // deploy hub app servers (staging, final, job, trace)
349- commands .add (new DeployHubServersCommand (hubConfig ));
316+ // don't deploy rest api servers
317+ commandMap .remove ("mlRestApiCommands" );
350318
351- // deploy user app servers in user-config
319+ List <Command > serverCommands = new ArrayList <>();
320+ serverCommands .add (new DeployHubServersCommand (hubConfig ));
352321 DeployOtherServersCommand otherServersCommand = new DeployOtherServersCommand ();
353322 otherServersCommand .setFilenamesToIgnore ("staging-server.json" , "final-server.json" , "job-server.json" , "trace-server.json" );
354- commands .add (otherServersCommand );
323+ serverCommands .add (otherServersCommand );
324+ commandMap .put ("mlServerCommands" , serverCommands );
355325
356- // Modules
357- commands .add (new LoadHubModulesCommand (hubConfig ));
358- commands .add (new LoadUserModulesCommand (hubConfig ));
359-
360- // Alerting
361- List <Command > alertCommands = new ArrayList <>();
362- alertCommands .add (new DeployAlertConfigsCommand ());
363- alertCommands .add (new DeployAlertActionsCommand ());
364- alertCommands .add (new DeployAlertRulesCommand ());
365- commands .addAll (alertCommands );
366-
367- // CPF
368- List <Command > cpfCommands = new ArrayList <>();
369- cpfCommands .add (new DeployCpfConfigsCommand ());
370- cpfCommands .add (new DeployDomainsCommand ());
371- cpfCommands .add (new DeployPipelinesCommand ());
372- commands .addAll (cpfCommands );
373-
374- // Flexrep
375- List <Command > flexrepCommands = new ArrayList <>();
376- flexrepCommands .add (new DeployConfigsCommand ());
377- flexrepCommands .add (new DeployTargetsCommand ());
378- flexrepCommands .add (new DeployFlexrepCommand ());
379- commands .addAll (flexrepCommands );
380-
381- // Groups
382- List <Command > groupCommands = new ArrayList <>();
383- groupCommands .add (new DeployGroupsCommand ());
384- commands .addAll (groupCommands );
385-
386- List <Command > mimetypeCommands = new ArrayList <>();
387- mimetypeCommands .add (new DeployMimetypesCommand ());
388- commands .addAll (mimetypeCommands );
389-
390- // Forest replicas
391- List <Command > replicaCommands = new ArrayList <>();
392- replicaCommands .add (new ConfigureForestReplicasCommand ());
393- commands .addAll (replicaCommands );
394-
395- // Tasks
396- List <Command > taskCommands = new ArrayList <>();
397- taskCommands .add (new DeployScheduledTasksCommand ());
398- commands .addAll (taskCommands );
399-
400- // Triggers
401- List <Command > triggerCommands = new ArrayList <>();
402- triggerCommands .add (new DeployTriggersCommand ());
403- commands .addAll (triggerCommands );
404-
405- // SQL Views
406- List <Command > viewCommands = new ArrayList <>();
407- DeployViewSchemasCommand deployViewSchemasCommand = new DeployViewSchemasCommand ();
408- deployViewSchemasCommand .setDatabaseIdOrName (hubConfig .finalDbName );
409- viewCommands .add (deployViewSchemasCommand );
410- commands .addAll (viewCommands );
326+ List <Command > moduleCommands = new ArrayList <>();
327+ moduleCommands .add (new LoadHubModulesCommand (hubConfig ));
328+ moduleCommands .add (new LoadUserModulesCommand (hubConfig ));
329+ commandMap .put ("mlModuleCommands" , moduleCommands );
411330
412- return commands ;
331+ List <Command > mimetypeCommands = commandMap .get ("mlMimetypeCommands" );
332+ mimetypeCommands .add (0 , new DeployHubMimetypesCommand (hubConfig ));
333+
334+ return commandMap ;
413335 }
414336
415337 /**
@@ -430,7 +352,7 @@ public void install(HubDeployStatusListener listener) {
430352
431353 AppConfig config = hubConfig .getAppConfig ();
432354 HubAppDeployer deployer = new HubAppDeployer (getManageClient (), getAdminManager (), listener );
433- deployer .setCommands (getCommands ());
355+ deployer .setCommands (getCommandList ());
434356 deployer .deploy (config );
435357 }
436358
@@ -459,7 +381,7 @@ public void uninstall(HubDeployStatusListener listener) {
459381
460382 AppConfig config = hubConfig .getAppConfig ();
461383 HubAppDeployer deployer = new HubAppDeployer (getManageClient (), getAdminManager (), listener );
462- deployer .setCommands (getCommands ());
384+ deployer .setCommands (getCommandList ());
463385 deployer .undeploy (config );
464386 }
465387
0 commit comments