Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 57da88a

Browse files
committed
Little bit of cleanup of DeployDatabaseCommand
1 parent 406d647 commit 57da88a

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

src/main/java/com/marklogic/appdeployer/command/databases/DeployDatabaseCommand.java

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ public class DeployDatabaseCommand extends AbstractCommand implements UndoableCo
6464
private boolean createForestsOnEachHost = true;
6565

6666
private int undoSortOrder;
67-
68-
private boolean isSubDatabase = false;
67+
68+
private boolean subDatabase = false;
6969
private String superDatabaseName;
70-
70+
7171

7272
public DeployDatabaseCommand() {
7373
setExecuteSortOrder(SortOrderConstants.DEPLOY_OTHER_DATABASES);
@@ -88,30 +88,14 @@ public String toString() {
8888
public Integer getUndoSortOrder() {
8989
return undoSortOrder;
9090
}
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-
10791

10892
@Override
10993
public void execute(CommandContext context) {
11094
String payload = buildPayload(context);
11195
if (payload != null) {
11296
DatabaseManager dbMgr = new DatabaseManager(context.getManageClient());
11397
SaveReceipt receipt = dbMgr.save(payload);
114-
98+
11599
databaseName = receipt.getResourceId();
116100
if (shouldCreateForests(context, payload)) {
117101
buildDeployForestsCommand(payload, receipt, context).execute(context);
@@ -124,7 +108,7 @@ public void execute(CommandContext context) {
124108
if(!isSubDatabase()){
125109
this.addSubDatabases(dbMgr, context, receipt.getResourceId());
126110
}
127-
111+
128112
}
129113
}
130114

@@ -140,25 +124,25 @@ public void undo(CommandContext context) {
140124
dbMgr.delete(payload);
141125
}
142126
}
143-
127+
144128
/**
145129
* Creates and attaches sub-databases to a the specified database, making it a super-database.
146130
* Note: Sub-databases are expected to have a configuration files in databases/subdatabases/<super-database-name>
147131
* @param dbMgr
148132
* @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
150134
*/
151135
protected void addSubDatabases(DatabaseManager dbMgr, CommandContext context, String superDatabaseName) {
152136
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));
154138
if(subdbDir.exists()){
155139
List<String> subDbNames = new ArrayList<String>();
156140
for (File f : listFilesInDirectory(subdbDir)) {
157141
logger.info(format("Will process sub database for %s found in file: %s", superDatabaseName, f.getAbsolutePath()));
158142
DeployDatabaseCommand subDbCommand = new DeployDatabaseCommand();
159143
subDbCommand.setDatabaseFilename(f.getName());
160144
subDbCommand.setSuperDatabaseName(superDatabaseName);
161-
subDbCommand.setIsSubDatabase(true);
145+
subDbCommand.setSubDatabase(true);
162146
subDbCommand.execute(context);
163147
subDbNames.add(subDbCommand.getDatabaseName());
164148
logger.info(format("Created subdatabase %s for database %s", subDbCommand.getDatabaseName(), superDatabaseName));
@@ -168,7 +152,7 @@ protected void addSubDatabases(DatabaseManager dbMgr, CommandContext context, St
168152
}
169153
}
170154
}
171-
155+
172156
/**
173157
* Detaches and deletes all sub-databases for the specified super-database
174158
* @param dbMgr
@@ -185,13 +169,13 @@ protected void removeSubDatabases(DatabaseManager dbMgr, CommandContext context,
185169
DeployDatabaseCommand subDbCommand = new DeployDatabaseCommand();
186170
subDbCommand.setDatabaseFilename(f.getName());
187171
subDbCommand.setSuperDatabaseName(superDatabaseName);
188-
subDbCommand.setIsSubDatabase(true);
172+
subDbCommand.setSubDatabase(true);
189173
subDbCommand.undo(context);
190174

191175
}
192176
}
193177
}
194-
178+
195179

196180
/**
197181
* 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) {
234218
if (databaseFilename != null) {
235219
if(isSubDatabase()){
236220
String subDbFileName =context.getAppConfig().getConfigDir().getDatabasesDir() + File.separator + "subdatabases" + File.separator + this.getSuperDatabaseName() + File.separator + databaseFilename;
237-
logger.info("!!!! getting paylod for: " + subDbFileName);
238221
f = new File(subDbFileName);
239222
}else {
240223
f = new File(context.getAppConfig().getConfigDir().getDatabasesDir(), databaseFilename);
@@ -396,4 +379,20 @@ public boolean isCheckForCustomForests() {
396379
public void setCheckForCustomForests(boolean checkForCustomForests) {
397380
this.checkForCustomForests = checkForCustomForests;
398381
}
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+
}
399398
}

0 commit comments

Comments
 (0)