use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class PaymentConfigurationFacadeImpl method configuration.
@Override
public ReadableConfiguration configuration(String module, MerchantStore store) {
try {
ReadableConfiguration config = null;
List<PaymentMethod> methods = paymentService.getAcceptedPaymentMethods(store);
Optional<ReadableConfiguration> configuration = methods.stream().filter(m -> module.equals(m.getModule().getCode())).map(m -> this.configuration(m.getInformations(), store)).findFirst();
if (configuration.isPresent()) {
config = configuration.get();
}
return config;
} catch (ServiceException e) {
throw new ServiceRuntimeException("Error while getting payment configuration [" + module + "]", e);
}
}
use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class PaymentConfigurationFacadeImpl method configurations.
@Override
public List<ReadableConfiguration> configurations(MerchantStore store) {
try {
List<PaymentMethod> methods = paymentService.getAcceptedPaymentMethods(store);
List<ReadableConfiguration> configurations = methods.stream().map(m -> configuration(m.getInformations(), store)).collect(Collectors.toList());
return configurations;
} catch (ServiceException e) {
throw new ServiceRuntimeException("Error while getting payment configurations", e);
}
}
use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class ProductCommonFacadeImpl method deleteProduct.
@Override
public void deleteProduct(Long id, MerchantStore store) {
Validate.notNull(id, "Product id cannot be null");
Validate.notNull(store, "store cannot be null");
Product p = productService.getById(id);
if (p == null) {
throw new ResourceNotFoundException("Product with id [" + id + " not found");
}
if (p.getMerchantStore().getId().intValue() != store.getId().intValue()) {
throw new ResourceNotFoundException("Product with id [" + id + " not found for store [" + store.getCode() + "]");
}
try {
productService.delete(p);
} catch (ServiceException e) {
throw new ServiceRuntimeException("Error while deleting ptoduct with id [" + id + "]", e);
}
}
use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class UserFacadeImpl method delete.
@Override
public void delete(Long id, String merchant) {
Validate.notNull(id, "User id cannot be null");
try {
User user = userService.findByStore(id, merchant);
if (user == null) {
throw new ServiceRuntimeException("Cannot find user [" + id + "]");
}
// cannot delete superadmin
if (user.getGroups().contains(Constants.GROUP_SUPERADMIN)) {
throw new ServiceRuntimeException("Cannot delete superadmin user [" + id + "]");
}
userService.delete(user);
} catch (ServiceException e) {
throw new ServiceRuntimeException("Cannot find user [" + id + "]", e);
}
}
use of com.salesmanager.core.business.exception.ServiceException in project shopizer by shopizer-ecommerce.
the class UserFacadeImpl method updateEnabled.
@Override
public void updateEnabled(MerchantStore store, PersistableUser user) {
Validate.notNull(user, "User cannot be null");
Validate.notNull(store, "MerchantStore cannot be null");
Validate.notNull(user.getId(), "User.id cannot be null");
try {
User modelUser = userService.findByStore(user.getId(), store.getCode());
if (modelUser == null) {
throw new ResourceNotFoundException("User with id [" + user.getId() + "] not found for store [" + store.getCode() + "]");
}
modelUser.setActive(user.isActive());
userService.saveOrUpdate(modelUser);
} catch (ServiceException e) {
throw new ServiceRuntimeException("Error while updating user enable flag", e);
}
}
Aggregations