diff options
Diffstat (limited to 'catalog-be/src')
36 files changed, 505 insertions, 543 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 e4c75eab05..61f0c02d10 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 @@ -619,7 +619,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } return Either.left(new ImmutablePair<String, byte[]>(csarArtifact.getArtifactName(), generated.left().value())); } - return downloadArtifact(csarArtifact); + return downloadArtifact(csarArtifact, component); } public Either<ImmutablePair<String, byte[]>, ResponseFormat> handleDownloadRequestById(String componentId, String artifactId, String userId, ComponentTypeEnum componentType, String parentId, String containerComponentType) { @@ -640,7 +640,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { if (artifactDefinition.getPayloadData() != null) { return Either.left(new ImmutablePair<String, byte[]>(artifactDefinition.getArtifactName(), artifactDefinition.getPayloadData())); } - return downloadArtifact(artifactDefinition); + return downloadArtifact(artifactDefinition, null); } public Either<Map<String, ArtifactDefinition>, ResponseFormat> handleGetArtifactsByType(String containerComponentType, String parentId, ComponentTypeEnum componentType, String componentId, String artifactGroupType, String userId) { @@ -1526,6 +1526,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { handleAuditing(auditingAction, parent, componentId, user, null, null, artifactId, responseFormat, componentType, null); return Either.right(responseFormat); } + Either<ArtifactDefinition, Operation> insideEither = Either.left(artifactDefinition); ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.OK); handleAuditing(auditingAction, parent, componentId, user, artifactDefinition, null, artifactId, responseFormat, componentType, null); @@ -3001,7 +3002,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } // Downloading the artifact - Either<ImmutablePair<String, byte[]>, ResponseFormat> downloadArtifactEither = downloadArtifact(deploymentArtifact); + Either<ImmutablePair<String, byte[]>, ResponseFormat> downloadArtifactEither = downloadArtifact(deploymentArtifact, null); if (downloadArtifactEither.isRight()) { log.debug("Download artifact {} failed", artifactName); return Either.right(downloadArtifactEither.right().value()); @@ -3062,7 +3063,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { log.debug("Found deployment artifact {}", artifactName); deployableArtifact = artifacts.values().stream().filter(filterArtifactByName).findFirst().get(); // Downloading the artifact - Either<ImmutablePair<String, byte[]>, ResponseFormat> downloadArtifactEither = downloadArtifact(deployableArtifact); + Either<ImmutablePair<String, byte[]>, ResponseFormat> downloadArtifactEither = downloadArtifact(deployableArtifact, service ); if (downloadArtifactEither.isRight()) { log.debug("Download artifact {} failed", artifactName); @@ -3167,7 +3168,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } log.debug("Found deployment artifact {}", normalizedArtifactName); // Downloading the artifact - Either<ImmutablePair<String, byte[]>, ResponseFormat> downloadArtifactEither = downloadArtifact(foundArtifactOptl.get()); + Either<ImmutablePair<String, byte[]>, ResponseFormat> downloadArtifactEither = downloadArtifact(foundArtifactOptl.get(), service); if (downloadArtifactEither.isRight()) { log.debug("Download artifact {} failed", normalizedArtifactName); return Either.right(downloadArtifactEither.right().value()); @@ -3190,7 +3191,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return Either.right(componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, "")); } - return downloadArtifact(artifactDefinition); + return downloadArtifact(artifactDefinition, null); } private boolean checkArtifactInComponent(org.openecomp.sdc.be.model.Component component, String artifactId) { @@ -3370,7 +3371,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return auditingAction; } - private Either<ImmutablePair<String, byte[]>, ResponseFormat> downloadArtifact(ArtifactDefinition artifactDefinition) { + private Either<ImmutablePair<String, byte[]>, ResponseFormat> downloadArtifact(ArtifactDefinition artifactDefinition, Component component) { String esArtifactId = artifactDefinition.getEsId(); Either<ESArtifactData, CassandraOperationStatus> artifactfromES = artifactCassandraDao.getArtifact(esArtifactId); if (artifactfromES.isRight()) { @@ -3378,7 +3379,10 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { 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, artifactDefinition.getArtifactDisplayName())); + ResponseFormat responseFormat = componentsUtils.getResponseFormatByArtifactId(actionStatus, artifactDefinition.getArtifactDisplayName()); + handleAuditing(AuditingActionEnum.DOWNLOAD_ARTIFACT, component, null, null, artifactDefinition, null, artifactDefinition.getArtifactUUID(), responseFormat, null, null); + + return Either.right(responseFormat); } ESArtifactData esArtifactData = artifactfromES.left().value(); @@ -3864,7 +3868,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } } } - currArtifact.setHeatParamsUpdateDate(System.currentTimeMillis()); + //currArtifact.setHeatParamsUpdateDate(System.currentTimeMillis()); currArtifact.setListHeatParameters(currentHeatEnvParams); Either<ArtifactDefinition, StorageOperationStatus> updateArifactRes = artifactToscaOperation.updateArifactOnResource(currArtifact, parent.getUniqueId(), currArtifact.getUniqueId(), componentType.getNodeType(), componentId); @@ -4776,7 +4780,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } if (errorWrapper.isEmpty()) { deploymentArtifact = artifactsList.get(0); - downloadArtifactEither = downloadArtifact(deploymentArtifact); + downloadArtifactEither = downloadArtifact(deploymentArtifact, null); if (downloadArtifactEither.isRight()) { log.debug("Failed to download artifact {}. ", deploymentArtifact.getArtifactName()); errorWrapper.setInnerElement(downloadArtifactEither.right().value()); 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 1d153e0a5d..5a4961b24f 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 @@ -20,12 +20,8 @@ package org.openecomp.sdc.be.components.impl; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - +import com.google.gson.JsonElement; +import fj.data.Either; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.config.BeEcompErrorManager; @@ -40,26 +36,15 @@ import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.impl.ComponentsUtils; -import org.openecomp.sdc.be.model.Component; -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; -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.*; import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache; import org.openecomp.sdc.be.model.jsontitan.operations.ArtifactsOperations; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; -import org.openecomp.sdc.be.model.operations.api.IAttributeOperation; import org.openecomp.sdc.be.model.operations.api.IElementOperation; import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation; import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation; import org.openecomp.sdc.be.model.operations.api.IGroupOperation; import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation; -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.DaoStatusConverter; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; @@ -80,9 +65,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import com.google.gson.JsonElement; - -import fj.data.Either; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.function.Function; public abstract class BaseBusinessLogic { 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 21f7b3ab7c..33180cd35e 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 @@ -905,11 +905,18 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic { } else { genericTypeToscaName = component.fetchGenericTypeToscaNameFromConfig(); } - if(null == genericTypeToscaName) + log.debug("Fetching generic tosca name {}", genericTypeToscaName); + if(null == genericTypeToscaName) { + log.debug("Failed to fetch certified node type by tosca resource name {}", genericTypeToscaName); return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)); + } + Either<Resource, StorageOperationStatus> findLatestGeneric = toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(genericTypeToscaName); - if(findLatestGeneric.isRight()) + if(findLatestGeneric.isRight()){ + log.debug("Failed to fetch certified node type by tosca resource name {}", genericTypeToscaName); return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType(), genericTypeToscaName)); + } + Resource genericTypeResource = findLatestGeneric.left().value(); component.setDerivedFromGenericInfo(genericTypeResource); return Either.left(genericTypeResource); 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 5b6488d788..6dc83bfc2b 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 @@ -401,6 +401,15 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic { return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(result))); } componentInstance.setDeploymentArtifacts(finalDeploymentArtifacts); + + + artStatus = toscaOperationFacade.addInformationalArtifactsToInstance(containerComponent.getUniqueId(), componentInstance, originComponent.getArtifacts()); + if ( artStatus != StorageOperationStatus.OK){ + log.debug("Failed to add informational artifacts to the instance {} belonging to the conatiner {}. Status is {}", componentInstance.getUniqueId(), containerComponent.getUniqueId(), artStatus); + return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponseForResourceInstance(artStatus, false))); + + } + componentInstance.setArtifacts(originComponent.getArtifacts()); return Either.left(ActionStatus.OK); } @@ -1828,23 +1837,23 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } return result; } + + public Either<ComponentInstance, ResponseFormat> deleteServiceProxy(String containerComponentType, String containerComponentId, String serviceProxyId, String userId) { + // TODO Add implementation + Either<ComponentInstance, ResponseFormat> result = Either.left(new ComponentInstance()); + return result; + } - private Boolean validateInstanceNameUniqueness(Component containerComponent, ComponentInstance oldComponentInstance, String newInstanceName) { - Boolean isUnique = true; - String newInstanceNormalizedName = ValidationUtils.normalizeComponentInstanceName(newInstanceName); - if (!oldComponentInstance.getNormalizedName().equals(newInstanceNormalizedName)) { - Optional<ComponentInstance> foundComponentInstance = containerComponent.getComponentInstances().stream().filter(ci -> ci.getNormalizedName().equals(newInstanceNormalizedName)).findFirst(); - if (foundComponentInstance.isPresent()) { - isUnique = false; - } - if (isUnique) { - foundComponentInstance = containerComponent.getComponentInstances().stream().filter(ci -> ci.getUniqueId().endsWith(newInstanceNormalizedName)).findFirst(); - if (foundComponentInstance.isPresent()) { - isUnique = false; - } - } - } - return isUnique; + public Either<ComponentInstance, ResponseFormat> createServiceProxy(String containerComponentType, String containerComponentId, String userId, ComponentInstance componentInstance) { + // TODO Add implementation + Either<ComponentInstance, ResponseFormat> result = Either.left(new ComponentInstance()); + return result; + } + + public Either<ComponentInstance, ResponseFormat> changeServiceProxyVersion(String containerComponentType, String containerComponentId, String serviceProxyId, String userId) { + // TODO Add implementation + Either<ComponentInstance, ResponseFormat> result = Either.left(new ComponentInstance()); + return result; } private Boolean validateInstanceNameUniquenessUponUpdate(Component containerComponent, ComponentInstance oldComponentInstance, String newInstanceName) { @@ -1889,12 +1898,11 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic { resourceInstanceForUpdate.setCustomizationUUID(origInstanceForUpdate.getCustomizationUUID()); - if (StringUtils.isEmpty(resourceInstanceForUpdate.getName())) { + if (StringUtils.isEmpty(resourceInstanceForUpdate.getName()) && StringUtils.isNotEmpty(origInstanceForUpdate.getName())) { resourceInstanceForUpdate.setName(origInstanceForUpdate.getName()); - } - if (StringUtils.isEmpty(resourceInstanceForUpdate.getNormalizedName())) - resourceInstanceForUpdate.setNormalizedName(origInstanceForUpdate.getNormalizedName()); + + resourceInstanceForUpdate.setNormalizedName(ValidationUtils.normalizeComponentInstanceName(resourceInstanceForUpdate.getName())); if (StringUtils.isEmpty(resourceInstanceForUpdate.getIcon())) resourceInstanceForUpdate.setIcon(origInstanceForUpdate.getIcon()); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java index 3dee3839b1..2de9eee217 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java @@ -20,15 +20,7 @@ package org.openecomp.sdc.be.components.impl; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -import javax.annotation.Resource; - +import fj.data.Either; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.components.impl.CommonImportManager.ElementTypeEnum; import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaTagNamesEnum; @@ -37,16 +29,21 @@ import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.GroupTypeDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation; -import org.openecomp.sdc.be.model.operations.api.IResourceOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; import org.openecomp.sdc.exception.ResponseFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import fj.data.Either; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; @Component("groupTypeImportManager") public class GroupTypeImportManager { @@ -69,13 +66,11 @@ public class GroupTypeImportManager { private static Logger log = LoggerFactory.getLogger(GroupTypeImportManager.class.getName()); @Resource - private PropertyOperation propertyOperation; - @Resource private IGroupTypeOperation groupTypeOperation; @Resource private ComponentsUtils componentsUtils; @Resource - private IResourceOperation resourceOperation; + private ToscaOperationFacade toscaOperationFacade; @Resource private CommonImportManager commonImportManager; @@ -103,7 +98,7 @@ public class GroupTypeImportManager { } else { for (String member : groupType.getMembers()) { // Verify that such Resource exist - Either<org.openecomp.sdc.be.model.Resource, StorageOperationStatus> eitherMemberExist = resourceOperation.getLatestByToscaResourceName(member, false); + Either<org.openecomp.sdc.be.model.Resource, StorageOperationStatus> eitherMemberExist = toscaOperationFacade.getLatestByToscaResourceName(member); if (eitherMemberExist.isRight()) { StorageOperationStatus operationStatus = eitherMemberExist.right().value(); log.debug("Error when fetching parent resource {}, error: {}", member, operationStatus); 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 838cd53458..1755d0b20c 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 @@ -21,12 +21,7 @@ package org.openecomp.sdc.be.components.impl; import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; import java.util.function.Consumer; import java.util.function.Function; @@ -61,22 +56,55 @@ public final class ImportUtils { private ImportUtils() { } - public static Yaml STRICT_MAPPING_YAML_LOADER = new YamlLoader().getStrictYamlLoader(); private static CustomResolver customResolver = new CustomResolver(); + private static Yaml STRICT_MAPPING_YAML_LOADER = new YamlLoader().getStrictYamlLoader(); private static class CustomResolver extends Resolver { - @Override + @Override protected void addImplicitResolvers() { - // avoid implicit resolvers for strings that can be interpreted as boolean values - addImplicitResolver(Tag.STR, EMPTY, ""); - addImplicitResolver(Tag.STR, NULL, null); - addImplicitResolver(Tag.NULL, NULL, "~nN\0"); - addImplicitResolver(Tag.NULL, EMPTY, null); - addImplicitResolver(Tag.YAML, YAML, "!&*"); + // avoid implicit resolvers for strings that can be interpreted as boolean values + addImplicitResolver(Tag.STR, EMPTY, ""); + addImplicitResolver(Tag.STR, NULL, null); + addImplicitResolver(Tag.NULL, NULL, "~nN\0"); + addImplicitResolver(Tag.NULL, EMPTY, null); + addImplicitResolver(Tag.INT, INT, "-+0123456789"); + addImplicitResolver(Tag.FLOAT, FLOAT, "-+0123456789."); + addImplicitResolver(Tag.YAML, YAML, "!&*"); } } - + + + private static void buildMap(Map<String, Object> output, Map<String, Object> map) { + for (Entry<String, Object> entry : map.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + if (value instanceof Map) { + Map<String, Object> result = new LinkedHashMap<>(); + buildMap(result, (Map) value); + output.put(key, result); + } + else if (value instanceof Collection) { + Map<String, Object> result = new LinkedHashMap<>(); + int i = 0; + for(Object item : (Collection<Object>) value) { + buildMap(result, Collections.singletonMap("[" + (i++) + "]", item)); + } + output.put(key, new ArrayList<>(result.values())); + } + else { + output.put(key, value); + } + } + } + + public static Map<String, Object> loadYamlAsStrictMap(String content){ + Map<String, Object> result = new LinkedHashMap<>(); + Object map = STRICT_MAPPING_YAML_LOADER.load(content); + buildMap(result, (Map<String, Object>)map); + return result; + } + private static class YamlLoader extends YamlProcessor { public Yaml getStrictYamlLoader() { return createYaml(); 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 f85e25e5fb..892da8af9d 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 @@ -1274,6 +1274,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic { input.setName(inputName + "_" + prop.getName()); } + input.setDefaultValue(prop.getValue()); input.setName(inputName); input.setUniqueId(UniqueIdBuilder.buildPropertyUniqueId(component.getUniqueId(), input.getName())); input.setInputPath(propertiesName); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyTypeImportManager.java index 1e0670daa2..7b55a6988e 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyTypeImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyTypeImportManager.java @@ -20,41 +20,36 @@ package org.openecomp.sdc.be.components.impl; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -import javax.annotation.Resource; - +import fj.data.Either; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.components.impl.CommonImportManager.ElementTypeEnum; import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaTagNamesEnum; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.PolicyTypeDefinition; +import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.IGroupOperation; import org.openecomp.sdc.be.model.operations.api.IPolicyTypeOperation; -import org.openecomp.sdc.be.model.operations.api.IResourceOperation; -import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import fj.data.Either; +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; @Component("policyTypeImportManager") public class PolicyTypeImportManager { @Resource - private PropertyOperation propertyOperation; - @Resource private IPolicyTypeOperation policyTypeOperation; @Resource private ComponentsUtils componentsUtils; - @Resource - private IResourceOperation resourceOperation; @Autowired protected IGroupOperation groupOperation; + @Autowired + private ToscaOperationFacade toscaOperationFacade; @Resource private CommonImportManager commonImportManager; @@ -82,7 +77,8 @@ public class PolicyTypeImportManager { } if (result.isLeft()) { for (String targetName : policyType.getTargets()) { - boolean isValid = resourceOperation.getLatestByToscaResourceName(targetName, false).isLeft(); + + boolean isValid = toscaOperationFacade.getLatestByToscaResourceName(targetName).isLeft();; if (!isValid) { isValid = groupOperation.isGroupExist(targetName, false); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java index 96f7eec2d8..da64f3f5b7 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ProductBusinessLogic.java @@ -43,7 +43,6 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.ICacheMangerOperation; import org.openecomp.sdc.be.model.operations.api.IElementOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.openecomp.sdc.be.model.operations.impl.ProductOperation; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; 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 7f73dc405c..833e6c0b9e 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 @@ -20,16 +20,11 @@ package org.openecomp.sdc.be.components.impl; -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; -import java.util.function.Supplier; - -import javax.servlet.ServletContext; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.reflect.TypeToken; +import fj.data.Either; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.config.BeEcompErrorManager; @@ -38,7 +33,6 @@ import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; -import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.impl.WebAppContextWrapper; import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.IComplexDefaultValue; @@ -46,12 +40,8 @@ import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.PropertyDefinition; 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.IElementOperation; -import org.openecomp.sdc.be.model.operations.api.IResourceOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter; -import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintDeserialiser; import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; @@ -61,20 +51,20 @@ import org.openecomp.sdc.be.model.tosca.validators.PropertyTypeValidator; import org.openecomp.sdc.be.resources.data.EntryData; import org.openecomp.sdc.be.resources.data.PropertyData; import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.common.config.EcompErrorName; import org.openecomp.sdc.exception.ResponseFormat; 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.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.reflect.TypeToken; - -import fj.data.Either; +import javax.servlet.ServletContext; +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; +import java.util.function.Supplier; @Component("propertyBusinessLogic") public class PropertyBusinessLogic extends BaseBusinessLogic { @@ -87,9 +77,6 @@ public class PropertyBusinessLogic extends BaseBusinessLogic { private DataTypeValidatorConverter dataTypeValidatorConverter = DataTypeValidatorConverter.getInstance(); - @javax.annotation.Resource - private IResourceOperation resourceOperation = null; - protected static IElementOperation getElementDao(Class<IElementOperation> class1, ServletContext context) { WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) context.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RequirementsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RequirementsBusinessLogic.java index f8dde98010..bd7e810066 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RequirementsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/RequirementsBusinessLogic.java @@ -20,23 +20,11 @@ package org.openecomp.sdc.be.components.impl; -import org.openecomp.sdc.be.config.BeEcompErrorManager; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.impl.ComponentsUtils; -import org.openecomp.sdc.be.model.RequirementDefinition; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.operations.api.IResourceOperation; -import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils; -import org.openecomp.sdc.common.config.EcompErrorName; -import org.openecomp.sdc.exception.ResponseFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import fj.data.Either; - @Component("requirementsBusinessLogic") public class RequirementsBusinessLogic { private static Logger log = LoggerFactory.getLogger(RequirementsBusinessLogic.class.getName()); @@ -47,48 +35,5 @@ public class RequirementsBusinessLogic { @javax.annotation.Resource private ResourceBusinessLogic resourceBusinessLogic; - @javax.annotation.Resource - private IResourceOperation resourceOperation; - - public Either<RequirementDefinition, ResponseFormat> updateRequirement(String resourceId, String requirementId, RequirementDefinition requirementDefinition, String userId) { - - // Get the resource from DB - Either<Resource, StorageOperationStatus> status = getResource(resourceId); - if (status.isRight()) { - log.debug("Couldn't get resource {} from DB", resourceId); - return Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(status.right().value()), "")); - } - Resource resource = status.left().value(); - if (resource == null) { - BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeResourceMissingError, "Requirement Business Logic", resourceId); - BeEcompErrorManager.getInstance().logBeComponentMissingError("Requirement Business Logic", ComponentTypeEnum.RESOURCE.getValue(), resourceId); - log.debug("Couldn't get resource {} from DB", resourceId); - return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)); - } - // verify that resource is checked-out and the user is the last updater - if (!ComponentValidationUtils.canWorkOnResource(resource, userId)) { - return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION)); - } - - // TODO - return null; - } - - private Either<Resource, StorageOperationStatus> getResource(final String resourceId) { - - log.debug("Get resource with id {}", resourceId); - Either<Resource, StorageOperationStatus> status = resourceOperation.getResource(resourceId); - if (status.isRight()) { - log.debug("Resource with id {} was not found", resourceId); - return Either.right(status.right().value()); - } - - Resource resource = status.left().value(); - if (resource == null) { - log.debug("General Error while get resource with id {}", resourceId); - return Either.right(StorageOperationStatus.GENERAL_ERROR); - } - return Either.left(resource); - } } 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 0aa4a6f006..383f1eb2ec 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 @@ -154,6 +154,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import fj.data.Either; +import org.yaml.snakeyaml.parser.ParserException; @org.springframework.stereotype.Component("resourceBusinessLogic") public class ResourceBusinessLogic extends ComponentBusinessLogic { @@ -686,7 +687,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { return result; } - 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) { Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = CsarUtils.extractVfcsArtifactsFromCsar(csar); @@ -695,8 +695,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { try { nodeTypesArtifactsToHandleRes = Either.left(nodeTypesArtifactsToHandle); - Map<String, String> extractedVfcToscaNames = extractVfcToscaNames(nodeTypesInfo, yamlFileName, oldResource.getSystemName()); - Either<EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>, ResponseFormat> curNodeTypeArtifactsToHandleRes = null; + Map<String, String> extractedVfcToscaNames = extractVfcToscaNames(nodeTypesInfo, yamlFileName, oldResource.getName()); + Either<EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>, ResponseFormat> curNodeTypeArtifactsToHandleRes; 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); @@ -957,9 +957,13 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { log.trace("YAML topology file found in CSAR, file name: {}, contents: {}", yamlFileName, yamlFileContents); Map<String, NodeTypeInfo> nodeTypesInfo = extractNodeTypesInfo(csar.left().value(), yamlFileContents); - Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = findNodeTypeArtifactsToCreate(csar.left().value(), resource); CsarInfo csarInfo = new CsarInfo(resource.getName(), user, csarUUID, csar.left().value(), false); - Either<Resource, ResponseFormat> createResourceFromYaml = createResourceFromYaml(resource, yamlFileContents, yamlFileName, nodeTypesInfo, csarInfo, nodeTypesArtifactsToCreate, true, false, null); + Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandleRes = findNodeTypesArtifactsToHandle(nodeTypesInfo, csarInfo.getCsar(), csarInfo.getCsarUUID(), yamlFileName, resource, csarInfo.getModifier()); + if (findNodeTypesArtifactsToHandleRes.isRight()) { + log.debug("failed to find node types for update with artifacts during import csar {}. ", csarInfo.getCsarUUID()); + return Either.right(findNodeTypesArtifactsToHandleRes.right().value()); + } + Either<Resource, ResponseFormat> createResourceFromYaml = createResourceFromYaml(resource, yamlFileContents, yamlFileName, nodeTypesInfo, csarInfo, findNodeTypesArtifactsToHandleRes.left().value(), true, false, null); if (createResourceFromYaml.isRight()) { log.debug("Couldn't create resource from YAML"); return Either.right(createResourceFromYaml.right().value()); @@ -1216,14 +1220,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { } if(result == null){ newComplexVfc = buildCvfcRes.left().value(); - if(csarInfo.isUpdate()){ - Either<Resource, StorageOperationStatus> oldComplexVfcRes = toscaOperationFacade.getLatestByToscaResourceName(newComplexVfc.getToscaResourceName()); - if(oldComplexVfcRes.isRight() && oldComplexVfcRes.right().value() != StorageOperationStatus.NOT_FOUND){ - log.debug("Failed to fetch previous complex VFC by tosca resource name {}. Status is {}. ", newComplexVfc.getToscaResourceName(), oldComplexVfcRes.right().value()); - result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)); - } else if(oldComplexVfcRes.isLeft()){ - oldComplexVfc = oldComplexVfcRes.left().value(); - } + Either<Resource, StorageOperationStatus> oldComplexVfcRes = toscaOperationFacade.getLatestByToscaResourceName(newComplexVfc.getToscaResourceName()); + if(oldComplexVfcRes.isRight() && oldComplexVfcRes.right().value() != StorageOperationStatus.NOT_FOUND){ + log.debug("Failed to fetch previous complex VFC by tosca resource name {}. Status is {}. ", newComplexVfc.getToscaResourceName(), oldComplexVfcRes.right().value()); + result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)); + } else if(oldComplexVfcRes.isLeft()){ + oldComplexVfc = oldComplexVfcRes.left().value(); } } if(result == null){ @@ -1417,7 +1419,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { cvfc.setVendorName(resourceVf.getVendorName()); cvfc.setVendorRelease(resourceVf.getVendorRelease()); cvfc.setResourceVendorModelNumber(resourceVf.getResourceVendorModelNumber()); - cvfc.setToscaResourceName(buildNestedToscaResourceName(ResourceTypeEnum.VFC.name(), csarInfo.getVfResourceName(), nodeName)); + cvfc.setToscaResourceName(buildNestedToscaResourceName(ResourceTypeEnum.CVFC.name(), csarInfo.getVfResourceName(), nodeName)); cvfc.setInvariantUUID(UniqueIdBuilder.buildInvariantUUID()); List<String> tags = new ArrayList<>(); @@ -1889,18 +1891,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { return result; } - private Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> findNodeTypeArtifactsToCreate(Map<String, byte[]> csar, Resource resource) { - - Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = CsarUtils.extractVfcsArtifactsFromCsar(csar); - 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; - } - private void handleAndAddExtractedVfcsArtifacts(List<ArtifactDefinition> vfcArtifacts, List<ArtifactDefinition> artifactsToAdd) { List<String> vfcArtifactNames = vfcArtifacts.stream().map(a -> a.getArtifactName()).collect(Collectors.toList()); artifactsToAdd.stream().forEach(a -> { @@ -3348,7 +3338,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { resStatus = Either.right(responseFormat); return resStatus; } - currHeatParam.setCurrentValue(HeatParameterType.isValidType(currHeatParam.getType()).getConverter().convert(updatedParamValue, null, null)); + currHeatParam.setCurrentValue(paramType.getConverter().convert(updatedParamValue, null, null)); // newHeatEnvParams.add(currHeatParam); break; } @@ -3558,6 +3548,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>(); Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties = new HashMap<>(); Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>(); + Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>(); Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>(); Map<String, List<PropertyDefinition>> instAttributes = new HashMap<>(); Map<String, Resource> originCompMap = new HashMap<>(); @@ -3566,10 +3557,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>(); for (Entry<String, UploadComponentInstanceInfo> entry : uploadResInstancesMap.entrySet()) { + log.trace("Processing entry: {}", entry); UploadComponentInstanceInfo uploadComponentInstanceInfo = entry.getValue(); ComponentInstance currentCompInstance = null; for (ComponentInstance compInstance : componentInstancesList) { - + log.trace("Processing component instance: {}", compInstance); if (compInstance.getName().equals(uploadComponentInstanceInfo.getName())) { currentCompInstance = compInstance; break; @@ -3629,7 +3621,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { instRequirements.put(currentCompInstance, originRequirements); } if (originResource.getDeploymentArtifacts() != null && !originResource.getDeploymentArtifacts().isEmpty()) - instArtifacts.put(resourceInstanceId, originResource.getDeploymentArtifacts()); + instDeploymentArtifacts.put(resourceInstanceId, originResource.getDeploymentArtifacts()); + if (originResource.getArtifacts() != null && !originResource.getArtifacts().isEmpty()) + instArtifacts.put(resourceInstanceId, originResource.getArtifacts()); if (originResource.getAttributes() != null && !originResource.getAttributes().isEmpty()) instAttributes.put(resourceInstanceId, originResource.getAttributes()); if (originResource.getResourceType() != ResourceTypeEnum.CVFC) { @@ -3667,7 +3661,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { return Either.right(responseFormat); } } - StorageOperationStatus addArtToInst = toscaOperationFacade.associateArtifactToInstances(instArtifacts, resource.getUniqueId(), user); + StorageOperationStatus addArtToInst = toscaOperationFacade.associateDeploymentArtifactsToInstances(instDeploymentArtifacts, resource.getUniqueId(), user); + if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) { + log.debug("failed to associate artifact of resource {} status is {}", resource.getUniqueId(), addArtToInst); + ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName); + return Either.right(responseFormat); + } + + addArtToInst = toscaOperationFacade.associateArtifactsToInstances(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); ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName); @@ -4212,7 +4213,15 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { mappedToscaTemplate = nodeTypesInfo.get(nodeName).getMappedToscaTemplate(); } else { - mappedToscaTemplate = (Map<String, Object>) new Yaml().load(resourceYml); + try { + //DE154502 Fail if duplicate key found in file + mappedToscaTemplate = ImportUtils.loadYamlAsStrictMap(resourceYml); + + } catch(ParserException e) { + log.error("Failed to load yaml file {}", yamlFileName, e); + ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.TOSCA_PARSE_ERROR, yamlFileName, e.getMessage()); + return Either.right(responseFormat); + } } Either<Object, ResultStatusEnum> toscaElementEither = ImportUtils.findToscaElement(mappedToscaTemplate, ToscaTagNamesEnum.TOPOLOGY_TEMPLATE, ToscaElementTypeEnum.ALL); if (toscaElementEither.isRight()) { @@ -5573,10 +5582,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { // IResourceOperation dataModel = getResourceOperation(); Either<Resource, StorageOperationStatus> storageStatus = toscaOperationFacade.getToscaElement(resourceId); - if (storageStatus.isRight()) { log.debug("failed to get resource by id {}", resourceId); - return Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageStatus.right().value()), "")); + return Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageStatus.right().value()), resourceId)); + } + if(!(storageStatus.left().value() instanceof Resource)){ + return Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND), resourceId)); } return Either.left(storageStatus.left().value()); @@ -6807,14 +6818,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { try { if (groupTemplateJson != null && groupTemplateJson instanceof Map) { Map<String, Object> groupTemplateJsonMap = (Map<String, Object>) groupTemplateJson; - // Type - String groupType = null; - if (groupTemplateJsonMap.containsKey(ToscaTagNamesEnum.TYPE.getElementName())) { - groupType = (String) groupTemplateJsonMap.get(ToscaTagNamesEnum.TYPE.getElementName()); + String groupType = (String) groupTemplateJsonMap.get(ToscaTagNamesEnum.TYPE.getElementName()); + if (!StringUtils.isEmpty(groupType)) { groupInfo.setType(groupType); } else { log.debug("The 'type' member is not found under group {}", groupName); - result = Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE)); + return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_MISSING_GROUP_TYPE, groupName)); } if (groupTemplateJsonMap.containsKey(ToscaTagNamesEnum.DESCRIPTION.getElementName())) { @@ -6832,8 +6841,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { } groupInfo.setMembers(membersLoaded); } else { - log.debug("The 'type' member is not found under group {}", groupName); - result = Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE)); + log.debug("The 'members' member is not of type list under group {}", groupName); + return Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE)); } } } @@ -6873,7 +6882,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { Either<GroupTypeDefinition, StorageOperationStatus> groupTypeRes = groupTypeOperation.getLatestGroupTypeByType(groupType, true); if (groupTypeRes.isRight()) { - return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_MISSING_GROUP_TYPE, groupType)); + return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_TYPE_IS_INVALID, groupType)); } Map<String, PropertyDefinition> gtProperties = new HashMap<>(); @@ -7067,6 +7076,15 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { private String buildNestedToscaResourceName(String nodeResourceType, String vfResourceName, String nodeTypeFullName) { + String actualType; + String actualVfName; + if(ResourceTypeEnum.CVFC.name().equals(nodeResourceType)){ + actualVfName = vfResourceName + ResourceTypeEnum.CVFC.name(); + actualType = ResourceTypeEnum.VFC.name(); + } else { + actualVfName = vfResourceName; + actualType = nodeResourceType; + } StringBuilder toscaResourceName = new StringBuilder(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX); String nameWithouNamespacePrefix = nodeTypeFullName.substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length()); String[] findTypes = nameWithouNamespacePrefix.split("\\."); @@ -7074,9 +7092,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { String actualName = nameWithouNamespacePrefix.substring(resourceType.length()); if (actualName.startsWith(Constants.ABSTRACT)) { - toscaResourceName.append(resourceType.toLowerCase()).append('.').append(ValidationUtils.convertToSystemName(vfResourceName)); + toscaResourceName.append(resourceType.toLowerCase()).append('.').append(ValidationUtils.convertToSystemName(actualVfName)); } else { - toscaResourceName.append(nodeResourceType.toLowerCase()).append('.').append(ValidationUtils.convertToSystemName(vfResourceName)).append('.').append(Constants.ABSTRACT); + toscaResourceName.append(actualType.toLowerCase()).append('.').append(ValidationUtils.convertToSystemName(actualVfName)).append('.').append(Constants.ABSTRACT); } return toscaResourceName.append(actualName.toLowerCase()).toString(); } 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 ac6183db00..b21195ff42 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 @@ -20,22 +20,7 @@ package org.openecomp.sdc.be.components.impl; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.function.Function; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -import javax.servlet.ServletContext; - +import fj.data.Either; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.auditing.api.IAuditingManager; @@ -53,24 +38,13 @@ 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.impl.WebAppContextWrapper; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.ComponentInstanceProperty; -import org.openecomp.sdc.be.model.CsarInfo; -import org.openecomp.sdc.be.model.InterfaceDefinition; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.PropertyDefinition; -import org.openecomp.sdc.be.model.RequirementDefinition; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.UploadResourceInfo; -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.SubCategoryDefinition; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; 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.CapabilityTypeOperation; -import org.openecomp.sdc.be.model.operations.impl.ResourceOperation; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.common.config.EcompErrorName; import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; @@ -83,7 +57,20 @@ import org.springframework.stereotype.Component; import org.springframework.web.context.WebApplicationContext; import org.yaml.snakeyaml.Yaml; -import fj.data.Either; +import javax.servlet.ServletContext; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.function.Function; +import java.util.regex.Pattern; +import java.util.stream.Collectors; @Component("resourceImportManager") public class ResourceImportManager { @@ -102,9 +89,6 @@ public class ResourceImportManager { @Autowired protected ComponentsUtils componentsUtils; - @Autowired - protected ResourceOperation resourceOperation; - public final static Pattern PROPERTY_NAME_PATTERN_IGNORE_LENGTH = Pattern .compile("[\\w\\-\\_\\d\\:]+"); @Autowired @@ -963,8 +947,5 @@ public class ResourceImportManager { this.auditingManager = auditingManager; } - public void setResourceOperation(ResourceOperation resourceOperation) { - this.resourceOperation = resourceOperation; - } } 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 ae7ae31ed9..85db9a2c0f 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 @@ -1144,17 +1144,22 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic { if (eitherCreator.isRight()) { return Either.right(eitherCreator.right().value()); } - user = eitherCreator.left().value(); Either<Service, StorageOperationStatus> storageStatus = toscaOperationFacade.getToscaElement(serviceId); if (storageStatus.isRight()) { log.debug("failed to get service by id {}", serviceId); return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(storageStatus.right().value(), ComponentTypeEnum.SERVICE), serviceId)); } - // Service service = - // createServiceApiArtifactLIst(storageStatus.left().value()); + + if(!(storageStatus.left().value() instanceof Service)){ + return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND), serviceId)); + } Service service = storageStatus.left().value(); return Either.left(service); + + + + } public Either<Service, ResponseFormat> getServiceByNameAndVersion(String serviceName, String serviceVersion, String userId) { 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 11ffcd9329..d1cc93acc8 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 @@ -22,12 +22,8 @@ package org.openecomp.sdc.be.components.impl; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; -import org.openecomp.sdc.be.model.operations.impl.ComponentOperation; -import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.stereotype.Component; -import fj.data.Either; - @Component("serviceComponentInstanceBusinessLogic") public class ServiceComponentInstanceBusinessLogic extends ComponentInstanceBusinessLogic { 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 b18c4d0985..d12afdbd55 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 @@ -20,18 +20,8 @@ package org.openecomp.sdc.be.components.lifecycle; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; -import java.util.Set; - -import org.apache.commons.codec.binary.Base64; +import fj.data.Either; import org.openecomp.sdc.be.components.distribution.engine.ServiceDistributionArtifactsBuilder; -import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic; import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic; import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic; import org.openecomp.sdc.be.config.BeEcompErrorManager; @@ -42,40 +32,30 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.impl.ComponentsUtils; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.CapabilityDefinition; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentInstance; -import org.openecomp.sdc.be.model.LifeCycleTransitionEnum; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Operation; -import org.openecomp.sdc.be.model.RequirementAndRelationshipPair; -import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; -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.*; 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; -import org.openecomp.sdc.be.model.operations.api.ILifecycleOperation; 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.ResourceOperation; 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; import org.openecomp.sdc.exception.ResponseFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import fj.data.Either; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.Set; public class CertificationRequestTransition extends LifeCycleTransition { @@ -326,47 +306,6 @@ public class CertificationRequestTransition extends LifeCycleTransition { return Either.left(true); } - private Either<Boolean, ResponseFormat> parseRelationsForReqCapVerification(Component component, Map<String, List<String>> reqName2Ids, Map<String, List<String>> capName2Ids) { - log.debug("Submit for testing validation - Preparing relations for inner atomic instances validation"); - List<RequirementCapabilityRelDef> componentInstancesRelations = component.getComponentInstancesRelations(); - if (componentInstancesRelations != null) { - for (RequirementCapabilityRelDef reqCapRelDef : componentInstancesRelations) { - List<RequirementAndRelationshipPair> relationships = reqCapRelDef.getRelationships(); - if (relationships != null) { - for (RequirementAndRelationshipPair reqRelPair : relationships) { - String capUniqueId = reqRelPair.getCapabilityUid(); - Either<CapabilityDefinition, StorageOperationStatus> capability = capabilityOperation.getCapability(capUniqueId); - if (capability.isRight()) { - log.error("Couldn't fetch capability by id {}", capUniqueId); - return Either.right(componentUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)); - } - String reqCapType = capability.left().value().getType(); - String capabilityOwnerId = reqRelPair.getCapabilityOwnerId(); - String requirementOwnerId = reqRelPair.getRequirementOwnerId(); - // Update req - List<String> reqIds = reqName2Ids.get(reqCapType); - if (reqIds == null) { - reqIds = new ArrayList<>(); - reqName2Ids.put(reqCapType, reqIds); - } - reqIds.add(requirementOwnerId); - // Update cap - List<String> capIds = capName2Ids.get(reqCapType); - if (capIds == null) { - capIds = new ArrayList<>(); - capName2Ids.put(reqCapType, capIds); - } - capIds.add(capabilityOwnerId); - } - } - } - log.debug("Parsed req for validation: {}, parsed cap for validation: {}", reqName2Ids, capName2Ids); - } else { - log.debug("There are no relations found for component {}", component.getUniqueId()); - } - return Either.left(true); - } - @Override public Either<Boolean, ResponseFormat> validateBeforeTransition(Component component, ComponentTypeEnum componentType, User modifier, User owner, LifecycleStateEnum oldState, LifecycleChangeInfoWithAction lifecycleChangeInfo) { String componentName = component.getComponentMetadataDefinition().getMetadataDataDefinition().getName(); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifeCycleTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifeCycleTransition.java index 0d0e06fe6d..cc534bb694 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifeCycleTransition.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifeCycleTransition.java @@ -39,7 +39,6 @@ import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementLifecycleOperation; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; -import org.openecomp.sdc.be.model.operations.api.ILifecycleOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.user.Role; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/StartCertificationTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/StartCertificationTransition.java index 8a80e0bb64..24266521c2 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/StartCertificationTransition.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/StartCertificationTransition.java @@ -20,15 +20,12 @@ package org.openecomp.sdc.be.components.lifecycle; -import java.util.Arrays; - -import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic; +import fj.data.Either; import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic; import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.jsongraph.TitanDao; 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.impl.ComponentsUtils; import org.openecomp.sdc.be.model.Component; @@ -39,7 +36,6 @@ 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.ILifecycleOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.user.Role; @@ -47,7 +43,7 @@ import org.openecomp.sdc.exception.ResponseFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import fj.data.Either; +import java.util.Arrays; public class StartCertificationTransition extends LifeCycleTransition { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/listen/BEAppContextListener.java b/catalog-be/src/main/java/org/openecomp/sdc/be/listen/BEAppContextListener.java index 436b2319e9..fa31989d87 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/listen/BEAppContextListener.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/listen/BEAppContextListener.java @@ -20,19 +20,9 @@ package org.openecomp.sdc.be.listen; -import java.io.IOException; -import java.io.InputStream; -import java.util.jar.Attributes; -import java.util.jar.Manifest; - -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; - import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.impl.DownloadArtifactLogic; import org.openecomp.sdc.be.impl.WebAppContextWrapper; -import org.openecomp.sdc.be.model.operations.api.IResourceOperation; import org.openecomp.sdc.be.monitoring.BeMonitoringService; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.impl.ExternalConfiguration; @@ -41,6 +31,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import java.io.IOException; +import java.io.InputStream; +import java.util.jar.Attributes; +import java.util.jar.Manifest; + public class BEAppContextListener extends AppContextListener implements ServletContextListener { private static final String MANIFEST_FILE_NAME = "/META-INF/MANIFEST.MF"; @@ -71,11 +69,6 @@ public class BEAppContextListener extends AppContextListener implements ServletC } - private IResourceOperation getResourceOperationManager(Class<? extends IResourceOperation> clazz, WebApplicationContext webContext) { - - return webContext.getBean(clazz); - } - private String getVersionFromManifest(ServletContextEvent context) { ServletContext servletContext = context.getServletContext(); InputStream inputStream = servletContext.getResourceAsStream(MANIFEST_FILE_NAME); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.java b/catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.java index 34a56cdd13..6be300d6db 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.java @@ -74,7 +74,8 @@ public class EsGateway extends ProxyServlet { esPort = monitoringBL.getEsPort(); } - String scheme = request.getScheme(); + //String scheme = request.getScheme(); esGateway HTTP + String scheme = "http"; String contextPath = request.getContextPath(); // /mywebapp String servletPath = request.getServletPath(); // /servlet/MyServlet String pathInfo = request.getPathInfo(); // /a/b;c=123 diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java index d7db4ec3a3..a89d8b109b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java @@ -880,6 +880,120 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { } + @POST + @Path("/{containerComponentType}/{containerComponentId}/serviceProxy") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Create service proxy", httpMethod = "POST", notes = "Returns created service proxy", response = Response.class) + @ApiResponses(value = { @ApiResponse(code = 201, message = "Service proxy created"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 400, message = "Invalid content / Missing content"), + @ApiResponse(code = 409, message = "Service proxy already exist") }) + public Response createServiceProxy(@ApiParam(value = "RI object to be created", required = true) String data, @PathParam("containerComponentId") final String containerComponentId, + @ApiParam(value = "valid values: resources / services", allowableValues = ComponentTypeEnum.RESOURCE_PARAM_NAME + "," + ComponentTypeEnum.SERVICE_PARAM_NAME) @PathParam("containerComponentType") final String containerComponentType, + @HeaderParam(value = Constants.USER_ID_HEADER) @ApiParam(value = "USER_ID of modifier user", required = true) String userId, @Context final HttpServletRequest request) { + ServletContext context = request.getSession().getServletContext(); + + try { + + ComponentInstance componentInstance = RepresentationUtils.fromRepresentation(data, ComponentInstance.class); + componentInstance.setInvariantName(null); + ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); + if(componentTypeEnum != ComponentTypeEnum.SERVICE){ + log.debug("Unsupported container component type {}", containerComponentType); + return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); + } + ComponentInstanceBusinessLogic componentInstanceLogic = getComponentInstanceBL(context, componentTypeEnum); + if (componentInstanceLogic == null) { + log.debug("Unsupported component type {}", containerComponentType); + return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); + } + Either<ComponentInstance, ResponseFormat> actionResponse = componentInstanceLogic.createServiceProxy(containerComponentType, containerComponentId, userId, componentInstance); + + if (actionResponse.isRight()) { + return buildErrorResponse(actionResponse.right().value()); + } + return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.CREATED), actionResponse.left().value()); + + } catch (Exception e) { + BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Create service proxy"); + log.debug("Create service proxy failed with exception", e); + return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)); + } + } + + @DELETE + @Path("/{containerComponentType}/{containerComponentId}/serviceProxy/{serviceProxyId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Delete service proxy", httpMethod = "DELETE", notes = "Returns delete service proxy", response = Response.class) + @ApiResponses(value = { @ApiResponse(code = 201, message = "Service proxy deleted"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 400, message = "Invalid content / Missing content") }) + public Response deleteServiceProxy(@PathParam("containerComponentId") final String containerComponentId, @PathParam("serviceProxyId") final String serviceProxyId, + @ApiParam(value = "valid values: resources / services / products", allowableValues = ComponentTypeEnum.RESOURCE_PARAM_NAME + "," + ComponentTypeEnum.SERVICE_PARAM_NAME + "," + + ComponentTypeEnum.PRODUCT_PARAM_NAME) @PathParam("containerComponentType") final String containerComponentType, + @Context final HttpServletRequest request) { + ServletContext context = request.getSession().getServletContext(); + String url = request.getMethod() + " " + request.getRequestURI(); + Response response = null; + try { + log.debug("Start handle request of {}", url); + ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); + ComponentInstanceBusinessLogic componentInstanceLogic = getComponentInstanceBL(context, componentTypeEnum); + if (componentInstanceLogic == null) { + log.debug("Unsupported component type {}", containerComponentType); + return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); + } + String userId = request.getHeader(Constants.USER_ID_HEADER); + Either<ComponentInstance, ResponseFormat> actionResponse = componentInstanceLogic.deleteServiceProxy(containerComponentType, containerComponentId, serviceProxyId, userId); + + if (actionResponse.isRight()) { + response = buildErrorResponse(actionResponse.right().value()); + } else { + response = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.NO_CONTENT), null); + } + return response; + } catch (Exception e) { + BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Delete service proxy"); + log.debug("Delete service proxy failed with exception", e); + return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)); + } + } + + @POST + @Path("/{containerComponentType}/{containerComponentId}/serviceProxy/{serviceProxyId}/changeVersion/{newServiceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Update service proxy with new version", httpMethod = "POST", notes = "Returns updated service proxy", response = Response.class) + @ApiResponses(value = { @ApiResponse(code = 201, message = "Service proxy created"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 400, message = "Invalid content / Missing content") }) + public Response changeServiceProxyVersion(@PathParam("containerComponentId") final String containerComponentId, @PathParam("serviceProxyId") final String serviceProxyId, + @ApiParam(value = "valid values: resources / services", allowableValues = ComponentTypeEnum.RESOURCE_PARAM_NAME + "," + ComponentTypeEnum.SERVICE_PARAM_NAME) @PathParam("containerComponentType") final String containerComponentType, + @Context final HttpServletRequest request) { + ServletContext context = request.getSession().getServletContext(); + + String url = request.getMethod() + " " + request.getRequestURI(); + log.debug("Start handle request of {}", url); + try { + + String userId = request.getHeader(Constants.USER_ID_HEADER); + + ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); + ComponentInstanceBusinessLogic componentInstanceLogic = getComponentInstanceBL(context, componentTypeEnum); + if (componentInstanceLogic == null) { + log.debug("Unsupported component type {}", containerComponentType); + return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); + } + Either<ComponentInstance, ResponseFormat> actionResponse = componentInstanceLogic.changeServiceProxyVersion(containerComponentType, containerComponentId, serviceProxyId, userId); + + if (actionResponse.isRight()) { + return buildErrorResponse(actionResponse.right().value()); + } + return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), actionResponse.left().value()); + + } catch (Exception e) { + BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Update service proxy with new version"); + log.debug("Update service proxy with new version failed with exception", e); + return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)); + } + } + private Either<ComponentInstance, ResponseFormat> convertToResourceInstance(String data) { // Either<ComponentInstance, ActionStatus> convertStatus = diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java index 22943bccea..2e961f294b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java @@ -20,6 +20,7 @@ package org.openecomp.sdc.be.servlets; +import java.lang.reflect.Type; import java.util.Map; import javax.inject.Singleton; @@ -39,7 +40,9 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.impl.WebAppContextWrapper; import org.openecomp.sdc.be.model.DataTypeDefinition; +import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintSerialiser; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.config.EcompErrorName; import org.openecomp.sdc.common.datastructure.Wrapper; @@ -48,6 +51,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; import com.jcabi.aspects.Loggable; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -95,9 +101,12 @@ public class TypesFetchServlet extends AbstractValidationsServlet { // return buildErrorResponse(allDataTypes.right().value()); } else { + Map<String, DataTypeDefinition> dataTypes = allDataTypes.left().value(); - Response okResponse = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), dataTypes); + String dataTypeJson = gson.toJson(dataTypes); + Response okResponse = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), dataTypeJson); responseWrapper.setInnerElement(okResponse); + } } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java index 3fd5297439..6c4c5fafe1 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java @@ -122,7 +122,7 @@ public class CapabiltyRequirementConvertor { if (prop.getSchema() != null && prop.getSchema().getProperty() != null) { innerType = prop.getSchema().getProperty().getType(); } - Object convertedValue = PropertyConvertor.getInstance().convertToToscaObject(propertyType, prop.getName(), prop.getValue(), innerType, dataTypes); + Object convertedValue = PropertyConvertor.getInstance().convertToToscaObject(propertyType, prop.getValue(), innerType, dataTypes); return convertedValue; } @@ -183,9 +183,19 @@ public class CapabiltyRequirementConvertor { if (requirements != null) { for (Map.Entry<String, List<RequirementDefinition>> entry : requirements.entrySet()) { entry.getValue().stream().forEach(r -> { - String fullReqName = getRequirementPath(r); + String fullReqName; + String sourceCapName; + if(ToscaUtils.isComplexVfc(component)){ + fullReqName = r.getName(); + sourceCapName = getSourceCvfcDataTypeName(r.getName(), r.getOwnerName()); + } else { + fullReqName = getRequirementPath(r); + sourceCapName = getSubPathByFirstDelimiterAppearance(fullReqName); + } log.debug("the requirement {} belongs to resource {} ", fullReqName, component.getUniqueId()); - toscaRequirements.put(fullReqName, new String[]{r.getOwnerName(), getSubPathByFirstDelimiterAppearance(fullReqName)}); + if(sourceCapName!= null){ + toscaRequirements.put(fullReqName, new String[]{r.getOwnerName(), sourceCapName}); + } }); log.debug("Finish convert Requirements for node type"); } @@ -195,6 +205,13 @@ public class CapabiltyRequirementConvertor { return toscaRequirements; } + private String getSourceCvfcDataTypeName(String name, String ownerName) { + if(name.contains(ownerName)){ + return name.substring(0, name.length() - ownerName.length() - 1); + } + return null; + } + private String getRequirementPath(RequirementDefinition r) { List<String> pathArray = Lists.reverse(r.getPath().stream() .map(path -> ValidationUtils.normalizeComponentInstanceName(getSubPathByLastDelimiterAppearance(path))) @@ -254,9 +271,19 @@ public class CapabiltyRequirementConvertor { if (capabilities != null) { for (Map.Entry<String, List<CapabilityDefinition>> entry : capabilities.entrySet()) { entry.getValue().stream().forEach(c -> { - String fullCapName = getCapabilityPath(c); + String fullCapName; + String sourceReqName; + if(ToscaUtils.isComplexVfc(component)){ + fullCapName = c.getName(); + sourceReqName = getSourceCvfcDataTypeName(c.getName(), c.getOwnerName()); + } else { + fullCapName = getCapabilityPath(c); + sourceReqName = getSubPathByFirstDelimiterAppearance(fullCapName); + } log.debug("the capabilty {} belongs to resource {} ", fullCapName, component.getUniqueId()); - toscaCapabilities.put(fullCapName, new String[]{c.getOwnerName(), getSubPathByFirstDelimiterAppearance(fullCapName)}); + if(sourceReqName!= null){ + toscaCapabilities.put(fullCapName, new String[]{c.getOwnerName(), sourceReqName}); + } }); } } else { 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 b70dae68e8..85b1927548 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 @@ -20,26 +20,8 @@ package org.openecomp.sdc.be.tosca; -import java.io.BufferedOutputStream; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -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.Map.Entry; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; - +import com.google.gson.Gson; +import fj.data.Either; import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.output.ByteArrayOutputStream; @@ -68,10 +50,10 @@ import org.openecomp.sdc.be.model.Operation; 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.operations.ToscaElementLifecycleOperation; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter; -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; @@ -92,9 +74,25 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import com.google.gson.Gson; - -import fj.data.Either; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +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.Map.Entry; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; /** @@ -814,10 +812,10 @@ public class CsarUtils { if (UUID_NORMATIVE_NEW_VERSION.matcher(component.getVersion()).matches() ) { version = component.getVersion(); } else { - String[] versionParts = component.getVersion().split(LifecycleOperation.VERSION_DELIMETER_REGEXP); + String[] versionParts = component.getVersion().split(ToscaElementLifecycleOperation.VERSION_DELIMETER_REGEXP); Integer majorVersion = Integer.parseInt(versionParts[0]); - version = (majorVersion + 1) + LifecycleOperation.VERSION_DELIMETER + "0"; + version = (majorVersion + 1) + ToscaElementLifecycleOperation.VERSION_DELIMETER + "0"; } additionalParams.put(AdditionalParams.ServiceVersion.getName(), version); 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 b8414367aa..646a7ecc8b 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 @@ -20,12 +20,11 @@ package org.openecomp.sdc.be.tosca; -import java.io.StringReader; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import com.google.gson.stream.JsonReader; +import fj.data.Either; import org.apache.commons.lang3.StringUtils; import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; import org.openecomp.sdc.be.model.Component; @@ -33,6 +32,7 @@ import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; +import org.openecomp.sdc.be.model.tosca.converters.DataTypePropertyConverter; import org.openecomp.sdc.be.model.tosca.converters.ToscaMapValueConverter; import org.openecomp.sdc.be.model.tosca.converters.ToscaValueConverter; import org.openecomp.sdc.be.tosca.model.EntrySchema; @@ -41,14 +41,10 @@ import org.openecomp.sdc.be.tosca.model.ToscaProperty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; -import com.google.gson.stream.JsonReader; - -import fj.data.Either; +import java.io.StringReader; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class PropertyConvertor { private static PropertyConvertor instance; @@ -101,7 +97,7 @@ public class PropertyConvertor { prop.setEntry_schema(eschema); } 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.setDefaultp(convertToToscaObject(property.getType(), property.getDefaultValue(), innerType, dataTypes)); prop.setType(property.getType()); prop.setDescription(property.getDescription()); if (isCapabiltyProperty) { @@ -111,10 +107,10 @@ public class PropertyConvertor { return prop; } - public Object convertToToscaObject(String propertyType, String propertyName, String value, String innerType, Map<String, DataTypeDefinition> dataTypes) { + public Object convertToToscaObject(String propertyType, String value, String innerType, Map<String, DataTypeDefinition> dataTypes) { log.trace("try to convert propertyType {} , value [{}], innerType {}", propertyType, value, innerType); - if (value == null) { - value = getDataTypeDefaultValue(propertyName, dataTypes.get(propertyType)); + if (StringUtils.isEmpty(value)) { + value = DataTypePropertyConverter.getInstance().getDataTypePropertiesDefaultValuesRec(propertyType, dataTypes); if(StringUtils.isEmpty(value)){ return null; } @@ -193,35 +189,4 @@ public class PropertyConvertor { } - private String getDataTypeDefaultValue(String propertyName, DataTypeDefinition dataTypeDefinition) { - - String delaultValue = null; - JsonObject asJsonObjectIn = new JsonObject(); - Map<String, PropertyDefinition> allParentsProps = new HashMap<>(); - while (dataTypeDefinition != null) { - - List<PropertyDefinition> currentParentsProps = dataTypeDefinition.getProperties(); - if (currentParentsProps != null) { - currentParentsProps.stream().forEach(p -> allParentsProps.put(p.getName(), p)); - } - - dataTypeDefinition = dataTypeDefinition.getDerivedFrom(); - } - for (Entry<String, PropertyDefinition> entry : allParentsProps.entrySet()) { - String propName = entry.getKey(); - PropertyDefinition propertyDefinition = entry.getValue(); - JsonElement elementValue = asJsonObjectIn.get(propName); - if(elementValue == null && propertyDefinition.getDefaultValue() != null){ - JsonReader jsonReader = new JsonReader(new StringReader(propertyDefinition.getDefaultValue())); - jsonReader.setLenient(true); - elementValue = jsonParser.parse(jsonReader); - asJsonObjectIn.add(propName, elementValue); - } - } - if(!asJsonObjectIn.isJsonNull()){ - delaultValue = gson.toJson(asJsonObjectIn); - } - return delaultValue; - } - } 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 f802d0f412..8e0c312f1a 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 @@ -634,7 +634,8 @@ public class ToscaExportHandler { List<ComponentInstanceInput> instanceInputsList = componentInstancesInputs.get(instanceUniqueId); if (instanceInputsList != null) { instanceInputsList.forEach(input -> { - Supplier<String> supplier = () -> input.getValue(); + + Supplier<String> supplier = () -> input.getValue() != null && !input.getValue().isEmpty()? input.getValue(): input.getDefaultValue(); convertAndAddValue(dataTypes, componentInstance, props, input, supplier); }); } @@ -695,7 +696,7 @@ public class ToscaExportHandler { if (input.getSchema() != null && input.getSchema().getProperty() != null) { innerType = input.getSchema().getProperty().getType(); } - return propertyConvertor.convertToToscaObject(propertyType, input.getName(), supplier.get(), innerType, dataTypes); + return propertyConvertor.convertToToscaObject(propertyType, supplier.get(), innerType, dataTypes); } private ToscaGroupTemplate convertGroup(GroupDefinition group) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java index dce3b3bbc0..24586d9ea0 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java @@ -44,6 +44,16 @@ public class ToscaUtils { } return false; } + + public static boolean isComplexVfc(Component component) { + if (ComponentTypeEnum.RESOURCE == component.getComponentType()) { + ResourceTypeEnum resourceType = ((ResourceMetadataDataDefinition) component.getComponentMetadataDefinition().getMetadataDataDefinition()).getResourceType(); + if (ResourceTypeEnum.CVFC == resourceType) { + return true; + } + } + return false; + } public static Map<String, Object> objectToMap(Object objectToConvert, Class clazz) throws IllegalArgumentException, IllegalAccessException { Map<String, Object> map = new HashMap<>(); diff --git a/catalog-be/src/main/webapp/WEB-INF/web.xml b/catalog-be/src/main/webapp/WEB-INF/web.xml index 889b1fac60..16c6fd6756 100644 --- a/catalog-be/src/main/webapp/WEB-INF/web.xml +++ b/catalog-be/src/main/webapp/WEB-INF/web.xml @@ -158,7 +158,7 @@ <url-pattern>/lbClassicStatus</url-pattern> </servlet-mapping> - <filter> +<!-- <filter> <filter-name>GzipFilter</filter-name> <filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class> <async-supported>true</async-supported> @@ -175,7 +175,7 @@ <filter-name>GzipFilter</filter-name> <url-pattern>/sdc2/rest/*</url-pattern> </filter-mapping> - +--> <context-param> <param-name>contextConfigLocation</param-name> @@ -190,9 +190,6 @@ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> - - - <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java index 134038abb6..0dceaed4f2 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java @@ -95,7 +95,7 @@ public class GroupBusinessLogicTest { @BeforeClass public static void setupBeforeClass() { when(graphLockOperation.lockComponent(componentId, ComponentTypeEnum.RESOURCE.getNodeType())).thenReturn(StorageOperationStatus.OK); - when(groupOperation.getGroup(groupUniqueId)).thenReturn(Either.left(groupDefenition)); +// when(groupOperation.getGroup(groupUniqueId)).thenReturn(Either.left(groupDefenition)); } public enum ResponseEnum{ diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java index ae929edb31..1309af8ff7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java @@ -41,7 +41,6 @@ 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.IPropertyOperation; -import org.openecomp.sdc.be.model.operations.api.IResourceOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.EntryData; import org.openecomp.sdc.be.user.Role; @@ -74,8 +73,6 @@ public class PropertyBusinessLogicTest { @Mock private IPropertyOperation propertyOperation; @Mock - private IResourceOperation resourceOperation; - @Mock private WebAppContextWrapper webAppContextWrapper; @Mock private UserBusinessLogic mockUserAdmin; @@ -115,20 +112,20 @@ public class PropertyBusinessLogicTest { when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager); when(servletContext.getAttribute(Constants.PROPERTY_OPERATION_MANAGER)).thenReturn(propertyOperation); when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper); - when(servletContext.getAttribute(Constants.RESOURCE_OPERATION_MANAGER)).thenReturn(resourceOperation); +// when(servletContext.getAttribute(Constants.RESOURCE_OPERATION_MANAGER)).thenReturn(resourceOperation); when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webAppContext); // Resource Operation mock methods // getCount - Either<Integer, StorageOperationStatus> eitherCount = Either.left(0); - when(resourceOperation.getNumberOfResourcesByName("MyResourceName".toLowerCase())).thenReturn(eitherCount); - Either<Integer, StorageOperationStatus> eitherCountExist = Either.left(1); - when(resourceOperation.getNumberOfResourcesByName("alreadyExist".toLowerCase())).thenReturn(eitherCountExist); - Either<Integer, StorageOperationStatus> eitherCountRoot = Either.left(1); - when(resourceOperation.getNumberOfResourcesByName("Root".toLowerCase())).thenReturn(eitherCountRoot); - - Either<Resource, StorageOperationStatus> eitherGetResource = Either.left(createResourceObject(true)); - when(resourceOperation.getResource(resourceId)).thenReturn(eitherGetResource); +// Either<Integer, StorageOperationStatus> eitherCount = Either.left(0); +// when(resourceOperation.getNumberOfResourcesByName("MyResourceName".toLowerCase())).thenReturn(eitherCount); +// Either<Integer, StorageOperationStatus> eitherCountExist = Either.left(1); +// when(resourceOperation.getNumberOfResourcesByName("alreadyExist".toLowerCase())).thenReturn(eitherCountExist); +// Either<Integer, StorageOperationStatus> eitherCountRoot = Either.left(1); +// when(resourceOperation.getNumberOfResourcesByName("Root".toLowerCase())).thenReturn(eitherCountRoot); +// +// Either<Resource, StorageOperationStatus> eitherGetResource = Either.left(createResourceObject(true)); +// when(resourceOperation.getResource(resourceId)).thenReturn(eitherGetResource); } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java index a453df2563..c545474f5d 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java @@ -55,7 +55,6 @@ import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.UploadResourceInfo; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; -import org.openecomp.sdc.be.model.operations.impl.ResourceOperation; import org.openecomp.sdc.be.model.tosca.constraints.GreaterOrEqualConstraint; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.user.UserBusinessLogic; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java index ed16ca722a..d8b82da396 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java @@ -20,26 +20,12 @@ package org.openecomp.sdc.be.components; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.ServletContext; - +import fj.data.Either; import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; import org.openecomp.sdc.ElementOperationMock; import org.openecomp.sdc.be.auditing.api.IAuditingManager; import org.openecomp.sdc.be.auditing.impl.AuditingManager; @@ -49,20 +35,15 @@ import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; -import org.openecomp.sdc.be.dao.impl.AuditingDao; import org.openecomp.sdc.be.dao.jsongraph.TitanDao; -import org.openecomp.sdc.be.dao.titan.TitanGenericDao; 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.impl.ComponentsUtils; import org.openecomp.sdc.be.impl.WebAppContextWrapper; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.GroupInstance; -import org.openecomp.sdc.be.model.InputDefinition; -import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; @@ -72,8 +53,6 @@ import org.openecomp.sdc.be.model.operations.api.IElementOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.CacheMangerOperation; import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation; -import org.openecomp.sdc.be.model.operations.impl.ServiceOperation; -import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.resources.data.auditing.DistributionDeployEvent; import org.openecomp.sdc.be.resources.data.auditing.DistributionNotificationEvent; import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent; @@ -83,7 +62,6 @@ import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; -import org.openecomp.sdc.common.datastructure.ESTimeBasedEvent; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.common.util.ValidationUtils; @@ -92,10 +70,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import javax.servlet.ServletContext; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import fj.data.Either; +import static org.junit.Assert.*; +import static org.mockito.Mockito.when; public class ServiceBusinessLogicTest { @@ -158,7 +141,7 @@ public class ServiceBusinessLogicTest { // Servlet Context attributes when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager); - when(servletContext.getAttribute(Constants.SERVICE_OPERATION_MANAGER)).thenReturn(new ServiceOperation()); +// when(servletContext.getAttribute(Constants.SERVICE_OPERATION_MANAGER)).thenReturn(new ServiceOperation()); when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper); when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webAppContext); when(webAppContext.getBean(IElementOperation.class)).thenReturn(mockElementDao); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java index 6cb90d0920..5de6762bdd 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java @@ -20,18 +20,10 @@ package org.openecomp.sdc.be.components.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.cassandra.io.sstable.Component; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import fj.data.Either; import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig.Feature; @@ -40,11 +32,8 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.mockito.InjectMocks; -import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.openecomp.sdc.be.components.ArtifactsResolver; -import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic; import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -66,7 +55,6 @@ import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.api.IUserAdminOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.ArtifactOperation; -import org.openecomp.sdc.be.model.operations.impl.ServiceOperation; import org.openecomp.sdc.be.resources.data.ESArtifactData; import org.openecomp.sdc.be.servlets.RepresentationUtils; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; @@ -76,11 +64,14 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import fj.data.Either; +import static org.junit.Assert.*; +import static org.mockito.Mockito.when; public class ArtifactBusinessLogicTest { @@ -95,7 +86,6 @@ public class ArtifactBusinessLogicTest { public static final IInterfaceLifecycleOperation lifecycleOperation = Mockito.mock(IInterfaceLifecycleOperation.class); public static final IUserAdminOperation userOperation = Mockito.mock(IUserAdminOperation.class); public static final IElementOperation elementOperation = Mockito.mock(IElementOperation.class); - public static final ServiceOperation serviceOperation = Mockito.mock(ServiceOperation.class); public static final ArtifactCassandraDao artifactCassandraDao = Mockito.mock(ArtifactCassandraDao.class); public static final ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class); @@ -110,7 +100,7 @@ public class ArtifactBusinessLogicTest { public static void setup() { Either<ArtifactDefinition, StorageOperationStatus> NotFoundResult = Either.right(StorageOperationStatus.NOT_FOUND); - when(artifactOperation.getArtifactById(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(NotFoundResult); +// when(artifactOperation.getArtifactById(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(NotFoundResult); Either<Map<String, ArtifactDefinition>, StorageOperationStatus> NotFoundResult2 = Either.right(StorageOperationStatus.NOT_FOUND); when(artifactOperation.getArtifacts(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Service), Mockito.anyBoolean())).thenReturn(NotFoundResult2); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java index d7b0800e03..a3022330a1 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java @@ -20,25 +20,12 @@ package org.openecomp.sdc.be.components.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import fj.data.Either; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic; -import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; -import org.openecomp.sdc.be.components.impl.ServiceComponentInstanceBusinessLogic; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; @@ -55,7 +42,6 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.openecomp.sdc.be.model.operations.impl.ServiceOperation; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.user.UserBusinessLogic; @@ -66,7 +52,13 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; -import fj.data.Either; +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.*; public class ResourceInstanceBusinessLogicTest { @@ -87,7 +79,7 @@ public class ResourceInstanceBusinessLogicTest { public static final ArtifactsBusinessLogic artifactBusinessLogic = Mockito.mock(ArtifactsBusinessLogic.class); public static final UserBusinessLogic userAdminManager = Mockito.mock(UserBusinessLogic.class); - public static final ServiceOperation serviceOperation = Mockito.mock(ServiceOperation.class); +// public static final ServiceOperation serviceOperation = Mockito.mock(ServiceOperation.class); public static final ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class); public static final IGroupInstanceOperation groupInstanceOperation = Mockito.mock(IGroupInstanceOperation.class); public static final ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class); @@ -132,7 +124,7 @@ public class ResourceInstanceBusinessLogicTest { Object lightService = new Service(); Either<Object, StorageOperationStatus> eitherLightService = Either.left(lightService); - Mockito.when(serviceOperation.getLightComponent(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(eitherLightService); +// Mockito.when(serviceOperation.getLightComponent(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(eitherLightService); Mockito.doNothing().when(componentsUtils).auditComponent(Mockito.any(ResponseFormat.class), Mockito.any(User.class), Mockito.any(Component.class), Mockito.anyString(), Mockito.anyString(), Mockito.any(AuditingActionEnum.class), Mockito.any(ComponentTypeEnum.class), Mockito.any(EnumMap.class)); @@ -149,6 +141,7 @@ public class ResourceInstanceBusinessLogicTest { StorageOperationStatus status = StorageOperationStatus.OK; Mockito.when(toscaOperationFacade.addDeploymentArtifactsToInstance(Mockito.any(String.class), Mockito.any(ComponentInstance.class), Mockito.any(Map.class))).thenReturn(status); + Mockito.when(toscaOperationFacade.addInformationalArtifactsToInstance(Mockito.any(String.class), Mockito.any(ComponentInstance.class), Mockito.any(Map.class))).thenReturn(status); Mockito.when(toscaOperationFacade.addGroupInstancesToComponentInstance(Mockito.any(Component.class), Mockito.any(ComponentInstance.class), Mockito.any(List.class), Mockito.any(Map.class))).thenReturn(status); } @@ -156,7 +149,7 @@ public class ResourceInstanceBusinessLogicTest { @Before public void initMocks() { MockitoAnnotations.initMocks(this); - Mockito.reset(artifactBusinessLogic, serviceOperation, componentsUtils, userAdminManager); +// Mockito.reset(artifactBusinessLogic, serviceOperation, componentsUtils, userAdminManager); setup(); } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java index e26934bfaf..6bfd64be41 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java @@ -20,13 +20,7 @@ package org.openecomp.sdc.be.components.lifecycle; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; - +import fj.data.Either; import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; @@ -36,9 +30,7 @@ import org.mockito.MockitoAnnotations; import org.openecomp.sdc.be.components.distribution.engine.ServiceDistributionArtifactsBuilder; import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic; import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.dao.jsongraph.TitanDao; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.Component; @@ -49,18 +41,21 @@ 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.ToscaOperationFacade; import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter; 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.ResourceOperation; 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.user.Role; import org.openecomp.sdc.exception.ResponseFormat; -import fj.data.Either; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; public class CertificationRequestTest extends LifecycleTestBase { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java index 1488f13015..ff5c618138 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java @@ -55,7 +55,6 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementLifecycleOper 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.StorageOperationStatus; -import org.openecomp.sdc.be.model.operations.impl.LifecycleOperation; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.be.user.UserBusinessLogic; |