mirror of https://github.com/apache/archiva.git
[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:
parent
58671364fc
commit
2666b91c1b
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue