use of com.salesmanager.core.business.exception.ConversionException in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method getCustomerDataByUserName.
/**
* Method used to fetch customer based on the username and storecode. Customer username is unique
* to each store.
*
* @param userName
* @param store
* @throws ConversionException
*/
@Override
public CustomerEntity getCustomerDataByUserName(final String userName, final MerchantStore store, final Language language) throws Exception {
LOG.info("Fetching customer with userName" + userName);
Customer customer = customerService.getByNick(userName);
if (customer != null) {
LOG.info("Found customer, converting to CustomerEntity");
try {
CustomerEntityPopulator customerEntityPopulator = new CustomerEntityPopulator();
// store, language
return customerEntityPopulator.populate(customer, store, language);
} catch (ConversionException ex) {
LOG.error("Error while converting Customer to CustomerEntity", ex);
throw new Exception(ex);
}
}
return null;
}
use of com.salesmanager.core.business.exception.ConversionException in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method convertPersistableCustomerToCustomer.
private Customer convertPersistableCustomerToCustomer(PersistableCustomer customer, MerchantStore store) {
Customer cust = new Customer();
try {
customerPopulator.populate(customer, cust, store, store.getDefaultLanguage());
} catch (ConversionException e) {
throw new ConversionRuntimeException(e);
}
List<Group> groups = getListOfGroups(GroupType.CUSTOMER);
cust.setGroups(groups);
String password = customer.getPassword();
if (StringUtils.isBlank(password)) {
password = new String(UUID.generateRandomBytes());
customer.setPassword(password);
}
return cust;
}
use of com.salesmanager.core.business.exception.ConversionException in project shopizer by shopizer-ecommerce.
the class SearchFacadeImpl method convertProductToReadableProduct.
private ReadableProduct convertProductToReadableProduct(Product product, MerchantStore merchantStore, Language language) {
ReadableProductPopulator populator = new ReadableProductPopulator();
populator.setPricingService(pricingService);
populator.setimageUtils(imageUtils);
try {
return populator.populate(product, new ReadableProduct(), merchantStore, language);
} catch (ConversionException e) {
throw new ConversionRuntimeException(e);
}
}
use of com.salesmanager.core.business.exception.ConversionException in project shopizer by shopizer-ecommerce.
the class ShippingFacadeImpl method shipToCountry.
@Override
public List<ReadableCountry> shipToCountry(MerchantStore store, Language language) {
try {
List<Country> countries = shippingService.getShipToCountryList(store, language);
List<ReadableCountry> countryList = new ArrayList<ReadableCountry>();
if (!CollectionUtils.isEmpty(countries)) {
countryList = countries.stream().map(c -> {
try {
return convert(c, store, language);
} catch (ConversionException e) {
throw new ConversionRuntimeException("Error converting Country to readable country,e");
}
}).sorted(Comparator.comparing(ReadableCountry::getName)).collect(Collectors.toList());
}
return countryList;
} catch (Exception e) {
throw new ServiceRuntimeException("Error getting shipping country", e);
}
}
use of com.salesmanager.core.business.exception.ConversionException in project shopizer by shopizer-ecommerce.
the class ProductCommonFacadeImpl method getProduct.
@Override
public ReadableProduct getProduct(MerchantStore store, Long id, Language language) {
Product product = productService.findOne(id, store);
if (product == null) {
throw new ResourceNotFoundException("Product [" + id + "] not found");
}
if (product.getMerchantStore().getId() != store.getId()) {
throw new ResourceNotFoundException("Product [" + id + "] not found for store [" + store.getId() + "]");
}
ReadableProduct readableProduct = new ReadableProduct();
ReadableProductPopulator populator = new ReadableProductPopulator();
populator.setPricingService(pricingService);
populator.setimageUtils(imageUtils);
try {
readableProduct = populator.populate(product, readableProduct, store, language);
} catch (ConversionException e) {
throw new ConversionRuntimeException("Error converting product [" + id + "]", e);
}
return readableProduct;
}
Aggregations