From c8571f77e285d4012e75b1ebe28b0fb85b6f9379 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Fri, 17 Aug 2007 07:47:06 +0000 Subject: [MRM-436] configuration tests don't always set database scanning fields, so add some null guards git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@566959 13f79535-47bb-0310-9956-ffa450edef68 --- .../configuration/DefaultArchivaConfiguration.java | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'archiva-base/archiva-configuration') diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java index 38d7a6751..82ff2069b 100644 --- a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java @@ -268,17 +268,17 @@ public class DefaultArchivaConfiguration private String unescapeCronExpression( String cronExpression ) { - return StringUtils.replace( cronExpression, "\\," , "," ); + return StringUtils.replace( cronExpression, "\\,", "," ); } private String escapeCronExpression( String cronExpression ) { - return StringUtils.replace( cronExpression, "," , "\\," ); + return StringUtils.replace( cronExpression, ",", "\\," ); } - private Configuration processExpressions( Configuration config ) + private Configuration processExpressions( Configuration config ) { - // TODO: for commons-configuration 1.3 only + // TODO: for commons-configuration 1.3 only for ( Iterator i = config.getRepositories().iterator(); i.hasNext(); ) { RepositoryConfiguration c = (RepositoryConfiguration) i.next(); @@ -286,8 +286,12 @@ public class DefaultArchivaConfiguration c.setRefreshCronExpression( unescapeCronExpression( c.getRefreshCronExpression() ) ); } - String cron = config.getDatabaseScanning().getCronExpression(); - config.getDatabaseScanning().setCronExpression( unescapeCronExpression( cron ) ); + DatabaseScanningConfiguration databaseScanning = config.getDatabaseScanning(); + if ( databaseScanning != null ) + { + String cron = databaseScanning.getCronExpression(); + databaseScanning.setCronExpression( unescapeCronExpression( cron ) ); + } return config; } @@ -298,12 +302,15 @@ public class DefaultArchivaConfiguration { RepositoryConfiguration c = (RepositoryConfiguration) i.next(); - c.setRefreshCronExpression( - escapeCronExpression( c.getRefreshCronExpression() ) ); + c.setRefreshCronExpression( escapeCronExpression( c.getRefreshCronExpression() ) ); } - String cron = config.getDatabaseScanning().getCronExpression(); - config.getDatabaseScanning().setCronExpression( escapeCronExpression( cron ) ); + DatabaseScanningConfiguration databaseScanning = config.getDatabaseScanning(); + if ( databaseScanning != null ) + { + String cron = databaseScanning.getCronExpression(); + databaseScanning.setCronExpression( escapeCronExpression( cron ) ); + } return config; } -- cgit v1.2.3