From cec0cb7254ede8a790ec6f70ad5e31d10e2d32d7 Mon Sep 17 00:00:00 2001 From: "rajesh.kumar" Date: Tue, 6 Sep 2022 11:47:18 +0000 Subject: Added get APIs for dataspace. Issue-ID: CPS-1186 Change-ID: I73f97f986a817d423f93a8d922dcd9647b0829aa Signed-off-by: rajesh.kumar --- .../onap/cps/rest/controller/AdminRestController.java | 18 ++++++++++++++++++ .../onap/cps/rest/controller/CpsRestInputMapper.java | 4 ++++ 2 files changed, 22 insertions(+) (limited to 'cps-rest/src/main') 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 2707d9f29..a29f8d296 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 @@ -3,6 +3,7 @@ * Copyright (C) 2020-2022 Nordix Foundation * Modifications Copyright (C) 2020-2021 Bell Canada. * Modifications Copyright (C) 2021 Pantheon.tech + * Modifications Copyright (C) 2022 TechMahindra Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,8 +36,10 @@ import org.onap.cps.api.CpsAdminService; import org.onap.cps.api.CpsModuleService; import org.onap.cps.rest.api.CpsAdminApi; import org.onap.cps.rest.model.AnchorDetails; +import org.onap.cps.rest.model.DataspaceDetails; import org.onap.cps.rest.model.SchemaSetDetails; import org.onap.cps.spi.model.Anchor; +import org.onap.cps.spi.model.Dataspace; import org.onap.cps.spi.model.SchemaSet; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -174,4 +177,19 @@ public class AdminRestController implements CpsAdminApi { .collect(Collectors.toList()); return new ResponseEntity<>(anchorDetails, HttpStatus.OK); } + + @Override + public ResponseEntity> getAllDataspaces() { + final Collection dataspaces = cpsAdminService.getAllDataspaces(); + final List dataspaceDetails = dataspaces.stream().map(cpsRestInputMapper::toDataspaceDetails) + .collect(Collectors.toList()); + return new ResponseEntity<>(dataspaceDetails, HttpStatus.OK); + } + + @Override + public ResponseEntity getDataspace(final String dataspaceName) { + final Dataspace dataspace = cpsAdminService.getDataspace(dataspaceName); + final DataspaceDetails dataspaceDetails = cpsRestInputMapper.toDataspaceDetails(dataspace); + return new ResponseEntity<>(dataspaceDetails, HttpStatus.OK); + } } diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestInputMapper.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestInputMapper.java index d0a4a108c..3d3ab1145 100644 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestInputMapper.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestInputMapper.java @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2022 Nordix Foundation + * Modifications Copyright (C) 2022 TechMahindra Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,8 +26,10 @@ import org.mapstruct.Mapping; import org.mapstruct.NullValueCheckStrategy; import org.mapstruct.NullValuePropertyMappingStrategy; import org.onap.cps.rest.model.AnchorDetails; +import org.onap.cps.rest.model.DataspaceDetails; import org.onap.cps.rest.model.SchemaSetDetails; import org.onap.cps.spi.model.Anchor; +import org.onap.cps.spi.model.Dataspace; import org.onap.cps.spi.model.SchemaSet; @Mapper(componentModel = "spring") @@ -39,4 +42,5 @@ public interface CpsRestInputMapper { AnchorDetails toAnchorDetails(final Anchor anchor); + DataspaceDetails toDataspaceDetails(final Dataspace dataspace); } -- cgit 1.2.3-korg