X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=dmaap-adaptor-java%2Fsrc%2Fmain%2Fjava%2Forg%2Foran%2Fdmaapadapter%2Fcontrollers%2FProducerCallbacksController.java;h=ca7c96cda83b20b5adb5b53b8e6aed142a5a22a6;hb=960e66a1728c1c332f6b74320bbd086a442ba5ea;hp=d4fe95cef50437b399c7f1a75b866c1b52392633;hpb=f1cee0f81c6bc482f73182c8f4c903e8376381e8;p=nonrtric.git diff --git a/dmaap-adaptor-java/src/main/java/org/oran/dmaapadapter/controllers/ProducerCallbacksController.java b/dmaap-adaptor-java/src/main/java/org/oran/dmaapadapter/controllers/ProducerCallbacksController.java index d4fe95ce..ca7c96cd 100644 --- a/dmaap-adaptor-java/src/main/java/org/oran/dmaapadapter/controllers/ProducerCallbacksController.java +++ b/dmaap-adaptor-java/src/main/java/org/oran/dmaapadapter/controllers/ProducerCallbacksController.java @@ -24,12 +24,16 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.ArrayList; +import java.util.Collection; + import org.oran.dmaapadapter.r1.ProducerJobInfo; import org.oran.dmaapadapter.repository.InfoTypes; import org.oran.dmaapadapter.repository.Job; @@ -52,7 +56,7 @@ import org.springframework.web.bind.annotation.RestController; public class ProducerCallbacksController { private static final Logger logger = LoggerFactory.getLogger(ProducerCallbacksController.class); - public static final String API_NAME = "Management of configuration"; + public static final String API_NAME = "Producer job control API"; public static final String API_DESCRIPTION = ""; public static final String JOB_URL = "/dmaap_dataproducer/info_job"; public static final String SUPERVISION_URL = "/dmaap_dataproducer/health_check"; @@ -70,7 +74,9 @@ public class ProducerCallbacksController { description = "The call is invoked to activate or to modify a data subscription. The endpoint is provided by the Information Producer.") @ApiResponses(value = { // @ApiResponse(responseCode = "200", description = "OK", // - content = @Content(schema = @Schema(implementation = VoidResponse.class))) // + content = @Content(schema = @Schema(implementation = VoidResponse.class))), // + @ApiResponse(responseCode = "404", description = "Information type is not found", // + content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))), // }) public ResponseEntity jobCreatedCallback( // @RequestBody String body) { @@ -78,7 +84,8 @@ public class ProducerCallbacksController { ProducerJobInfo request = gson.fromJson(body, ProducerJobInfo.class); logger.info("Job started callback {}", request.id); - Job job = new Job(request.id, request.targetUri, types.getType(request.typeId)); + Job job = new Job(request.id, request.targetUri, types.getType(request.typeId), request.owner, + request.lastUpdated); this.jobs.put(job); return new ResponseEntity<>(HttpStatus.OK); } catch (Exception e) { @@ -86,6 +93,21 @@ public class ProducerCallbacksController { } } + @GetMapping(path = JOB_URL, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Get all jobs", description = "Returns all info jobs, can be used for trouble shooting") + @ApiResponse(responseCode = "200", // + description = "Information jobs", // + content = @Content(array = @ArraySchema(schema = @Schema(implementation = ProducerJobInfo.class)))) // + public ResponseEntity getJobs() { + + Collection producerJobs = new ArrayList<>(); + for (Job j : this.jobs.getAll()) { + producerJobs.add(new ProducerJobInfo(null, j.getId(), j.getType().getId(), j.getCallbackUrl(), j.getOwner(), + j.getLastUpdated())); + } + return new ResponseEntity<>(gson.toJson(producerJobs), HttpStatus.OK); + } + @DeleteMapping(path = JOB_URL + "/{infoJobId}", produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Callback for Information Job deletion", description = "The call is invoked to terminate a data subscription. The endpoint is provided by the Information Producer.") @@ -109,7 +131,7 @@ public class ProducerCallbacksController { content = @Content(schema = @Schema(implementation = String.class))) // }) public ResponseEntity producerSupervision() { - logger.info("Producer supervision"); + logger.debug("Producer supervision"); return new ResponseEntity<>(HttpStatus.OK); }