use of com.salesmanager.shop.store.api.exception.ConversionRuntimeException 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.shop.store.api.exception.ConversionRuntimeException 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.shop.store.api.exception.ConversionRuntimeException 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.shop.store.api.exception.ConversionRuntimeException 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;
}
use of com.salesmanager.shop.store.api.exception.ConversionRuntimeException in project shopizer by shopizer-ecommerce.
the class ProductFacadeImpl method getProductByCode.
@Override
public ReadableProduct getProductByCode(MerchantStore store, String uniqueCode, Language language) {
Product product = productService.getByCode(uniqueCode, language);
ReadableProduct readableProduct = new ReadableProduct();
ReadableProductPopulator populator = new ReadableProductPopulator();
populator.setPricingService(pricingService);
populator.setimageUtils(imageUtils);
try {
populator.populate(product, readableProduct, product.getMerchantStore(), language);
} catch (ConversionException e) {
throw new ConversionRuntimeException("Product with code [" + uniqueCode + "] cannot be converted", e);
}
return readableProduct;
}
Aggregations