use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class ProductOptionSetFacadeImpl method create.
@Override
public void create(PersistableProductOptionSet optionSet, MerchantStore store, Language language) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(language, "Language cannot be null");
Validate.notNull(optionSet, "PersistableProductOptionSet cannot be null");
if (this.exists(optionSet.getCode(), store)) {
throw new OperationNotAllowedException("Option set with code [" + optionSet.getCode() + "] already exist");
}
ProductOptionSet opt = persistableProductOptionSetMapper.convert(optionSet, store, language);
try {
opt.setStore(store);
productOptionSetService.create(opt);
} catch (ServiceException e) {
throw new ServiceRuntimeException("Exception while creating ProductOptionSet", e);
}
}
use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class ProductOptionSetFacadeImpl method list.
@Override
public List<ReadableProductOptionSet> list(MerchantStore store, Language language) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(language, "Language cannot be null");
try {
List<ProductOptionSet> optionSets = productOptionSetService.listByStore(store, language);
return optionSets.stream().map(opt -> this.convert(opt, store, language)).collect(Collectors.toList());
} catch (ServiceException e) {
throw new ServiceRuntimeException("Exception while listing ProductOptionSet", e);
}
}
use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class ProductOptionSetFacadeImpl method update.
@Override
public void update(Long id, PersistableProductOptionSet optionSet, MerchantStore store, Language language) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(language, "Language cannot be null");
Validate.notNull(optionSet, "PersistableProductOptionSet cannot be null");
ProductOptionSet opt = productOptionSetService.getById(store, id, language);
if (opt == null) {
throw new ResourceNotFoundException("ProductOptionSet not found for id [" + id + "] and store [" + store.getCode() + "]");
}
optionSet.setId(id);
optionSet.setCode(opt.getCode());
ProductOptionSet model = persistableProductOptionSetMapper.convert(optionSet, store, language);
try {
model.setStore(store);
productOptionSetService.save(model);
} catch (ServiceException e) {
throw new ServiceRuntimeException("Exception while creating ProductOptionSet", e);
}
}
use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class ProductTypeFacadeImpl method get.
@Override
public ReadableProductType get(MerchantStore store, String code, Language language) {
ProductType t;
try {
t = productTypeService.getByCode(code, store, language);
} catch (ServiceException e) {
throw new RuntimeException("An exception occured while getting product type [" + code + "] for merchant store [" + store.getCode() + "]", e);
}
if (t == null) {
throw new ResourceNotFoundException("Product type [" + code + "] not found for merchant [" + store.getCode() + "]");
}
ReadableProductType readableType = readableProductTypeMapper.convert(t, store, language);
return readableType;
}
use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class ProductVariationFacadeImpl method delete.
@Override
public void delete(Long variationId, MerchantStore store) {
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(variationId, "variationId cannot be null");
ProductVariation opt = productVariationService.getById(variationId);
if (opt == null) {
throw new ResourceNotFoundException("ProductVariation not found for id [" + variationId + "] and store [" + store.getCode() + "]");
}
if (!opt.getMerchantStore().getCode().equals(store.getCode())) {
throw new ResourceNotFoundException("ProductVariation not found for id [" + variationId + "] and store [" + store.getCode() + "]");
}
try {
productVariationService.delete(opt);
} catch (ServiceException e) {
throw new ServiceRuntimeException("Exception while deleting ProductVariation", e);
}
}
Aggregations