Fix artifact name invalid error message 90/123490/2
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>
Sun, 22 Aug 2021 01:04:29 +0000 (02:04 +0100)
committerMichael Morris <michael.morris@est.tech>
Tue, 24 Aug 2021 20:43:02 +0000 (20:43 +0000)
Issue-ID: SDC-3680
Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech>
Change-Id: I859953a9a0d8065437589cd7592137b14b29c7e5

catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java

index 8f5b2b6..6d243d2 100644 (file)
@@ -1803,9 +1803,11 @@ errors:
         messageId: "SVC4669"
     }
     #---------SVC4670------------------------------
+    # %1 - artifactname
+    # %2 - validname
     ARTIFACT_NAME_INVALID: {
         code: 400,
-        message: "Error: Artifact name is invalid.",
+        message: "Error: Artifact name '%1' is invalid. Only the following characters are allowed in the Artifact Name: '%2'.",
         messageId: "SVC4670"
     }
     #---------SVC4671------------------------------
index 152b78b..0e08be5 100644 (file)
@@ -198,6 +198,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
     private static final String CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES = "Create Resource - validateCapabilityTypesCreate";
     private static final String COMPONENT_INSTANCE_WITH_NAME = "component instance with name ";
     private static final String COMPONENT_INSTANCE_WITH_NAME_IN_RESOURCE = "component instance with name {}  in resource {} ";
+    private static final String VALID_CHARACTERS_ARTIFACT_NAME = "'A-Z', 'a-z', '0-9', '.', '_', '-', '@' and space";
     private static final LoggerSupportability loggerSupportability = LoggerSupportability.getLogger(ResourceBusinessLogic.class.getName());
     private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
     private final ResourceImportManager resourceImportManager;
@@ -2148,7 +2149,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
             Either<List<NonMetaArtifactInfo>, String> artifactPathAndNameList = getValidArtifactNames(csarInfo, collectedWarningMessages);
             if (artifactPathAndNameList.isRight()) {
                 return Either.right(
-                    getComponentsUtils().getResponseFormatByArtifactId(ActionStatus.ARTIFACT_NAME_INVALID, artifactPathAndNameList.right().value()));
+                    getComponentsUtils().getResponseFormatByArtifactId(ActionStatus.ARTIFACT_NAME_INVALID, artifactPathAndNameList.right().value(),
+                        VALID_CHARACTERS_ARTIFACT_NAME));
             }
             EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>> vfCsarArtifactsToHandle = null;
             if (artifactOperation.isCreateOrLink()) {
index 3b55e67..af05825 100644 (file)
@@ -404,12 +404,15 @@ public class ComponentsUtils {
         return responseFormat;
     }
 
-    public ResponseFormat getResponseFormatByArtifactId(ActionStatus actionStatus, String artifactId) {
+    public ResponseFormat getResponseFormatByArtifactId(ActionStatus actionStatus, String... params) {
         ResponseFormat responseFormat;
         switch (actionStatus) {
             case RESOURCE_NOT_FOUND:
             case ARTIFACT_NOT_FOUND:
-                responseFormat = getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, artifactId);
+                responseFormat = getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, params);
+                break;
+            case ARTIFACT_NAME_INVALID:
+                responseFormat = getResponseFormat(ActionStatus.ARTIFACT_NAME_INVALID, params);
                 break;
             default:
                 responseFormat = getResponseFormat(actionStatus);