use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class ShippingConfigurationApi method shippingModule.
/**
* Get merchant shipping module details
*
* @param code
* @param merchantStore
* @param language
* @return
*/
@GetMapping("/private/modules/shipping/{code}")
@ApiOperation(httpMethod = "GET", value = "Shipping module by code", produces = "application/json", response = List.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "string", defaultValue = "DEFAULT") })
public IntegrationConfiguration shippingModule(@PathVariable String code, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
try {
// configured modules
List<IntegrationModule> modules = shippingService.getShippingMethods(merchantStore);
// check if exist
Optional<IntegrationModule> checkIfExist = modules.stream().filter(m -> m.getCode().equals(code)).findAny();
if (!checkIfExist.isPresent()) {
throw new ResourceNotFoundException("Shipping module [" + code + "] not found");
}
IntegrationConfiguration config = shippingService.getShippingConfiguration(code, merchantStore);
if (config == null) {
config = new IntegrationConfiguration();
}
/**
* Build return object for now this is a read copy
*/
config.setActive(config.isActive());
config.setDefaultSelected(config.isDefaultSelected());
config.setIntegrationKeys(config.getIntegrationKeys());
config.setIntegrationOptions(config.getIntegrationOptions());
return config;
} catch (ServiceException e) {
LOGGER.error("Error getting shipping module [" + code + "]", e);
throw new ServiceRuntimeException("Error getting shipping module [" + code + "]", e);
}
}
use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class CatalogApi method addCatalogEntry.
@PostMapping(value = "/private/catalog/{id}")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(httpMethod = "POST", value = "Add catalog entry to catalog", notes = "", response = ReadableCatalogCategoryEntry.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public ReadableCatalogCategoryEntry addCatalogEntry(@PathVariable Long id, @RequestBody @Valid PersistableCatalogCategoryEntry catalogEntry, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
ReadableCatalog c = catalogFacade.getCatalog(id, merchantStore, language);
if (c == null) {
throw new ResourceNotFoundException("Catalog id [" + id + "] not found");
}
catalogEntry.setCatalog(c.getCode());
return catalogFacade.addCatalogEntry(catalogEntry, merchantStore, language);
}
use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method updateOrderCustomre.
@Override
public void updateOrderCustomre(Long orderId, PersistableCustomer customer, MerchantStore store) {
try {
// get order by order id
Order modelOrder = orderService.getOrder(orderId, store);
if (modelOrder == null) {
throw new ResourceNotFoundException("Order id [" + orderId + "] not found for store [" + store.getCode() + "]");
}
// set customer information
modelOrder.setCustomerEmailAddress(customer.getEmailAddress());
modelOrder.setBilling(this.convertBilling(customer.getBilling()));
modelOrder.setDelivery(this.convertDelivery(customer.getDelivery()));
orderService.saveOrUpdate(modelOrder);
} catch (Exception e) {
throw new ServiceRuntimeException("An error occured while updating order customer", e);
}
}
use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method listTransactions.
@Override
public List<ReadableTransaction> listTransactions(Long orderId, MerchantStore store) {
Validate.notNull(orderId, "orderId must not be null");
Validate.notNull(store, "MerchantStore must not be null");
List<ReadableTransaction> trx = new ArrayList<ReadableTransaction>();
try {
Order modelOrder = orderService.getOrder(orderId, store);
if (modelOrder == null) {
throw new ResourceNotFoundException("Order id [" + orderId + "] not found for store [" + store.getCode() + "]");
}
List<Transaction> transactions = transactionService.listTransactions(modelOrder);
ReadableTransaction transaction = null;
ReadableTransactionPopulator trxPopulator = null;
for (Transaction tr : transactions) {
transaction = new ReadableTransaction();
trxPopulator = new ReadableTransactionPopulator();
trxPopulator.setOrderService(orderService);
trxPopulator.setPricingService(pricingService);
trxPopulator.populate(tr, transaction, store, store.getDefaultLanguage());
trx.add(transaction);
}
return trx;
} catch (Exception e) {
LOGGER.error("Error while getting transactions for order [" + orderId + "] and store code [" + store.getCode() + "]");
throw new ServiceRuntimeException("Error while getting transactions for order [" + orderId + "] and store code [" + store.getCode() + "]");
}
}
use of com.salesmanager.shop.store.api.exception.ResourceNotFoundException in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method nextTransaction.
@Override
public TransactionType nextTransaction(Long orderId, MerchantStore store) {
try {
Order modelOrder = orderService.getOrder(orderId, store);
if (modelOrder == null) {
throw new ResourceNotFoundException("Order id [" + orderId + "] not found for store [" + store.getCode() + "]");
}
Transaction last = transactionService.lastTransaction(modelOrder, store);
if (last.getTransactionType().name().equals(TransactionType.AUTHORIZE.name())) {
return TransactionType.CAPTURE;
} else if (last.getTransactionType().name().equals(TransactionType.AUTHORIZECAPTURE.name())) {
return TransactionType.REFUND;
} else if (last.getTransactionType().name().equals(TransactionType.CAPTURE.name())) {
return TransactionType.REFUND;
} else if (last.getTransactionType().name().equals(TransactionType.REFUND.name())) {
return TransactionType.OK;
} else {
return TransactionType.OK;
}
} catch (Exception e) {
throw new ServiceRuntimeException("Error while getting last transaction for order [" + orderId + "]", e);
}
}
Aggregations