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

Commit a2fb76d

Browse files
author
Rob Rudin
committed
#149 User-provided filenames are now ignored properly by DeployOtherDatabasesCommand
1 parent 81529c0 commit a2fb76d

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,10 @@ protected void sortCommandsBeforeUndo(List<DeployDatabaseCommand> list, CommandC
6161

6262
protected List<DeployDatabaseCommand> buildDatabaseCommands(CommandContext context) {
6363
List<DeployDatabaseCommand> dbCommands = new ArrayList<>();
64-
6564
ConfigDir configDir = context.getAppConfig().getConfigDir();
6665
File dir = configDir.getDatabasesDir();
6766
if (dir != null && dir.exists()) {
68-
Set<String> ignore = new HashSet<>();
69-
for (File f : configDir.getContentDatabaseFiles()) {
70-
ignore.add(f.getName());
71-
}
72-
ignore.add(DeploySchemasDatabaseCommand.DATABASE_FILENAME);
73-
ignore.add(DeployTriggersDatabaseCommand.DATABASE_FILENAME);
74-
75-
ResourceFilenameFilter filter = new ResourceFilenameFilter(ignore);
76-
setResourceFilenameFilter(filter);
77-
67+
ignoreKnownDatabaseFilenames(context);
7868
for (File f : listFilesInDirectory(dir)) {
7969
if (logger.isDebugEnabled()) {
8070
logger.debug("Will process other database in file: " + f.getName());
@@ -86,4 +76,19 @@ protected List<DeployDatabaseCommand> buildDatabaseCommands(CommandContext conte
8676
}
8777
return dbCommands;
8878
}
79+
80+
/**
81+
* Adds to the list of resource filenames to ignore. Some may already have been set via the superclass method.
82+
*
83+
* @param context
84+
*/
85+
protected void ignoreKnownDatabaseFilenames(CommandContext context) {
86+
Set<String> ignore = new HashSet<>();
87+
for (File f : context.getAppConfig().getConfigDir().getContentDatabaseFiles()) {
88+
ignore.add(f.getName());
89+
}
90+
ignore.add(DeploySchemasDatabaseCommand.DATABASE_FILENAME);
91+
ignore.add(DeployTriggersDatabaseCommand.DATABASE_FILENAME);
92+
setFilenamesToIgnore(ignore.toArray(new String[]{}));
93+
}
8994
}

src/test/java/com/marklogic/appdeployer/command/databases/DeployOtherDatabasesTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public void test() {
1919

2020
appConfig.getForestCounts().put("other-sample-app-content", 2);
2121
appConfig.getForestCounts().put("other-sample-app-schemas", 3);
22+
appConfig.setResourceFilenamesToIgnore("ignored-database.json");
2223

2324
initializeAppDeployer(new DeployRestApiServersCommand(), new DeployContentDatabasesCommand(2),
2425
new DeployTriggersDatabaseCommand(), new DeploySchemasDatabaseCommand(),
@@ -34,6 +35,7 @@ public void test() {
3435
for (String name : dbNames) {
3536
assertTrue("Expected to find database: " + name, dbMgr.exists(name));
3637
}
38+
assertFalse("ignored-database.json should have been ignored", dbMgr.exists("ignored-content"));
3739

3840
assertEquals("The main content database should have 2 forests, as set in the command", 2,
3941
dbMgr.getForestIds("sample-app-content").size());
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"database-name": "ignored-content",
3+
"triggers-database": "other-sample-app-triggers",
4+
"schema-database": "other-sample-app-schemas"
5+
}

0 commit comments

Comments
 (0)