diff options
Diffstat (limited to 'cps-ri/src/main/java')
-rwxr-xr-x | cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java index 20a39f98e3..2cebfc72c0 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java @@ -3,6 +3,7 @@ * Copyright (C) 2020-2022 Nordix Foundation. * Modifications Copyright (C) 2020-2022 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. @@ -39,6 +40,7 @@ import org.onap.cps.spi.exceptions.DataspaceInUseException; import org.onap.cps.spi.exceptions.DataspaceNotFoundException; import org.onap.cps.spi.exceptions.ModuleNamesNotFoundException; import org.onap.cps.spi.model.Anchor; +import org.onap.cps.spi.model.Dataspace; import org.onap.cps.spi.repository.AnchorRepository; import org.onap.cps.spi.repository.DataspaceRepository; import org.onap.cps.spi.repository.SchemaSetRepository; @@ -82,6 +84,19 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic } @Override + public Dataspace getDataspace(final String dataspaceName) { + final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName); + return toDataspace(dataspaceEntity); + } + + @Override + public Collection<Dataspace> getAllDataspaces() { + final Collection<DataspaceEntity> dataspaceEntities = dataspaceRepository.findAll(); + return dataspaceEntities.stream().map(CpsAdminPersistenceServiceImpl::toDataspace) + .collect(Collectors.toSet()); + } + + @Override public void createAnchor(final String dataspaceName, final String schemaSetName, final String anchorName) { final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName); final var schemaSetEntity = @@ -155,6 +170,10 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic .build(); } + private static Dataspace toDataspace(final DataspaceEntity dataspaceEntity) { + return Dataspace.builder().name(dataspaceEntity.getName()).build(); + } + private void validateDataspaceAndModuleNames(final String dataspaceName, final Collection<String> inputModuleNames) { final Collection<String> retrievedModuleReferences = |