Search in sources :

Example 16 with ConversionRuntimeException

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;
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) Group(com.salesmanager.core.model.user.Group) ReadableCustomer(com.salesmanager.shop.model.customer.ReadableCustomer) Customer(com.salesmanager.core.model.customer.Customer) PersistableCustomer(com.salesmanager.shop.model.customer.PersistableCustomer) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException)

Example 17 with ConversionRuntimeException

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);
    }
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) ReadableProductPopulator(com.salesmanager.shop.populator.catalog.ReadableProductPopulator) ReadableProduct(com.salesmanager.shop.model.catalog.product.ReadableProduct) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException)

Example 18 with ConversionRuntimeException

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);
    }
}
Also used : ExpeditionConfiguration(com.salesmanager.shop.model.shipping.ExpeditionConfiguration) ShippingOrigin(com.salesmanager.core.model.shipping.ShippingOrigin) ShippingType(com.salesmanager.core.model.shipping.ShippingType) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Zone(com.salesmanager.core.model.reference.zone.Zone) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) ServiceException(com.salesmanager.core.business.exception.ServiceException) ZoneService(com.salesmanager.core.business.services.reference.zone.ZoneService) Language(com.salesmanager.core.model.reference.language.Language) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException) ShippingOriginService(com.salesmanager.core.business.services.shipping.ShippingOriginService) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Service(org.springframework.stereotype.Service) ReadableCountryPopulator(com.salesmanager.shop.populator.references.ReadableCountryPopulator) ShippingService(com.salesmanager.core.business.services.shipping.ShippingService) ReadableCountry(com.salesmanager.shop.model.references.ReadableCountry) OperationNotAllowedException(com.salesmanager.shop.store.api.exception.OperationNotAllowedException) CountryService(com.salesmanager.core.business.services.reference.country.CountryService) Validate(org.jsoup.helper.Validate) Logger(org.slf4j.Logger) Country(com.salesmanager.core.model.reference.country.Country) Collectors(java.util.stream.Collectors) List(java.util.List) ShippingPackageType(com.salesmanager.core.model.shipping.ShippingPackageType) PackageDetails(com.salesmanager.core.model.shipping.PackageDetails) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ConversionException(com.salesmanager.core.business.exception.ConversionException) PersistableAddress(com.salesmanager.shop.model.references.PersistableAddress) ReadableAddress(com.salesmanager.shop.model.references.ReadableAddress) ShippingConfiguration(com.salesmanager.core.model.shipping.ShippingConfiguration) Comparator(java.util.Comparator) ConversionException(com.salesmanager.core.business.exception.ConversionException) ArrayList(java.util.ArrayList) ReadableCountry(com.salesmanager.shop.model.references.ReadableCountry) Country(com.salesmanager.core.model.reference.country.Country) ReadableCountry(com.salesmanager.shop.model.references.ReadableCountry) ServiceException(com.salesmanager.core.business.exception.ServiceException) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) OperationNotAllowedException(com.salesmanager.shop.store.api.exception.OperationNotAllowedException) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ConversionException(com.salesmanager.core.business.exception.ConversionException) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException)

Example 19 with ConversionRuntimeException

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;
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) ReadableProductPopulator(com.salesmanager.shop.populator.catalog.ReadableProductPopulator) PersistableProduct(com.salesmanager.shop.model.catalog.product.PersistableProduct) ReadableProduct(com.salesmanager.shop.model.catalog.product.ReadableProduct) Product(com.salesmanager.core.model.catalog.product.Product) LightPersistableProduct(com.salesmanager.shop.model.catalog.product.LightPersistableProduct) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ReadableProduct(com.salesmanager.shop.model.catalog.product.ReadableProduct) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException)

Example 20 with ConversionRuntimeException

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;
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) ReadableProductPopulator(com.salesmanager.shop.populator.catalog.ReadableProductPopulator) PersistableProduct(com.salesmanager.shop.model.catalog.product.PersistableProduct) ReadableProduct(com.salesmanager.shop.model.catalog.product.ReadableProduct) Product(com.salesmanager.core.model.catalog.product.Product) ReadableProduct(com.salesmanager.shop.model.catalog.product.ReadableProduct) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException)

Aggregations

ConversionRuntimeException (com.salesmanager.shop.store.api.exception.ConversionRuntimeException)29 ConversionException (com.salesmanager.core.business.exception.ConversionException)17 ArrayList (java.util.ArrayList)9 ServiceException (com.salesmanager.core.business.exception.ServiceException)8 Product (com.salesmanager.core.model.catalog.product.Product)7 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)7 Language (com.salesmanager.core.model.reference.language.Language)7 Category (com.salesmanager.core.model.catalog.category.Category)6 ProductDescription (com.salesmanager.core.model.catalog.product.description.ProductDescription)6 ProductAvailability (com.salesmanager.core.model.catalog.product.availability.ProductAvailability)5 ProductImage (com.salesmanager.core.model.catalog.product.image.ProductImage)5 ReadableCategory (com.salesmanager.shop.model.catalog.category.ReadableCategory)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 CollectionUtils (org.apache.commons.collections4.CollectionUtils)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 ProductOptionValue (com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue)4 FinalPrice (com.salesmanager.core.model.catalog.product.price.FinalPrice)4 Mapper (com.salesmanager.shop.mapper.Mapper)4 ProductSpecification (com.salesmanager.shop.model.catalog.product.ProductSpecification)4