From a7bb8ec767dd9ec755dc5ef9b489f1114c034db3 Mon Sep 17 00:00:00 2001 From: Tal Gitelman Date: Thu, 15 Nov 2018 18:35:37 +0200 Subject: vcpe artifacts support - make the input csar could accepted by SDC Change-Id: Ia327044c3fa606278d0e5783f35bfa724e5d1d5f Issue-ID: SDC-1911 Signed-off-by: Tal Gitelman --- .../be/components/impl/ResourceBusinessLogic.java | 47 +++++++++++++--------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'catalog-be/src/main/java/org') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java index 14e28f3530..7917a0aa5d 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java @@ -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 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() { -- cgit 1.2.3-korg