use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class StoreFacadeImpl method convertToMerchantConfiguration.
private MerchantConfiguration convertToMerchantConfiguration(MerchantConfigEntity config, MerchantConfigurationType configurationType) {
MerchantConfiguration configTO = new MerchantConfiguration();
configTO.setId(config.getId());
configTO.setKey(config.getKey());
configTO.setMerchantConfigurationType(configurationType);
configTO.setValue(config.getValue());
configTO.setActive(new Boolean(config.isActive()));
return configTO;
}
use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class ShippingServiceImpl method getShippingModulesConfigured.
@Override
public Map<String, IntegrationConfiguration> getShippingModulesConfigured(MerchantStore store) throws ServiceException {
try {
Map<String, IntegrationConfiguration> modules = new HashMap<String, IntegrationConfiguration>();
MerchantConfiguration merchantConfiguration = merchantConfigurationService.getMerchantConfiguration(SHIPPING_MODULES, store);
if (merchantConfiguration != null) {
if (!StringUtils.isBlank(merchantConfiguration.getValue())) {
String decrypted = encryption.decrypt(merchantConfiguration.getValue());
modules = ConfigurationModulesLoader.loadIntegrationConfigurations(decrypted);
}
}
return modules;
} catch (Exception e) {
throw new ServiceException(e);
}
}
use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class ShippingServiceImpl method getShipToCountryList.
@Override
public List<Country> getShipToCountryList(MerchantStore store, Language language) throws ServiceException {
ShippingConfiguration shippingConfiguration = getShippingConfiguration(store);
ShippingType shippingType = ShippingType.INTERNATIONAL;
List<String> supportedCountries = new ArrayList<String>();
if (shippingConfiguration == null) {
shippingConfiguration = new ShippingConfiguration();
}
if (shippingConfiguration.getShippingType() != null) {
shippingType = shippingConfiguration.getShippingType();
}
if (shippingType.name().equals(ShippingType.NATIONAL.name())) {
supportedCountries.add(store.getCountry().getIsoCode());
} else {
MerchantConfiguration configuration = merchantConfigurationService.getMerchantConfiguration(SUPPORTED_COUNTRIES, store);
if (configuration != null) {
String countries = configuration.getValue();
if (!StringUtils.isBlank(countries)) {
Object objRegions = JSONValue.parse(countries);
JSONArray arrayRegions = (JSONArray) objRegions;
for (Object arrayRegion : arrayRegions) {
supportedCountries.add((String) arrayRegion);
}
}
}
}
return countryService.getCountries(supportedCountries, language);
}
use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class ShippingServiceImpl method saveShippingQuoteModuleConfiguration.
@Override
public void saveShippingQuoteModuleConfiguration(IntegrationConfiguration configuration, MerchantStore store) throws ServiceException {
// validate entries
try {
String moduleCode = configuration.getModuleCode();
ShippingQuoteModule quoteModule = (ShippingQuoteModule) shippingModules.get(moduleCode);
if (quoteModule == null) {
throw new ServiceException("Shipping quote module " + moduleCode + " does not exist");
}
quoteModule.validateModuleConfiguration(configuration, store);
} catch (IntegrationException ie) {
throw ie;
}
try {
Map<String, IntegrationConfiguration> modules = new HashMap<String, IntegrationConfiguration>();
MerchantConfiguration merchantConfiguration = merchantConfigurationService.getMerchantConfiguration(SHIPPING_MODULES, store);
if (merchantConfiguration != null) {
if (!StringUtils.isBlank(merchantConfiguration.getValue())) {
String decrypted = encryption.decrypt(merchantConfiguration.getValue());
modules = ConfigurationModulesLoader.loadIntegrationConfigurations(decrypted);
}
} else {
merchantConfiguration = new MerchantConfiguration();
merchantConfiguration.setMerchantStore(store);
merchantConfiguration.setKey(SHIPPING_MODULES);
}
modules.put(configuration.getModuleCode(), configuration);
String configs = ConfigurationModulesLoader.toJSONString(modules);
String encrypted = encryption.encrypt(configs);
merchantConfiguration.setValue(encrypted);
merchantConfigurationService.saveOrUpdate(merchantConfiguration);
} catch (Exception e) {
throw new ServiceException(e);
}
}
use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class ShippingServiceImpl method setSupportedCountries.
@Override
public void setSupportedCountries(MerchantStore store, List<String> countryCodes) throws ServiceException {
// transform a list of string to json entry
ObjectMapper mapper = new ObjectMapper();
try {
String value = mapper.writeValueAsString(countryCodes);
MerchantConfiguration configuration = merchantConfigurationService.getMerchantConfiguration(SUPPORTED_COUNTRIES, store);
if (configuration == null) {
configuration = new MerchantConfiguration();
configuration.setKey(SUPPORTED_COUNTRIES);
configuration.setMerchantStore(store);
}
configuration.setValue(value);
merchantConfigurationService.saveOrUpdate(configuration);
} catch (Exception e) {
throw new ServiceException(e);
}
}
Aggregations