From f772969ac32331ce847e8193059cd39dd362c7a6 Mon Sep 17 00:00:00 2001 From: franciscovila Date: Thu, 10 Mar 2022 11:55:04 +0000 Subject: Restrict deletion of archived VSPs if used in VF Verify if a VSP is used in a VF in SDC-BE before proceeding with the deletion of a VSP Issue-ID: SDC-3894 Signed-off-by: franciscovila Change-Id: I7c8bdd55516a51cf8693cfdb8c109a7c20e7ea84 --- .../sdc/common/CommonConfigurationManager.java | 10 ++++++ .../common/errors/CatalogRestClientException.java | 36 ++++++++++++++++++++++ .../org/openecomp/sdc/common/errors/Messages.java | 6 +++- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/CatalogRestClientException.java (limited to 'openecomp-be/lib') diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/CommonConfigurationManager.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/CommonConfigurationManager.java index 92ace445da..fb15b54a2e 100644 --- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/CommonConfigurationManager.java +++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/CommonConfigurationManager.java @@ -124,6 +124,16 @@ public class CommonConfigurationManager { } } + /** + * This method can be used to access any yaml whole section configuration. + * + * @param yamlSection The yaml section that must be accessed + * @return map of entries configured for the specified section + */ + public Map getConfigValue(String yamlSection) { + return this.configuration.get(yamlSection); + } + /** * This method can be used to access a specific configuration parameter in the configuration in the yamlSection predefined in the constructor. * diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/CatalogRestClientException.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/CatalogRestClientException.java new file mode 100644 index 0000000000..c929d272c3 --- /dev/null +++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/CatalogRestClientException.java @@ -0,0 +1,36 @@ +/* + * ============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.openecomp.sdc.common.errors; + +public class CatalogRestClientException extends RuntimeException { + + public CatalogRestClientException() { + } + + public CatalogRestClientException(final String message) { + super(message); + } + + public CatalogRestClientException(final String message, final Throwable e) { + super(message, e); + } +} diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java index 32cc143b24..65906bd3d2 100644 --- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java +++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java @@ -96,9 +96,13 @@ public enum Messages { SUB_ENTITY_NOT_FOUND("Incorrect sub entity details provided."), FAILED_TO_SYNC("Non existing version cannot be synced."), FAILED_TO_PUBLISH_OUT_OF_SYNC("Publish is not allowed since the version status is Out of sync"), - DELETE_VSP_ERROR("VSP has been certified and cannot be deleted."), + DELETE_VSP_ERROR("Certified VSP must be archived before it can be deleted."), + DELETE_VSP_ERROR_USED_BY_VF("VSP cannot be deleted as it is used by VF %s. The VSP will only be available for deletion if VF %s is deleted."), + DELETE_VSP_UNEXPECTED_ERROR_USED_BY_VF("An error occurred while retrieving the usage of VSP %s through the rest endpoint %s"), DELETE_VSP_FROM_STORAGE_ERROR("Failed to delete VSP '%s' from Storage"), DELETE_VLM_ERROR("VLM has been certified and cannot be deleted."), + DELETE_VSP_ARCHIVED_ERROR("VSP has not been archived and cannot be deleted."), + CONFIG_ERROR("Configuration could not be loaded."), ZIP_SHOULD_NOT_CONTAIN_FOLDERS("Zip file should not contain folders"), VES_ZIP_SHOULD_CONTAIN_YML_ONLY("Wrong VES EVENT Artifact was uploaded - all files contained in Artifact must be YAML files" + " (using .yaml/.yml extensions)"), -- cgit 1.2.3-korg