diff options
Diffstat (limited to 'catalog-be')
4 files changed, 32 insertions, 13 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java index 74bb55b63d..1ee3bc61c8 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java @@ -3648,12 +3648,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { Either<ESArtifactData, CassandraOperationStatus> artifactfromES; ESArtifactData esArtifactData; if (esArtifactId != null && !esArtifactId.isEmpty() && artifactDefinition.getPayloadData() == null) { + log.debug("Try to fetch artifact from cassandra with id : {}", esArtifactId); artifactfromES = artifactCassandraDao.getArtifact(esArtifactId); if (artifactfromES.isRight()) { CassandraOperationStatus resourceUploadStatus = artifactfromES.right().value(); StorageOperationStatus storageResponse = DaoStatusConverter.convertCassandraStatusToStorageStatus(resourceUploadStatus); ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(storageResponse); - log.debug("Error when getting artifact from ES, error: {}", actionStatus.name()); + log.debug("Error when getting artifact from ES, error: {} esid : {}", actionStatus.name(), esArtifactId); return Either.right(componentsUtils.getResponseFormatByArtifactId(actionStatus, artifactDefinition.getArtifactDisplayName())); } esArtifactData = artifactfromES.left().value(); 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 b0feffdd42..08d377c7db 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 @@ -917,6 +917,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { vfcToscaNames.put(nodeType.getKey(), toscaResourceName); } } + for(NodeTypeInfo cvfc : nodeTypesInfo.values()){ + vfcToscaNames.put(cvfc.getType(), buildNestedToscaResourceName(ResourceTypeEnum.CVFC.name(), vfResourceName, cvfc.getType())); + } return vfcToscaNames; } @@ -1461,7 +1464,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { String nameWithouNamespacePrefix = nodeName.substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length()); String[] findTypes = nameWithouNamespacePrefix.split("\\."); String resourceType = findTypes[0]; - return resourceVfName + "-" + nameWithouNamespacePrefix.substring(resourceType.length() + 1) + "Cvfc"; + String resourceName = resourceVfName + "-" + nameWithouNamespacePrefix.substring(resourceType.length() + 1); + return addCvfcSuffixToResourceName(resourceName); } private Either<Resource, ResponseFormat> createResourceAndRIsFromYaml(String yamlName, Resource resource, ParsedToscaYamlInfo parsedToscaYamlInfo, AuditingActionEnum actionEnum, boolean isNormative, @@ -1987,6 +1991,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { if (eitherCreateResult.isRight()) { return Either.right(eitherCreateResult.right().value()); } + resource = eitherCreateResult.left().value(); Either<ImmutablePair<String, String>, ResponseFormat> artifacsMetaCsarStatus = CsarValidationUtils.getArtifactsMeta(csarInfo.getCsar(), csarInfo.getCsarUUID(), componentsUtils); if (artifacsMetaCsarStatus.isLeft()) { @@ -2895,7 +2900,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { } } if (resStatus == null) { - resStatus = Either.left(resource); + Either<Resource, StorageOperationStatus> toscaElement = toscaOperationFacade.getToscaElement(resource.getUniqueId()); + resStatus = toscaElement.bimap(resourceResponse -> resourceResponse, + storageResponse -> componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageResponse), resource)); } } catch (Exception e) { resStatus = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)); @@ -6209,11 +6216,23 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { * * return Either.left(true); } */ + private boolean isResourceNameEquals(Resource currentResource, Resource updateInfoResource) { + String resourceNameUpdated = updateInfoResource.getName(); + String resourceNameCurrent = currentResource.getName(); + if (resourceNameCurrent.equals(resourceNameUpdated)) + return true; + // In case of CVFC type we should support the case of old VF with CVFC instances that were created without the "Cvfc" suffix + return (currentResource.getResourceType().equals(ResourceTypeEnum.CVFC) + && resourceNameUpdated.equals(addCvfcSuffixToResourceName(resourceNameCurrent))); + } + + private String addCvfcSuffixToResourceName(String resourceName) { + return resourceName+"Cvfc"; + } private Either<Boolean, ResponseFormat> validateResourceName(Resource currentResource, Resource updateInfoResource, boolean hasBeenCertified) { String resourceNameUpdated = updateInfoResource.getName(); - String resourceNameCurrent = currentResource.getName(); - if (!resourceNameCurrent.equals(resourceNameUpdated)) { + if (!isResourceNameEquals(currentResource, updateInfoResource)) { if (!hasBeenCertified) { Either<Boolean, ResponseFormat> validateResourceNameResponse = validateComponentName(null, updateInfoResource, null); if (validateResourceNameResponse.isRight()) { @@ -6229,7 +6248,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { currentResource.setNormalizedName(ValidationUtils.normaliseComponentName(resourceNameUpdated)); currentResource.setSystemName(ValidationUtils.convertToSystemName(resourceNameUpdated)); - } else { + } else if(currentResource.getResourceType() != ResourceTypeEnum.CVFC) { log.info("Resource name: {}, cannot be updated once the resource has been certified once.", resourceNameUpdated); ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED); return Either.right(errorResponse); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java index a0cc347e09..fda199052e 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java @@ -146,7 +146,8 @@ public class CsarUtils { ImportUtils.Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "([\\d\\w\\_\\-\\.\\s]+)" + DEL_PATTERN + "([\\d\\w\\_\\-\\.\\s]+)" + DEL_PATTERN + - "([\\d\\w\\_\\-\\.\\s]+)" + DEL_PATTERN; + "([\\d\\w\\_\\-\\.\\s]+)" + DEL_PATTERN + + "([\\d\\w\\_\\-\\.\\s]+)"; public static final String VF_NODE_TYPE_ARTIFACTS_PATH_PATTERN = ARTIFACTS + DEL_PATTERN+ // Artifact Group (i.e Deployment/Informational) diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java index 0e27636901..40986bf59d 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java @@ -1655,17 +1655,15 @@ public class ResourceBusinessLogicTest { deploymentArtifactToUpdate.setArtifactName(deploymentArtifactToUpdateFileName); deploymentArtifactToUpdate.setArtifactType("SNMP_POLL"); deploymentArtifactToUpdate.setPayload(oldPayloadData); - deploymentArtifactToUpdate - .setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData)); - + deploymentArtifactToUpdate.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData)); + ArtifactDefinition deploymentArtifactToDelete = new ArtifactDefinition(); deploymentArtifactToDelete.setMandatory(false); deploymentArtifactToDelete.setArtifactName(deploymentArtifactToDeleteFileName); deploymentArtifactToDelete.setArtifactType("SNMP_TRAP"); deploymentArtifactToDelete.setPayload(oldPayloadData); - deploymentArtifactToDelete - .setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData)); - + deploymentArtifactToDelete.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData)); + ArtifactDefinition deploymentArtifactToIgnore = new ArtifactDefinition(); deploymentArtifacts.put(ValidationUtils.normalizeArtifactLabel(deploymentArtifactToUpdate.getArtifactName()), |