From 2666b91c1b835377b4b287673b0c9a4b03e8102f Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Fri, 17 Aug 2007 06:59:41 +0000 Subject: [PATCH] [MRM-436] - Added '\' for the snapshots cron expression in default-archiva.xml to escape the ',' - (DefaultArchivaConfiguration) Added method for adding '\' to the cron expression if ',' exists before saving the configuration and method for removing '\' after the configuration is read from the configuration file git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@566945 13f79535-47bb-0310-9956-ffa450edef68 --- .../DefaultArchivaConfiguration.java | 53 ++++++++++++++++--- .../archiva/configuration/default-archiva.xml | 2 +- 2 files changed, 48 insertions(+), 7 deletions(-) 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 c652fb28b..38d7a6751 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 @@ -96,6 +96,9 @@ public class DefaultArchivaConfiguration { configuration = load(); } + + configuration = processExpressions( configuration ); + return configuration; } @@ -115,12 +118,6 @@ public class DefaultArchivaConfiguration Configuration config = new ConfigurationRegistryReader().read( subset ); - // TODO: for commons-configuration 1.3 only - for ( Iterator i = config.getRepositories().iterator(); i.hasNext(); ) - { - RepositoryConfiguration c = (RepositoryConfiguration) i.next(); - c.setUrl( removeExpressions( c.getUrl() ) ); - } return config; } @@ -181,6 +178,8 @@ public class DefaultArchivaConfiguration } } + configuration = escapeCronExpressions( configuration ); + new ConfigurationRegistryWriter().write( configuration, section ); section.save(); @@ -267,4 +266,46 @@ public class DefaultArchivaConfiguration return value; } + private String unescapeCronExpression( String cronExpression ) + { + return StringUtils.replace( cronExpression, "\\," , "," ); + } + + private String escapeCronExpression( String cronExpression ) + { + return StringUtils.replace( cronExpression, "," , "\\," ); + } + + private Configuration processExpressions( Configuration config ) + { + // TODO: for commons-configuration 1.3 only + for ( Iterator i = config.getRepositories().iterator(); i.hasNext(); ) + { + RepositoryConfiguration c = (RepositoryConfiguration) i.next(); + c.setUrl( removeExpressions( c.getUrl() ) ); + c.setRefreshCronExpression( unescapeCronExpression( c.getRefreshCronExpression() ) ); + } + + String cron = config.getDatabaseScanning().getCronExpression(); + config.getDatabaseScanning().setCronExpression( unescapeCronExpression( cron ) ); + + return config; + } + + private Configuration escapeCronExpressions( Configuration config ) + { + for ( Iterator i = config.getRepositories().iterator(); i.hasNext(); ) + { + RepositoryConfiguration c = (RepositoryConfiguration) i.next(); + + c.setRefreshCronExpression( + escapeCronExpression( c.getRefreshCronExpression() ) ); + } + + String cron = config.getDatabaseScanning().getCronExpression(); + config.getDatabaseScanning().setCronExpression( escapeCronExpression( cron ) ); + + return config; + } + } diff --git a/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml b/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml index d9e066c15..6e7d4681b 100644 --- a/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml +++ b/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml @@ -21,7 +21,7 @@ false true true - 0 0,30 0 * * ? + 0 0\,30 0 * * ? 30