+ @PutMapping(path = ProducerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE)
+ @ApiResponses(
+ value = { //
+ @ApiResponse(code = 200, message = "Type updated", response = VoidResponse.class), //
+ @ApiResponse(code = 201, message = "Type created", response = VoidResponse.class), //
+ @ApiResponse(code = 400, message = "Bad request", response = ErrorResponse.ErrorInfo.class)})
+
+ @ApiOperation(value = "Individual EI type", notes = "")
+ public ResponseEntity<Object> putEiType( //
+ @PathVariable("eiTypeId") String eiTypeId, @RequestBody ProducerEiTypeInfo registrationInfo) {
+
+ EiType previousDefinition = this.eiTypes.get(eiTypeId);
+ if (registrationInfo.jobDataSchema == null) {
+ return ErrorResponse.create("No schema provided", HttpStatus.BAD_REQUEST);
+ }
+ this.eiTypes.put(new EiType(eiTypeId, registrationInfo.jobDataSchema));
+ return new ResponseEntity<>(previousDefinition == null ? HttpStatus.CREATED : HttpStatus.OK);
+ }
+
+ @DeleteMapping(path = ProducerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE)
+ @ApiOperation(value = "Individual EI type", notes = "")
+ @ApiResponses(
+ value = { //
+ @ApiResponse(code = 200, message = "Not used", response = VoidResponse.class),
+ @ApiResponse(code = 204, message = "Producer deleted", response = VoidResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Enrichment Information type is not found",
+ response = ErrorResponse.ErrorInfo.class),
+ @ApiResponse(
+ code = 406,
+ message = "The Enrichment Information type has one or several active producers",
+ response = ErrorResponse.ErrorInfo.class)})
+ public ResponseEntity<Object> deleteEiType( //
+ @PathVariable("eiTypeId") String eiTypeId) {
+
+ EiType type = this.eiTypes.get(eiTypeId);
+ if (type == null) {
+ return ErrorResponse.create("EI type not found", HttpStatus.NOT_FOUND);
+ }
+ if (!this.eiProducers.getProducersForType(type).isEmpty()) {
+ String firstProducerId = this.eiProducers.getProducersForType(type).iterator().next().getId();
+ return ErrorResponse.create("The type has active producers: " + firstProducerId, HttpStatus.NOT_ACCEPTABLE);
+ }
+ this.eiTypes.remove(type);
+ return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+ }
+