From 9cfc03f3af00d0128a5b22e32cc5ba439de627b6 Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Fri, 30 Jun 2023 12:14:07 +0100 Subject: Combine alreadyDefinedException classes Issue-ID: CPS-1774 Signed-off-by: danielhanrahan Change-Id: I52ff9074a9f8188e8635a811b0d2713a97cb4b10 --- .../onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'cps-ri/src') diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java index 7fed534b7..f4afe3d73 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java @@ -52,7 +52,6 @@ import org.onap.cps.spi.entities.AnchorEntity; import org.onap.cps.spi.entities.DataspaceEntity; import org.onap.cps.spi.entities.FragmentEntity; import org.onap.cps.spi.exceptions.AlreadyDefinedException; -import org.onap.cps.spi.exceptions.AlreadyDefinedExceptionBatch; import org.onap.cps.spi.exceptions.ConcurrencyException; import org.onap.cps.spi.exceptions.CpsAdminException; import org.onap.cps.spi.exceptions.CpsPathException; @@ -105,12 +104,12 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService for (final Collection newList : newLists) { try { addChildrenDataNodes(anchorEntity, parentNodeXpath, newList); - } catch (final AlreadyDefinedExceptionBatch e) { - failedXpaths.addAll(e.getAlreadyDefinedXpaths()); + } catch (final AlreadyDefinedException alreadyDefinedException) { + failedXpaths.addAll(alreadyDefinedException.getAlreadyDefinedObjectNames()); } } if (!failedXpaths.isEmpty()) { - throw new AlreadyDefinedExceptionBatch(failedXpaths); + throw AlreadyDefinedException.forDataNodes(failedXpaths, anchorEntity.getName()); } } @@ -122,7 +121,8 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService try { fragmentRepository.save(newChildAsFragmentEntity); } catch (final DataIntegrityViolationException e) { - throw AlreadyDefinedException.forDataNode(newChild.getXpath(), anchorEntity.getName(), e); + throw AlreadyDefinedException.forDataNodes(Collections.singletonList(newChild.getXpath()), + anchorEntity.getName()); } } @@ -156,7 +156,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService } } if (!failedXpaths.isEmpty()) { - throw new AlreadyDefinedExceptionBatch(failedXpaths); + throw AlreadyDefinedException.forDataNodes(failedXpaths, anchorEntity.getName()); } } @@ -189,7 +189,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService } } if (!failedXpaths.isEmpty()) { - throw new AlreadyDefinedExceptionBatch(failedXpaths); + throw AlreadyDefinedException.forDataNodes(failedXpaths, anchorEntity.getName()); } } -- cgit 1.2.3-korg