summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java125
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java12
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CassandraHealthCheck.java189
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java50
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java58
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java56
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java31
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/HealthCheckBusinessLogic.java361
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java98
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductComponentInstanceBusinessLogic.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java1691
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java16
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java140
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceComponentInstanceBusinessLogic.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/VFComponentInstanceBusinessLogic.java12
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransition.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java55
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java14
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentServlet.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java44
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/GroupServlet.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java60
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java71
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java27
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/common/transaction/mngr/RollbackManager.java13
-rw-r--r--catalog-be/src/main/resources/config/SDC.zipbin30057 -> 29275 bytes
-rw-r--r--catalog-be/src/main/resources/config/configuration.yaml23
-rw-r--r--catalog-be/src/main/resources/config/error-configuration.yaml518
-rw-r--r--catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml53
-rw-r--r--catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zipbin5277 -> 5408 bytes
-rw-r--r--catalog-be/src/main/resources/import/tosca/heat-types.zipbin72549 -> 0 bytes
-rw-r--r--catalog-be/src/main/resources/import/tosca/heat-types/Generic_PNF/Generic_PNF.json21
-rw-r--r--catalog-be/src/main/resources/import/tosca/heat-types/Generic_PNF/Generic_PNF.yml11
-rw-r--r--catalog-be/src/main/resources/import/tosca/heat-types/Generic_PNF/Generic_PNF.zipbin0 -> 320 bytes
-rw-r--r--catalog-be/src/main/resources/import/tosca/heat-types/extCp/extCp.yml20
-rw-r--r--catalog-be/src/main/resources/import/tosca/heat-types/extCp/extCp.zipbin790 -> 780 bytes
-rw-r--r--catalog-be/src/main/resources/import/tosca/heat-types/multiFlavorVFC/multiFlavorVFC.json21
-rw-r--r--catalog-be/src/main/resources/import/tosca/heat-types/multiFlavorVFC/multiFlavorVFC.yml10
-rw-r--r--catalog-be/src/main/resources/import/tosca/heat-types/multiFlavorVFC/multiFlavorVFC.zipbin0 -> 714 bytes
-rw-r--r--catalog-be/src/main/resources/import/tosca/heat-types/vnfConfiguration/vnfConfiguration.json21
-rw-r--r--catalog-be/src/main/resources/import/tosca/heat-types/vnfConfiguration/vnfConfiguration.yml10
-rw-r--r--catalog-be/src/main/resources/import/tosca/heat-types/vnfConfiguration/vnfConfiguration.zipbin0 -> 759 bytes
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py7
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/upgradeHeatTypes1707.py5
-rw-r--r--catalog-be/src/main/webapp/WEB-INF/web.xml1
48 files changed, 2456 insertions, 1425 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 cec045d8a3..ebdfe22185 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
@@ -340,10 +340,14 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
private boolean artifactGenerationRequired(org.openecomp.sdc.be.model.Component component, ArtifactDefinition artifactInfo) {
boolean needGenerate;
needGenerate = artifactInfo.getArtifactGroupType() == ArtifactGroupTypeEnum.TOSCA && (component.getLifecycleState() == LifecycleStateEnum.NOT_CERTIFIED_CHECKIN || component.getLifecycleState() == LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- needGenerate = needGenerate || (ComponentTypeEnum.RESOURCE == component.getComponentType() && artifactInfo.getArtifactType().equalsIgnoreCase(ArtifactTypeEnum.HEAT_ENV.getType()));
+ needGenerate = needGenerate || (ComponentTypeEnum.RESOURCE == component.getComponentType() && (artifactInfo.getArtifactType().equalsIgnoreCase(ArtifactTypeEnum.HEAT_ENV.getType()) || isAbstractVfcEmptyCsar((Resource) component, artifactInfo)));
return needGenerate;
}
+ private boolean isAbstractVfcEmptyCsar(Resource resource, ArtifactDefinition artifactInfo) {
+ return resource.isAbstract() && artifactInfo.getArtifactGroupType() == ArtifactGroupTypeEnum.TOSCA && artifactInfo.getArtifactType().equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) && StringUtils.isEmpty(artifactInfo.getArtifactChecksum());
+ }
+
public Either<Either<ArtifactDefinition, Operation>, ResponseFormat> generateAndSaveToscaArtifact(ArtifactDefinition artifactDefinition, org.openecomp.sdc.be.model.Component component, User user, boolean isInCertificationRequest,
boolean shouldLock, boolean inTransaction, boolean fetchTemplatesFromDB) {
@@ -798,13 +802,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
return Either.left(artifactResult.left().value());
}
- private Either<Either<ArtifactDefinition, Operation>, ResponseFormat> handleCreate(String parentId, ArtifactDefinition artifactInfo, ArtifactOperationInfo operation, AuditingActionEnum auditingAction, User user, ComponentTypeEnum componentType,
+ private Either<Either<ArtifactDefinition, Operation>, ResponseFormat> handleCreate(String componentId, ArtifactDefinition artifactInfo, ArtifactOperationInfo operation, AuditingActionEnum auditingAction, User user, ComponentTypeEnum componentType,
org.openecomp.sdc.be.model.Component parent, String origMd5, String originData, String interfaceType, String operationName, boolean shouldLock, boolean inTransaction) {
String artifactId = null;
// step 11
- Either<byte[], ResponseFormat> payloadEither = validateInput(parentId, artifactInfo, operation, auditingAction, artifactId, user, componentType, parent, origMd5, originData, interfaceType, operationName, inTransaction);
+ Either<byte[], ResponseFormat> payloadEither = validateInput(componentId, artifactInfo, operation, auditingAction, artifactId, user, componentType, parent, origMd5, originData, interfaceType, operationName, inTransaction);
if (payloadEither.isRight()) {
return Either.right(payloadEither.right().value());
}
@@ -814,14 +818,14 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
if (shouldLock) {
Either<Boolean, ResponseFormat> lockComponent = lockComponent(parent, "Upload Artifact - lock ");
if (lockComponent.isRight()) {
- handleAuditing(auditingAction, parent, parentId, user, null, null, null, lockComponent.right().value(), componentType, null);
+ handleAuditing(auditingAction, parent, componentId, user, null, null, null, lockComponent.right().value(), componentType, null);
return Either.right(lockComponent.right().value());
}
}
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> resultOp = null;
try {
- resultOp = createArtifact(parent, parentId, artifactInfo, decodedPayload, user, componentType, auditingAction, interfaceType, operationName);
+ resultOp = createArtifact(parent, componentId, artifactInfo, decodedPayload, user, componentType, auditingAction, interfaceType, operationName);
return resultOp;
} finally {
if (shouldLock) {
@@ -872,28 +876,28 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
return lockComponentAndUpdateArtifact(parentId, artifactInfo, auditingAction, artifactId, user, componentType, parent, decodedPayload, interfaceType, operationName, shouldLock, inTransaction);
}
- private Either<byte[], ResponseFormat> validateInput(String parentId, ArtifactDefinition artifactInfo, ArtifactOperationInfo operation, AuditingActionEnum auditingAction, String artifactId, User user, ComponentTypeEnum componentType,
+ private Either<byte[], ResponseFormat> validateInput(String componentId, ArtifactDefinition artifactInfo, ArtifactOperationInfo operation, AuditingActionEnum auditingAction, String artifactId, User user, ComponentTypeEnum componentType,
org.openecomp.sdc.be.model.Component parent, String origMd5, String originData, String interfaceType, String operationName, boolean inTransaction) {
// Md5 validations
Either<Boolean, ResponseFormat> validateMd5 = validateMd5(origMd5, originData, artifactInfo.getPayloadData(), operation);
if (validateMd5.isRight()) {
ResponseFormat responseFormat = validateMd5.right().value();
- handleAuditing(auditingAction, parent, parentId, user, null, null, artifactId, responseFormat, componentType, null);
+ handleAuditing(auditingAction, parent, componentId, user, null, null, artifactId, responseFormat, componentType, null);
return Either.right(responseFormat);
}
// step 11
- Either<ArtifactDefinition, ResponseFormat> validateResult = validateInput(parentId, artifactInfo, operation, artifactId, user, interfaceType, operationName, componentType, parent, inTransaction);
+ Either<ArtifactDefinition, ResponseFormat> validateResult = validateInput(componentId, artifactInfo, operation, artifactId, user, interfaceType, operationName, componentType, parent, inTransaction);
if (validateResult.isRight()) {
ResponseFormat responseFormat = validateResult.right().value();
- handleAuditing(auditingAction, parent, parentId, user, null, null, artifactId, responseFormat, componentType, null);
+ handleAuditing(auditingAction, parent, componentId, user, null, null, artifactId, responseFormat, componentType, null);
return Either.right(validateResult.right().value());
}
Either<byte[], ResponseFormat> payloadEither = handlePayload(artifactInfo, isArtifactMetadataUpdate(auditingAction));
if (payloadEither.isRight()) {
ResponseFormat responseFormat = payloadEither.right().value();
- handleAuditing(auditingAction, parent, parentId, user, null, null, artifactId, responseFormat, componentType, null);
+ handleAuditing(auditingAction, parent, componentId, user, null, null, artifactId, responseFormat, componentType, null);
log.debug("Error during handle payload");
return Either.right(responseFormat);
}
@@ -903,7 +907,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
Either<ArtifactDefinition, ResponseFormat> validateAndConvertHeatParamers = validateAndConvertHeatParamers(artifactInfo, artifactInfo.getArtifactType());
if (validateAndConvertHeatParamers.isRight()) {
ResponseFormat responseFormat = validateAndConvertHeatParamers.right().value();
- handleAuditing(auditingAction, parent, parentId, user, artifactInfo, null, artifactId, responseFormat, componentType, null);
+ handleAuditing(auditingAction, parent, componentId, user, artifactInfo, null, artifactId, responseFormat, componentType, null);
log.debug("Error during handle payload");
return Either.right(responseFormat);
}
@@ -1025,9 +1029,16 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
return Either.left(true);
}
- private Either<ArtifactDefinition, ResponseFormat> validateInput(String parentId, ArtifactDefinition artifactInfo, ArtifactOperationInfo operation, String artifactId, User user, String interfaceName, String operationName,
+ private Either<ArtifactDefinition, ResponseFormat> validateInput(String componentId, ArtifactDefinition artifactInfo, ArtifactOperationInfo operation, String artifactId, User user, String interfaceName, String operationName,
ComponentTypeEnum componentType, Component parentComponent, boolean inTransaction) {
+ Either<ArtifactDefinition, ResponseFormat> artifactById = findArtifactOnParentComponent(parentComponent, componentType, componentId, operation, artifactId);
+ if (artifactById.isRight()) {
+ return Either.right(artifactById.right().value());
+ }
+ ArtifactDefinition currentArtifactInfo = artifactById.left().value();
+
+ ignoreUnupdateableFieldsInUpdate(operation, artifactInfo, currentArtifactInfo);
Either<Boolean, ResponseFormat> validateInformationalArtifactRes = validateInformationalArtifact(artifactInfo, parentComponent);
if (validateInformationalArtifactRes.isRight()) {
return Either.right(validateInformationalArtifactRes.right().value());
@@ -1036,16 +1047,11 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
if (validateAndSetArtifactname.isRight()) {
return Either.right(validateAndSetArtifactname.right().value());
}
- Either<ArtifactDefinition, ResponseFormat> artifactById = findArtifactOnParentComponent(parentComponent, componentType, parentId, operation, artifactId);
- if (artifactById.isRight()) {
- return Either.right(artifactById.right().value());
- }
- ArtifactDefinition currentArtifactInfo = artifactById.left().value();
if (operationName != null && interfaceName != null) {
operationName = operationName.toLowerCase();
interfaceName = interfaceName.toLowerCase();
}
- Either<ActionStatus, ResponseFormat> logicalNameStatus = handleArtifactLabel(parentId, operation, artifactId, artifactInfo, interfaceName, operationName, currentArtifactInfo, componentType, inTransaction);
+ Either<ActionStatus, ResponseFormat> logicalNameStatus = handleArtifactLabel(componentId, parentComponent, operation, artifactId, artifactInfo, interfaceName, operationName, currentArtifactInfo, componentType);
if (logicalNameStatus.isRight()) {
return Either.right(logicalNameStatus.right().value());
}
@@ -1058,7 +1064,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
checkCreateFields(user, artifactInfo, (operationName != null ? ArtifactGroupTypeEnum.LIFE_CYCLE : ArtifactGroupTypeEnum.INFORMATIONAL));
}
- composeArtifactId(parentId, artifactId, artifactInfo, interfaceName, operationName);
+ composeArtifactId(componentId, artifactId, artifactInfo, interfaceName, operationName);
if (currentArtifactInfo != null) {
artifactInfo.setMandatory(currentArtifactInfo.getMandatory());
}
@@ -1077,7 +1083,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
boolean isCreate = operation.getArtifactOperationEnum() == ArtifactOperationEnum.Create;
if (isDeploymentArtifact(artifactInfo)) {
- Either<Boolean, ResponseFormat> deploymentValidationResult = validateDeploymentArtifact(parentComponent, parentId, user.getUserId(), isCreate, artifactInfo, currentArtifactInfo, parentType);
+ Either<Boolean, ResponseFormat> deploymentValidationResult = validateDeploymentArtifact(parentComponent, componentId, user.getUserId(), isCreate, artifactInfo, currentArtifactInfo, parentType);
if (deploymentValidationResult.isRight()) {
return Either.right(deploymentValidationResult.right().value());
}
@@ -1135,6 +1141,14 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
return Either.left(artifactInfo);
}
+ private void ignoreUnupdateableFieldsInUpdate(ArtifactOperationInfo operation, ArtifactDefinition artifactInfo, ArtifactDefinition currentArtifactInfo) {
+ if(operation.getArtifactOperationEnum().equals(ArtifactOperationEnum.Update)){
+ artifactInfo.setArtifactType(currentArtifactInfo.getArtifactType());
+ artifactInfo.setArtifactGroupType(currentArtifactInfo.getArtifactGroupType());
+ artifactInfo.setArtifactLabel(currentArtifactInfo.getArtifactLabel());
+ }
+ }
+
private Either<ArtifactDefinition, ResponseFormat> findArtifactOnParentComponent(Component parentComponent, ComponentTypeEnum componentType, String parentId, ArtifactOperationInfo operation, String artifactId) {
Either<ArtifactDefinition, ResponseFormat> result = null;
@@ -1474,13 +1488,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
private void resetMandatoryArtifactFields(ArtifactDefinition fetchedArtifact) {
if (fetchedArtifact != null) {
log.debug("Going to reset mandatory artifact {} fields. ", fetchedArtifact.getUniqueId());
- fetchedArtifact.setEsId("");
- fetchedArtifact.setArtifactName("");
- fetchedArtifact.setDescription("");
- fetchedArtifact.setApiUrl("");
- fetchedArtifact.setArtifactChecksum("");
+ fetchedArtifact.setEsId(null);
+ fetchedArtifact.setArtifactName(null);
+ fetchedArtifact.setDescription(null);
+ fetchedArtifact.setApiUrl(null);
+ fetchedArtifact.setArtifactChecksum(null);
nodeTemplateOperation.setDefaultArtifactTimeout(fetchedArtifact.getArtifactGroupType(), fetchedArtifact);
- fetchedArtifact.setArtifactUUID("");
+ fetchedArtifact.setArtifactUUID(null);
long time = System.currentTimeMillis();
fetchedArtifact.setPayloadUpdateDate(time);
fetchedArtifact.setHeatParameters(null);
@@ -1540,10 +1554,10 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
return Either.left(currentArtifactInfo);
}
- private Either<ActionStatus, ResponseFormat> handleArtifactLabel(String componentId, ArtifactOperationInfo operation, String artifactId, ArtifactDefinition artifactInfo, String interfaceName, String operationName,
- ArtifactDefinition currentArtifactInfo, ComponentTypeEnum componentType, boolean inTransaction) {
- String artifactLabel = artifactInfo.getArtifactLabel();
+ private Either<ActionStatus, ResponseFormat> handleArtifactLabel(String componentId, Component parentComponent, ArtifactOperationInfo operation, String artifactId, ArtifactDefinition artifactInfo, String interfaceName, String operationName,
+ ArtifactDefinition currentArtifactInfo, ComponentTypeEnum componentType) {
+ String artifactLabel = artifactInfo.getArtifactLabel();
if (operationName == null && (artifactInfo.getArtifactLabel() == null || artifactInfo.getArtifactLabel().isEmpty())) {
BeEcompErrorManager.getInstance().logBeMissingArtifactInformationError("Artifact Update / Upload", "artifactLabel");
log.debug("missing artifact logical name for component {}", componentId);
@@ -1584,27 +1598,25 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
log.debug("Invalid lenght form Artifact label : {}", artifactLabel);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.EXCEEDS_LIMIT, ARTIFACT_LABEL, String.valueOf(ValidationUtils.ARTIFACT_LABEL_LENGTH)));
}
- if (!validateLabelUniqueness(componentId, artifactLabel, componentType)) {
+ if (!validateLabelUniqueness(componentId, parentComponent, artifactLabel, componentType)) {
log.debug("Non unique Artifact label : {}", artifactLabel);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_EXIST, artifactLabel));
}
}
artifactInfo.setArtifactLabel(artifactLabel);
- if (currentArtifactInfo != null && !currentArtifactInfo.getArtifactLabel().equals(artifactInfo.getArtifactLabel())) {
- log.info("Logical artifact's name cannot be changed {}", artifactId);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_LOGICAL_NAME_CANNOT_BE_CHANGED));
- }
return Either.left(ActionStatus.OK);
}
- private boolean validateLabelUniqueness(String parentId, String artifactLabel, ComponentTypeEnum componentType) {
+ private boolean validateLabelUniqueness(String componentId, Component parentComponent, String artifactLabel, ComponentTypeEnum componentType) {
boolean isUnique = true;
- if (componentType.equals(ComponentTypeEnum.RESOURCE)) {
+ Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifacts;
+ if (componentType.equals(ComponentTypeEnum.RESOURCE_INSTANCE)) {
+ artifacts = artifactToscaOperation.getAllInstanceArtifacts(parentComponent.getUniqueId(), componentId);
} else {
+ artifacts = artifactToscaOperation.getArtifacts(componentId);
}
- // Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifacts = artifactOperation.getArtifacts(parentId, parentType, inTransaction);
- Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifacts = artifactToscaOperation.getArtifacts(parentId);
+
if (artifacts.isLeft()) {
for (String label : artifacts.left().value().keySet()) {
if (label.equals(artifactLabel)) {
@@ -1614,7 +1626,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
}
if (componentType.equals(ComponentTypeEnum.RESOURCE)) {
- Either<Map<String, InterfaceDefinition>, StorageOperationStatus> allInterfacesOfResource = interfaceLifecycleOperation.getAllInterfacesOfResource(parentId, true, true);
+ Either<Map<String, InterfaceDefinition>, StorageOperationStatus> allInterfacesOfResource = interfaceLifecycleOperation.getAllInterfacesOfResource(componentId, true, true);
if (allInterfacesOfResource.isLeft()) {
for (InterfaceDefinition interace : allInterfacesOfResource.left().value().values()) {
for (Operation operation : interace.getOperationsMap().values()) {
@@ -3886,7 +3898,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
* currently getArtifactById does not retrieve heatParameters Either<ArtifactDefinition, StorageOperationStatus> artifactRes = artifactOperation.getArtifactById(artifactId, false); ArtifactDefinition currArtifact = artifactRes.left().value();
*/
String currentHeatId = currHeatArtifact.getUniqueId();
-
+
String esArtifactId = currHeatArtifact.getEsId();
Either<ESArtifactData, CassandraOperationStatus> artifactfromES = artifactCassandraDao.getArtifact(esArtifactId);
if (artifactfromES.isRight()) {
@@ -3899,8 +3911,8 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
ESArtifactData esArtifactData = artifactfromES.left().value();
byte[] data = esArtifactData.getDataAsArray();
-
-
+
+
ArtifactDefinition updatedHeatArt = currHeatArtifact;
List<HeatParameterDefinition> updatedHeatEnvParams = artifactEnvInfo.getListHeatParameters();
@@ -3949,7 +3961,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
if (!updatedHeatArt.getDuplicated() || esArtifactData.getId() == null)
esArtifactData.setId(updatedHeatArt.getEsId());
res = saveArtifacts(esArtifactData, parent.getUniqueId(), false);
-
+
if (res) {
log.debug("Artifact saved into ES - {}", updatedHeatArt.getUniqueId());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.OK);
@@ -3964,7 +3976,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
resultOp = Either.right(responseFormat);
// return resultOp;
}
-
+
insideEither = Either.left(updatedHeatArt);
}
}
@@ -3976,13 +3988,17 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
updateHeatEnvArtifact = artifactToscaOperation.updateHeatEnvPlaceholder(artifactEnvInfo, componentId, componentType.getNodeType());
}
- if ( needToUpdateGroup && updateHeatEnvArtifact.isLeft() ){
+ if (needToUpdateGroup && updateHeatEnvArtifact.isLeft()) {
ActionStatus result = updateGroupForHeat(currHeatArtifact, updatedHeatArt, artifactEnvInfo, updateHeatEnvArtifact.left().value(), parent, componentType);
- if ( result != ActionStatus.OK ){
+ if (result != ActionStatus.OK) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(result);
return Either.right(responseFormat);
}
}
+
+ if (updatedHeatEnvParams.isEmpty()) {
+ return getResponseAndAuditInvalidEmptyHeatEnvFile(auditingAction, parent, parent.getUniqueId(), user, currHeatArtifact, artifactId, componentType);
+ }
resultOp = Either.left(insideEither);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.OK);
handleAuditing(auditingAction, parent, parent.getUniqueId(), user, currHeatArtifact, null, artifactId, responseFormat, componentType, "");
@@ -3990,6 +4006,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
+ private Either<Either<ArtifactDefinition,Operation>,ResponseFormat> getResponseAndAuditInvalidEmptyHeatEnvFile(AuditingActionEnum auditingAction, Component parent, String uniqueId, User user, ArtifactDefinition currHeatArtifact, String artifactId, ComponentTypeEnum componentType) {
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_YAML);
+ handleAuditing(auditingAction, parent, parent.getUniqueId(), user, currHeatArtifact, null, artifactId, responseFormat, componentType, "");
+ return Either.right(responseFormat);
+ }
+
+
private StorageOperationStatus generateCustomizationUUIDOnGroupInstance(ComponentInstance ri, String artifactId, String componentId) {
StorageOperationStatus error = StorageOperationStatus.OK;
log.debug("Need to re-generate customization UUID for group instance on component instance {}", ri.getUniqueId());
@@ -4092,7 +4115,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
Component component = getComponentByUuid(componentType, componentUuid, errorWrapper);
if (errorWrapper.isEmpty()) {
auditAdditionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
- downloadedArtifact = downloadArtifact(component.getDeploymentArtifacts(), artifactUUID, errorWrapper, component.getName());
+ downloadedArtifact = downloadArtifact(component.getAllArtifacts(), artifactUUID, errorWrapper, component.getName());
}
if (errorWrapper.isEmpty()) {
result = Either.left(downloadedArtifact);
@@ -4733,17 +4756,17 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
byte[] downloadedArtifact = null;
Either<ImmutablePair<String, byte[]>, ResponseFormat> downloadArtifactEither = null;
- List<ArtifactDefinition> deploymentArtifacts = null;
+ List<ArtifactDefinition> artifactsList = null;
ArtifactDefinition deploymentArtifact = null;
if (artifacts != null && !artifacts.isEmpty()) {
- deploymentArtifacts = artifacts.values().stream().filter(art -> art.getArtifactUUID() != null && art.getArtifactUUID().equals(artifactUUID)).collect(Collectors.toList());
+ artifactsList = artifacts.values().stream().filter(art -> art.getArtifactUUID() != null && art.getArtifactUUID().equals(artifactUUID)).collect(Collectors.toList());
}
- if (deploymentArtifacts == null || deploymentArtifacts.isEmpty()) {
+ if (artifactsList == null || artifactsList.isEmpty()) {
log.debug("Deployment artifact with uuid {} was not found for component {}", artifactUUID, componentName);
errorWrapper.setInnerElement(componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, artifactUUID));
}
if (errorWrapper.isEmpty()) {
- deploymentArtifact = deploymentArtifacts.get(0);
+ deploymentArtifact = artifactsList.get(0);
downloadArtifactEither = downloadArtifact(deploymentArtifact);
if (downloadArtifactEither.isRight()) {
log.debug("Failed to download artifact {}. ", deploymentArtifact.getArtifactName());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
index df8460ca96..1d153e0a5d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
@@ -47,6 +47,7 @@ import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.GroupProperty;
import org.openecomp.sdc.be.model.IComplexDefaultValue;
+import org.openecomp.sdc.be.model.IPropertyInputCommon;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
@@ -391,11 +392,10 @@ public abstract class BaseBusinessLogic {
}
protected Either<Boolean, ResponseFormat> validatePropertyDefaultValue(IComplexDefaultValue property, Map<String, DataTypeDefinition> dataTypes) {
- log.debug("validate property");
String type = null;
String innerType = null;
if (!propertyOperation.isPropertyTypeValid(property)) {
- log.info("Invalid type for property");
+ log.info("Invalid type for property {} type {}", property.getName(), property.getType());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY_TYPE, property.getType(), property.getName());
return Either.right(responseFormat);
}
@@ -404,13 +404,13 @@ public abstract class BaseBusinessLogic {
ImmutablePair<String, Boolean> propertyInnerTypeValid = propertyOperation.isPropertyInnerTypeValid(property, dataTypes);
innerType = propertyInnerTypeValid.getLeft();
if (!propertyInnerTypeValid.getRight().booleanValue()) {
- log.info("Invalid inner type for property");
+ log.info("Invalid inner type for property {} type {}", property.getName(), property.getType() );
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY_INNER_TYPE, innerType, property.getName());
return Either.right(responseFormat);
}
}
if (!propertyOperation.isPropertyDefaultValueValid(property, dataTypes)) {
- log.info("Invalid default value for property");
+ log.info("Invalid default value for property {} type {}", property.getName(), property.getType() );
ResponseFormat responseFormat;
if (type.equals(ToscaPropertyType.LIST.getType()) || type.equals(ToscaPropertyType.MAP.getType())) {
responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_COMPLEX_DEFAULT_VALUE, property.getName(), type, innerType, property.getDefaultValue());
@@ -568,7 +568,7 @@ public abstract class BaseBusinessLogic {
return Arrays.asList(enumValues).contains(enumFound);
}
- protected Either<String, StorageOperationStatus> validatePropValueBeforeCreate(ComponentInstanceProperty property, String value, boolean isValidate, String innerType, Map<String, DataTypeDefinition> allDataTypes) {
+ protected Either<String, StorageOperationStatus> validatePropValueBeforeCreate(IPropertyInputCommon property, String value, boolean isValidate, String innerType, Map<String, DataTypeDefinition> allDataTypes) {
String propertyType = property.getType();
ToscaPropertyType type = ToscaPropertyType.isValidType(propertyType);
@@ -603,7 +603,7 @@ public abstract class BaseBusinessLogic {
}
ImmutablePair<String, Boolean> pair = validateAndUpdateRules(propertyType, property.getRules(), innerType, allDataTypes, isValidate);
- log.debug("After validateAndUpdateRules. pair = {}", pair);
+ log.trace("After validateAndUpdateRules. pair = {}", pair);
if (pair.getRight() != null && pair.getRight() == false) {
BeEcompErrorManager.getInstance().logBeInvalidValueError("Add property value", pair.getLeft(), property.getName(), propertyType);
return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(TitanOperationStatus.ILLEGAL_ARGUMENT));
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CassandraHealthCheck.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CassandraHealthCheck.java
new file mode 100644
index 0000000000..237ec6d5fe
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CassandraHealthCheck.java
@@ -0,0 +1,189 @@
+package org.openecomp.sdc.be.components.impl;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.annotation.PostConstruct;
+
+import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.be.dao.cassandra.schema.SdcSchemaUtils;
+import org.openecomp.sdc.be.dao.cassandra.schema.Table;
+import org.openecomp.sdc.common.util.GeneralUtility;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.KeyspaceMetadata;
+import com.datastax.driver.core.Metadata;
+import com.datastax.driver.core.Session;
+
+@Component("cassandra-health-check")
+public class CassandraHealthCheck {
+
+
+ private static Logger log = LoggerFactory.getLogger(CassandraHealthCheck.class.getName());
+
+ private String localDataCenterName = null;
+
+ private Set<String> sdcKeyspaces = new HashSet<String>();
+
+ private int HC_FormulaNumber;
+
+ @PostConstruct
+ private void init() {
+
+ //Initialize local data center name - this field must be filled by DevOps
+ localDataCenterName = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getLocalDataCenter();
+
+ if (GeneralUtility.isEmptyString(localDataCenterName)) {
+ log.error("localDataCenter Name in configuration.yaml is missing.");
+ return;
+ }
+
+ //Collect all SDC keyspaces
+ for (Table table : Table.values()) {
+ sdcKeyspaces.add(table.getTableDescription().getKeyspace());
+ }
+
+ String titanCfgFile = ConfigurationManager.getConfigurationManager().getConfiguration().getTitanCfgFile();
+ Properties prop = new Properties();
+ InputStream titanProp = null;
+ try {
+ //load a properties file
+ titanProp = new FileInputStream(titanCfgFile);
+ prop.load(titanProp);
+ //Add titan keyspace
+ String titanKeyspace = prop.getProperty("storage.cassandra.keyspace");
+ if (!GeneralUtility.isEmptyString(titanKeyspace)) {
+ sdcKeyspaces.add(titanKeyspace);
+ }
+ } catch (Exception e) {
+ log.error("Failed to open titen.properties file , url is : {}", titanCfgFile);
+ }
+
+ log.info("All sdc keyspaces are : {}", sdcKeyspaces);
+
+ //Calculate the Formula of Health Check
+ Cluster cluster = null;
+ try {
+
+ log.info("creating cluster for Cassandra Health Check.");
+ //Create cluster from nodes in cassandra configuration
+ cluster = SdcSchemaUtils.createCluster();
+ if (cluster == null) {
+ log.error("Failure create cassandra cluster.");
+ return;
+ }
+
+ Metadata metadata = cluster.getMetadata();
+
+ if (metadata == null) {
+ log.error("Failure get cassandra metadata.");
+ return;
+ }
+
+ log.info("Cluster Metadata: {}", metadata.toString());
+ List<KeyspaceMetadata> keyspaces = metadata.getKeyspaces();
+ List<Integer> replactionFactorList = new ArrayList<Integer>();
+
+ //Collect the keyspaces Replication Factor of current localDataCenter
+ for (KeyspaceMetadata keyspace : keyspaces) {
+
+ if (sdcKeyspaces.contains(keyspace.getName())) {
+
+ log.info("keyspace : {} , replication: {}", keyspace.getName(), keyspace.getReplication());
+ Map<String, String> replicationOptions = keyspace.getReplication();
+
+ //In 1 site with one data center
+ if (replicationOptions.containsKey("replication_factor")) {
+ replactionFactorList.add(Integer.parseInt(replicationOptions.get("replication_factor")));
+ }
+ //In multiple sites with some data center
+ else if (replicationOptions.containsKey(localDataCenterName)) {
+ replactionFactorList.add(Integer.parseInt(replicationOptions.get(localDataCenterName)));
+ }
+ }
+ }
+
+ if (replactionFactorList.size() == 0) {
+ log.error("Replication factor NOT found in all keyspaces");
+ return;
+ }
+
+ int maxReplicationFactor = Collections.max(replactionFactorList);
+ log.info("maxReplication Factor is: {}", maxReplicationFactor);
+
+ int localQuorum = maxReplicationFactor/2 + 1;
+ log.info("localQuorum is: {}", localQuorum);
+
+ HC_FormulaNumber = maxReplicationFactor - localQuorum;
+
+ log.info("Health Check formula : Replication Factor – Local_Quorum = {}", HC_FormulaNumber);
+
+
+ } catch (Exception e) {
+ log.error("create cassandra cluster failed with exception.", e);
+ } finally {
+ if (cluster != null) {
+ cluster.close();
+ }
+ }
+
+ }
+
+ public boolean getCassandraStatus() {
+
+ if (GeneralUtility.isEmptyString(localDataCenterName)) {
+ log.error("localDataCenter Name in configuration.yaml is missing.");
+ return false;
+ }
+
+ Cluster cluster = null;
+ Session session = null;
+ try {
+ log.info("creating cluster for Cassandra for monitoring.");
+ cluster = SdcSchemaUtils.createCluster();
+ if (cluster == null) {
+ log.error("Failure create cassandra cluster.");
+ return false;
+ }
+ session = cluster.connect();
+ Metadata metadata = cluster.getMetadata();
+
+ if (metadata == null) {
+ log.error("Failure get cassandra metadata.");
+ return false;
+ }
+
+ log.info("The number of cassandra nodes is:{}", metadata.getAllHosts().size());
+
+ //Count the number of data center nodes that are down
+ Long downHostsNumber = metadata.getAllHosts().stream()
+ .filter(x -> x.getDatacenter().equals(localDataCenterName) && !x.isUp()).count();
+
+ log.info("The cassandra down nodes number is {}", downHostsNumber.toString());
+ return (HC_FormulaNumber >= downHostsNumber);
+
+ } catch (Exception e) {
+ log.error("create cassandra cluster failed with exception.", e);
+ return false;
+ } finally {
+ if (session != null) {
+ session.close();
+ }
+ if (cluster != null) {
+ cluster.close();
+ }
+ }
+ }
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index 5ee5c88f69..d1be69689e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -183,11 +183,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
return Either.right(errorResponse);
}
- description = ValidationUtils.removeNoneUtf8Chars(description);
- description = ValidationUtils.normaliseWhitespace(description);
- description = ValidationUtils.stripOctets(description);
- description = ValidationUtils.removeHtmlTagsOnly(description);
-
+ description = cleanUpText(description);
Either<Boolean, ResponseFormat> validatDescription = validateComponentDescription(description, type);
if (validatDescription.isRight()) {
ResponseFormat responseFormat = validatDescription.right().value();
@@ -666,19 +662,25 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
}
toscaArtifact = generateToscaRes.left().value().left().value();
component.getToscaArtifacts().put(toscaArtifact.getArtifactLabel(), toscaArtifact);
- toscaArtifact = component.getToscaArtifacts().values().stream()
- .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.TOSCA_CSAR.getType()))
- .findAny().get();
- generateToscaRes = saveToscaArtifactPayload(toscaArtifact, component, user, isInCertificationRequest, shouldLock, inTransaction, true);
- }
- if (generateToscaRes.isRight()) {
- return generateToscaRes;
+ if(!isAbstractResource(component)){
+ toscaArtifact = component.getToscaArtifacts().values().stream()
+ .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.TOSCA_CSAR.getType()))
+ .findAny().get();
+ generateToscaRes = saveToscaArtifactPayload(toscaArtifact, component, user, isInCertificationRequest, shouldLock, inTransaction, true);
+ if (generateToscaRes.isRight()) {
+ return generateToscaRes;
+ }
+ toscaArtifact = generateToscaRes.left().value().left().value();
+ component.getToscaArtifacts().put(toscaArtifact.getArtifactLabel(), toscaArtifact);
+ }
}
- ArtifactDefinition toscaArtifact = generateToscaRes.left().value().left().value();
- component.getToscaArtifacts().put(toscaArtifact.getArtifactLabel(), toscaArtifact);
return generateToscaRes;
}
+ private boolean isAbstractResource(Component component) {
+ return component.getComponentType() == ComponentTypeEnum.RESOURCE && ((Resource)component).isAbstract();
+ }
+
public Either<Either<ArtifactDefinition, Operation>, ResponseFormat> saveToscaArtifactPayload(ArtifactDefinition artifactDefinition, org.openecomp.sdc.be.model.Component component, User user, boolean isInCertificationRequest, boolean shouldLock,
boolean inTransaction, boolean fetchTemplatesFromDB) {
return artifactsBusinessLogic.generateAndSaveToscaArtifact(artifactDefinition, component, user, isInCertificationRequest, shouldLock, inTransaction, fetchTemplatesFromDB);
@@ -735,11 +737,11 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
}
}
- public Either<Boolean, ResponseFormat> validateAndUpdateDescription(User user, Component currentComponent, Component updatedComponent, AuditingActionEnum audatingAction) {
+ public Either<Boolean, ResponseFormat> validateAndUpdateDescription(User user, Component currentComponent, Component updatedComponent, AuditingActionEnum auditingAction) {
String descriptionUpdated = updatedComponent.getDescription();
String descriptionCurrent = currentComponent.getDescription();
if (descriptionUpdated != null && !descriptionCurrent.equals(descriptionUpdated)) {
- Either<Boolean, ResponseFormat> validateDescriptionResponse = validateDescriptionAndCleanup(user, updatedComponent, audatingAction);
+ Either<Boolean, ResponseFormat> validateDescriptionResponse = validateDescriptionAndCleanup(user, updatedComponent, auditingAction);
if (validateDescriptionResponse.isRight()) {
ResponseFormat errorRespons = validateDescriptionResponse.right().value();
return Either.right(errorRespons);
@@ -977,8 +979,12 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
}
protected <T extends Component> Either<Resource, ResponseFormat> fetchAndSetDerivedFromGenericType(T component){
-
- String genericTypeToscaName = component.fetchGenericTypeToscaNameFromConfig();
+ String genericTypeToscaName = null;
+ if(component.getComponentType() == ComponentTypeEnum.RESOURCE && ((Resource)component).getResourceType() == ResourceTypeEnum.CVFC){
+ genericTypeToscaName = ((Resource)component).getDerivedFrom().get(0);
+ } else {
+ genericTypeToscaName = component.fetchGenericTypeToscaNameFromConfig();
+ }
if(null == genericTypeToscaName)
return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
Either<Resource, StorageOperationStatus> findLatestGeneric = toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(genericTypeToscaName);
@@ -1237,6 +1243,14 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
}
return isMatchingType;
}
+
+ protected String cleanUpText(String text){
+ text = ValidationUtils.removeNoneUtf8Chars(text);
+ text = ValidationUtils.normaliseWhitespace(text);
+ text = ValidationUtils.stripOctets(text);
+ text = ValidationUtils.removeHtmlTagsOnly(text);
+ return text;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index 5da416ec0b..56cd91d754 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -58,10 +58,12 @@ import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.GroupInstance;
+import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.PropertyDefinition.PropertyNames;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.IComponentInstanceOperation;
@@ -72,6 +74,7 @@ import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
import org.openecomp.sdc.be.resources.data.PropertyValueData;
+import org.openecomp.sdc.be.tosca.ToscaUtils;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.api.Constants;
@@ -142,9 +145,9 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
containerComponent = validateComponentExists.left().value();
}
- Either<Boolean, ResponseFormat> validateAllowedToContainCompInstances = validateAllowedToContainCompInstances(containerComponent);
- if (validateAllowedToContainCompInstances.isRight()) {
- return Either.right(validateAllowedToContainCompInstances.right().value());
+ if (ToscaUtils.isAtomicType(containerComponent)) {
+ log.debug("Cannot attach resource instances to container resource of type {}", containerComponent.assetType());
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESOURCE_CANNOT_CONTAIN_RESOURCE_INSTANCES, containerComponent.assetType()));
}
Either<Boolean, ResponseFormat> validateCanWorkOnComponent = validateCanWorkOnComponent(containerComponent, userId);
@@ -201,9 +204,9 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
org.openecomp.sdc.be.model.Component containerComponent = validateComponentExists.left().value();
- Either<Boolean, ResponseFormat> validateAllowedToContainCompInstances = validateAllowedToContainCompInstances(containerComponent);
- if (validateAllowedToContainCompInstances.isRight()) {
- return Either.right(validateAllowedToContainCompInstances.right().value());
+ if (ToscaUtils.isAtomicType(containerComponent)) {
+ log.debug("Cannot attach resource instances to container resource of type {}", containerComponent.assetType());
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESOURCE_CANNOT_CONTAIN_RESOURCE_INSTANCES, containerComponent.assetType()));
}
Either<Boolean, ResponseFormat> validateCanWorkOnComponent = validateCanWorkOnComponent(containerComponent, userId);
@@ -620,6 +623,7 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
Optional<ComponentInstance> componentInstanceOptional = null;
Either<ImmutablePair<Component, String>, StorageOperationStatus> updateRes = null;
ComponentInstance oldComponentInstance = null;
+ boolean isNameChanged = false;
if (resultOp == null) {
componentInstanceOptional = containerComponent.getComponentInstances().stream().filter(ci -> ci.getUniqueId().equals(componentInstance.getUniqueId())).findFirst();
@@ -631,6 +635,9 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (resultOp == null) {
oldComponentInstance = componentInstanceOptional.get();
String newInstanceName = componentInstance.getName();
+ if ( oldComponentInstance!=null && oldComponentInstance.getName() != null
+ && !oldComponentInstance.getName().equals( newInstanceName ) )
+ isNameChanged = true;
Boolean isUniqueName = validateInstanceNameUniquenessUponUpdate(containerComponent, oldComponentInstance, newInstanceName);
if (!isUniqueName) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to update the name of the component instance {} to {}. A component instance with the same name already exists. ", oldComponentInstance.getName(), newInstanceName);
@@ -643,6 +650,14 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to update metadata of component instance {} belonging to container component {}. Status is {}. ", componentInstance.getName(), containerComponent.getName(),
updateRes.right().value());
resultOp = Either.right(componentsUtils.getResponseFormatForResourceInstance(componentsUtils.convertFromStorageResponseForResourceInstance(updateRes.right().value(), true), "", null));
+ }else{
+ //region - Update instance Groups
+ if ( isNameChanged ){
+ Either result = toscaOperationFacade.cleanAndAddGroupInstancesToComponentInstance( containerComponent ,oldComponentInstance ,componentInstanceId );
+ if ( result.isRight() )
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to rename group instances for container {}. error {} ", componentInstanceId ,result.right().value() );
+ }
+ //endregion
}
}
if (resultOp == null) {
@@ -662,11 +677,29 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
return resultOp;
}
+ /**
+ * @param oldPrefix- The normalized old vf name
+ * @param newNormailzedPrefix- The normalized new vf name
+ * @param qualifiedGroupInstanceName- old Group Instance Name
+ **/
+ //modify group names
+ private String getNewGroupName( String oldPrefix ,String newNormailzedPrefix , String qualifiedGroupInstanceName){
+ if (qualifiedGroupInstanceName == null){
+ log.info("CANNOT change group name ");
+ return null;
+ }
+ if (qualifiedGroupInstanceName.startsWith(oldPrefix) || qualifiedGroupInstanceName.startsWith(ValidationUtils.normalizeComponentInstanceName(oldPrefix)))
+ return qualifiedGroupInstanceName.replaceFirst(oldPrefix, newNormailzedPrefix);
+ return qualifiedGroupInstanceName;
+ }
private ComponentInstance updateComponentInstanceMetadata(ComponentInstance oldComponentInstance, ComponentInstance newComponentInstance) {
oldComponentInstance.setName(newComponentInstance.getName());
oldComponentInstance.setModificationTime(System.currentTimeMillis());
oldComponentInstance.setCustomizationUUID(UUID.randomUUID().toString());
+ if ( oldComponentInstance.getGroupInstances() != null )
+ oldComponentInstance.getGroupInstances().forEach( group ->
+ group.setName( getNewGroupName( oldComponentInstance.getNormalizedName() , ValidationUtils.normalizeComponentInstanceName( newComponentInstance.getName() ) , group.getName() ) ) );
return oldComponentInstance;
}
@@ -748,6 +781,17 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
resultOp = Either.right(componentsUtils.getResponseFormat(status, componentInstanceId));
}
}
+ if(resultOp.isLeft() && CollectionUtils.isNotEmpty(containerComponent.getInputs())){
+ List<InputDefinition> inputsToDelete = containerComponent.getInputs().stream().filter(i -> i.getInstanceUniqueId() != null && i.getInstanceUniqueId().equals(componentInstanceId)).collect(Collectors.toList());
+ if(CollectionUtils.isNotEmpty(inputsToDelete)){
+ StorageOperationStatus deleteInputsRes =
+ toscaOperationFacade.deleteComponentInstanceInputsFromTopologyTemplate(containerComponent, containerComponent.getComponentType(), inputsToDelete);
+ if(deleteInputsRes != StorageOperationStatus.OK){
+ log.debug("Failed to delete inputs of the component instance {} from container component. ", componentInstanceId);
+ resultOp = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(deleteInputsRes, containerComponentType), componentInstanceId));
+ }
+ }
+ }
return resultOp;
}
@@ -1696,8 +1740,6 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
}
- protected abstract Either<Boolean, ResponseFormat> validateAllowedToContainCompInstances(org.openecomp.sdc.be.model.Component containerComponent);
-
protected abstract NodeTypeEnum getNodeTypeOfComponentInstanceOrigin();
protected abstract ComponentTypeEnum getComponentTypeOfComponentInstance();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
index 669b84f229..7214d011e0 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
@@ -20,19 +20,10 @@
package org.openecomp.sdc.be.components.impl;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
+import com.thinkaurelius.titan.core.TitanGraph;
+import fj.data.Either;
import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
@@ -47,24 +38,10 @@ import org.openecomp.sdc.be.datamodel.api.CategoryTypeEnum;
import org.openecomp.sdc.be.datamodel.utils.NodeTypeConvertUtils;
import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum;
+import org.openecomp.sdc.be.datatypes.enums.*;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.ArtifactType;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.DistributionStatusEnum;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.PropertyScope;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.ResourceMetadataDefinition;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.Tag;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.GroupingDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
@@ -87,9 +64,10 @@ import org.openecomp.sdc.exception.ResponseFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.thinkaurelius.titan.core.TitanGraph;
-
-import fj.data.Either;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
@org.springframework.stereotype.Component("elementsBusinessLogic")
public class ElementBusinessLogic extends BaseBusinessLogic {
@@ -1003,16 +981,16 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
return elementOperation.getDefaultHeatTimeout();
}
- public Either<Map<String, List<? extends Component>>, ResponseFormat> getCatalogComponents(String userId) {
+ public Either<Map<String, List<? extends Component>>, ResponseFormat> getCatalogComponents(String userId, List<OriginTypeEnum> excludeTypes) {
Either<User, ResponseFormat> resp = validateUserExists(userId, "get Catalog Components", false);
if (resp.isRight()) {
return Either.right(resp.right().value());
}
Map<String, List<? extends Component>> resMap = new HashMap<>();
- Either<List<Resource>, StorageOperationStatus> resResources = toscaOperationFacade.getCatalogComponents(ComponentTypeEnum.RESOURCE, true);
+ Either<List<Resource>, StorageOperationStatus> resResources = toscaOperationFacade.getCatalogComponents(ComponentTypeEnum.RESOURCE,excludeTypes, true);
if (resResources.isLeft()) {
- Either<List<Service>, StorageOperationStatus> resServices = toscaOperationFacade.getCatalogComponents(ComponentTypeEnum.SERVICE, true);
+ Either<List<Service>, StorageOperationStatus> resServices = toscaOperationFacade.getCatalogComponents(ComponentTypeEnum.SERVICE,excludeTypes, true);
if (resServices.isLeft()) {
// Either<List<Product>, StorageOperationStatus> resProducts = productOperation.getProductCatalogData(false);
// if (resProducts.isLeft()) {
@@ -1041,7 +1019,7 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
}
if (filters == null || filters.isEmpty()) {
- Either<List<Component>, StorageOperationStatus> componentsList = toscaOperationFacade.getCatalogComponents(assetTypeEnum, false);
+ Either<List<Component>, StorageOperationStatus> componentsList = toscaOperationFacade.getCatalogComponents(assetTypeEnum,null, false);
if(componentsList.isRight()) {
return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(componentsList.right().value())));
}
@@ -1134,15 +1112,15 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
log.debug("getCatalogComponentsByUuidAndAssetType: Corresponding ComponentTypeEnum not allowed for this API");
return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
}
-
+
Either<List<Component>, StorageOperationStatus> componentsListByUuid = toscaOperationFacade.getComponentListByUuid(uuid, additionalPropertiesToMatch);
if(componentsListByUuid.isRight()) {
- log.debug("getCatalogComponentsByUuidAndAssetType: Service fetching failed");
- ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(componentsListByUuid.right().value(), ComponentTypeEnum.SERVICE);
+ log.debug("getCatalogComponentsByUuidAndAssetType: " + assetTypeEnum.getValue()+ " fetching failed");
+ ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(componentsListByUuid.right().value(), assetTypeEnum);
return Either.right(componentsUtils.getResponseFormat(actionStatus, uuid));
}
-
- log.debug("getCatalogComponentsByUuidAndAssetType: " + assetTypeEnum.getValue() + "Service fetching successful");
+
+ log.debug("getCatalogComponentsByUuidAndAssetType: " + assetTypeEnum.getValue() + assetTypeEnum.getValue() + "fetching successful");
return Either.left(componentsListByUuid.left().value());
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
index f298b0f203..a3d590374f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
@@ -359,7 +359,7 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
* @param inTransaction
* @return
*/
- public Either<GroupDefinition, ResponseFormat> validateAndUpdateGroupMetadata(String componentId, User user, ComponentTypeEnum componentType, GroupDefinition updatedGroup, boolean inTransaction) {
+ public Either<GroupDefinition, ResponseFormat> validateAndUpdateGroupMetadata(String componentId, User user, ComponentTypeEnum componentType, GroupDefinition updatedGroup, boolean inTransaction , boolean shouldLock) {
Either<GroupDefinition, ResponseFormat> result = null;
try {
@@ -396,10 +396,12 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
return result;
}
GroupDefinition currentGroup = currentGroupOpt.get();
- Either<Boolean, ResponseFormat> lockResult = lockComponent(componentId, component, "Update GroupDefinition Metadata");
- if (lockResult.isRight()) {
- result = Either.right(lockResult.right().value());
- return result;
+ if ( shouldLock ){
+ Either<Boolean, ResponseFormat> lockResult = lockComponent(componentId, component, "Update GroupDefinition Metadata");
+ if (lockResult.isRight()) {
+ result = Either.right(lockResult.right().value());
+ return result;
+ }
}
// Validate group type is vfModule
if (!currentGroup.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)) {
@@ -417,7 +419,8 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
} else {
titanDao.rollback();
}
- graphLockOperation.unlockComponent(componentId, componentType.getNodeType());
+ if( shouldLock )
+ graphLockOperation.unlockComponent(componentId, componentType.getNodeType());
}
}
@@ -734,7 +737,7 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
String nameUpdated = groupUpdate.getName();
String nameCurrent = currentGroup.getName();
if (!nameCurrent.equals(nameUpdated)) {
- Either<Boolean, ResponseFormat> validatNameResponse = validateGroupName(currentGroup.getName(), groupUpdate.getName());
+ Either<Boolean, ResponseFormat> validatNameResponse = validateGroupName(currentGroup.getName(), groupUpdate.getName() ,true);
if (validatNameResponse.isRight()) {
ResponseFormat errorRespons = validatNameResponse.right().value();
return Either.right(errorRespons);
@@ -752,7 +755,7 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
* @param groupUpdateName
* @return
*/
- private Either<Boolean, ResponseFormat> validateGroupName(String currentGroupName, String groupUpdateName) {
+ private Either<Boolean, ResponseFormat> validateGroupName(String currentGroupName, String groupUpdateName , boolean isforceNameModification) {
try {
// Check if the group name is in old format.
if (Pattern.compile(Constants.MODULE_OLD_NAME_PATTERN).matcher(groupUpdateName).matches()) {
@@ -771,14 +774,16 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
String[] split2 = groupUpdateName.split("\\.\\.");
String groupUpdateResourceName = split2[0];
String groupUpdateCounter = split2[2];
+ if (!isforceNameModification){ //if not forced ,allow name prefix&suffix validation [no changes]
+ if (!currentResourceName.equals(groupUpdateResourceName)) {
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_VF_MODULE_NAME_MODIFICATION, currentResourceName));
+ }
- if (!currentResourceName.equals(groupUpdateResourceName)) {
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_VF_MODULE_NAME_MODIFICATION, currentResourceName));
+ if (!currentCounter.equals(groupUpdateCounter)) {
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_VF_MODULE_NAME_MODIFICATION, currentCounter));
+ }
}
- if (!currentCounter.equals(groupUpdateCounter)) {
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_VF_MODULE_NAME_MODIFICATION, currentCounter));
- }
}
return Either.left(true);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/HealthCheckBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/HealthCheckBusinessLogic.java
index e535214d70..8a8937740f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/HealthCheckBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/HealthCheckBusinessLogic.java
@@ -20,7 +20,10 @@
package org.openecomp.sdc.be.components.impl;
+import java.io.IOException;
+import java.lang.reflect.Type;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -34,16 +37,23 @@ import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
-import javax.servlet.ServletContext;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
import org.openecomp.sdc.be.components.distribution.engine.DistributionEngineClusterHealth;
import org.openecomp.sdc.be.components.distribution.engine.UebHealthCheckCall;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
+import org.openecomp.sdc.be.config.Configuration;
+import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.IEsHealthCheckDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.switchover.detector.SwitchoverDetector;
-import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.api.HealthCheckInfo;
import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckComponent;
import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus;
@@ -52,7 +62,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import org.springframework.web.context.WebApplicationContext;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
@Component("healthCheckBusinessLogic")
public class HealthCheckBusinessLogic {
@@ -62,6 +74,7 @@ public class HealthCheckBusinessLogic {
private static Logger healthLogger = LoggerFactory.getLogger(BE_HEALTH_LOG_CONTEXT);
private static final String BE_HEALTH_CHECK_STR = "beHealthCheck";
+ private static final String COMPONENT_CHANGED_MESSAGE = "BE Component %s state changed from %s to %s";
@Resource
private TitanGenericDao titanGenericDao;
@@ -72,15 +85,16 @@ public class HealthCheckBusinessLogic {
@Resource
private DistributionEngineClusterHealth distributionEngineClusterHealth;
+ @Resource
+ private CassandraHealthCheck cassandraHealthCheck;
+
@Autowired
private SwitchoverDetector switchoverDetector;
private static Logger log = LoggerFactory.getLogger(HealthCheckBusinessLogic.class.getName());
- private volatile List<HealthCheckInfo> lastBeHealthCheckInfos = null;
+ private volatile List<HealthCheckInfo> prevBeHealthCheckInfos = null;
- // private static volatile HealthCheckBusinessLogic instance;
- //
public HealthCheckBusinessLogic() {
}
@@ -99,9 +113,9 @@ public class HealthCheckBusinessLogic {
@PostConstruct
public void init() {
- lastBeHealthCheckInfos = getBeHealthCheckInfos();
+ prevBeHealthCheckInfos = getBeHealthCheckInfos();
- log.debug("After initializing lastBeHealthCheckInfos: {}", lastBeHealthCheckInfos);
+ log.debug("After initializing prevBeHealthCheckInfos: {}", prevBeHealthCheckInfos);
healthCheckScheduledTask = new HealthCheckScheduledTask();
@@ -111,115 +125,9 @@ public class HealthCheckBusinessLogic {
}
- //
- // public static HealthCheckBusinessLogic getInstance(){
- //// if (instance == null){
- //// instance = init();
- //// }
- // return instance;
- // }
-
- // private synchronized static HealthCheckBusinessLogic init() {
- // if (instance == null){
- // instance = new HealthCheckBusinessLogic();
- // }
- // return instance;
- // }
-
- private List<HealthCheckInfo> getBeHealthCheckInfos(ServletContext servletContext) {
-
- List<HealthCheckInfo> healthCheckInfos = new ArrayList<HealthCheckInfo>();
-
- // BE
- getBeHealthCheck(servletContext, healthCheckInfos);
-
- // ES
- getEsHealthCheck(servletContext, healthCheckInfos);
-
- // Titan
- getTitanHealthCheck(servletContext, healthCheckInfos);
-
- // Distribution Engine
- getDistributionEngineCheck(servletContext, healthCheckInfos);
-
- return healthCheckInfos;
- }
-
- private List<HealthCheckInfo> getBeHealthCheck(ServletContext servletContext, List<HealthCheckInfo> healthCheckInfos) {
- String appVersion = ExternalConfiguration.getAppVersion();
- String description = "OK";
- healthCheckInfos.add(new HealthCheckInfo(HealthCheckComponent.BE, HealthCheckStatus.UP, appVersion, description));
- return healthCheckInfos;
- }
-
- public List<HealthCheckInfo> getTitanHealthCheck(ServletContext servletContext, List<HealthCheckInfo> healthCheckInfos) {
- // Titan health check and version
- TitanGenericDao titanStatusDao = (TitanGenericDao) getDao(servletContext, TitanGenericDao.class);
- String description;
- boolean isTitanUp;
-
- try {
- isTitanUp = titanStatusDao.isGraphOpen();
- } catch (Exception e) {
- description = "Titan error: " + e.getMessage();
- healthCheckInfos.add(new HealthCheckInfo(HealthCheckComponent.TITAN, HealthCheckStatus.DOWN, null, description));
- return healthCheckInfos;
- }
- if (isTitanUp) {
- description = "OK";
- healthCheckInfos.add(new HealthCheckInfo(HealthCheckComponent.TITAN, HealthCheckStatus.UP, null, description));
- } else {
- description = "Titan graph is down";
- healthCheckInfos.add(new HealthCheckInfo(HealthCheckComponent.TITAN, HealthCheckStatus.DOWN, null, description));
- }
- return healthCheckInfos;
- }
-
- public List<HealthCheckInfo> getEsHealthCheck(ServletContext servletContext, List<HealthCheckInfo> healthCheckInfos) {
-
- // ES health check and version
- IEsHealthCheckDao esStatusDao = (IEsHealthCheckDao) getDao(servletContext, IEsHealthCheckDao.class);
- HealthCheckStatus healthCheckStatus;
- String description;
-
- try {
- healthCheckStatus = esStatusDao.getClusterHealthStatus();
- } catch (Exception e) {
- healthCheckStatus = HealthCheckStatus.DOWN;
- description = "ES cluster error: " + e.getMessage();
- healthCheckInfos.add(new HealthCheckInfo(HealthCheckComponent.ES, healthCheckStatus, null, description));
- return healthCheckInfos;
- }
- if (healthCheckStatus.equals(HealthCheckStatus.DOWN)) {
- description = "ES cluster is down";
- } else {
- description = "OK";
- }
- healthCheckInfos.add(new HealthCheckInfo(HealthCheckComponent.ES, healthCheckStatus, null, description));
- return healthCheckInfos;
- }
-
- public Object getDao(ServletContext servletContext, Class<?> clazz) {
- WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR);
-
- WebApplicationContext webApplicationContext = webApplicationContextWrapper.getWebAppContext(servletContext);
-
- return webApplicationContext.getBean(clazz);
- }
-
- private void getDistributionEngineCheck(ServletContext servletContext, List<HealthCheckInfo> healthCheckInfos) {
-
- DistributionEngineClusterHealth deDao = (DistributionEngineClusterHealth) getDao(servletContext, DistributionEngineClusterHealth.class);
- HealthCheckInfo healthCheckInfo = deDao.getHealthCheckInfo();
+ public boolean isDistributionEngineUp() {
- healthCheckInfos.add(healthCheckInfo);
-
- }
-
- public boolean isDistributionEngineUp(ServletContext servletContext) {
-
- DistributionEngineClusterHealth deDao = (DistributionEngineClusterHealth) getDao(servletContext, DistributionEngineClusterHealth.class);
- HealthCheckInfo healthCheckInfo = deDao.getHealthCheckInfo();
+ HealthCheckInfo healthCheckInfo = distributionEngineClusterHealth.getHealthCheckInfo();
if (healthCheckInfo.getHealthCheckStatus().equals(HealthCheckStatus.DOWN)) {
return false;
}
@@ -228,7 +136,7 @@ public class HealthCheckBusinessLogic {
public List<HealthCheckInfo> getBeHealthCheckInfosStatus() {
- return lastBeHealthCheckInfos;
+ return prevBeHealthCheckInfos;
}
@@ -241,8 +149,8 @@ public class HealthCheckBusinessLogic {
// BE
getBeHealthCheck(healthCheckInfos);
- // ES
- getEsHealthCheck(healthCheckInfos);
+ /*// ES
+ getEsHealthCheck(healthCheckInfos);*/
// Titan
getTitanHealthCheck(healthCheckInfos);
@@ -250,6 +158,12 @@ public class HealthCheckBusinessLogic {
// Distribution Engine
getDistributionEngineCheck(healthCheckInfos);
+ //Cassandra
+ getCassandraHealthCheck(healthCheckInfos);
+
+ // Amdocs
+ getAmdocsHealthCheck(healthCheckInfos);
+
return healthCheckInfos;
}
@@ -260,7 +174,8 @@ public class HealthCheckBusinessLogic {
return healthCheckInfos;
}
- public List<HealthCheckInfo> getEsHealthCheck(List<HealthCheckInfo> healthCheckInfos) {
+ //Removed from aggregate HC - TDP 293490
+/* private List<HealthCheckInfo> getEsHealthCheck(List<HealthCheckInfo> healthCheckInfos) {
// ES health check and version
HealthCheckStatus healthCheckStatus;
@@ -282,7 +197,7 @@ public class HealthCheckBusinessLogic {
healthCheckInfos.add(new HealthCheckInfo(HealthCheckComponent.ES, healthCheckStatus, null, description));
return healthCheckInfos;
}
-
+*/
public List<HealthCheckInfo> getTitanHealthCheck(List<HealthCheckInfo> healthCheckInfos) {
// Titan health check and version
String description;
@@ -305,6 +220,28 @@ public class HealthCheckBusinessLogic {
return healthCheckInfos;
}
+ private List<HealthCheckInfo> getCassandraHealthCheck(List<HealthCheckInfo> healthCheckInfos) {
+
+ String description;
+ boolean isCassandraUp;
+
+ try {
+ isCassandraUp = cassandraHealthCheck.getCassandraStatus();
+ } catch (Exception e) {
+ isCassandraUp = false;
+ description = "Cassandra error: " + e.getMessage();
+ }
+ if (isCassandraUp) {
+ description = "OK";
+ healthCheckInfos.add(new HealthCheckInfo(HealthCheckComponent.CASSANDRA, HealthCheckStatus.UP, null, description));
+ } else {
+ description = "Cassandra is down";
+ healthCheckInfos.add(new HealthCheckInfo(HealthCheckComponent.CASSANDRA, HealthCheckStatus.DOWN, null, description));
+ }
+ return healthCheckInfos;
+
+ }
+
private void getDistributionEngineCheck(List<HealthCheckInfo> healthCheckInfos) {
HealthCheckInfo healthCheckInfo = distributionEngineClusterHealth.getHealthCheckInfo();
@@ -313,6 +250,76 @@ public class HealthCheckBusinessLogic {
}
+ private List<HealthCheckInfo> getAmdocsHealthCheck(List<HealthCheckInfo> healthCheckInfos) {
+ HealthCheckStatus healthCheckStatus;
+ String description;
+ Map<String, Object> amdocsHC = null;
+ String version = null;
+ List<HealthCheckInfo> componentsInfo = null;
+ CloseableHttpClient httpClient = getHttpClient();
+ String amdocsHealtchCheckUrl = buildHealthCheckUrl();
+ HttpGet httpGet = new HttpGet(amdocsHealtchCheckUrl);
+ CloseableHttpResponse beResponse;
+ int beStatus;
+ try {
+ beResponse = httpClient.execute(httpGet);
+ beStatus = beResponse.getStatusLine().getStatusCode();
+
+ HttpEntity entity = beResponse.getEntity();
+ String beJsonResponse = EntityUtils.toString(entity);
+ Gson gson = new Gson();
+ amdocsHC = gson.fromJson(beJsonResponse, Map.class);
+ version = amdocsHC.get("sdcVersion") != null ? amdocsHC.get("sdcVersion").toString() : null;
+ Object object = amdocsHC.get("componentsInfo");
+ Type listType = new TypeToken<List<HealthCheckInfo>>(){}.getType();
+ componentsInfo = gson.fromJson(object.toString(), listType);
+
+ if (beStatus != HttpStatus.SC_OK) {
+ healthCheckStatus = HealthCheckStatus.DOWN;
+ StringBuilder sb = new StringBuilder();
+ componentsInfo.forEach(x -> {
+ if (x.getHealthCheckStatus()==HealthCheckStatus.DOWN){
+ sb.append("Component "+x.getHealthCheckComponent().name()+" is Down,");
+ }
+ });
+ //Removing the last comma
+ description = sb.length()>0
+ ? sb.substring(0, sb.length()-1)
+ : "Onboarding is Down, specific reason unknown";//No Amdocs inner component returned DOWN, but the status of Amdocs HC is still DOWN.
+ } else {
+ healthCheckStatus = HealthCheckStatus.UP;
+ description = "OK";
+
+
+ }
+
+ } catch (Exception e) {
+ healthCheckStatus = HealthCheckStatus.DOWN;
+ description = "Onboarding unexpected response: " + e.getMessage();
+ } finally {
+ if (httpClient != null) {
+ try {
+ httpClient.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ healthCheckInfos.add(new HealthCheckInfo(HealthCheckComponent.ON_BOARDING, healthCheckStatus, version, description, componentsInfo));
+ return healthCheckInfos;
+ }
+
+ private CloseableHttpClient getHttpClient() {
+ int timeout = 3000;
+ RequestConfig.Builder requestBuilder = RequestConfig.custom();
+ requestBuilder.setConnectTimeout(timeout).setConnectionRequestTimeout(timeout).setSocketTimeout(timeout);
+
+ HttpClientBuilder builder = HttpClientBuilder.create();
+ builder.setDefaultRequestConfig(requestBuilder.build());
+ return builder.build();
+ }
+
@PreDestroy
private void destroy() {
@@ -340,101 +347,127 @@ public class HealthCheckBusinessLogic {
healthLogger.trace("Executing BE Health Check Task");
- List<HealthCheckInfo> beHealthCheckInfos = getBeHealthCheckInfos();
- boolean healthStatus = getAggregateBeStatus(beHealthCheckInfos);
+ List<HealthCheckInfo> currentBeHealthCheckInfos = getBeHealthCheckInfos();
+ boolean healthStatus = getAggregateBeStatus(currentBeHealthCheckInfos);
+
+ boolean prevHealthStatus = getAggregateBeStatus(prevBeHealthCheckInfos);
- boolean lastHealthStatus = getAggregateBeStatus(lastBeHealthCheckInfos);
+ boolean anyStatusChanged = anyStatusChanged(currentBeHealthCheckInfos, prevBeHealthCheckInfos);
- if (lastHealthStatus != healthStatus) {
+ if (prevHealthStatus != healthStatus || anyStatusChanged) {
log.trace("BE Health State Changed to {}. Issuing alarm / recovery alarm...", healthStatus);
- lastBeHealthCheckInfos = beHealthCheckInfos;
+ prevBeHealthCheckInfos = currentBeHealthCheckInfos;
logAlarm(healthStatus);
+ }
- } else {
- // check if we need to update the status's list in case one of
- // the statuses was changed
- if (true == anyStatusChanged(beHealthCheckInfos, lastBeHealthCheckInfos)) {
- lastBeHealthCheckInfos = beHealthCheckInfos;
- }
+ }
- }
+ private boolean getAggregateBeStatus(List<HealthCheckInfo> beHealthCheckInfos) {
+
+ boolean status = true;
+ for (HealthCheckInfo healthCheckInfo : beHealthCheckInfos) {
+ if (healthCheckInfo.getHealthCheckStatus().equals(HealthCheckStatus.DOWN) && healthCheckInfo.getHealthCheckComponent() != HealthCheckComponent.DE) {
+ status = false;
+ break;
+ }
+ }
+ return status;
}
}
- private void logAlarm(boolean lastHealthState) {
- if (lastHealthState == true) {
+ private void logAlarm(boolean prevHealthState) {
+ if (prevHealthState) {
BeEcompErrorManager.getInstance().logBeHealthCheckRecovery(BE_HEALTH_CHECK_STR);
} else {
BeEcompErrorManager.getInstance().logBeHealthCheckError(BE_HEALTH_CHECK_STR);
}
}
- private boolean getAggregateBeStatus(List<HealthCheckInfo> beHealthCheckInfos) {
-
- boolean status = true;
-
- for (HealthCheckInfo healthCheckInfo : beHealthCheckInfos) {
- if (healthCheckInfo.getHealthCheckStatus().equals(HealthCheckStatus.DOWN) && healthCheckInfo.getHealthCheckComponent() != HealthCheckComponent.DE) {
- status = false;
- break;
- }
- }
- return status;
+ private void logAlarm(String componentChangedMsg) {
+ BeEcompErrorManager.getInstance().logBeHealthCheckRecovery(componentChangedMsg);
}
+
public String getSiteMode() {
return switchoverDetector.getSiteMode();
}
- public boolean anyStatusChanged(List<HealthCheckInfo> beHealthCheckInfos, List<HealthCheckInfo> lastBeHealthCheckInfos) {
+ public boolean anyStatusChanged(List<HealthCheckInfo> beHealthCheckInfos, List<HealthCheckInfo> prevBeHealthCheckInfos) {
boolean result = false;
- if (beHealthCheckInfos != null && lastBeHealthCheckInfos != null) {
+ if (beHealthCheckInfos != null && prevBeHealthCheckInfos != null) {
Map<HealthCheckComponent, HealthCheckStatus> currentValues = beHealthCheckInfos.stream().collect(Collectors.toMap(p -> p.getHealthCheckComponent(), p -> p.getHealthCheckStatus()));
- Map<HealthCheckComponent, HealthCheckStatus> lastValues = lastBeHealthCheckInfos.stream().collect(Collectors.toMap(p -> p.getHealthCheckComponent(), p -> p.getHealthCheckStatus()));
+ Map<HealthCheckComponent, HealthCheckStatus> prevValues = prevBeHealthCheckInfos.stream().collect(Collectors.toMap(p -> p.getHealthCheckComponent(), p -> p.getHealthCheckStatus()));
- if (currentValues != null && lastValues != null) {
+ if (currentValues != null && prevValues != null) {
int currentSize = currentValues.size();
- int lastSize = lastValues.size();
+ int prevSize = prevValues.size();
+
+ if (currentSize != prevSize) {
+
+ result = true; //extra/missing component
+
+ Map<HealthCheckComponent, HealthCheckStatus> notPresent = null;
+ if (currentValues.keySet().containsAll(prevValues.keySet())) {
+ notPresent = new HashMap<>(currentValues);
+ notPresent.keySet().removeAll(prevValues.keySet());
+ } else {
+ notPresent = new HashMap<>(prevValues);
+ notPresent.keySet().removeAll(currentValues.keySet());
+ }
+
+ for (HealthCheckComponent component : notPresent.keySet()) {
+ logAlarm(String.format(COMPONENT_CHANGED_MESSAGE, component, prevValues.get(component), currentValues.get(component)));
+ }
+ // HealthCheckComponent changedComponent = notPresent.keySet().iterator().next();
- if (currentSize != lastSize) {
- result = true;
} else {
for (Entry<HealthCheckComponent, HealthCheckStatus> entry : currentValues.entrySet()) {
HealthCheckComponent key = entry.getKey();
HealthCheckStatus value = entry.getValue();
- if (false == lastValues.containsKey(key)) {
- result = true;
+ if (!prevValues.containsKey(key)) {
+ result = true; //component missing
+ logAlarm(String.format(COMPONENT_CHANGED_MESSAGE, key, prevValues.get(key), currentValues.get(key)));
break;
}
- HealthCheckStatus lastHealthCheckStatus = lastValues.get(key);
+ HealthCheckStatus prevHealthCheckStatus = prevValues.get(key);
- if (value != lastHealthCheckStatus) {
- result = true;
+ if (value != prevHealthCheckStatus) {
+ result = true; //component status changed
+ logAlarm(String.format(COMPONENT_CHANGED_MESSAGE, key, prevValues.get(key), currentValues.get(key)));
break;
}
}
}
- } else if (currentValues == null && lastValues == null) {
- result = false;
- } else {
- result = true;
}
- } else if (beHealthCheckInfos == null && lastBeHealthCheckInfos == null) {
+ } else if (beHealthCheckInfos == null && prevBeHealthCheckInfos == null) {
result = false;
} else {
+ logAlarm(String.format(COMPONENT_CHANGED_MESSAGE, "", prevBeHealthCheckInfos == null ? "null" : "true", prevBeHealthCheckInfos == null ? "true" : "null"));
result = true;
}
return result;
}
+
+ private String buildHealthCheckUrl() {
+
+ Configuration.OnboardingConfig onboardingConfig = ConfigurationManager.getConfigurationManager().getConfiguration().getOnboarding();
+
+ String protocol = onboardingConfig.getProtocol();
+ String host = onboardingConfig.getHost();
+ Integer port = onboardingConfig.getPort();
+ String uri = onboardingConfig.getHealthCheckUri();
+
+ return protocol + "://" + host + ":" + port + uri;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
index cded9ee706..c85520dbe4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
@@ -107,6 +107,7 @@ public final class ImportUtils {
public static final List<String> TOSCA_DEFINITION_VERSIONS = Arrays.asList(new String[] { "tosca_simple_yaml_1_0_0", "tosca_simple_profile_for_nfv_1_0_0", "tosca_simple_yaml_1_0" });
public static final List<String> TOSCA_YML_CSAR_VALID_SUFFIX = Arrays.asList(new String[] { ".yml", ".yaml", ".csar" });
public static final String UI_JSON_PAYLOAD_NAME = "payloadName";
+ public static final String CVFC_DESCRIPTION = "Complex node type that is used as nested type in VF";
}
public enum ResultStatusEnum {
@@ -133,6 +134,7 @@ public final class ImportUtils {
PARAMETERS("parameters"),
// Import Validations
TOSCA_VERSION("tosca_definitions_version"), TOPOLOGY_TEMPLATE("topology_template"), NODE_TYPES("node_types"), OCCURRENCES("occurrences"), NODE_TEMPLATES("node_templates"), GROUPS("groups"), INPUTS("inputs"),
+ SUBSTITUTION_MAPPINGS("substitution_mappings"), NODE_TYPE("node_type"),
// Attributes
ATTRIBUTES("attributes"), LABEL("label"), HIDDEN("hidden"), IMMUTABLE("immutable"), GET_INPUT("get_input");
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index d6497b58ea..f85e25e5fb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -456,47 +456,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
resList = result.left().value();
- /*int index = 0;
- for (Entry<String, List<InputDefinition>> entry : newInputsMap.entrySet()) {
-
- String compInstId = entry.getKey();
-
- Optional<ComponentInstance> op = ciList.stream().filter(ci -> ci.getUniqueId().equals(compInstId)).findAny();
- if(!op.isPresent()){
- ActionStatus actionStatus = ActionStatus.INVALID_CONTENT;
- log.debug("Failed to find component instance {} under component {}", compInstId, componentId);
- result = Either.right(componentsUtils.getResponseFormat(actionStatus));
- return result;
- }
- ComponentInstance ci = op.get();
- String compInstname = ci.getNormalizedName();
- Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> origComponentEither = getOriginComponent(ci, origComponentMap);
- if(origComponentEither.isRight()){
- ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(origComponentEither.right().value());
- log.debug("Failed to create inputs value under component {}, error: {}", componentId, actionStatus.name());
- result = Either.right(componentsUtils.getResponseFormat(actionStatus));
- return result;
- }
- org.openecomp.sdc.be.model.Component origComponent = origComponentEither.left().value();
-
- List<InputDefinition> inputs = entry.getValue();
-
- if (inputs != null && !inputs.isEmpty()) {
-
- for (InputDefinition input : inputs) {
-
- StorageOperationStatus status = addInputsToComponent(componentId, inputsToCreate, inputsValueToCreateMap, allDataTypes.left().value(), resList, index, compInstId, compInstname, origComponent, input);
- if(status != StorageOperationStatus.OK ){
- ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(status);
- log.debug("Failed to create inputs value under component {}, error: {}", componentId, actionStatus.name());
- result = Either.right(componentsUtils.getResponseFormat(actionStatus));
- return result;
- }
-
- }
- }
-
- }*/
+
}
@@ -715,42 +675,38 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
Either<List<InputDefinition>, ResponseFormat> result = Either.left(resList);
List<InputDefinition> resourceProperties = component.getInputs();
- if(inputs != null && !inputs.isEmpty()){
- Either<Map<String, DataTypeDefinition>, ResponseFormat> allDataTypes = getAllDataTypes(applicationDataTypeCache);
- if (allDataTypes.isRight()) {
- return Either.right(allDataTypes.right().value());
- }
+ Either<Map<String, DataTypeDefinition>, ResponseFormat> allDataTypes = getAllDataTypes(applicationDataTypeCache);
+ if (allDataTypes.isRight()) {
+ return Either.right(allDataTypes.right().value());
+ }
- Map<String, DataTypeDefinition> dataTypes = allDataTypes.left().value();
+ Map<String, DataTypeDefinition> dataTypes = allDataTypes.left().value();
- for (Map.Entry<String, InputDefinition> inputDefinition : inputs.entrySet()) {
- String inputName = inputDefinition.getKey();
- inputDefinition.getValue().setName(inputName);
+ for (Map.Entry<String, InputDefinition> inputDefinition : inputs.entrySet()) {
+ String inputName = inputDefinition.getKey();
+ inputDefinition.getValue().setName(inputName);
- Either<InputDefinition, ResponseFormat> preparedInputEither = prepareAndValidateInputBeforeCreate(inputDefinition.getValue(), dataTypes);
- if(preparedInputEither.isRight()){
- return Either.right(preparedInputEither.right().value());
- }
-
- }
- if (resourceProperties != null) {
- Map<String, InputDefinition> generatedInputs = resourceProperties.stream().collect(Collectors.toMap(i -> i.getName(), i -> i));
- Either<Map<String, InputDefinition>, String> mergeEither = ToscaDataDefinition.mergeDataMaps(generatedInputs, inputs);
- if(mergeEither.isRight()){
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_ALREADY_EXIST, mergeEither.right().value()));
- }
- inputs = mergeEither.left().value();
+ Either<InputDefinition, ResponseFormat> preparedInputEither = prepareAndValidateInputBeforeCreate(inputDefinition.getValue(), dataTypes);
+ if(preparedInputEither.isRight()){
+ return Either.right(preparedInputEither.right().value());
}
- Either<List<InputDefinition>, StorageOperationStatus> assotiateInputsEither = toscaOperationFacade.createAndAssociateInputs(inputs, component.getUniqueId());
- if(assotiateInputsEither.isRight()){
- log.debug("Failed to create inputs under component {}. Status is {}", component.getUniqueId(), assotiateInputsEither.right().value());
- return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(assotiateInputsEither.right().value())));
+ }
+ if (resourceProperties != null) {
+ Map<String, InputDefinition> generatedInputs = resourceProperties.stream().collect(Collectors.toMap(i -> i.getName(), i -> i));
+ Either<Map<String, InputDefinition>, String> mergeEither = ToscaDataDefinition.mergeDataMaps(generatedInputs, inputs);
+ if(mergeEither.isRight()){
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_ALREADY_EXIST, mergeEither.right().value()));
}
- result = Either.left(assotiateInputsEither.left().value());
-
+ inputs = mergeEither.left().value();
}
+ Either<List<InputDefinition>, StorageOperationStatus> assotiateInputsEither = toscaOperationFacade.createAndAssociateInputs(inputs, component.getUniqueId());
+ if(assotiateInputsEither.isRight()){
+ log.debug("Failed to create inputs under component {}. Status is {}", component.getUniqueId(), assotiateInputsEither.right().value());
+ return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(assotiateInputsEither.right().value())));
+ }
+ result = Either.left(assotiateInputsEither.left().value());
return result;
}
@@ -901,15 +857,13 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
List<ComponentInstanceInput> inputsValue= getComponentInstanceInputsByInputId(component, inputId);
- Map<String, List<ComponentInstanceInput>> insInputsMatToDelete = new HashMap<>();
-
+
if(inputsValue != null && !inputsValue.isEmpty()){
for(ComponentInstanceInput inputValue: inputsValue){
String compInstId = inputValue.getComponentInstanceId();
prepareValueBeforeDelete(compInstId, inputForDelete, inputValue, inputValue.getPath());
status = toscaOperationFacade.updateComponentInstanceInput(component, compInstId, inputValue);
- List<ComponentInstanceInput> inputList = null;
if(status != StorageOperationStatus.OK){
log.debug("Component id: {} update component instance property {} id: {} failed", componentId, inputValue.getUniqueId(), inputId);
deleteEither = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status), component.getName()));
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductComponentInstanceBusinessLogic.java
index ab0969358c..7a7148a6a1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductComponentInstanceBusinessLogic.java
@@ -30,10 +30,6 @@ import fj.data.Either;
@Component("productComponentInstanceBusinessLogic")
public class ProductComponentInstanceBusinessLogic extends ComponentInstanceBusinessLogic {
- @Override
- protected Either<Boolean, ResponseFormat> validateAllowedToContainCompInstances(org.openecomp.sdc.be.model.Component containerComponent) {
- return Either.left(true);
- }
@Override
protected NodeTypeEnum getNodeTypeOfComponentInstanceOrigin() {
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 cc4a6d9c71..37067e6541 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
@@ -79,6 +79,7 @@ import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
@@ -86,10 +87,12 @@ import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.GroupProperty;
import org.openecomp.sdc.be.model.GroupTypeDefinition;
import org.openecomp.sdc.be.model.HeatParameterDefinition;
+import org.openecomp.sdc.be.model.ImportCsarInfo;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.NodeTypeInfo;
import org.openecomp.sdc.be.model.Operation;
import org.openecomp.sdc.be.model.ParsedToscaYamlInfo;
import org.openecomp.sdc.be.model.PropertyDefinition;
@@ -111,13 +114,11 @@ import org.openecomp.sdc.be.model.heat.HeatParameterType;
import org.openecomp.sdc.be.model.operations.api.ICacheMangerOperation;
import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
-import org.openecomp.sdc.be.model.operations.api.IHeatParametersOperation;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.IPropertyOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.CsarOperation;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
-import org.openecomp.sdc.be.model.operations.impl.InputsOperation;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
@@ -125,6 +126,7 @@ import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.servlets.RepresentationUtils;
import org.openecomp.sdc.be.tosca.CsarUtils;
import org.openecomp.sdc.be.tosca.CsarUtils.NonMetaArtifactInfo;
+import org.openecomp.sdc.be.tosca.ToscaUtils;
import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer;
import org.openecomp.sdc.be.user.IUserBusinessLogic;
import org.openecomp.sdc.be.user.Role;
@@ -203,18 +205,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
@Autowired
private InputsBusinessLogic inputsBusinessLogic;
- @javax.annotation.Resource
- private InputsOperation inputOperation;
-
- // @Autowired
- // private GroupOperation groupOperation;
-
- @Autowired
- private IHeatParametersOperation heatParametersOperation;
-
- // @Autowired
- // private IArtifactOperation artifactOperation;
-
@Autowired
private CompositionBusinessLogic compositionBusinessLogic;
@@ -290,8 +280,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
* the method returns a list of all the resources that are certified, the returned resources are only abstract or only none abstract according to the given param
*
* @param getAbstract
- * @param userId
- * TODO
+ * @param userId TODO
* @return
*/
public Either<List<Resource>, ResponseFormat> getAllCertifiedResources(boolean getAbstract, HighestFilterEnum highestFilter, String userId) {
@@ -301,16 +290,16 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
Boolean isHighest = null;
switch (highestFilter) {
- case ALL:
- break;
- case HIGHEST_ONLY:
- isHighest = true;
- break;
- case NON_HIGHEST_ONLY:
- isHighest = false;
- break;
- default:
- break;
+ case ALL:
+ break;
+ case HIGHEST_ONLY:
+ isHighest = true;
+ break;
+ case NON_HIGHEST_ONLY:
+ isHighest = false;
+ break;
+ default:
+ break;
}
Either<List<Resource>, StorageOperationStatus> getResponse = toscaOperationFacade.getAllCertifiedResources(getAbstract, isHighest);
@@ -489,7 +478,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private Either<Resource, ResponseFormat> updateResourceFromCsar(Resource oldRresource, Resource newRresource, User user, AuditingActionEnum updateResource, boolean inTransaction, Either<Map<String, byte[]>, StorageOperationStatus> csarUIPayload,
- String csarUUID) {
+ String csarUUID) {
// check state
if (LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.equals(oldRresource.getLifecycleState())) {
@@ -538,19 +527,24 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Either<Resource, ResponseFormat> result = null;
String yamlFileName = toscaYamlCsarStatus.left().value().getKey();
+ String yamlFileContents = toscaYamlCsarStatus.left().value().getValue();
Either<Map<String, Resource>, ResponseFormat> parseNodeTypeInfoYamlEither = null;
+ ImportCsarInfo importCsarInfo = new ImportCsarInfo(newRresource.getName(), user, csarUUID, csar.left().value());
+
try {
Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> prepareForUpdate = null;
Resource preparedResource = null;
- Either<ParsedToscaYamlInfo, ResponseFormat> uploadComponentInstanceInfoMap = parseResourceInfoFromYaml(yamlFileName, newRresource, toscaYamlCsarStatus.left().value().getValue(), user);
+ Either<ParsedToscaYamlInfo, ResponseFormat> uploadComponentInstanceInfoMap = parseResourceInfoFromYaml(yamlFileName, newRresource, toscaYamlCsarStatus.left().value().getValue(), user, importCsarInfo.getCreatedNodesToscaResourceNames(), null, null);
if (uploadComponentInstanceInfoMap.isRight()) {
ResponseFormat responseFormat = uploadComponentInstanceInfoMap.right().value();
componentsUtils.auditResource(responseFormat, user, newRresource, "", "", updateResource, null);
result = Either.right(responseFormat);
return result;
}
+ Map<String, NodeTypeInfo> nodeTypesInfo = extractNodeTypesInfo(csar.left().value(), yamlFileContents);
Map<String, UploadComponentInstanceInfo> instances = uploadComponentInstanceInfoMap.left().value().getInstances();
- Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandleRes = findNodeTypesArtifactsToHandle(csar.left().value(), csarUUID, yamlFileName, oldRresource, user, true, instances);
+ Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandleRes = findNodeTypesArtifactsToHandle(nodeTypesInfo, csar.left().value(), csarUUID, yamlFileName, oldRresource, user, true,
+ instances);
if (findNodeTypesArtifactsToHandleRes.isRight()) {
log.debug("failed to find node types for update with artifacts during import csar {}. ", csarUUID);
result = Either.right(findNodeTypesArtifactsToHandleRes.right().value());
@@ -567,10 +561,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
preparedResource = prepareForUpdate.left().value().left;
- String yamlFileContents = toscaYamlCsarStatus.left().value().getValue();
log.trace("YAML topology file found in CSAR, file name: {}, contents: {}", yamlFileName, yamlFileContents);
- parseNodeTypeInfoYamlEither = this.handleNodeTypes(yamlFileName, preparedResource, user, yamlFileContents, csar.left().value(), false, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts);
+ parseNodeTypeInfoYamlEither = this.handleNodeTypes(yamlFileName, preparedResource, yamlFileContents, false, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, importCsarInfo);
if (parseNodeTypeInfoYamlEither.isRight()) {
ResponseFormat responseFormat = parseNodeTypeInfoYamlEither.right().value();
componentsUtils.auditResource(responseFormat, user, preparedResource, "", "", updateResource, null);
@@ -638,7 +631,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
preparedResource = dataModelResponse.left().value();
}
- Either<Resource, ResponseFormat> createdCsarArtifactsEither = handleCsarArtifacts(preparedResource, user, csarUUID, csar.left().value(), createdArtifacts,
+ Either<Resource, ResponseFormat> createdCsarArtifactsEither = handleVfCsarArtifacts(preparedResource, importCsarInfo, createdArtifacts,
artifactsBusinessLogic.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.Update), false, true);
if (createdCsarArtifactsEither.isRight()) {
@@ -674,8 +667,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
- private Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandle(Map<String, byte[]> csar, String csarUUID, String yamlFileName, Resource oldResource, User user,
- boolean inTransaction, Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap) {
+ private Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandle(Map<String, NodeTypeInfo> nodeTypesInfo, Map<String, byte[]> csar, String csarUUID, String yamlFileName, Resource oldResource, User user,
+ boolean inTransaction, Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap) {
Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = CsarUtils.extractVfcsArtifactsFromCsar(csar);
Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
@@ -683,14 +676,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
try {
nodeTypesArtifactsToHandleRes = Either.left(nodeTypesArtifactsToHandle);
- List<ImmutablePair<ImmutablePair<String, List<String>>, String>> extractedVfcToscaNames = extractVfcToscaNames(csar, yamlFileName, oldResource.getSystemName(), uploadComponentInstanceInfoMap);
- validateNodeTypeIdentifiers(extractedVfcsArtifacts, extractedVfcToscaNames);
+ Map<String, String> extractedVfcToscaNames = extractVfcToscaNames(nodeTypesInfo, yamlFileName, oldResource.getSystemName(), uploadComponentInstanceInfoMap);
Either<EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>, ResponseFormat> curNodeTypeArtifactsToHandleRes = null;
EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>> curNodeTypeArtifactsToHandle = null;
log.debug("Going to fetch node types for resource with name {} during import csar with UUID {}. ", oldResource.getName(), csarUUID);
- for (ImmutablePair<ImmutablePair<String, List<String>>, String> currVfcToscaNameEntry : extractedVfcToscaNames) {
+ for (Entry<String, String> currVfcToscaNameEntry : extractedVfcToscaNames.entrySet()) {
String currVfcToscaName = currVfcToscaNameEntry.getValue();
+ String currNamespace = currVfcToscaNameEntry.getKey();
log.debug("Going to fetch node type with tosca name {}. ", currVfcToscaName);
Either<Resource, StorageOperationStatus> curVfcRes = toscaOperationFacade.getLatestByToscaResourceName(currVfcToscaName);
@@ -706,10 +699,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
if (!MapUtils.isEmpty(extractedVfcsArtifacts)) {
List<ArtifactDefinition> currArtifacts = new ArrayList<>();
- for (String currNamespace : currVfcToscaNameEntry.getKey().getValue()) {
- if (extractedVfcsArtifacts.containsKey(currNamespace)) {
- handleAndAddExtractedVfcsArtifacts(currArtifacts, extractedVfcsArtifacts.get(currNamespace));
- }
+ if (extractedVfcsArtifacts.containsKey(currNamespace)) {
+ handleAndAddExtractedVfcsArtifacts(currArtifacts, extractedVfcsArtifacts.get(currNamespace));
}
curNodeTypeArtifactsToHandleRes = findNodeTypeArtifactsToHandle(curNodeType, currArtifacts);
if (curNodeTypeArtifactsToHandleRes.isRight()) {
@@ -731,7 +722,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
}
if (MapUtils.isNotEmpty(curNodeTypeArtifactsToHandle)) {
- nodeTypesArtifactsToHandle.put(currVfcToscaNameEntry.getKey().getKey(), curNodeTypeArtifactsToHandle);
+ nodeTypesArtifactsToHandle.put(currVfcToscaNameEntry.getKey(), curNodeTypeArtifactsToHandle);
}
}
} catch (Exception e) {
@@ -742,22 +733,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return nodeTypesArtifactsToHandleRes;
}
- private void validateNodeTypeIdentifiers(Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts, List<ImmutablePair<ImmutablePair<String, List<String>>, String>> extractedVfcToscaNames) {
- if (extractedVfcsArtifacts != null) {
- List<String> validIdentifiers = new ArrayList<>();
- if (extractedVfcToscaNames != null) {
- extractedVfcToscaNames.stream().forEach(pair -> {
- validIdentifiers.addAll(pair.getKey().getValue());
- validIdentifiers.add(pair.getKey().getKey());
- });
- }
- for (String curIdentifier : extractedVfcsArtifacts.keySet()) {
- if (validIdentifiers != null && !validIdentifiers.contains(curIdentifier))
- log.warn("Warning - VFC identification {} provided in the Artifacts folder of the CSAR is not valid. ", curIdentifier);
- }
- }
- }
-
private Either<EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>, ResponseFormat> findNodeTypeArtifactsToHandle(Resource curNodeType, List<ArtifactDefinition> extractedArtifacts) {
Either<EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>, ResponseFormat> nodeTypeArtifactsToHandleRes = null;
@@ -870,7 +845,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
* @return
*/
public Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifacts(Resource nodeTypeResource, Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle, List<ArtifactDefinition> vfcsNewCreatedArtifacts,
- User user, boolean inTransaction) {
+ User user, boolean inTransaction) {
Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifactsRequestRes;
Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifactsRes = null;
Either<Resource, ResponseFormat> changeStateResponse;
@@ -912,32 +887,30 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
@SuppressWarnings("unchecked")
- private List<ImmutablePair<ImmutablePair<String, List<String>>, String>> extractVfcToscaNames(Map<String, byte[]> csar, String yamlFileName, String vfResourceName, Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap) {
- List<ImmutablePair<ImmutablePair<String, List<String>>, String>> vfcToscaNames = new ArrayList<>();
- Map<String, Object> nodeTypes;
- if (csar != null) {
- nodeTypes = new HashMap<>();
- putNodeTypesFromYaml(csar, yamlFileName, nodeTypes);
- putNodeTypesFromYaml(csar, Constants.GLOBAL_SUBSTITUTION_TYPES_SERVICE_TEMPLATE, nodeTypes);
- putNodeTypesFromYaml(csar, Constants.ABSTRACT_SUBSTITUTE_GLOBAL_TYPES_SERVICE_TEMPLATE, nodeTypes);
- Map<String,String> nestedServiceTemplatesMap = new HashMap<>();
- for(UploadComponentInstanceInfo ci : uploadComponentInstanceInfoMap.values()){
- if(ci.getProperties() != null && ci.getProperties().containsKey("service_template_filter")){
- String tempName = CsarUtils.DEFINITIONS_PATH + ((Map<String, String>)ci.getProperties().get("service_template_filter").get(0).getValue()).get("substitute_service_template");
- putNodeTypesFromYaml(csar,tempName, nodeTypes);
- nestedServiceTemplatesMap.put(ci.getType(), tempName);
- }
+ private Map<String, String> extractVfcToscaNames(Map<String, NodeTypeInfo> nodeTypesInfo, String yamlFileName, String vfResourceName, Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap) {
+ Map<String, String> vfcToscaNames = new HashMap<>();
+
+ Map<String, Object> nodes = extractAllNodes(nodeTypesInfo);
+ if (!nodes.isEmpty()) {
+ Iterator<Entry<String, Object>> nodesNameEntry = nodes.entrySet().iterator();
+ while (nodesNameEntry.hasNext()) {
+ Entry<String, Object> nodeType = nodesNameEntry.next();
+ String toscaResourceName = buildNodeToscaResourceName(vfResourceName, nodeType.getKey());
+ vfcToscaNames.put(nodeType.getKey(), toscaResourceName);
}
+ }
+ return vfcToscaNames;
+ }
- if (!nodeTypes.isEmpty()) {
- Iterator<Entry<String, Object>> nodesNameEntry = nodeTypes.entrySet().iterator();
- while (nodesNameEntry.hasNext()) {
- Entry<String, Object> nodeType = nodesNameEntry.next();
- addVfcToscaNameFindSubstitutes(csar, vfResourceName, vfcToscaNames, nodeType.getKey(), nestedServiceTemplatesMap);
- }
+ private Map<String, Object> extractAllNodes(Map<String, NodeTypeInfo> nodeTypesInfo) {
+ Map<String, Object> nodes = new HashMap<>();
+ for(NodeTypeInfo nodeTypeInfo: nodeTypesInfo.values()){
+ Either<Map<String, Object>, ResultStatusEnum> eitherNodeTypes = ImportUtils.findFirstToscaMapElement(nodeTypeInfo.getMappedToscaTemplate(), ToscaTagNamesEnum.NODE_TYPES);
+ if (eitherNodeTypes.isLeft()) {
+ nodes.putAll(eitherNodeTypes.left().value());
}
}
- return vfcToscaNames;
+ return nodes;
}
@SuppressWarnings("unchecked")
@@ -954,22 +927,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
}
- private void addVfcToscaNameFindSubstitutes(Map<String, byte[]> csar, String vfResourceName, List<ImmutablePair<ImmutablePair<String, List<String>>, String>> vfcToscaNames, String nodeTypeFullName, Map<String, String> nestedServiceTemplatesMap) {
-
- String toscaResourceName = buildNestedVfcToscaResourceName(vfResourceName, nodeTypeFullName);
- String nodeTypeTemplateYamlName =null;
- if(nestedServiceTemplatesMap.containsKey(nodeTypeFullName)){
- nodeTypeTemplateYamlName = nestedServiceTemplatesMap.get(nodeTypeFullName);
- }
- List<String> relatedVfcsToscaNameSpaces = new ArrayList<>();
- relatedVfcsToscaNameSpaces.add(buildNestedVfcToscaNamespace(nodeTypeFullName));
- if (nodeTypeTemplateYamlName!=null && csar.containsKey(nodeTypeTemplateYamlName)) {
- addSubstituteToscaNamespacesRecursively(csar, nodeTypeTemplateYamlName, relatedVfcsToscaNameSpaces, nestedServiceTemplatesMap);
- }
- ImmutablePair<String, List<String>> toscaNameSpacesHierarchy = new ImmutablePair<>(nodeTypeFullName, relatedVfcsToscaNameSpaces);
- vfcToscaNames.add(new ImmutablePair<>(toscaNameSpacesHierarchy, toscaResourceName));
- }
-
private void addSubstituteToscaNamespacesRecursively(Map<String, byte[]> csar, String yamlFileName, List<String> toscaNameSpaces, Map<String, String> nestedServiceTemplatesMap) {
Map<String, Object> nodeTypes = new HashMap<>();
@@ -988,12 +945,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
toscaNameSpaces.add(toscaNameSpace);
- String nodeTypeTemplateYamlName =null;
- if(nestedServiceTemplatesMap.containsKey(nodeTypeFullName)){
+ String nodeTypeTemplateYamlName = null;
+ if (nestedServiceTemplatesMap.containsKey(nodeTypeFullName)) {
nodeTypeTemplateYamlName = nestedServiceTemplatesMap.get(nodeTypeFullName);
}
- if (nodeTypeTemplateYamlName!=null && csar.containsKey(nodeTypeTemplateYamlName)) {
+ if (nodeTypeTemplateYamlName != null && csar.containsKey(nodeTypeTemplateYamlName)) {
addSubstituteToscaNamespacesRecursively(csar, nodeTypeTemplateYamlName, toscaNameSpaces, nestedServiceTemplatesMap);
}
}
@@ -1024,7 +981,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
String yamlFileName = toscaYamlCsarStatus.left().value().getKey();
String yamlFileContents = toscaYamlCsarStatus.left().value().getValue();
log.trace("YAML topology file found in CSAR, file name: {}, contents: {}", yamlFileName, yamlFileContents);
- Either<Resource, ResponseFormat> createResourceFromYaml = createResourceFromYaml(resource, user, yamlFileContents, yamlFileName, csar.left().value(), csarUUID);
+
+ Map<String, NodeTypeInfo> nodeTypesInfo = extractNodeTypesInfo(csar.left().value(), yamlFileContents);
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = findNodeTypeArtifactsToCreate(csar.left().value(), resource);
+ ImportCsarInfo importCsarInfo = new ImportCsarInfo(resource.getName(), user, csarUUID, csar.left().value());
+ Either<Resource, ResponseFormat> createResourceFromYaml = createResourceFromYaml(resource, yamlFileContents, yamlFileName, nodeTypesInfo, importCsarInfo, nodeTypesArtifactsToCreate, true, false, null);
if (createResourceFromYaml.isRight()) {
log.debug("Couldn't create resource from YAML");
return Either.right(createResourceFromYaml.right().value());
@@ -1035,6 +996,78 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.left(vfResource);
}
+ @SuppressWarnings("unchecked")
+ private Map<String, NodeTypeInfo> extractNodeTypesInfo(Map<String, byte[]> csar, String yamlFileContent) {
+ Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>();
+ List<Entry<String, byte[]>> globalSubstitutes = new ArrayList<>();
+ for (Map.Entry<String, byte[]> entry : csar.entrySet()) {
+ if (Pattern.compile(CsarUtils.SERVICE_TEMPLATE_PATH_PATTERN).matcher(entry.getKey()).matches()) {
+ if (!isGlobalSubstitute(entry.getKey())) {
+ String yamlFileContents = new String(entry.getValue());
+ Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(yamlFileContents);
+ Either<Object, ResultStatusEnum> substitutionMappingsEither = ImportUtils.findToscaElement(mappedToscaTemplate, ToscaTagNamesEnum.SUBSTITUTION_MAPPINGS, ToscaElementTypeEnum.MAP);
+ if (substitutionMappingsEither.isLeft()) {
+ Map<String, Object> substitutionMappings = (Map<String, Object>) substitutionMappingsEither.left().value();
+ if (substitutionMappings.containsKey(ToscaTagNamesEnum.NODE_TYPE.getElementName())) {
+ NodeTypeInfo nodeTypeInfo = new NodeTypeInfo();
+ nodeTypeInfo.setType((String) substitutionMappings.get(ToscaTagNamesEnum.NODE_TYPE.getElementName()));
+ nodeTypeInfo.setTemplateFileName(entry.getKey());
+ nodeTypeInfo.setMappedToscaTemplate(mappedToscaTemplate);
+ nodeTypesInfo.put(nodeTypeInfo.getType(), nodeTypeInfo);
+ }
+ }
+ } else {
+ globalSubstitutes.add(entry);
+ }
+ }
+ }
+ if (CollectionUtils.isNotEmpty(globalSubstitutes)) {
+ for (Map.Entry<String, byte[]> entry : globalSubstitutes) {
+ String yamlFileContents = new String(entry.getValue());
+ Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(yamlFileContents);
+ Either<Object, ResultStatusEnum> nodeTypesEither = ImportUtils.findToscaElement(mappedToscaTemplate, ToscaTagNamesEnum.NODE_TYPES, ToscaElementTypeEnum.MAP);
+ if (nodeTypesEither.isLeft()) {
+ Map<String, Object> nodeTypes = (Map<String, Object>) nodeTypesEither.left().value();
+ for (Entry<String, Object> nodeType : nodeTypes.entrySet()) {
+ Map<String, Object> nodeTypeMap = (Map<String, Object>) nodeType.getValue();
+ if (nodeTypeMap.containsKey(ToscaTagNamesEnum.DERIVED_FROM.getElementName())) {
+ if (nodeTypesInfo.containsKey(nodeType.getKey())) {
+ NodeTypeInfo nodeTypeInfo = nodeTypesInfo.get(nodeType.getKey());
+ List<String> derivedFrom = new ArrayList<>();
+ derivedFrom.add((String) nodeTypeMap.get(ToscaTagNamesEnum.DERIVED_FROM.getElementName()));
+ nodeTypeInfo.setDerivedFrom(derivedFrom);
+ }
+ }
+ }
+ }
+ }
+ }
+ markNestedVfc(yamlFileContent, nodeTypesInfo);
+ return nodeTypesInfo;
+ }
+
+ private void markNestedVfc(String yamlFileContent, Map<String, NodeTypeInfo> nodeTypesInfo) {
+ Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(yamlFileContent);
+ Either<Object, ResultStatusEnum> nodeTemplatesEither = ImportUtils.findToscaElement(mappedToscaTemplate, ToscaTagNamesEnum.NODE_TEMPLATES, ToscaElementTypeEnum.MAP);
+ if (nodeTemplatesEither.isLeft()) {
+ Map<String, Object> nodeTemplates = (Map<String, Object>) nodeTemplatesEither.left().value();
+ for (Entry<String, Object> nodeTemplateEntry : nodeTemplates.entrySet()) {
+ Map<String, Object> nodeTemplate = (Map<String, Object>) nodeTemplateEntry.getValue();
+ if (nodeTemplate.containsKey(ToscaTagNamesEnum.TYPE.getElementName())) {
+ String type = (String) nodeTemplate.get(ToscaTagNamesEnum.TYPE.getElementName());
+ if (nodeTypesInfo.containsKey(type)) {
+ NodeTypeInfo nodeTypeInfo = nodeTypesInfo.get(type);
+ nodeTypeInfo.setNested(true);
+ }
+ }
+ }
+ }
+ }
+
+ private boolean isGlobalSubstitute(String fileName) {
+ return fileName.equalsIgnoreCase(Constants.GLOBAL_SUBSTITUTION_TYPES_SERVICE_TEMPLATE) || fileName.equalsIgnoreCase(Constants.ABSTRACT_SUBSTITUTE_GLOBAL_TYPES_SERVICE_TEMPLATE);
+ }
+
private Either<ImmutablePair<String, String>, ResponseFormat> validateAndParseCsar(Resource resource, User user, String csarUUID, Either<Map<String, byte[]>, StorageOperationStatus> csar) {
if (csar.isRight()) {
StorageOperationStatus value = csar.right().value();
@@ -1079,8 +1112,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (validateRes.isRight()) {
return Either.right(validateRes.right().value());
}
- // VF "derivedFrom" should be null (or ignored)
- if (!resource.getResourceType().equals(ResourceTypeEnum.VF)) {
+ // VF / PNF "derivedFrom" should be null (or ignored)
+ if (ToscaUtils.isAtomicType(resource)) {
Either<Boolean, ResponseFormat> validateDerivedFromNotEmpty = validateDerivedFromNotEmpty(user, resource, AuditingActionEnum.CREATE_RESOURCE);
if (validateDerivedFromNotEmpty.isRight()) {
return Either.right(validateDerivedFromNotEmpty.right().value());
@@ -1089,26 +1122,31 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return validateResourceBeforeCreate(resource, user, AuditingActionEnum.CREATE_RESOURCE, inTransaction);
}
-
- public Either<Resource, ResponseFormat> createResourceFromYaml(Resource resource, User user, String topologyTemplateYaml, String yamlName, Map<String, byte[]> csar, String csarUUID) {
+//resource, yamlFileContents, yamlFileName, nodeTypesInfo,importCsarInfo, nodeTypesArtifactsToCreate, true, false, null
+ private Either<Resource, ResponseFormat> createResourceFromYaml(Resource resource, String topologyTemplateYaml, String yamlName,
+ Map<String, NodeTypeInfo> nodeTypesInfo, ImportCsarInfo importCsarInfo,
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
+ boolean shouldLock, boolean inTransaction, String nodeTypeName) {
List<ArtifactDefinition> createdArtifacts = new ArrayList<ArtifactDefinition>();
log.trace("************* createResourceFromYaml before parse yaml ");
- Either<ParsedToscaYamlInfo, ResponseFormat> parseResourceInfoFromYamlEither = parseResourceInfoFromYaml(yamlName, resource, topologyTemplateYaml, user);
+ Either<ParsedToscaYamlInfo, ResponseFormat> parseResourceInfoFromYamlEither = parseResourceInfoFromYaml(yamlName, resource, topologyTemplateYaml, importCsarInfo.getModifier(), importCsarInfo.getCreatedNodesToscaResourceNames(), nodeTypesInfo, nodeTypeName);
if (parseResourceInfoFromYamlEither.isRight()) {
ResponseFormat responseFormat = parseResourceInfoFromYamlEither.right().value();
- componentsUtils.auditResource(responseFormat, user, resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
+ componentsUtils.auditResource(responseFormat, importCsarInfo.getModifier(), resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
return Either.right(responseFormat);
}
log.trace("************* createResourceFromYaml after parse yaml ");
ParsedToscaYamlInfo parsedToscaYamlInfo = parseResourceInfoFromYamlEither.left().value();
log.debug("The parsed tosca yaml info is {}", parsedToscaYamlInfo);
log.trace("************* createResourceFromYaml before create ");
- Either<Resource, ResponseFormat> createdResourceResponse = createResourceAndRIsFromYaml(yamlName, resource, user, parsedToscaYamlInfo, AuditingActionEnum.IMPORT_RESOURCE, false, csarUUID, csar, createdArtifacts, topologyTemplateYaml);
+ Either<Resource, ResponseFormat> createdResourceResponse = createResourceAndRIsFromYaml(yamlName, resource, parsedToscaYamlInfo,
+ AuditingActionEnum.IMPORT_RESOURCE, false, createdArtifacts, topologyTemplateYaml,
+ nodeTypesInfo, importCsarInfo, nodeTypesArtifactsToCreate, shouldLock, inTransaction, nodeTypeName);
log.trace("************* createResourceFromYaml after create ");
if (createdResourceResponse.isRight()) {
ResponseFormat responseFormat = createdResourceResponse.right().value();
- componentsUtils.auditResource(responseFormat, user, resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
+ componentsUtils.auditResource(responseFormat, importCsarInfo.getModifier(), resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
return Either.right(responseFormat);
}
@@ -1116,48 +1154,109 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
- public Either<Map<String, Resource>, ResponseFormat> createResourcesFromYamlNodeTypesList(String yamlName, Resource resource, String resourceYml, User user, boolean needLock,
- Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts) {
-
- Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(resourceYml);
+ @SuppressWarnings("unchecked")
+ public Either<Map<String, Resource>, ResponseFormat> createResourcesFromYamlNodeTypesList(String yamlName, Resource resource, String resourceYml, Map<String, Object> mappedToscaTemplate, boolean needLock,
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
+ Map<String, NodeTypeInfo> nodeTypesInfo, ImportCsarInfo importCsarInfo) {
Either<String, ResultStatusEnum> tosca_version = ImportUtils.findFirstToscaStringElement(mappedToscaTemplate, ToscaTagNamesEnum.TOSCA_VERSION);
if (tosca_version.isRight()) {
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_TOSCA_TEMPLATE);
return Either.right(responseFormat);
}
-
Either<Map<String, Object>, ResultStatusEnum> eitherNodeTypes = ImportUtils.findFirstToscaMapElement(mappedToscaTemplate, ToscaTagNamesEnum.NODE_TYPES);
-
Map<String, Resource> nodeTypesResources = new HashMap<>();
Either<Map<String, Resource>, ResponseFormat> result = Either.left(nodeTypesResources);
-
Map<String, Object> mapToConvert = new HashMap<String, Object>();
mapToConvert.put(ToscaTagNamesEnum.TOSCA_VERSION.getElementName(), tosca_version.left().value());
-
+ Resource vfcCreated = null;
if (eitherNodeTypes.isLeft()) {
-
Iterator<Entry<String, Object>> nodesNameValue = eitherNodeTypes.left().value().entrySet().iterator();
-
while (nodesNameValue.hasNext()) {
-
Entry<String, Object> nodeType = nodesNameValue.next();
Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle = nodeTypesArtifactsToHandle == null || nodeTypesArtifactsToHandle.isEmpty() ? null : nodeTypesArtifactsToHandle.get(nodeType.getKey());
- log.trace("************* Going to create node {}", nodeType.getKey());
- Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> resourceCreated = this.createNodeTypeResourceFromYaml(yamlName, nodeType, user, mapToConvert, resource, needLock, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts);
- log.trace("************* finished to create node {}", nodeType.getKey());
- if (resourceCreated.isRight()) {
- return Either.right(resourceCreated.right().value());
- }
- Resource vfcCreated = resourceCreated.left().value().getLeft();
- nodeTypesResources.put(nodeType.getKey(), vfcCreated);
+ if (nodeTypesInfo.containsKey(nodeType.getKey())) {
+ log.trace("************* Going to handle nested vfc {}", nodeType.getKey());
+ Either<Resource, ResponseFormat> handleNeatedVfcYaml = handleNestedVfc(resource, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, importCsarInfo, nodeType.getKey(), nodeTypesResources);
+ log.trace("************* Finished to handle nested vfc {}", nodeType.getKey());
+ if (handleNeatedVfcYaml.isRight()) {
+ return Either.right(handleNeatedVfcYaml.right().value());
+ }
+ vfcCreated = handleNeatedVfcYaml.left().value();
+ } else if(importCsarInfo.getCreatedNodesToscaResourceNames()!= null && !importCsarInfo.getCreatedNodesToscaResourceNames().containsKey(nodeType.getKey())){
+ log.trace("************* Going to create node {}", nodeType.getKey());
+ Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> resourceCreated = this.createNodeTypeResourceFromYaml(yamlName, nodeType, importCsarInfo.getModifier(), mapToConvert, resource, needLock, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, true);
+ log.debug("************* Finished to create node {}", nodeType.getKey());
+
+ if (resourceCreated.isRight()) {
+ return Either.right(resourceCreated.right().value());
+ }
+ vfcCreated = resourceCreated.left().value().getLeft();
+ importCsarInfo.getCreatedNodesToscaResourceNames().put(nodeType.getKey(),vfcCreated.getToscaResourceName());
+ }
+ if (vfcCreated != null) {
+ nodeTypesResources.put(nodeType.getKey(), vfcCreated);
+ }
mapToConvert.remove(ToscaTagNamesEnum.NODE_TYPES.getElementName());
+ }
+ }
+ return result;
+ }
+
+ private Either<Resource, ResponseFormat> handleNestedVfc(Resource resource, Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo, ImportCsarInfo importCsarInfo,
+ String nodeType, Map<String, Resource> createdResourcesFromdNodeTypeMap) {
+ Either<Resource, ResponseFormat> handleNestedVfcRes = Either.left(resource);
+ String serviceTemplateFileFullName = nodeTypesInfo.get(nodeType).getTemplateFileName();
+ String serviceTemplateFileContent = new String(importCsarInfo.getCsar().get(serviceTemplateFileFullName));
+ Map<String, Object> nestedVfcJsonMap = nodeTypesInfo.get(nodeType).getMappedToscaTemplate();
+
+ Either<Map<String, Resource>, ResponseFormat> createdResourcesFromdNodeTypeMapEither = createResourcesFromYamlNodeTypesList(serviceTemplateFileFullName, resource, serviceTemplateFileContent,
+ nestedVfcJsonMap, false, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, importCsarInfo);
+ log.debug("************* Finished to create all nodes from yaml {}", serviceTemplateFileFullName);
+ if (createdResourcesFromdNodeTypeMapEither.isRight()) {
+ log.debug("failed to resources from node types status is {}", createdResourcesFromdNodeTypeMapEither.right().value());
+ return Either.right(createdResourcesFromdNodeTypeMapEither.right().value());
+ }
+ createdResourcesFromdNodeTypeMap.putAll(createdResourcesFromdNodeTypeMapEither.left().value());
+
+ if (nestedVfcJsonMap.containsKey(ToscaTagNamesEnum.TOPOLOGY_TEMPLATE.getElementName())) {
+ Resource complexVfc = new Resource();
+ fillComplexVfcMetadata(resource, importCsarInfo, complexVfc, nodeType, nodeTypesInfo, false);
+ if(!importCsarInfo.getCvfcToCreateQueue().contains(nodeType)){
+ importCsarInfo.getCvfcToCreateQueue().add(nodeType);
+ } else {
+ log.debug("CFVC LOOP DETECTED, VSP {}, CVFC {}", importCsarInfo.getVfResourceName(), complexVfc.getName());
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CFVC_LOOP_DETECTED, importCsarInfo.getVfResourceName(), complexVfc.getName()));
}
+ Either<Resource, ResponseFormat> validationRes = validateResourceBeforeCreate(complexVfc, importCsarInfo.getModifier(), AuditingActionEnum.IMPORT_RESOURCE, true);
+ if(validationRes.isRight()){
+ log.debug("Failed to validate complex VFC {}. ", complexVfc.getName());
+ return validationRes;
+ }
+ Map<String, NodeTypeInfo> newNodeTypesInfo = nodeTypesInfo.entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().getUnmarkedCopy()));
+ markNestedVfc(serviceTemplateFileContent, newNodeTypesInfo);
+ handleNestedVfcRes = createResourceFromYaml(complexVfc, serviceTemplateFileContent, serviceTemplateFileFullName,
+ newNodeTypesInfo, importCsarInfo, nodeTypesArtifactsToHandle, false, true, nodeType);
+ if (handleNestedVfcRes.isRight()) {
+ log.debug("Couldn't create resource from YAML");
+ return Either.right(handleNestedVfcRes.right().value());
+ }
+ importCsarInfo.getCreatedNodesToscaResourceNames().put(nodeType, handleNestedVfcRes.left().value().getToscaResourceName());
+ LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction("certification on import", LifecycleChanceActionEnum.CREATE_FROM_CSAR);
+ log.debug("Going to certify cvfc {}. ", handleNestedVfcRes.left().value().getName());
+ Either<Resource, ResponseFormat> certRes = propagateStateToCertified(importCsarInfo.getModifier(), handleNestedVfcRes.left().value(), lifecycleChangeInfo, true, false, true);
+ if (certRes.isRight()) {
+ log.debug("Couldn't certify resource {}. ", handleNestedVfcRes.left().value());
+ return certRes;
+ }
+ createdResourcesFromdNodeTypeMap.put(nodeType, certRes.left().value());
+ importCsarInfo.getCvfcToCreateQueue().remove();
}
- return result;
+ return handleNestedVfcRes;
}
private String getNodeTypeActualName(String fullName) {
@@ -1168,40 +1267,44 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createNodeTypeResourceFromYaml(String yamlName, Entry<String, Object> nodeNameValue, User user, Map<String, Object> mapToConvert, Resource resourceVf, boolean needLock,
- Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts) {
+ Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, boolean forceCertificationAllowed) {
Either<UploadResourceInfo, ResponseFormat> resourceMetaData = fillResourceMetadata(yamlName, resourceVf, nodeNameValue.getKey(), user);
if (resourceMetaData.isRight()) {
return Either.right(resourceMetaData.right().value());
}
+ String csarVfName = resourceVf.getSystemName();
+ String singleVfcYaml = buildNodeTypeYaml(nodeNameValue, mapToConvert, resourceMetaData.left().value().getResourceType(), csarVfName);
+ Either<User, ResponseFormat> eitherCreator = validateUser(user, "CheckIn Resource", resourceVf, AuditingActionEnum.CHECKIN_RESOURCE, true);
+ if (eitherCreator.isRight()) {
+ return Either.right(eitherCreator.right().value());
+ }
+ user = eitherCreator.left().value();
+
+ return this.createResourceFromNodeType(singleVfcYaml, resourceMetaData.left().value(), user, true, needLock, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed);
+ }
+
+ private String buildNodeTypeYaml(Entry<String, Object> nodeNameValue, Map<String, Object> mapToConvert, String nodeResourceType, String csarVfName) {
// We need to create a Yaml from each node_types in order to create
// resource from each node type using import normative flow.
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Yaml yaml = new Yaml(options);
- Map<String, Object> singleVfc = new HashMap<>();
+ Map<String, Object> node = new HashMap<>();
+ node.put(buildNestedToscaResourceName(nodeResourceType, csarVfName, nodeNameValue.getKey()), nodeNameValue.getValue());
+ mapToConvert.put(ToscaTagNamesEnum.NODE_TYPES.getElementName(), node);
- String actualName = this.getNodeTypeActualName(nodeNameValue.getKey());
+ return yaml.dumpAsMap(mapToConvert);
+ }
+
+ private String buildNestedToscaResourceName(String nodeResourceType, String csarVfName, String originToscaResourceName) {
+ String actualName = getNodeTypeActualName(originToscaResourceName);
if (!actualName.startsWith(Constants.ABSTRACT)) {
actualName = "." + Constants.ABSTRACT + actualName;
}
-
- // Setting tosca name
- String toscaResourceName = ImportUtils.Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + resourceMetaData.left().value().getResourceType().toLowerCase() + '.' + resourceVf.getSystemName() + actualName;
- singleVfc.put(toscaResourceName, nodeNameValue.getValue());
- mapToConvert.put(ToscaTagNamesEnum.NODE_TYPES.getElementName(), singleVfc);
-
- String singleVfcYaml = yaml.dumpAsMap(mapToConvert);
-
- Either<User, ResponseFormat> eitherCreator = validateUser(user, "CheckIn Resource", resourceVf, AuditingActionEnum.CHECKIN_RESOURCE, true);
- if (eitherCreator.isRight()) {
- return Either.right(eitherCreator.right().value());
- }
- user = eitherCreator.left().value();
-
- return this.createResourceFromNodeType(singleVfcYaml, resourceMetaData.left().value(), user, true, needLock, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts);
+ return ImportUtils.Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + nodeResourceType.toLowerCase() + '.' + ValidationUtils.convertToSystemName(csarVfName) + actualName;
}
public Either<Boolean, ResponseFormat> validateResourceCreationFromNodeType(Resource resource, User creator) {
@@ -1214,11 +1317,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
public Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createResourceFromNodeType(String nodeTypeYaml, UploadResourceInfo resourceMetaData, User creator, boolean isInTransaction, boolean needLock,
- Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts) {
+ Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, boolean forceCertificationAllowed) {
LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction("certification on import", LifecycleChanceActionEnum.CREATE_FROM_CSAR);
Function<Resource, Either<Boolean, ResponseFormat>> validator = (resource) -> this.validateResourceCreationFromNodeType(resource, creator);
- return this.resourceImportManager.importCertifiedResource(nodeTypeYaml, resourceMetaData, creator, validator, lifecycleChangeInfo, isInTransaction, true, needLock, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts);
+ return this.resourceImportManager.importCertifiedResource(nodeTypeYaml, resourceMetaData, creator, validator, lifecycleChangeInfo, isInTransaction, true, needLock, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed);
}
private Either<UploadResourceInfo, ResponseFormat> fillResourceMetadata(String yamlName, Resource resourceVf, String nodeTypeName, User user) {
@@ -1279,20 +1382,76 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.left(resourceMetaData);
}
- private Either<Resource, ResponseFormat> createResourceAndRIsFromYaml(String yamlName, Resource resource, User user, ParsedToscaYamlInfo parsedToscaYamlInfo, AuditingActionEnum actionEnum, boolean isNormative, String csarUUID,
- Map<String, byte[]> csar, List<ArtifactDefinition> createdArtifacts, String topologyTemplateYaml) {
+ private void fillComplexVfcMetadata(Resource resourceVf, ImportCsarInfo importCsarInfo, Resource cvfc, String nodeTypeName, Map<String, NodeTypeInfo> nodeTypesInfo, boolean shouldBeCertified) {
+ NodeTypeInfo nodeTypeInfo = nodeTypesInfo.get(nodeTypeName);
+ cvfc.setName(buildCvfcName(importCsarInfo.getVfResourceName(), nodeTypeName));
+ cvfc.setNormalizedName(ValidationUtils.normaliseComponentName(cvfc.getName()));
+ cvfc.setSystemName(ValidationUtils.convertToSystemName(cvfc.getName()));
+ cvfc.setResourceType(ResourceTypeEnum.CVFC);
+ cvfc.setAbstract(true);
+ cvfc.setDerivedFrom(nodeTypeInfo.getDerivedFrom());
+ cvfc.setDescription(ImportUtils.Constants.CVFC_DESCRIPTION);
+ cvfc.setIcon(ImportUtils.Constants.DEFAULT_ICON);
+ cvfc.setContactId(importCsarInfo.getModifier().getUserId());
+ cvfc.setCreatorUserId(importCsarInfo.getModifier().getUserId());
+ cvfc.setVendorName(resourceVf.getVendorName());
+ cvfc.setVendorRelease(resourceVf.getVendorRelease());
+ cvfc.setResourceVendorModelNumber(resourceVf.getResourceVendorModelNumber());
+ cvfc.setToscaResourceName(buildNestedToscaResourceName(ResourceTypeEnum.VFC.name(), importCsarInfo.getVfResourceName(), nodeTypeName));
+ cvfc.setInvariantUUID(UniqueIdBuilder.buildInvariantUUID());
+
+ List<String> tags = new ArrayList<>();
+ tags.add(cvfc.getName());
+ cvfc.setTags(tags);
+
+ CategoryDefinition category = new CategoryDefinition();
+ category.setName(ImportUtils.Constants.ABSTRACT_CATEGORY_NAME);
+ SubCategoryDefinition subCategory = new SubCategoryDefinition();
+ subCategory.setName(ImportUtils.Constants.ABSTRACT_SUBCATEGORY);
+ category.addSubCategory(subCategory);
+ List<CategoryDefinition> categories = new ArrayList<>();
+ categories.add(category);
+ cvfc.setCategories(categories);
+
+ String version;
+ LifecycleStateEnum state;
+
+ if (shouldBeCertified) {
+ version = ImportUtils.Constants.FIRST_CERTIFIED_VERSION_VERSION;
+ state = ImportUtils.Constants.NORMATIVE_TYPE_LIFE_CYCLE;
+ } else {
+ version = ImportUtils.Constants.FIRST_NON_CERTIFIED_VERSION;
+ state = ImportUtils.Constants.NORMATIVE_TYPE_LIFE_CYCLE_NOT_CERTIFIED_CHECKOUT;
+ }
+ cvfc.setVersion(version);
+ cvfc.setLifecycleState(state);
+ cvfc.setHighestVersion(ImportUtils.Constants.NORMATIVE_TYPE_HIGHEST_VERSION);
+ }
+
+ private String buildCvfcName(String resourceVfName, String nodeTypeName) {
+ String nameWithouNamespacePrefix = nodeTypeName.substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length());
+ String[] findTypes = nameWithouNamespacePrefix.split("\\.");
+ String resourceType = findTypes[0];
+ return resourceVfName + "-" + nameWithouNamespacePrefix.substring(resourceType.length() + 1);
+ }
+
+ private Either<Resource, ResponseFormat> createResourceAndRIsFromYaml(String yamlName, Resource resource, ParsedToscaYamlInfo parsedToscaYamlInfo, AuditingActionEnum actionEnum, boolean isNormative,
+ List<ArtifactDefinition> createdArtifacts, String topologyTemplateYaml, Map<String, NodeTypeInfo> nodeTypesInfo,
+ ImportCsarInfo importCsarInfo, Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
+ boolean shouldLock, boolean inTransaction, String nodeTypeName) {
boolean result = true;
- boolean inTransaction = true;
Map<String, Resource> createdVfcs = new HashMap<>();
List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
- Either<Boolean, ResponseFormat> lockResult = lockComponentByName(resource.getSystemName(), resource, "Create Resource");
- if (lockResult.isRight()) {
- ResponseFormat responseFormat = lockResult.right().value();
- return Either.right(responseFormat);
- }
- log.debug("name is locked {} status = {}", resource.getSystemName(), lockResult);
+ if (shouldLock) {
+ Either<Boolean, ResponseFormat> lockResult = lockComponentByName(resource.getSystemName(), resource, "Create Resource");
+ if (lockResult.isRight()) {
+ ResponseFormat responseFormat = lockResult.right().value();
+ return Either.right(responseFormat);
+ }
+ log.debug("name is locked {} status = {}", resource.getSystemName(), lockResult);
+ }
try {
log.trace("************* createResourceFromYaml before full create resource {}", yamlName);
Either<Resource, ResponseFormat> genericResourceEither = fetchAndSetDerivedFromGenericType(resource);
@@ -1300,7 +1459,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
result = false;
return genericResourceEither;
}
- Either<Resource, ResponseFormat> createResourcesEither = createResourceTransaction(resource, user, isNormative, inTransaction);
+ Either<Resource, ResponseFormat> createResourcesEither = createResourceTransaction(resource, importCsarInfo.getModifier(), isNormative, inTransaction);
log.trace("************* createResourceFromYaml after full create resource {}", yamlName);
if (createResourcesEither.isRight()) {
result = false;
@@ -1313,7 +1472,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
generateInputsFromGenericTypeProperties(resource, genericResourceEither.left().value());
Map<String, InputDefinition> inputs = parsedToscaYamlInfo.getInputs();
- Either<Resource, ResponseFormat> createInputsOnResource = createInputsOnResource(resource, user, inputs, inTransaction);
+ Either<Resource, ResponseFormat> createInputsOnResource = createInputsOnResource(resource, importCsarInfo.getModifier(), inputs, inTransaction);
if (createInputsOnResource.isRight()) {
result = false;
return createInputsOnResource;
@@ -1323,7 +1482,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap = parsedToscaYamlInfo.getInstances();
log.trace("************* Going to create nodes, RI's and Relations from yaml {}", yamlName);
- createResourcesEither = createRIAndRelationsFromYaml(yamlName, resource, user, uploadComponentInstanceInfoMap, actionEnum, topologyTemplateYaml, csar, csarUUID, nodeTypesNewCreatedArtifacts, createdVfcs);
+
+ createResourcesEither = createRIAndRelationsFromYaml(yamlName, resource, uploadComponentInstanceInfoMap, actionEnum, topologyTemplateYaml,
+ nodeTypesNewCreatedArtifacts, createdVfcs, nodeTypesInfo, importCsarInfo, nodeTypesArtifactsToCreate);
log.trace("************* Finished to create nodes, RI and Relation from yaml {}", yamlName);
if (createResourcesEither.isRight()) {
result = false;
@@ -1346,7 +1507,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
} else {
groups = parsedToscaYamlInfo.getGroups();
}
- Either<Resource, ResponseFormat> createGroupsOnResource = createGroupsOnResource(resource, user, groups);
+ Either<Resource, ResponseFormat> createGroupsOnResource = createGroupsOnResource(resource, importCsarInfo.getModifier(), groups);
if (createGroupsOnResource.isRight()) {
result = false;
return createGroupsOnResource;
@@ -1355,43 +1516,54 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.trace("************* Finished to add groups from yaml {}", yamlName);
log.trace("************* Going to add artifacts from yaml {}", yamlName);
- Either<Resource, ResponseFormat> createdCsarArtifactsEither = this.handleCsarArtifacts(resource, user, csarUUID, csar, createdArtifacts, artifactsBusinessLogic.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.Create), false,
- inTransaction);
- log.trace("************* Finished to add artifacts from yaml {}", yamlName);
- if (createdCsarArtifactsEither.isRight()) {
- result = false;
- return createdCsarArtifactsEither;
- }
- resource = createdCsarArtifactsEither.left().value();
+ if(resource.getResourceType() == ResourceTypeEnum.CVFC){
+ if(nodeTypesArtifactsToCreate.containsKey(nodeTypeName) && nodeTypesArtifactsToCreate.get(nodeTypeName) !=null && !nodeTypesArtifactsToCreate.get(nodeTypeName).isEmpty()){
+ Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifactsRes =
+ handleNodeTypeArtifacts(resource, nodeTypesArtifactsToCreate.get(nodeTypeName), nodeTypesNewCreatedArtifacts, importCsarInfo.getModifier(), true);
+ if(handleNodeTypeArtifactsRes.isRight()){
+ return Either.right(handleNodeTypeArtifactsRes.right().value());
+ }
+ }
+ } else {
+ Either<Resource, ResponseFormat> createdCsarArtifactsEither = this.handleVfCsarArtifacts(resource, importCsarInfo, createdArtifacts, artifactsBusinessLogic.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.Create), false,
+ inTransaction);
+ log.trace("************* Finished to add artifacts from yaml {}", yamlName);
+ if (createdCsarArtifactsEither.isRight()) {
+ result = false;
+ return createdCsarArtifactsEither;
+ }
+ resource = createdCsarArtifactsEither.left().value();
+ }
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.CREATED);
- componentsUtils.auditResource(responseFormat, user, resource, "", "", actionEnum, null);
+ componentsUtils.auditResource(responseFormat, importCsarInfo.getModifier(), resource, "", "", actionEnum, null);
ASDCKpiApi.countCreatedResourcesKPI();
return Either.left(resource);
} finally {
- if (!result) {
- log.warn("operation failed. do rollback");
- titanDao.rollback();
- if (!createdArtifacts.isEmpty() || !nodeTypesNewCreatedArtifacts.isEmpty()) {
- createdArtifacts.addAll(nodeTypesNewCreatedArtifacts);
- StorageOperationStatus deleteFromEsRes = artifactsBusinessLogic.deleteAllComponentArtifactsIfNotOnGraph(createdArtifacts);
- if (!deleteFromEsRes.equals(StorageOperationStatus.OK)) {
- ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(deleteFromEsRes);
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(actionStatus, resource.getName());
+ if (!inTransaction) {
+ if (!result) {
+ log.warn("operation failed. do rollback");
+ titanDao.rollback();
+ if (!createdArtifacts.isEmpty() || !nodeTypesNewCreatedArtifacts.isEmpty()) {
+ createdArtifacts.addAll(nodeTypesNewCreatedArtifacts);
+ StorageOperationStatus deleteFromEsRes = artifactsBusinessLogic.deleteAllComponentArtifactsIfNotOnGraph(createdArtifacts);
+ if (!deleteFromEsRes.equals(StorageOperationStatus.OK)) {
+ ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(deleteFromEsRes);
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(actionStatus, resource.getName());
+ }
+ log.debug("component and all its artifacts were deleted, id = {}", resource.getName());
}
- log.debug("component and all its artifacts were deleted, id = {}", resource.getName());
- }
- } else {
- log.debug("operation success. do commit");
- titanDao.commit();
+ } else {
+ log.debug("operation success. do commit");
+ titanDao.commit();
+ }
+ }
+ if (shouldLock) {
+ graphLockOperation.unlockComponentByName(resource.getSystemName(), resource.getUniqueId(), NodeTypeEnum.Resource);
}
-
- graphLockOperation.unlockComponentByName(resource.getSystemName(), resource.getUniqueId(), NodeTypeEnum.Resource);
-
}
-
}
private Either<Resource, ResponseFormat> createGroupsOnResource(Resource resource, User user, Map<String, GroupDefinition> groups) {
@@ -1493,11 +1665,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private Either<Resource, ResponseFormat> createInputsOnResource(Resource resource, User user, Map<String, InputDefinition> inputs, boolean inTransaction) {
- if (inputs != null && false == inputs.isEmpty()) {
+ List<InputDefinition> resourceProperties = resource.getInputs();
+ if ( (inputs != null && false == inputs.isEmpty()) || (resourceProperties != null && false == resourceProperties.isEmpty()) ) {
- Either<List<InputDefinition>, ResponseFormat> createGroups = inputsBusinessLogic.createInputsInGraph(inputs, resource, user, inTransaction);
- if (createGroups.isRight()) {
- return Either.right(createGroups.right().value());
+ Either<List<InputDefinition>, ResponseFormat> createInputs = inputsBusinessLogic.createInputsInGraph(inputs, resource, user, inTransaction);
+ if (createInputs.isRight()) {
+ return Either.right(createInputs.right().value());
}
} else {
return Either.left(resource);
@@ -1618,12 +1791,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// Filtered Members Of Current Group containing only members which
// are groups
List<String> currGroupFilteredMembers = currGroupMembers.stream().
- // Keep Only Elements of type group and not Resource Instances
- filter(innerGroupName -> allGroups.containsKey(innerGroupName)).
+ // Keep Only Elements of type group and not Resource Instances
+ filter(innerGroupName -> allGroups.containsKey(innerGroupName)).
// Add Filtered Elements to main Set
- peek(innerGroupName -> allGroupMembers.add(innerGroupName)).
+ peek(innerGroupName -> allGroupMembers.add(innerGroupName)).
// Collect results
- collect(Collectors.toList());
+ collect(Collectors.toList());
// Recursively call the method for all the filtered group members
for (String innerGroupName : currGroupFilteredMembers) {
@@ -1649,25 +1822,24 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (!stop) {
final Set<String> allMembers = allGroups.get(groupName).getMembers().keySet();
Set<String> membersOfTypeGroup = allMembers.stream().
- // Filter In Only Group members
- filter(innerGroupName -> allGroups.containsKey(innerGroupName)).
+ // Filter In Only Group members
+ filter(innerGroupName -> allGroups.containsKey(innerGroupName)).
// Collect
- collect(Collectors.toSet());
+ collect(Collectors.toSet());
stop = allGroupMembers.containsAll(membersOfTypeGroup);
}
return stop;
}
- private Either<Resource, ResponseFormat> createRIAndRelationsFromYaml(String yamlName, Resource resource, User user, Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap, AuditingActionEnum actionEnum,
- String topologyTemplateYaml, Map<String, byte[]> csar, String csarUUID, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, Resource> createdVfcs) {
+ private Either<Resource, ResponseFormat> createRIAndRelationsFromYaml(String yamlName, Resource resource, Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap, AuditingActionEnum actionEnum,
+ String topologyTemplateYaml, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, Resource> createdVfcs,
+ Map<String, NodeTypeInfo> nodeTypesInfo, ImportCsarInfo importCsarInfo, Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate) {
Either<Resource, ResponseFormat> result;
Either<Resource, ResponseFormat> createResourcesInstancesEither;
- Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = findNodeTypeArtifactsToCreate(csar, yamlName, resource, uploadComponentInstanceInfoMap);
-
log.debug("************* Going to create all nodes {}", yamlName);
- Either<Map<String, Resource>, ResponseFormat> createdResourcesFromdNodeTypeMap = this.handleNodeTypes(yamlName, resource, user, topologyTemplateYaml, csar, false, nodeTypesArtifactsToCreate, nodeTypesNewCreatedArtifacts);
+ Either<Map<String, Resource>, ResponseFormat> createdResourcesFromdNodeTypeMap = this.handleNodeTypes(yamlName, resource, topologyTemplateYaml, false, nodeTypesArtifactsToCreate, nodeTypesNewCreatedArtifacts, nodeTypesInfo, importCsarInfo);
log.debug("************* Finished to create all nodes {}", yamlName);
if (createdResourcesFromdNodeTypeMap.isRight()) {
log.debug("failed to resources from node types status is {}", createdResourcesFromdNodeTypeMap.right().value());
@@ -1677,7 +1849,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
createdVfcs.putAll(createdResourcesFromdNodeTypeMap.left().value());
log.debug("************* Going to create all resource instances {}", yamlName);
- createResourcesInstancesEither = createResourceInstances(user, yamlName, resource, uploadComponentInstanceInfoMap, true, false, createdResourcesFromdNodeTypeMap.left().value());
+ createResourcesInstancesEither = createResourceInstances(importCsarInfo.getModifier(), yamlName, resource, uploadComponentInstanceInfoMap, true, false, createdResourcesFromdNodeTypeMap.left().value());
log.debug("************* Finished to create all resource instances {}", yamlName);
if (createResourcesInstancesEither.isRight()) {
@@ -1687,7 +1859,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
resource = createResourcesInstancesEither.left().value();
log.debug("************* Going to create all relations {}", yamlName);
- createResourcesInstancesEither = createResourceInstancesRelations(user, yamlName, resource, uploadComponentInstanceInfoMap, true, false);
+ createResourcesInstancesEither = createResourceInstancesRelations(importCsarInfo.getModifier(), yamlName, resource, uploadComponentInstanceInfoMap, true, false);
log.debug("************* Finished to create all relations {}", yamlName);
@@ -1700,44 +1872,21 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
log.debug("************* Going to create positions {}", yamlName);
- Either<List<ComponentInstance>, ResponseFormat> eitherSetPosition = compositionBusinessLogic.setPositionsForComponentInstances(resource, user.getUserId());
+ Either<List<ComponentInstance>, ResponseFormat> eitherSetPosition = compositionBusinessLogic.setPositionsForComponentInstances(resource, importCsarInfo.getModifier().getUserId());
log.debug("************* Finished to set positions {}", yamlName);
result = eitherSetPosition.isRight() ? Either.right(eitherSetPosition.right().value()) : Either.left(resource);
return result;
}
- private Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> findNodeTypeArtifactsToCreate(Map<String, byte[]> csar, String yamlName, Resource resource, Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap) {
+ private Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> findNodeTypeArtifactsToCreate(Map<String, byte[]> csar, Resource resource) {
Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = CsarUtils.extractVfcsArtifactsFromCsar(csar);
- List<ImmutablePair<ImmutablePair<String, List<String>>, String>> extractedVfcToscaNames = extractVfcToscaNames(csar, yamlName, resource.getSystemName(), uploadComponentInstanceInfoMap);
- validateNodeTypeIdentifiers(extractedVfcsArtifacts, extractedVfcToscaNames);
- Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = null;
- if (!extractedVfcsArtifacts.isEmpty() && !extractedVfcToscaNames.isEmpty()) {
- for (ImmutablePair<ImmutablePair<String, List<String>>, String> currToscaNamePair : extractedVfcToscaNames) {
- EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>> curNodeTypeArtifacts = null;
- String currVfcToscaNamespace = currToscaNamePair.getKey().getKey();
- List<String> relatedVfcs = currToscaNamePair.getKey().getValue();
- List<ArtifactDefinition> currArtifactList = null;
-
- for (String currSubstitute : relatedVfcs) {
- if (extractedVfcsArtifacts.containsKey(currSubstitute)) {
- if (MapUtils.isEmpty(curNodeTypeArtifacts)) {
- curNodeTypeArtifacts = new EnumMap<>(ArtifactOperationEnum.class);
- currArtifactList = new ArrayList<>();
- curNodeTypeArtifacts.put(ArtifactOperationEnum.Create, currArtifactList);
- } else {
- currArtifactList = curNodeTypeArtifacts.get(ArtifactOperationEnum.Create);
- }
- handleAndAddExtractedVfcsArtifacts(currArtifactList, extractedVfcsArtifacts.get(currSubstitute));
- }
- }
-
- if (nodeTypesArtifactsToHandle == null) {
- nodeTypesArtifactsToHandle = new HashMap<>();
- }
- nodeTypesArtifactsToHandle.put(currVfcToscaNamespace, curNodeTypeArtifacts);
- }
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
+ for (Map.Entry<String, List<ArtifactDefinition>> currArts : extractedVfcsArtifacts.entrySet()) {
+ EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>> artifactsToCreate = new EnumMap<>(ArtifactOperationEnum.class);
+ artifactsToCreate.put(ArtifactOperationEnum.Create, currArts.getValue());
+ nodeTypesArtifactsToHandle.put(currArts.getKey(), artifactsToCreate);
}
return nodeTypesArtifactsToHandle;
}
@@ -1754,31 +1903,30 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
- private Either<Map<String, Resource>, ResponseFormat> handleNodeTypes(String yamlName, Resource resource, User user, String topologyTemplateYaml, Map<String, byte[]> csar, boolean needLock,
- Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts) {
+ @SuppressWarnings("unchecked")
+ private Either<Map<String, Resource>, ResponseFormat> handleNodeTypes(String yamlName, Resource resource, String topologyTemplateYaml, boolean needLock,
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
+ Map<String, NodeTypeInfo> nodeTypesInfo, ImportCsarInfo importCsarInfo) {
Map<String, Resource> createdResourcesFromdNodeTypeMap = new HashMap<>();
Either<Map<String, Resource>, ResponseFormat> result = Either.left(createdResourcesFromdNodeTypeMap);
+ for (Entry<String, NodeTypeInfo> nodeTypeEntry : nodeTypesInfo.entrySet()) {
+ if (nodeTypeEntry.getValue().isNested()) {
- String yamlFileName = Constants.GLOBAL_SUBSTITUTION_TYPES_SERVICE_TEMPLATE;
-
- if (csar != null && csar.containsKey(yamlFileName)) {
- byte[] yamlFileBytes = csar.get(yamlFileName);
- String globalTypesYaml = new String(yamlFileBytes, StandardCharsets.UTF_8);
- Either<Map<String, Resource>, ResponseFormat> createdNodeTypesFromGlobalTypesTemplateEither = this.createResourcesFromYamlNodeTypesList(yamlFileName, resource, globalTypesYaml, user, needLock, nodeTypesArtifactsToHandle,
- nodeTypesNewCreatedArtifacts);
- if (createdNodeTypesFromGlobalTypesTemplateEither.isRight()) {
- ResponseFormat responseFormat = createdNodeTypesFromGlobalTypesTemplateEither.right().value();
- componentsUtils.auditResource(responseFormat, user, resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
- return Either.right(responseFormat);
+ Either<Resource, ResponseFormat> createResourceFromYaml = handleNestedVfc(resource, nodeTypesArtifactsToHandle,
+ nodeTypesNewCreatedArtifacts, nodeTypesInfo, importCsarInfo, nodeTypeEntry.getKey(), createdResourcesFromdNodeTypeMap);
+ log.trace("************* finished to create node {}", nodeTypeEntry.getKey());
+ if (createResourceFromYaml.isRight()) {
+ return Either.right(createResourceFromYaml.right().value());
+ }
}
- createdResourcesFromdNodeTypeMap.putAll(createdNodeTypesFromGlobalTypesTemplateEither.left().value());
}
-
- Either<Map<String, Resource>, ResponseFormat> createdNodeTypeFromMainTemplateEither = createResourcesFromYamlNodeTypesList(yamlName, resource, topologyTemplateYaml, user, needLock, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts);
+ Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(topologyTemplateYaml);
+ Either<Map<String, Resource>, ResponseFormat> createdNodeTypeFromMainTemplateEither = createResourcesFromYamlNodeTypesList(yamlName, resource, topologyTemplateYaml, mappedToscaTemplate, needLock, nodeTypesArtifactsToHandle,
+ nodeTypesNewCreatedArtifacts, nodeTypesInfo, importCsarInfo);
if (createdNodeTypeFromMainTemplateEither.isRight()) {
ResponseFormat responseFormat = createdNodeTypeFromMainTemplateEither.right().value();
- componentsUtils.auditResource(responseFormat, user, resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
+ componentsUtils.auditResource(responseFormat, importCsarInfo.getModifier(), resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
return Either.right(responseFormat);
}
@@ -1791,10 +1939,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return result;
}
- private Either<Resource, ResponseFormat> handleCsarArtifacts(Resource resource, User user, String csarUUID, Map<String, byte[]> csar, List<ArtifactDefinition> createdArtifacts, ArtifactOperationInfo artifactOperation, boolean shouldLock,
- boolean inTransaction) {
+ private Either<Resource, ResponseFormat> handleVfCsarArtifacts(Resource resource, ImportCsarInfo importCsarInfo, List<ArtifactDefinition> createdArtifacts, ArtifactOperationInfo artifactOperation, boolean shouldLock,
+ boolean inTransaction) {
- if (csar != null) {
+ if (importCsarInfo.getCsar() != null) {
String vendorLicenseModelId = null;
String vfLicenseModelId = null;
@@ -1811,26 +1959,26 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
// Specific Behavior for license artifacts
- createOrUpdateSingleNonMetaArtifact(resource, user, csarUUID, csar, CsarUtils.ARTIFACTS_PATH + Constants.VENDOR_LICENSE_MODEL, Constants.VENDOR_LICENSE_MODEL, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT,
+ createOrUpdateSingleNonMetaArtifact(resource, importCsarInfo, CsarUtils.ARTIFACTS_PATH + Constants.VENDOR_LICENSE_MODEL, Constants.VENDOR_LICENSE_MODEL, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT,
Constants.VENDOR_LICENSE_LABEL, Constants.VENDOR_LICENSE_DISPLAY_NAME, Constants.VENDOR_LICENSE_DESCRIPTION, vendorLicenseModelId, artifactOperation, null, shouldLock, inTransaction);
- createOrUpdateSingleNonMetaArtifact(resource, user, csarUUID, csar, CsarUtils.ARTIFACTS_PATH + Constants.VF_LICENSE_MODEL, Constants.VF_LICENSE_MODEL, ArtifactTypeEnum.VF_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT,
+ createOrUpdateSingleNonMetaArtifact(resource, importCsarInfo, CsarUtils.ARTIFACTS_PATH + Constants.VF_LICENSE_MODEL, Constants.VF_LICENSE_MODEL, ArtifactTypeEnum.VF_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT,
Constants.VF_LICENSE_LABEL, Constants.VF_LICENSE_DISPLAY_NAME, Constants.VF_LICENSE_DESCRIPTION, vfLicenseModelId, artifactOperation, null, shouldLock, inTransaction);
- Either<Resource, ResponseFormat> eitherCreateResult = createOrUpdateNonMetaArtifacts(csarUUID, csar, resource, user, createdArtifacts, shouldLock, inTransaction, artifactOperation);
+ Either<Resource, ResponseFormat> eitherCreateResult = createOrUpdateNonMetaArtifacts(importCsarInfo, resource, createdArtifacts, shouldLock, inTransaction, artifactOperation);
if (eitherCreateResult.isRight()) {
return Either.right(eitherCreateResult.right().value());
}
- Either<ImmutablePair<String, String>, ResponseFormat> artifacsMetaCsarStatus = CsarValidationUtils.getArtifactsMeta(csar, csarUUID, componentsUtils);
+ Either<ImmutablePair<String, String>, ResponseFormat> artifacsMetaCsarStatus = CsarValidationUtils.getArtifactsMeta(importCsarInfo.getCsar(), importCsarInfo.getCsarUUID(), componentsUtils);
if (artifacsMetaCsarStatus.isLeft()) {
String artifactsFileName = artifacsMetaCsarStatus.left().value().getKey();
String artifactsContents = artifacsMetaCsarStatus.left().value().getValue();
Either<Resource, ResponseFormat> createArtifactsFromCsar = Either.left(resource);
if (artifactOperation.getArtifactOperationEnum() == ArtifactOperationEnum.Create)
- createArtifactsFromCsar = createResourceArtifactsFromCsar(csarUUID, csar, resource, user, artifactsContents, artifactsFileName, createdArtifacts, shouldLock, inTransaction);
+ createArtifactsFromCsar = createResourceArtifactsFromCsar(importCsarInfo, resource, artifactsContents, artifactsFileName, createdArtifacts, shouldLock, inTransaction);
else
- createArtifactsFromCsar = updateResourceArtifactsFromCsar(csarUUID, csar, resource, user, artifactsContents, artifactsFileName, createdArtifacts, shouldLock, inTransaction);
+ createArtifactsFromCsar = updateResourceArtifactsFromCsar(importCsarInfo, resource, artifactsContents, artifactsFileName, createdArtifacts, shouldLock, inTransaction);
if (createArtifactsFromCsar.isRight()) {
log.debug("Couldn't create artifacts from artifacts.meta");
return Either.right(createArtifactsFromCsar.right().value());
@@ -1849,7 +1997,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
* Either.right(componentsUtils.getResponseFormat(actionStatus)); } } }
*/
for (String artifactId : artifactsToDelete) {
- Either<Either<ArtifactDefinition, Operation>, ResponseFormat> handleDelete = artifactsBusinessLogic.handleDelete(resource.getUniqueId(), artifactId, user, AuditingActionEnum.ARTIFACT_DELETE, ComponentTypeEnum.RESOURCE,
+ Either<Either<ArtifactDefinition, Operation>, ResponseFormat> handleDelete = artifactsBusinessLogic.handleDelete(resource.getUniqueId(), artifactId, importCsarInfo.getModifier(), AuditingActionEnum.ARTIFACT_DELETE, ComponentTypeEnum.RESOURCE,
resource, null, null, shouldLock, inTransaction);
if (handleDelete.isRight()) {
log.debug("Couldn't delete artifact {}", artifactId);
@@ -1870,18 +2018,18 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.left(resource);
}
- private Either<Boolean, ResponseFormat> createOrUpdateSingleNonMetaArtifact(Resource resource, User user, String csarUUID, Map<String, byte[]> csar, String artifactPath, String artifactFileName, String artifactType,
- ArtifactGroupTypeEnum artifactGroupType, String artifactLabel, String artifactDisplayName, String artifactDescription, String artifactId, ArtifactOperationInfo operation, List<ArtifactDefinition> createdArtifacts, boolean shouldLock,
- boolean inTransaction) {
+ private Either<Boolean, ResponseFormat> createOrUpdateSingleNonMetaArtifact(Resource resource, ImportCsarInfo importCsarInfo, String artifactPath, String artifactFileName, String artifactType,
+ ArtifactGroupTypeEnum artifactGroupType, String artifactLabel, String artifactDisplayName, String artifactDescription, String artifactId, ArtifactOperationInfo operation, List<ArtifactDefinition> createdArtifacts, boolean shouldLock,
+ boolean inTransaction) {
byte[] artifactFileBytes = null;
- if (csar.containsKey(artifactPath)) {
- artifactFileBytes = csar.get(artifactPath);
+ if (importCsarInfo.getCsar().containsKey(artifactPath)) {
+ artifactFileBytes = importCsarInfo.getCsar().get(artifactPath);
}
Either<Boolean, ResponseFormat> result = Either.left(true);
if (operation.getArtifactOperationEnum() == ArtifactOperationEnum.Update || operation.getArtifactOperationEnum() == ArtifactOperationEnum.Delete) {
if (artifactId != null && !artifactId.isEmpty() && artifactFileBytes == null) {
- Either<Either<ArtifactDefinition, Operation>, ResponseFormat> handleDelete = artifactsBusinessLogic.handleDelete(resource.getUniqueId(), artifactId, user, AuditingActionEnum.ARTIFACT_DELETE, ComponentTypeEnum.RESOURCE, resource, null,
+ Either<Either<ArtifactDefinition, Operation>, ResponseFormat> handleDelete = artifactsBusinessLogic.handleDelete(resource.getUniqueId(), artifactId, importCsarInfo.getModifier(), AuditingActionEnum.ARTIFACT_DELETE, ComponentTypeEnum.RESOURCE, resource, null,
null, shouldLock, inTransaction);
if (handleDelete.isRight()) {
result = Either.right(handleDelete.right().value());
@@ -1896,10 +2044,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
if (artifactFileBytes != null) {
Map<String, Object> vendorLicenseModelJson = buildJsonForUpdateArtifact(artifactId, artifactFileName, artifactType, artifactGroupType, artifactLabel, artifactDisplayName, artifactDescription, artifactFileBytes, null);
- Either<Either<ArtifactDefinition, Operation>, ResponseFormat> eitherNonMetaArtifacts = createOrUpdateCsarArtifactFromJson(resource, user, vendorLicenseModelJson, operation, shouldLock, inTransaction);
+ Either<Either<ArtifactDefinition, Operation>, ResponseFormat> eitherNonMetaArtifacts = createOrUpdateCsarArtifactFromJson(resource, importCsarInfo.getModifier(), vendorLicenseModelJson, operation, shouldLock, inTransaction);
addNonMetaCreatedArtifactsToSupportRollback(operation, createdArtifacts, eitherNonMetaArtifacts);
if (eitherNonMetaArtifacts.isRight()) {
- BeEcompErrorManager.getInstance().logInternalFlowError("UploadLicenseArtifact", "Failed to upload license artifact: " + artifactFileName + "With csar uuid: " + csarUUID, ErrorSeverity.WARNING);
+ BeEcompErrorManager.getInstance().logInternalFlowError("UploadLicenseArtifact", "Failed to upload license artifact: " + artifactFileName + "With csar uuid: " + importCsarInfo.getCsarUUID(), ErrorSeverity.WARNING);
return Either.right(eitherNonMetaArtifacts.right().value());
}
}
@@ -1930,13 +2078,13 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.left(uploadArtifactToService.left().value());
}
- public Either<Resource, ResponseFormat> updateResourceArtifactsFromCsar(String csarUUID, Map<String, byte[]> csar, Resource resource, User user, String artifactsMetaFile, String artifactsMetaFileName, List<ArtifactDefinition> createdNewArtifacts,
- boolean shouldLock, boolean inTransaction) {
+ public Either<Resource, ResponseFormat> updateResourceArtifactsFromCsar(ImportCsarInfo importCsarInfo, Resource resource, String artifactsMetaFile, String artifactsMetaFileName, List<ArtifactDefinition> createdNewArtifacts,
+ boolean shouldLock, boolean inTransaction) {
- Either<Map<String, List<ArtifactTemplateInfo>>, ResponseFormat> parseResourceInfoFromYamlEither = parseResourceArtifactsInfoFromFile(resource, artifactsMetaFile, artifactsMetaFileName, user);
+ Either<Map<String, List<ArtifactTemplateInfo>>, ResponseFormat> parseResourceInfoFromYamlEither = parseResourceArtifactsInfoFromFile(resource, artifactsMetaFile, artifactsMetaFileName, importCsarInfo.getModifier());
if (parseResourceInfoFromYamlEither.isRight()) {
ResponseFormat responseFormat = parseResourceInfoFromYamlEither.right().value();
- componentsUtils.auditResource(responseFormat, user, resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
+ componentsUtils.auditResource(responseFormat, importCsarInfo.getModifier(), resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
return Either.right(responseFormat);
}
@@ -1960,7 +2108,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
}
}
- return createResourceArtifacts(csarUUID, csar, resource, user, parseResourceInfoFromYamlEither.left().value(), AuditingActionEnum.CREATE_RESOURCE, createdNewArtifacts, shouldLock, inTransaction);
+ return createResourceArtifacts(importCsarInfo, resource, parseResourceInfoFromYamlEither.left().value(), AuditingActionEnum.CREATE_RESOURCE, createdNewArtifacts, shouldLock, inTransaction);
}
// find master in group
@@ -1996,7 +2144,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<GroupDefinition, MergedArtifactInfo> mergedgroup = mergeGroupInUpdateFlow(groupArtifact, parsedGroup, artifactsToDelete, groupToDelete, jsonMasterArtifacts, createdDeplymentArtifactsAfterDelete);
// Set<String> deletedArtifactsName = new HashSet<String>();
- Either<List<ArtifactDefinition>, ResponseFormat> deletedArtifactsEither = deleteArtifactsInUpdateCsarFlow(resource, user, shouldLock, inTransaction, artifactsToDelete, groupToDelete);
+ Either<List<ArtifactDefinition>, ResponseFormat> deletedArtifactsEither = deleteArtifactsInUpdateCsarFlow(resource, importCsarInfo.getModifier(), shouldLock, inTransaction, artifactsToDelete, groupToDelete);
if (deletedArtifactsEither.isRight()) {
log.debug("Failed to delete artifacts. Status is {} ", deletedArtifactsEither.right().value());
@@ -2023,8 +2171,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
////////////// dissociate, associate or create
////////////// artifacts////////////////////////////
- Either<Resource, ResponseFormat> assDissotiateEither = associateAndDissociateArtifactsToGroup(csarUUID, csar, resource, user, createdNewArtifacts, labelCounter, shouldLock, inTransaction, createdDeplymentArtifactsAfterDelete,
- mergedgroup, deletedArtifacts);
+ Either<Resource, ResponseFormat> assDissotiateEither = associateAndDissociateArtifactsToGroup(importCsarInfo, resource, createdNewArtifacts, labelCounter, shouldLock, inTransaction, createdDeplymentArtifactsAfterDelete,
+ mergedgroup, deletedArtifacts);
if (assDissotiateEither.isRight()) {
log.debug("Failed to delete artifacts. Status is {} ", assDissotiateEither.right().value());
@@ -2042,7 +2190,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
groups = resource.getGroups();
- List<GroupDefinition> groupToUpdate = new ArrayList<>();
+
// update vfModule names
Set<GroupDefinition> groupForAssociateWithMembers = mergedgroup.keySet();
if (groups != null && !groups.isEmpty()) {
@@ -2056,30 +2204,22 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
;
for (GroupDefinition updatedGroupDef : groupForAssociateWithMembers) {
- GroupDefinition group = null;
- Optional<GroupDefinition> opGr = groups.stream().filter(p -> p.getUniqueId().equals(updatedGroupDef.getUniqueId())).findAny();
- if (opGr.isPresent()) {
- group = opGr.get();
- groupToUpdate.add(group);
- }
- if (group != null) {
- Map<String, String> members = new HashMap<String, String>();
- Set<String> artifactsGroup = new HashSet<String>();
- artifactsGroup.addAll(group.getArtifacts());
- associateMembersToArtifacts(createdNewArtifacts, createdDeplymentArtifactsAfterDelete, heatGroups, artifactsGroup, members);
- if (!members.isEmpty()) {
- group.setMembers(members);
- }
+ if (updatedGroupDef.getMembers() != null && !updatedGroupDef.getMembers().isEmpty()) {
+ updatedGroupDef.getMembers().clear();
+ }
+ Map<String, String> members = new HashMap<String, String>();
+ Set<String> artifactsGroup = new HashSet<String>();
+ artifactsGroup.addAll(updatedGroupDef.getArtifacts());
+ associateMembersToArtifacts(createdNewArtifacts, createdDeplymentArtifactsAfterDelete, heatGroups, artifactsGroup, members);
+ if (!members.isEmpty()) {
+ updatedGroupDef.setMembers(members);
+
}
+
}
- /*
- * if (!groupToUpdate.isEmpty()) { Either<List<GroupDefinition>, ResponseFormat> assotiateGroupEither = groupBusinessLogic.associateMembersToGroup(resource.getUniqueId(), user.getUserId(), ComponentTypeEnum.RESOURCE, groupToUpdate, false,
- * true); if (assotiateGroupEither.isRight()) { log.debug("Failed to associate artifacts to groups. Status is {} ", assotiateGroupEither.right().value()); return Either.right(assotiateGroupEither.right().value());
- *
- * } }
- */
+
}
@@ -2111,7 +2251,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (validateGroupNamesRes.isRight()) {
return Either.right(validateGroupNamesRes.right().value());
}
- Either<Resource, ResponseFormat> resStatus = createGroupDeploymentArtifactsFromCsar(csarUUID, csar, resource, user, newArtifactsGroup, createdNewArtifacts, createdDeplymentArtifactsAfterDelete, labelCounter, shouldLock, inTransaction);
+ Either<Resource, ResponseFormat> resStatus = createGroupDeploymentArtifactsFromCsar(importCsarInfo, resource, newArtifactsGroup, createdNewArtifacts, createdDeplymentArtifactsAfterDelete, labelCounter, shouldLock, inTransaction);
if (resStatus.isRight())
return resStatus;
}
@@ -2142,7 +2282,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private Either<List<ArtifactDefinition>, ResponseFormat> deleteArtifactsInUpdateCsarFlow(Resource resource, User user, boolean shouldLock, boolean inTransaction, Set<ArtifactDefinition> artifactsToDelete,
- Map<String, List<ArtifactDefinition>> groupToDelete) {
+ Map<String, List<ArtifactDefinition>> groupToDelete) {
List<ArtifactDefinition> deletedArtifacts = new ArrayList<ArtifactDefinition>();
String resourceId = resource.getUniqueId();
if (!artifactsToDelete.isEmpty()) {
@@ -2159,9 +2299,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
* deletedArtifacts.add(removeArifactFromGraph.left().value());
*/
- }
-
- else {
+ } else {
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> handleDelete = artifactsBusinessLogic.handleDelete(resourceId, artifact.getUniqueId(), user, AuditingActionEnum.ARTIFACT_DELETE, ComponentTypeEnum.RESOURCE, resource,
null, null, shouldLock, inTransaction);
if (handleDelete.isRight()) {
@@ -2194,8 +2332,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.left(deletedArtifacts);
}
- private Either<Resource, ResponseFormat> associateAndDissociateArtifactsToGroup(String csarUUID, Map<String, byte[]> csar, Resource resource, User user, List<ArtifactDefinition> createdNewArtifacts, int labelCounter, boolean shouldLock,
- boolean inTransaction, List<ArtifactDefinition> createdDeplymentArtifactsAfterDelete, Map<GroupDefinition, MergedArtifactInfo> mergedgroup, List<ArtifactDefinition> deletedArtifacts) {
+ private Either<Resource, ResponseFormat> associateAndDissociateArtifactsToGroup(ImportCsarInfo importCsarInfo, Resource resource, List<ArtifactDefinition> createdNewArtifacts, int labelCounter, boolean shouldLock,
+ boolean inTransaction, List<ArtifactDefinition> createdDeplymentArtifactsAfterDelete, Map<GroupDefinition, MergedArtifactInfo> mergedgroup, List<ArtifactDefinition> deletedArtifacts) {
Map<GroupDefinition, List<ArtifactTemplateInfo>> artifactsToAssotiate = new HashMap<GroupDefinition, List<ArtifactTemplateInfo>>();
Map<GroupDefinition, List<ImmutablePair<ArtifactDefinition, ArtifactTemplateInfo>>> artifactsToUpdateMap = new HashMap<GroupDefinition, List<ImmutablePair<ArtifactDefinition, ArtifactTemplateInfo>>>();
Either<Resource, ResponseFormat> resEither = Either.left(resource);
@@ -2212,7 +2350,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
List<ArtifactTemplateInfo> newArtifactsInGroup = entry.getValue().getListToAssociateArtifactToGroup();
if (newArtifactsInGroup != null && !newArtifactsInGroup.isEmpty())
artifactsToAssotiate.put(entry.getKey(), newArtifactsInGroup);
-
List<ImmutablePair<ArtifactDefinition, ArtifactTemplateInfo>> artifactsToUpdate = entry.getValue().getListToUpdateArtifactInGroup();
if (artifactsToUpdate != null && !artifactsToUpdate.isEmpty())
@@ -2224,11 +2361,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
for (Entry<GroupDefinition, List<ImmutablePair<ArtifactDefinition, ArtifactTemplateInfo>>> artifactsToUpdateEntry : artifactsToUpdateMap.entrySet()) {
List<ImmutablePair<ArtifactDefinition, ArtifactTemplateInfo>> artifactsToUpdateList = artifactsToUpdateEntry.getValue();
GroupDefinition groupToUpdate = artifactsToUpdateEntry.getKey();
-
+
for (ImmutablePair<ArtifactDefinition, ArtifactTemplateInfo> artifact : artifactsToUpdateList) {
String prevUUID = artifact.getKey().getArtifactUUID();
String prevId = artifact.getKey().getUniqueId();
- Either<ArtifactDefinition, ResponseFormat> updateArtifactEither = updateDeploymentArtifactsFromCsar(csarUUID, csar, resource, user, artifact.getKey(), artifact.getValue(), updatedArtifacts,
+ Either<ArtifactDefinition, ResponseFormat> updateArtifactEither = updateDeploymentArtifactsFromCsar(importCsarInfo, resource, artifact.getKey(), artifact.getValue(), updatedArtifacts,
artifact.getRight().getRelatedArtifactsInfo(), shouldLock, inTransaction);
if (updateArtifactEither.isRight()) {
log.debug("failed to update artifacts. status is {}", updateArtifactEither.right().value());
@@ -2236,7 +2373,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return resEither;
}
ArtifactDefinition artAfterUpdate = updateArtifactEither.left().value();
- if ( !prevUUID.equals(artAfterUpdate.getArtifactUUID()) || !prevId.equals(artAfterUpdate.getUniqueId()) ){
+ if (!prevUUID.equals(artAfterUpdate.getArtifactUUID()) || !prevId.equals(artAfterUpdate.getUniqueId())) {
groupToUpdate.getArtifacts().remove(prevId);
groupToUpdate.getArtifactsUuid().remove(prevUUID);
groupToUpdate.getArtifacts().add(artAfterUpdate.getUniqueId());
@@ -2251,6 +2388,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
for (Entry<GroupDefinition, List<ArtifactTemplateInfo>> associateEntry : artifactsToAssotiate.entrySet()) {
List<ArtifactTemplateInfo> associatedArtifact = associateEntry.getValue();
Set<String> arifactsUids = new HashSet<String>();
+ Set<String> arifactsUuids = new HashSet<String>();
for (ArtifactTemplateInfo artifactTemplate : associatedArtifact) { // try
// to
// find
@@ -2261,6 +2399,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
for (ArtifactDefinition createdArtifact : createdDeplymentArtifactsAfterDelete) {
if (artifactTemplate.getFileName().equalsIgnoreCase(createdArtifact.getArtifactName())) {
arifactsUids.add(createdArtifact.getUniqueId());
+ arifactsUuids.add(createdArtifact.getUniqueId());
isCreate = false;
String heatEnvId = checkAndGetHeatEnvId(createdArtifact);
if (!heatEnvId.isEmpty()) {
@@ -2280,6 +2419,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
for (ArtifactDefinition createdNewArtifact : createdNewArtifacts) {
if (artifactTemplate.getFileName().equalsIgnoreCase(createdNewArtifact.getArtifactName())) {
arifactsUids.add(createdNewArtifact.getUniqueId());
+ arifactsUuids.add(createdNewArtifact.getUniqueId());
isCreate = false;
String heatEnvId = checkAndGetHeatEnvId(createdNewArtifact);
if (!heatEnvId.isEmpty()) {
@@ -2291,17 +2431,18 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
if (isCreate) {
- Either<ArtifactDefinition, ResponseFormat> createArtifactEither = createDeploymentArtifact(csarUUID, csar, resource, user, ARTIFACTS_PATH, artifactTemplate, createdNewArtifacts, labelCounter, shouldLock, inTransaction);
+ Either<ArtifactDefinition, ResponseFormat> createArtifactEither = createDeploymentArtifact(importCsarInfo, resource, ARTIFACTS_PATH, artifactTemplate, createdNewArtifacts, labelCounter, shouldLock, inTransaction);
if (createArtifactEither.isRight()) {
resEither = Either.right(createArtifactEither.right().value());
return resEither;
}
ArtifactDefinition createdArtifact = createArtifactEither.left().value();
arifactsUids.add(createdArtifact.getUniqueId());
+ arifactsUuids.add(createdArtifact.getUniqueId());
ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(createdArtifact.getArtifactType());
if (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_VOL) {
Either<ArtifactDefinition, ResponseFormat> createHeatEnvPlaceHolder = artifactsBusinessLogic.createHeatEnvPlaceHolder(createdArtifact, ArtifactsBusinessLogic.HEAT_VF_ENV_NAME, resource.getUniqueId(), NodeTypeEnum.Resource,
- resource.getName(), user, resource, null);
+ resource.getName(), importCsarInfo.getModifier(), resource, null);
if (createHeatEnvPlaceHolder.isRight()) {
return Either.right(createHeatEnvPlaceHolder.right().value());
}
@@ -2314,11 +2455,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (arifactsUids.size() > 0) {
List<String> artifactsToAssociate = new ArrayList<String>();
artifactsToAssociate.addAll(arifactsUids);
- GroupDefinition assotiateGroup = new GroupDefinition();
- assotiateGroup.setUniqueId(associateEntry.getKey().getUniqueId());
- assotiateGroup.setArtifacts(artifactsToAssociate);
- associateArtifactGroup.add(assotiateGroup);
-
+ GroupDefinition assotiateGroup = associateEntry.getKey();
+ assotiateGroup.getArtifacts().addAll(arifactsUids);
+ assotiateGroup.getArtifactsUuid().addAll(arifactsUuids);
}
}
@@ -2354,7 +2493,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private Map<GroupDefinition, MergedArtifactInfo> mergeGroupInUpdateFlow(Map<GroupDefinition, Map<ArtifactDefinition, List<ArtifactDefinition>>> groupArtifact, Map<ArtifactTemplateInfo, Set<ArtifactTemplateInfo>> parsedGroup,
- Set<ArtifactDefinition> artifactsToDelete, Map<String, List<ArtifactDefinition>> groupToDelete, Set<ArtifactTemplateInfo> jsonMasterArtifacts, List<ArtifactDefinition> createdDeplymentArtifacts) {
+ Set<ArtifactDefinition> artifactsToDelete, Map<String, List<ArtifactDefinition>> groupToDelete, Set<ArtifactTemplateInfo> jsonMasterArtifacts, List<ArtifactDefinition> createdDeplymentArtifacts) {
Map<GroupDefinition, MergedArtifactInfo> mergedgroup = new HashMap<GroupDefinition, MergedArtifactInfo>();
for (Entry<GroupDefinition, Map<ArtifactDefinition, List<ArtifactDefinition>>> groupListEntry : groupArtifact.entrySet()) {
Map<ArtifactDefinition, List<ArtifactDefinition>> createdArtifactMap = groupListEntry.getValue();
@@ -2365,21 +2504,21 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
for (ArtifactDefinition artToDelete : listToDelete) {
findArtifactToDelete(parsedGroup, artifactsToDelete, groupListEntry.getKey().getUniqueId(), artToDelete, createdDeplymentArtifacts);
}
- if(artifactsToDelete != null && !artifactsToDelete.isEmpty()){
+ if (artifactsToDelete != null && !artifactsToDelete.isEmpty()) {
GroupDefinition group = groupListEntry.getKey();
- for(ArtifactDefinition artifactDefinition: artifactsToDelete){
+ for (ArtifactDefinition artifactDefinition : artifactsToDelete) {
if (CollectionUtils.isNotEmpty(group.getArtifacts()) && group.getArtifacts().contains(artifactDefinition.getUniqueId())) {
group.getArtifacts().remove(artifactDefinition.getUniqueId());
-
+
}
if (CollectionUtils.isNotEmpty(group.getArtifactsUuid()) && group.getArtifactsUuid().contains(artifactDefinition.getArtifactUUID())) {
group.getArtifactsUuid().remove(artifactDefinition.getArtifactUUID());
-
+
}
}
-
+
}
-
+
for (ArtifactTemplateInfo jsonMasterArtifact : jsonMasterArtifacts) {
if (maserArtifact.getArtifactName().equalsIgnoreCase(jsonMasterArtifact.getFileName())) {
MergedArtifactInfo mergedGroup = new MergedArtifactInfo();
@@ -2400,34 +2539,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return mergedgroup;
}
- private Set<String> findArtifactsNotInGroupToDelete(List<GroupDefinition> groups, List<ArtifactDefinition> createdDeplymentArtifactsAfterDelete) {
- Set<String> artifactNotInGroupSet = new HashSet<String>();
- for (ArtifactDefinition artifact : createdDeplymentArtifactsAfterDelete) {
- boolean needToDelete = true;
- if (artifact.getArtifactName().equalsIgnoreCase(Constants.VENDOR_LICENSE_MODEL) || artifact.getArtifactName().equalsIgnoreCase(Constants.VF_LICENSE_MODEL))
- continue;
- if (groups != null) {
- for (GroupDefinition group : groups) {
- List<String> groupArtifactIds = group.getArtifacts();
- if (groupArtifactIds == null || groupArtifactIds.isEmpty()) {
- continue;
- }
- for (String groupArtifactid : groupArtifactIds) {
- if (groupArtifactid.equalsIgnoreCase(artifact.getUniqueId()))
- needToDelete = false;
-
- }
-
- }
- }
- if (needToDelete)
- artifactNotInGroupSet.add(artifact.getUniqueId());
- }
- return artifactNotInGroupSet;
- }
-
private void findArtifactToDelete(Map<ArtifactTemplateInfo, Set<ArtifactTemplateInfo>> parsedGroup, Set<ArtifactDefinition> artifactsToDelete, String deleteGroupId, ArtifactDefinition artifact,
- List<ArtifactDefinition> createdDeplymentArtifacts) {
+ List<ArtifactDefinition> createdDeplymentArtifacts) {
boolean isNeedToDeleteArtifact = true;
String artifactType = artifact.getArtifactType();
ArtifactDefinition generatedFromArt = null;
@@ -2492,20 +2605,20 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
}
- public Either<Resource, ResponseFormat> createResourceArtifactsFromCsar(String csarUUID, Map<String, byte[]> csar, Resource resource, User user, String artifactsMetaFile, String artifactsMetaFileName, List<ArtifactDefinition> createdArtifacts,
- boolean shouldLock, boolean inTransaction) {
+ public Either<Resource, ResponseFormat> createResourceArtifactsFromCsar(ImportCsarInfo importCsarInfo, Resource resource, String artifactsMetaFile, String artifactsMetaFileName, List<ArtifactDefinition> createdArtifacts,
+ boolean shouldLock, boolean inTransaction) {
log.debug("parseResourceArtifactsInfoFromFile start");
- Either<Map<String, List<ArtifactTemplateInfo>>, ResponseFormat> parseResourceInfoFromYamlEither = parseResourceArtifactsInfoFromFile(resource, artifactsMetaFile, artifactsMetaFileName, user);
+ Either<Map<String, List<ArtifactTemplateInfo>>, ResponseFormat> parseResourceInfoFromYamlEither = parseResourceArtifactsInfoFromFile(resource, artifactsMetaFile, artifactsMetaFileName, importCsarInfo.getModifier());
if (parseResourceInfoFromYamlEither.isRight()) {
ResponseFormat responseFormat = parseResourceInfoFromYamlEither.right().value();
- componentsUtils.auditResource(responseFormat, user, resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
+ componentsUtils.auditResource(responseFormat, importCsarInfo.getModifier(), resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
return Either.right(responseFormat);
}
log.debug("parseResourceArtifactsInfoFromFile end");
log.debug("createResourceArtifacts start");
- Either<Resource, ResponseFormat> respStatus = createResourceArtifacts(csarUUID, csar, resource, user, parseResourceInfoFromYamlEither.left().value(), AuditingActionEnum.CREATE_RESOURCE, createdArtifacts, shouldLock, inTransaction);
+ Either<Resource, ResponseFormat> respStatus = createResourceArtifacts(importCsarInfo, resource, parseResourceInfoFromYamlEither.left().value(), AuditingActionEnum.CREATE_RESOURCE, createdArtifacts, shouldLock, inTransaction);
if (respStatus.isRight()) {
return respStatus;
}
@@ -2523,8 +2636,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
- private Either<Resource, ResponseFormat> createGroupDeploymentArtifactsFromCsar(String csarUUID, Map<String, byte[]> csar, Resource resource, User user, List<ArtifactTemplateInfo> artifactsTemplateList,
- List<ArtifactDefinition> createdNewArtifacts, List<ArtifactDefinition> artifactsFromResource, int labelCounter, boolean shouldLock, boolean inTransaction) {
+ private Either<Resource, ResponseFormat> createGroupDeploymentArtifactsFromCsar(ImportCsarInfo importCsarInfo, Resource resource, List<ArtifactTemplateInfo> artifactsTemplateList,
+ List<ArtifactDefinition> createdNewArtifacts, List<ArtifactDefinition> artifactsFromResource, int labelCounter, boolean shouldLock, boolean inTransaction) {
Either<Resource, ResponseFormat> resStatus = Either.left(resource);
List<GroupDefinition> createdGroups = resource.getGroups();
List<GroupDefinition> heatGroups = null;
@@ -2538,7 +2651,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Set<String> artifactsGroup = new HashSet<String>();
Set<String> artifactsUUIDGroup = new HashSet<String>();
- resStatus = createDeploymentArtifactsFromCsar(csarUUID, csar, resource, user, artifactsGroup, artifactsUUIDGroup, groupTemplateInfo, createdNewArtifacts, artifactsFromResource, labelCounter, shouldLock, inTransaction);
+ resStatus = createDeploymentArtifactsFromCsar(importCsarInfo, resource, artifactsGroup, artifactsUUIDGroup, groupTemplateInfo, createdNewArtifacts, artifactsFromResource, labelCounter, shouldLock, inTransaction);
if (resStatus.isRight())
return resStatus;
@@ -2562,7 +2675,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
prop.setName(Constants.IS_BASE);
prop.setValue(Boolean.toString(groupTemplateInfo.isBase()));
properties.add(prop);
-
+
List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
createdArtifacts.addAll(createdNewArtifacts);
createdArtifacts.addAll(artifactsFromResource);
@@ -2590,15 +2703,15 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
resource = component.left().value();
- Either<List<GroupDefinition>, ResponseFormat> addGroups = groupBusinessLogic.addGroups(resource, user, ComponentTypeEnum.RESOURCE, needToAdd);
+ Either<List<GroupDefinition>, ResponseFormat> addGroups = groupBusinessLogic.addGroups(resource, importCsarInfo.getModifier(), ComponentTypeEnum.RESOURCE, needToAdd);
if (addGroups.isRight())
return Either.right(addGroups.right().value());
return resStatus;
}
- private Either<Resource, ResponseFormat> createDeploymentArtifactsFromCsar(String csarUUID, Map<String, byte[]> csar, Resource resource, User user, Set<String> artifactsGroup, Set<String> artifactsUUIDGroup,
- ArtifactTemplateInfo artifactTemplateInfo, List<ArtifactDefinition> createdArtifacts, List<ArtifactDefinition> artifactsFromResource, int labelCounter, boolean shoudLock, boolean inTransaction) {
+ private Either<Resource, ResponseFormat> createDeploymentArtifactsFromCsar(ImportCsarInfo importCsarInfo, Resource resource, Set<String> artifactsGroup, Set<String> artifactsUUIDGroup,
+ ArtifactTemplateInfo artifactTemplateInfo, List<ArtifactDefinition> createdArtifacts, List<ArtifactDefinition> artifactsFromResource, int labelCounter, boolean shoudLock, boolean inTransaction) {
Either<Resource, ResponseFormat> resStatus = Either.left(resource);
String artifactFileName = artifactTemplateInfo.getFileName();
String artifactUid = "";
@@ -2646,7 +2759,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// if not exist need to create
if (!alreadyExist) {
- Either<ArtifactDefinition, ResponseFormat> newArtifactEither = createDeploymentArtifact(csarUUID, csar, resource, user, ARTIFACTS_PATH, artifactTemplateInfo, createdArtifacts, labelCounter, shoudLock, inTransaction);
+ Either<ArtifactDefinition, ResponseFormat> newArtifactEither = createDeploymentArtifact(importCsarInfo, resource, ARTIFACTS_PATH, artifactTemplateInfo, createdArtifacts, labelCounter, shoudLock, inTransaction);
if (newArtifactEither.isRight()) {
resStatus = Either.right(newArtifactEither.right().value());
return resStatus;
@@ -2657,7 +2770,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(newArtifact.getArtifactType());
if (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_VOL) {
Either<ArtifactDefinition, ResponseFormat> createHeatEnvPlaceHolder = artifactsBusinessLogic.createHeatEnvPlaceHolder(newArtifact, ArtifactsBusinessLogic.HEAT_VF_ENV_NAME, resource.getUniqueId(), NodeTypeEnum.Resource,
- resource.getName(), user, resource, null);
+ resource.getName(), importCsarInfo.getModifier(), resource, null);
if (createHeatEnvPlaceHolder.isRight()) {
return Either.right(createHeatEnvPlaceHolder.right().value());
}
@@ -2674,7 +2787,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
List<ArtifactTemplateInfo> relatedArtifacts = artifactTemplateInfo.getRelatedArtifactsInfo();
if (relatedArtifacts != null) {
for (ArtifactTemplateInfo relatedArtifactTemplateInfo : relatedArtifacts) {
- resStatus = createDeploymentArtifactsFromCsar(csarUUID, csar, resource, user, artifactsGroup, artifactsUUIDGroup, relatedArtifactTemplateInfo, createdArtifacts, artifactsFromResource, labelCounter, shoudLock, inTransaction);
+ resStatus = createDeploymentArtifactsFromCsar(importCsarInfo, resource, artifactsGroup, artifactsUUIDGroup, relatedArtifactTemplateInfo, createdArtifacts, artifactsFromResource, labelCounter, shoudLock, inTransaction);
if (resStatus.isRight())
return resStatus;
}
@@ -2682,8 +2795,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return resStatus;
}
- private Either<Resource, ResponseFormat> createResourceArtifacts(String csarUUID, Map<String, byte[]> csar, Resource resource, User user, Map<String, List<ArtifactTemplateInfo>> artifactsMap, AuditingActionEnum createResource,
- List<ArtifactDefinition> createdArtifacts, boolean shouldLock, boolean inTransaction) {
+ private Either<Resource, ResponseFormat> createResourceArtifacts(ImportCsarInfo importCsarInfo, Resource resource, Map<String, List<ArtifactTemplateInfo>> artifactsMap, AuditingActionEnum createResource,
+ List<ArtifactDefinition> createdArtifacts, boolean shouldLock, boolean inTransaction) {
Either<Resource, ResponseFormat> resStatus = Either.left(resource);
@@ -2691,7 +2804,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
for (List<ArtifactTemplateInfo> groupTemplateList : arifactsCollection) {
if (groupTemplateList != null) {
- resStatus = createGroupDeploymentArtifactsFromCsar(csarUUID, csar, resource, user, groupTemplateList, createdArtifacts, 0, shouldLock, inTransaction);
+ resStatus = createGroupDeploymentArtifactsFromCsar(importCsarInfo, resource, groupTemplateList, createdArtifacts, 0, shouldLock, inTransaction);
if (resStatus.isRight())
return resStatus;
}
@@ -2701,8 +2814,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
- private Either<Resource, ResponseFormat> createOrUpdateNonMetaArtifacts(String csarUUID, Map<String, byte[]> csar, Resource resource, User user, List<ArtifactDefinition> createdArtifacts, boolean shouldLock, boolean inTransaction,
- ArtifactOperationInfo artifactOperation) {
+ private Either<Resource, ResponseFormat> createOrUpdateNonMetaArtifacts(ImportCsarInfo importCsarInfo, Resource resource, List<ArtifactDefinition> createdArtifacts, boolean shouldLock, boolean inTransaction, ArtifactOperationInfo artifactOperation) {
Either<Resource, ResponseFormat> resStatus = null;
Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
@@ -2710,7 +2822,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
try {
List<NonMetaArtifactInfo> artifactPathAndNameList =
// Stream of file paths contained in csar
- csar.entrySet().stream()
+ importCsarInfo.getCsar().entrySet().stream()
// Filter in only VF artifact path location
.filter(e -> Pattern.compile(VF_NODE_TYPE_ARTIFACTS_PATH_PATTERN).matcher(e.getKey()).matches())
// Validate and add warnings
@@ -2722,13 +2834,19 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// collect to List
.collect(Collectors.toList());
+ Either<Boolean, String> responseFormatEither = validateArtifactNames(artifactPathAndNameList);
+ if (responseFormatEither.isRight()) {
+ return Either.right(getComponentsUtils().getResponseFormatByArtifactId(ActionStatus.ARTIFACT_NAME_INVALID, responseFormatEither.right().value()));
+ }
+
+
EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>> vfCsarArtifactsToHandle = null;
if (artifactOperation.getArtifactOperationEnum() == ArtifactOperationEnum.Create) {
vfCsarArtifactsToHandle = new EnumMap<>(ArtifactOperationEnum.class);
vfCsarArtifactsToHandle.put(artifactOperation.getArtifactOperationEnum(), artifactPathAndNameList);
} else {
- Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat> findVfCsarArtifactsToHandleRes = findVfCsarArtifactsToHandle(resource, artifactPathAndNameList, user);
+ Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat> findVfCsarArtifactsToHandleRes = findVfCsarArtifactsToHandle(resource, artifactPathAndNameList, importCsarInfo.getModifier());
if (findVfCsarArtifactsToHandleRes.isRight()) {
resStatus = Either.right(findVfCsarArtifactsToHandleRes.right().value());
@@ -2744,15 +2862,15 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// Stream of artifacts to be created
currArtifactOperationPair.getValue().stream()
// create each artifact
- .map(e -> createOrUpdateSingleNonMetaArtifact(resource, user, csarUUID, csar, e.getPath(), e.getArtifactName(), e.getArtifactType().getType(), e.getArtifactGroupType(), e.getArtifactLabel(), e.getDisplayName(),
+ .map(e -> createOrUpdateSingleNonMetaArtifact(resource, importCsarInfo, e.getPath(), e.getArtifactName(), e.getArtifactType().getType(), e.getArtifactGroupType(), e.getArtifactLabel(), e.getDisplayName(),
CsarUtils.ARTIFACT_CREATED_FROM_CSAR, e.getArtifactUniqueId(), artifactsBusinessLogic.new ArtifactOperationInfo(false, false, currArtifactOperationPair.getKey()), createdArtifacts, shouldLock,
inTransaction))
// filter in only error
.filter(e -> e.isRight()).
// Convert the error from either to ResponseFormat
- map(e -> e.right().value()).
+ map(e -> e.right().value()).
// Check if an error occurred
- findAny();
+ findAny();
// Error found on artifact Creation
if (optionalCreateInDBError.isPresent()) {
resStatus = Either.right(optionalCreateInDBError.get());
@@ -2772,6 +2890,17 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return resStatus;
}
+ private Either<Boolean, String> validateArtifactNames(List<NonMetaArtifactInfo> artifactPathAndNameList) {
+ Pattern englishNumbersAndUnderScoresOnly = Pattern.compile(CsarUtils.VALID_ENGLISH_ARTIFACT_NAME);
+ for (NonMetaArtifactInfo nonMetaArtifactInfo : artifactPathAndNameList) {
+ if (!englishNumbersAndUnderScoresOnly.matcher(nonMetaArtifactInfo.getDisplayName()).matches()) {
+ return Either.right(nonMetaArtifactInfo.getArtifactName());
+ }
+ }
+ return Either.left(true);
+ }
+
+
private Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat> findVfCsarArtifactsToHandle(Resource resource, List<NonMetaArtifactInfo> artifactPathAndNameList, User user) {
List<ArtifactDefinition> existingArtifacts = new ArrayList<>();
@@ -2816,8 +2945,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return result;
}
- private Either<Resource, ResponseFormat> createGroupDeploymentArtifactsFromCsar(String csarUUID, Map<String, byte[]> csar, Resource resource, User user, List<ArtifactTemplateInfo> artifactsTemplateList, List<ArtifactDefinition> createdArtifacts,
- int labelCounter, boolean shouldLock, boolean inTransaction) {
+ private Either<Resource, ResponseFormat> createGroupDeploymentArtifactsFromCsar(ImportCsarInfo importCsarInfo, Resource resource, List<ArtifactTemplateInfo> artifactsTemplateList, List<ArtifactDefinition> createdArtifacts,
+ int labelCounter, boolean shouldLock, boolean inTransaction) {
Either<Resource, ResponseFormat> resStatus = Either.left(resource);
List<GroupDefinition> createdGroups = resource.getGroups();
List<GroupDefinition> heatGroups = null;
@@ -2840,7 +2969,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Set<String> artifactsUUIDGroup = new HashSet<String>();
log.debug("createDeploymentArtifactsFromCsar start");
- resStatus = createDeploymentArtifactFromCsar(csarUUID, ARTIFACTS_PATH, csar, resource, user, artifactsGroup, artifactsUUIDGroup, groupTemplateInfo, createdArtifacts, labelCounter, shouldLock, inTransaction);
+ resStatus = createDeploymentArtifactFromCsar(importCsarInfo, ARTIFACTS_PATH, resource, artifactsGroup, artifactsUUIDGroup, groupTemplateInfo, createdArtifacts, labelCounter, shouldLock, inTransaction);
log.debug("createDeploymentArtifactsFromCsar end");
if (resStatus.isRight())
return resStatus;
@@ -2895,7 +3024,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
}
- Either<List<GroupDefinition>, ResponseFormat> createGroups = groupBusinessLogic.addGroups(component.left().value(), user, ComponentTypeEnum.RESOURCE, needToCreate);
+ Either<List<GroupDefinition>, ResponseFormat> createGroups = groupBusinessLogic.addGroups(component.left().value(), importCsarInfo.getModifier(), ComponentTypeEnum.RESOURCE, needToCreate);
if (createGroups.isRight()) {
return Either.right(createGroups.right().value());
}
@@ -3004,8 +3133,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
}
- private Either<Resource, ResponseFormat> createDeploymentArtifactFromCsar(String csarUUID, String artifactPath, Map<String, byte[]> csar, Resource resource, User user, Set<String> artifactsGroup, Set<String> artifactsUUIDGroup,
- ArtifactTemplateInfo artifactTemplateInfo, List<ArtifactDefinition> createdArtifacts, int labelCounter, boolean shoudLock, boolean inTransaction) {
+ private Either<Resource, ResponseFormat> createDeploymentArtifactFromCsar(ImportCsarInfo importCsarInfo, String artifactPath, Resource resource, Set<String> artifactsGroup, Set<String> artifactsUUIDGroup,
+ ArtifactTemplateInfo artifactTemplateInfo, List<ArtifactDefinition> createdArtifacts, int labelCounter, boolean shoudLock, boolean inTransaction) {
Either<Resource, ResponseFormat> resStatus = Either.left(resource);
String artifactFileName = artifactTemplateInfo.getFileName();
String artifactUid = "";
@@ -3031,7 +3160,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// if not exist need to create
if (!alreadyExist) {
- Either<ArtifactDefinition, ResponseFormat> newArtifactEither = createDeploymentArtifact(csarUUID, csar, resource, user, artifactPath, artifactTemplateInfo, createdArtifacts, labelCounter, shoudLock, inTransaction);
+ Either<ArtifactDefinition, ResponseFormat> newArtifactEither = createDeploymentArtifact(importCsarInfo, resource, artifactPath, artifactTemplateInfo, createdArtifacts, labelCounter, shoudLock, inTransaction);
if (newArtifactEither.isRight()) {
resStatus = Either.right(newArtifactEither.right().value());
return resStatus;
@@ -3043,7 +3172,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(newArtifact.getArtifactType());
if (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_VOL) {
Either<ArtifactDefinition, ResponseFormat> createHeatEnvPlaceHolder = artifactsBusinessLogic.createHeatEnvPlaceHolder(newArtifact, ArtifactsBusinessLogic.HEAT_VF_ENV_NAME, resource.getUniqueId(), NodeTypeEnum.Resource,
- resource.getName(), user, resource, null);
+ resource.getName(), importCsarInfo.getModifier(), resource, null);
if (createHeatEnvPlaceHolder.isRight()) {
return Either.right(createHeatEnvPlaceHolder.right().value());
}
@@ -3060,7 +3189,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
List<ArtifactTemplateInfo> relatedArtifacts = artifactTemplateInfo.getRelatedArtifactsInfo();
if (relatedArtifacts != null) {
for (ArtifactTemplateInfo relatedArtifactTemplateInfo : relatedArtifacts) {
- resStatus = createDeploymentArtifactFromCsar(csarUUID, artifactPath, csar, resource, user, artifactsGroup, artifactsUUIDGroup, relatedArtifactTemplateInfo, createdArtifacts, labelCounter, shoudLock, inTransaction);
+ resStatus = createDeploymentArtifactFromCsar(importCsarInfo, artifactPath, resource, artifactsGroup, artifactsUUIDGroup, relatedArtifactTemplateInfo, createdArtifacts, labelCounter, shoudLock, inTransaction);
if (resStatus.isRight())
return resStatus;
}
@@ -3077,10 +3206,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return artifactEnvUid;
}
- private Either<ArtifactDefinition, ResponseFormat> createDeploymentArtifact(String csarUUID, Map<String, byte[]> csar, Resource resource, User user, String artifactPath, ArtifactTemplateInfo artifactTemplateInfo,
- List<ArtifactDefinition> createdArtifacts, int labelCounter, boolean shoudLock, boolean inTransaction) {
+ private Either<ArtifactDefinition, ResponseFormat> createDeploymentArtifact(ImportCsarInfo importCsarInfo, Resource resource, String artifactPath, ArtifactTemplateInfo artifactTemplateInfo,
+ List<ArtifactDefinition> createdArtifacts, int labelCounter, boolean shoudLock, boolean inTransaction) {
final String artifactFileName = artifactTemplateInfo.getFileName();
- Either<ImmutablePair<String, byte[]>, ResponseFormat> artifactContententStatus = CsarValidationUtils.getArtifactsContent(csarUUID, csar, artifactPath + artifactFileName, artifactFileName, componentsUtils);
+ Either<ImmutablePair<String, byte[]>, ResponseFormat> artifactContententStatus = CsarValidationUtils.getArtifactsContent(importCsarInfo.getCsarUUID(), importCsarInfo.getCsar(), artifactPath + artifactFileName, artifactFileName, componentsUtils);
if (artifactContententStatus.isRight()) {
return Either.right(artifactContententStatus.right().value());
}
@@ -3088,7 +3217,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, Object> json = buildJsonForArtifact(artifactTemplateInfo, artifactContententStatus.left().value().getValue(), labelCounter);
- Either<Either<ArtifactDefinition, Operation>, ResponseFormat> uploadArtifactToService = createOrUpdateCsarArtifactFromJson(resource, user, json, artifactsBusinessLogic.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.Create),
+ Either<Either<ArtifactDefinition, Operation>, ResponseFormat> uploadArtifactToService = createOrUpdateCsarArtifactFromJson(resource, importCsarInfo.getModifier(), json, artifactsBusinessLogic.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.Create),
shoudLock, inTransaction);
if (uploadArtifactToService.isRight())
@@ -3097,7 +3226,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ArtifactDefinition currentInfo = uploadArtifactToService.left().value().left().value();
if (currentInfo.getHeatParameters() != null) {
- Either<ArtifactDefinition, ResponseFormat> updateEnvEither = updateHeatParamsFromCsar(resource, csarUUID, csar, artifactTemplateInfo, currentInfo, false);
+ Either<ArtifactDefinition, ResponseFormat> updateEnvEither = updateHeatParamsFromCsar(resource, importCsarInfo, artifactTemplateInfo, currentInfo, false);
if (updateEnvEither.isRight()) {
log.debug("failed to update parameters to artifact {}", artifactFileName);
return Either.right(updateEnvEither.right().value());
@@ -3113,30 +3242,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
- private Either<ArtifactDefinition, ResponseFormat> createInformationalArtifact(String csarUUID, Map<String, byte[]> csar, Resource resource, User user, ArtifactTemplateInfo artifactTemplateInfo, int labelCounter, boolean shoudLock,
- boolean inTransaction) {
- final String artifactFileName = artifactTemplateInfo.getFileName();
- String artifactPath = CsarUtils.ARTIFACTS_PATH + CsarUtils.INFORMATIONAL_ARTIFACTS + artifactFileName;
- Either<ImmutablePair<String, byte[]>, ResponseFormat> artifactContententStatus = CsarValidationUtils.getArtifactsContent(csarUUID, csar, artifactPath, artifactFileName, componentsUtils);
- if (artifactContententStatus.isRight())
- return Either.right(artifactContententStatus.right().value());
-
- Map<String, Object> json = buildJsonForArtifact(artifactTemplateInfo, artifactContententStatus.left().value().getValue(), labelCounter);
-
- Either<Either<ArtifactDefinition, Operation>, ResponseFormat> uploadArtifactToService = createOrUpdateCsarArtifactFromJson(resource, user, json, artifactsBusinessLogic.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.Create),
- shoudLock, inTransaction);
-
- if (uploadArtifactToService.isRight())
- return Either.right(uploadArtifactToService.right().value());
-
- ArtifactDefinition currentInfo = uploadArtifactToService.left().value().left().value();
-
- return Either.left(currentInfo);
-
- }
-
- private Either<ArtifactDefinition, ResponseFormat> updateDeploymentArtifactsFromCsar(String csarUUID, Map<String, byte[]> csar, Resource resource, User user, ArtifactDefinition oldArtifact, ArtifactTemplateInfo artifactTemplateInfo,
- List<ArtifactDefinition> updatedArtifacts, List<ArtifactTemplateInfo> updatedRequiredArtifacts, boolean shouldLock, boolean inTransaction) {
+ private Either<ArtifactDefinition, ResponseFormat> updateDeploymentArtifactsFromCsar(ImportCsarInfo importCsarInfo, Resource resource, ArtifactDefinition oldArtifact, ArtifactTemplateInfo artifactTemplateInfo,
+ List<ArtifactDefinition> updatedArtifacts, List<ArtifactTemplateInfo> updatedRequiredArtifacts, boolean shouldLock, boolean inTransaction) {
Either<ArtifactDefinition, ResponseFormat> resStatus = null;
String artifactFileName = artifactTemplateInfo.getFileName();
@@ -3158,7 +3265,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
- Either<ImmutablePair<String, byte[]>, ResponseFormat> artifactContententStatus = CsarValidationUtils.getArtifactsContent(csarUUID, csar, CsarUtils.ARTIFACTS_PATH + artifactFileName, artifactFileName, componentsUtils);
+ Either<ImmutablePair<String, byte[]>, ResponseFormat> artifactContententStatus = CsarValidationUtils.getArtifactsContent(importCsarInfo.getCsarUUID(), importCsarInfo.getCsar(), CsarUtils.ARTIFACTS_PATH + artifactFileName, artifactFileName, componentsUtils);
if (artifactContententStatus.isRight()) {
resStatus = Either.right(artifactContententStatus.right().value());
return resStatus;
@@ -3167,7 +3274,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, Object> json = buildJsonForUpdateArtifact(oldArtifact.getUniqueId(), artifactFileName, oldArtifact.getArtifactType(), ArtifactGroupTypeEnum.DEPLOYMENT, oldArtifact.getArtifactLabel(), oldArtifact.getArtifactDisplayName(),
oldArtifact.getDescription(), artifactContententStatus.left().value().getRight(), updatedRequiredArtifacts);
- Either<Either<ArtifactDefinition, Operation>, ResponseFormat> uploadArtifactToService = createOrUpdateCsarArtifactFromJson(resource, user, json, artifactsBusinessLogic.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.Update),
+ Either<Either<ArtifactDefinition, Operation>, ResponseFormat> uploadArtifactToService = createOrUpdateCsarArtifactFromJson(resource, importCsarInfo.getModifier(), json, artifactsBusinessLogic.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.Update),
shouldLock, inTransaction);
if (uploadArtifactToService.isRight()) {
@@ -3176,7 +3283,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
ArtifactDefinition currentInfo = uploadArtifactToService.left().value().left().value();
- Either<ArtifactDefinition, ResponseFormat> updateEnvEither = updateHeatParamsFromCsar(resource, csarUUID, csar, artifactTemplateInfo, currentInfo, true);
+ Either<ArtifactDefinition, ResponseFormat> updateEnvEither = updateHeatParamsFromCsar(resource, importCsarInfo, artifactTemplateInfo, currentInfo, true);
if (updateEnvEither.isRight()) {
log.debug("failed to update parameters to artifact {}", artifactFileName);
resStatus = Either.right(updateEnvEither.right().value());
@@ -3192,11 +3299,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
- private Either<ArtifactDefinition, ResponseFormat> updateHeatParamsFromCsar(Resource resource, String csarUUID, Map<String, byte[]> csar, ArtifactTemplateInfo artifactTemplateInfo, ArtifactDefinition currentInfo, boolean isUpdateEnv) {
+ private Either<ArtifactDefinition, ResponseFormat> updateHeatParamsFromCsar(Resource resource, ImportCsarInfo importCsarInfo, ArtifactTemplateInfo artifactTemplateInfo, ArtifactDefinition currentInfo, boolean isUpdateEnv) {
Either<ArtifactDefinition, ResponseFormat> resStatus = Either.left(currentInfo);
if (artifactTemplateInfo.getEnv() != null && !artifactTemplateInfo.getEnv().isEmpty()) {
- Either<ImmutablePair<String, byte[]>, ResponseFormat> artifactparamsStatus = CsarValidationUtils.getArtifactsContent(csarUUID, csar, CsarUtils.ARTIFACTS_PATH + artifactTemplateInfo.getEnv(), artifactTemplateInfo.getEnv(),
+ Either<ImmutablePair<String, byte[]>, ResponseFormat> artifactparamsStatus = CsarValidationUtils.getArtifactsContent(importCsarInfo.getCsarUUID(), importCsarInfo.getCsar(), CsarUtils.ARTIFACTS_PATH + artifactTemplateInfo.getEnv(), artifactTemplateInfo.getEnv(),
componentsUtils);
if (artifactparamsStatus.isRight()) {
resStatus = Either.right(artifactparamsStatus.right().value());
@@ -3308,7 +3415,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private Map<String, Object> buildJsonForUpdateArtifact(String artifactId, String artifactName, String artifactType, ArtifactGroupTypeEnum artifactGroupType, String label, String displayName, String description, byte[] artifactContentent,
- List<ArtifactTemplateInfo> updatedRequiredArtifacts) {
+ List<ArtifactTemplateInfo> updatedRequiredArtifacts) {
Map<String, Object> json = new HashMap<String, Object>();
if (artifactId != null && !artifactId.isEmpty())
@@ -3446,6 +3553,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, Resource> originCompMap = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
+ Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
+
for (Entry<String, UploadComponentInstanceInfo> entry : uploadResInstancesMap.entrySet()) {
UploadComponentInstanceInfo uploadComponentInstanceInfo = entry.getValue();
ComponentInstance currentCompInstance = null;
@@ -3477,20 +3586,54 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
} else {
originResource = originCompMap.get(currentCompInstance.getComponentUid());
}
- if (originResource.getCapabilities() != null && !originResource.getCapabilities().isEmpty())
- instCapabilties.put(currentCompInstance, originResource.getCapabilities());
- if (originResource.getRequirements() != null && !originResource.getRequirements().isEmpty())
- instRequirements.put(currentCompInstance, originResource.getRequirements());
+ if (originResource.getCapabilities() != null && !originResource.getCapabilities().isEmpty()) {
+ Map<String, List<CapabilityDefinition>> originCapabilities ;
+ if (MapUtils.isNotEmpty(uploadComponentInstanceInfo.getCapabilitiesNamesToUpdate()) && resource.getResourceType() == ResourceTypeEnum.CVFC) {
+ originCapabilities = new HashMap<>();
+ originResource.getCapabilities().entrySet().stream().forEach(e ->{
+ List<CapabilityDefinition> list = e.getValue().stream().map(l -> new CapabilityDefinition(l)).collect(Collectors.toList());
+ originCapabilities.put(e.getKey(), list);
+ });
+ for (List<CapabilityDefinition> capabilities : originCapabilities.values()) {
+ capabilities.stream().filter(c -> uploadComponentInstanceInfo.getCapabilitiesNamesToUpdate().containsKey(c.getName())).forEach(c -> c.setName(uploadComponentInstanceInfo.getCapabilitiesNamesToUpdate().get(c.getName())));
+ }
+ }else{
+ originCapabilities = originResource.getCapabilities();
+ }
+ instCapabilties.put(currentCompInstance, originCapabilities);
+ }
+ if (originResource.getRequirements() != null && !originResource.getRequirements().isEmpty()) {
+ Map<String, List<RequirementDefinition>> originRequirements;
+ if (MapUtils.isNotEmpty(uploadComponentInstanceInfo.getRequirementsNamesToUpdate()) && resource.getResourceType() == ResourceTypeEnum.CVFC) {
+ originRequirements = new HashMap<>();
+ originResource.getRequirements().entrySet().stream().forEach(e ->{
+ List<RequirementDefinition> list = e.getValue().stream().map(l -> new RequirementDefinition(l)).collect(Collectors.toList());
+ originRequirements.put(e.getKey(), list);
+ });
+ for (List<RequirementDefinition> requirements : originRequirements.values()) {
+ requirements.stream().filter(r -> uploadComponentInstanceInfo.getRequirementsNamesToUpdate().containsKey(r.getName())).forEach(r -> r.setName(uploadComponentInstanceInfo.getRequirementsNamesToUpdate().get(r.getName())));
+ }
+ }else{
+ originRequirements = originResource.getRequirements();
+ }
+ instRequirements.put(currentCompInstance, originRequirements);
+ }
if (originResource.getDeploymentArtifacts() != null && !originResource.getDeploymentArtifacts().isEmpty())
instArtifacts.put(resourceInstanceId, originResource.getDeploymentArtifacts());
if (originResource.getAttributes() != null && !originResource.getAttributes().isEmpty())
instAttributes.put(resourceInstanceId, originResource.getAttributes());
-
- ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance, yamlName, instProperties, allDataTypes.left().value());
- if (addPropertiesValueToRiRes.getStatus() != 200) {
- return Either.right(addPropertiesValueToRiRes);
+ if (originResource.getResourceType() != ResourceTypeEnum.CVFC) {
+ ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance, yamlName, instProperties, allDataTypes.left().value());
+ if (addPropertiesValueToRiRes.getStatus() != 200) {
+ return Either.right(addPropertiesValueToRiRes);
+ }
+ } else {
+ // TO DO
+ ResponseFormat addInputValueToRiRes = addInputsValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance, yamlName, instInputs, allDataTypes.left().value());
+ if (addInputValueToRiRes.getStatus() != 200) {
+ return Either.right(addInputValueToRiRes);
+ }
}
-
}
Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addPropToInst = toscaOperationFacade.associateComponentInstancePropertiesToComponent(instProperties, resource.getUniqueId());
@@ -3499,7 +3642,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName);
return Either.right(responseFormat);
}
-
+ if (instInputs != null && !instInputs.isEmpty()) {
+ Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> addInputToInst = toscaOperationFacade.associateComponentInstanceInputsToComponent(instInputs, resource.getUniqueId());
+ if (addInputToInst.isRight()) {
+ log.debug("failed to associate inputs value of resource {} status is {}", resource.getUniqueId(), addInputToInst.right().value());
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addInputToInst.right().value()), yamlName);
+ return Either.right(responseFormat);
+ }
+ }
StorageOperationStatus addArtToInst = toscaOperationFacade.associateArtifactToInstances(instArtifacts, resource.getUniqueId(), user);
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate artifact of resource {} status is {}", resource.getUniqueId(), addArtToInst);
@@ -3609,89 +3759,187 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
String resourceInstanceId = currentCompInstance.getUniqueId();
- log.debug("************* addPropertyValuesToRi start");
- long startAddProperty = System.currentTimeMillis();
- log.debug("************* addPropertyValuesToRi end");
- totalCreatePropVal += (System.currentTimeMillis() - startAddProperty);
Map<String, List<UploadReqInfo>> regMap = uploadComponentInstanceInfo.getRequirements();
- if (regMap == null) {
+
+ if (regMap != null) {
+ Iterator<Entry<String, List<UploadReqInfo>>> nodesRegValue = regMap.entrySet().iterator();
+
+ long startAddRelation = System.currentTimeMillis();
+
+ while (nodesRegValue.hasNext()) {
+ Entry<String, List<UploadReqInfo>> nodesRegInfoEntry = nodesRegValue.next();
+
+ List<UploadReqInfo> uploadRegInfoList = nodesRegInfoEntry.getValue();
+ for (UploadReqInfo uploadRegInfo : uploadRegInfoList) {
+ log.debug("Going to create relation {}", uploadRegInfo.getName());
+ String regName = uploadRegInfo.getName();
+ RequirementCapabilityRelDef regCapRelDef = new RequirementCapabilityRelDef();
+ regCapRelDef.setFromNode(resourceInstanceId);
+ log.debug("try to find available requirement {} ", regName);
+ Either<RequirementDefinition, ResponseFormat> eitherReqStatus = findAviableRequiremen(regName, yamlName, uploadComponentInstanceInfo, currentCompInstance, uploadRegInfo.getCapabilityName());
+ if (eitherReqStatus.isRight()) {
+ log.debug("failed to find available requirement {} status is {}", regName, eitherReqStatus.right().value());
+ return eitherReqStatus.right().value();
+ }
+
+ RequirementDefinition validReq = eitherReqStatus.left().value();
+ List<RequirementAndRelationshipPair> reqAndRelationshipPairList = regCapRelDef.getRelationships();
+ if (reqAndRelationshipPairList == null)
+ reqAndRelationshipPairList = new ArrayList<RequirementAndRelationshipPair>();
+ RequirementAndRelationshipPair reqAndRelationshipPair = new RequirementAndRelationshipPair();
+ reqAndRelationshipPair.setRequirement(regName);
+ reqAndRelationshipPair.setRequirementOwnerId(validReq.getOwnerId());
+ reqAndRelationshipPair.setRequirementUid(validReq.getUniqueId());
+ RelationshipImpl relationship = new RelationshipImpl();
+ relationship.setType(validReq.getCapability());
+ reqAndRelationshipPair.setRelationships(relationship);
+
+ ComponentInstance currentCapCompInstance = null;
+ for (ComponentInstance compInstance : componentInstancesList) {
+ if (compInstance.getName().equals(uploadRegInfo.getNode())) {
+ currentCapCompInstance = compInstance;
+ break;
+ }
+ }
+
+ if (currentCapCompInstance == null) {
+ log.debug("The component instance with name {} not found on resource {} ", uploadRegInfo.getNode(), resource.getUniqueId());
+ BeEcompErrorManager.getInstance().logInternalDataError("component instance with name " + uploadRegInfo.getNode() + " in resource {} ", resource.getUniqueId(), ErrorSeverity.ERROR);
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
+ return responseFormat;
+ }
+ regCapRelDef.setToNode(currentCapCompInstance.getUniqueId());
+ log.debug("try to find aviable Capability req name is {} ", validReq.getName());
+ CapabilityDefinition aviableCapForRel = findAvailableCapabilityByTypeOrName(validReq, currentCapCompInstance, uploadRegInfo);
+ if (aviableCapForRel == null) {
+ log.debug("aviable capability was not found. req name is {} component instance is {}", validReq.getName(), currentCapCompInstance.getUniqueId());
+ BeEcompErrorManager.getInstance().logInternalDataError("aviable capability was not found. req name is " + validReq.getName() + " component instance is " + currentCapCompInstance.getUniqueId(), resource.getUniqueId(),
+ ErrorSeverity.ERROR);
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
+ return responseFormat;
+ }
+ reqAndRelationshipPair.setCapability(aviableCapForRel.getName());
+ reqAndRelationshipPair.setCapabilityUid(aviableCapForRel.getUniqueId());
+ reqAndRelationshipPair.setCapabilityOwnerId(aviableCapForRel.getOwnerId());
+ reqAndRelationshipPairList.add(reqAndRelationshipPair);
+ regCapRelDef.setRelationships(reqAndRelationshipPairList);
+ relations.add(regCapRelDef);
+ }
+ }
+ totalCreateRel += (System.currentTimeMillis() - startAddRelation);
+ } else if (resource.getResourceType() != ResourceTypeEnum.CVFC) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.OK, yamlName);
return responseFormat;
}
- Iterator<Entry<String, List<UploadReqInfo>>> nodesRegValue = regMap.entrySet().iterator();
-
- long startAddRelation = System.currentTimeMillis();
-
- while (nodesRegValue.hasNext()) {
- Entry<String, List<UploadReqInfo>> nodesRegInfoEntry = nodesRegValue.next();
-
- List<UploadReqInfo> uploadRegInfoList = nodesRegInfoEntry.getValue();
- for (UploadReqInfo uploadRegInfo : uploadRegInfoList) {
- log.debug("Going to create relation {}", uploadRegInfo.getName());
- String regName = uploadRegInfo.getName();
- String nodeCapName = uploadRegInfo.getNode();
- RequirementCapabilityRelDef regCapRelDef = new RequirementCapabilityRelDef();
- regCapRelDef.setFromNode(resourceInstanceId);
- log.debug("try to find available requirement {} ", regName);
- Either<RequirementDefinition, ResponseFormat> eitherReqStatus = findAviableRequiremen(regName, yamlName, uploadComponentInstanceInfo, currentCompInstance, uploadRegInfo.getCapabilityName());
- if (eitherReqStatus.isRight()) {
- log.debug("failed to find available requirement {} status is {}", regName, eitherReqStatus.right().value());
- return eitherReqStatus.right().value();
- }
-
- RequirementDefinition validReq = eitherReqStatus.left().value();
- List<RequirementAndRelationshipPair> reqAndRelationshipPairList = regCapRelDef.getRelationships();
- if (reqAndRelationshipPairList == null)
- reqAndRelationshipPairList = new ArrayList<RequirementAndRelationshipPair>();
- RequirementAndRelationshipPair reqAndRelationshipPair = new RequirementAndRelationshipPair();
- reqAndRelationshipPair.setRequirement(regName);
- reqAndRelationshipPair.setRequirementOwnerId(validReq.getOwnerId());
- reqAndRelationshipPair.setRequirementUid(validReq.getUniqueId());
- RelationshipImpl relationship = new RelationshipImpl();
- relationship.setType(validReq.getCapability());
- reqAndRelationshipPair.setRelationships(relationship);
-
- ComponentInstance currentCapCompInstance = null;
- for (ComponentInstance compInstance : componentInstancesList) {
- if (compInstance.getName().equals(uploadRegInfo.getNode())) {
- currentCapCompInstance = compInstance;
- break;
- }
+ return componentsUtils.getResponseFormat(ActionStatus.OK);
+ }
+
+ private ResponseFormat addInputsValuesToRi(UploadComponentInstanceInfo uploadComponentInstanceInfo, Resource resource, Resource originResource, ComponentInstance currentCompInstance, String yamlName,
+ Map<String, List<ComponentInstanceInput>> instInputs, Map<String, DataTypeDefinition> allDataTypes) {
+ Map<String, List<UploadPropInfo>> propMap = uploadComponentInstanceInfo.getProperties();
+ if (propMap != null && propMap.size() > 0) {
+ Map<String, InputDefinition> currPropertiesMap = new HashMap<String, InputDefinition>();
+
+ int index = 0;
+ List<InputDefinition> listFromMap = originResource.getInputs();
+ if (listFromMap == null || listFromMap.isEmpty()) {
+ log.debug("failed to find properties ");
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND);
+ return responseFormat;
+ }
+ for (InputDefinition prop : listFromMap) {
+ String propName = prop.getName();
+ if (!currPropertiesMap.containsKey(propName)) {
+ currPropertiesMap.put(propName, prop);
}
+ }
+ List<ComponentInstanceInput> instPropList = new ArrayList<>();
+ for (List<UploadPropInfo> propertyList : propMap.values()) {
- if (currentCapCompInstance == null) {
- log.debug("component instance with name {} in resource {} ", uploadRegInfo.getNode(), resource.getUniqueId());
- BeEcompErrorManager.getInstance().logInternalDataError("component instance with name " + uploadRegInfo.getNode() + " in resource {} ", resource.getUniqueId(), ErrorSeverity.ERROR);
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
+ UploadPropInfo propertyInfo = propertyList.get(0);
+ String propName = propertyInfo.getName();
+ if (!currPropertiesMap.containsKey(propName)) {
+ log.debug("failed to find property {} ", propName);
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND, propName);
return responseFormat;
}
- regCapRelDef.setToNode(currentCapCompInstance.getUniqueId());
- log.debug("try to find aviable Capability req name is {} ", validReq.getName());
- CapabilityDefinition aviableCapForRel = findAvailableCapabilityByTypeOrName(validReq, currentCapCompInstance, uploadRegInfo);
- if (aviableCapForRel == null) {
- log.debug("aviable capability was not found. req name is {} component instance is {}", validReq.getName(), currentCapCompInstance.getUniqueId());
- BeEcompErrorManager.getInstance().logInternalDataError("aviable capability was not found. req name is " + validReq.getName() + " component instance is " + currentCapCompInstance.getUniqueId(), resource.getUniqueId(),
- ErrorSeverity.ERROR);
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
- return responseFormat;
+ InputDefinition curPropertyDef = currPropertiesMap.get(propName);
+ ComponentInstanceInput property = null;
+
+ String value = null;
+ List<GetInputValueDataDefinition> getInputs = null;
+ boolean isValidate = true;
+ if (propertyInfo.getValue() != null) {
+ getInputs = propertyInfo.getGet_input();
+ isValidate = getInputs == null || getInputs.isEmpty();
+ if (isValidate) {
+ value = ImportUtils.getPropertyJsonStringValue(propertyInfo.getValue(), curPropertyDef.getType());
+ } else
+ value = ImportUtils.getPropertyJsonStringValue(propertyInfo.getValue(), ToscaTagNamesEnum.GET_INPUT.getElementName());
}
- reqAndRelationshipPair.setCapability(aviableCapForRel.getName());
- reqAndRelationshipPair.setCapabilityUid(aviableCapForRel.getUniqueId());
- reqAndRelationshipPair.setCapabilityOwnerId(aviableCapForRel.getOwnerId());
- reqAndRelationshipPairList.add(reqAndRelationshipPair);
- regCapRelDef.setRelationships(reqAndRelationshipPairList);
- relations.add(regCapRelDef);
+ String innerType = null;
+ property = new ComponentInstanceInput(curPropertyDef, value, null);
- }
+ Either<String, StorageOperationStatus> validatevalueEiter = validatePropValueBeforeCreate(property, value, isValidate, innerType, allDataTypes);
+ if (validatevalueEiter.isRight()) {
+ return componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(validatevalueEiter.right().value()));
+ }
- }
- totalCreateRel += (System.currentTimeMillis() - startAddRelation);
+ // String uniqueId = UniqueIdBuilder.buildResourceInstancePropertyValueUid(currentCompInstance.getComponentUid(), index++);
+ // property.setUniqueId(uniqueId);
+ property.setValue(validatevalueEiter.left().value());
+
+ if (getInputs != null && !getInputs.isEmpty()) {
+ List<GetInputValueDataDefinition> getInputValues = new ArrayList<>();
+ for (GetInputValueDataDefinition getInput : getInputs) {
+ List<InputDefinition> inputs = resource.getInputs();
+ if (inputs == null || inputs.isEmpty()) {
+ log.debug("Failed to add property {} to resource instance {}. Inputs list is empty ", property, currentCompInstance.getUniqueId());
+ return componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT);
+ }
+ Optional<InputDefinition> optional = inputs.stream().filter(p -> p.getName().equals(getInput.getInputName())).findAny();
+ if (!optional.isPresent()) {
+ log.debug("Failed to find input {} ", getInput.getInputName());
+ // @@TODO error message
+ return componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT);
+ }
+ InputDefinition input = optional.get();
+ getInput.setInputId(input.getUniqueId());
+ getInputValues.add(getInput);
+
+ GetInputValueDataDefinition getInputIndex = getInput.getGetInputIndex();
+ if (getInputIndex != null) {
+ optional = inputs.stream().filter(p -> p.getName().equals(getInputIndex.getInputName())).findAny();
+ if (!optional.isPresent()) {
+ log.debug("Failed to find input {} ", getInputIndex.getInputName());
+ // @@TODO error message
+ return componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT);
+ }
+ InputDefinition inputIndex = optional.get();
+ getInputIndex.setInputId(inputIndex.getUniqueId());
+ getInputValues.add(getInputIndex);
+ }
+ }
+ property.setGetInputValues(getInputValues);
+ }
+ instPropList.add(property);
+ // delete overriden property
+ currPropertiesMap.remove(property.getName());
+ }
+ // add rest of properties
+ if (!currPropertiesMap.isEmpty()) {
+ for (InputDefinition value : currPropertiesMap.values()) {
+ instPropList.add(new ComponentInstanceInput(value));
+ }
+ }
+ instInputs.put(currentCompInstance.getUniqueId(), instPropList);
+ }
return componentsUtils.getResponseFormat(ActionStatus.OK);
}
private ResponseFormat addPropertyValuesToRi(UploadComponentInstanceInfo uploadComponentInstanceInfo, Resource resource, Resource originResource, ComponentInstance currentCompInstance, String yamlName,
- Map<String, List<ComponentInstanceProperty>> instProperties, Map<String, DataTypeDefinition> allDataTypes) {
+ Map<String, List<ComponentInstanceProperty>> instProperties, Map<String, DataTypeDefinition> allDataTypes) {
Map<String, List<UploadPropInfo>> propMap = uploadComponentInstanceInfo.getProperties();
if (propMap != null && propMap.size() > 0) {
@@ -3845,14 +4093,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return cap;
}
- private RequirementAndRelationshipPair getReqRelPair(CapabilityDefinition cap) {
- RequirementAndRelationshipPair relationPair = new RequirementAndRelationshipPair();
- relationPair.setCapabilityUid(cap.getUniqueId());
- relationPair.setCapability(cap.getName());
- relationPair.setCapabilityOwnerId(cap.getOwnerId());
- return relationPair;
- }
-
private CapabilityDefinition findAviableCapability(RequirementDefinition validReq, ComponentInstance currentCapCompInstance) {
CapabilityDefinition aviableCapForRel = null;
Map<String, List<CapabilityDefinition>> capMap = currentCapCompInstance.getCapabilities();
@@ -3955,9 +4195,15 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
@SuppressWarnings("unchecked")
- public Either<ParsedToscaYamlInfo, ResponseFormat> parseResourceInfoFromYaml(String yamlFileName, Resource resource, String resourceYml, User user) {
+ public Either<ParsedToscaYamlInfo, ResponseFormat> parseResourceInfoFromYaml(String yamlFileName, Resource resource, String resourceYml, User user, Map<String, String> createdNodesToscaResourceNames, Map<String, NodeTypeInfo> nodeTypesInfo, String nodeTypeName) {
- Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(resourceYml);
+ Map<String, Object> mappedToscaTemplate;
+ if(nodeTypesInfo != null && nodeTypeName != null && nodeTypesInfo.containsKey(nodeTypeName)){
+ mappedToscaTemplate = nodeTypesInfo.get(nodeTypeName).getMappedToscaTemplate();
+ }
+ else {
+ mappedToscaTemplate = (Map<String, Object>) new Yaml().load(resourceYml);
+ }
Either<Object, ResultStatusEnum> toscaElementEither = ImportUtils.findToscaElement(mappedToscaTemplate, ToscaTagNamesEnum.TOPOLOGY_TEMPLATE, ToscaElementTypeEnum.ALL);
if (toscaElementEither.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE);
@@ -3970,7 +4216,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.right(responseFormat);
}
- Either<Map<String, UploadComponentInstanceInfo>, ResponseFormat> uploadResInstancesEither = createResourcesInstanceInfoFromYaml(yamlFileName, mappedToscaTemplate, resource);
+ Either<Map<String, UploadComponentInstanceInfo>, ResponseFormat> uploadResInstancesEither = createResourcesInstanceInfoFromYaml(yamlFileName, mappedToscaTemplate, resource, createdNodesToscaResourceNames);
if (uploadResInstancesEither.isRight()) {
ResponseFormat responseFormat = uploadResInstancesEither.right().value();
return Either.right(responseFormat);
@@ -3991,7 +4237,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private Either<Resource, ResponseFormat> createResourceInstances(User user, String yamlName, Resource resource, Map<String, UploadComponentInstanceInfo> uploadResInstancesMap, boolean inTransaction, boolean needLock,
- Map<String, Resource> nodeTypeNamespaceMap) {
+ Map<String, Resource> nodeTypeNamespaceMap) {
Either<Resource, ResponseFormat> eitherResource = null;
log.debug("createResourceInstances is {} - going to create resource instanse from CSAR", yamlName);
@@ -4114,32 +4360,36 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.ILLEGAL_COMPONENT_STATE, refResource.getComponentType().getValue(), refResource.getName(), componentState);
return Either.right(responseFormat);
}
- ResourceTypeEnum resourceTypeEnum = refResource.getResourceType();
- if (resourceTypeEnum == ResourceTypeEnum.VF) {
- log.debug("validateResourceInstanceBeforeCreate - ref resource type is ", resourceTypeEnum);
+
+ if (!ToscaUtils.isAtomicType(refResource) && refResource.getResourceType() != ResourceTypeEnum.CVFC) {
+ log.debug("validateResourceInstanceBeforeCreate - ref resource type is ", refResource.getResourceType());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_NODE_TEMPLATE, yamlName, uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
return Either.right(responseFormat);
}
return Either.left(refResource);
}
- private Either<Map<String, UploadComponentInstanceInfo>, ResponseFormat> createResourcesInstanceInfoFromYaml(String yamlFileName, Map<String, Object> toscaJson, Resource resource) {
+ private Either<Map<String, UploadComponentInstanceInfo>, ResponseFormat> createResourcesInstanceInfoFromYaml(String yamlFileName, Map<String, Object> toscaJson, Resource resource, Map<String, String> createdNodesToscaResourceNames) {
Map<String, UploadComponentInstanceInfo> moduleComponentInstances = new HashMap<String, UploadComponentInstanceInfo>();
+ Map<String, Object> substitutionMappings = null;
Either<Map<String, UploadComponentInstanceInfo>, ResponseFormat> result = Either.left(moduleComponentInstances);
Either<Map<String, Object>, ResultStatusEnum> eitherNodesTemlates = ImportUtils.findFirstToscaMapElement(toscaJson, ToscaTagNamesEnum.NODE_TEMPLATES);
+ Either<Map<String, Object>, ResultStatusEnum> eitherSubstitutionMappings = ImportUtils.findFirstToscaMapElement(toscaJson, ToscaTagNamesEnum.SUBSTITUTION_MAPPINGS);
+ if (eitherSubstitutionMappings.isLeft()) {
+ substitutionMappings = eitherSubstitutionMappings.left().value();
+ }
if (eitherNodesTemlates.isLeft()) {
Map<String, Object> jsonNodeTemplates = eitherNodesTemlates.left().value();
Iterator<Entry<String, Object>> nodesNameValue = jsonNodeTemplates.entrySet().iterator();
while (nodesNameValue.hasNext()) {
Entry<String, Object> nodeNameValue = nodesNameValue.next();
- Either<UploadComponentInstanceInfo, ResponseFormat> eitherNode = createModuleComponentInstanceInfo(nodeNameValue.getValue());
+ Either<UploadComponentInstanceInfo, ResponseFormat> eitherNode = createModuleComponentInstanceInfo(nodeNameValue, substitutionMappings, createdNodesToscaResourceNames);
if (eitherNode.isRight()) {
log.info("error when creating node template:{}, for resource:{}", nodeNameValue.getKey(), resource.getName());
return Either.right(eitherNode.right().value());
} else {
UploadComponentInstanceInfo uploadComponentInstanceInfo = eitherNode.left().value();
- uploadComponentInstanceInfo.setName(nodeNameValue.getKey());
moduleComponentInstances.put(nodeNameValue.getKey(), uploadComponentInstanceInfo);
}
@@ -4154,20 +4404,25 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return result;
}
- private Either<UploadComponentInstanceInfo, ResponseFormat> createModuleComponentInstanceInfo(Object nodeTemplateJson) {
+ @SuppressWarnings("unchecked")
+ private Either<UploadComponentInstanceInfo, ResponseFormat> createModuleComponentInstanceInfo(Entry<String, Object> nodeTemplateJsonEntry, Map<String, Object> substitutionMappings, Map<String, String> createdNodesToscaResourceNames) {
UploadComponentInstanceInfo nodeTemplateInfo = new UploadComponentInstanceInfo();
Either<UploadComponentInstanceInfo, ResponseFormat> result = Either.left(nodeTemplateInfo);
-
+ nodeTemplateInfo.setName(nodeTemplateJsonEntry.getKey());
try {
- if (nodeTemplateJson instanceof String) {
- String nodeTemplateJsonString = (String) nodeTemplateJson;
+ if (nodeTemplateJsonEntry.getValue() instanceof String) {
+ String nodeTemplateJsonString = (String) nodeTemplateJsonEntry.getValue();
nodeTemplateInfo.setType(nodeTemplateJsonString);
- } else if (nodeTemplateJson instanceof Map) {
- Map<String, Object> nodeTemplateJsonMap = (Map<String, Object>) nodeTemplateJson;
+ } else if (nodeTemplateJsonEntry.getValue() instanceof Map) {
+ Map<String, Object> nodeTemplateJsonMap = (Map<String, Object>) nodeTemplateJsonEntry.getValue();
// Type
if (nodeTemplateJsonMap.containsKey(ToscaTagNamesEnum.TYPE.getElementName())) {
- nodeTemplateInfo.setType((String) nodeTemplateJsonMap.get(ToscaTagNamesEnum.TYPE.getElementName()));
+ String toscaResourceType = (String) nodeTemplateJsonMap.get(ToscaTagNamesEnum.TYPE.getElementName());
+ if (createdNodesToscaResourceNames.containsKey(toscaResourceType)) {
+ toscaResourceType = createdNodesToscaResourceNames.get(toscaResourceType);
+ }
+ nodeTemplateInfo.setType(toscaResourceType);
}
if (nodeTemplateJsonMap.containsKey(ToscaTagNamesEnum.REQUIREMENTS.getElementName())) {
@@ -4195,13 +4450,30 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
nodeTemplateInfo.setProperties(regResponse.left().value());
}
}
+ if (substitutionMappings != null) {
+ if (substitutionMappings.containsKey(ToscaTagNamesEnum.CAPABILITIES.getElementName())) {
+ Either<Map<String, String>, ResponseFormat> getCapNamesToUpdateRes = getNamesToUpdate(nodeTemplateInfo, (Map<String, List<String>>) substitutionMappings.get(ToscaTagNamesEnum.CAPABILITIES.getElementName()));
+ if (getCapNamesToUpdateRes.isRight())
+ return Either.right(getCapNamesToUpdateRes.right().value());
+ if (getCapNamesToUpdateRes.left().value().size() > 0) {
+ nodeTemplateInfo.setCapabilitiesNamesToUpdate(getCapNamesToUpdateRes.left().value());
+ }
+ }
+ if (substitutionMappings.containsKey(ToscaTagNamesEnum.REQUIREMENTS.getElementName())) {
+ Either<Map<String, String>, ResponseFormat> getReqNamesToUpdateRes = getNamesToUpdate(nodeTemplateInfo, (Map<String, List<String>>) substitutionMappings.get(ToscaTagNamesEnum.REQUIREMENTS.getElementName()));
+ if (getReqNamesToUpdateRes.isRight())
+ return Either.right(getReqNamesToUpdateRes.right().value());
+ if (getReqNamesToUpdateRes.left().value().size() > 0) {
+ nodeTemplateInfo.setRequirementsNamesToUpdate(getReqNamesToUpdateRes.left().value());
+ }
+ }
+ }
} else {
result = Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE));
}
} catch (Exception e) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeSystemError, "Import Resource - create capability");
BeEcompErrorManager.getInstance().logBeSystemError("Import Resource - create capability");
log.debug("error when creating capability, message:{}", e.getMessage(), e);
result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_YAML));
@@ -4210,6 +4482,18 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return result;
}
+ private Either<Map<String, String>, ResponseFormat> getNamesToUpdate(UploadComponentInstanceInfo nodeTemplateInfo, Map<String, List<String>> elements) {
+ Either<Map<String, String>, ResponseFormat> response;
+ try {
+ Map<String, String> namesToUpdate = elements.entrySet().stream().filter(e -> e.getValue().get(0).equalsIgnoreCase(nodeTemplateInfo.getName())).collect(Collectors.toMap(e -> e.getValue().get(1), e -> e.getKey()));
+ response = Either.left(namesToUpdate);
+ } catch (Exception e) {
+ log.debug("The exception {} occured upon adding names to update for instance {} . ", e.getMessage(), nodeTemplateInfo.getName());
+ response = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
+ }
+ return response;
+ }
+
private Either<Map<String, List<UploadPropInfo>>, ResponseFormat> createPropModuleFromYaml(Map<String, Object> nodeTemplateJsonMap) {
Map<String, List<UploadPropInfo>> moduleProp = new HashMap<String, List<UploadPropInfo>>();
Either<Map<String, List<UploadPropInfo>>, ResponseFormat> response = Either.left(moduleProp);
@@ -4222,21 +4506,21 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Object propValue = jsonPropObj.getValue();
if (valueContainsPattern(STR_REPLACE_PATTERN, propValue)) {
- log.debug("Ignore property value {}.", propName);
+ log.trace("Ignore property value {}.", propName);
continue;
}
if (valueContainsPattern(TOKEN_PATTERN, propValue)) {
- log.debug("Ignore property value {}.", propName);
+ log.trace("Ignore property value {}.", propName);
continue;
}
if (valueContainsPattern(GET_PROPERTY_PATTERN, propValue)) {
- log.debug("Ignore property value {}.", propName);
+ log.trace("Ignore property value {}.", propName);
continue;
}
if (valueContainsPattern(CONCAT_PATTERN, propValue)) {
- log.debug("Ignore property value {}.", propName);
+ log.trace("Ignore property value {}.", propName);
continue;
}
@@ -4399,7 +4683,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.debug("valueContainsToken value is {}", propValue);
boolean result = false;
if (propValue != null) {
- log.debug("valueContainspattern value is {}", propValue.getClass());
+ log.trace("valueContainspattern value is {}", propValue.getClass());
Matcher matcher = pattern.matcher(propValue.toString());
result = matcher.find();
}
@@ -4536,29 +4820,28 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return result;
}
- public Either<Resource, ResponseFormat> propagateStateToCertified(User user, Resource resource, LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean inTransaction, boolean needLock) {
+ public Either<Resource, ResponseFormat> propagateStateToCertified(User user, Resource resource, LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean inTransaction, boolean needLock, boolean forceCertificationAllowed) {
+
Either<Resource, ResponseFormat> result = null;
-
- // resource updated with checkout. certify the resource
- if (resource.getLifecycleState().equals(LifecycleStateEnum.CERTIFIED)) {
- Either<Either<ArtifactDefinition, Operation>, ResponseFormat> eitherPopulated = populateToscaArtifacts(resource, user, false, inTransaction, needLock);
- result = eitherPopulated.isLeft() ? Either.left(resource) : Either.right(eitherPopulated.right().value());
- return result;
- }
try {
- result = lifecycleBusinessLogic.changeState(resource.getUniqueId(), user, LifeCycleTransitionEnum.CERTIFICATION_REQUEST, lifecycleChangeInfo, inTransaction, needLock);
- if (result.isLeft()) {
+ if(resource.getLifecycleState() != LifecycleStateEnum.CERTIFIED && forceCertificationAllowed){
+ result = nodeForceCertification(resource, user, lifecycleChangeInfo, inTransaction, needLock);
+ if(result.isRight()){
+ return result;
+ }
resource = result.left().value();
- result = lifecycleBusinessLogic.changeState(resource.getUniqueId(), user, LifeCycleTransitionEnum.START_CERTIFICATION, lifecycleChangeInfo, inTransaction, needLock);
}
- if (result.isLeft()) {
- resource = result.left().value();
- result = lifecycleBusinessLogic.changeState(resource.getUniqueId(), user, LifeCycleTransitionEnum.CERTIFY, lifecycleChangeInfo, inTransaction, needLock);
+ if (resource.getLifecycleState() == LifecycleStateEnum.CERTIFIED) {
+ Either<Either<ArtifactDefinition, Operation>, ResponseFormat> eitherPopulated = populateToscaArtifacts(resource, user, false, inTransaction, needLock);
+ result = eitherPopulated.isLeft() ? Either.left(resource) : Either.right(eitherPopulated.right().value());
+ return result;
}
- return result;
+ return nodeFullCertification(resource.getUniqueId(), user, lifecycleChangeInfo, inTransaction, needLock);
+ } catch (Exception e) {
+ log.debug("The exception {} has occured upon certification of resource {}. ", e.getMessage(), resource.getName());
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
} finally {
if (result == null || result.isRight()) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeSystemError, "Change LifecycleState - Certify");
BeEcompErrorManager.getInstance().logBeSystemError("Change LifecycleState - Certify");
if (inTransaction == false) {
log.debug("operation failed. do rollback");
@@ -4571,6 +4854,21 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
}
+ private Either<Resource, ResponseFormat> nodeFullCertification(String uniqueId, User user, LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean inTransaction, boolean needLock) {
+ Either<Resource, ResponseFormat> result = lifecycleBusinessLogic.changeState(uniqueId, user, LifeCycleTransitionEnum.CERTIFICATION_REQUEST, lifecycleChangeInfo, inTransaction, needLock);
+ if (result.isLeft()) {
+ result = lifecycleBusinessLogic.changeState(uniqueId, user, LifeCycleTransitionEnum.START_CERTIFICATION, lifecycleChangeInfo, inTransaction, needLock);
+ }
+ if (result.isLeft()) {
+ result = lifecycleBusinessLogic.changeState(uniqueId, user, LifeCycleTransitionEnum.CERTIFY, lifecycleChangeInfo, inTransaction, needLock);
+ }
+ return result;
+ }
+
+ private Either<Resource, ResponseFormat> nodeForceCertification(Resource resource, User user, LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean inTransaction, boolean needLock) {
+ return lifecycleBusinessLogic.forceResourceCertification(resource, user, lifecycleChangeInfo, inTransaction, needLock);
+ }
+
/*
* /**
*
@@ -4596,7 +4894,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
else {
StorageOperationStatus status = latestByName.right().value();
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeResourceMissingError, "Create / Update resource by import", resource.getName());
BeEcompErrorManager.getInstance().logBeComponentMissingError("Create / Update resource by import", ComponentTypeEnum.RESOURCE.getValue(), resource.getName());
log.debug("resource already exist {}. status={}", resource.getName(), status);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.RESOURCE_ALREADY_EXISTS);
@@ -4614,7 +4911,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// error
else {
StorageOperationStatus status = latestByName.right().value();
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeResourceMissingError, "Create / Update resource by import", resource.getName());
log.debug("failed to get latest version of resource {}. status={}", resource.getName(), status);
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(latestByName.right().value()), resource);
componentsUtils.auditResource(responseFormat, user, resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
@@ -4726,7 +5022,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return result;
} finally {
if (result == null || result.isRight()) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeSystemError, "Change LifecycleState - Certify");
BeEcompErrorManager.getInstance().logBeSystemError("Change LifecycleState - Certify");
log.debug("operation failed. do rollback");
titanDao.rollback();
@@ -4764,6 +5059,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
newResource.setVendorRelease(oldResource.getVendorRelease());
}
+ if (newResource.getResourceVendorModelNumber() == null) {
+ newResource.setResourceVendorModelNumber(oldResource.getResourceVendorModelNumber());
+ }
+
if (newResource.getContactId() == null) {
newResource.setContactId(oldResource.getContactId());
}
@@ -4808,12 +5107,13 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resource.setCreatorUserId(user.getUserId());
resource.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
resource.setContactId(resource.getContactId().toLowerCase());
- if (resource.getResourceType().equals(ResourceTypeEnum.VF)) {
- resource.setToscaResourceName(CommonBeUtils.generateToscaResourceName(ResourceTypeEnum.VF.name(), resource.getSystemName()));
+ if (!ToscaUtils.isAtomicType(resource) && resource.getResourceType() != ResourceTypeEnum.CVFC) {
+ resource.setToscaResourceName(CommonBeUtils.generateToscaResourceName(resource.getResourceType().name(), resource.getSystemName()));
}
// Generate invariant UUID - must be here and not in operation since it
// should stay constant during clone
+ // TODO
String invariantUUID = UniqueIdBuilder.buildInvariantUUID();
resource.setInvariantUUID(invariantUUID);
@@ -4842,10 +5142,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Either<InterfaceDefinition, StorageOperationStatus> eitherCapTypeFound = interfaceTypeOperation.getInterface(intType);
if (eitherCapTypeFound.isRight()) {
if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeInterfaceMissingError, "Create Resource - validateLifecycleTypesCreate", intType);
BeEcompErrorManager.getInstance().logBeGraphObjectMissingError("Create Resource - validateLifecycleTypesCreate", "Interface", intType);
log.debug("Lifecycle Type: {} is required by resource: {} but does not exist in the DB", intType, resource.getName());
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError, "Create Resource - validateLifecycleTypesCreate");
BeEcompErrorManager.getInstance().logBeDaoSystemError("Create Resource - validateLifecycleTypesCreate");
log.debug("request to data model failed with error: {}", eitherCapTypeFound.right().value().name());
}
@@ -4878,7 +5176,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (resource.getRequirements() != null && resource.getRequirements().size() > 0) {
log.debug("validate capability Types Exist - requirements section");
for (String type : resource.getRequirements().keySet()) {
- eitherResult = validateCapabilityTypeExists(user, capabilityTypeOperation, resource, resource.getRequirements().get(type) , actionEnum, eitherResult, type, inTransaction);
+ eitherResult = validateCapabilityTypeExists(user, capabilityTypeOperation, resource, resource.getRequirements().get(type), actionEnum, eitherResult, type, inTransaction);
if (eitherResult.isRight()) {
return Either.right(eitherResult.right().value());
}
@@ -4888,24 +5186,22 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return eitherResult;
}
- //@param typeObject- the object to which the validation is done
- private Either<Boolean, ResponseFormat> validateCapabilityTypeExists(User user, ICapabilityTypeOperation capabilityTypeOperation, Resource resource, List validationObjects , AuditingActionEnum actionEnum, Either<Boolean, ResponseFormat> eitherResult, String type,
- boolean inTransaction) {
+ // @param typeObject- the object to which the validation is done
+ private Either<Boolean, ResponseFormat> validateCapabilityTypeExists(User user, ICapabilityTypeOperation capabilityTypeOperation, Resource resource, List validationObjects, AuditingActionEnum actionEnum, Either<Boolean, ResponseFormat> eitherResult, String type,
+ boolean inTransaction) {
Either<CapabilityTypeDefinition, StorageOperationStatus> eitherCapTypeFound = capabilityTypeOperation.getCapabilityType(type, inTransaction);
if (eitherCapTypeFound.isRight()) {
if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeCapabilityTypeMissingError, "Create Resource - validateCapabilityTypesCreate", type);
BeEcompErrorManager.getInstance().logBeGraphObjectMissingError("Create Resource - validateCapabilityTypesCreate", "Capability Type", type);
log.debug("Capability Type: {} is required by resource: {} but does not exist in the DB", type, resource.getName());
BeEcompErrorManager.getInstance().logBeDaoSystemError("Create Resource - validateCapabilityTypesCreate");
}
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError, "Create Resource - validateCapabilityTypesCreate");
log.debug("Trying to get capability type {} failed with error: {}", type, eitherCapTypeFound.right().value().name());
- ResponseFormat errorResponse =null;
- if (type!=null)
+ ResponseFormat errorResponse = null;
+ if (type != null)
errorResponse = componentsUtils.getResponseFormat(ActionStatus.MISSING_CAPABILITY_TYPE, type);
else
- errorResponse = componentsUtils.getResponseFormatByElement(ActionStatus.MISSING_CAPABILITY_TYPE, validationObjects );
+ errorResponse = componentsUtils.getResponseFormatByElement(ActionStatus.MISSING_CAPABILITY_TYPE, validationObjects);
eitherResult = Either.right(errorResponse);
componentsUtils.auditResource(errorResponse, user, resource, "", "", actionEnum, null);
}
@@ -4913,16 +5209,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private Either<Boolean, ResponseFormat> validateCapabilityTypeExists(User user, ICapabilityTypeOperation capabilityTypeOperation, Resource resource, AuditingActionEnum actionEnum, Either<Boolean, ResponseFormat> eitherResult,
- Entry<String, List<CapabilityDefinition>> typeEntry, boolean inTransaction) {
+ Entry<String, List<CapabilityDefinition>> typeEntry, boolean inTransaction) {
Either<CapabilityTypeDefinition, StorageOperationStatus> eitherCapTypeFound = capabilityTypeOperation.getCapabilityType(typeEntry.getKey(), inTransaction);
if (eitherCapTypeFound.isRight()) {
if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeCapabilityTypeMissingError, "Create Resource - validateCapabilityTypesCreate", typeEntry.getKey());
BeEcompErrorManager.getInstance().logBeGraphObjectMissingError("Create Resource - validateCapabilityTypesCreate", "Capability Type", typeEntry.getKey());
log.debug("Capability Type: {} is required by resource: {} but does not exist in the DB", typeEntry.getKey(), resource.getName());
BeEcompErrorManager.getInstance().logBeDaoSystemError("Create Resource - validateCapabilityTypesCreate");
}
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDaoSystemError, "Create Resource - validateCapabilityTypesCreate");
log.debug("Trying to get capability type {} failed with error: {}", typeEntry.getKey(), eitherCapTypeFound.right().value().name());
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.MISSING_CAPABILITY_TYPE, typeEntry.getKey());
eitherResult = Either.right(errorResponse);
@@ -4985,8 +5279,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Either<Resource, ResponseFormat> respStatus = createResourceTransaction(resource, user, isNormative, inTransaction);
if (respStatus.isLeft()) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.CREATED);
- componentsUtils.auditResource(responseFormat, user, resource, "", "", actionEnum, additionalParams);
+ auditCreateResource(user, respStatus.left().value(), actionEnum, additionalParams);
ASDCKpiApi.countCreatedResourcesKPI();
} else
componentsUtils.auditResource(respStatus.right().value(), user, resource, "", "", actionEnum, additionalParams);
@@ -4999,6 +5292,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
}
+ private void auditCreateResource(User user, Resource persistedResource, AuditingActionEnum actionEnum, EnumMap<AuditingFieldsKeysEnum, Object> additionalParams) {
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.CREATED);
+ componentsUtils.auditResource(responseFormat, user, persistedResource, "", "", actionEnum, additionalParams);
+ }
+
private Either<Resource, ResponseFormat> createResourceTransaction(Resource resource, User user, boolean isNormative, boolean inTransaction) {
// validate resource name uniqueness
log.debug("validate resource name");
@@ -5026,7 +5324,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
resource.setVersion(INITIAL_VERSION);
resource.setHighestVersion(true);
- resource.setAbstract(false);
+ if (resource.getResourceType() != null && resource.getResourceType() != ResourceTypeEnum.CVFC)
+ resource.setAbstract(false);
}
Either<Resource, StorageOperationStatus> createToscaElement = toscaOperationFacade.createToscaComponent(resource);
@@ -5090,6 +5389,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resource.setDeploymentArtifacts(artifactMap);
}
+ @SuppressWarnings("unchecked")
private void setInformationalArtifactsPlaceHolder(Resource resource, User user) {
Map<String, ArtifactDefinition> artifactMap = resource.getArtifacts();
if (artifactMap == null) {
@@ -5097,6 +5397,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
String resourceUniqueId = resource.getUniqueId();
List<String> exludeResourceCategory = ConfigurationManager.getConfigurationManager().getConfiguration().getExcludeResourceCategory();
+ List<String> exludeResourceType = ConfigurationManager.getConfigurationManager().getConfiguration().getExcludeResourceType();
Map<String, Object> informationalResourceArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration().getInformationalResourceArtifacts();
List<CategoryDefinition> categories = resource.getCategories();
boolean isCreateArtifact = true;
@@ -5110,6 +5411,16 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
}
+ if (isCreateArtifact && exludeResourceType != null) {
+ String resourceType = resource.getResourceType().name();
+ for (String type : exludeResourceType) {
+ if (type.equalsIgnoreCase(resourceType)) {
+ isCreateArtifact = false;
+ break;
+ }
+ }
+
+ }
if (informationalResourceArtifacts != null && isCreateArtifact) {
Set<String> keys = informationalResourceArtifacts.keySet();
@@ -5273,14 +5584,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/**
* updateResourceMetadata
*
- * @param user
- * - modifier data (userId)
- * @param inTransaction
- * TODO
- * @param resourceIdToUpdate
- * - the resource identifier
+ * @param user - modifier data (userId)
+ * @param inTransaction TODO
+ * @param resourceIdToUpdate - the resource identifier
* @param newResource
- *
* @return Either<Resource, responseFormat>
*/
public Either<Resource, ResponseFormat> updateResourceMetadata(String resourceIdToUpdate, Resource newResource, Resource currentResource, User user, boolean inTransaction) {
@@ -5315,7 +5622,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// lock resource
StorageOperationStatus lockResult = graphLockOperation.lockComponent(resourceIdToUpdate, NodeTypeEnum.Resource);
if (!lockResult.equals(StorageOperationStatus.OK)) {
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeFailedLockObjectError, "Upload Artifact - lock " + resourceIdToUpdate + ": " + NodeTypeEnum.Resource);
BeEcompErrorManager.getInstance().logBeFailedLockObjectError("Upload Artifact - lock ", NodeTypeEnum.Resource.getName(), resourceIdToUpdate);
log.debug("Failed to lock resource: {}, error - {}", resourceIdToUpdate, lockResult);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(lockResult));
@@ -5331,7 +5637,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// list
// This code is not called from import resources, because of root
// VF "derivedFrom" should be null (or ignored)
- if (!currentResource.getResourceType().equals(ResourceTypeEnum.VF)) {
+ if (ToscaUtils.isAtomicType(currentResource)) {
Either<Boolean, ResponseFormat> derivedFromNotEmptyEither = validateDerivedFromNotEmpty(null, newResource, null);
if (derivedFromNotEmptyEither.isRight()) {
log.debug("for updated resource {}, derived from field is empty", newResource.getName());
@@ -5373,7 +5679,54 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
}
+ private Either<List<GroupDefinition>,Boolean> updateComponentGroupName(String replacePattern , String with ,List<GroupDefinition> oldGroup){
+ if ( oldGroup==null || with==null || replacePattern==null || with.isEmpty() || replacePattern.isEmpty()){
+ if (log.isInfoEnabled())
+ log.info("cannot update group name , invalid args -> replacePattern:{} , with:{} , oldGroup:{}" , replacePattern, with, oldGroup == null ? null : " < size : "+oldGroup.size()+" >" );
+ return Either.right(false);
+ }
+ List<GroupDefinition> list = oldGroup.stream().map( group -> new GroupDefinition(group)).collect(Collectors.toList());
+ for ( GroupDefinition group : list) {
+ if ( group!=null && group.isSamePrefix( replacePattern ) ){
+ String prefix = group.getName().substring( 0, replacePattern.length() );
+ String newGroupName = group.getName().replaceFirst(prefix , with);
+ group.setName(newGroupName);
+ //String newUid = group.getUniqueId().replaceFirst(prefix , with); //removing this will also change the unique id
+ //group.setUniqueId(newUid);
+ }
+ }
+ return Either.left(list);
+ }
+
+ private boolean isComponentNameChanged(Resource newResource,Resource oldResource){
+ if (newResource!=null && oldResource!=null){ //TODO - must protect all chain against null , use optional
+ String futureName = newResource.getComponentMetadataDefinition().getMetadataDataDefinition().getName();
+ String oldName = oldResource.getComponentMetadataDefinition().getMetadataDataDefinition().getName();
+ return !oldName.equals(futureName);
+ }
+ return false;
+ }
+
private Either<Resource, ResponseFormat> updateResourceMetadata(String resourceIdToUpdate, Resource newResource, User user, Resource currentResource, boolean shouldLock, boolean inTransaction) {
+ //region -> Update groups name for newResource
+ if ( isComponentNameChanged( currentResource , newResource) ){
+ String replacePattern = Optional.ofNullable( //get currentResource name from metadata
+ Optional.ofNullable( Optional.ofNullable( currentResource )
+ .orElse(null).getComponentMetadataDefinition() )
+ .orElse(null).getMetadataDataDefinition() )
+ .orElse(null).getName();
+ String with = Optional.ofNullable( //get newResource name from metadata
+ Optional.ofNullable( Optional.ofNullable( newResource )
+ .orElse(null).getComponentMetadataDefinition() )
+ .orElse(null).getMetadataDataDefinition() )
+ .orElse(null).getName();
+ if ( with != null && replacePattern != null ){
+ Either result = updateComponentGroupName( replacePattern , with ,currentResource.getGroups());
+ if (result.isLeft())
+ newResource.setGroups( (List<GroupDefinition>)result.left().value() );
+ }
+ }
+ //endregion
Either<Boolean, ResponseFormat> validateResourceFields = validateResourceFieldsBeforeUpdate(currentResource, newResource, inTransaction);
if (validateResourceFields.isRight()) {
@@ -5395,6 +5748,18 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
log.debug("send resource {} to dao for update", newResource.getUniqueId());
+ if (newResource!=null && newResource.getGroups()!=null){
+ for ( GroupDefinition group : newResource.getGroups() ){
+ if (newResource.getComponentMetadataDefinition()!=null && newResource.getComponentMetadataDefinition().getMetadataDataDefinition()!=null)
+ groupBusinessLogic.validateAndUpdateGroupMetadata(
+ newResource.getComponentMetadataDefinition().getMetadataDataDefinition().getUniqueId() ,
+ user,
+ ComponentTypeEnum.RESOURCE_INSTANCE,
+ group,
+ true ,
+ false) ;
+ }
+ }
Either<Resource, StorageOperationStatus> dataModelResponse = toscaOperationFacade.updateToscaElement(newResource);
if (dataModelResponse.isRight()) {
@@ -5410,12 +5775,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/**
* validateResourceFieldsBeforeCreate
*
- * @param user
- * - modifier data (userId)
- * @param dataModel
- * - IResourceOperation for resource crud
- * @param resource
- * - Resource object to validate
+ * @param user - modifier data (userId)
+ * @param dataModel - IResourceOperation for resource crud
+ * @param resource - Resource object to validate
* @return Either<Boolean, ErrorResponse>
*/
private Either<Boolean, ResponseFormat> validateResourceFieldsBeforeCreate(User user, Resource resource, AuditingActionEnum actionEnum, boolean inTransaction) {
@@ -5449,7 +5811,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return eitherValidation;
}
- // validate vendor name & release
+ // validate vendor name & release & model number
log.debug("validate vendor name");
eitherValidation = validateVendorName(user, resource, actionEnum);
if (eitherValidation.isRight()) {
@@ -5462,6 +5824,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return eitherValidation;
}
+ log.debug("validate resource vendor model number");
+ eitherValidation = validateResourceVendorModelNumber(user, resource, actionEnum);
+ if (eitherValidation.isRight()) {
+ return eitherValidation;
+ }
+
// validate contact info
/*
* log.debug("validate contact info"); eitherValidation = validateContactIdContactId(user, resource, actionEnum); if (eitherValidation.isRight()) { return eitherValidation; }
@@ -5483,7 +5851,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// validate template (derived from)
log.debug("validate derived from");
- if (resource.getResourceType().equals(ResourceTypeEnum.VF)) {
+ if (!ToscaUtils.isAtomicType(resource) && resource.getResourceType() != ResourceTypeEnum.CVFC) {
resource.setDerivedFrom(null);
}
eitherValidation = validateDerivedFromExist(user, resource, actionEnum);
@@ -5519,8 +5887,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/**
* validateResourceFieldsBeforeUpdate
*
- * @param currentResource
- * - Resource object to validate
+ * @param currentResource - Resource object to validate
* @return Either<Boolean, ErrorResponse>
*/
private Either<Boolean, ResponseFormat> validateResourceFieldsBeforeUpdate(Resource currentResource, Resource updateInfoResource, boolean inTransaction) {
@@ -5559,6 +5926,13 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return eitherValidation;
}
+ log.debug("validate resource vendor model number before update");
+ eitherValidation = validateResourceVendorModelNumber(currentResource, updateInfoResource);
+ if (eitherValidation.isRight()) {
+ return eitherValidation;
+ }
+
+
log.debug("validate vendor release before update");
eitherValidation = validateVendorReleaseName(null, updateInfoResource, null);
if (eitherValidation.isRight()) {
@@ -5763,6 +6137,19 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.left(true);
}
+ private Either<Boolean, ResponseFormat> validateResourceVendorModelNumber(Resource currentResource, Resource updateInfoResource) {
+ String updatedResourceVendorModelNumber = updateInfoResource.getResourceVendorModelNumber();
+ String currentResourceVendorModelNumber = currentResource.getResourceVendorModelNumber();
+ if (!currentResourceVendorModelNumber.equals(updatedResourceVendorModelNumber)) {
+ Either<Boolean, ResponseFormat> validateResourceVendorModelNumber = validateResourceVendorModelNumber(null, updateInfoResource, null);
+ if (validateResourceVendorModelNumber.isRight()) {
+ ResponseFormat errorResponse = validateResourceVendorModelNumber.right().value();
+ return Either.right(errorResponse);
+ }
+ }
+ return Either.left(true);
+ }
+
private Either<Boolean, ResponseFormat> validateCategory(Resource currentResource, Resource updateInfoResource, boolean hasBeenCertified, boolean inTransaction) {
Either<Boolean, ResponseFormat> validateCategoryName = validateCategory(null, updateInfoResource, null, inTransaction);
if (validateCategoryName.isRight()) {
@@ -5841,9 +6228,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.trace("audit before sending response");
componentsUtils.auditResource(responseFormat, user, resource, "", "", actionEnum, null);
return Either.right(responseFormat);
- }
-
- else if (!dataModelResponse.left().value()) {
+ } else if (!dataModelResponse.left().value()) {
log.info("resource template with name: {}, does not exists", templateName);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.PARENT_RESOURCE_NOT_FOUND);
componentsUtils.auditResource(responseFormat, user, resource, "", "", actionEnum, null);
@@ -5958,7 +6343,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.right(responseFormat);
}
if (subcategories.size() > 1) {
- log.debug("Must be only one sub ategory for resource");
+ log.debug("Must be only one sub category for resource");
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.RESOURCE_TOO_MUCH_SUBCATEGORIES);
return Either.right(responseFormat);
}
@@ -6071,6 +6456,18 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
+ private Either<Boolean, ResponseFormat> validateResourceVendorModelNumber(User user, Resource resource, AuditingActionEnum actionEnum) {
+ String resourceVendorModelNumber = resource.getResourceVendorModelNumber();
+ Either<Boolean, ResponseFormat> validateResourceVendorModelNumber = validateResourceVendorModelNumber(resourceVendorModelNumber);
+ if (validateResourceVendorModelNumber.isRight()) {
+ ResponseFormat responseFormat = validateResourceVendorModelNumber.right().value();
+ componentsUtils.auditResource(responseFormat, user, resource, "", "", actionEnum, null);
+ }
+ return validateResourceVendorModelNumber;
+
+ }
+
+
private Either<Boolean, ResponseFormat> validateVendorName(String vendorName) {
if (vendorName != null) {
if (!ValidationUtils.validateVendorNameLength(vendorName)) {
@@ -6091,6 +6488,26 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
+ private Either<Boolean, ResponseFormat> validateResourceVendorModelNumber(String resourceVendorModelNumber) {
+ if (resourceVendorModelNumber.equals("")) {
+ return Either.left(true);
+ } else {
+ if (!ValidationUtils.validateResourceVendorModelNumberLength(resourceVendorModelNumber)) {
+ log.info("resource vendor model number exceeds limit.");
+ ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT, "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
+ return Either.right(errorResponse);
+ }
+ // resource vendor model number is currently validated as vendor name
+ if (!ValidationUtils.validateVendorName(resourceVendorModelNumber)) {
+ log.info("resource vendor model number is not valid.");
+ ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.INVALID_RESOURCE_VENDOR_MODEL_NUMBER);
+ return Either.right(errorResponse);
+ }
+ return Either.left(true);
+ }
+ }
+
+
/*
* private Either<Boolean, ResponseFormat> validateDescriptionAndCleanup(User user, Resource resource, AuditingActionEnum actionEnum) { String description = resource.getDescription(); if (!ValidationUtils.validateStringNotEmpty(description)) {
* log.debug("Resource description is empty"); ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus. COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.RESOURCE.getValue()); componentsUtils.auditResource(errorResponse,
@@ -6355,7 +6772,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (inputs.isRight()) {
String message = "Failed when creating inputs: for resource:" + resource.getName();
BeEcompErrorManager.getInstance().logInternalFlowError("ImportResource", message, ErrorSeverity.INFO);
- Map<String, InputDefinition> resultMap = new HashMap();
+ Map<String, InputDefinition> resultMap = new HashMap<>();
return Either.left(resultMap);
}
@@ -6568,7 +6985,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat> organizeVfCsarArtifactsByArtifactOperation(List<NonMetaArtifactInfo> artifactPathAndNameList, List<ArtifactDefinition> existingArtifactsToHandle,
- Resource resource, User user) {
+ Resource resource, User user) {
EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>> nodeTypeArtifactsToHandle = new EnumMap<>(ArtifactOperationEnum.class);
Wrapper<ResponseFormat> responseWrapper = new Wrapper<>();
@@ -6648,6 +7065,21 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
return toscaResourceName;
}
+
+ private String buildNodeToscaResourceName(String vfResourceName, String nodeTypeFullName) {
+ String toscaResourceName;
+ 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 = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + ResourceTypeEnum.VFC.name().toLowerCase() + '.' + vfResourceName + '.' + actualName;
+ } else {
+ toscaResourceName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + resourceType.toLowerCase() + '.' + vfResourceName + '.' + Constants.ABSTRACT + actualName;
+ }
+ return toscaResourceName;
+ }
public ICacheMangerOperation getCacheManagerOperation() {
return cacheManagerOperation;
@@ -6659,84 +7091,13 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
///////////////////////////////////////// DataModel refactoring/////////////////////////////////////////////
- /*
- * /**
- *
- * @deprecated Use {@link #createOrUpdateResourceByImport(Resource,User,boolean, boolean,boolean)} instead
- */
- /*
- * public Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResourceByImport(Resource resource, User user, AuditingActionEnum auditingEnum, boolean isNormative, boolean needLock) { return
- * createOrUpdateResourceByImport(resource, user, isNormative, false, needLock); }
- */
-
- public Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateNodeTypeByImport(Resource resource, User user, boolean isNormative, boolean isInTransaction, boolean needLock) {
-
- // check if resource already exist
- Either<Resource, StorageOperationStatus> latestByName = toscaOperationFacade.getLatestByName(resource.getName());
- Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> result = null;
-
- // create
- if (latestByName.isRight() && latestByName.right().value().equals(StorageOperationStatus.NOT_FOUND)) {
-
- Either<Resource, StorageOperationStatus> latestByToscaName = toscaOperationFacade.getLatestByToscaResourceName(resource.getToscaResourceName());
- if (latestByToscaName.isRight() && latestByToscaName.right().value().equals(StorageOperationStatus.NOT_FOUND))
- result = createNodeTypeByImport(resource, user, isNormative, isInTransaction);
-
- else {
- StorageOperationStatus status = latestByName.right().value();
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeResourceMissingError, "Create / Update resource by import", resource.getName());
- BeEcompErrorManager.getInstance().logBeComponentMissingError("Create / Update resource by import", ComponentTypeEnum.RESOURCE.getValue(), resource.getName());
- log.debug("resource already exist {}. status={}", resource.getName(), status);
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.RESOURCE_ALREADY_EXISTS);
- componentsUtils.auditResource(responseFormat, user, resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
- result = Either.right(responseFormat);
- }
-
- }
-
- // update
- else if (latestByName.isLeft()) {
- // result = updateExistingNodeTypeByImport(resource, latestByName.left().value(), user, isNormative, needLock);
- }
-
- // error
- else {
- StorageOperationStatus status = latestByName.right().value();
- BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeResourceMissingError, "Create / Update resource by import", resource.getName());
- log.debug("failed to get latest version of resource {}. status={}", resource.getName(), status);
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(latestByName.right().value()), resource);
- componentsUtils.auditResource(responseFormat, user, resource, "", "", AuditingActionEnum.IMPORT_RESOURCE, null);
- result = Either.right(responseFormat);
- }
- return result;
-
- }
-
- private Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createNodeTypeByImport(Resource resource, User user, boolean isNormative, boolean isInTransaction) {
- log.debug("resource with name {} does not exist. create new resource", resource.getName());
- Either<Resource, ResponseFormat> response = validateResourceBeforeCreate(resource, user, AuditingActionEnum.IMPORT_RESOURCE, isInTransaction);
- if (response.isRight()) {
- return Either.right(response.right().value());
- }
-
- Either<Resource, ResponseFormat> createResponse = createResourceByDao(resource, user, AuditingActionEnum.IMPORT_RESOURCE, isNormative, isInTransaction, null);
- if (createResponse.isRight()) {
- return Either.right(createResponse.right().value());
- } else {
- ImmutablePair<Resource, ActionStatus> resourcePair = new ImmutablePair<>(createResponse.left().value(), ActionStatus.CREATED);
- ASDCKpiApi.countImportResourcesKPI();
- return Either.left(resourcePair);
-
- }
- }
-
public Either<UiComponentDataTransfer, ResponseFormat> getUiComponentDataTransferByComponentId(String resourceId, List<String> dataParamsToReturn) {
ComponentParametersView paramsToRetuen = new ComponentParametersView(dataParamsToReturn);
Either<Resource, StorageOperationStatus> resourceResultEither = toscaOperationFacade.getToscaElement(resourceId, paramsToRetuen);
if (resourceResultEither.isRight()) {
- if(resourceResultEither.right().value().equals(StorageOperationStatus.NOT_FOUND)) {
+ if (resourceResultEither.right().value().equals(StorageOperationStatus.NOT_FOUND)) {
log.debug("Failed to found resource with id {} ", resourceId);
Either.right(componentsUtils.getResponseFormat(ActionStatus.RESOURCE_NOT_FOUND, resourceId));
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index b157b635b4..d2743aa039 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -124,7 +124,7 @@ public class ResourceImportManager {
lifecycleChangeInfo.setUserRemarks("certification on import");
Function<Resource, Either<Boolean, ResponseFormat>> validator = (resource) -> resourceBusinessLogic.validatePropertiesDefaultValues(resource);
- return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false, createNewVersion, needLock, null, null);
+ return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false, createNewVersion, needLock, null, null, false);
}
public Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> importNormativeResourceFromCsar(String resourceYml, UploadResourceInfo resourceMetaData, User creator, boolean createNewVersion, boolean needLock) {
@@ -133,18 +133,18 @@ public class ResourceImportManager {
lifecycleChangeInfo.setUserRemarks("certification on import");
Function<Resource, Either<Boolean, ResponseFormat>> validator = (resource) -> resourceBusinessLogic.validatePropertiesDefaultValues(resource);
- return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false, createNewVersion, needLock, null, null);
+ return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false, createNewVersion, needLock, null, null, false);
}
public Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> importCertifiedResource(String resourceYml, UploadResourceInfo resourceMetaData, User creator, Function<Resource, Either<Boolean, ResponseFormat>> validationFunction,
- LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean isInTransaction, boolean createNewVersion, boolean needLock, Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts) {
+ LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean isInTransaction, boolean createNewVersion, boolean needLock, Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, boolean forceCertificationAllowed) {
Resource resource = new Resource();
ImmutablePair<Resource, ActionStatus> responsePair = new ImmutablePair<>(resource, ActionStatus.CREATED);
Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> response = Either.left(responsePair);
String latestCertifiedResourceId = null;
try {
- boolean shouldBeCertified = nodeTypeArtifactsToHandle == null || nodeTypeArtifactsToHandle.isEmpty() ? true : false;
+ boolean shouldBeCertified = nodeTypeArtifactsToHandle == null || nodeTypeArtifactsToHandle.isEmpty();
setConstantMetaData(resource, shouldBeCertified);
setMetaDataFromJson(resourceMetaData, resource);
@@ -179,7 +179,7 @@ public class ResourceImportManager {
}
}
latestCertifiedResourceId = getLatestCertifiedResourceId(resource);
- changeStateResponse = resourceBusinessLogic.propagateStateToCertified(creator, resource, lifecycleChangeInfo, isInTransaction, needLock);
+ changeStateResponse = resourceBusinessLogic.propagateStateToCertified(creator, resource, lifecycleChangeInfo, isInTransaction, needLock, forceCertificationAllowed);
if (changeStateResponse.isRight()) {
response = Either.right(changeStateResponse.right().value());
} else {
@@ -270,14 +270,14 @@ public class ResourceImportManager {
}
- private Either<Boolean, ResponseFormat> populateResourceFromYaml(String resourceYml, Resource resource, boolean inTransaction) {
+ Either<Boolean, ResponseFormat> populateResourceFromYaml(String resourceYml, Resource resource, boolean inTransaction) {
@SuppressWarnings("unchecked")
Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
Map<String, Object> toscaJsonAll = (Map<String, Object>) new Yaml().load(resourceYml);
Map<String, Object> toscaJson = toscaJsonAll;
// Checks if exist and builds the node_types map
- if (toscaJsonAll.containsKey(ToscaTagNamesEnum.NODE_TYPES.getElementName())) {
+ if (toscaJsonAll.containsKey(ToscaTagNamesEnum.NODE_TYPES.getElementName()) && resource.getResourceType()!=ResourceTypeEnum.CVFC) {
toscaJson = new HashMap<String, Object>();
toscaJson.put(ToscaTagNamesEnum.NODE_TYPES.getElementName(), toscaJsonAll.get(ToscaTagNamesEnum.NODE_TYPES.getElementName()));
}
@@ -721,7 +721,7 @@ public class ResourceImportManager {
capabilityDefinition.setProperties(capabilityProperties);
}
}
- } else {
+ } else if (!(capabilityJson instanceof List)) {
result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_YAML));
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index bc1c6e5910..ae7ae31ed9 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -447,14 +447,12 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
return componentsFieldsValidation;
}
- // validate service name uniqueness
log.debug("validate service name uniqueness");
Either<Boolean, ResponseFormat> serviceNameUniquenessValidation = validateComponentNameUnique(user, service, actionEnum);
if (serviceNameUniquenessValidation.isRight()) {
return serviceNameUniquenessValidation;
}
- // validate category
log.debug("validate category");
Either<Boolean, ResponseFormat> categoryValidation = validateServiceCategory(user, service, actionEnum);
if (categoryValidation.isRight()) {
@@ -462,12 +460,23 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
// validate project name (ProjectCode) - mandatory in service
-
log.debug("validate projectName");
Either<Boolean, ResponseFormat> projectCodeValidation = validateProjectCode(user, service, actionEnum);
if (projectCodeValidation.isRight()) {
return projectCodeValidation;
}
+
+ log.debug("validate service type");
+ Either<Boolean, ResponseFormat> serviceTypeValidation = validateServiceTypeAndCleanup(user, service, actionEnum);
+ if (serviceTypeValidation.isRight()) {
+ return serviceTypeValidation;
+ }
+
+ log.debug("validate service role");
+ Either<Boolean, ResponseFormat> serviceRoleValidation = validateServiceRoleAndCleanup(user, service, actionEnum);
+ if (serviceRoleValidation.isRight()) {
+ return serviceRoleValidation;
+ }
return Either.left(true);
@@ -704,6 +713,18 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (!uuidCurrent.equals(uuidUpdated)) {
log.info("update srvice: recived request to update uuid to {} the field is not updatable ignoring.", uuidUpdated);
}
+
+ response = validateAndUpdateServiceType(user, currentService, serviceUpdate, null);
+ if (response.isRight()) {
+ ResponseFormat errorResponse = response.right().value();
+ return Either.right(errorResponse);
+ }
+
+ response = validateAndUpdateServiceRole(user, currentService, serviceUpdate, null);
+ if (response.isRight()) {
+ ResponseFormat errorResponse = response.right().value();
+ return Either.right(errorResponse);
+ }
String currentInvariantUuid = currentService.getInvariantUUID();
String updatedInvariantUuid = serviceUpdate.getInvariantUUID();
@@ -821,18 +842,18 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
return Either.left(true);
}
- private Either<Boolean, ResponseFormat> validateAndUpdateServiceName(User user, Service currentService, Service serviceUpdate, boolean hasBeenCertified, AuditingActionEnum audatingAction) {
+ private Either<Boolean, ResponseFormat> validateAndUpdateServiceName(User user, Service currentService, Service serviceUpdate, boolean hasBeenCertified, AuditingActionEnum auditingAction) {
String serviceNameUpdated = serviceUpdate.getName();
String serviceNameCurrent = currentService.getName();
if (!serviceNameCurrent.equals(serviceNameUpdated)) {
if (!hasBeenCertified) {
- Either<Boolean, ResponseFormat> validatServiceNameResponse = validateComponentName(user, serviceUpdate, audatingAction);
+ Either<Boolean, ResponseFormat> validatServiceNameResponse = validateComponentName(user, serviceUpdate, auditingAction);
if (validatServiceNameResponse.isRight()) {
ResponseFormat errorRespons = validatServiceNameResponse.right().value();
return Either.right(errorRespons);
}
- Either<Boolean, ResponseFormat> serviceNameUniquenessValidation = validateComponentNameUnique(user, serviceUpdate, audatingAction);
+ Either<Boolean, ResponseFormat> serviceNameUniquenessValidation = validateComponentNameUnique(user, serviceUpdate, auditingAction);
if (serviceNameUniquenessValidation.isRight()) {
return serviceNameUniquenessValidation;
}
@@ -848,6 +869,111 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
return Either.left(true);
}
+
+ private Either<Boolean, ResponseFormat> validateAndUpdateServiceType(User user, Service currentService, Service updatedService, AuditingActionEnum auditingAction) {
+ String updatedServiceType = updatedService.getServiceType();
+ String currentServiceType = currentService.getServiceType();
+ if (!currentServiceType.equals(updatedServiceType)) {
+ Either<Boolean, ResponseFormat> validateServiceType = validateServiceTypeAndCleanup(user, updatedService , auditingAction);
+ if (validateServiceType.isRight()) {
+ ResponseFormat errorResponse = validateServiceType.right().value();
+ componentsUtils.auditComponentAdmin(errorResponse, user, updatedService, "", "", auditingAction, ComponentTypeEnum.SERVICE);
+ return Either.right(errorResponse);
+ }
+ currentService.setServiceType(updatedServiceType);
+ }
+ return Either.left(true);
+ }
+
+ protected Either<Boolean, ResponseFormat> validateServiceTypeAndCleanup(User user, Component component, AuditingActionEnum actionEnum) {
+ String serviceType = ((Service)component).getServiceType();
+ if (serviceType != null){
+ serviceType = cleanUpText(serviceType);
+ Either<Boolean, ResponseFormat> validateServiceType = validateServiceType(serviceType);
+ if (validateServiceType.isRight()) {
+ ResponseFormat responseFormat = validateServiceType.right().value();
+ componentsUtils.auditComponentAdmin(responseFormat, user, component, "", "", actionEnum, ComponentTypeEnum.SERVICE);
+ return Either.right(responseFormat);
+ }
+ return Either.left(true);
+ } else {
+ return Either.left(false);
+ }
+ }
+
+
+ private Either<Boolean, ResponseFormat> validateServiceType(String serviceType) {
+ if (serviceType.equals("")){
+ return Either.left(true);
+ } else {
+ if (!ValidationUtils.validateServiceTypeLength(serviceType)) {
+ log.info("service type exceeds limit.");
+ ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.SERVICE_TYPE_EXCEEDS_LIMIT, "" + ValidationUtils.SERVICE_TYPE_MAX_LENGTH);
+ return Either.right(errorResponse);
+ }
+
+ if (!ValidationUtils.validateIsEnglish(serviceType)) {
+ log.info("service type is not valid.");
+ ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.INVALID_SERVICE_TYPE);
+ return Either.right(errorResponse);
+ }
+ return Either.left(true);
+ }
+ }
+
+ private Either<Boolean, ResponseFormat> validateAndUpdateServiceRole(User user, Service currentService, Service updatedService, AuditingActionEnum auditingAction) {
+ String updatedServiceRole = updatedService.getServiceRole();
+ String currentServiceRole = currentService.getServiceRole();
+ if (!currentServiceRole.equals(updatedServiceRole)) {
+ Either<Boolean, ResponseFormat> validateServiceRole = validateServiceRoleAndCleanup(user, updatedService , auditingAction);
+ if (validateServiceRole.isRight()) {
+ ResponseFormat errorResponse = validateServiceRole.right().value();
+ componentsUtils.auditComponentAdmin(errorResponse, user, updatedService, "", "", auditingAction, ComponentTypeEnum.SERVICE);
+ return Either.right(errorResponse);
+ }
+ currentService.setServiceRole(updatedServiceRole);
+ }
+ return Either.left(true);
+ }
+
+ protected Either<Boolean, ResponseFormat> validateServiceRoleAndCleanup(User user, Component component, AuditingActionEnum actionEnum) {
+ String serviceRole = ((Service)component).getServiceRole();
+ if (serviceRole != null){
+ serviceRole = cleanUpText(serviceRole);
+
+ Either<Boolean, ResponseFormat> validateServiceRole = validateServiceRole(serviceRole);
+ if (validateServiceRole.isRight()) {
+ ResponseFormat responseFormat = validateServiceRole.right().value();
+ componentsUtils.auditComponentAdmin(responseFormat, user, component, "", "", actionEnum, ComponentTypeEnum.SERVICE);
+ return Either.right(responseFormat);
+ }
+ return Either.left(true);
+ } else {
+ return Either.left(false);
+ }
+ }
+
+
+ private Either<Boolean, ResponseFormat> validateServiceRole(String serviceRole) {
+ if (serviceRole.equals("")){
+ return Either.left(true);
+ } else {
+ if (!ValidationUtils.validateServiceRoleLength(serviceRole)) {
+ log.info("service role exceeds limit.");
+ ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.SERVICE_ROLE_EXCEEDS_LIMIT, "" + ValidationUtils.SERVICE_ROLE_MAX_LENGTH);
+ return Either.right(errorResponse);
+ }
+
+ if (!ValidationUtils.validateIsEnglish(serviceRole)) {
+ log.info("service role is not valid.");
+ ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.INVALID_SERVICE_ROLE);
+ return Either.right(errorResponse);
+ }
+ return Either.left(true);
+ }
+ }
+
+
private Either<Boolean, ResponseFormat> validateAndUpdateCategory(User user, Service currentService, Service serviceUpdate, boolean hasBeenCertified, AuditingActionEnum audatingAction) {
List<CategoryDefinition> categoryUpdated = serviceUpdate.getCategories();
@@ -1225,7 +1351,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
// DE194021
ServletContext servletContext = request.getSession().getServletContext();
- boolean isDistributionEngineUp = getHealthCheckBL(servletContext).isDistributionEngineUp(request.getSession().getServletContext()); // DE
+ boolean isDistributionEngineUp = getHealthCheckBL(servletContext).isDistributionEngineUp(); // DE
if (!isDistributionEngineUp) {
BeEcompErrorManager.getInstance().logBeSystemError("Distribution Engine is DOWN");
log.debug("Distribution Engine is DOWN");
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceComponentInstanceBusinessLogic.java
index 9586be81ea..11ffcd9329 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceComponentInstanceBusinessLogic.java
@@ -31,10 +31,6 @@ import fj.data.Either;
@Component("serviceComponentInstanceBusinessLogic")
public class ServiceComponentInstanceBusinessLogic extends ComponentInstanceBusinessLogic {
- @Override
- protected Either<Boolean, ResponseFormat> validateAllowedToContainCompInstances(org.openecomp.sdc.be.model.Component containerComponent) {
- return Either.left(true);
- }
@Override
protected NodeTypeEnum getNodeTypeOfComponentInstanceOrigin() {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/VFComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/VFComponentInstanceBusinessLogic.java
index 61a5af5b74..5a93ecf182 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/VFComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/VFComponentInstanceBusinessLogic.java
@@ -25,6 +25,7 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.tosca.ToscaUtils;
import org.openecomp.sdc.exception.ResponseFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,17 +39,6 @@ public class VFComponentInstanceBusinessLogic extends ComponentInstanceBusinessL
private static Logger log = LoggerFactory.getLogger(VFComponentInstanceBusinessLogic.class.getName());
@Override
- protected Either<Boolean, ResponseFormat> validateAllowedToContainCompInstances(org.openecomp.sdc.be.model.Component containerComponent) {
- Resource resource = (Resource) containerComponent;
- ResourceTypeEnum resourceType = resource.getResourceType();
- if (ResourceTypeEnum.VF != resourceType) {
- log.debug("Cannot attach resource instances to container resource of type {}", resourceType);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESOURCE_CANNOT_CONTAIN_RESOURCE_INSTANCES, resourceType.getValue()));
- }
- return Either.left(true);
- }
-
- @Override
protected NodeTypeEnum getNodeTypeOfComponentInstanceOrigin() {
return NodeTypeEnum.Resource;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransition.java
index 042af54383..b18c4d0985 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransition.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTransition.java
@@ -55,6 +55,7 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElementTypeEnum;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementLifecycleOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
@@ -66,6 +67,7 @@ import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.tosca.ToscaError;
import org.openecomp.sdc.be.tosca.ToscaExportHandler;
import org.openecomp.sdc.be.tosca.ToscaRepresentation;
+import org.openecomp.sdc.be.tosca.ToscaUtils;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.util.ValidationUtils;
@@ -196,7 +198,7 @@ public class CertificationRequestTransition extends LifeCycleTransition {
ResponseFormat responseFormat;
Either<? extends Component, ResponseFormat> result = null;
try{
- if (componentType == ComponentTypeEnum.SERVICE || (componentType == ComponentTypeEnum.RESOURCE && ((Resource) component).getResourceType() == ResourceTypeEnum.VF)) {
+ if (component.getToscaType().equals(ToscaElementTypeEnum.TopologyTemplate.getValue())) {
Either<Boolean, ResponseFormat> statusCert = validateAllResourceInstanceCertified(component);
if (statusCert.isRight()) {
@@ -270,7 +272,10 @@ public class CertificationRequestTransition extends LifeCycleTransition {
// occurrences in the future
Map<String, List<String>> reqName2Ids = new HashMap<>();
Map<String, List<String>> capName2Ids = new HashMap<>();
- parseRelationsForReqCapVerification(component, reqName2Ids, capName2Ids);
+// Either<Boolean, ResponseFormat> parseRelationsForReqCapVerificationRes = parseRelationsForReqCapVerification(component, reqName2Ids, capName2Ids);
+// if(parseRelationsForReqCapVerificationRes.isRight()){
+// return parseRelationsForReqCapVerificationRes;
+// }
Map<String, Set<String>> requirementsToFulfillBeforeCert = configurationManager.getConfiguration().getRequirementsToFulfillBeforeCert();
Map<String, Set<String>> capabilitiesToConsumeBeforeCert = configurationManager.getConfiguration().getCapabilitiesToConsumeBeforeCert();
for (ComponentInstance compInst : componentInstances) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java
index 8e89a6bf31..4fe0965ef6 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java
@@ -32,6 +32,7 @@ import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic;
import org.openecomp.sdc.be.components.impl.ProductBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
+import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction.LifecycleChanceActionEnum;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
@@ -46,13 +47,14 @@ import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementLifecycleOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.api.ICacheMangerOperation;
import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.CapabilityOperation;
-import org.openecomp.sdc.be.model.operations.impl.ComponentOperation;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.tosca.ToscaExportHandler;
import org.openecomp.sdc.common.api.Constants;
@@ -204,9 +206,9 @@ public class LifecycleBusinessLogic {
String resourceCurrVersion = component.getVersion();
LifecycleStateEnum resourceCurrState = component.getLifecycleState();
- log.info("lock component {}", componentId);
// lock resource
if (inTransaction == false && needLock) {
+ log.info("lock component {}", componentId);
Either<Boolean, ResponseFormat> eitherLockResource = lockComponent(componentType, component);
if (eitherLockResource.isRight()) {
errorResponse = eitherLockResource.right().value();
@@ -214,8 +216,8 @@ public class LifecycleBusinessLogic {
log.error("lock component {} failed", componentId);
return Either.right(errorResponse);
}
+ log.info("after lock component {}", componentId);
}
- log.info("after lock component {}", componentId);
try {
Either<String, ResponseFormat> commentValidationResult = validateComment(changeInfo, transitionEnum);
if (commentValidationResult.isRight()) {
@@ -463,4 +465,51 @@ public class LifecycleBusinessLogic {
return Either.left(latestComponent);
}
+ public Either<Resource, ResponseFormat> forceResourceCertification(Resource resource, User user, LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean inTransaction, boolean needLock) {
+ Either<Resource, ResponseFormat> result = null;
+ Either<ToscaElement, StorageOperationStatus> certifyResourceRes = null;
+ if(lifecycleChangeInfo.getAction() != LifecycleChanceActionEnum.CREATE_FROM_CSAR){
+ log.debug("Force certification is not allowed for the action {}. ", lifecycleChangeInfo.getAction().name());
+ result = Either.right(componentUtils.getResponseFormat(ActionStatus.NOT_ALLOWED));
+ }
+ // lock resource
+ if(result == null && !inTransaction && needLock){
+ log.info("lock component {}", resource.getUniqueId());
+ Either<Boolean, ResponseFormat> eitherLockResource = lockComponent(resource.getComponentType(), resource);
+ if (eitherLockResource.isRight()) {
+ log.error("lock component {} failed", resource.getUniqueId());
+ result = Either.right(eitherLockResource.right().value());
+ }
+ log.info("after lock component {}", resource.getUniqueId());
+ }
+ try{
+ if(result == null){
+ certifyResourceRes = lifecycleOperation.forceCerificationOfToscaElement(resource.getUniqueId(), user.getUserId(), user.getUserId());
+ if (certifyResourceRes.isRight()) {
+ StorageOperationStatus status = certifyResourceRes.right().value();
+ log.debug("Failed to perform a force certification of resource {}. The status is {}. ", resource.getName(), status);
+ result = Either.right(componentUtils.getResponseFormatByResource(componentUtils.convertFromStorageResponse(status), resource));
+ }
+ }
+ if(result == null){
+ result = Either.left(ModelConverter.convertFromToscaElement(certifyResourceRes.left().value()));
+ }
+ } finally {
+ log.info("unlock component {}", resource.getUniqueId());
+ if (!inTransaction) {
+ if(result.isLeft()){
+ titanDao.commit();
+ } else{
+ titanDao.rollback();
+ }
+ if(needLock){
+ NodeTypeEnum nodeType = resource.getComponentType().getNodeType();
+ log.info("During change state, another component {} has been created/updated", resource.getUniqueId());
+ graphLockOperation.unlockComponent(resource.getUniqueId(), nodeType);
+ }
+ }
+ }
+ return result;
+ }
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java
index c3708d4017..f96e226d26 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java
@@ -126,10 +126,11 @@ public class AssetsDataServlet extends AbstractValidationsServlet {
Response response = null;
ResponseFormat responseFormat = null;
String query = request.getQueryString();
- String requestURI = request.getRequestURI();
+ String requestURI = request.getRequestURI().endsWith("/")?
+ removeDuplicateSlashSeparator(request.getRequestURI()): request.getRequestURI();
String url = request.getMethod() + " " + requestURI;
log.debug("Start handle request of {}", url);
-
+
AuditingActionEnum auditingActionEnum = query == null ? AuditingActionEnum.GET_ASSET_LIST : AuditingActionEnum.GET_FILTERED_ASSET_LIST;
EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(AuditingFieldsKeysEnum.class);
@@ -162,7 +163,7 @@ public class AssetsDataServlet extends AbstractValidationsServlet {
}
if (resourceType != null) {
ResourceTypeEnum resourceTypeEnum = ResourceTypeEnum.getTypeIgnoreCase(resourceType);
- if( resourceTypeEnum == null ){
+ if (resourceTypeEnum == null) {
log.debug("getAssetList: Asset Fetching Failed. Invalid resource type was received");
responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
@@ -370,4 +371,11 @@ public class AssetsDataServlet extends AbstractValidationsServlet {
return response;
}
}
+
+
+ private String removeDuplicateSlashSeparator(String requestUri) {
+ return requestUri.substring(0, requestUri.length()-1);
+ }
+
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java
index b4240777a8..40a5322afa 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java
@@ -120,7 +120,7 @@ public class CrudExternalServlet extends AbstractValidationsServlet {
@ApiOperation(value = "creates a resource", httpMethod = "POST", notes = "Creates a resource")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "ECOMP component is authenticated and Asset created", response = Resource.class),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing X-ECOMP-InstanceID HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
@@ -269,7 +269,7 @@ public class CrudExternalServlet extends AbstractValidationsServlet {
@ApiOperation(value = "Change Resource lifecycle State", httpMethod = "POST")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Resource state changed", response = AssetMetadata.class),
- @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
+ @ApiResponse(code = 400, message = "Missing X-ECOMP-InstanceID HTTP header - POL5001"),
@ApiResponse(code = 401, message = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
@ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
@ApiResponse(code = 404, message = "Error: Requested '%1' (uuid) resource was not found - SVC4063"),
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentServlet.java
index 92bc31f123..dff6cddbbb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentServlet.java
@@ -120,7 +120,7 @@ public class ComponentServlet extends BeGenericServlet {
@Path("/{componentType}/{componentId}/requirmentsCapabilities")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value = "Get Component Requirments And Capabilities", httpMethod = "GET", notes = "Returns Requirments And Capabilities according to componentId", response = Resource.class)
+ @ApiOperation(value = "Get Component Requirments And Capabilities", httpMethod = "GET", notes = "Returns Requirements And Capabilities according to componentId", response = Resource.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Component found"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 404, message = "Component not found") })
public Response getRequirementAndCapabilities(@PathParam("componentType") final String componentType, @PathParam("componentId") final String componentId, @Context final HttpServletRequest request,
@HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java
index da64dc58fb..4b2ff89ef8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java
@@ -20,26 +20,8 @@
package org.openecomp.sdc.be.servlets;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Singleton;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
+import com.jcabi.aspects.Loggable;
+import fj.data.Either;
import org.openecomp.sdc.be.components.clean.ComponentsCleanBusinessLogic;
import org.openecomp.sdc.be.components.impl.ElementBusinessLogic;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
@@ -47,13 +29,9 @@ import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.info.ArtifactTypesInfo;
-import org.openecomp.sdc.be.model.ArtifactType;
-import org.openecomp.sdc.be.model.Category;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.PropertyScope;
-import org.openecomp.sdc.be.model.Tag;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.GroupingDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
@@ -65,14 +43,20 @@ import org.openecomp.sdc.exception.ResponseFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.jcabi.aspects.Loggable;
+import javax.inject.Singleton;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-import fj.data.Either;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.*;
@Path("/v1/")
@@ -552,14 +536,14 @@ public class ElementServlet extends BeGenericServlet {
@ApiOperation(value = "Retrieve catalog resources and services", httpMethod = "GET", notes = "Retrieve catalog resources and services", response = User.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Returns resources and services Ok"), @ApiResponse(code = 404, message = "No resources and services were found"), @ApiResponse(code = 404, message = "User not found"),
@ApiResponse(code = 500, message = "Internal Server Error") })
- public Response getCatalogComponents(@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
+ public Response getCatalogComponents(@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId, @QueryParam("excludeTypes") List<OriginTypeEnum> excludeTypes) {
Response res = null;
try {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug("Start handle request of {}", url);
- Either<Map<String, List<? extends Component>>, ResponseFormat> catalogData = getElementBL(request.getSession().getServletContext()).getCatalogComponents(userId);
+ Either<Map<String, List<? extends Component>>, ResponseFormat> catalogData = getElementBL(request.getSession().getServletContext()).getCatalogComponents(userId, excludeTypes);
if (catalogData.isRight()) {
log.debug("failed to get catalog data");
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/GroupServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/GroupServlet.java
index 04081bac30..f7e7ae2da1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/GroupServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/GroupServlet.java
@@ -153,7 +153,7 @@ public class GroupServlet extends AbstractValidationsServlet {
// Update GroupDefinition
ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
Either<GroupDefinition, ResponseFormat> actionResponse = businessLogic
- .validateAndUpdateGroupMetadata(componentId, user, componentTypeEnum, updatedGroup, true);
+ .validateAndUpdateGroupMetadata(componentId, user, componentTypeEnum, updatedGroup, true ,true);
if (actionResponse.isRight()) {
log.debug("failed to update GroupDefinition");
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 fb87e34de7..b70dae68e8 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
@@ -75,8 +75,10 @@ import org.openecomp.sdc.be.model.operations.impl.LifecycleOperation;
import org.openecomp.sdc.be.resources.data.ESArtifactData;
import org.openecomp.sdc.be.resources.data.SdcSchemaFilesData;
import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
+import org.openecomp.sdc.be.utils.CommonBeUtils;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
+import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.util.GeneralUtility;
import org.openecomp.sdc.common.util.ValidationUtils;
@@ -146,9 +148,14 @@ public class CsarUtils {
"([\\w\\_\\-\\.\\s]+)(/)" +
// Artifact Type
"([\\w\\_\\-\\.\\s]+)(/)" +
- // Artifact File Name
- "([\\w\\_\\-\\.\\s]+)";
- public static final String ARTIFACT_CREATED_FROM_CSAR = "Artifact created from csar";
+ // Artifact Any File Name
+ ".+";
+ public static final String VALID_ENGLISH_ARTIFACT_NAME = "([\\w\\_\\-\\.\\s]+)";
+ public static final String SERVICE_TEMPLATE_PATH_PATTERN = Constants.SERVICE_TEMPLATES_CONTAINING_FOLDER +
+ // Service Template File Name
+ "([\\w\\_\\-\\.\\s]+)";
+
+ public static final String ARTIFACT_CREATED_FROM_CSAR = "Artifact created from csar";
public CsarUtils() {
if(SDC_VERSION != null && !SDC_VERSION.isEmpty()){
@@ -281,8 +288,8 @@ public class CsarUtils {
dependencies = dependenciesRes.left().value().getDependencies();
}
- //UID <cassandraId,filename,component>
- Map<String, ImmutableTriple<String,String, Component>> innerComponentsCache = new HashMap<>();
+ //UID <cassandraId,filename,component>
+ Map<String, ImmutableTriple<String,String, Component>> innerComponentsCache = new HashMap<>();
if (dependencies != null && !dependencies.isEmpty()) {
for (Triple<String, String, Component> d : dependencies) {
@@ -295,18 +302,16 @@ public class CsarUtils {
return Either.right(responseFormat);
}
- //fill innerComponentsCache
- fileName = d.getLeft();
- innerComponentsCache.put(childComponent.getUniqueId(),
- new ImmutableTriple<String, String, Component>(cassandraId, fileName, childComponent));
- insertInnerComponentsToCache(innerComponentsCache, childComponent);
-
- byte[] content = entryData.left().value();
- generatorInputs.add(new ImmutablePair<Component, byte[]>(childComponent, content));
- }
+ //fill innerComponentsCache
+ fileName = d.getLeft();
+ addComponentToCache(innerComponentsCache, cassandraId, fileName, childComponent);
+ addInnerComponentsToCache(innerComponentsCache, childComponent);
- //add inner components to CSAR
-
+ byte[] content = entryData.left().value();
+ generatorInputs.add(new ImmutablePair<Component, byte[]>(childComponent, content));
+ }
+
+ //add inner components to CSAR
for (Entry<String, ImmutableTriple<String, String, Component>> innerComponentTripleEntry : innerComponentsCache.entrySet()) {
ImmutableTriple<String, String, Component> innerComponentTriple = innerComponentTripleEntry.getValue();
@@ -418,7 +423,7 @@ public class CsarUtils {
}
- private void insertInnerComponentsToCache(Map<String, ImmutableTriple<String, String, Component>> componentCache,
+ private void addInnerComponentsToCache(Map<String, ImmutableTriple<String, String, Component>> componentCache,
Component childComponent) {
List<ComponentInstance> instances = childComponent.getComponentInstances();
@@ -438,19 +443,32 @@ public class CsarUtils {
ArtifactDefinition childArtifactDefinition = childToscaArtifacts.get(ToscaExportHandler.ASSET_TOSCA_TEMPLATE);
if (childArtifactDefinition != null) {
//add to cache
- componentCache.put(ci.getComponentUid(),
- new ImmutableTriple<String, String, Component>(childArtifactDefinition.getEsId(),
- childArtifactDefinition.getArtifactName(), componentRI));
+ addComponentToCache(componentCache, childArtifactDefinition.getEsId(), childArtifactDefinition.getArtifactName(), componentRI);
}
//if not atomic - insert inner components as well
if(!ToscaUtils.isAtomicType(componentRI)) {
- insertInnerComponentsToCache(componentCache, componentRI);
+ addInnerComponentsToCache(componentCache, componentRI);
}
}
});
}
}
+
+ private void addComponentToCache(Map<String, ImmutableTriple<String, String, Component>> componentCache,
+ String id, String fileName, Component component) {
+
+ ImmutableTriple<String, String, Component> cachedComponent = componentCache.get(component.getInvariantUUID());
+ if (cachedComponent == null || CommonBeUtils.compareAsdcComponentVersions(component.getVersion(), cachedComponent.getRight().getVersion())) {
+ componentCache.put(component.getInvariantUUID(),
+ new ImmutableTriple<String, String, Component>(id, fileName, component));
+
+ if(cachedComponent != null) {
+ //overwriting component with newer version
+ log.warn("Overwriting component invariantID {} of version {} with a newer version {}", id, cachedComponent.getRight().getVersion(), component.getVersion());
+ }
+ }
+ }
private Either<ZipOutputStream, ResponseFormat> writeComponentInterface(Component component, ZipOutputStream zip, String fileName) {
try {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
index 0804ef1ed4..b8414367aa 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
@@ -100,7 +100,7 @@ public class PropertyConvertor {
eschema.setDescription(schema.getProperty().getDescription());
prop.setEntry_schema(eschema);
}
- log.debug("try to convert property {} from type {} with default value {}", property.getName(), property.getType(), property.getDefaultValue());
+ log.trace("try to convert property {} from type {} with default value [{}]", property.getName(), property.getType(), property.getDefaultValue());
prop.setDefaultp(convertToToscaObject(property.getType(), property.getName(), property.getDefaultValue(), innerType, dataTypes));
prop.setType(property.getType());
prop.setDescription(property.getDescription());
@@ -112,45 +112,46 @@ public class PropertyConvertor {
}
public Object convertToToscaObject(String propertyType, String propertyName, String value, String innerType, Map<String, DataTypeDefinition> dataTypes) {
- log.debug("try to convert propertyType {} , value {}, innerType {}", propertyType, value, innerType);
+ log.trace("try to convert propertyType {} , value [{}], innerType {}", propertyType, value, innerType);
if (value == null) {
value = getDataTypeDefaultValue(propertyName, dataTypes.get(propertyType));
if(StringUtils.isEmpty(value)){
return null;
}
- }
-
- ToscaMapValueConverter mapConverterInst = ToscaMapValueConverter.getInstance();
- ToscaValueConverter innerConverter = null;
- Boolean isScalar = true;
-
- ToscaPropertyType type = ToscaPropertyType.isValidType(propertyType);
- if (type == null) {
- log.debug("isn't prederfined type, get from all data types");
- DataTypeDefinition dataTypeDefinition = dataTypes.get(propertyType);
- if (innerType == null) {
- innerType = propertyType;
- }
-
- if ((type = mapConverterInst.isScalarType(dataTypeDefinition)) != null) {
- log.debug("This is scalar type. get suitable converter for type {}", type);
- innerConverter = type.getValueConverter();
- } else {
- isScalar = false;
- }
- } else {
- ToscaPropertyType typeIfScalar = ToscaPropertyType.getTypeIfScalar(type.getType());
- if (typeIfScalar == null) {
- isScalar = false;
- }
- innerConverter = type.getValueConverter();
- if (ToscaPropertyType.STRING.equals(type) && value.startsWith("/")) {
- return innerConverter.convertToToscaValue(value, innerType, dataTypes);
- }
}
- JsonElement jsonElement = null;
try {
+ ToscaMapValueConverter mapConverterInst = ToscaMapValueConverter.getInstance();
+ ToscaValueConverter innerConverter = null;
+ Boolean isScalar = true;
+
+ ToscaPropertyType type = ToscaPropertyType.isValidType(propertyType);
+ if (type == null) {
+ log.trace("isn't prederfined type, get from all data types");
+ DataTypeDefinition dataTypeDefinition = dataTypes.get(propertyType);
+ if (innerType == null) {
+ innerType = propertyType;
+ }
+
+ if ((type = mapConverterInst.isScalarType(dataTypeDefinition)) != null) {
+ log.trace("This is scalar type. get suitable converter for type {}", type);
+ innerConverter = type.getValueConverter();
+ } else {
+ isScalar = false;
+ }
+ } else {
+ ToscaPropertyType typeIfScalar = ToscaPropertyType.getTypeIfScalar(type.getType());
+ if (typeIfScalar == null) {
+ isScalar = false;
+ }
+
+ innerConverter = type.getValueConverter();
+ if (ToscaPropertyType.STRING.equals(type) && value.startsWith("/")) {
+ return innerConverter.convertToToscaValue(value, innerType, dataTypes);
+ }
+ }
+ JsonElement jsonElement = null;
+
StringReader reader = new StringReader(value);
JsonReader jsonReader = new JsonReader(reader);
jsonReader.setLenient(true);
@@ -162,11 +163,11 @@ public class PropertyConvertor {
}
if (jsonElement.isJsonPrimitive() && isScalar) {
- log.debug("It's well defined type. convert it");
+ log.trace("It's well defined type. convert it");
ToscaValueConverter converter = type.getValueConverter();
return converter.convertToToscaValue(value, innerType, dataTypes);
} else {
- log.debug("It's data type or inputs in primitive type. convert as map");
+ log.trace("It's data type or inputs in primitive type. convert as map");
Object convertedValue;
if (innerConverter != null && (ToscaPropertyType.MAP.equals(type) || ToscaPropertyType.LIST.equals(type))) {
convertedValue = innerConverter.convertToToscaValue(value, innerType, dataTypes);
@@ -185,7 +186,7 @@ public class PropertyConvertor {
return convertedValue;
}
- } catch (JsonSyntaxException e) {
+ } catch (Exception e) {
log.debug("convertToToscaValue failed to parse json value :", e);
return null;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index d6f87967ca..9fdd2d3b0f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -333,10 +333,13 @@ public class ToscaExportHandler {
toscaMetadata.setSubcategory(categoryDefinition.getSubcategories().get(0).getName());
toscaMetadata.setResourceVendor(resource.getVendorName());
toscaMetadata.setResourceVendorRelease(resource.getVendorRelease());
-
+ toscaMetadata.setResourceVendorModelNumber(resource.getResourceVendorModelNumber());
break;
case SERVICE:
+ Service service = (Service) component;
toscaMetadata.setType(component.getComponentType().getValue());
+ toscaMetadata.setServiceType(service.getServiceType());
+ toscaMetadata.setServiceRole(service.getServiceRole());
if (!isInstance) {
// DE268546
toscaMetadata.setServiceEcompNaming(((Service)component).isEcompGeneratedNaming());
@@ -747,8 +750,9 @@ public class ToscaExportHandler {
toscaMetadata = new VfModuleToscaMetadata();
Map<String, Object> properties = fillGroupProperties(props.get());
-
- properties.put(VF_MODULE_DESC_KEY, description.get());
+ if(!properties.containsKey(VF_MODULE_DESC_KEY) || StringUtils.isEmpty((String) properties.get(VF_MODULE_DESC_KEY))){
+ properties.put(VF_MODULE_DESC_KEY, description.get());
+ }
toscaGroup.setProperties(properties);
}
toscaMetadata.setName(groupName.get());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java
index 6573313dbb..604a52083b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java
@@ -32,6 +32,9 @@ public class ToscaMetadata implements IToscaMetadata {
private String subcategory;
private String resourceVendor;
private String resourceVendorRelease;
+ private String resourceVendorModelNumber;
+ private String serviceType;
+ private String serviceRole;
private Boolean serviceEcompNaming;
private Boolean ecompGeneratedNaming;
private String namingPolicy;
@@ -110,6 +113,30 @@ public class ToscaMetadata implements IToscaMetadata {
public void setResourceVendorRelease(String resourceVendorRelease) {
this.resourceVendorRelease = resourceVendorRelease;
}
+
+ public String getResourceVendorModelNumber() {
+ return resourceVendorModelNumber;
+ }
+
+ public void setResourceVendorModelNumber(String resourceVendorModelNumber) {
+ this.resourceVendorModelNumber = resourceVendorModelNumber;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public String getServiceRole() {
+ return serviceRole;
+ }
+
+ public void setServiceRole(String serviceRole) {
+ this.serviceRole = serviceRole;
+ }
public Boolean isEcompGeneratedNaming() {
return ecompGeneratedNaming;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/common/transaction/mngr/RollbackManager.java b/catalog-be/src/main/java/org/openecomp/sdc/common/transaction/mngr/RollbackManager.java
index 99e0da0116..7485a8dc43 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/common/transaction/mngr/RollbackManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/common/transaction/mngr/RollbackManager.java
@@ -20,20 +20,20 @@
package org.openecomp.sdc.common.transaction.mngr;
-import org.openecomp.sdc.common.transaction.api.RollbackHandler;
-import org.openecomp.sdc.common.transaction.api.TransactionUtils.DBActionCodeEnum;
-import org.openecomp.sdc.common.transaction.api.TransactionUtils.DBTypeEnum;
-import org.openecomp.sdc.common.util.MethodActivationStatusEnum;
-
import fj.P;
import fj.data.Either;
import fj.data.HashMap;
import fj.data.List;
+import org.openecomp.sdc.common.transaction.api.RollbackHandler;
+import org.openecomp.sdc.common.transaction.api.TransactionUtils.DBActionCodeEnum;
+import org.openecomp.sdc.common.transaction.api.TransactionUtils.DBTypeEnum;
+import org.openecomp.sdc.common.util.MethodActivationStatusEnum;
+
public class RollbackManager {
private final HashMap<DBTypeEnum, RollbackHandler> rollbackHandlersMap;
private final Integer transactionId;
- private final String userId;
+ private final String userId;
private final String actionType;
RollbackManager(Integer transactionId, String userId, String actionType, Iterable<RollbackHandler> rollbackHandlers) {
@@ -83,5 +83,4 @@ public class RollbackManager {
// by convention left is failure; in SDC right is failure
return rollbackHandlersMap.get(dbType).toEither(MethodActivationStatusEnum.NOT_FOUND).swap();
}
-
}
diff --git a/catalog-be/src/main/resources/config/SDC.zip b/catalog-be/src/main/resources/config/SDC.zip
index 674f6f86b4..6df1b13f2b 100644
--- a/catalog-be/src/main/resources/config/SDC.zip
+++ b/catalog-be/src/main/resources/config/SDC.zip
Binary files differ
diff --git a/catalog-be/src/main/resources/config/configuration.yaml b/catalog-be/src/main/resources/config/configuration.yaml
index c9ebfd2e9f..bbb1969255 100644
--- a/catalog-be/src/main/resources/config/configuration.yaml
+++ b/catalog-be/src/main/resources/config/configuration.yaml
@@ -23,7 +23,7 @@ beSslPort: 8443
version: 1.0
released: 2012-11-30
-toscaConformanceLevel: 3.0
+toscaConformanceLevel: 4.0
minToscaConformanceLevel: 3.0
titanCfgFile: /home/vagrant/catalog-be/config/catalog-be/titan.properties
@@ -41,7 +41,6 @@ esReconnectIntervalInSeconds: 3
uebHealthCheckReconnectIntervalInSeconds: 15
uebHealthCheckReadTimeout: 4
-
# Protocols
protocols:
- http
@@ -75,7 +74,7 @@ neo4j:
cassandraConfig:
cassandraHosts: ['localhost']
- localDataCenter:
+ localDataCenter: datacenter1
reconnectTimeout : 30000
authenticate: false
username: koko
@@ -87,6 +86,7 @@ cassandraConfig:
- { name: sdcaudit, replicationStrategy: SimpleStrategy, replicationInfo: ['1']}
- { name: sdcartifact, replicationStrategy: SimpleStrategy, replicationInfo: ['1']}
- { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']}
+ - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']}
#Application-specific settings of ES
elasticSearch:
@@ -147,6 +147,7 @@ resourceTypes: &allResourceTypes
- VF
- VFCMT
- Abstract
+ - CVFC
# validForResourceTypes usage
# validForResourceTypes:
@@ -195,6 +196,8 @@ toscaArtifacts:
#Informational artifacts placeHolder
excludeResourceCategory:
- Generic
+excludeResourceType:
+ - PNF
informationalResourceArtifacts:
features:
displayName: Features
@@ -500,7 +503,15 @@ resourceInformationalArtifacts:
validForResourceTypes: *allResourceTypes
OTHER:
acceptedTypes:
- validForResourceTypes: *allResourceTypes
+ validForResourceTypes:
+ - VFC
+ - CVFC
+ - CP
+ - VL
+ - VF
+ - VFCMT
+ - Abstract
+ - PNF
SNMP_POLL:
acceptedTypes:
validForResourceTypes: *allResourceTypes
@@ -512,6 +523,7 @@ resourceInformationalArtifacts:
validForResourceTypes:
- VF
- VFC
+ - CVFC
resourceInformationalDeployedArtifacts:
@@ -538,6 +550,7 @@ onboarding:
host: localhost
port: 8080
downloadCsarUri: "/onboarding-api/v1.0/vendor-software-products/packages"
+ healthCheckUri: "/onboarding-api/v1.0/healthcheck"
switchoverDetector:
gBeFqdn: AIO-BE.ecomp.idns.cip.com
@@ -597,5 +610,7 @@ vfModuleProperties:
genericAssetNodeTypes:
VFC: org.openecomp.resource.abstract.nodes.VFC
+ CVFC: org.openecomp.resource.abstract.nodes.VFC
VF : org.openecomp.resource.abstract.nodes.VF
+ PNF: org.openecomp.resource.abstract.nodes.PNF
Service: org.openecomp.resource.abstract.nodes.service
diff --git a/catalog-be/src/main/resources/config/error-configuration.yaml b/catalog-be/src/main/resources/config/error-configuration.yaml
index 4985ab552a..62bd7206ba 100644
--- a/catalog-be/src/main/resources/config/error-configuration.yaml
+++ b/catalog-be/src/main/resources/config/error-configuration.yaml
@@ -12,103 +12,103 @@ errors:
code: 204,
message: "No Content"
}
-#--------POL4050-----------------------------
+#--------POL4050-----------------------------
NOT_ALLOWED: {
code: 405,
message: "Error: Method not allowed.",
messageId: "POL4050"
}
-#--------POL5000-----------------------------
+#--------POL5000-----------------------------
GENERAL_ERROR: {
code: 500,
message: "Error: Internal Server Error. Please try again later.",
messageId: "POL5000"
}
-#---------POL5001------------------------------
+#---------POL5001------------------------------
MISSING_X_ECOMP_INSTANCE_ID: {
code: 400 ,
message: "Error: Missing 'X-ECOMP-InstanceID' HTTP header.",
messageId: "POL5001"
}
-#---------POL5002------------------------------
+#---------POL5002------------------------------
AUTH_REQUIRED: {
code: 401 ,
message: "Error: Authentication is required to use the API.",
messageId: "POL5002"
}
-#---------POL5003------------------------------
+#---------POL5003------------------------------
AUTH_FAILED: {
code: 403 ,
message: "Error: Not authorized to use the API.",
messageId: "POL5003"
}
-#---------POL5004------------------------------
+#---------POL5004------------------------------
MISSING_USER_ID: {
code: 400 ,
message: "Error: Missing 'USER_ID' HTTP header.",
messageId: "POL5004"
}
-#---------SVC4000-----------------------------
+#---------SVC4000-----------------------------
INVALID_CONTENT: {
code: 400,
message: "Error: Invalid content.",
messageId: "SVC4000"
}
-#---------SVC4002-----------------------------
+#---------SVC4002-----------------------------
MISSING_INFORMATION: {
code: 403,
message: "Error: Missing information.",
messageId: "SVC4002"
}
-#---------SVC4003------------------------------
-# %1 - Users's ID
+#---------SVC4003------------------------------
+# %1 - Users's ID
USER_NOT_FOUND: {
code: 404,
message: "Error: User '%1' was not found.",
messageId: "SVC4003"
}
-#---------SVC4004-----------------------------
-# %1 - Users's email address
+#---------SVC4004-----------------------------
+# %1 - Users's email address
INVALID_EMAIL_ADDRESS: {
code: 400,
message: "Error: Invalid email address '%1'.",
messageId: "SVC4004"
}
-#---------SVC4005------------------------------
+#---------SVC4005------------------------------
# %1 - role
INVALID_ROLE: {
code: 400,
message: "Error: Invalid role '%1'.",
messageId: "SVC4005"
}
-#---------SVC4006------------------------------
-# %1 - Users's USER_ID
+#---------SVC4006------------------------------
+# %1 - Users's USER_ID
USER_ALREADY_EXIST: {
code: 409,
message: "Error: User with '%1' ID already exists.",
messageId: "SVC4006"
}
-#---------SVC4007------------------------------
+#---------SVC4007------------------------------
DELETE_USER_ADMIN_CONFLICT: {
code: 409,
message: "Error: An administrator can only be deleted by another administrator.",
messageId: "SVC4007"
}
-#---------SVC4008-----------------------------
-# %1 - Users's userId
+#---------SVC4008-----------------------------
+# %1 - Users's userId
INVALID_USER_ID: {
code: 400,
message: "Error: Invalid userId '%1'.",
messageId: "SVC4008"
}
-#---------SVC4049------------------------------
+#---------SVC4049------------------------------
# %1 - service/resource
COMPONENT_MISSING_CONTACT: {
code: 400,
message: "Error: Invalid Content. Missing %1 contact.",
messageId: "SVC4049"
- }
-#---------SVC4050-----------------------------
+ }
+#---------SVC4050-----------------------------
# %1 - Service/Resource/Additional parameter
# %2 - service/resource/label name
COMPONENT_NAME_ALREADY_EXIST: {
@@ -116,90 +116,90 @@ errors:
message: "Error: %1 with name '%2' already exists.",
messageId: "SVC4050"
}
-#---------SVC4051------------------------------
-# %1 - resource/service
+#---------SVC4051------------------------------
+# %1 - resource/service
COMPONENT_MISSING_CATEGORY: {
code: 400,
message: "Error: Invalid Content. Missing %1 category.",
messageId: "SVC4051"
}
-#---------SVC4052------------------------------
+#---------SVC4052------------------------------
COMPONENT_MISSING_TAGS: {
code: 400,
message: "Error: Invalid Content. At least one tag has to be specified.",
messageId: "SVC4052"
}
-#---------SVC4053------------------------------
+#---------SVC4053------------------------------
# %1 - service/resource
COMPONENT_MISSING_DESCRIPTION: {
code: 400,
message: "Error: Invalid Content. Missing %1 description.",
messageId: "SVC4053"
}
-#---------SVC4054------------------------------
+#---------SVC4054------------------------------
# %1 - resource/service
COMPONENT_INVALID_CATEGORY: {
code: 400,
message: "Error: Invalid Content. Invalid %1 category.",
messageId: "SVC4054"
}
-#---------SVC4055------------------------------
+#---------SVC4055------------------------------
MISSING_VENDOR_NAME: {
code: 400,
message: "Error: Invalid Content. Missing vendor name.",
messageId: "SVC4055"
}
-#---------SVC4056------------------------------
+#---------SVC4056------------------------------
MISSING_VENDOR_RELEASE: {
code: 400,
message: "Error: Invalid Content. Missing vendor release.",
messageId: "SVC4056"
}
-#---------SVC4057------------------------------
+#---------SVC4057------------------------------
MISSING_DERIVED_FROM_TEMPLATE: {
code: 400,
message: "Error: Invalid Content. Missing derived from template specification.",
messageId: "SVC4057"
}
-#---------SVC4058------------------------------
+#---------SVC4058------------------------------
# %1 - service/resource
COMPONENT_MISSING_ICON: {
code: 400,
message: "Error: Invalid Content. Missing %1 icon.",
messageId: "SVC4058"
}
-#---------SVC4059------------------------------
+#---------SVC4059------------------------------
# %1 - service/resource
COMPONENT_INVALID_ICON: {
code: 400,
message: "Error: Invalid Content. Invalid %1 icon.",
messageId: "SVC4059"
}
-#---------SVC4060------------------------------
+#---------SVC4060------------------------------
PARENT_RESOURCE_NOT_FOUND: {
code: 400,
message: "Error: Invalid Content. Derived from resource template was not found.",
messageId: "SVC4060"
}
-#---------SVC4061------------------------------
+#---------SVC4061------------------------------
MULTIPLE_PARENT_RESOURCE_FOUND: {
code: 400,
message: "Error: Invalid Content. Multiple derived from resource template is not allowed.",
messageId: "SVC4061"
}
-#---------SVC4062------------------------------
+#---------SVC4062------------------------------
# %1 - service/resource
MISSING_COMPONENT_NAME: {
code: 400,
message: "Error: Invalid Content. Missing %1 name.",
messageId: "SVC4062"
}
-#---------SVC4063------------------------------
+#---------SVC4063------------------------------
#%1  -  resource/service name
RESOURCE_NOT_FOUND: {
code: 404,
@@ -207,51 +207,51 @@ errors:
messageId: "SVC4063"
}
-#---------SVC4064------------------------------
+#---------SVC4064------------------------------
# %1 - Service/Resource/Property
COMPONENT_INVALID_DESCRIPTION: {
code: 400,
message: "Error: Invalid Content. %1 description contains non-english characters.",
messageId: "SVC4064"
}
-#---------SVC4065------------------------------
+#---------SVC4065------------------------------
# %1 - Service/Resource/Property
-# %2 - max resource/service name length
+# %2 - max resource/service name length
COMPONENT_DESCRIPTION_EXCEEDS_LIMIT: {
code: 400,
message: "Error: Invalid Content. %1 description exceeds limit of %2 characters.",
messageId: "SVC4065"
}
-#---------SVC4066------------------------------
-# %1 - max length
+#---------SVC4066------------------------------
+# %1 - max length
COMPONENT_TAGS_EXCEED_LIMIT: {
code: 400,
message: "Error: Invalid Content. Tags overall length exceeds limit of %1 characters.",
messageId: "SVC4066"
}
#---------SVC4067------------------------------
-# %1 - max length
+# %1 - max length
VENDOR_NAME_EXCEEDS_LIMIT: {
code: 400,
message: "Error: Invalid Content. Vendor name exceeds limit of %1 characters.",
messageId: "SVC4067"
}
#---------SVC4068------------------------------
-# %1 - max length
+# %1 - max length
VENDOR_RELEASE_EXCEEDS_LIMIT: {
code: 400,
message: "Error: Invalid Content. Vendor release exceeds limit of %1 characters.",
messageId: "SVC4068"
}
-#---------SVC4069------------------------------
+#---------SVC4069------------------------------
# %1 - Service/Resource/Product
COMPONENT_INVALID_CONTACT: {
code: 400,
message: "Error: Invalid Content. %1 Contact Id should be in format 'mnnnnnn' or 'aannna' or 'aannnn', where m=m ,a=a-zA-Z and n=0-9",
messageId: "SVC4069"
}
-#---------SVC4070------------------------------
+#---------SVC4070------------------------------
# %1 - Service/Resource
INVALID_COMPONENT_NAME: {
code: 400,
@@ -259,27 +259,27 @@ errors:
messageId: "SVC4070"
}
-#---------SVC4071------------------------------
+#---------SVC4071------------------------------
INVALID_VENDOR_NAME: {
code: 400,
message: 'Error: Invalid Content. Vendor name is not allowed to contain characters like <>:"\/|?* and space characters other than regular space.',
messageId: "SVC4071"
}
-#---------SVC4072------------------------------
+#---------SVC4072------------------------------
INVALID_VENDOR_RELEASE: {
code: 400,
message: 'Error: Invalid Content. Vendor release is not allowed to contain characters like <>:"\/|?* and space characters other than regular space.',
messageId: "SVC4072"
}
-#---------SVC4073------------------------------
+#---------SVC4073------------------------------
# %1 - Service/Resource
-# %2 - max resource/service name
+# %2 - max resource/service name
COMPONENT_NAME_EXCEEDS_LIMIT: {
code: 400,
message: "Error: Invalid Content. %1 name exceeds limit of %2 characters.",
messageId: "SVC4073"
}
-#---------SVC4080------------------------------
+#---------SVC4080------------------------------
# %1 - resource/service name
# %2 - resource/service
# %3 - First name of last modifier
@@ -290,7 +290,7 @@ errors:
message: "Error: Requested '%1' %2 is locked for modification by %3 %4(%5).",
messageId: "SVC4080"
}
-#---------SVC4081-----------------------------
+#---------SVC4081-----------------------------
# %1 - resource/service name
# %2 - resource/service
# %3 - First name of last modifier
@@ -302,7 +302,7 @@ errors:
messageId: "SVC4081"
}
-#-----------SVC4082---------------------------
+#-----------SVC4082---------------------------
# %1 - resource/service name
# %2 - resource/service
# %3 - First name of last modifier
@@ -392,7 +392,7 @@ errors:
}
#-----------SVC4102---------------------------
-# %1 - capability type name
+# %1 - capability type name
CAPABILITY_TYPE_ALREADY_EXIST: {
code: 409,
message: "Error: Capability Type with name '%1' already exists.",
@@ -405,7 +405,7 @@ errors:
messageId: "SVC4114"
}
#-----------SVC4115---------------------------
-# %1 - capability type name
+# %1 - capability type name
MISSING_CAPABILITY_TYPE: {
code: 400,
message: "Error: Invalid Content. Missing Capability Type '%1'.",
@@ -483,7 +483,7 @@ errors:
message: "Error: Artifact '%1' already exists.",
messageId: "SVC4125"
}
-#---------SVC4126------------------------------
+#---------SVC4126------------------------------
# %1 - resource/service/product/...
# %2 - field (tag, vendor name...)
INVALID_FIELD_FORMAT: {
@@ -518,7 +518,7 @@ errors:
#-----------SVC4131---------------------------
# %1-resource/service
# %2-srtifact/artifacts
-# %3-semicolomn separated list of artifact
+# %3-semicolomn separated list of artifact
COMPONENT_MISSING_MANDATORY_ARTIFACTS: {
code: 403,
message: "Error: Missing mandatory informational %1 %2: [%3].",
@@ -545,60 +545,60 @@ errors:
message: "Error: Invalid Content. Missing interface life-cycle type.",
messageId: "SVC4134"
}
-#---------SVC4135------------------------------
+#---------SVC4135------------------------------
SERVICE_CATEGORY_CANNOT_BE_CHANGED: {
code: 400,
message: "Error: Service category cannot be changed once the service is certified.",
messageId: "SVC4135"
}
-#---------SVC4136------------------------------
-# %1 - distribution environment name
+#---------SVC4136------------------------------
+# %1 - distribution environment name
DISTRIBUTION_ENVIRONMENT_NOT_AVAILABLE: {
code: 500,
message: "Error: Requested distribution environment '%1' is not available.",
messageId: "SVC4136"
}
-#---------SVC4137------------------------------
-# %1 - distribution environment name
+#---------SVC4137------------------------------
+# %1 - distribution environment name
DISTRIBUTION_ENVIRONMENT_NOT_FOUND: {
code: 400,
message: "Error: Requested distribution environment '%1' was not found.",
messageId: "SVC4137"
}
-#---------SVC4138------------------------------
+#---------SVC4138------------------------------
DISTRIBUTION_ENVIRONMENT_INVALID: {
code: 400,
message: "Error: Invalid distribution environment.",
messageId: "SVC4138"
}
-#---------SVC4139------------------------------
+#---------SVC4139------------------------------
# %1 - service name
DISTRIBUTION_ARTIFACT_NOT_FOUND: {
code: 409,
message: "Error: Service '%1' cannot be distributed due to missing deployment artifacts.",
messageId: "SVC4139"
}
-#---------SVC4200------------------------------
+#---------SVC4200------------------------------
# %1 - Service/Resource
-# %2 - max icon name length
+# %2 - max icon name length
COMPONENT_ICON_EXCEEDS_LIMIT: {
code: 400,
message: "Error: Invalid Content. %1 icon name exceeds limit of %2 characters.",
messageId: "SVC4200"
}
-#---------SVC4300------------------------------
+#---------SVC4300------------------------------
RESTRICTED_ACCESS: {
code: 403,
message: "Error: Restricted access.",
messageId: "SVC4300"
}
-#---------SVC4301------------------------------
+#---------SVC4301------------------------------
RESTRICTED_OPERATION: {
code: 409,
message: "Error: Restricted operation.",
messageId: "SVC4301"
}
-#---------SVC4500------------------------------
+#---------SVC4500------------------------------
MISSING_BODY: {
code: 400 ,
message: "Error: Missing request body.",
@@ -610,7 +610,7 @@ errors:
message: "Error: Invalid Content. Missing mandatory parameter 'apiPublicKey'." ,
messageId: "SVC4501"
}
-#---------SVC4502------------------------------
+#---------SVC4502------------------------------
DISTRIBUTION_ENV_DOES_NOT_EXIST: {
code: 400 ,
message: "Error: Invalid Body : Missing mandatory parameter 'distrEnvName'." ,
@@ -624,7 +624,7 @@ errors:
messageId: "SVC4503"
}
-#---------SVC4504------------------------------
+#---------SVC4504------------------------------
# %1 - Service/Resource
# %2 - service/resource version
COMPONENT_VERSION_NOT_FOUND: {
@@ -634,103 +634,103 @@ errors:
}
#-----------SVC4505---------------------------
#%1-artifact name
-
+
ARTIFACT_NOT_FOUND: {
code: 404,
message: "Error: Artifact '%1' was not found.",
messageId: "SVC4505"
}
-#---------SVC4506------------------------------
+#---------SVC4506------------------------------
MISSING_ENV_NAME: {
code: 400 ,
message: "Error: Invalid Content. Missing mandatory parameter 'distrEnvName'.",
messageId: "SVC4506"
}
-#---------SVC4507------------------------------
+#---------SVC4507------------------------------
COMPONENT_INVALID_TAGS_NO_COMP_NAME: {
code: 400,
message: "Error: Invalid Content. One of the tags should be the component name.",
messageId: "SVC4507"
}
-
-#---------SVC4508------------------------------
+
+#---------SVC4508------------------------------
SERVICE_NAME_CANNOT_BE_CHANGED: {
code: 400,
message: "Error: Service name cannot be changed once the service is certified.",
messageId: "SVC4508"
}
-#---------SVC4509------------------------------
+#---------SVC4509------------------------------
SERVICE_ICON_CANNOT_BE_CHANGED: {
code: 400,
message: "Error: Icon cannot be changed once the service is certified.",
messageId: "SVC4509"
}
-#---------SVC4510------------------------------
+#---------SVC4510------------------------------
# %1 - icon name max length
SERVICE_ICON_EXCEEDS_LIMIT: {
code: 400,
message: "Error: Invalid Content. Icon name exceeds limit of %1 characters.",
messageId: "SVC4510"
}
-#---------SVC4511------------------------------
+#---------SVC4511------------------------------
DISTRIBUTION_REQUESTED_NOT_FOUND: {
code: 404,
message: "Error: Requested distribution was not found.",
messageId: "SVC4511"
}
-#---------SVC4512------------------------------
+#---------SVC4512------------------------------
# %1 - Distribution ID
DISTRIBUTION_REQUESTED_FAILED: {
code: 403,
message: "Error: Requested distribution '%1' failed.",
messageId: "SVC4512"
}
-#---------SVC4513------------------------------
+#---------SVC4513------------------------------
RESOURCE_CATEGORY_CANNOT_BE_CHANGED: {
code: 400,
message: "Error: Resource category cannot be changed once the resource is certified.",
messageId: "SVC4513"
}
-#---------SVC4514------------------------------
+#---------SVC4514------------------------------
RESOURCE_NAME_CANNOT_BE_CHANGED: {
code: 400,
message: "Error: Resource name cannot be changed once the resource is certified.",
messageId: "SVC4514"
}
-#---------SVC4515------------------------------
+#---------SVC4515------------------------------
RESOURCE_ICON_CANNOT_BE_CHANGED: {
code: 400,
message: "Error: Icon cannot be changed once the resource is certified.",
messageId: "SVC4515"
}
-#---------SVC4516------------------------------
+#---------SVC4516------------------------------
RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED: {
code: 400,
message: "Error: Vendor name cannot be changed once the resource is certified.",
messageId: "SVC4516"
}
-#---------SVC4517------------------------------
+#---------SVC4517------------------------------
RESOURCE_DERIVED_FROM_CANNOT_BE_CHANGED: {
code: 400,
message: "Error: Derived from resource template cannot be changed once the resource is certified.",
messageId: "SVC4517"
}
-#---------SVC4518------------------------------
-# %1 - max length
+#---------SVC4518------------------------------
+# %1 - max length
COMPONENT_SINGLE_TAG_EXCEED_LIMIT: {
code: 400,
message: "Error: Invalid Content. Single tag exceeds limit of %1 characters.",
messageId: "SVC4518"
}
-#---------SVC4519------------------------------
+#---------SVC4519------------------------------
INVALID_DEFAULT_VALUE: {
code: 400,
message: "Error: mismatch in data-type occurred for property %1. data type is %2 and default value found is %3.",
messageId: "SVC4519"
}
-#---------SVC4520------------------------------
-# %1 - service or resource
+#---------SVC4520------------------------------
+# %1 - service or resource
ADDITIONAL_INFORMATION_MAX_NUMBER_REACHED: {
code: 409,
message: "Error: Maximal number of additional %1 parameters was reached.",
@@ -742,7 +742,7 @@ errors:
message: "Error: Invalid Content. The Additional information label and value cannot be empty.",
messageId: "SVC4521"
}
-#---------SVC4522------------------------------
+#---------SVC4522------------------------------
# %1 - label/value
# %2 - Maximal length of %1
ADDITIONAL_INFORMATION_EXCEEDS_LIMIT: {
@@ -762,32 +762,32 @@ errors:
message: "Error: Requested additional information was not found.",
messageId: "SVC4524"
}
-#---------SVC4525------------------------------
+#---------SVC4525------------------------------
ADDITIONAL_INFORMATION_VALUE_NOT_ALLOWED_CHARACTERS: {
code: 400,
message: 'Error: Invalid Content. Additional information contains non-english characters.',
messageId: "SVC4525"
}
-#---------SVC4526------------------------------
+#---------SVC4526------------------------------
RESOURCE_INSTANCE_NOT_FOUND: {
code: 404,
message: "Error: Requested '%1' resource instance was not found.",
messageId: "SVC4526"
}
-#---------SVC4527------------------------------
+#---------SVC4527------------------------------
ASDC_VERSION_NOT_FOUND: {
code: 500,
message: 'Error: ASDC version cannot be displayed.',
messageId: "SVC4527"
}
-#---------SVC4528------------------------------
+#---------SVC4528------------------------------
# %1-artifact url/artifact label/artifact description/VNF Service Indicator
MISSING_DATA: {
code: 400,
message: "Error: Invalid content. Missing %1.",
messageId: "SVC4528"
}
-#---------SVC4529------------------------------
+#---------SVC4529------------------------------
# %1-artifact url/artifact label/artifact description/artifact name
# %2 - Maximal length of %1
EXCEEDS_LIMIT: {
@@ -795,51 +795,51 @@ errors:
message: "Error: Invalid Content. %1 exceeds limit of %2 characters.",
messageId: "SVC4529"
}
-#---------SVC4530------------------------------
+#---------SVC4530------------------------------
ARTIFACT_INVALID_TIMEOUT: {
code: 400,
message: "Error: Invalid Content. Artifact Timeout should be set to valid positive non-zero number of minutes.",
messageId: "SVC4530"
}
-#---------SVC4531------------------------------
+#---------SVC4531------------------------------
SERVICE_IS_VNF_CANNOT_BE_CHANGED: {
code: 400,
message: "Error: VNF Indicator cannot be updated for certified service.",
messageId: "SVC4531"
}
- #---------SVC4532------------------------------
+ #---------SVC4532------------------------------
RESOURCE_INSTANCE_NOT_FOUND_ON_SERVICE: {
code: 404,
message: "Error: Requested '%1' resource instance was not found on the service '%2.",
messageId: "SVC4532"
}
- #---------SVC4533------------------------------
- # %1 - "HEAT"/"HEAT_ENV"/"MURANO_PKG"/"YANG_XML"
+ #---------SVC4533------------------------------
+ # %1 - "HEAT"/"HEAT_ENV"/"MURANO_PKG"/"YANG_XML"
WRONG_ARTIFACT_FILE_EXTENSION: {
code: 400,
message: "Error: Invalid file extension for %1 artifact type.",
messageId: "SVC4533"
}
-#---------SVC4534------------------------------
-# %1 - "HEAT"/"HEAT_ENV"
+#---------SVC4534------------------------------
+# %1 - "HEAT"/"HEAT_ENV"
INVALID_YAML: {
code: 400,
message: "Error: Uploaded YAML file for %1 artifact is invalid.",
messageId: "SVC4534"
}
-#---------SVC4535------------------------------
-# %1 - "HEAT"
+#---------SVC4535------------------------------
+# %1 - "HEAT"
INVALID_DEPLOYMENT_ARTIFACT_HEAT: {
code: 400,
message: "Error: Invalid %1 artifact.",
messageId: "SVC4535"
}
-#---------SVC4536------------------------------
+#---------SVC4536------------------------------
# %1 - "Resource"/"Service"
-# %2 - resource/service name
-# %3 - "HEAT"/"HEAT_ENV"/"MURANO_PKG"
+# %2 - resource/service name
+# %3 - "HEAT"/"HEAT_ENV"/"MURANO_PKG"
# %4 - "HEAT"/"HEAT_ENV"/"MURANO_PKG
DEPLOYMENT_ARTIFACT_OF_TYPE_ALREADY_EXISTS: {
code: 400,
@@ -847,80 +847,80 @@ errors:
messageId: "SVC4536"
}
-#---------SVC4537------------------------------
+#---------SVC4537------------------------------
MISSING_HEAT: {
code: 400,
message: "Error: Missing HEAT artifact. HEAT_ENV artifact cannot be uploaded without corresponding HEAT template.",
messageId: "SVC4537"
}
-#---------SVC4538------------------------------
+#---------SVC4538------------------------------
MISMATCH_HEAT_VS_HEAT_ENV: {
code: 400,
message: "Error: Invalid artifact content. Parameter's set in HEAT_ENV '%1' artifact doesn't match the parameters in HEAT '%2' artifact.",
messageId: "SVC4538"
}
-#---------SVC4539------------------------------
+#---------SVC4539------------------------------
INVALID_RESOURCE_PAYLOAD: {
code: 400,
message: "Error: Invalid resource payload.",
messageId: "SVC4539"
}
-#---------SVC4540------------------------------
+#---------SVC4540------------------------------
INVALID_TOSCA_FILE_EXTENSION: {
code: 400,
message: "Error: Invalid file extension for TOSCA template.",
messageId: "SVC4540"
}
-#---------SVC4541------------------------------
+#---------SVC4541------------------------------
INVALID_YAML_FILE: {
code: 400,
message: "Error: Invalid YAML file.",
messageId: "SVC4541"
}
-#---------SVC4542------------------------------
+#---------SVC4542------------------------------
INVALID_TOSCA_TEMPLATE: {
code: 400,
message: "Error: Invalid TOSCA template.",
messageId: "SVC4542"
}
-#---------SVC4543------------------------------
+#---------SVC4543------------------------------
NOT_RESOURCE_TOSCA_TEMPLATE: {
code: 400,
message: "Error: Imported Service TOSCA template.",
messageId: "SVC4543"
}
-#---------SVC4544------------------------------
+#---------SVC4544------------------------------
NOT_SINGLE_RESOURCE: {
code: 400,
message: "Error: Imported TOSCA template should contain one resource definition.",
messageId: "SVC4544"
}
-#---------SVC4545------------------------------
+#---------SVC4545------------------------------
INVALID_RESOURCE_NAMESPACE: {
code: 400,
message: "Error: Invalid resource namespace.",
messageId: "SVC4545"
}
-#---------SVC4546------------------------------
+#---------SVC4546------------------------------
RESOURCE_ALREADY_EXISTS: {
code: 400,
message: "Error: Imported resource already exists in ASDC Catalog.",
messageId: "SVC4546"
}
-#---------SVC4549------------------------------
+#---------SVC4549------------------------------
INVALID_RESOURCE_CHECKSUM: {
code: 400,
message: "Error: Invalid resource checksum.",
messageId: "SVC4549"
}
-#---------SVC4550------------------------------
+#---------SVC4550------------------------------
#%1  -  Consumer salt
INVALID_LENGTH: {
code: 400,
message: "Error: Invalid %1 length.",
messageId: "SVC4550"
}
- #---------SVC4551------------------------------
+ #---------SVC4551------------------------------
#%1  -  ECOMP User name
ECOMP_USER_NOT_FOUND: {
code: 404,
@@ -934,13 +934,13 @@ errors:
messageId: "SVC4552"
}
#---------SVC4553-----------------------------
- #%1  -  Consumer name / Consumer password/ Consumer salt
+ #%1  -  Consumer name / Consumer password/ Consumer salt
INVALID_CONTENT_PARAM: {
code: 400,
message: "Error: %1 is invalid.",
messageId: "SVC4553"
}
- #---------SVC4554------------------------------
+ #---------SVC4554------------------------------
# %1 - "Resource"/"Service"
COMPONENT_ARTIFACT_NOT_FOUND: {
code: 404,
@@ -954,7 +954,7 @@ errors:
message: "Error: Requested '%1' service is not ready for certification. Service has to have at least one deployment artifact.",
messageId: "SVC4554"
}
-#---------SVC4555------------------------------
+#---------SVC4555------------------------------
#%1 - "Resource"/"Service"/"Product"
#%2 - "category"
COMPONENT_ELEMENT_INVALID_NAME_LENGTH: {
@@ -962,7 +962,7 @@ errors:
message: "Error: Invalid %1 %2 name length.",
messageId: "SVC4555"
}
-#---------SVC4556------------------------------
+#---------SVC4556------------------------------
#%1 - "Resource"/"Service"/"Product"
#%2 - "category"
COMPONENT_ELEMENT_INVALID_NAME_FORMAT: {
@@ -970,7 +970,7 @@ errors:
message: "Error: Invalid %1 %2 name format.",
messageId: "SVC4556"
}
-#---------SVC4557------------------------------
+#---------SVC4557------------------------------
#%1 - "Resource"/"Service"/"Product"
#%2 - "category name"
COMPONENT_CATEGORY_ALREADY_EXISTS: {
@@ -1001,7 +1001,7 @@ errors:
code: 403,
message: "Error: Submit for Testing is not permitted as your '%1' includes non-validated '%2' resource. Please use one of available validated resource versions.",
messageId: "SVC4560"
- }
+ }
#---------SVC4561------------------------------
# %1 - "resource"/"product"
# %2 - "category"
@@ -1029,108 +1029,108 @@ errors:
message: "Error: %1 grouping '%2' already exists under '%3' sub-category.",
messageId: "SVC4563"
}
-#---------SVC4564------------------------------
+#---------SVC4564------------------------------
# %1 - product name
PRODUCT_NOT_FOUND: {
code: 404,
message: "Error: Requested '%1' product was not found.",
messageId: "SVC4564"
}
-#---------SVC4565------------------------------
-# %1 - "HEAT"
-# %2 - parameter type ("string" , "boolean" , "number")
+#---------SVC4565------------------------------
+# %1 - "HEAT"
+# %2 - parameter type ("string" , "boolean" , "number")
# %3 - parameter name
INVALID_HEAT_PARAMETER_VALUE: {
code: 400,
message: "Error: Invalid %1 artifact. Invalid %2 value set for '%3' parameter.",
messageId: "SVC4565"
}
-#---------SVC4566------------------------------
-# %1 - "HEAT"
-# %2 - parameter type ("string" , "boolean" , "number")
+#---------SVC4566------------------------------
+# %1 - "HEAT"
+# %2 - parameter type ("string" , "boolean" , "number")
INVALID_HEAT_PARAMETER_TYPE: {
code: 400,
message: "Error: Invalid %1 artifact. Unsupported '%2' parameter type.",
messageId: "SVC4566"
}
-#---------SVC4567------------------------------
-# %1 - "YANG_XML"
+#---------SVC4567------------------------------
+# %1 - "YANG_XML"
INVALID_XML: {
code: 400,
message: "Error: Uploaded XML file for %1 artifact is invalid.",
messageId: "SVC4567"
}
-#---------SVC4567------------------------------
-# %1 - "User Name and UserId"
+#---------SVC4567------------------------------
+# %1 - "User Name and UserId"
# %2 -"checked-out"/"in-certification"
CANNOT_DELETE_USER_WITH_ACTIVE_ELEMENTS: {
code: 409,
message: "Error: User cannot be deleted. User '%1' has %2 projects.",
messageId: "SVC4567"
}
-#---------SVC4568------------------------------
-# %1 - "User Name and UserId"
+#---------SVC4568------------------------------
+# %1 - "User Name and UserId"
# %2 -"checked-out"/"in-certification"
CANNOT_UPDATE_USER_WITH_ACTIVE_ELEMENTS: {
code: 409,
message: "Error: Role cannot be changed. User '%1' has %2 projects.",
messageId: "SVC4568"
}
-#---------SVC4570------------------------------
+#---------SVC4570------------------------------
UPDATE_USER_ADMIN_CONFLICT: {
code: 409,
message: "Error: An administrator is not allowed to change his/her role.",
messageId: "SVC4570"
}
-#---------SVC4571------------------------------
+#---------SVC4571------------------------------
SERVICE_CANNOT_CONTAIN_SUBCATEGORY: {
code: 400,
message: "Error: Sub category cannot be defined for service",
messageId: "SVC4571"
}
-#---------SVC4572------------------------------
+#---------SVC4572------------------------------
# %1 - "Resource"/"Service"
COMPONENT_TOO_MUCH_CATEGORIES: {
code: 400,
message: "Error: %1 must have only 1 category",
messageId: "SVC4572"
}
-#---------SVC4574------------------------------
+#---------SVC4574------------------------------
RESOURCE_TOO_MUCH_SUBCATEGORIES: {
code: 400,
message: "Error: Resource must have only 1 sub category",
messageId: "SVC4574"
}
-#---------SVC4575------------------------------
+#---------SVC4575------------------------------
COMPONENT_MISSING_SUBCATEGORY: {
code: 400,
message: "Error: Missing sub category",
messageId: "SVC4575"
}
- #---------SVC4576------------------------------
+ #---------SVC4576------------------------------
# %1 - "component type"
UNSUPPORTED_ERROR: {
code: 400,
message: "Error : Requested component type %1 is unsupported.",
messageId: "SVC4576"
}
- #---------SVC4577------------------------------
+ #---------SVC4577------------------------------
# %1 - "resource type"
RESOURCE_CANNOT_CONTAIN_RESOURCE_INSTANCES: {
code: 409,
message: "Error : Resource of type %1 cannot contain resource instances.",
messageId: "SVC4577"
}
-#---------SVC4578------------------------------
+#---------SVC4578------------------------------
# %1 - "Resource"/"Service"
-# %2 - resource/service name
-# %3 - "artifact name"
+# %2 - resource/service name
+# %3 - "artifact name"
DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS: {
code: 400,
message: "Error: %1 '%2' already has a deployment artifact named '%3'.",
messageId: "SVC4578"
}
-#---------SVC4579------------------------------
+#---------SVC4579------------------------------
# %1 - "Category"/"Sub-Category"/"Group"
# %2 - category/sub-category/grouping name.
INVALID_GROUP_ASSOCIATION: {
@@ -1138,27 +1138,27 @@ errors:
message: "Error: Invalid group association. %1 '%2' was not found.",
messageId: "SVC4579"
}
-#---------SVC4580------------------------------
+#---------SVC4580------------------------------
EMPTY_PRODUCT_CONTACTS_LIST: {
code: 400,
message: "Error: Invalid content. At least one Product Contact has to be specified.",
messageId: "SVC4580"
}
-#---------SVC4581------------------------------
+#---------SVC4581------------------------------
# %1 - UserId
INVALID_PRODUCT_CONTACT: {
code: 400,
message: "Error: Invalid content. User '%1' cannot be set as Product Contact.",
messageId: "SVC4581"
}
-#---------SVC4582------------------------------
+#---------SVC4582------------------------------
# %1 - Product
# %2 - "abbreviated"/"full"
MISSING_ONE_OF_COMPONENT_NAMES: {
code: 400,
message: "Error: Invalid content. Missing %1 %2 name.",
messageId: "SVC4582"
- }
+ }
#---------SVC4583------------------------------
# %1 - "Icon"
# %2 - "resource"/"service"/"product"
@@ -1168,10 +1168,10 @@ errors:
messageId: "SVC4583"
}
#---------SVC4584------------------------------
-# %1 - service/VF name
+# %1 - service/VF name
# %2 - "service" /"VF"
# %3 - resource instance origin type
-# %4 - resource instance name
+# %4 - resource instance name
# %5 - requirement/capability
# %6 - requirement/capability name
# %7 - "fulfilled" (for req)/"consumed (for cap)"
@@ -1180,57 +1180,57 @@ errors:
message: "Error: Requested '%1' %2 is not ready for certification. %3 '%4' has to have %5 '%6' %7.",
messageId: "SVC4584"
}
-#---------SVC4585------------------------------
+#---------SVC4585------------------------------
INVALID_OCCURRENCES: {
code: 400,
message: "Error: Invalid occurrences format.",
messageId: "SVC4585"
}
-#---------SVC4586------------------------------
-#---------SVC4586------------------------------
+#---------SVC4586------------------------------
+#---------SVC4586------------------------------
INVALID_SERVICE_API_URL: {
code: 400,
message: 'Error: Invalid Service API URL. Please check whether your URL has a valid domain extension and does not contain the following characters - #?&@%+;,=$<>~^`\[]{}|"*!',
messageId: "SVC4586"
}
-#---------SVC4587------------------------------
-# %1 - Data type name
+#---------SVC4587------------------------------
+# %1 - Data type name
DATA_TYPE_ALREADY_EXIST: {
code: 409,
message: 'Error: Data type %1 already exists.',
messageId: "SVC4587"
}
-#---------SVC4588------------------------------
-# %1 - Data type name
+#---------SVC4588------------------------------
+# %1 - Data type name
DATA_TYPE_NOR_PROPERTIES_NEITHER_DERIVED_FROM: {
code: 400,
message: 'Error: Invalid Data type %1. Data type must have either a valid derived from declaration or at least one valid property',
messageId: "SVC4588"
}
-#---------SVC4589------------------------------
-# %1 - Data type name
+#---------SVC4589------------------------------
+# %1 - Data type name
DATA_TYPE_PROPERTIES_CANNOT_BE_EMPTY: {
code: 400,
message: "Error: Invalid Data type %1. 'properties' parameter cannot be empty if provided.",
messageId: "SVC4589"
}
-#---------SVC4590------------------------------
-# %1 - Property type name
+#---------SVC4590------------------------------
+# %1 - Property type name
# %2 - Property name
INVALID_PROPERTY_TYPE: {
code: 400,
message: "Error: Invalid Property type %1 in property %2.",
messageId: "SVC4590"
}
-#---------SVC4591------------------------------
+#---------SVC4591------------------------------
# %1 - Property inner type
-# %2 - Property name
+# %2 - Property name
INVALID_PROPERTY_INNER_TYPE: {
code: 400,
message: "Error: Invalid property inner type %1, in property %2",
messageId: "SVC4591"
}
-#---------SVC4592------------------------------
+#---------SVC4592------------------------------
# %1 - component instance name
# %2 - "resource instance"/"service instance"
COMPONENT_INSTANCE_NOT_FOUND: {
@@ -1238,11 +1238,11 @@ errors:
message: "Error: Requested '%1' %2 was not found.",
messageId: "SVC4592"
}
-#---------SVC4593------------------------------
+#---------SVC4593------------------------------
# %1 - component instance name
# %2 - "resource instance"/"service instance"
# %3 - "resource/"service"/"product"
-# %4 - container name
+# %4 - container name
COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER: {
code: 404,
message: "Error: Requested '%1' %2 was not found on the %3 '%4'.",
@@ -1259,20 +1259,20 @@ errors:
#---------SVC4595------------------------------
#%1 - requirement / capability
#%2 - requirement name
-#%3 - parent containing the requirement
+#%3 - parent containing the requirement
IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED: {
code: 400,
message: "Error: Imported TOSCA template contains %1 '%2' that is already defined by derived template %3.",
messageId: "SVC4595"
}
-#---------SVC4596------------------------------
+#---------SVC4596------------------------------
# %1 - Data type name
DATA_TYPE_DERIVED_IS_MISSING: {
code: 400,
message: "Error: Invalid Content. The ancestor data type %1 cannot be found in the system.",
messageId: "SVC4596"
}
-#---------SVC4597------------------------------
+#---------SVC4597------------------------------
# %1 - Data type name
# %2 - Property names
DATA_TYPE_PROPERTY_ALREADY_DEFINED_IN_ANCESTOR: {
@@ -1280,14 +1280,14 @@ errors:
message: "Error: Invalid Content. The data type %1 contains properties named %2 which are already defined in one of its ancestors.",
messageId: "SVC4597"
}
-#---------SVC4598------------------------------
+#---------SVC4598------------------------------
# %1 - Data type name
DATA_TYPE_DUPLICATE_PROPERTY: {
code: 400,
message: "Error: Invalid Content. The data type %1 contains duplicate property.",
messageId: "SVC4598"
}
-#---------SVC4599------------------------------
+#---------SVC4599------------------------------
# %1 - Data type name
# %2 - Property names
DATA_TYPE_PROEPRTY_CANNOT_HAVE_SAME_TYPE_OF_DATA_TYPE: {
@@ -1295,14 +1295,14 @@ errors:
message: "Error: Invalid Content. The data type %1 contains properties %2 which their type is this data type.",
messageId: "SVC4599"
}
-#---------SVC4600------------------------------
+#---------SVC4600------------------------------
# %1 - Data type name
DATA_TYPE_CANNOT_HAVE_PROPERTIES: {
code: 400,
message: "Error: Invalid Content. The data type %1 cannot have properties since it is of type scalar",
messageId: "SVC4600"
}
-#---------SVC4601------------------------------
+#---------SVC4601------------------------------
NOT_TOPOLOGY_TOSCA_TEMPLATE: {
code: 400,
message: "Error: TOSCA yaml file %1 cannot be modeled to VF as it does not contain 'topology_template.",
@@ -1317,7 +1317,7 @@ errors:
message: "Error: TOSCA yaml file '%1' contains node_template '%2' of type '%3' that does not represent existing VFC/CP/VL",
messageId: "SVC4602"
}
-#---------SVC4603------------------------------
+#---------SVC4603------------------------------
# %1 - component type
# %2 - component name
# %3 - state
@@ -1326,21 +1326,21 @@ errors:
message: "Error: Component instance of %1 can not be created because the component '%2' is in an illegal state %3.",
messageId: "SVC4603"
}
-#---------SVC4604------------------------------
+#---------SVC4604------------------------------
# %1 - csar file name
CSAR_INVALID: {
code: 400,
message: "Error: TOSCA CSAR '%1' is invalid. 'TOSCA-Metadata/Tosca.meta' file must be provided.",
messageId: "SVC4604"
}
-#---------SVC4605------------------------------
+#---------SVC4605------------------------------
# %1 - csar file name
CSAR_INVALID_FORMAT: {
code: 400,
message: "Error: TOSCA CSAR '%1' is invalid. Invalid 'TOSCA-Metadata/Tosca.meta' file format.",
messageId: "SVC4605"
}
-#---------SVC4606------------------------------
+#---------SVC4606------------------------------
# %1 - property name
# %2 - property type
# %3 - property innerType
@@ -1350,14 +1350,14 @@ errors:
message: "Error: Invalid default value of property %1. Data type is %2 with inner type %3 and default value found is %4.",
messageId: "SVC4606"
}
-#---------SVC4607------------------------------
+#---------SVC4607------------------------------
# %1 - csar file name
CSAR_NOT_FOUND: {
code: 400,
message: "Error: TOSCA CSAR '%1' is not found.",
messageId: "SVC4607"
}
-#---------SVC4608------------------------------
+#---------SVC4608------------------------------
# %1 - artifact name
# %2 - component type
# %3 - actual component type
@@ -1367,14 +1367,14 @@ errors:
messageId: "SVC4608"
}
-#---------SVC4609------------------------------
-# %1 - "INVALID_JSON"
+#---------SVC4609------------------------------
+# %1 - "INVALID_JSON"
INVALID_JSON: {
code: 400,
message: "Error: Uploaded JSON file for %1 artifact is invalid.",
messageId: "SVC4609"
}
-#---------SVC4610------------------------------
+#---------SVC4610------------------------------
# %1 - csar file name
# %2 - missing file name
YAML_NOT_FOUND_IN_CSAR: {
@@ -1382,21 +1382,21 @@ errors:
message: "Error - TOSCA CSAR %1 is invalid. TOSCA-Metadata/Tosca.meta refers to file %2 that is not provided.",
messageId: "SVC4610"
}
-#---------SVC4611------------------------------
+#---------SVC4611------------------------------
# %1 - group name
GROUP_MEMBER_EMPTY: {
code: 400,
message: "Error: Invalid Content. Group %1 member list was provided but does not have values",
messageId: "SVC4611"
}
-#---------SVC4612------------------------------
-# %1 - group name
+#---------SVC4612------------------------------
+# %1 - group name
GROUP_TYPE_ALREADY_EXIST: {
code: 409,
message: 'Error: Group type %1 already exists.',
messageId: "SVC4612"
}
-#---------SVC4613------------------------------
+#---------SVC4613------------------------------
# %1 - group name
# %2 - VF name(component name)
# %3 - actual component type [VF]
@@ -1404,15 +1404,15 @@ errors:
code: 409,
message: "Error: Group with name '%1' already exists in %2 %3.",
messageId: "SVC4613"
- }
-#---------SVC4614------------------------------
+ }
+#---------SVC4614------------------------------
# %1 - group type
GROUP_TYPE_IS_INVALID: {
code: 400,
message: "Error: Invalid content. Group type %1 does not exist",
messageId: "SVC4614"
}
-#---------SVC4615------------------------------
+#---------SVC4615------------------------------
# %1 - group name
GROUP_MISSING_GROUP_TYPE: {
code: 400,
@@ -1428,7 +1428,7 @@ errors:
code: 400,
message: "Error: Member '%1' listed in group '%2' is not part of '%3' %4.",
messageId: "SVC4616"
- }
+ }
#---------SVC4617------------------------------
# %1 - member name
# %2 - group name
@@ -1438,7 +1438,7 @@ errors:
message: "Error: member %1 listed in group %2 is not part of allowed members of group type %3.",
messageId: "SVC4617"
}
-#---------SVC4618------------------------------
+#---------SVC4618------------------------------
# %1 - missing file name
# %2 - csar file name
ARTIFACT_NOT_FOUND_IN_CSAR: {
@@ -1446,7 +1446,7 @@ errors:
message: "Error: artifact %1 is defined in CSAR %2 manifest but is not provided",
messageId: "SVC4618"
}
-#---------SVC4619------------------------------
+#---------SVC4619------------------------------
# %1 - artifact name
# %2 - artifact type
# %3 - existing artifact type
@@ -1455,23 +1455,23 @@ errors:
message: "Error: artifact %1 in type %2 already exists in type %3.",
messageId: "SVC4619"
}
-#---------SVC4620------------------------------
+#---------SVC4620------------------------------
FAILED_RETRIVE_ARTIFACTS_TYPES: {
code: 400,
message: "Error: Failed to retrieve list of suported artifact types.",
messageId: "SVC4620"
}
-#---------SVC4621------------------------------
+#---------SVC4621------------------------------
# %1 - artifact name
-# %2 - master
+# %2 - master
ARTIFACT_ALRADY_EXIST_IN_MASTER_IN_CSAR: {
code: 400,
message: "Error: artifact %1 already exists in master %2 .",
messageId: "SVC4621"
}
-#---------SVC4622------------------------------
+#---------SVC4622------------------------------
# %1 - artifact name
-# %2 - artifact type
+# %2 - artifact type
# %3 - master name
# %4 - master type
ARTIFACT_NOT_VALID_IN_MASTER: {
@@ -1479,9 +1479,9 @@ errors:
message: "Error: artifact %1 in type %2 can not be exists under master %3 in type %4.",
messageId: "SVC4622"
}
-#---------SVC4623------------------------------
+#---------SVC4623------------------------------
# %1 - artifact name
-# %2 - artifact type
+# %2 - artifact type
# %3 - env name
# %4 - existing env
ARTIFACT_NOT_VALID_ENV: {
@@ -1489,7 +1489,7 @@ errors:
message: "Error: Artifact %1 in type %2 with env %3 already exists with another env %4",
messageId: "SVC4623"
}
-#---------SVC4624------------------------------
+#---------SVC4624------------------------------
# %1 - groups names
# %2 - VF name
# %3 - component type [VF ]
@@ -1498,14 +1498,14 @@ errors:
message: "Error: Invalid Content. The groups '%1' cannot be found under %2 %3.",
messageId: "SVC4624"
}
-#---------SVC4625------------------------------
+#---------SVC4625------------------------------
# %1 - groups name
GROUP_ARTIFACT_ALREADY_ASSOCIATED: {
code: 400,
message: "Error: Invalid Content. Artifact already associated to group '%1'.",
messageId: "SVC4625"
}
-#---------SVC4626------------------------------
+#---------SVC4626------------------------------
# %1 - groups name
GROUP_ARTIFACT_ALREADY_DISSOCIATED: {
code: 400,
@@ -1521,7 +1521,7 @@ errors:
message: "Error: property %1 listed in group %2 is not exist in group type %3.",
messageId: "SVC4627"
}
-#---------SVC4628------------------------------
+#---------SVC4628------------------------------
# %1 - csarUUID
# %2 - VF name
VSP_ALREADY_EXISTS: {
@@ -1529,14 +1529,14 @@ errors:
message: "Error: The VSP with UUID %1 was already imported for VF %2. Please select another or update the existing VF.",
messageId: "SVC4628"
}
-#---------SVC4629------------------------------
+#---------SVC4629------------------------------
# %1 - VF name
MISSING_CSAR_UUID: {
code: 400,
message: "Error: The Csar UUID or payload name is missing for VF %1.",
messageId: "SVC4629"
}
-#---------SVC4630------------------------------
+#---------SVC4630------------------------------
# %1 - VF name
# %2 - new csarUUID
# %3 - old csarUUID
@@ -1545,8 +1545,8 @@ errors:
message: "Error: Resource %1 cannot be updated using CsarUUID %2 since the resource is linked to a different VSP with csarUUID %3.",
messageId: "SVC4630"
}
-#---------SVC4631------------------------------
-# %1 - policy name
+#---------SVC4631------------------------------
+# %1 - policy name
POLICY_TYPE_ALREADY_EXIST: {
code: 409,
message: "Error: Policy type %1 already exists.",
@@ -1593,7 +1593,7 @@ errors:
code: 404,
message: "Error: Requested '%1' attribute was not found.",
messageId: "SVC4637"
- }
+ }
#-----------SVC4638---------------------------
#%1 - attribute name
ATTRIBUTE_ALREADY_EXIST: {
@@ -1661,7 +1661,7 @@ errors:
message: "Error: Invalid Content. VF Module name '%1' contains invalid characters",
messageId: "SVC4646"
}
-
+
#---------SVC4647------------------------------
# %1 - "modifiedName"
INVALID_VF_MODULE_NAME_MODIFICATION: {
@@ -1699,23 +1699,23 @@ errors:
message: "Error: Once resource is certified, derived_from can be changed only to a sibling",
messageId: "SVC4651"
}
-#---------SVC4652------------------------------
+#---------SVC4652------------------------------
# %1 - resource/service
COMPONENT_INVALID_SUBCATEGORY: {
code: 400,
message: "Error: Invalid Content. Invalid %1 sub category.",
messageId: "SVC4652"
}
-#---------SVC4653------------------------------
-# %1 - group instance uniqueId
+#---------SVC4653------------------------------
+# %1 - group instance uniqueId
# %2 - service uniqueId
GROUP_INSTANCE_NOT_FOUND_ON_COMPONENT_INSTANCE: {
code: 404,
message: "Error: Requested group instance %1 was not found on component %2.",
messageId: "SVC4653"
}
-#---------SVC4654------------------------------
-# %1 - group property name
+#---------SVC4654------------------------------
+# %1 - group property name
# %2 - valid min limit value
# %3 - valid max limit value
INVALID_GROUP_MIN_MAX_INSTANCES_PROPERTY_VALUE: {
@@ -1723,8 +1723,8 @@ errors:
message: "Error: Value of %1 must be not higher than %2, and not lower than %3.",
messageId: "SVC4654"
}
-#---------SVC4655------------------------------
-# %1 - group property name
+#---------SVC4655------------------------------
+# %1 - group property name
# %2 - valid min limit value
# %3 - valid max limit value
INVALID_GROUP_INITIAL_COUNT_PROPERTY_VALUE: {
@@ -1732,15 +1732,15 @@ errors:
message: "Error: Value of %1 must be between %2 and %3.",
messageId: "SVC4655"
}
-#---------SVC4656------------------------------
-# %1 - group property name
+#---------SVC4656------------------------------
+# %1 - group property name
# %2 - lower/higher
# %3 - valid max/min value
INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER: {
code: 400,
message: "Error: Value of %1 must be %2 or equals to %3.",
messageId: "SVC4656"
- }
+ }
#---------SVC4657------------------------------
# %1 - certificationRequest / startTesting
RESOURCE_VFCMT_LIFECYCLE_STATE_NOT_VALID: {
@@ -1752,7 +1752,7 @@ errors:
# %1 – asset type [service / resource ]
# %2 – main asset uuid
# %3 – not found asset type [service / resource]
-# %4 – not found asset name
+# %4 – not found asset name
ASSET_NOT_FOUND_DURING_CSAR_CREATION: {
code: 400,
message: "Error: CSAR packaging failed for %1 %2. %3 %4 was not found",
@@ -1761,7 +1761,7 @@ errors:
#---------SVC4659------------------------------
# %1 – asset type [service / resource ]
# %2 – main asset uuid
-# %3 – Artifact name
+# %3 – Artifact name
# %4 – Artifact uuid
ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION: {
code: 400,
@@ -1777,18 +1777,78 @@ errors:
messageId: "SVC4660"
}
#---------SVC4661------------------------------
-# %1 - version
-# %2 - conformance level
+# %1 - assetType
+# %2 - matching generic node type name
TOSCA_SCHEMA_FILES_NOT_FOUND: {
code: 400,
message: "Error: CSAR packaging failed. TOSCA schema files for SDC-Version: %1 and Conformance-Level %2 were not found",
messageId: "SVC4661"
}
-#---------SVC4662------------------------------
+#---------SVC4662------------------------------
# %1 - file name
# %2 - parser error
TOSCA_PARSE_ERROR: {
code: 400,
message: "Error: Invalid TOSCA template in file %1. %2",
messageId: "SVC4662"
+ }
+#---------SVC4663------------------------------
+# %1 - max length
+ RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT: {
+ code: 400,
+ message: "Error: Invalid Content. Resource vendor model number exceeds limit of %1 characters.",
+ messageId: "SVC4663"
+ }
+#---------SVC4664------------------------------
+ INVALID_RESOURCE_VENDOR_MODEL_NUMBER: {
+ code: 400,
+ message: 'Error: Invalid Content. Resource vendor model number is not allowed to contain characters like <>:"\/|?* and space characters other than regular space.',
+ messageId: "SVC4664"
+ }
+#---------SVC4665------------------------------
+# %1 - max length
+ SERVICE_TYPE_EXCEEDS_LIMIT: {
+ code: 400,
+ message: "Error: Invalid Content. Service type exceeds limit of %1 characters.",
+ messageId: "SVC4665"
+ }
+#---------SVC4666------------------------------
+ INVALID_SERVICE_TYPE: {
+ code: 400,
+ message: 'Error: Invalid Content. Serivce type is not allowed to contain characters like <>:"\/|?* and space characters other than regular space.',
+ messageId: "SVC4666"
+ }
+#---------SVC4667------------------------------
+# %1 - max length
+ SERVICE_ROLE_EXCEEDS_LIMIT: {
+ code: 400,
+ message: "Error: Invalid Content. Service role exceeds limit of %1 characters.",
+ messageId: "SVC4667"
+ }
+#---------SVC4668------------------------------
+ INVALID_SERVICE_ROLE: {
+ code: 400,
+ message: 'Error: Invalid Content. Service role is not allowed to contain characters like <>:"\/|?* and space characters other than regular space.',
+ messageId: "SVC4668"
+ }
+
+#---------SVC4669-----------------------------
+ INVALID_RESOURCE_TYPE: {
+ code: 400,
+ message: "Error: Invalid resource type.",
+ messageId: "SVC4669"
+ }
+#---------SVC4670------------------------------
+ ARTIFACT_NAME_INVALID: {
+ code: 400,
+ message: "Error: Artifact name is invalid.",
+ messageId: "SVC4670"
+ }
+#---------SVC4671------------------------------
+# %1 - VSP name
+# %2 - VFC name
+ CFVC_LOOP_DETECTED: {
+ code: 400,
+ message: 'Error: VSP %1 cannot be imported. The VSP contains internal loop in VFC %2',
+ messageId: "SVC4671"
} \ No newline at end of file
diff --git a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml
index 63d70c699e..da15414d9d 100644
--- a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml
+++ b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml
@@ -1196,4 +1196,57 @@ org.openecomp.datatypes.Naming:
type: string
required: false
+# NFoD
+org.openecomp.datatypes.flavors.ComputeFlavor:
+ derived_from: tosca.datatypes.Root
+ properties:
+ num_cpus:
+ type: integer
+ disk_size:
+ type: scalar-unit.size
+ mem_size:
+ type: scalar-unit.size
+
+org.openecomp.datatypes.flavors.LicenseFlavor:
+ derived_from: tosca.datatypes.Root
+ properties:
+ feature_group_uuid:
+ type: string
+
+org.openecomp.datatypes.flavors.VendorInfo:
+ derived_from: tosca.datatypes.Root
+ properties:
+ manufacturer_reference_number:
+ type: string
+ vendor_model:
+ type: string
+
+org.openecomp.datatypes.flavors.DeploymentFlavor:
+ derived_from: tosca.datatypes.Root
+ properties:
+ sp_part_number:
+ type: string
+ vendor_info:
+ type: org.openecomp.datatypes.flavors.VendorInfo
+ compute_flavor:
+ type: org.openecomp.datatypes.flavors.ComputeFlavor
+ license_flavor:
+ type: org.openecomp.datatypes.flavors.LicenseFlavor
+ required: false
+
+
+org.openecomp.datatypes.ImageInfo:
+ derived_from: tosca.datatypes.Root
+ properties:
+ software_version:
+ type: string
+ file_name:
+ type: string
+ file_hash:
+ type: string
+ description: checksum/signature
+ file_hash_type:
+ type: string
+ required: false
+ default: md5
diff --git a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zip b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zip
index 9c5964df1d..08d4bfc3a5 100644
--- a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zip
+++ b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zip
Binary files differ
diff --git a/catalog-be/src/main/resources/import/tosca/heat-types.zip b/catalog-be/src/main/resources/import/tosca/heat-types.zip
deleted file mode 100644
index ebb5afd09d..0000000000
--- a/catalog-be/src/main/resources/import/tosca/heat-types.zip
+++ /dev/null
Binary files differ
diff --git a/catalog-be/src/main/resources/import/tosca/heat-types/Generic_PNF/Generic_PNF.json b/catalog-be/src/main/resources/import/tosca/heat-types/Generic_PNF/Generic_PNF.json
new file mode 100644
index 0000000000..cfa11dc3c7
--- /dev/null
+++ b/catalog-be/src/main/resources/import/tosca/heat-types/Generic_PNF/Generic_PNF.json
@@ -0,0 +1,21 @@
+{
+ "payloadName": "Generic_PNF.yml",
+ "contactId": "jh0003",
+ "name": "Generic_PNF",
+ "description": "Represents a generic PNF.",
+ "resourceIconPath": "defaulticon",
+ "resourceType": "ABSTRACT",
+ "categories": [
+ {
+ "name": "Generic",
+ "subcategories": [
+ {
+ "name": "Abstract"
+ }
+ ]
+ }
+],
+ "tags": [
+ "Generic_PNF"
+ ]
+} \ No newline at end of file
diff --git a/catalog-be/src/main/resources/import/tosca/heat-types/Generic_PNF/Generic_PNF.yml b/catalog-be/src/main/resources/import/tosca/heat-types/Generic_PNF/Generic_PNF.yml
new file mode 100644
index 0000000000..db3fc7cd3e
--- /dev/null
+++ b/catalog-be/src/main/resources/import/tosca/heat-types/Generic_PNF/Generic_PNF.yml
@@ -0,0 +1,11 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+node_types:
+ org.openecomp.resource.abstract.nodes.PNF:
+ derived_from: tosca.nodes.Root
+ properties:
+ nf_function:
+ type: string
+ nf_role:
+ type: string
+ nf_type:
+ type: string \ No newline at end of file
diff --git a/catalog-be/src/main/resources/import/tosca/heat-types/Generic_PNF/Generic_PNF.zip b/catalog-be/src/main/resources/import/tosca/heat-types/Generic_PNF/Generic_PNF.zip
new file mode 100644
index 0000000000..fc5d706514
--- /dev/null
+++ b/catalog-be/src/main/resources/import/tosca/heat-types/Generic_PNF/Generic_PNF.zip
Binary files differ
diff --git a/catalog-be/src/main/resources/import/tosca/heat-types/extCp/extCp.yml b/catalog-be/src/main/resources/import/tosca/heat-types/extCp/extCp.yml
index e73cafe100..9160a9ba22 100644
--- a/catalog-be/src/main/resources/import/tosca/heat-types/extCp/extCp.yml
+++ b/catalog-be/src/main/resources/import/tosca/heat-types/extCp/extCp.yml
@@ -37,16 +37,16 @@ node_types:
subnetpoolid:
type: string
requirements:
- virtualLink:
- capability: tosca.capabilities.network.Linkable
- relationship: tosca.relationships.network.LinksTo
- virtualBinding:
- capability: tosca.capabilities.network.Bindable
- relationship: tosca.relationships.network.BindsTo
- external_virtualLink:
- capability: tosca.capabilities.network.Linkable
- relationship: tosca.relationships.network.LinksTo
- node: org.openecomp.resource.vl.VL
+ - virtualLink:
+ capability: tosca.capabilities.network.Linkable
+ relationship: tosca.relationships.network.LinksTo
+ - virtualBinding:
+ capability: tosca.capabilities.network.Bindable
+ relationship: tosca.relationships.network.BindsTo
+ - external_virtualLink:
+ capability: tosca.capabilities.network.Linkable
+ relationship: tosca.relationships.network.LinksTo
+ node: org.openecomp.resource.vl.VL
capabilities:
internal_connectionPoint:
type: tosca.capabilities.Node
diff --git a/catalog-be/src/main/resources/import/tosca/heat-types/extCp/extCp.zip b/catalog-be/src/main/resources/import/tosca/heat-types/extCp/extCp.zip
index a26c323819..5e18a2474a 100644
--- a/catalog-be/src/main/resources/import/tosca/heat-types/extCp/extCp.zip
+++ b/catalog-be/src/main/resources/import/tosca/heat-types/extCp/extCp.zip
Binary files differ
diff --git a/catalog-be/src/main/resources/import/tosca/heat-types/multiFlavorVFC/multiFlavorVFC.json b/catalog-be/src/main/resources/import/tosca/heat-types/multiFlavorVFC/multiFlavorVFC.json
new file mode 100644
index 0000000000..1d27562aae
--- /dev/null
+++ b/catalog-be/src/main/resources/import/tosca/heat-types/multiFlavorVFC/multiFlavorVFC.json
@@ -0,0 +1,21 @@
+{
+ "payloadName": "multiFlavorVFC.yml",
+ "contactId": "jh0003",
+ "name": "multiFlavorVFC",
+ "description": "Represents a generic multi flavor VFC.",
+ "resourceIconPath": "defaulticon",
+ "resourceType": "VFC",
+ "categories": [
+ {
+ "name": "Generic",
+ "subcategories": [
+ {
+ "name": "Abstract"
+ }
+ ]
+ }
+],
+ "tags": [
+ "multiFlavorVFC"
+ ]
+} \ No newline at end of file
diff --git a/catalog-be/src/main/resources/import/tosca/heat-types/multiFlavorVFC/multiFlavorVFC.yml b/catalog-be/src/main/resources/import/tosca/heat-types/multiFlavorVFC/multiFlavorVFC.yml
new file mode 100644
index 0000000000..2df111d1c5
--- /dev/null
+++ b/catalog-be/src/main/resources/import/tosca/heat-types/multiFlavorVFC/multiFlavorVFC.yml
@@ -0,0 +1,10 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+node_types:
+ org.openecomp.resource.abstract.nodes.MultiFlavorVFC:
+ derived_from: org.openecomp.resource.abstract.nodes.VFC
+ properties:
+ images:
+ type: map
+ entry_schema:
+ type: org.openecomp.datatypes.ImageInfo
+ required: false
diff --git a/catalog-be/src/main/resources/import/tosca/heat-types/multiFlavorVFC/multiFlavorVFC.zip b/catalog-be/src/main/resources/import/tosca/heat-types/multiFlavorVFC/multiFlavorVFC.zip
new file mode 100644
index 0000000000..d73488d0c0
--- /dev/null
+++ b/catalog-be/src/main/resources/import/tosca/heat-types/multiFlavorVFC/multiFlavorVFC.zip
Binary files differ
diff --git a/catalog-be/src/main/resources/import/tosca/heat-types/vnfConfiguration/vnfConfiguration.json b/catalog-be/src/main/resources/import/tosca/heat-types/vnfConfiguration/vnfConfiguration.json
new file mode 100644
index 0000000000..2a955ab955
--- /dev/null
+++ b/catalog-be/src/main/resources/import/tosca/heat-types/vnfConfiguration/vnfConfiguration.json
@@ -0,0 +1,21 @@
+{
+ "payloadName": "vnfConfiguration.yml",
+ "contactId": "jh0003",
+ "name": "vnfConfiguration",
+ "description": "Configuration parameters for VNF",
+ "resourceIconPath": "vnfconfiguration",
+ "resourceType": "VFC",
+ "categories": [
+ {
+ "name": "Generic",
+ "subcategories": [
+ {
+ "name": "Abstract"
+ }
+ ]
+ }
+],
+ "tags": [
+ "vnfConfiguration"
+ ]
+} \ No newline at end of file
diff --git a/catalog-be/src/main/resources/import/tosca/heat-types/vnfConfiguration/vnfConfiguration.yml b/catalog-be/src/main/resources/import/tosca/heat-types/vnfConfiguration/vnfConfiguration.yml
new file mode 100644
index 0000000000..4ee624615a
--- /dev/null
+++ b/catalog-be/src/main/resources/import/tosca/heat-types/vnfConfiguration/vnfConfiguration.yml
@@ -0,0 +1,10 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+node_types:
+ org.openecomp.resource.abstract.nodes.VnfConfiguration:
+ derived_from: tosca.nodes.Root
+ properties:
+ allowed_flavors:
+ description: a collection of all flavor valuesets available for a given VFC
+ type: map
+ entry_schema:
+ type: org.openecomp.datatypes.flavors.DeploymentFlavor
diff --git a/catalog-be/src/main/resources/import/tosca/heat-types/vnfConfiguration/vnfConfiguration.zip b/catalog-be/src/main/resources/import/tosca/heat-types/vnfConfiguration/vnfConfiguration.zip
new file mode 100644
index 0000000000..03a7d535f2
--- /dev/null
+++ b/catalog-be/src/main/resources/import/tosca/heat-types/vnfConfiguration/vnfConfiguration.zip
Binary files differ
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py
index f65aefacf1..e7eaa8610b 100644
--- a/catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py
+++ b/catalog-be/src/main/resources/scripts/import/tosca/importHeatTypes.py
@@ -37,7 +37,8 @@ def importHeatTypes(beHost, bePort, adminUser, fileDir, updateversion):
"eline",
"abstractSubstitute",
"Generic_VFC",
- "Generic_VF",
+ "Generic_VF",
+ "Generic_PNF",
"Generic_Service",
"contrailNetworkRules",
"contrailPort",
@@ -48,7 +49,9 @@ def importHeatTypes(beHost, bePort, adminUser, fileDir, updateversion):
"contrailCompute",
"contrailV2VirtualMachineInterface",
"subInterface",
- "contrailV2VLANSubInterface"
+ "contrailV2VLANSubInterface",
+ "multiFlavorVFC",
+ "vnfConfiguration"
]
responseCodes = [200, 201]
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/upgradeHeatTypes1707.py b/catalog-be/src/main/resources/scripts/import/tosca/upgradeHeatTypes1707.py
index 7c0746fb55..7315ec0635 100644
--- a/catalog-be/src/main/resources/scripts/import/tosca/upgradeHeatTypes1707.py
+++ b/catalog-be/src/main/resources/scripts/import/tosca/upgradeHeatTypes1707.py
@@ -26,7 +26,8 @@ def upgradeHeatTypes1707(beHost, bePort, adminUser, fileDir, updateversion):
"extVl",
"extCp",
"Generic_VFC",
- "Generic_VF",
+ "Generic_VF",
+ "Generic_PNF",
"Generic_Service",
"globalPort",
"globalNetwork",
@@ -37,6 +38,8 @@ def upgradeHeatTypes1707(beHost, bePort, adminUser, fileDir, updateversion):
"contrailVirtualNetwork",
"neutronNet",
"neutronPort",
+ "multiFlavorVFC",
+ "vnfConfiguration"
]
responseCodes = [200, 201]
diff --git a/catalog-be/src/main/webapp/WEB-INF/web.xml b/catalog-be/src/main/webapp/WEB-INF/web.xml
index 9b7a55a4dd..889b1fac60 100644
--- a/catalog-be/src/main/webapp/WEB-INF/web.xml
+++ b/catalog-be/src/main/webapp/WEB-INF/web.xml
@@ -77,7 +77,6 @@
<servlet-mapping>
<servlet-name>jerseyDistribution</servlet-name>
<url-pattern>/sdc/*</url-pattern>
- <url-pattern>/asdc/*</url-pattern>
</servlet-mapping>
<servlet>