use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class ShippingServiceImpl method removeCustomShippingQuoteModuleConfiguration.
@Override
public void removeCustomShippingQuoteModuleConfiguration(String moduleCode, MerchantStore store) throws ServiceException {
try {
removeShippingQuoteModuleConfiguration(moduleCode, store);
MerchantConfiguration merchantConfiguration = merchantConfigurationService.getMerchantConfiguration(moduleCode, store);
if (merchantConfiguration != null) {
merchantConfigurationService.delete(merchantConfiguration);
}
} catch (Exception e) {
throw new ServiceException(e);
}
}
use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class ShippingServiceImpl method saveCustomShippingConfiguration.
@Override
public void saveCustomShippingConfiguration(String moduleCode, CustomIntegrationConfiguration shippingConfiguration, MerchantStore store) throws ServiceException {
ShippingQuoteModule quoteModule = shippingModules.get(moduleCode);
if (quoteModule == null) {
throw new ServiceException("Shipping module " + moduleCode + " does not exist");
}
String configurationValue = shippingConfiguration.toJSONString();
try {
MerchantConfiguration configuration = merchantConfigurationService.getMerchantConfiguration(moduleCode, store);
if (configuration == null) {
configuration = new MerchantConfiguration();
configuration.setKey(moduleCode);
configuration.setMerchantStore(store);
}
configuration.setValue(configurationValue);
merchantConfigurationService.saveOrUpdate(configuration);
} catch (Exception e) {
throw new IntegrationException(e);
}
}
use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class ShoppingCartServiceImpl method getPopulatedShoppingCart.
/* @Override
@Transactional
public ShoppingCart getByCustomer(final Customer customer) throws ServiceException {
try {
List<ShoppingCart> shoppingCart = shoppingCartRepository.findByCustomer(customer.getId());
if (shoppingCart == null) {
return null;
}
return getPopulatedShoppingCart(shoppingCart);
} catch (Exception e) {
throw new ServiceException(e);
}
}*/
@Transactional(noRollbackFor = { org.springframework.dao.EmptyResultDataAccessException.class })
private ShoppingCart getPopulatedShoppingCart(final ShoppingCart shoppingCart) throws Exception {
try {
boolean cartIsObsolete = false;
if (shoppingCart != null) {
Set<ShoppingCartItem> items = shoppingCart.getLineItems();
if (items == null || items.size() == 0) {
shoppingCart.setObsolete(true);
return shoppingCart;
}
// HashSet<ShoppingCartItem>();
for (ShoppingCartItem item : items) {
LOGGER.debug("Populate item " + item.getId());
getPopulatedItem(item);
LOGGER.debug("Obsolete item ? " + item.isObsolete());
if (item.isObsolete()) {
cartIsObsolete = true;
}
}
// shoppingCart.setLineItems(shoppingCartItems);
Set<ShoppingCartItem> refreshedItems = new HashSet<>(items);
// if (refreshCart) {
shoppingCart.setLineItems(refreshedItems);
update(shoppingCart);
if (cartIsObsolete) {
shoppingCart.setObsolete(true);
}
return shoppingCart;
}
} catch (Exception e) {
LOGGER.error(e.getMessage());
throw new ServiceException(e);
}
return shoppingCart;
}
use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class LanguageServiceImpl method getLanguages.
@Override
@SuppressWarnings("unchecked")
public List<Language> getLanguages() throws ServiceException {
List<Language> langs = null;
try {
langs = (List<Language>) cache.getFromCache("LANGUAGES");
if (langs == null) {
langs = this.list();
cache.putInCache(langs, "LANGUAGES");
}
} catch (Exception e) {
LOGGER.error("getCountries()", e);
throw new ServiceException(e);
}
return langs;
}
use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class ConfigurationModulesLoader method loadIntegrationConfigurations.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Map<String, IntegrationConfiguration> loadIntegrationConfigurations(String value) throws Exception {
Map<String, IntegrationConfiguration> modules = new HashMap<String, IntegrationConfiguration>();
ObjectMapper mapper = new ObjectMapper();
try {
Map[] objects = mapper.readValue(value, Map[].class);
for (Map object : objects) {
IntegrationConfiguration configuration = new IntegrationConfiguration();
String moduleCode = (String) object.get("moduleCode");
if (object.get("active") != null) {
configuration.setActive((Boolean) object.get("active"));
}
if (object.get("defaultSelected") != null) {
configuration.setDefaultSelected((Boolean) object.get("defaultSelected"));
}
if (object.get("environment") != null) {
configuration.setEnvironment((String) object.get("environment"));
}
configuration.setModuleCode(moduleCode);
modules.put(moduleCode, configuration);
if (object.get("integrationKeys") != null) {
Map<String, String> confs = (Map<String, String>) object.get("integrationKeys");
configuration.setIntegrationKeys(confs);
}
if (object.get("integrationKeys") != null) {
Map<String, List<String>> options = (Map<String, List<String>>) object.get("integrationOptions");
configuration.setIntegrationOptions(options);
}
}
return modules;
} catch (Exception e) {
throw new ServiceException(e);
}
}
Aggregations