2 * Copyright (c) 2018 Orange
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5 * the License. You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11 * specific language governing permissions and limitations under the License.
13 package org.onap.nbi.apis.hub.service;
15 import javax.validation.Valid;
16 import org.onap.nbi.apis.hub.model.Event;
17 import org.onap.nbi.apis.hub.model.Subscriber;
18 import org.onap.nbi.exceptions.BackendFunctionalException;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.scheduling.annotation.Async;
23 import org.springframework.stereotype.Service;
24 import org.springframework.web.client.RestTemplate;
27 public class NotifierService {
29 private final Logger logger = LoggerFactory.getLogger(NotifierService.class);
32 RestTemplate restTemplate;
35 public void run(Subscriber subscriber, @Valid Event event) {
37 restTemplate.postForEntity(subscriber.getCallback(), event, Object.class);
38 } catch (BackendFunctionalException e) {
39 logger.error(" unable to post event to {} , receive {}, {}", subscriber.getCallback(), e.getHttpStatus(),