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

Commit f7d883d

Browse files
committed
#222 Logging when resource directories not found
1 parent 7653719 commit f7d883d

14 files changed

+51
-17
lines changed

src/main/java/com/marklogic/appdeployer/command/AbstractCommand.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ protected File[] listFilesInDirectory(File dir) {
206206
return files;
207207
}
208208

209+
protected void logResourceDirectoryNotFound(File dir) {
210+
if (dir != null && logger.isInfoEnabled()) {
211+
logger.info("No resource directory found at: " + dir.getAbsolutePath());
212+
}
213+
}
214+
209215
public void setPayloadTokenReplacer(PayloadTokenReplacer payloadTokenReplacer) {
210216
this.payloadTokenReplacer = payloadTokenReplacer;
211217
}

src/main/java/com/marklogic/appdeployer/command/AbstractResourceCommand.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ protected File[] findResourceDirs(AppConfig appConfig, ResourceDirFinder resourc
5555
File dir = resourceDirFinder.getResourceDir(configDir);
5656
if (dir != null && dir.exists()) {
5757
list.add(dir);
58-
} else if (dir != null && logger.isInfoEnabled()) {
59-
logger.info("No resource directory found at: " + dir.getAbsolutePath());
58+
} else {
59+
logResourceDirectoryNotFound(dir);
6060
}
6161
}
6262
}
@@ -67,20 +67,22 @@ protected File[] findResourceDirs(AppConfig appConfig, ResourceDirFinder resourc
6767
}
6868

6969
protected void processExecuteOnResourceDir(CommandContext context, File resourceDir) {
70-
if (resourceDir.exists()) {
71-
ResourceManager mgr = getResourceManager(context);
72-
if (logger.isInfoEnabled()) {
73-
logger.info("Processing files in directory: " + resourceDir.getAbsolutePath());
74-
}
75-
for (File f : listFilesInDirectory(resourceDir, context)) {
76-
if (logger.isInfoEnabled()) {
77-
logger.info("Processing file: " + f.getAbsolutePath());
78-
}
79-
SaveReceipt receipt = saveResource(mgr, context, f);
80-
afterResourceSaved(mgr, context, f, receipt);
81-
}
82-
}
83-
}
70+
if (resourceDir.exists()) {
71+
ResourceManager mgr = getResourceManager(context);
72+
if (logger.isInfoEnabled()) {
73+
logger.info("Processing files in directory: " + resourceDir.getAbsolutePath());
74+
}
75+
for (File f : listFilesInDirectory(resourceDir, context)) {
76+
if (logger.isInfoEnabled()) {
77+
logger.info("Processing file: " + f.getAbsolutePath());
78+
}
79+
SaveReceipt receipt = saveResource(mgr, context, f);
80+
afterResourceSaved(mgr, context, f, receipt);
81+
}
82+
} else {
83+
logResourceDirectoryNotFound(resourceDir);
84+
}
85+
}
8486

8587
/**
8688
* Defaults to the parent method. This was extracted so that a subclass can override it and have access to the

src/main/java/com/marklogic/appdeployer/command/alert/DeployAlertActionsCommand.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ protected void deployActions(CommandContext context, ConfigDir configDir, String
4848
deployActionsInDirectory(f, context, databaseIdOrName);
4949
}
5050
}
51+
} else {
52+
logResourceDirectoryNotFound(configsDir);
5153
}
5254
}
5355

src/main/java/com/marklogic/appdeployer/command/alert/DeployAlertRulesCommand.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ protected void deployRules(CommandContext context, ConfigDir configDir, String d
4040
deployRulesInDirectory(f, context, databaseIdOrName);
4141
}
4242
}
43+
} else {
44+
logResourceDirectoryNotFound(configsDir);
4345
}
4446
}
4547

src/main/java/com/marklogic/appdeployer/command/clusters/ModifyLocalClusterCommand.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public void execute(CommandContext context) {
3030
new ClusterManager(context.getManageClient()).modifyLocalCluster(payload, context.getAdminManager());
3131
}
3232
}
33+
} else {
34+
logResourceDirectoryNotFound(clustersDir);
3335
}
3436
}
3537
}

src/main/java/com/marklogic/appdeployer/command/cpf/AbstractCpfResourceCommand.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public void execute(CommandContext context) {
2525
String payload = copyFileToString(f, context);
2626
mgr.save(config.getTriggersDatabaseName(), payload);
2727
}
28+
} else {
29+
logResourceDirectoryNotFound(dir);
2830
}
2931
}
3032
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ protected List<DeployDatabaseCommand> buildDatabaseCommands(CommandContext conte
7676
}
7777
dbCommands.add(buildDeployDatabaseCommand(f));
7878
}
79+
} else {
80+
logResourceDirectoryNotFound(dir);
7981
}
8082
}
8183
return dbCommands;

src/main/java/com/marklogic/appdeployer/command/flexrep/DeployFlexrepCommand.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public void execute(CommandContext context) {
4848
configDir.setBaseDir(currentBaseDir);
4949
}
5050
}
51+
} else {
52+
logResourceDirectoryNotFound(flexrepBaseDir);
5153
}
5254
}
5355

@@ -74,6 +76,9 @@ public void undo(CommandContext context) {
7476
protected File getFlexrepBaseDir(AppConfig appConfig) {
7577
String path = appConfig.getFlexrepPath();
7678
if (path == null) {
79+
if (logger.isInfoEnabled()) {
80+
logger.info("Flexrep path not configured, so not attempting to find any Flexrep resources to deploy");
81+
}
7782
return null;
7883
}
7984

@@ -85,6 +90,7 @@ protected File getFlexrepBaseDir(AppConfig appConfig) {
8590
for (ConfigDir configDir : appConfig.getConfigDirs()) {
8691
File flexrepDir = configDir.getFlexrepDir();
8792
if (flexrepDir == null || !flexrepDir.exists()) {
93+
logResourceDirectoryNotFound(flexrepDir);
8894
continue;
8995
}
9096

src/main/java/com/marklogic/appdeployer/command/flexrep/DeployTargetsCommand.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ protected void deployTargets(CommandContext context, ConfigDir configDir, String
4444
deployTargetsInDirectory(f, context, databaseIdOrName);
4545
}
4646
}
47+
} else {
48+
logResourceDirectoryNotFound(configsDir);
4749
}
4850
}
4951

src/main/java/com/marklogic/appdeployer/command/forests/ConfigureForestReplicasCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public void execute(CommandContext context) {
6464

6565
if ((databaseNamesAndReplicaCounts == null || databaseNamesAndReplicaCounts.isEmpty())
6666
&& (forestNamesAndReplicaCounts == null || forestNamesAndReplicaCounts.isEmpty())) {
67+
logger.info("No database or forest replica counts defined, so not configuring any forest replicas");
6768
return;
6869
}
6970

0 commit comments

Comments
 (0)