use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method verifyCustomerLink.
private Customer verifyCustomerLink(String token, String store) {
Customer customer = null;
try {
customer = customerService.getByPasswordResetToken(store, token);
if (customer == null) {
throw new ResourceNotFoundException("Customer not fount for store [" + store + "] and token [" + token + "]");
}
} catch (Exception e) {
throw new ServiceRuntimeException("Cannot verify customer token", e);
}
Date tokenExpiry = customer.getCredentialsResetRequest().getCredentialsRequestExpiry();
if (tokenExpiry == null) {
throw new GenericRuntimeException("No expiry date configured for token [" + token + "]");
}
if (!DateUtil.dateBeforeEqualsDate(new Date(), tokenExpiry)) {
throw new GenericRuntimeException("Ttoken [" + token + "] has expired");
}
return customer;
}
use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class ManufacturerFacadeImpl method getManufacturer.
@Override
public ReadableManufacturer getManufacturer(Long id, MerchantStore store, Language language) throws Exception {
Manufacturer manufacturer = manufacturerService.getById(id);
if (manufacturer == null) {
throw new ResourceNotFoundException("Manufacturer [" + id + "] not found");
}
if (manufacturer.getMerchantStore().getId() != store.getId()) {
throw new ResourceNotFoundException("Manufacturer [" + id + "] not found for store [" + store.getId() + "]");
}
ReadableManufacturer readableManufacturer = new ReadableManufacturer();
ReadableManufacturerPopulator populator = new ReadableManufacturerPopulator();
readableManufacturer = populator.populate(manufacturer, readableManufacturer, store, language);
return readableManufacturer;
}
use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class ManufacturerFacadeImpl method saveOrUpdateManufacturer.
@Override
public void saveOrUpdateManufacturer(PersistableManufacturer manufacturer, MerchantStore store, Language language) throws Exception {
PersistableManufacturerPopulator populator = new PersistableManufacturerPopulator();
populator.setLanguageService(languageService);
Manufacturer manuf = new Manufacturer();
if (manufacturer.getId() != null && manufacturer.getId().longValue() > 0) {
manuf = manufacturerService.getById(manufacturer.getId());
if (manuf == null) {
throw new ResourceNotFoundException("Manufacturer with id [" + manufacturer.getId() + "] not found");
}
if (manuf.getMerchantStore().getId().intValue() != store.getId().intValue()) {
throw new ResourceNotFoundException("Manufacturer with id [" + manufacturer.getId() + "] not found for store [" + store.getId() + "]");
}
}
populator.populate(manufacturer, manuf, store, language);
manufacturerService.saveOrUpdate(manuf);
manufacturer.setId(manuf.getId());
}
use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class ShoppingCartFacadeImpl method get.
// facade
@Override
public ReadableShoppingCart get(Optional<String> cart, Long customerId, MerchantStore store, Language language) {
Validate.notNull(customerId, "Customer id cannot be null");
Validate.notNull(store, "MerchantStore cannot be null");
try {
// lookup customer
Customer customer = customerService.getById(customerId);
if (customer == null) {
throw new ResourceNotFoundException("No Customer found for id [" + customerId + "]");
}
ShoppingCart cartModel = shoppingCartService.getShoppingCart(customer);
if (cart.isPresent()) {
cartModel = customerFacade.mergeCart(customer, cart.get(), store, language);
}
if (cartModel == null) {
return null;
}
ReadableShoppingCart readableCart = shoppingCartFacade.readableCart(cartModel, store, language);
return readableCart;
} catch (Exception e) {
throw new ServiceRuntimeException(e);
}
}
use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class TaxFacadeImpl method deleteTaxClass.
@Override
public void deleteTaxClass(Long id, MerchantStore store, Language language) {
Validate.notNull(id, "TaxClass id cannot be null");
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(store.getCode(), "MerchantStore code cannot be null");
try {
TaxClass model = taxClassService.getById(id);
if (model == null) {
throw new ResourceNotFoundException("TaxClass not found [" + id + "] for store [" + store.getCode() + "]");
} else {
if (!model.getMerchantStore().getCode().equals(store.getCode())) {
throw new UnauthorizedException("MerchantStore [" + store.getCode() + "] cannot delete tax class [" + id + "]");
}
}
taxClassService.delete(model);
} catch (ServiceException e) {
LOGGER.error("Error while getting taxClasse [" + id + "] for store [" + store.getCode() + "]", e);
throw new ServiceRuntimeException("Error while getting taxClasse [" + id + "] for store [" + store.getCode() + "]", e);
}
}
Aggregations