Search in sources :

Example 1 with CustomerEntityPopulator

use of com.salesmanager.shop.populator.customer.CustomerEntityPopulator 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;
}
Also used : ConversionException(com.salesmanager.core.business.exception.ConversionException) ReadableCustomer(com.salesmanager.shop.model.customer.ReadableCustomer) Customer(com.salesmanager.core.model.customer.Customer) PersistableCustomer(com.salesmanager.shop.model.customer.PersistableCustomer) CustomerEntityPopulator(com.salesmanager.shop.populator.customer.CustomerEntityPopulator) ServiceException(com.salesmanager.core.business.exception.ServiceException) UserAlreadyExistException(com.salesmanager.shop.model.customer.UserAlreadyExistException) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ConversionException(com.salesmanager.core.business.exception.ConversionException)

Aggregations

ConversionException (com.salesmanager.core.business.exception.ConversionException)1 ServiceException (com.salesmanager.core.business.exception.ServiceException)1 Customer (com.salesmanager.core.model.customer.Customer)1 PersistableCustomer (com.salesmanager.shop.model.customer.PersistableCustomer)1 ReadableCustomer (com.salesmanager.shop.model.customer.ReadableCustomer)1 UserAlreadyExistException (com.salesmanager.shop.model.customer.UserAlreadyExistException)1 CustomerEntityPopulator (com.salesmanager.shop.populator.customer.CustomerEntityPopulator)1 ConversionRuntimeException (com.salesmanager.shop.store.api.exception.ConversionRuntimeException)1 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)1 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)1