X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ncmp-service%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fcps%2Fncmp%2Fapi%2Fmodels%2FDmiPluginRegistration.java;h=f1b3888c6e3d1b5d8ebc82d1c6a4bc065f38bdad;hb=e0873dde9816543a34818c1509b1aaa1c195a875;hp=a604f3448482b00fd1f08c6a6de80a6992680c72;hpb=7c483c72e3643abb0d425f0092c15310c5359276;p=cps.git diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/DmiPluginRegistration.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/DmiPluginRegistration.java index a604f34484..f1b3888c6e 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/DmiPluginRegistration.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/DmiPluginRegistration.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation + * Copyright (C) 2021-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. @@ -28,6 +28,7 @@ import com.google.common.base.Strings; import java.util.List; import lombok.Getter; import lombok.Setter; +import org.onap.cps.ncmp.api.impl.exception.DmiRequestException; import org.onap.cps.ncmp.api.impl.exception.NcmpException; /** @@ -53,8 +54,6 @@ public class DmiPluginRegistration { private List removedCmHandles; - public static final String PLEASE_SUPPLY_CORRECT_PLUGIN_INFORMATION = "Please supply correct plugin information."; - /** * Validates plugin service names. * @@ -67,19 +66,22 @@ public class DmiPluginRegistration { String errorMessage = null; - if (isNullEmptyOrBlank(combinedServiceName) - && isNullEmptyOrBlank(dataServiceName) - && isNullEmptyOrBlank(modelsServiceName)) { - errorMessage = "No DMI plugin service names"; - } - - if (!isNullEmptyOrBlank(combinedServiceName) - && (!isNullEmptyOrBlank(dataServiceName) || !isNullEmptyOrBlank(modelsServiceName))) { - errorMessage = "Invalid combination of plugin service names"; + if (isNullEmptyOrBlank(combinedServiceName)) { + if ((isNullEmptyOrBlank(dataServiceName) && isNullEmptyOrBlank(modelsServiceName))) { + errorMessage = "No DMI plugin service names"; + } else { + if (isNullEmptyOrBlank(dataServiceName) || isNullEmptyOrBlank(modelsServiceName)) { + errorMessage = "Cannot register just a Data or Model plugin service name"; + } + } + } else { + if (!isNullEmptyOrBlank(dataServiceName) || !isNullEmptyOrBlank(modelsServiceName)) { + errorMessage = "Cannot register combined plugin service name and other service names"; + } } if (errorMessage != null) { - throw new NcmpException(errorMessage, PLEASE_SUPPLY_CORRECT_PLUGIN_INFORMATION); + throw new DmiRequestException(errorMessage, "Please supply correct plugin information."); } }