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%2Fconsumer%2FConsumerController.java;h=ff045223a658af46e2cb65d0c0d482425bff9c81;hb=af40dc43f26d3fea66ac04625080314162e93496;hp=e167eb859174f02d852c9690a576c0e922280ea7;hpb=17041db5ec17da3beb56b962e7a2cca79ca6ff59;p=nonrtric.git diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java index e167eb85..ff045223 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java @@ -252,10 +252,14 @@ public class ConsumerController { try { EiType eiType = this.eiTypes.getType(eiTypeId); validateJobData(eiType.getJobDataSchema(), eiJobInfo.jobData); - final boolean newJob = this.eiJobs.get(eiJobId) == null; - EiJob eiJob = toEiJob(eiJobInfo, eiJobId, eiType); - this.eiJobs.put(eiJob); - this.producerCallbacks.notifyProducersJobCreated(eiJob); + EiJob existingEiJob = this.eiJobs.get(eiJobId); + final boolean newJob = existingEiJob == null; + if (existingEiJob != null && !existingEiJob.type().getId().equals(eiTypeId)) { + return ErrorResponse.create("Not allowed to change type for existing EI job", HttpStatus.CONFLICT); + } + EiJob newEiJob = toEiJob(eiJobInfo, eiJobId, eiType); + this.eiJobs.put(newEiJob); + this.producerCallbacks.notifyProducersJobCreated(newEiJob); return new ResponseEntity<>(newJob ? HttpStatus.CREATED : HttpStatus.OK); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND);