vcpe artifacts support 00/72800/2
authorTal Gitelman <tal.gitelman@att.com>
Thu, 15 Nov 2018 16:35:37 +0000 (18:35 +0200)
committerIdan Amit <idan.amit@intl.att.com>
Thu, 15 Nov 2018 18:25:04 +0000 (18:25 +0000)
 -  make the input csar could accepted by SDC

Change-Id: Ia327044c3fa606278d0e5783f35bfa724e5d1d5f
Issue-ID: SDC-1911
Signed-off-by: Tal Gitelman <tal.gitelman@att.com>
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java

index 14e28f3..7917a0a 100644 (file)
@@ -5086,12 +5086,13 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
             ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR);
             responseWrapper.setInnerElement(responseFormat);
             log.debug("Exception occured when findNodeTypeArtifactsToHandle, error is:{}", e.getMessage(), e);
+            nodeTypeArtifactsToHandleRes = Either.right(responseWrapper.getInnerElement());
         }
         return nodeTypeArtifactsToHandleRes;
     }
 
     ImmutablePair<String, String> buildNestedToscaResourceName(String nodeResourceType, String vfResourceName,
-                                                                       String nodeTypeFullName) {
+                                                               String nodeTypeFullName) {
         String actualType;
         String actualVfName;
         if (ResourceTypeEnum.CVFC.name().equals(nodeResourceType)) {
@@ -5102,25 +5103,31 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
             actualType = nodeResourceType;
         }
 
-        StringBuilder toscaResourceName = new StringBuilder(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX);
-        String nameWithouNamespacePrefix = nodeTypeFullName
-                .substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length());
-        String[] findTypes = nameWithouNamespacePrefix.split("\\.");
-        String resourceType = findTypes[0];
-        String actualName = nameWithouNamespacePrefix.substring(resourceType.length());
-
-        if (actualName.startsWith(Constants.ABSTRACT)) {
-            toscaResourceName.append(resourceType.toLowerCase()).append('.')
-                    .append(ValidationUtils.convertToSystemName(actualVfName));
-        } else {
-            toscaResourceName.append(actualType.toLowerCase()).append('.')
-                    .append(ValidationUtils.convertToSystemName(actualVfName)).append('.').append(Constants.ABSTRACT);
-        }
-        StringBuilder previousToscaResourceName = new StringBuilder(toscaResourceName);
-        return new ImmutablePair<>(toscaResourceName.append(actualName.toLowerCase()).toString(),
-                previousToscaResourceName
-                        .append(actualName.substring(actualName.split("\\.")[1].length() + 1).toLowerCase())
-                        .toString());
+        try {
+            StringBuilder toscaResourceName = new StringBuilder(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX);
+            String nameWithouNamespacePrefix = nodeTypeFullName
+                    .substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length());
+            String[] findTypes = nameWithouNamespacePrefix.split("\\.");
+            String resourceType = findTypes[0];
+            String actualName = nameWithouNamespacePrefix.substring(resourceType.length());
+
+            if (actualName.startsWith(Constants.ABSTRACT)) {
+                toscaResourceName.append(resourceType.toLowerCase()).append('.')
+                        .append(ValidationUtils.convertToSystemName(actualVfName));
+            } else {
+                toscaResourceName.append(actualType.toLowerCase()).append('.')
+                        .append(ValidationUtils.convertToSystemName(actualVfName)).append('.').append(Constants.ABSTRACT);
+            }
+            StringBuilder previousToscaResourceName = new StringBuilder(toscaResourceName);
+            return new ImmutablePair<>(toscaResourceName.append(actualName.toLowerCase()).toString(),
+                    previousToscaResourceName
+                            .append(actualName.substring(actualName.split("\\.")[1].length() + 1).toLowerCase())
+                            .toString());
+        } catch (Exception e) {
+            ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_TOSCA_TEMPLATE);
+            log.debug("Exception occured when buildNestedToscaResourceName, error is:{}", e.getMessage(), e);
+            throw new ComponentException(ActionStatus.INVALID_TOSCA_TEMPLATE, vfResourceName);
+        }
     }
 
     public ICacheMangerOperation getCacheManagerOperation() {