summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ri/src/main')
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java24
1 files changed, 17 insertions, 7 deletions
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 e02fb7355b..d62421c5af 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
@@ -103,17 +103,17 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
@Override
public void addMultipleLists(final String dataspaceName, final String anchorName, final String parentNodeXpath,
final Collection<Collection<DataNode>> newLists) {
- final Collection<String> failedCmHandleIds = new HashSet<>();
+ final Collection<String> failedXpaths = new HashSet<>();
newLists.forEach(newList -> {
try {
addChildrenDataNodes(dataspaceName, anchorName, parentNodeXpath, newList);
- } catch (final AlreadyDefinedException e) {
- newList.forEach(listElement -> failedCmHandleIds.add((String) listElement.getLeaves().get("id")));
+ } catch (final AlreadyDefinedExceptionBatch e) {
+ failedXpaths.addAll(e.getAlreadyDefinedXpaths());
}
});
- if (!failedCmHandleIds.isEmpty()) {
- throw new AlreadyDefinedExceptionBatch(failedCmHandleIds);
+ if (!failedXpaths.isEmpty()) {
+ throw new AlreadyDefinedExceptionBatch(failedXpaths);
}
}
@@ -147,7 +147,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
});
fragmentRepository.saveAll(fragmentEntities);
} catch (final DataIntegrityViolationException e) {
- log.warn("Exception occurred : {} , Batch with size : {} will be retried using individual save operations",
+ log.warn("Exception occurred : {} , While saving : {} children, retrying using individual save operations",
e, fragmentEntities.size());
retrySavingEachChildIndividually(dataspaceName, anchorName, parentNodeXpath, newChildren);
}
@@ -155,7 +155,17 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
private void retrySavingEachChildIndividually(final String dataspaceName, final String anchorName,
final String parentNodeXpath, final Collection<DataNode> newChildren) {
- newChildren.forEach(newChild -> addNewChildDataNode(dataspaceName, anchorName, parentNodeXpath, newChild));
+ final Collection<String> failedXpaths = new HashSet<>();
+ for (final DataNode newChild : newChildren) {
+ try {
+ addNewChildDataNode(dataspaceName, anchorName, parentNodeXpath, newChild);
+ } catch (final AlreadyDefinedException e) {
+ failedXpaths.add(newChild.getXpath());
+ }
+ }
+ if (!failedXpaths.isEmpty()) {
+ throw new AlreadyDefinedExceptionBatch(failedXpaths);
+ }
}
@Override