|
| 1 | +package com.marklogic.appdeployer.command; |
| 2 | + |
| 3 | +import com.marklogic.appdeployer.command.alert.DeployAlertActionsCommand; |
| 4 | +import com.marklogic.appdeployer.command.alert.DeployAlertConfigsCommand; |
| 5 | +import com.marklogic.appdeployer.command.alert.DeployAlertRulesCommand; |
| 6 | +import com.marklogic.appdeployer.command.appservers.DeployOtherServersCommand; |
| 7 | +import com.marklogic.appdeployer.command.appservers.UpdateRestApiServersCommand; |
| 8 | +import com.marklogic.appdeployer.command.clusters.ModifyLocalClusterCommand; |
| 9 | +import com.marklogic.appdeployer.command.cpf.DeployCpfConfigsCommand; |
| 10 | +import com.marklogic.appdeployer.command.cpf.DeployDomainsCommand; |
| 11 | +import com.marklogic.appdeployer.command.cpf.DeployPipelinesCommand; |
| 12 | +import com.marklogic.appdeployer.command.databases.DeployContentDatabasesCommand; |
| 13 | +import com.marklogic.appdeployer.command.databases.DeployOtherDatabasesCommand; |
| 14 | +import com.marklogic.appdeployer.command.databases.DeploySchemasDatabaseCommand; |
| 15 | +import com.marklogic.appdeployer.command.databases.DeployTriggersDatabaseCommand; |
| 16 | +import com.marklogic.appdeployer.command.flexrep.DeployConfigsCommand; |
| 17 | +import com.marklogic.appdeployer.command.flexrep.DeployFlexrepCommand; |
| 18 | +import com.marklogic.appdeployer.command.flexrep.DeployTargetsCommand; |
| 19 | +import com.marklogic.appdeployer.command.forests.ConfigureForestReplicasCommand; |
| 20 | +import com.marklogic.appdeployer.command.forests.DeployCustomForestsCommand; |
| 21 | +import com.marklogic.appdeployer.command.groups.DeployGroupsCommand; |
| 22 | +import com.marklogic.appdeployer.command.mimetypes.DeployMimetypesCommand; |
| 23 | +import com.marklogic.appdeployer.command.modules.LoadModulesCommand; |
| 24 | +import com.marklogic.appdeployer.command.restapis.DeployRestApiServersCommand; |
| 25 | +import com.marklogic.appdeployer.command.schemas.LoadSchemasCommand; |
| 26 | +import com.marklogic.appdeployer.command.security.*; |
| 27 | +import com.marklogic.appdeployer.command.tasks.DeployScheduledTasksCommand; |
| 28 | +import com.marklogic.appdeployer.command.triggers.DeployTriggersCommand; |
| 29 | +import com.marklogic.appdeployer.command.viewschemas.DeployViewSchemasCommand; |
| 30 | + |
| 31 | +import java.util.ArrayList; |
| 32 | +import java.util.HashMap; |
| 33 | +import java.util.List; |
| 34 | +import java.util.Map; |
| 35 | + |
| 36 | +/** |
| 37 | + * The intent of this class is to construct a map of commonly used commands that can used in a variety of contexts - i.e. |
| 38 | + * ml-gradle or the Data Hub Framework - thus preventing those clients from having to duplicate this code. |
| 39 | + * |
| 40 | + * A map is returned so that the commands can be grouped into lists, which is convenient for e.g. ml-gradle tasks that |
| 41 | + * want to execute all of the commands for a particular resource or set of resources - e.g. mlSecurityCommands for |
| 42 | + * invoking all commands pertaining to security resources. |
| 43 | + */ |
| 44 | +public class CommandMapBuilder { |
| 45 | + |
| 46 | + public Map<String, List<Command>> buildCommandMap() { |
| 47 | + Map<String, List<Command>> map = new HashMap<>(); |
| 48 | + |
| 49 | + // Security |
| 50 | + List<Command> securityCommands = new ArrayList<Command>(); |
| 51 | + securityCommands.add(new DeployRolesCommand()); |
| 52 | + securityCommands.add(new DeployUsersCommand()); |
| 53 | + securityCommands.add(new DeployAmpsCommand()); |
| 54 | + securityCommands.add(new DeployCertificateTemplatesCommand()); |
| 55 | + securityCommands.add(new DeployCertificateAuthoritiesCommand()); |
| 56 | + securityCommands.add(new DeployExternalSecurityCommand()); |
| 57 | + securityCommands.add(new DeployPrivilegesCommand()); |
| 58 | + securityCommands.add(new DeployProtectedCollectionsCommand()); |
| 59 | + map.put("mlSecurityCommands", securityCommands); |
| 60 | + |
| 61 | + // Cluster |
| 62 | + List<Command> clusterCommands = new ArrayList<Command>(); |
| 63 | + clusterCommands.add(new ModifyLocalClusterCommand()); |
| 64 | + map.put("mlClusterCommands", clusterCommands); |
| 65 | + |
| 66 | + // Databases |
| 67 | + List<Command> dbCommands = new ArrayList<Command>(); |
| 68 | + dbCommands.add(new DeployContentDatabasesCommand()); |
| 69 | + dbCommands.add(new DeployTriggersDatabaseCommand()); |
| 70 | + dbCommands.add(new DeploySchemasDatabaseCommand()); |
| 71 | + dbCommands.add(new DeployOtherDatabasesCommand()); |
| 72 | + map.put("mlDatabaseCommands", dbCommands); |
| 73 | + |
| 74 | + // Schemas |
| 75 | + List<Command> schemaCommands = new ArrayList<>(); |
| 76 | + schemaCommands.add(new LoadSchemasCommand()); |
| 77 | + map.put("mlSchemaCommands", schemaCommands); |
| 78 | + |
| 79 | + // REST API instance creation |
| 80 | + List<Command> restApiCommands = new ArrayList<>(); |
| 81 | + restApiCommands.add(new DeployRestApiServersCommand()); |
| 82 | + map.put("mlRestApiCommands", restApiCommands); |
| 83 | + |
| 84 | + // App servers |
| 85 | + List<Command> serverCommands = new ArrayList<>(); |
| 86 | + serverCommands.add(new DeployOtherServersCommand()); |
| 87 | + serverCommands.add(new UpdateRestApiServersCommand()); |
| 88 | + map.put("mlServerCommands", serverCommands); |
| 89 | + |
| 90 | + // Modules |
| 91 | + List<Command> moduleCommands = new ArrayList<>(); |
| 92 | + moduleCommands.add(new LoadModulesCommand()); |
| 93 | + map.put("mlModuleCommands", moduleCommands); |
| 94 | + |
| 95 | + // Alerting |
| 96 | + List<Command> alertCommands = new ArrayList<Command>(); |
| 97 | + alertCommands.add(new DeployAlertConfigsCommand()); |
| 98 | + alertCommands.add(new DeployAlertActionsCommand()); |
| 99 | + alertCommands.add(new DeployAlertRulesCommand()); |
| 100 | + map.put("mlAlertCommands", alertCommands); |
| 101 | + |
| 102 | + // CPF |
| 103 | + List<Command> cpfCommands = new ArrayList<Command>(); |
| 104 | + cpfCommands.add(new DeployCpfConfigsCommand()); |
| 105 | + cpfCommands.add(new DeployDomainsCommand()); |
| 106 | + cpfCommands.add(new DeployPipelinesCommand()); |
| 107 | + map.put("mlCpfCommands", cpfCommands); |
| 108 | + |
| 109 | + // Flexrep |
| 110 | + List<Command> flexrepCommands = new ArrayList<Command>(); |
| 111 | + flexrepCommands.add(new DeployConfigsCommand()); |
| 112 | + flexrepCommands.add(new DeployTargetsCommand()); |
| 113 | + flexrepCommands.add(new DeployFlexrepCommand()); |
| 114 | + map.put("mlFlexrepCommands", flexrepCommands); |
| 115 | + |
| 116 | + // Groups |
| 117 | + List<Command> groupCommands = new ArrayList<Command>(); |
| 118 | + groupCommands.add(new DeployGroupsCommand()); |
| 119 | + map.put("mlGroupCommands", groupCommands); |
| 120 | + |
| 121 | + List<Command> mimetypeCommands = new ArrayList<Command>(); |
| 122 | + mimetypeCommands.add(new DeployMimetypesCommand()); |
| 123 | + map.put("mlMimetypeCommands", mimetypeCommands); |
| 124 | + |
| 125 | + // Forests |
| 126 | + List<Command> forestCommands = new ArrayList<Command>(); |
| 127 | + forestCommands.add(new DeployCustomForestsCommand()); |
| 128 | + map.put("mlForestCommands", forestCommands); |
| 129 | + |
| 130 | + // Forest replicas |
| 131 | + List<Command> replicaCommands = new ArrayList<Command>(); |
| 132 | + replicaCommands.add(new ConfigureForestReplicasCommand()); |
| 133 | + map.put("mlForestReplicaCommands", replicaCommands); |
| 134 | + |
| 135 | + // Tasks |
| 136 | + List<Command> taskCommands = new ArrayList<Command>(); |
| 137 | + taskCommands.add(new DeployScheduledTasksCommand()); |
| 138 | + map.put("mlTaskCommands", taskCommands); |
| 139 | + |
| 140 | + // Triggers |
| 141 | + List<Command> triggerCommands = new ArrayList<Command>(); |
| 142 | + triggerCommands.add(new DeployTriggersCommand()); |
| 143 | + map.put("mlTriggerCommands", triggerCommands); |
| 144 | + |
| 145 | + // SQL Views |
| 146 | + List<Command> viewCommands = new ArrayList<Command>(); |
| 147 | + viewCommands.add(new DeployViewSchemasCommand()); |
| 148 | + map.put("mlViewCommands", viewCommands); |
| 149 | + |
| 150 | + return map; |
| 151 | + } |
| 152 | +} |
0 commit comments