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%2Fa1e%2FA1eController.java;h=8c056fc673da87d1c5a07f731dcc4dd2f67c5ade;hb=d0c7f9207203ce9a502fc15c09f9938eebfd44f7;hp=5f796b8d2b740db154f2ca54cf94df247f18f270;hpb=02a72fd14966d3a7f26e6ef93f1a045607348f14;p=nonrtric.git diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eController.java index 5f796b8d..8c056fc6 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/a1e/A1eController.java @@ -277,8 +277,18 @@ public class A1eController { @ApiResponse( responseCode = "404", description = "Enrichment Information type is not found", // - content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) // + content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))), + @ApiResponse( + responseCode = "400", + description = "Input validation failed", // + content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))), // + @ApiResponse( + responseCode = "409", + description = "Cannot modify job type", // + content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) + }) + public Mono> putIndividualEiJob( // @PathVariable("eiJobId") String eiJobId, // @RequestBody A1eEiJobInfo eiJobObject) { @@ -288,15 +298,15 @@ public class A1eController { return validatePutEiJob(eiJobId, eiJobObject) // .flatMap(this::startEiJob) // .doOnNext(newEiJob -> this.eiJobs.put(newEiJob)) // - .flatMap(newEiJob -> Mono.just(new ResponseEntity<>(isNewJob ? HttpStatus.CREATED : HttpStatus.OK))) - .onErrorResume(throwable -> Mono.just(ErrorResponse.create(throwable, HttpStatus.NOT_FOUND))); + .map(newEiJob -> new ResponseEntity<>(isNewJob ? HttpStatus.CREATED : HttpStatus.OK)) // + .onErrorResume(throwable -> Mono.just(ErrorResponse.create(throwable, HttpStatus.INTERNAL_SERVER_ERROR))); } private Mono startEiJob(InfoJob newEiJob) { return this.producerCallbacks.startInfoSubscriptionJob(newEiJob, infoProducers) // .doOnNext(noOfAcceptingProducers -> this.logger.debug( "Started EI job {}, number of activated producers: {}", newEiJob.getId(), noOfAcceptingProducers)) // - .flatMap(noOfAcceptingProducers -> Mono.just(newEiJob)); + .map(noOfAcceptingProducers -> newEiJob); } private Mono validatePutEiJob(String eiJobId, A1eEiJobInfo eiJobInfo) { @@ -320,7 +330,7 @@ public class A1eController { if (url != null && !url.isEmpty()) { URI uri = new URI(url); if (!uri.isAbsolute()) { - throw new ServiceException("URI: " + url + " is not absolute", HttpStatus.CONFLICT); + throw new ServiceException("URI: " + url + " is not absolute", HttpStatus.BAD_REQUEST); } } } @@ -338,7 +348,7 @@ public class A1eController { JSONObject json = new JSONObject(objectAsString); schema.validate(json); } catch (Exception e) { - throw new ServiceException("Json validation failure " + e.toString(), HttpStatus.CONFLICT); + throw new ServiceException("Json validation failure " + e.toString(), HttpStatus.BAD_REQUEST); } } }