2  * ============LICENSE_START=======================================================
 
   3  * BBS-RELOCATION-CPE-AUTHENTICATION-HANDLER
 
   4  * ================================================================================
 
   5  * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.bbs.event.processor.tasks;
 
  23 import org.onap.bbs.event.processor.exceptions.AaiTaskException;
 
  24 import org.onap.bbs.event.processor.model.PnfAaiObject;
 
  25 import org.onap.bbs.event.processor.model.ServiceInstanceAaiObject;
 
  26 import org.onap.bbs.event.processor.utilities.AaiReactiveClient;
 
  27 import org.slf4j.Logger;
 
  28 import org.slf4j.LoggerFactory;
 
  29 import org.springframework.beans.factory.annotation.Autowired;
 
  30 import org.springframework.stereotype.Component;
 
  31 import org.springframework.util.StringUtils;
 
  33 import reactor.core.publisher.Mono;
 
  36 public class AaiClientTaskImpl implements AaiClientTask {
 
  38     private static final Logger LOGGER = LoggerFactory.getLogger(AaiClientTaskImpl.class);
 
  39     private final AaiReactiveClient reactiveClient;
 
  42     public AaiClientTaskImpl(AaiReactiveClient reactiveClient) {
 
  43         this.reactiveClient = reactiveClient;
 
  47     public Mono<PnfAaiObject> executePnfRetrieval(String taskName, String url) {
 
  48         if (StringUtils.isEmpty(url)) {
 
  49             throw new AaiTaskException("Cannot invoke an A&AI client task with an invalid URL");
 
  51         LOGGER.info("Executing task ({}) for retrieving PNF object", taskName);
 
  52         return resolveClient().getPnfObjectDataFor(url);
 
  56     public Mono<ServiceInstanceAaiObject> executeServiceInstanceRetrieval(String taskName, String url) {
 
  57         if (StringUtils.isEmpty(url)) {
 
  58             throw new AaiTaskException("Cannot invoke an A&AI client task with an invalid URL");
 
  60         LOGGER.info("Executing task ({}) for retrieving Service Instance object", taskName);
 
  61         return resolveClient().getServiceInstanceObjectDataFor(url);
 
  65     public AaiReactiveClient resolveClient() {
 
  66         return reactiveClient;