X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=enrichment-coordinator-service%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fenrichment%2Fcontrollers%2Fproducer%2FProducerController.java;h=9bfa2d20b79d375ce14066e6c4abdaa317a61611;hb=530fa60a49e8f870cea442a338b148783fbe2ab7;hp=d67b8ed4e52fa84125a7aad2aba601453c7f634d;hpb=77e580513eeb2d27f8040588dc1363b94f4afa0d;p=nonrtric.git diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java index d67b8ed4..9bfa2d20 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java @@ -33,10 +33,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.oransc.enrichment.clients.ProducerCallbacks; -import org.oransc.enrichment.clients.ProducerJobInfo; import org.oransc.enrichment.controllers.ErrorResponse; import org.oransc.enrichment.controllers.VoidResponse; +import org.oransc.enrichment.controllers.consumer.ConsumerCallbacks; import org.oransc.enrichment.controllers.producer.ProducerRegistrationInfo.ProducerEiTypeRegistrationInfo; import org.oransc.enrichment.repository.EiJob; import org.oransc.enrichment.repository.EiJobs; @@ -64,9 +63,7 @@ public class ProducerController { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // + private static Gson gson = new GsonBuilder().create(); @Autowired private EiJobs eiJobs; @@ -80,6 +77,9 @@ public class ProducerController { @Autowired ProducerCallbacks producerCallbacks; + @Autowired + ConsumerCallbacks consumerCallbacks; + @GetMapping(path = ProducerConsts.API_ROOT + "/eitypes", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "EI type identifiers", notes = "") @ApiResponses( @@ -101,7 +101,7 @@ public class ProducerController { } @GetMapping(path = ProducerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Individual EI Type", notes = "") + @ApiOperation(value = "Individual EI type", notes = "") @ApiResponses( value = { // @ApiResponse(code = 200, message = "EI type", response = ProducerEiTypeInfo.class), // @@ -146,7 +146,7 @@ public class ProducerController { @ApiOperation(value = "Individual EI producer", notes = "") @ApiResponses( value = { // - @ApiResponse(code = 200, message = "EI Jobs", response = ProducerRegistrationInfo.class), // + @ApiResponse(code = 200, message = "EI jobs", response = ProducerRegistrationInfo.class), // @ApiResponse( code = 404, message = "Enrichment Information producer is not found", @@ -216,6 +216,7 @@ public class ProducerController { ProducerStatusInfo.OperationalState opState = producer.isAvailable() ? ProducerStatusInfo.OperationalState.ENABLED : ProducerStatusInfo.OperationalState.DISABLED; + this.logger.debug("opState {}", opState); return new ProducerStatusInfo(opState); } @@ -253,7 +254,7 @@ public class ProducerController { private void purgeTypes(Collection types) { for (EiType type : types) { if (type.getProducerIds().isEmpty()) { - this.eiTypes.deregisterType(type, this.eiJobs); + this.eiTypes.remove(type); } } } @@ -271,6 +272,7 @@ public class ProducerController { try { final EiProducer producer = this.eiProducers.getProducer(eiProducerId); this.eiProducers.deregisterProducer(producer, this.eiTypes, this.eiJobs); + this.consumerCallbacks.notifyConsumersProducerDeleted(producer); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); @@ -282,6 +284,7 @@ public class ProducerController { if (type == null) { type = new EiType(typeInfo.eiTypeId, typeInfo.jobDataSchema); this.eiTypes.put(type); + this.consumerCallbacks.notifyConsumersTypeAdded(type); } return type; }