summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service/src/main/java/org/onap')
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java29
2 files changed, 35 insertions, 6 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index 209ade9559..0eb275cf0e 100755
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
@@ -59,7 +59,7 @@ import org.onap.cps.ncmp.api.models.DmiPluginRegistration;
import org.onap.cps.ncmp.api.models.DmiPluginRegistrationResponse;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
import org.onap.cps.spi.FetchDescendantsOption;
-import org.onap.cps.spi.exceptions.AlreadyDefinedException;
+import org.onap.cps.spi.exceptions.AlreadyDefinedExceptionBatch;
import org.onap.cps.spi.exceptions.CpsException;
import org.onap.cps.spi.exceptions.DataNodeNotFoundException;
import org.onap.cps.spi.exceptions.DataValidationException;
@@ -365,12 +365,12 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
try {
lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleStatePerCmHandle);
return CmHandleRegistrationResponse.createSuccessResponses(cmHandleIds);
- } catch (final AlreadyDefinedException alreadyDefinedException) {
- return List.of(CmHandleRegistrationResponse.createFailureResponse(
- String.join(",", cmHandleIds), RegistrationError.CM_HANDLE_ALREADY_EXIST));
+ } catch (final AlreadyDefinedExceptionBatch alreadyDefinedExceptionBatch) {
+ return CmHandleRegistrationResponse.createFailureResponses(
+ alreadyDefinedExceptionBatch.getAlreadyDefinedCmHandleIds(),
+ RegistrationError.CM_HANDLE_ALREADY_EXIST);
} catch (final Exception exception) {
- return List.of(CmHandleRegistrationResponse.createFailureResponse(String.join(",", cmHandleIds),
- exception));
+ return CmHandleRegistrationResponse.createFailureResponses(cmHandleIds, exception);
}
}
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java
index b7faf09a9e..9f80218420 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java
@@ -21,6 +21,7 @@
package org.onap.cps.ncmp.api.models;
+import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import lombok.Builder;
@@ -67,6 +68,34 @@ public class CmHandleRegistrationResponse {
.build();
}
+ /**
+ * Creates a failure response based on registration error.
+ *
+ * @param cmHandleIds list of failed cmHandleIds
+ * @param registrationError enum describing the type of registration error
+ * @return CmHandleRegistrationResponse
+ */
+ public static List<CmHandleRegistrationResponse> createFailureResponses(final Collection<String> cmHandleIds,
+ final RegistrationError registrationError) {
+ return cmHandleIds.stream()
+ .map(cmHandleId -> CmHandleRegistrationResponse.createFailureResponse(cmHandleId, registrationError))
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Creates a failure response based on other exception.
+ *
+ * @param cmHandleIds list of failed cmHandleIds
+ * @param exception exception caught during the registration
+ * @return CmHandleRegistrationResponse
+ */
+ public static List<CmHandleRegistrationResponse> createFailureResponses(final Collection<String> cmHandleIds,
+ final Exception exception) {
+ return cmHandleIds.stream()
+ .map(cmHandleId -> CmHandleRegistrationResponse.createFailureResponse(cmHandleId, exception))
+ .collect(Collectors.toList());
+ }
+
public static CmHandleRegistrationResponse createSuccessResponse(final String cmHandle) {
return CmHandleRegistrationResponse.builder().cmHandle(cmHandle)
.status(Status.SUCCESS).build();