use of com.salesmanager.shop.store.api.exception.ServiceRuntimeException in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method create.
@Override
public ReadableCustomer create(PersistableCustomer customer, MerchantStore store, Language language) {
Validate.notNull(customer, "Customer cannot be null");
Validate.notNull(customer.getEmailAddress(), "Customer email address is required");
// set customer user name
customer.setUserName(customer.getEmailAddress());
if (userExist(customer.getUserName())) {
throw new ServiceRuntimeException("User already exist");
}
// end user exists
Customer customerToPopulate = convertPersistableCustomerToCustomer(customer, store);
try {
setCustomerModelDefaultProperties(customerToPopulate, store);
} catch (Exception e) {
throw new ServiceRuntimeException("Cannot set default customer properties", e);
}
saveCustomer(customerToPopulate);
customer.setId(customerToPopulate.getId());
notifyNewCustomer(customer, store, customerToPopulate.getDefaultLanguage());
// convert to readable
return convertCustomerToReadableCustomer(customerToPopulate, store, language);
}
use of com.salesmanager.shop.store.api.exception.ServiceRuntimeException in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method updateAuthCustomer.
private PersistableCustomer updateAuthCustomer(PersistableCustomer customer, MerchantStore store) {
if (customer.getId() == null || customer.getId() == 0) {
throw new ServiceRuntimeException("Can't update a customer with null id");
}
Customer cust = customerService.getById(customer.getId());
try {
customerPopulator.populate(customer, cust, store, store.getDefaultLanguage());
} catch (ConversionException e) {
throw new ConversionRuntimeException(e);
}
saveCustomer(cust);
customer.setId(cust.getId());
return customer;
}
use of com.salesmanager.shop.store.api.exception.ServiceRuntimeException in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method changePassword.
@Override
public void changePassword(Customer customer, String newPassword) {
String encoded = passwordEncoder.encode(newPassword);
customer.setPassword(encoded);
try {
customerService.update(customer);
} catch (ServiceException e) {
throw new ServiceRuntimeException("Exception while changing password", e);
}
}
use of com.salesmanager.shop.store.api.exception.ServiceRuntimeException in project shopizer by shopizer-ecommerce.
the class ShippingFacadeImpl method getDbConfig.
private ShippingConfiguration getDbConfig(MerchantStore store) {
try {
// get original configuration
ShippingConfiguration config = shippingService.getShippingConfiguration(store);
if (config == null) {
config = new ShippingConfiguration();
config.setShippingType(ShippingType.INTERNATIONAL);
}
return config;
} catch (ServiceException e) {
LOGGER.error("Error while getting expedition configuration", e);
throw new ServiceRuntimeException("Error while getting Expedition configuration for store[" + store.getCode() + "]", e);
}
}
use of com.salesmanager.shop.store.api.exception.ServiceRuntimeException in project shopizer by shopizer-ecommerce.
the class ShippingFacadeImpl method getExpeditionConfiguration.
@Override
public ExpeditionConfiguration getExpeditionConfiguration(MerchantStore store, Language language) {
ExpeditionConfiguration expeditionConfiguration = new ExpeditionConfiguration();
try {
ShippingConfiguration config = getDbConfig(store);
if (config != null) {
expeditionConfiguration.setIternationalShipping(config.getShipType() != null && config.getShipType().equals(ShippingType.INTERNATIONAL.name()) ? true : false);
expeditionConfiguration.setTaxOnShipping(config.isTaxOnShipping());
}
List<String> countries = shippingService.getSupportedCountries(store);
if (!CollectionUtils.isEmpty(countries)) {
List<String> countryCode = countries.stream().sorted(Comparator.comparing(n -> n.toString())).collect(Collectors.toList());
expeditionConfiguration.setShipToCountry(countryCode);
}
} catch (ServiceException e) {
LOGGER.error("Error while getting expedition configuration", e);
throw new ServiceRuntimeException("Error while getting Expedition configuration for store[" + store.getCode() + "]", e);
}
return expeditionConfiguration;
}
Aggregations