aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/a1pesimulator/controller/RanCellController.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/a1pesimulator/controller/RanCellController.java')
-rw-r--r--src/main/java/org/onap/a1pesimulator/controller/RanCellController.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/main/java/org/onap/a1pesimulator/controller/RanCellController.java b/src/main/java/org/onap/a1pesimulator/controller/RanCellController.java
index ae20f1c..f79cb64 100644
--- a/src/main/java/org/onap/a1pesimulator/controller/RanCellController.java
+++ b/src/main/java/org/onap/a1pesimulator/controller/RanCellController.java
@@ -60,10 +60,6 @@ public class RanCellController {
@GetMapping(value = "/{identifier}")
public ResponseEntity<CellDetails> getCellById(final @PathVariable String identifier) {
-
- if (!ranCellService.getCellIds().contains(identifier)) {
- return ResponseEntity.notFound().build();
- }
return ResponseEntity.ok(ranCellService.getCellById(identifier));
}
@@ -71,7 +67,7 @@ public class RanCellController {
@PostMapping(value = "/{identifier}/startFailure")
public ResponseEntity<String> startSendingFailureVesEvents(@ApiParam(value = "Cell Id") final @PathVariable String identifier,
@ApiParam(value = "Reporting Method", defaultValue = "FILE_READY", required = true) final @RequestParam() ReportingMethodEnum reportingMethod) {
-
+ checkIfCellExistOrThrowException(identifier);
ranCellService.failure(identifier);
ranVesBrokerService.startSendingFailureVesEvents(identifier, reportingMethod);
ranCellStateService.failingState(identifier);
@@ -82,7 +78,7 @@ public class RanCellController {
@ApiOperation("Stop sending failure VES events for specific cell")
@PostMapping(value = "/{identifier}/stopFailure")
public ResponseEntity<Void> stopSendingFailureVesEvents(@ApiParam(value = "Cell Id") final @PathVariable String identifier) {
-
+ checkIfCellExistOrThrowException(identifier);
ranCellService.recoverFromFailure(identifier);
Optional<RanPeriodicEvent> vesEvent = ranVesBrokerService.stopSendingVesEvents(identifier);
@@ -101,8 +97,9 @@ public class RanCellController {
@ApiParam(value = "Cell Id") final @PathVariable String identifier,
@ApiParam(value = "Granularity period in seconds", example = "60") final @RequestParam(required = false) Integer interval,
@ApiParam(value = "Reporting Method", defaultValue = "FILE_READY", required = true) final @RequestParam() ReportingMethodEnum reportingMethod) {
- log.info("Start sending ves events every {} seconds for {} ", getInterval(interval), identifier);
+ checkIfCellExistOrThrowException(identifier);
+ log.info("Start sending ves events every {} seconds for {} ", getInterval(interval), identifier);
VesEvent vesEvent = vesEventOpt.orElse(ranVesBrokerService.getGlobalPmVesStructure());
ResponseEntity<String> responseEntity =
@@ -118,6 +115,7 @@ public class RanCellController {
@ApiOperation("Stop sending normal VES events for specific cell")
@PostMapping(value = "/{identifier}/stop")
public ResponseEntity<Void> stopSendingVesEvents(@ApiParam(value = "Cell Id") final @PathVariable String identifier) {
+ checkIfCellExistOrThrowException(identifier);
log.info("Stop sending custom ves events for {}", identifier);
Optional<RanPeriodicEvent> vesEvent = ranVesBrokerService.stopSendingVesEvents(identifier);
if (!vesEvent.isPresent()) {
@@ -130,6 +128,7 @@ public class RanCellController {
@GetMapping(value = "/{identifier}/eventStructure")
public ResponseEntity<VesEvent> getVesEventStructure(final @PathVariable String identifier) {
+ checkIfCellExistOrThrowException(identifier);
if (!ranVesBrokerService.getEnabledEventElementIdentifiers().contains(identifier)) {
return ResponseEntity.notFound().build();
}
@@ -142,4 +141,13 @@ public class RanCellController {
}
return requested;
}
+
+ /**
+ * Check if cell exists otherwise getCellById() throws CellNotFoundException which is catched by RestExceptionHandler.class
+ *
+ * @param identifier cellId
+ */
+ private void checkIfCellExistOrThrowException(String identifier) {
+ ranCellService.getCellById(identifier);
+ }
}