@Override public void execute() throws ResourceUnavailableException { CallContext.current().setEventDetails("Route Id: " + id); boolean result = _vpcService.revokeStaticRoute(id); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete static route"); } }
@Override public void execute() throws ResourceUnavailableException { boolean success = false; StaticRoute route = null; try { CallContext.current().setEventDetails("Static route Id: " + getEntityId()); success = _vpcService.applyStaticRoute(getEntityId()); // State is different after the route is applied, so retrieve the object only here route = _entityMgr.findById(StaticRoute.class, getEntityId()); StaticRouteResponse routeResponse = new StaticRouteResponse(); if (route != null) { routeResponse = _responseGenerator.createStaticRouteResponse(route); setResponseObject(routeResponse); } routeResponse.setResponseName(getCommandName()); } finally { if (!success || route == null) { _vpcService.revokeStaticRoute(getEntityId()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create static route"); } } }
@Override public void execute() throws ResourceUnavailableException { CallContext.current().setEventDetails("Route Id: " + id); final boolean result = _vpcService.revokeStaticRoute(id); if (result) { final SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete static route"); } }
@Override public void execute() throws ResourceUnavailableException { boolean success = false; StaticRoute route = null; try { CallContext.current().setEventDetails("Static route Id: " + getEntityId()); success = _vpcService.applyStaticRoute(getEntityId()); // State is different after the route is applied, so retrieve the object only here route = _entityMgr.findById(StaticRoute.class, getEntityId()); StaticRouteResponse routeResponse = new StaticRouteResponse(); if (route != null) { routeResponse = _responseGenerator.createStaticRouteResponse(route); setResponseObject(routeResponse); } routeResponse.setResponseName(getCommandName()); } finally { if (!success || route == null) { _vpcService.revokeStaticRoute(getEntityId()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create static route"); } } }