@ApiResponse(
responseCode = "404",
description = "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<ResponseEntity<Object>> putIndividualInfoJob( //
@PathVariable("infoJobId") String jobId, //
@Parameter(
return validatePutInfoJob(jobId, informationJobObject, performTypeCheck) //
.flatMap(this::startInfoSubscriptionJob) //
.doOnNext(this.infoJobs::put) //
- .flatMap(newEiJob -> Mono.just(new ResponseEntity<>(isNewJob ? HttpStatus.CREATED : HttpStatus.OK)))
+ .map(newEiJob -> new ResponseEntity<>(isNewJob ? HttpStatus.CREATED : HttpStatus.OK)) //
.onErrorResume(throwable -> Mono.just(ErrorResponse.create(throwable, HttpStatus.NOT_FOUND)));
}
return this.producerCallbacks.startInfoSubscriptionJob(newInfoJob, infoProducers) //
.doOnNext(noOfAcceptingProducers -> this.logger.debug("Started job {}, number of activated producers: {}",
newInfoJob.getId(), noOfAcceptingProducers)) //
- .flatMap(noOfAcceptingProducers -> Mono.just(newInfoJob));
+ .map(noOfAcceptingProducers -> newInfoJob);
}
private Mono<InfoJob> validatePutInfoJob(String jobId, ConsumerJobInfo jobInfo, boolean performTypeCheck) {
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);
}
}
}
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);
}
}
}