use of org.broadleafcommerce.common.config.domain.ModuleConfiguration in project BroadleafCommerce by BroadleafCommerce.
the class AddressServiceImpl method verifyAddress.
@Override
public List<Address> verifyAddress(Address address) throws AddressVerificationException {
if (address.getStandardized() != null && Boolean.TRUE.equals(address.getStandardized())) {
// If this address is already standardized, don't waste a call.
ArrayList<Address> out = new ArrayList<Address>();
out.add(address);
return out;
}
if (providers != null && !providers.isEmpty()) {
List<ModuleConfiguration> moduleConfigs = moduleConfigService.findActiveConfigurationsByType(ModuleConfigurationType.ADDRESS_VERIFICATION);
if (moduleConfigs != null && !moduleConfigs.isEmpty()) {
// Try to find a default configuration
ModuleConfiguration config = null;
for (ModuleConfiguration configuration : moduleConfigs) {
if (configuration.getIsDefault()) {
config = configuration;
break;
}
}
if (config == null) {
// if there wasn't a default one, use the first active one...
config = moduleConfigs.get(0);
}
for (AddressVerificationProvider provider : providers) {
if (provider.canRespond(config)) {
return provider.validateAddress(address, config);
}
}
}
}
if (mustValidateAddresses) {
throw new AddressVerificationException("No providers were configured to handle address validation");
}
ArrayList<Address> out = new ArrayList<Address>();
out.add(address);
return out;
}
use of org.broadleafcommerce.common.config.domain.ModuleConfiguration in project BroadleafCommerce by BroadleafCommerce.
the class SiteMapServiceImpl method findActiveSiteMapConfiguration.
protected SiteMapConfiguration findActiveSiteMapConfiguration() {
List<ModuleConfiguration> configurations = moduleConfigurationService.findActiveConfigurationsByType(ModuleConfigurationType.SITE_MAP);
SiteMapConfiguration smc = null;
if (configurations != null && !configurations.isEmpty()) {
// Try to find a default configuration
for (ModuleConfiguration configuration : configurations) {
if (configuration.getIsDefault()) {
smc = (SiteMapConfiguration) configuration;
break;
}
}
if (smc == null) {
// if there wasn't a default one, use the first active one...
smc = (SiteMapConfiguration) configurations.get(0);
}
}
return smc;
}
use of org.broadleafcommerce.common.config.domain.ModuleConfiguration in project BroadleafCommerce by BroadleafCommerce.
the class SiteMapGeneratorTest method testGenerator.
protected void testGenerator(List<SiteMapGeneratorConfiguration> smgcList, SiteMapGenerator smg, int maxEntriesPerFile) throws SiteMapException, IOException {
if (CollectionUtils.isNotEmpty(smgcList)) {
SiteMapConfiguration smc = new SiteMapConfigurationImpl();
smc.setMaximumUrlEntriesPerFile(maxEntriesPerFile);
smc.setSiteMapGeneratorConfigurations(smgcList);
smc.setIndexedSiteMapFileName("sitemap_index.xml");
for (SiteMapGeneratorConfiguration smgc : smgcList) {
smgc.setSiteMapConfiguration(smc);
}
List<ModuleConfiguration> mcList = new ArrayList<>();
mcList.add(smc);
ModuleConfigurationService mcs = EasyMock.createMock(ModuleConfigurationService.class);
EasyMock.expect(mcs.findActiveConfigurationsByType(ModuleConfigurationType.SITE_MAP)).andReturn(mcList);
EasyMock.replay(mcs);
List<SiteMapGenerator> smgList = new ArrayList<>();
smgList.add(smg);
siteMapService.setGzipSiteMapFiles(false);
siteMapService.setModuleConfigurationService(mcs);
siteMapService.setSiteMapGenerators(smgList);
SiteMapGenerationResponse smgr = siteMapService.generateSiteMap();
Assert.assertFalse(smgr.isHasError());
}
}
use of org.broadleafcommerce.common.config.domain.ModuleConfiguration in project BroadleafCommerce by BroadleafCommerce.
the class TaxServiceImpl method calculateTaxForOrder.
@Override
public Order calculateTaxForOrder(Order order) throws TaxException {
List<ModuleConfiguration> configurations = moduleConfigService.findActiveConfigurationsByType(ModuleConfigurationType.TAX_CALCULATION);
// Try to find a default configuration
ModuleConfiguration config = null;
if (configurations != null) {
for (ModuleConfiguration configuration : configurations) {
if (configuration.getIsDefault()) {
config = configuration;
break;
}
}
if (config == null && CollectionUtils.isNotEmpty(configurations)) {
// if there wasn't a default one, use the first active one...
config = configurations.get(0);
}
}
if (CollectionUtils.isNotEmpty(providers)) {
for (TaxProvider provider : providers) {
if (provider.canRespond(config)) {
return provider.calculateTaxForOrder(order, config);
}
}
}
// haven't returned anything, nothing must have run
if (!mustCalculate) {
return order;
}
throw new TaxException("No eligible tax providers were configured.");
}
Aggregations