@@ -64,10 +64,10 @@ public class DeployDatabaseCommand extends AbstractCommand implements UndoableCo
64
64
private boolean createForestsOnEachHost = true ;
65
65
66
66
private int undoSortOrder ;
67
-
68
- private boolean isSubDatabase = false ;
67
+
68
+ private boolean subDatabase = false ;
69
69
private String superDatabaseName ;
70
-
70
+
71
71
72
72
public DeployDatabaseCommand () {
73
73
setExecuteSortOrder (SortOrderConstants .DEPLOY_OTHER_DATABASES );
@@ -88,30 +88,14 @@ public String toString() {
88
88
public Integer getUndoSortOrder () {
89
89
return undoSortOrder ;
90
90
}
91
-
92
- public void setIsSubDatabase (boolean isSubDatabase ){
93
- this .isSubDatabase = isSubDatabase ;
94
- }
95
-
96
- public boolean isSubDatabase () {
97
- return this .isSubDatabase ;
98
- }
99
-
100
- public void setSuperDatabaseName (String name ){
101
- this .superDatabaseName = name ;
102
- }
103
- public String getSuperDatabaseName () {
104
- return this .superDatabaseName ;
105
- }
106
-
107
91
108
92
@ Override
109
93
public void execute (CommandContext context ) {
110
94
String payload = buildPayload (context );
111
95
if (payload != null ) {
112
96
DatabaseManager dbMgr = new DatabaseManager (context .getManageClient ());
113
97
SaveReceipt receipt = dbMgr .save (payload );
114
-
98
+
115
99
databaseName = receipt .getResourceId ();
116
100
if (shouldCreateForests (context , payload )) {
117
101
buildDeployForestsCommand (payload , receipt , context ).execute (context );
@@ -124,7 +108,7 @@ public void execute(CommandContext context) {
124
108
if (!isSubDatabase ()){
125
109
this .addSubDatabases (dbMgr , context , receipt .getResourceId ());
126
110
}
127
-
111
+
128
112
}
129
113
}
130
114
@@ -140,25 +124,25 @@ public void undo(CommandContext context) {
140
124
dbMgr .delete (payload );
141
125
}
142
126
}
143
-
127
+
144
128
/**
145
129
* Creates and attaches sub-databases to a the specified database, making it a super-database.
146
130
* Note: Sub-databases are expected to have a configuration files in databases/subdatabases/<super-database-name>
147
131
* @param dbMgr
148
132
* @param context
149
- * @param superDatabaseName Name of the database the sub-databases are to be associated with
133
+ * @param superDatabaseName Name of the database the sub-databases are to be associated with
150
134
*/
151
135
protected void addSubDatabases (DatabaseManager dbMgr , CommandContext context , String superDatabaseName ) {
152
136
File subdbDir = new File (context .getAppConfig ().getConfigDir ().getDatabasesDir () + File .separator + "subdatabases" + File .separator + superDatabaseName );
153
- logger .info (format ("Checking for Subdatabases in: %s for database: %s" , subdbDir .getAbsolutePath (), superDatabaseName ));
137
+ logger .info (format ("Checking for sub-databases in: %s for database: %s" , subdbDir .getAbsolutePath (), superDatabaseName ));
154
138
if (subdbDir .exists ()){
155
139
List <String > subDbNames = new ArrayList <String >();
156
140
for (File f : listFilesInDirectory (subdbDir )) {
157
141
logger .info (format ("Will process sub database for %s found in file: %s" , superDatabaseName , f .getAbsolutePath ()));
158
142
DeployDatabaseCommand subDbCommand = new DeployDatabaseCommand ();
159
143
subDbCommand .setDatabaseFilename (f .getName ());
160
144
subDbCommand .setSuperDatabaseName (superDatabaseName );
161
- subDbCommand .setIsSubDatabase (true );
145
+ subDbCommand .setSubDatabase (true );
162
146
subDbCommand .execute (context );
163
147
subDbNames .add (subDbCommand .getDatabaseName ());
164
148
logger .info (format ("Created subdatabase %s for database %s" , subDbCommand .getDatabaseName (), superDatabaseName ));
@@ -168,7 +152,7 @@ protected void addSubDatabases(DatabaseManager dbMgr, CommandContext context, St
168
152
}
169
153
}
170
154
}
171
-
155
+
172
156
/**
173
157
* Detaches and deletes all sub-databases for the specified super-database
174
158
* @param dbMgr
@@ -185,13 +169,13 @@ protected void removeSubDatabases(DatabaseManager dbMgr, CommandContext context,
185
169
DeployDatabaseCommand subDbCommand = new DeployDatabaseCommand ();
186
170
subDbCommand .setDatabaseFilename (f .getName ());
187
171
subDbCommand .setSuperDatabaseName (superDatabaseName );
188
- subDbCommand .setIsSubDatabase (true );
172
+ subDbCommand .setSubDatabase (true );
189
173
subDbCommand .undo (context );
190
174
191
175
}
192
176
}
193
177
}
194
-
178
+
195
179
196
180
/**
197
181
* Configures the DatabaseManager in terms of how it deletes forests based on properties in the AppConfig instance
@@ -234,7 +218,6 @@ protected String getPayload(CommandContext context) {
234
218
if (databaseFilename != null ) {
235
219
if (isSubDatabase ()){
236
220
String subDbFileName =context .getAppConfig ().getConfigDir ().getDatabasesDir () + File .separator + "subdatabases" + File .separator + this .getSuperDatabaseName () + File .separator + databaseFilename ;
237
- logger .info ("!!!! getting paylod for: " + subDbFileName );
238
221
f = new File (subDbFileName );
239
222
}else {
240
223
f = new File (context .getAppConfig ().getConfigDir ().getDatabasesDir (), databaseFilename );
@@ -396,4 +379,20 @@ public boolean isCheckForCustomForests() {
396
379
public void setCheckForCustomForests (boolean checkForCustomForests ) {
397
380
this .checkForCustomForests = checkForCustomForests ;
398
381
}
382
+
383
+ public void setSubDatabase (boolean isSubDatabase ){
384
+ this .subDatabase = isSubDatabase ;
385
+ }
386
+
387
+ public boolean isSubDatabase () {
388
+ return this .subDatabase ;
389
+ }
390
+
391
+ public void setSuperDatabaseName (String name ){
392
+ this .superDatabaseName = name ;
393
+ }
394
+
395
+ public String getSuperDatabaseName () {
396
+ return this .superDatabaseName ;
397
+ }
399
398
}
0 commit comments