Issue 1542: DirectoryListingService should be managed by Spring
Refactored creation of directoryListing service into a seperate method
Formatting of template URL is refactored to a dedicated step for
better readability
ConfigurationManager now is private scoped member variable as this
scope fits better
@@ -100,7 +100,7 @@ public class WebConfig
private YAMLMapperFactory yamlMapperFactory;
@Inject
- protected ConfigurationManager configurationManager;
+ private ConfigurationManager configurationManager;
WebConfig()
{
@@ -198,17 +198,22 @@ public class WebConfig
@Bean
@Qualifier("loggingManagementDirectoryListingService")
public DirectoryListingService getLoggingManagementDirectoryListingService()
+ {
+ return createDirectoryListingServiceForTemplate("%s/api/logging");
+ }
+
+ private DirectoryListingService createDirectoryListingServiceForTemplate(String template)
{
String baseUrl = StringUtils.chomp(configurationManager.getConfiguration().getBaseUrl(), "/");
- return new DirectoryListingServiceImpl(String.format("%s/api/logging", baseUrl));
+ String finalUrl = String.format(template, baseUrl);
+ return new DirectoryListingServiceImpl(finalUrl);
}
@Bean
@Qualifier("browseRepositoryDirectoryListingService")
public DirectoryListingService getBrowseRepositoryDirectoryListingService()
{
- String baseUrl = StringUtils.chomp(configurationManager.getConfiguration().getBaseUrl(), "/");
- return new DirectoryListingServiceImpl(String.format("%s/api/browse", baseUrl));
+ return createDirectoryListingServiceForTemplate("%s/api/browse");
}
@Override
