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%2Fr1consumer%2FConsumerController.java;h=e93d9cbdfa29f4f388c3b479188cf0928c9f1d3a;hb=2a88005a4b62628df36c8c187b435c2dda89828e;hp=7a1bf184a267107c894f084e9d04c749e65804dd;hpb=6c468636c3790e3420da97dab19057892988fa11;p=nonrtric.git diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerController.java index 7a1bf184..e93d9cbd 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/r1consumer/ConsumerController.java @@ -262,7 +262,7 @@ public class ConsumerController { path = "/info-jobs/{infoJobId}", // produces = MediaType.APPLICATION_JSON_VALUE, // consumes = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = ConsumerConsts.INDIVIDUAL_JOB) + @Operation(summary = ConsumerConsts.INDIVIDUAL_JOB, description = ConsumerConsts.PUT_INDIVIDUAL_JOB_DESCRIPTION) @ApiResponses( value = { // @ApiResponse( @@ -280,11 +280,19 @@ public class ConsumerController { }) public Mono> putIndividualInfoJob( // @PathVariable("infoJobId") String jobId, // + @Parameter( + name = ConsumerConsts.PERFORM_TYPE_CHECK_PARAM, + required = false, // + description = ConsumerConsts.PERFORM_TYPE_CHECK_PARAM_DESCRIPTION) // + @RequestParam( + name = ConsumerConsts.PERFORM_TYPE_CHECK_PARAM, + required = false, + defaultValue = "false") boolean performTypeCheck, @RequestBody ConsumerJobInfo informationJobObject) { final boolean isNewJob = this.jobs.get(jobId) == null; - return validatePutInfoJob(jobId, informationJobObject) // + return validatePutInfoJob(jobId, informationJobObject, performTypeCheck) // .flatMap(this::startInfoSubscriptionJob) // .doOnNext(newEiJob -> this.jobs.put(newEiJob)) // .flatMap(newEiJob -> Mono.just(new ResponseEntity<>(isNewJob ? HttpStatus.CREATED : HttpStatus.OK))) @@ -298,16 +306,18 @@ public class ConsumerController { .flatMap(noOfAcceptingProducers -> Mono.just(newInfoJob)); } - private Mono validatePutInfoJob(String jobId, ConsumerJobInfo jobInfo) { + private Mono validatePutInfoJob(String jobId, ConsumerJobInfo jobInfo, boolean performTypeCheck) { try { - EiType infoType = this.infoTypes.getType(jobInfo.infoTypeId); - validateJsonObjectAgainstSchema(infoType.getJobDataSchema(), jobInfo.jobDefinition); + if (performTypeCheck) { + EiType infoType = this.infoTypes.getType(jobInfo.infoTypeId); + validateJsonObjectAgainstSchema(infoType.getJobDataSchema(), jobInfo.jobDefinition); + } EiJob existingEiJob = this.jobs.get(jobId); if (existingEiJob != null && !existingEiJob.getTypeId().equals(jobInfo.infoTypeId)) { throw new ServiceException("Not allowed to change type for existing job", HttpStatus.CONFLICT); } - return Mono.just(toEiJob(jobInfo, jobId, infoType)); + return Mono.just(toEiJob(jobInfo, jobId, jobInfo.infoTypeId)); } catch (Exception e) { return Mono.error(e); } @@ -331,10 +341,10 @@ public class ConsumerController { } } - private EiJob toEiJob(ConsumerJobInfo info, String id, EiType type) { + private EiJob toEiJob(ConsumerJobInfo info, String id, String typeId) { return EiJob.builder() // .id(id) // - .typeId(type.getId()) // + .typeId(typeId) // .owner(info.owner) // .jobData(info.jobDefinition) // .targetUrl(info.jobResultUri) // @@ -342,6 +352,10 @@ public class ConsumerController { .build(); } + private EiJob toEiJob(ConsumerJobInfo info, String id, EiType type) { + return toEiJob(info, id, type.getId()); + } + private ConsumerInfoTypeInfo toInfoTypeInfo(EiType type) { return new ConsumerInfoTypeInfo(type.getJobDataSchema()); }