diff options
author | 2022-09-13 09:07:54 +0000 | |
---|---|---|
committer | 2022-09-13 09:07:54 +0000 | |
commit | 5b977b6607d696d347de08ecba638ffbf4d57d16 (patch) | |
tree | 10e2ddab3c2f8c2046bf044b7767cbd0c5108613 /cps-service | |
parent | 96d54ef097e3d7ccbc89b615bf3c042ec0141e97 (diff) | |
parent | 7b6ab50231f5ab39d1476531031437f81328115e (diff) |
Merge "Handle partial failure"
Diffstat (limited to 'cps-service')
4 files changed, 40 insertions, 6 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java index 6bf493556..b6aa04be7 100755 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java @@ -97,7 +97,7 @@ public class CpsDataServiceImpl implements CpsDataService { CpsValidator.validateNameCharacters(dataspaceName, anchorName); final Collection<Collection<DataNode>> listElementDataNodeCollections = buildDataNodes(dataspaceName, anchorName, parentNodeXpath, jsonDataList); - cpsDataPersistenceService.addListElementsBatch(dataspaceName, anchorName, parentNodeXpath, + cpsDataPersistenceService.addMultipleLists(dataspaceName, anchorName, parentNodeXpath, listElementDataNodeCollections); processDataUpdatedEventAsync(dataspaceName, anchorName, parentNodeXpath, UPDATE, observedTimestamp); } diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java index 8b45ae78d..cd0cefcbf 100644 --- a/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java +++ b/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java @@ -66,15 +66,15 @@ public interface CpsDataPersistenceService { Collection<DataNode> listElementsCollection); /** - * Adds list child elements to a Fragment. + * Add multiple lists of data nodes to a parent node at the same time. * * @param dataspaceName dataspace name * @param anchorName anchor name * @param parentNodeXpath parent node xpath - * @param listElementsCollections collections of data nodes representing list elements + * @param newLists collections of lists of data nodes representing list elements */ - void addListElementsBatch(String dataspaceName, String anchorName, String parentNodeXpath, - Collection<Collection<DataNode>> listElementsCollections); + void addMultipleLists(String dataspaceName, String anchorName, String parentNodeXpath, + Collection<Collection<DataNode>> newLists); /** * Retrieves datanode by XPath for given dataspace and anchor. diff --git a/cps-service/src/main/java/org/onap/cps/spi/exceptions/AlreadyDefinedExceptionBatch.java b/cps-service/src/main/java/org/onap/cps/spi/exceptions/AlreadyDefinedExceptionBatch.java new file mode 100644 index 000000000..a5ce6fde2 --- /dev/null +++ b/cps-service/src/main/java/org/onap/cps/spi/exceptions/AlreadyDefinedExceptionBatch.java @@ -0,0 +1,34 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.cps.spi.exceptions; + +import java.util.Collection; +import lombok.Getter; + +public class AlreadyDefinedExceptionBatch extends RuntimeException { + + @Getter + private final Collection<String> alreadyDefinedCmHandleIds; + + public AlreadyDefinedExceptionBatch(final Collection<String> alreadyDefinedCmHandleIds) { + this.alreadyDefinedCmHandleIds = alreadyDefinedCmHandleIds; + } +} diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy index ab960df6a..3f28f0ac8 100644 --- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy @@ -143,7 +143,7 @@ class CpsDataServiceImplSpec extends Specification { def jsonData = '{"branch": [{"name": "A"}, {"name": "B"}]}' objectUnderTest.saveListElementsBatch(dataspaceName, anchorName, '/test-tree', [jsonData], observedTimestamp) then: 'the persistence service method is invoked with correct parameters' - 1 * mockCpsDataPersistenceService.addListElementsBatch(dataspaceName, anchorName, '/test-tree',_) >> { + 1 * mockCpsDataPersistenceService.addMultipleLists(dataspaceName, anchorName, '/test-tree',_) >> { args -> { def listElementsCollection = args[3] as Collection<Collection<DataNode>> assert listElementsCollection.size() == 1 |