summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/main/java
diff options
context:
space:
mode:
authorRuslan Kashapov <ruslan.kashapov@pantheon.tech>2020-12-10 10:49:59 +0200
committerRuslan Kashapov <ruslan.kashapov@pantheon.tech>2021-01-06 15:03:59 +0200
commit5a8718b84dbd3c6fa78aa644a4695274a0a1ab5d (patch)
tree4dbd96f90aee895053036d5616a00b9912dcde82 /cps-ri/src/main/java
parentec3e17505d12785586fc2418438c3d45b63d7dbd (diff)
Create dataspace
Issue-ID: CPS-134 Change-Id: Ie7f00f9c322a12a6c2a71c1407f6970a7dd24d2d Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Diffstat (limited to 'cps-ri/src/main/java')
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java10
1 files changed, 10 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 5093ba5899..d6579bdbb5 100644
--- 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
@@ -28,6 +28,7 @@ import org.onap.cps.spi.entities.Dataspace;
import org.onap.cps.spi.entities.Fragment;
import org.onap.cps.spi.entities.SchemaSet;
import org.onap.cps.spi.exceptions.AnchorAlreadyDefinedException;
+import org.onap.cps.spi.exceptions.DataspaceAlreadyDefinedException;
import org.onap.cps.spi.model.Anchor;
import org.onap.cps.spi.repository.DataspaceRepository;
import org.onap.cps.spi.repository.FragmentRepository;
@@ -49,6 +50,15 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic
private SchemaSetRepository schemaSetRepository;
@Override
+ public void createDataspace(final String dataspaceName) {
+ try {
+ dataspaceRepository.save(new Dataspace(dataspaceName));
+ } catch (final DataIntegrityViolationException e) {
+ throw new DataspaceAlreadyDefinedException(dataspaceName, e);
+ }
+ }
+
+ @Override
public void createAnchor(final String dataspaceName, final String schemaSetName, final String anchorName) {
final Dataspace dataspace = dataspaceRepository.getByName(dataspaceName);
final SchemaSet schemaSet = schemaSetRepository.getByDataspaceAndName(dataspace, schemaSetName);