aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-06-17 22:40:44 +0300
committerMichael Lando <ml636r@att.com>2017-06-18 07:20:49 +0300
commit4d97d5fac309ce0d66938e5ccd0349e2660d4e23 (patch)
tree3f921054f997d1962fa6f9db9a0119e31a851eea /catalog-be/src/main
parent89786d31f266a205857cae0177904c249ac6a512 (diff)
[sdc] update code of sdc
Change-Id: If9f37c80b659cb67b34d18e6c019defecca58b9a Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java195
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java20
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java18
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java252
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionCatalogServlet.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionServlet.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverter.java13
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java45
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java21
-rw-r--r--catalog-be/src/main/resources/config/error-configuration.yaml12
-rw-r--r--catalog-be/src/main/webapp/WEB-INF/web.xml2
15 files changed, 423 insertions, 197 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 83c8183a01..887ce12c3c 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
@@ -23,6 +23,7 @@ package org.openecomp.sdc.be.components.impl;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.math.BigDecimal;
+import java.rmi.activation.ActivationSystem;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.EnumMap;
@@ -30,6 +31,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
@@ -270,7 +272,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
// step 8
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> result = validateAndHandleArtifact(componentId, componentType, operation, artifactId, artifactInfo, origMd5, originData, interfaceName, operationName, parentId, user, component,
- shouldLock, inTransaction);
+ shouldLock, inTransaction, true);
return result;
}
@@ -283,7 +285,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
* @return
*/
public Either<Either<ArtifactDefinition, Operation>, ResponseFormat> validateAndHandleArtifact(String componentUniqueId, ComponentTypeEnum componentType, ArtifactOperationInfo operation, String artifactUniqueId,
- ArtifactDefinition artifactDefinition, String origMd5, String originData, String interfaceName, String operationName, String parentId, User user, Component component, boolean shouldLock, boolean inTransaction) {
+ ArtifactDefinition artifactDefinition, String origMd5, String originData, String interfaceName, String operationName, String parentId, User user, Component component, boolean shouldLock, boolean inTransaction, boolean needUpdateGroup) {
Component parent = component;
Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
@@ -293,7 +295,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> result;
if (errorWrapper.isEmpty()) {
// step 10
- result = doAction(componentUniqueId, componentType, operation, artifactUniqueId, artifactDefinition, origMd5, originData, interfaceName, operationName, auditingAction, user, parent, shouldLock, inTransaction);
+ result = doAction(componentUniqueId, componentType, operation, artifactUniqueId, artifactDefinition, origMd5, originData, interfaceName, operationName, auditingAction, user, parent, shouldLock, inTransaction, needUpdateGroup);
} else {
result = Either.right(errorWrapper.getInnerElement());
}
@@ -387,7 +389,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
private Either<Either<ArtifactDefinition, Operation>, ResponseFormat> doAction(String componentId, ComponentTypeEnum componentType, ArtifactOperationInfo operation, String artifactId, ArtifactDefinition artifactInfo, String origMd5,
- String originData, String interfaceName, String operationName, AuditingActionEnum auditingAction, User user, org.openecomp.sdc.be.model.Component parent, boolean shouldLock, boolean inTransaction) {
+ String originData, String interfaceName, String operationName, AuditingActionEnum auditingAction, User user, org.openecomp.sdc.be.model.Component parent, boolean shouldLock, boolean inTransaction, boolean needUpdateGroup) {
if (interfaceName != null && operationName != null) {
interfaceName = interfaceName.toLowerCase();
operationName = operationName.toLowerCase();
@@ -401,22 +403,119 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
case Delete:
return handleDelete(componentId, artifactId, user, auditingAction, componentType, parent, interfaceName, operationName, shouldLock, inTransaction);
case Update:
+ Either<Either<ArtifactDefinition, Operation>, ResponseFormat> result = null;
ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactInfo.getArtifactType());
if (componentType.equals(ComponentTypeEnum.RESOURCE_INSTANCE)
&& (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_VOL || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_ENV)) {
- return handleUpdateHeatEnv(componentId, artifactInfo, auditingAction, artifactId, user, componentType, parent, originData, origMd5, operation, shouldLock, inTransaction);
+ result = handleUpdateHeatEnv(componentId, artifactInfo, auditingAction, artifactId, user, componentType, parent, originData, origMd5, operation, shouldLock, inTransaction);
+ if (needUpdateGroup && result.isLeft()) {
+ Either<ArtifactDefinition, Operation> updateResult = result.left().value();
+ ActionStatus error = updateGroupInstance(artifactInfo, updateResult.left().value(), parent, componentType, componentId);
+ if (error != ActionStatus.OK) {
+ result = Either.right(componentsUtils.getResponseFormat(error));
+ }
+ }
} else {
if (componentType.equals(ComponentTypeEnum.RESOURCE) && artifactType == ArtifactTypeEnum.HEAT_ENV) {
- return handleUpdateHeatWithHeatEnvParams(componentId, artifactInfo, auditingAction, artifactId, user, componentType, parent, originData, origMd5, operation, shouldLock, inTransaction);
+ result = handleUpdateHeatWithHeatEnvParams(componentId, artifactInfo, auditingAction, artifactId, user, componentType, parent, originData, origMd5, operation, shouldLock, inTransaction, needUpdateGroup);
+ }
+ }
+ if (result == null) {
+ result = handleUpdate(componentId, artifactInfo, operation, auditingAction, artifactId, user, componentType, parent, origMd5, originData, interfaceName, operationName, shouldLock, inTransaction);
+ if (needUpdateGroup && result.isLeft()) {
+ Either<ArtifactDefinition, Operation> updateResult = result.left().value();
+
+ ActionStatus error = updateGroupForHeat(artifactInfo, updateResult.left().value(), parent, componentType);
+ if (error != ActionStatus.OK) {
+ result = Either.right(componentsUtils.getResponseFormat(error));
+ }
}
}
- return handleUpdate(componentId, artifactInfo, operation, auditingAction, artifactId, user, componentType, parent, origMd5, originData, interfaceName, operationName, shouldLock, inTransaction);
+ return result;
case Create:
return handleCreate(componentId, artifactInfo, operation, auditingAction, user, componentType, parent, origMd5, originData, interfaceName, operationName, shouldLock, inTransaction);
}
return null;
}
+ private ActionStatus updateGroupForHeat(ArtifactDefinition artifactInfo, ArtifactDefinition artAfterUpdate, Component parent, ComponentTypeEnum componentType) {
+ List<GroupDefinition> groups = parent.getGroups();
+ if (groups != null && !groups.isEmpty()) {
+ List<GroupDataDefinition> groupToUpdate = groups.stream().filter(g -> g.getArtifacts() != null && g.getArtifacts().contains(artifactInfo.getUniqueId())).collect(Collectors.toList());
+ if (groupToUpdate != null && !groupToUpdate.isEmpty()) {
+ groupToUpdate.forEach(g -> {
+ g.getArtifacts().remove(artifactInfo.getUniqueId());
+ g.getArtifactsUuid().remove(artifactInfo.getArtifactUUID());
+ g.getArtifacts().add(artAfterUpdate.getUniqueId());
+ g.getArtifactsUuid().add(artAfterUpdate.getArtifactUUID());
+ });
+ Either<List<GroupDefinition>, StorageOperationStatus> status = toscaOperationFacade.updateGroupsOnComponent(parent, componentType, groupToUpdate);
+ if (status.isRight()) {
+ log.debug("Failed to update groups of the component {}. ", parent.getUniqueId());
+ return componentsUtils.convertFromStorageResponse(status.right().value());
+ }
+ }
+ }
+ return ActionStatus.OK;
+ }
+
+ private ActionStatus updateGroupForHeat(ArtifactDefinition artifactInfoHeat, ArtifactDefinition artHeatAfterUpdate, ArtifactDefinition artifactInfoHeatE, ArtifactDefinition artHEAfterUpdate, Component parent, ComponentTypeEnum componentType) {
+ List<GroupDefinition> groups = parent.getGroups();
+ if (groups != null && !groups.isEmpty()) {
+ List<GroupDataDefinition> groupToUpdate = groups.stream().filter(g -> g.getArtifacts() != null && g.getArtifacts().contains(artifactInfoHeat.getUniqueId())).collect(Collectors.toList());
+ if (groupToUpdate != null && !groupToUpdate.isEmpty()) {
+ groupToUpdate.forEach(g -> {
+ g.getArtifacts().remove(artifactInfoHeat.getUniqueId());
+ g.getArtifactsUuid().remove(artifactInfoHeat.getArtifactUUID());
+ g.getArtifacts().remove(artifactInfoHeatE.getUniqueId());
+ g.getArtifacts().add(artHeatAfterUpdate.getUniqueId());
+ g.getArtifactsUuid().add(artHeatAfterUpdate.getArtifactUUID());
+ g.getArtifacts().add(artHEAfterUpdate.getUniqueId());
+ });
+ Either<List<GroupDefinition>, StorageOperationStatus> status = toscaOperationFacade.updateGroupsOnComponent(parent, componentType, groupToUpdate);
+ if (status.isRight()) {
+ log.debug("Failed to update groups of the component {}. ", parent.getUniqueId());
+ return componentsUtils.convertFromStorageResponse(status.right().value());
+ }
+ }
+ }
+ return ActionStatus.OK;
+ }
+
+ private ActionStatus updateGroupInstance(ArtifactDefinition artifactInfo, ArtifactDefinition artAfterUpdate, Component parent, ComponentTypeEnum componentType, String parentId) {
+ List<GroupInstance> updatedGroupInstances = new ArrayList<>();
+ List<GroupInstance> groupInstances = null;
+ Optional<ComponentInstance> componentInstOp = parent.getComponentInstances().stream().filter(ci -> ci.getUniqueId().equals(parentId)).findFirst();
+ if (componentInstOp.isPresent()) {
+ groupInstances = componentInstOp.get().getGroupInstances();
+ }
+ if (CollectionUtils.isNotEmpty(groupInstances)) {
+ boolean isUpdated = false;
+ for (GroupInstance groupInstance : groupInstances) {
+ isUpdated = false;
+ if (CollectionUtils.isNotEmpty(groupInstance.getGroupInstanceArtifacts()) && groupInstance.getGroupInstanceArtifacts().contains(artifactInfo.getUniqueId())) {
+ groupInstance.getGroupInstanceArtifacts().remove(artifactInfo.getUniqueId());
+ groupInstance.getGroupInstanceArtifacts().add(artAfterUpdate.getUniqueId());
+ isUpdated = true;
+ }
+ if (CollectionUtils.isNotEmpty(groupInstance.getGroupInstanceArtifactsUuid()) && groupInstance.getGroupInstanceArtifactsUuid().contains(artifactInfo.getArtifactUUID())) {
+ groupInstance.getGroupInstanceArtifactsUuid().remove(artifactInfo.getArtifactUUID());
+ groupInstance.getGroupInstanceArtifacts().add(artAfterUpdate.getArtifactUUID());
+ isUpdated = true;
+ }
+ if (isUpdated) {
+ updatedGroupInstances.add(groupInstance);
+ }
+ }
+ }
+ Either<List<GroupInstance>, StorageOperationStatus> status = toscaOperationFacade.updateGroupInstancesOnComponent(parent, componentType, parentId, updatedGroupInstances);
+ if (status.isRight()) {
+ log.debug("Failed to update groups of the component {}. ", parent.getUniqueId());
+ return componentsUtils.convertFromStorageResponse(status.right().value());
+ }
+ return ActionStatus.OK;
+ }
+
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> generateNotSavedArtifact(org.openecomp.sdc.be.model.Component parent, ArtifactDefinition artifactInfo, boolean shouldLock, boolean inTransaction) {
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> result;
if (artifactInfo.getArtifactGroupType() == ArtifactGroupTypeEnum.TOSCA) {
@@ -437,7 +536,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
private Either<Either<ArtifactDefinition, Operation>, ResponseFormat> handleUpdateHeatWithHeatEnvParams(String componentId, ArtifactDefinition artifactInfo, AuditingActionEnum auditingAction, String artifactId, User user,
- ComponentTypeEnum componentType, Component parent, String originData, String origMd5, ArtifactOperationInfo operation, boolean shouldLock, boolean inTransaction) {
+ ComponentTypeEnum componentType, Component parent, String originData, String origMd5, ArtifactOperationInfo operation, boolean shouldLock, boolean inTransaction, boolean needToUpdateGroup) {
convertParentType(componentType);
String parentId = parent.getUniqueId();
Either<ArtifactDefinition, StorageOperationStatus> artifactHeatRes = artifactToscaOperation.getArtifactById(componentId, artifactInfo.getGeneratedFromId());
@@ -476,7 +575,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> resultOp = null;
try {
- resultOp = updateHeatParams(componentId, artifactId, artifactInfo, user, auditingAction, parent, componentType, currHeatArtifact, origMd5);
+ resultOp = updateHeatParams(componentId, artifactId, artifactInfo, user, auditingAction, parent, componentType, currHeatArtifact, origMd5, needToUpdateGroup);
return resultOp;
} finally {
@@ -1061,11 +1160,11 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
private ArtifactDefinition findArtifact(Component parentComponent, ComponentTypeEnum componentType, String parentId, String artifactId) {
ArtifactDefinition foundArtifact;
if (parentComponent.getUniqueId().equals(parentId)) {
- foundArtifact = artifactsResolver.findArtifactOnComponent(parentComponent, componentType, artifactId);
- } else {
- ComponentInstance instance = findComponentInstance(parentId, parentComponent);
- foundArtifact = artifactsResolver.findArtifactOnComponentInstance(instance, artifactId);
- }
+ foundArtifact = artifactsResolver.findArtifactOnComponent(parentComponent, componentType, artifactId);
+ } else {
+ ComponentInstance instance = findComponentInstance(parentId, parentComponent);
+ foundArtifact = artifactsResolver.findArtifactOnComponentInstance(instance, artifactId);
+ }
return foundArtifact;
}
@@ -2557,6 +2656,18 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
String artifactType = artifactInfo.getArtifactType();
if (NodeTypeEnum.Resource == convertParentType
&& (ArtifactTypeEnum.HEAT.getType().equalsIgnoreCase(artifactType) || ArtifactTypeEnum.HEAT_VOL.getType().equalsIgnoreCase(artifactType) || ArtifactTypeEnum.HEAT_NET.getType().equalsIgnoreCase(artifactType))) {
+
+ if (!artifactUniqueId.equals(artifactId)) {
+ // need to update the generated id in heat env
+ Map<String, ArtifactDefinition> deploymentArtifacts = parent.getDeploymentArtifacts();
+ Optional<Entry<String, ArtifactDefinition>> findFirst = deploymentArtifacts.entrySet().stream().filter(a -> a.getValue().getGeneratedFromId().equals(artifactId)).findFirst();
+ if (findFirst.isPresent()) {
+ ArtifactDefinition artifactEnvInfo = findFirst.get().getValue();
+ artifactEnvInfo.setArtifactChecksum(null);
+ artifactToscaOperation.updateHeatEnvArtifact(parent.getUniqueId(), artifactEnvInfo, artifactId, artifactUniqueId, convertParentType, parentId);
+ }
+ }
+
/*
* if (!artifactUniqueId.equals(artifactId)) { artifactToscaOperation.updateHeatEnvArtifact(parentId, null, artifactId, artifactUniqueId, convertParentType);
*
@@ -2692,8 +2803,8 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
if (!ArtifactTypeEnum.HEAT_ENV.getType().equalsIgnoreCase(artifactType)) {
// HEAT specific YAML validation
DeploymentArtifactHeatConfiguration heatConfiguration = yamlToObjectConverter.convert(decodedPayload, DeploymentArtifactHeatConfiguration.class);
- if (heatConfiguration == null || heatConfiguration.getHeat_template_version() == null || heatConfiguration.getResources() == null) {
- log.debug("HEAT doesn't contain required \"heat_template_version\" and \"resources\" sections ");
+ if (heatConfiguration == null || heatConfiguration.getHeat_template_version() == null) {
+ log.debug("HEAT doesn't contain required \"heat_template_version\" section.");
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_DEPLOYMENT_ARTIFACT_HEAT, artifactType);
return Either.right(responseFormat);
}
@@ -3552,7 +3663,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
oldCheckSum = artifactDefinition.getArtifactChecksum();
artifactDefinition.setArtifactChecksum(newCheckSum);
-// artifactToscaOperation.updateUUID(artifactDefinition, oldCheckSum, artifactDefinition.getArtifactVersion());
+ // artifactToscaOperation.updateUUID(artifactDefinition, oldCheckSum, artifactDefinition.getArtifactVersion());
artifactDefinition.setEsId(artifactDefinition.getUniqueId());
updateArifactDefinitionStatus = artifactToscaOperation.updateArifactOnResource(artifactDefinition, component.getUniqueId(), artifactDefinition.getUniqueId(), componentType.getNodeType(), instanceId);
@@ -3765,7 +3876,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
private Either<Either<ArtifactDefinition, Operation>, ResponseFormat> updateHeatParams(String componentId, String artifactId, ArtifactDefinition artifactEnvInfo, User user, AuditingActionEnum auditingAction, Component parent,
- ComponentTypeEnum componentType, ArtifactDefinition currHeatArtifact, String origMd5) {
+ ComponentTypeEnum componentType, ArtifactDefinition currHeatArtifact, String origMd5, boolean needToUpdateGroup) {
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> resultOp = null;
Either<ArtifactDefinition, Operation> insideEither = null;
@@ -3773,6 +3884,21 @@ 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()) {
+ CassandraOperationStatus resourceUploadStatus = artifactfromES.right().value();
+ StorageOperationStatus storageResponse = DaoStatusConverter.convertCassandraStatusToStorageStatus(resourceUploadStatus);
+ ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(storageResponse);
+ log.debug("Error when getting artifact from ES, error: {}", actionStatus.name());
+ return Either.right(componentsUtils.getResponseFormatByArtifactId(actionStatus, currHeatArtifact.getArtifactDisplayName()));
+ }
+
+ ESArtifactData esArtifactData = artifactfromES.left().value();
+ byte[] data = esArtifactData.getDataAsArray();
+
+
ArtifactDefinition updatedHeatArt = currHeatArtifact;
List<HeatParameterDefinition> updatedHeatEnvParams = artifactEnvInfo.getListHeatParameters();
@@ -3817,17 +3943,44 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
updatedHeatArt = operationStatus.left().value();
+ boolean res = true;
+ 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);
+ handleAuditing(auditingAction, parent, parent.getUniqueId(), user, updatedHeatArt, currentHeatId, updatedHeatArt.getUniqueId(), responseFormat, componentType, null);
+ // resultOp = Either.left(result.left().value());
+ // return resultOp;
+ } else {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("Update Artifact");
+ log.debug("Failed to save the artifact.");
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR);
+ handleAuditing(auditingAction, parent, parent.getUniqueId(), user, updatedHeatArt, currentHeatId, updatedHeatArt.getUniqueId(), responseFormat, componentType, null);
+ resultOp = Either.right(responseFormat);
+ // return resultOp;
+ }
+
insideEither = Either.left(updatedHeatArt);
}
}
-
+ Either<ArtifactDefinition, StorageOperationStatus> updateHeatEnvArtifact;
if (!currentHeatId.equals(updatedHeatArt.getUniqueId())) {
artifactEnvInfo.setArtifactChecksum(null);
- artifactToscaOperation.updateHeatEnvArtifact(parent.getUniqueId(), artifactEnvInfo, currentHeatId, updatedHeatArt.getUniqueId(), componentType.getNodeType(), componentId);
+ updateHeatEnvArtifact = artifactToscaOperation.updateHeatEnvArtifact(parent.getUniqueId(), artifactEnvInfo, currentHeatId, updatedHeatArt.getUniqueId(), componentType.getNodeType(), componentId);
} else {
- artifactToscaOperation.updateHeatEnvPlaceholder(artifactEnvInfo, componentId, componentType.getNodeType());
+ updateHeatEnvArtifact = artifactToscaOperation.updateHeatEnvPlaceholder(artifactEnvInfo, componentId, componentType.getNodeType());
}
+ if ( needToUpdateGroup && updateHeatEnvArtifact.isLeft() ){
+ ActionStatus result = updateGroupForHeat(currHeatArtifact, updatedHeatArt, artifactEnvInfo, updateHeatEnvArtifact.left().value(), parent, componentType);
+ if ( result != ActionStatus.OK ){
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(result);
+ return Either.right(responseFormat);
+ }
+ }
resultOp = Either.left(insideEither);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.OK);
handleAuditing(auditingAction, parent, parent.getUniqueId(), user, currHeatArtifact, null, artifactId, responseFormat, componentType, "");
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 d8746737d3..dbcc0aec68 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
@@ -22,6 +22,7 @@ package org.openecomp.sdc.be.components.impl;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -48,6 +49,7 @@ 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.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
@@ -1101,8 +1103,22 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
log.debug("getCatalogComponentsByUuidAndAssetType: Corresponding ComponentTypeEnum not found");
return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
}
-
- Either<List<Component>, StorageOperationStatus> componentsListByUuid = toscaOperationFacade.getComponentListByUuid(uuid, null);
+
+ Map<GraphPropertyEnum, Object> additionalPropertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
+
+ switch (assetTypeEnum) {
+ case RESOURCE:
+ additionalPropertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name());
+ break;
+ case SERVICE:
+ additionalPropertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
+ break;
+ default:
+ 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);
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 1ff22dd17f..cded9ee706 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
@@ -43,6 +43,7 @@ import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyCons
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.util.GsonFactory;
+import org.springframework.beans.factory.config.YamlProcessor;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
@@ -60,7 +61,8 @@ public final class ImportUtils {
private ImportUtils() {
}
-
+ public static Yaml STRICT_MAPPING_YAML_LOADER = new YamlLoader().getStrictYamlLoader();
+
private static CustomResolver customResolver = new CustomResolver();
private static class CustomResolver extends Resolver {
@@ -74,6 +76,12 @@ public final class ImportUtils {
addImplicitResolver(Tag.YAML, YAML, "!&*");
}
}
+
+ private static class YamlLoader extends YamlProcessor {
+ public Yaml getStrictYamlLoader() {
+ return createYaml();
+ }
+ }
@SuppressWarnings("unchecked")
public static Either<List<HeatParameterDefinition>, ResultStatusEnum> getHeatParamsWithoutImplicitTypes(String heatDecodedPayload, String artifactType) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
index e0d531d622..7f73dc405c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
@@ -86,16 +86,10 @@ public class PropertyBusinessLogic extends BaseBusinessLogic {
private static final String EMPTY_VALUE = null;
private DataTypeValidatorConverter dataTypeValidatorConverter = DataTypeValidatorConverter.getInstance();
-
- @javax.annotation.Resource
- private IResourceOperation resourceOperation = null;
-
- @Autowired
- private ToscaOperationFacade toscaOperationFacade;
@javax.annotation.Resource
- private ComponentsUtils componentsUtils;
-
+ private IResourceOperation resourceOperation = null;
+
protected static IElementOperation getElementDao(Class<IElementOperation> class1, ServletContext context) {
WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) context.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR);
@@ -248,9 +242,7 @@ public class PropertyBusinessLogic extends BaseBusinessLogic {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND, ""));
}
for (PropertyDefinition property : properties) {
- // esofer - check also that the property belongs to the current
- // resource
- if (property.getUniqueId().equals(propertyId) && property.getParentUniqueId().equals(resourceId)) {
+ if (property.getUniqueId().equals(propertyId) && isPropertyBelongsToResource(property, resourceId)) {
Map<String, PropertyDefinition> propMap = new HashMap<>();
propMap.put(property.getName(), property);
return Either.left(propMap.entrySet().iterator().next());
@@ -259,6 +251,10 @@ public class PropertyBusinessLogic extends BaseBusinessLogic {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND, ""));
}
+ private boolean isPropertyBelongsToResource(PropertyDataDefinition property, String resourceId) {
+ return property.getOwnerId() == null || property.getOwnerId().equals(resourceId);
+ }
+
/**
* delete property of resource from graph
*
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 587be4d169..d3492f8f40 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
@@ -287,7 +287,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
@@ -300,16 +300,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);
@@ -488,7 +488,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())) {
@@ -674,7 +674,7 @@ 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) {
+ boolean inTransaction, Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap) {
Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = CsarUtils.extractVfcsArtifactsFromCsar(csar);
Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
@@ -828,7 +828,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/**
* Changes resource life cycle state to checked out
- *
+ *
* @param resource
* @param user
* @param inTransaction
@@ -860,7 +860,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/**
* Handles Artifacts of NodeType
- *
+ *
* @param nodeTypeResource
* @param nodeTypeArtifactsToHandle
* @param vfcsNewCreatedArtifacts
@@ -869,7 +869,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;
@@ -927,7 +927,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
nestedServiceTemplatesMap.put(ci.getType(), tempName);
}
}
-
+
if (!nodeTypes.isEmpty()) {
Iterator<Entry<String, Object>> nodesNameEntry = nodeTypes.entrySet().iterator();
while (nodesNameEntry.hasNext()) {
@@ -1116,7 +1116,7 @@ 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, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts) {
Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(resourceYml);
@@ -1167,7 +1167,7 @@ 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) {
Either<UploadResourceInfo, ResponseFormat> resourceMetaData = fillResourceMetadata(yamlName, resourceVf, nodeNameValue.getKey(), user);
if (resourceMetaData.isRight()) {
@@ -1213,7 +1213,7 @@ 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) {
LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction("certification on import", LifecycleChanceActionEnum.CREATE_FROM_CSAR);
Function<Resource, Either<Boolean, ResponseFormat>> validator = (resource) -> this.validateResourceCreationFromNodeType(resource, creator);
@@ -1279,7 +1279,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
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) {
+ Map<String, byte[]> csar, List<ArtifactDefinition> createdArtifacts, String topologyTemplateYaml) {
boolean result = true;
boolean inTransaction = true;
@@ -1567,7 +1567,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/**
* This Method validates that there is no cyclic group dependencies. meaning group A as member in group B which is member in group A
- *
+ *
* @param allGroups
* @return
*/
@@ -1599,7 +1599,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/**
* This Method fills recursively the set groupMembers with all the members of the given group which are also of type group.
- *
+ *
* @param groupName
* @param allGroups
* @param allGroupMembers
@@ -1617,12 +1617,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) {
@@ -1648,17 +1648,17 @@ 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) {
+ String topologyTemplateYaml, Map<String, byte[]> csar, String csarUUID, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, Resource> createdVfcs) {
Either<Resource, ResponseFormat> result;
Either<Resource, ResponseFormat> createResourcesInstancesEither;
@@ -1754,7 +1754,7 @@ 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) {
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts) {
Map<String, Resource> createdResourcesFromdNodeTypeMap = new HashMap<>();
Either<Map<String, Resource>, ResponseFormat> result = Either.left(createdResourcesFromdNodeTypeMap);
@@ -1791,7 +1791,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private Either<Resource, ResponseFormat> handleCsarArtifacts(Resource resource, User user, String csarUUID, Map<String, byte[]> csar, List<ArtifactDefinition> createdArtifacts, ArtifactOperationInfo artifactOperation, boolean shouldLock,
- boolean inTransaction) {
+ boolean inTransaction) {
if (csar != null) {
String vendorLicenseModelId = null;
@@ -1870,8 +1870,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
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) {
+ 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)) {
@@ -1922,7 +1922,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ArtifactDefinition artifactDefinitionFromJson = RepresentationUtils.convertJsonToArtifactDefinition(jsonStr, ArtifactDefinition.class);
String artifactUniqueId = artifactDefinitionFromJson == null ? null : artifactDefinitionFromJson.getUniqueId();
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> uploadArtifactToService = artifactsBusinessLogic.validateAndHandleArtifact(resource.getUniqueId(), ComponentTypeEnum.RESOURCE, operation, artifactUniqueId,
- artifactDefinitionFromJson, origMd5, jsonStr, null, null, null, user, resource, false, true);
+ artifactDefinitionFromJson, origMd5, jsonStr, null, null, null, user, resource, false, true, false);
if (uploadArtifactToService.isRight())
return Either.right(uploadArtifactToService.right().value());
@@ -1930,7 +1930,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
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) {
+ boolean shouldLock, boolean inTransaction) {
Either<Map<String, List<ArtifactTemplateInfo>>, ResponseFormat> parseResourceInfoFromYamlEither = parseResourceArtifactsInfoFromFile(resource, artifactsMetaFile, artifactsMetaFileName, user);
if (parseResourceInfoFromYamlEither.isRight()) {
@@ -2023,7 +2023,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
////////////// dissociate, associate or create
////////////// artifacts////////////////////////////
Either<Resource, ResponseFormat> assDissotiateEither = associateAndDissociateArtifactsToGroup(csarUUID, csar, resource, user, createdNewArtifacts, labelCounter, shouldLock, inTransaction, createdDeplymentArtifactsAfterDelete,
- dissocArtifactFromGroup, mergedgroup, deletedArtifacts);
+ mergedgroup, deletedArtifacts);
if (assDissotiateEither.isRight()) {
log.debug("Failed to delete artifacts. Status is {} ", assDissotiateEither.right().value());
@@ -2076,7 +2076,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/*
* 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());
- *
+ *
* } }
*/
@@ -2141,7 +2141,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()) {
@@ -2154,7 +2154,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
* Either<ArtifactDefinition, StorageOperationStatus> removeArifactFromGraph = artifactOperation.removeArifactFromResource(resourceId, artifact.getUniqueId(), NodeTypeEnum.Resource, true, true); if
* (removeArifactFromGraph.isRight()) { StorageOperationStatus status = removeArifactFromGraph.right().value(); log.debug("Failed to delete heat env artifact {} . status is {}", artifact.getUniqueId(), status); ActionStatus
* actionStatus = componentsUtils.convertFromStorageResponse(status); return Either.right(componentsUtils.getResponseFormat(actionStatus)); }
- *
+ *
* deletedArtifacts.add(removeArifactFromGraph.left().value());
*/
@@ -2194,70 +2194,55 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
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<String, List<String>> dissocArtifactFromGroup, Map<GroupDefinition, MergedArtifactInfo> mergedgroup, List<ArtifactDefinition> deletedArtifacts) {
+ 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);
for (Entry<GroupDefinition, MergedArtifactInfo> entry : mergedgroup.entrySet()) {
List<ArtifactDefinition> dissArtifactsInGroup = entry.getValue().getListToDissotiateArtifactFromGroup(deletedArtifacts);
+ GroupDefinition grDef = entry.getKey();
if (dissArtifactsInGroup != null && !dissArtifactsInGroup.isEmpty()) {
- List<String> dissList = new ArrayList<String>();
for (ArtifactDefinition art : dissArtifactsInGroup) {
- dissList.add(art.getUniqueId());
- // String heatEnvId = checkAndGetHeatEnvId(art);
- // if (!heatEnvId.isEmpty()) {
- // dissList.add(heatEnvId);
- // }
+ grDef.getArtifacts().remove(art.getUniqueId());
+ grDef.getArtifactsUuid().remove(art.getArtifactUUID());
}
- dissocArtifactFromGroup.put(entry.getKey().getUniqueId(), dissList);
}
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())
artifactsToUpdateMap.put(entry.getKey(), artifactsToUpdate);
}
- // Map<String, Set<String>> dissocArtifactFromGroup = new HashMap<String, Set<String>>();
- // HashMap<String, Set<String>>();
- List<GroupDefinition> dissotiateArtifactsgroups = new ArrayList<GroupDefinition>();
- for (Entry<String, List<String>> dissotiateEntry : dissocArtifactFromGroup.entrySet()) {
-
- GroupDefinition dissotiateGroup = new GroupDefinition();
- dissotiateGroup.setUniqueId(dissotiateEntry.getKey());
- dissotiateGroup.setArtifacts(dissotiateEntry.getValue());
- dissotiateArtifactsgroups.add(dissotiateGroup);
- }
- if (!dissotiateArtifactsgroups.isEmpty()) {
- /*
- * log.debug("try to dissociate artifacts from groups "); Either<List<GroupDefinition>, ResponseFormat> dissotiateGroupEither = groupBusinessLogic.dissociateArtifactsFromGroup(resource.getUniqueId(), user.getUserId(),
- * ComponentTypeEnum.RESOURCE, dissotiateArtifactsgroups, shouldLock, inTransaction); if (dissotiateGroupEither.isRight()) { log.debug("Failed to dissociate artifacts from groups. Status is {} ", dissotiateGroupEither.right().value());
- * resEither = Either.right(dissotiateGroupEither.right().value()); return resEither;
- *
- * }
- */
- }
-
if (!artifactsToUpdateMap.isEmpty()) {
List<ArtifactDefinition> updatedArtifacts = new ArrayList<ArtifactDefinition>();
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,
artifact.getRight().getRelatedArtifactsInfo(), shouldLock, inTransaction);
if (updateArtifactEither.isRight()) {
log.debug("failed to update artifacts. status is {}", updateArtifactEither.right().value());
resEither = Either.right(updateArtifactEither.right().value());
return resEither;
-
}
-
+ ArtifactDefinition artAfterUpdate = updateArtifactEither.left().value();
+ if ( !prevUUID.equals(artAfterUpdate.getArtifactUUID()) || !prevId.equals(artAfterUpdate.getUniqueId()) ){
+ groupToUpdate.getArtifacts().remove(prevId);
+ groupToUpdate.getArtifactsUuid().remove(prevUUID);
+ groupToUpdate.getArtifacts().add(artAfterUpdate.getUniqueId());
+ groupToUpdate.getArtifactsUuid().add(artAfterUpdate.getArtifactUUID());
+ }
}
}
-
}
List<GroupDefinition> associateArtifactGroup = new ArrayList<GroupDefinition>();
@@ -2266,11 +2251,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
List<ArtifactTemplateInfo> associatedArtifact = associateEntry.getValue();
Set<String> arifactsUids = new HashSet<String>();
for (ArtifactTemplateInfo artifactTemplate : associatedArtifact) { // try
- // to
- // find
- // artifact
- // in
- // resource
+ // to
+ // find
+ // artifact
+ // in
+ // resource
boolean isCreate = true;
for (ArtifactDefinition createdArtifact : createdDeplymentArtifactsAfterDelete) {
if (artifactTemplate.getFileName().equalsIgnoreCase(createdArtifact.getArtifactName())) {
@@ -2338,12 +2323,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/*
* if (!associateArtifactGroup.isEmpty()) {
- *
+ *
* log.debug("Try to associate artifacts to groups.");
- *
+ *
* Either<List<GroupDefinition>, ResponseFormat> assotiateGroupEither = groupBusinessLogic.associateArtifactsToGroup(resource.getUniqueId(), user.getUserId(), ComponentTypeEnum.RESOURCE, associateArtifactGroup, shouldLock, inTransaction); if
* (assotiateGroupEither.isRight()) { log.debug("Failed to associate artifacts to groups. Status is {} ", assotiateGroupEither.right().value()); resEither = Either.right(assotiateGroupEither.right().value()); return resEither;
- *
+ *
* } }
*/
@@ -2368,7 +2353,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();
@@ -2426,7 +2411,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
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,7 +2477,7 @@ 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) {
+ boolean shouldLock, boolean inTransaction) {
log.debug("parseResourceArtifactsInfoFromFile start");
Either<Map<String, List<ArtifactTemplateInfo>>, ResponseFormat> parseResourceInfoFromYamlEither = parseResourceArtifactsInfoFromFile(resource, artifactsMetaFile, artifactsMetaFileName, user);
@@ -2523,7 +2508,7 @@ 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) {
+ 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;
@@ -2560,7 +2545,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
GroupProperty prop = new GroupProperty();
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);
@@ -2571,8 +2557,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
properties = createVfModuleAdditionalProperties(groupTemplateInfo.isBase(), groupName, properties, createdArtifacts, artifactsList, getLatestGroupTypeRes.left().value());
groupDefinition.convertFromGroupProperties(properties);
- properties.add(prop);
- groupDefinition.convertFromGroupProperties(properties);
// Either<GroupDefinition, ResponseFormat> createGroup = groupBusinessLogic.createGroup(resource.getUniqueId(), user.getUserId(), ComponentTypeEnum.RESOURCE, groupDefinition, inTransaction);
// if (createGroup.isRight())
// return Either.right(createGroup.right().value());
@@ -2598,7 +2582,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
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) {
+ 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 = "";
@@ -2683,7 +2667,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
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) {
+ List<ArtifactDefinition> createdArtifacts, boolean shouldLock, boolean inTransaction) {
Either<Resource, ResponseFormat> resStatus = Either.left(resource);
@@ -2702,7 +2686,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) {
+ ArtifactOperationInfo artifactOperation) {
Either<Resource, ResponseFormat> resStatus = null;
Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
@@ -2750,9 +2734,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// 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());
@@ -2817,7 +2801,7 @@ 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> createdArtifacts,
- int labelCounter, boolean shouldLock, boolean inTransaction) {
+ int labelCounter, boolean shouldLock, boolean inTransaction) {
Either<Resource, ResponseFormat> resStatus = Either.left(resource);
List<GroupDefinition> createdGroups = resource.getGroups();
List<GroupDefinition> heatGroups = null;
@@ -3005,7 +2989,7 @@ 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) {
+ ArtifactTemplateInfo artifactTemplateInfo, List<ArtifactDefinition> createdArtifacts, int labelCounter, boolean shoudLock, boolean inTransaction) {
Either<Resource, ResponseFormat> resStatus = Either.left(resource);
String artifactFileName = artifactTemplateInfo.getFileName();
String artifactUid = "";
@@ -3078,7 +3062,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
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) {
+ 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);
if (artifactContententStatus.isRight()) {
@@ -3114,7 +3098,7 @@ 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) {
+ 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);
@@ -3136,7 +3120,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
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) {
+ List<ArtifactDefinition> updatedArtifacts, List<ArtifactTemplateInfo> updatedRequiredArtifacts, boolean shouldLock, boolean inTransaction) {
Either<ArtifactDefinition, ResponseFormat> resStatus = null;
String artifactFileName = artifactTemplateInfo.getFileName();
@@ -3205,7 +3189,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Either<List<HeatParameterDefinition>, ResponseFormat> propsStatus = extractHeatParameters(ArtifactTypeEnum.HEAT_ENV.getType(), artifactTemplateInfo.getEnv(), artifactparamsStatus.left().value().getValue(), false);
/*
* if (propsStatus.isRight()) {
- *
+ *
* resStatus = Either.right(propsStatus.right().value()); return resStatus; }
*/
if (propsStatus.isLeft()) {
@@ -3244,6 +3228,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.debug("Failed to update heat paratemers of heat on CSAR flow for component {} artifact {} label {}", resource.getUniqueId(), currentInfo.getUniqueId(), currentInfo.getArtifactLabel());
return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(updateArifactOnResource.right().value())));
}
+ resStatus = Either.left(updateArifactOnResource.left().value());
}
}
}
@@ -3307,7 +3292,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())
@@ -3690,7 +3675,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
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) {
@@ -3799,9 +3784,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// US740820 Relate RIs according to capability name
private CapabilityDefinition findAvailableCapabilityByTypeOrName(RequirementDefinition validReq, ComponentInstance currentCapCompInstance, UploadReqInfo uploadReqInfo) {
if (null == uploadReqInfo.getCapabilityName() || validReq.getCapability().equals(uploadReqInfo.getCapabilityName())) {// get
- // by
- // capability
- // type
+ // by
+ // capability
+ // type
return findAviableCapability(validReq, currentCapCompInstance);
}
return findAvailableCapability(validReq, currentCapCompInstance, uploadReqInfo);
@@ -3990,7 +3975,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);
@@ -4070,7 +4055,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
parametersView.setIgnoreComponentInstances(false);
parametersView.setIgnoreUsers(false);
parametersView.setIgnoreInputs(false); // inputs are read when creating
- // property values on instances
+ // property values on instances
Either<Resource, StorageOperationStatus> eitherGerResource = toscaOperationFacade.getToscaElement(resource.getUniqueId(), parametersView);
log.debug("*************finished to get resource {}", resource.getUniqueId());
if (eitherGerResource.isRight()) {
@@ -4379,17 +4364,17 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/*
* private boolean valueContainsStrReplace(Object propValue) {
- *
+ *
* log.debug("valueContainsStrReplace value is {}", propValue); boolean result = false; if (propValue != null) { log.debug("valueContainsStrReplace value is {}", propValue.getClass()); Matcher matcher =
* STR_REPLACE_PATTERN.matcher(propValue.toString()); result = matcher.find(); }
- *
+ *
* return result; }
- *
+ *
* private boolean valueContainsToken(Object propValue) {
- *
+ *
* log.debug("valueContainsToken value is {}", propValue); boolean result = false; if (propValue != null) { log.debug("valueContainsToken value is {}", propValue.getClass()); Matcher matcher = TOKEN_PATTERN.matcher(propValue.toString()); result =
* matcher.find(); }
- *
+ *
* return result; }
*/
@@ -4572,7 +4557,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/*
* /**
- *
+ *
* @deprecated Use {@link #createOrUpdateResourceByImport(Resource,User,boolean, boolean,boolean)} instead
*/
/*
@@ -4743,7 +4728,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/**
* Merge old resource with new. Keep old category and vendor name without change
- *
+ *
* @param oldResource
* @param newResource
*/
@@ -4876,10 +4861,8 @@ 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, 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());
}
@@ -4889,8 +4872,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return eitherResult;
}
- private Either<Boolean, ResponseFormat> validateCapabilityTypeExists(User user, ICapabilityTypeOperation capabilityTypeOperation, Resource resource, 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) {
@@ -4901,7 +4885,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
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 = componentsUtils.getResponseFormat(ActionStatus.MISSING_CAPABILITY_TYPE, type);
+ ResponseFormat errorResponse =null;
+ if (type!=null)
+ errorResponse = componentsUtils.getResponseFormat(ActionStatus.MISSING_CAPABILITY_TYPE, type);
+ else
+ errorResponse = componentsUtils.getResponseFormatByElement(ActionStatus.MISSING_CAPABILITY_TYPE, validationObjects );
eitherResult = Either.right(errorResponse);
componentsUtils.auditResource(errorResponse, user, resource, "", "", actionEnum, null);
}
@@ -4909,7 +4897,7 @@ 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) {
@@ -5121,7 +5109,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/**
* deleteResource
- *
+ *
* @param resourceId
* @param user
* @return
@@ -5268,7 +5256,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/**
* updateResourceMetadata
- *
+ *
* @param user
* - modifier data (userId)
* @param inTransaction
@@ -5276,7 +5264,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
* @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) {
@@ -5405,7 +5393,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/**
* validateResourceFieldsBeforeCreate
- *
+ *
* @param user
* - modifier data (userId)
* @param dataModel
@@ -5424,7 +5412,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/*
* log.debug("validate resource name"); Either<Boolean, ResponseFormat> eitherValidation = validateComponentName(user, resource, actionEnum); if (eitherValidation.isRight()) { return eitherValidation; }
- *
+ *
* // validate description log.debug("validate description"); eitherValidation = validateDescriptionAndCleanup(user, resource, actionEnum); if (eitherValidation.isRight()) { return eitherValidation; }
*/
@@ -5514,7 +5502,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/**
* validateResourceFieldsBeforeUpdate
- *
+ *
* @param currentResource
* - Resource object to validate
* @return Either<Boolean, ErrorResponse>
@@ -5678,18 +5666,18 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
/*
* private Either<Boolean, ResponseFormat> validateResourceName(User user, Resource resource, AuditingActionEnum actionEnum) { log.debug("validate resource name is not empty"); String resourceName = resource.getResourceName();
- *
+ *
* if (!ValidationUtils.validateStringNotEmpty(resourceName)) { log.debug("Resource name is empty"); ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue());
* componentsUtils.auditResource(responseFormat, user, resource, "", "", actionEnum, null); return Either.right(responseFormat); }
- *
+ *
* if (!ValidationUtils.validateResourceNameLength(resourceName)) { log.debug("Resource name is exceeds max length {} ", ValidationUtils.RESOURCE_NAME_MAX_LENGTH); ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.
* COMPONENT_NAME_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.RESOURCE_NAME_MAX_LENGTH); componentsUtils.auditResource(responseFormat, user, resource, "", "", actionEnum, null); return Either.right(responseFormat);
* }
- *
+ *
* if (!ValidationUtils.validateResourceName(resourceName)) { log.debug("Resource name {} has invalid format", resourceName); ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_COMPONENT_NAME,
* ComponentTypeEnum.RESOURCE.getValue()); componentsUtils.auditResource(responseFormat, user, resource, "", "", actionEnum, null); return Either.right(responseFormat); } resource.setNormalizedName(ValidationUtils.normaliseComponentName(
* resourceName)); resource.setSystemName(ValidationUtils.convertToSystemName(resourceName)) ;
- *
+ *
* return Either.left(true); }
*/
@@ -5850,7 +5838,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.left(true);
}
- // for extending inheritance US815447
+ // Tal G for extending inheritance US815447
private Either<Boolean, ResponseFormat> validateDerivedFromExtending(User user, Resource currentResource, Resource updateInfoResource, AuditingActionEnum actionEnum) {
// If updated resource is not deriving, should fail validation
/*
@@ -6564,7 +6552,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<>();
@@ -6736,7 +6724,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.debug("Failed to found resource with id {} ", resourceId);
Either.right(componentsUtils.getResponseFormat(ActionStatus.RESOURCE_NOT_FOUND, resourceId));
}
-
+
log.debug("failed to get resource by id {} with filters {}", resourceId, dataParamsToReturn.toString());
return Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(resourceResultEither.right().value()), ""));
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionCatalogServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionCatalogServlet.java
index a5d1093648..3b6012f3b2 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionCatalogServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionCatalogServlet.java
@@ -51,14 +51,23 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jcabi.aspects.Loggable;
+import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;
import fj.data.Either;
+/**
+ * This Servlet serves external users to download artifacts.
+ *
+ * @author tgitelman
+ *
+ */
+
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
+@Api(value = "Distribution Catalog Servlet", description = "This Servlet serves external users to download artifacts.")
@Singleton
public class DistributionCatalogServlet extends BeGenericServlet {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionServlet.java
index b1556bafc3..67f0e74b50 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/distribution/servlet/DistributionServlet.java
@@ -55,11 +55,20 @@ import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
import com.jcabi.aspects.Loggable;
+import com.wordnik.swagger.annotations.Api;
import fj.data.Either;
+/**
+ * This Servlet serves external users for distribution purposes.
+ *
+ * @author tgitelman
+ *
+ */
+
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1")
+@Api(value = "Distribution Servlet", description = "This Servlet serves external users for distribution purposes.")
@Singleton
public class DistributionServlet extends BeGenericServlet {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverter.java
index 2e94dfc554..93de8fed2c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverter.java
@@ -196,11 +196,10 @@ public class AssetMetadataConverter {
private <T extends ResourceAssetMetadata> T convertToResourceMetadata(T assetToPopulate, Resource resource, String serverBaseURL, boolean detailed) {
assetToPopulate = convertToAsset(assetToPopulate, resource, serverBaseURL, detailed);
- CategoryDefinition categoryDefinition;
if(resource.getCategories() != null && !resource.getCategories().isEmpty()){
- categoryDefinition = resource.getCategories().iterator().next();
+ CategoryDefinition categoryDefinition = resource.getCategories().get(0);
assetToPopulate.setCategory(categoryDefinition.getName());
- assetToPopulate.setSubCategory(categoryDefinition.getSubcategories().iterator().next().getName());
+ assetToPopulate.setSubCategory(categoryDefinition.getSubcategories().get(0).getName());
}
assetToPopulate.setResourceType(resource.getResourceType().name());
assetToPopulate.setLifecycleState(resource.getLifecycleState().name());
@@ -212,9 +211,11 @@ public class AssetMetadataConverter {
private <T extends ServiceAssetMetadata> T convertToServiceAssetMetadata(T assetToPopulate, Service service, String serverBaseURL, boolean detailed) {
assetToPopulate = convertToAsset(assetToPopulate, service, serverBaseURL, detailed);
- CategoryDefinition categoryDefinition = service.getCategories().iterator().next();
-
- assetToPopulate.setCategory(categoryDefinition.getName());
+ if(service.getCategories() != null && !service.getCategories().isEmpty()){
+ CategoryDefinition categoryDefinition = service.getCategories().get(0);
+ assetToPopulate.setCategory(categoryDefinition.getName());
+ }
+
assetToPopulate.setLifecycleState(service.getLifecycleState().name());
assetToPopulate.setLastUpdaterUserId(service.getLastUpdaterUserId());
assetToPopulate.setDistributionStatus(service.getDistributionStatus().name());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
index ec1a460417..bf5b3faf75 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
@@ -56,6 +56,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jcabi.aspects.Loggable;
+import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import com.wordnik.swagger.annotations.ApiResponse;
@@ -71,6 +72,7 @@ import fj.data.Either;
*/
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
+@Api(value = "Artifact External Servlet", description = "Servlet serves external users operations on artifacts.")
@Singleton
public class ArtifactExternalServlet extends AbstractValidationsServlet {
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 b0947c67f9..54959c325a 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
@@ -77,7 +77,6 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.servlets.AbstractValidationsServlet;
import org.openecomp.sdc.be.servlets.RepresentationUtils;
@@ -93,6 +92,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jcabi.aspects.Loggable;
+import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import com.wordnik.swagger.annotations.ApiResponse;
@@ -100,8 +100,16 @@ import com.wordnik.swagger.annotations.ApiResponses;
import fj.data.Either;
+/**
+ * This Servlet serves external users for retrieving component metadata.
+ *
+ * @author tgitelman
+ *
+ */
+
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
+@Api(value = "Asset Metadata External Servlet", description = "This Servlet serves external users for retrieving component metadata.")
@Singleton
public class AssetsDataServlet extends AbstractValidationsServlet {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
index a6415dc9b9..8c066c8fde 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
@@ -21,11 +21,8 @@
package org.openecomp.sdc.be.impl;
import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.EnumMap;
-import java.util.List;
-import java.util.Map;
+import java.security.cert.CollectionCertStoreParameters;
+import java.util.*;
import java.util.regex.Pattern;
import javax.annotation.PostConstruct;
@@ -42,21 +39,13 @@ import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.graph.datatype.AdditionalInformationEnum;
+import org.openecomp.sdc.be.dao.utils.CollectionUtils;
import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterInfo;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ConsumerDefinition;
-import org.openecomp.sdc.be.model.DataTypeDefinition;
-import org.openecomp.sdc.be.model.GroupTypeDefinition;
-import org.openecomp.sdc.be.model.PolicyTypeDefinition;
-import org.openecomp.sdc.be.model.PropertyConstraint;
-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.datatypes.tosca.ToscaDataDefinition;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintDeserialiser;
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintJacksonDeserialiser;
@@ -241,6 +230,30 @@ public class ComponentsUtils {
return responseFormat;
}
+ public <T> ResponseFormat getResponseFormatByElement(ActionStatus actionStatus, T obj) {
+ if (obj == null) {
+ return getResponseFormat(actionStatus);
+ }
+ ResponseFormat responseFormat = null;
+
+ switch (actionStatus) {
+ case MISSING_CAPABILITY_TYPE:
+ if (obj instanceof List && org.apache.commons.collections.CollectionUtils.isNotEmpty((List) obj)){
+ List list = (List)obj;
+ if ( list.get(0) instanceof RequirementDefinition ) {
+ responseFormat = getResponseFormat(ActionStatus.MISSING_CAPABILITY_TYPE, ((RequirementDefinition) list.get(0)).getName()); //Arbitray index, all we need is single object
+ return responseFormat;
+ }
+ }
+ log.debug("UNKNOWN TYPE : expecting obj as a non empty List<RequirmentsDefinitions>");
+ break;
+ default:
+ responseFormat = getResponseFormat(actionStatus);
+ break;
+ }
+ return responseFormat;
+ }
+
/**
* Returns the response format of resource error with respective variables according to actionStatus. This is needed for cases where actionStatus is anynomously converted from storage operation, and the caller doesn't know what actionStatus he
* received. It's caller's responisibility to fill the passed resource object with needed fields.
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 b18cbc9adc..fb87e34de7 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
@@ -629,7 +629,7 @@ public class CsarUtils {
}
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> validateAndHandleArtifact = artifactsBusinessLogic.validateAndHandleArtifact(componentUniqueId, componentType, operationType, artifactUniqueId, artDef, dataMD5, data, null,
- null, null, user, component, shouldLock, inTransaction);
+ null, null, user, component, shouldLock, inTransaction, false);
if (validateAndHandleArtifact.isRight()) {
if (ArtifactOperationEnum.Create == operationType.getArtifactOperationEnum() || ArtifactOperationEnum.Update == operationType.getArtifactOperationEnum()) {
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 8be5b0b4b3..a7eac1b8da 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
@@ -137,6 +137,11 @@ public class ToscaExportHandler {
}
public Either<ToscaRepresentation, ToscaError> exportComponentInterface(Component component) {
+ if(null == DEFAULT_IMPORTS) {
+ log.debug("convertToToscaTemplate - failed to get Default Imports section from configuration");
+ return Either.right(ToscaError.GENERAL_ERROR);
+ }
+
ToscaTemplate toscaTemplate = new ToscaTemplate(TOSCA_VERSION);
toscaTemplate.setImports(new ArrayList<>(DEFAULT_IMPORTS));
Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
@@ -189,6 +194,11 @@ public class ToscaExportHandler {
}
private Either<ToscaTemplate, ToscaError> convertToToscaTemplate(Component component) {
+ if(null == DEFAULT_IMPORTS) {
+ log.debug("convertToToscaTemplate - failed to get Default Imports section from configuration");
+ return Either.right(ToscaError.GENERAL_ERROR);
+ }
+
log.trace("start tosca export for {}", component.getUniqueId());
ToscaTemplate toscaTemplate = new ToscaTemplate(TOSCA_VERSION);
@@ -357,6 +367,12 @@ public class ToscaExportHandler {
private Either<ImmutablePair<ToscaTemplate, Map<String, Component>>, ToscaError> fillImports(Component component,
ToscaTemplate toscaTemplate) {
+
+ if(null == DEFAULT_IMPORTS) {
+ log.debug("convertToToscaTemplate - failed to get Default Imports section from configuration");
+ return Either.right(ToscaError.GENERAL_ERROR);
+ }
+
Map<String, Component> componentCache = new HashMap<>();
if (!ToscaUtils.isAtomicType(component)) {
@@ -603,9 +619,8 @@ public class ToscaExportHandler {
}
for (GroupInstance groupInst : groupInstances) {
ToscaGroupTemplate toscaGroup = convertGroupInstance(groupInst);
- String keyName = groupInst.getGroupName();
- groupsMap.put(keyName, toscaGroup);
+ groupsMap.put(groupInst.getName(), toscaGroup);
}
}
@@ -701,7 +716,7 @@ public class ToscaExportHandler {
ToscaGroupTemplate toscaGroup = new ToscaGroupTemplate();
Map<String, String> members = group.getMembers();
if (members != null)
- toscaGroup.setMembers(new ArrayList(members.keySet()));
+ toscaGroup.setMembers(new ArrayList<String>(members.keySet()));
Supplier<String> supplGroupType = () -> group.getType();
Supplier<String> supplDescription = () -> group.getDescription();
diff --git a/catalog-be/src/main/resources/config/error-configuration.yaml b/catalog-be/src/main/resources/config/error-configuration.yaml
index 0fb4e146d4..4985ab552a 100644
--- a/catalog-be/src/main/resources/config/error-configuration.yaml
+++ b/catalog-be/src/main/resources/config/error-configuration.yaml
@@ -1777,10 +1777,18 @@ errors:
messageId: "SVC4660"
}
#---------SVC4661------------------------------
-# %1 - assetType
-# %2 - matching generic node type name
+# %1 - version
+# %2 - conformance level
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------------------------------
+# %1 - file name
+# %2 - parser error
+ TOSCA_PARSE_ERROR: {
+ code: 400,
+ message: "Error: Invalid TOSCA template in file %1. %2",
+ messageId: "SVC4662"
} \ No newline at end of file
diff --git a/catalog-be/src/main/webapp/WEB-INF/web.xml b/catalog-be/src/main/webapp/WEB-INF/web.xml
index 481cdd6a2c..4ff202e45f 100644
--- a/catalog-be/src/main/webapp/WEB-INF/web.xml
+++ b/catalog-be/src/main/webapp/WEB-INF/web.xml
@@ -41,7 +41,7 @@
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
- <param-value>org.openecomp.sdc.be.distribution.servlet, org.openecomp.sdc.be.externalapi.servlet</param-value>
+ <param-value>com.wordnik.swagger.jaxrs.json, org.openecomp.sdc.be.distribution.servlet, org.openecomp.sdc.be.externalapi.servlet</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>