2 * Copyright (c) 2018 Orange
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with 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
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 * or implied. See the License for the specific language governing permissions and limitations under
14 package org.onap.nbi.apis.hub.service;
16 import javax.validation.Valid;
17 import org.onap.nbi.apis.hub.model.Event;
18 import org.onap.nbi.apis.hub.model.Subscriber;
19 import org.onap.nbi.exceptions.BackendFunctionalException;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.scheduling.annotation.Async;
24 import org.springframework.stereotype.Service;
25 import org.springframework.web.client.RestTemplate;
28 public class NotifierService {
30 private final Logger logger = LoggerFactory.getLogger(NotifierService.class);
33 RestTemplate restTemplate;
36 public void run(Subscriber subscriber, @Valid Event event) {
38 restTemplate.postForEntity(subscriber.getCallback(), event, Object.class);
39 } catch (BackendFunctionalException e) {
40 logger.error(" unable to post event to {} , receive {}, {}", subscriber.getCallback(),
41 e.getHttpStatus(), e.getBodyResponse());