Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Fix trigger not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
svenpopping committed Dec 9, 2017
1 parent af590d2 commit b8d8976
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class EventsSyncRestController {
/**
* Constructor ProductService.
*
* @param productService of type ProductService
* @param productService of type ProductService
* @param eventsSyncProductService of type EventsSyncProductService
*/
public EventsSyncRestController(ProductService productService, EventsSyncProductService eventsSyncProductService) {
Expand All @@ -57,15 +57,17 @@ public ResponseEntity<?> eventSync(HttpServletRequest request, @RequestBody Prod
return createResponseEntity(HttpStatus.UNAUTHORIZED, "User is not authorized", null);
}

switch (valueOf(productEventsSync.getTrigger())) {
case PRODUCT_CREATE_EDIT:
this.createOrUpdate(productEventsSync);
break;
case PRODUCT_DELETE:
eventsSyncProductService.deleteProduct(productEventsSync);
break;
default:
return createResponseEntity(HttpStatus.BAD_REQUEST, "Events trigger not supported!", null);
try {
switch (valueOf(productEventsSync.getTrigger())) {
case PRODUCT_CREATE_EDIT:
this.createOrUpdate(productEventsSync);
break;
case PRODUCT_DELETE:
eventsSyncProductService.deleteProduct(productEventsSync);
break;
}
} catch (IllegalArgumentException e) {
return createResponseEntity(HttpStatus.BAD_REQUEST, "Events trigger not supported!", null);
}

return createResponseEntity(HttpStatus.OK, null, null);
Expand Down

0 comments on commit b8d8976

Please sign in to comment.