From a966bab93a17fcba4e7fc28354c01b3f0878fbbe Mon Sep 17 00:00:00 2001 From: ToineSiebelink Date: Mon, 18 Dec 2023 12:25:41 +0000 Subject: Remove the dependency-cycle between beans - Splitting admin service into AnchorService and DataspaceService (this resolves the cyclic dependency) - Improved Delete dataspace integration error tests (were depending on execution order, now independent) Issue-ID: CPS-871 Change-Id: I47efedb6eb4bd2900f72d689616b7b7b62df2938 Signed-off-by: halil.cakal Signed-off-by: ToineSiebelink --- .../cps/rest/controller/AdminRestController.java | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'cps-rest/src/main/java') diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java index 993dad58c3..9b78f85201 100755 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java @@ -33,7 +33,8 @@ import java.util.Collection; import java.util.List; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; -import org.onap.cps.api.CpsAdminService; +import org.onap.cps.api.CpsAnchorService; +import org.onap.cps.api.CpsDataspaceService; import org.onap.cps.api.CpsModuleService; import org.onap.cps.rest.api.CpsAdminApi; import org.onap.cps.rest.model.AnchorDetails; @@ -53,9 +54,10 @@ import org.springframework.web.multipart.MultipartFile; @RequiredArgsConstructor public class AdminRestController implements CpsAdminApi { - private final CpsAdminService cpsAdminService; + private final CpsDataspaceService cpsDataspaceService; private final CpsModuleService cpsModuleService; private final CpsRestInputMapper cpsRestInputMapper; + private final CpsAnchorService cpsAnchorService; /** * Create a dataspace. @@ -65,7 +67,7 @@ public class AdminRestController implements CpsAdminApi { */ @Override public ResponseEntity createDataspace(@NotNull @Valid final String dataspaceName) { - cpsAdminService.createDataspace(dataspaceName); + cpsDataspaceService.createDataspace(dataspaceName); return new ResponseEntity<>(dataspaceName, HttpStatus.CREATED); } @@ -77,7 +79,7 @@ public class AdminRestController implements CpsAdminApi { */ @Override public ResponseEntity createDataspaceV2(@NotNull @Valid final String dataspaceName) { - cpsAdminService.createDataspace(dataspaceName); + cpsDataspaceService.createDataspace(dataspaceName); return new ResponseEntity<>(HttpStatus.CREATED); } @@ -89,7 +91,7 @@ public class AdminRestController implements CpsAdminApi { */ @Override public ResponseEntity deleteDataspace(final String apiVersion, final String dataspaceName) { - cpsAdminService.deleteDataspace(dataspaceName); + cpsDataspaceService.deleteDataspace(dataspaceName); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @@ -184,7 +186,7 @@ public class AdminRestController implements CpsAdminApi { @Override public ResponseEntity createAnchor(final String dataspaceName, @NotNull @Valid final String schemaSetName, @NotNull @Valid final String anchorName) { - cpsAdminService.createAnchor(dataspaceName, schemaSetName, anchorName); + cpsAnchorService.createAnchor(dataspaceName, schemaSetName, anchorName); return new ResponseEntity<>(anchorName, HttpStatus.CREATED); } @@ -199,7 +201,7 @@ public class AdminRestController implements CpsAdminApi { @Override public ResponseEntity createAnchorV2(final String dataspaceName, @NotNull @Valid final String schemaSetName, @NotNull @Valid final String anchorName) { - cpsAdminService.createAnchor(dataspaceName, schemaSetName, anchorName); + cpsAnchorService.createAnchor(dataspaceName, schemaSetName, anchorName); return new ResponseEntity<>(HttpStatus.CREATED); } @@ -214,7 +216,7 @@ public class AdminRestController implements CpsAdminApi { @Override public ResponseEntity deleteAnchor(final String apiVersion, final String dataspaceName, final String anchorName) { - cpsAdminService.deleteAnchor(dataspaceName, anchorName); + cpsAnchorService.deleteAnchor(dataspaceName, anchorName); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @@ -229,7 +231,7 @@ public class AdminRestController implements CpsAdminApi { @Override public ResponseEntity getAnchor(final String apiVersion, final String dataspaceName, final String anchorName) { - final var anchor = cpsAdminService.getAnchor(dataspaceName, anchorName); + final var anchor = cpsAnchorService.getAnchor(dataspaceName, anchorName); final var anchorDetails = cpsRestInputMapper.toAnchorDetails(anchor); return new ResponseEntity<>(anchorDetails, HttpStatus.OK); } @@ -244,7 +246,7 @@ public class AdminRestController implements CpsAdminApi { @Override public ResponseEntity> getAnchors(final String apiVersion, final String dataspaceName) { - final Collection anchors = cpsAdminService.getAnchors(dataspaceName); + final Collection anchors = cpsAnchorService.getAnchors(dataspaceName); final List anchorDetails = anchors.stream().map(cpsRestInputMapper::toAnchorDetails) .collect(Collectors.toList()); return new ResponseEntity<>(anchorDetails, HttpStatus.OK); @@ -252,7 +254,7 @@ public class AdminRestController implements CpsAdminApi { @Override public ResponseEntity> getAllDataspaces(final String apiVersion) { - final Collection dataspaces = cpsAdminService.getAllDataspaces(); + final Collection dataspaces = cpsDataspaceService.getAllDataspaces(); final List dataspaceDetails = dataspaces.stream().map(cpsRestInputMapper::toDataspaceDetails) .collect(Collectors.toList()); return new ResponseEntity<>(dataspaceDetails, HttpStatus.OK); @@ -260,7 +262,7 @@ public class AdminRestController implements CpsAdminApi { @Override public ResponseEntity getDataspace(final String apiVersion, final String dataspaceName) { - final Dataspace dataspace = cpsAdminService.getDataspace(dataspaceName); + final Dataspace dataspace = cpsDataspaceService.getDataspace(dataspaceName); final DataspaceDetails dataspaceDetails = cpsRestInputMapper.toDataspaceDetails(dataspace); return new ResponseEntity<>(dataspaceDetails, HttpStatus.OK); } -- cgit 1.2.3-korg