[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
This commit is contained in:
Maria Odea B. Ching 2007-08-17 06:59:41 +00:00
parent 58671364fc
commit 2666b91c1b
2 changed files with 48 additions and 7 deletions

View File

@ -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;
}
}

View File

@ -21,7 +21,7 @@
<releases>false</releases>
<snapshots>true</snapshots>
<indexed>true</indexed>
<refreshCronExpression>0 0,30 0 * * ?</refreshCronExpression>
<refreshCronExpression>0 0\,30 0 * * ?</refreshCronExpression>
<daysOlder>30</daysOlder>
</repository>
<repository>