import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
import org.onap.cps.spi.FetchDescendantsOption;
import org.onap.cps.spi.exceptions.DataNodeNotFoundException;
+import org.onap.cps.spi.exceptions.DataValidationException;
import org.onap.cps.spi.model.DataNode;
import org.onap.cps.spi.model.DataNodeBuilder;
+import org.onap.cps.utils.CpsValidator;
import org.springframework.stereotype.Service;
@Slf4j
* @param ncmpServiceCmHandles collection of ncmpServiceCmHandles
*/
public List<CmHandleRegistrationResponse> updateCmHandleProperties(
- final Collection<NcmpServiceCmHandle> ncmpServiceCmHandles)
- throws DataNodeNotFoundException {
+ final Collection<NcmpServiceCmHandle> ncmpServiceCmHandles) {
final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses = new ArrayList<>();
for (final NcmpServiceCmHandle ncmpServiceCmHandle : ncmpServiceCmHandles) {
- final String cmHandle = ncmpServiceCmHandle.getCmHandleID();
+ final String cmHandle = ncmpServiceCmHandle.getCmHandleId();
try {
+ CpsValidator.validateNameCharacters(cmHandle);
final String cmHandleXpath = String.format(CM_HANDLE_XPATH_TEMPLATE, cmHandle);
final DataNode existingCmHandleDataNode =
cpsDataService.getDataNode(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, cmHandleXpath,
cmHandle, e.getMessage());
cmHandleRegistrationResponses.add(CmHandleRegistrationResponse
.createFailureResponse(cmHandle, RegistrationError.CM_HANDLE_DOES_NOT_EXIST));
+ } catch (final DataValidationException e) {
+ log.error("Unable to update cm handle : {}, caused by : {}",
+ cmHandle, e.getMessage());
+ cmHandleRegistrationResponses.add(
+ CmHandleRegistrationResponse.createFailureResponse(cmHandle,
+ RegistrationError.CM_HANDLE_INVALID_ID));
} catch (final Exception exception) {
- log.error("Unable to update dataNode for cmHandleId : {} , caused by : {}",
+ log.error("Unable to update cmHandle : {} , caused by : {}",
cmHandle, exception.getMessage());
cmHandleRegistrationResponses.add(
CmHandleRegistrationResponse.createFailureResponse(cmHandle, exception));