use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class ProductOptionFacadeImpl method removeOptionValueImage.
@Override
public void removeOptionValueImage(Long optionValueId, MerchantStore store, Language language) {
Validate.notNull(optionValueId, "OptionValueId must not be null");
ProductOptionValue value = productOptionValueService.getById(store, optionValueId);
if (value == null) {
throw new ResourceNotFoundException("Product option value [" + optionValueId + "] not found");
}
try {
contentService.removeFile(store.getCode(), FileContentType.PROPERTY, value.getProductOptionValueImage());
value.setProductOptionValueImage(null);
productOptionValueService.saveOrUpdate(value);
} catch (Exception e) {
throw new ServiceRuntimeException("Exception while removing option value image", e);
}
return;
}
use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class ProductOptionSetFacadeImpl method get.
@Override
public ReadableProductOptionSet get(Long id, MerchantStore store, Language language) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(language, "Language cannot be null");
ProductOptionSet optionSet = productOptionSetService.getById(store, id, language);
if (optionSet == null) {
throw new ResourceNotFoundException("ProductOptionSet not found for id [" + id + "] and store [" + store.getCode() + "]");
}
return readableProductOptionSetMapper.convert(optionSet, store, language);
}
use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class ProductOptionSetFacadeImpl method list.
@Override
public List<ReadableProductOptionSet> list(MerchantStore store, Language language, String type) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(language, "Language cannot be null");
Validate.notNull(type, "Product type cannot be null");
// find product type by id
ReadableProductType readable = productTypeFacade.get(store, type, language);
if (readable == null) {
throw new ResourceNotFoundException("Can't fing product type [" + type + "] fpr merchand [" + store.getCode() + "]");
}
List<ProductOptionSet> optionSets = productOptionSetService.getByProductType(readable.getId(), store, language);
return optionSets.stream().map(opt -> this.convert(opt, store, language)).collect(Collectors.toList());
}
use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class ProductTypeFacadeImpl method update.
@Override
public void update(PersistableProductType type, Long id, MerchantStore store, Language language) {
Validate.notNull(type, "ProductType cannot be null");
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(id, "id cannot be empty");
try {
ProductType t = productTypeService.getById(id, store, language);
if (t == null) {
throw new ResourceNotFoundException("Product type [" + type.getCode() + "] does not exist for store [" + store.getCode() + "]");
}
type.setId(t.getId());
type.setCode(t.getCode());
ProductType model = persistableProductTypeMapper.merge(type, t, store, language);
model.setMerchantStore(store);
productTypeService.saveOrUpdate(model);
} catch (Exception e) {
throw new ServiceRuntimeException("An exception occured while saving product type", e);
}
}
use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class ProductTypeFacadeImpl method get.
@Override
public ReadableProductType get(MerchantStore store, Long id, Language language) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(id, "ProductType code cannot be empty");
try {
ProductType type = null;
if (language == null) {
type = productTypeService.getById(id, store);
} else {
type = productTypeService.getById(id, store, language);
}
if (type == null) {
throw new ResourceNotFoundException("Product type [" + id + "] not found for store [" + store.getCode() + "]");
}
ReadableProductType readableType = readableProductTypeMapper.convert(type, store, language);
return readableType;
} catch (Exception e) {
throw new ServiceRuntimeException("An exception occured while getting product type [" + id + "] not found for store [" + store.getCode() + "]", e);
}
}
Aggregations