From cd6f933375c412c2f79a12e909821322d58a8499 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Wed, 29 Jan 2020 17:25:21 +0000 Subject: Configure a new Artifact Type Centralizes artifact configuration in one yaml entry. Allow the configuration of a new artifact type without the need of code changes. The configuration file now is used as a source of artifacts types instead the artifact type enum. The enum will be used as a source of base artifact types and also in hard coded business rules. Change-Id: Id0383d9fca9bce0519a4d52a4ecb3a68c8713f0f Issue-ID: SDC-2754 Signed-off-by: andre.schmid --- .../csar/CsarArtifactsAndGroupsBusinessLogic.java | 10 +- .../distribution/engine/ArtifactInfoImpl.java | 89 +-- .../distribution/engine/IArtifactInfo.java | 4 +- .../be/components/impl/ArtifactsBusinessLogic.java | 683 +++++++++--------- .../be/components/impl/ElementBusinessLogic.java | 8 +- .../be/components/impl/ResourceBusinessLogic.java | 29 +- .../be/components/impl/ServiceBusinessLogic.java | 5 +- .../instance/ComponentInstanceArtifactsMerge.java | 2 +- .../sdc/be/info/ArtifactTemplateInfo.java | 55 +- .../openecomp/sdc/be/servlets/ElementServlet.java | 62 +- .../java/org/openecomp/sdc/be/tosca/CsarUtils.java | 227 +++--- .../sdc/be/tosca/utils/OperationArtifactUtil.java | 22 +- .../src/main/resources/config/configuration.yaml | 25 - .../org/openecomp/sdc/ElementOperationMock.java | 8 +- .../distribution/engine/ArtifactInfoImplTest.java | 25 +- .../components/impl/ArtifactBusinessLogicTest.java | 31 +- .../impl/ArtifactsBusinessLogicTest.java | 496 +++++++++---- .../components/impl/ResourceBusinessLogicTest.java | 12 +- .../ComponentInstanceArtifactsMergeTest.java | 2 +- .../be/impl/aaf/RoleAuthorizationHandlerTest.java | 3 +- .../sdc/be/servlets/ElementServletTest.java | 5 +- .../org/openecomp/sdc/be/tosca/CsarUtilsTest.java | 10 +- .../be/tosca/utils/OperationArtifactUtilTest.java | 4 +- .../config/catalog-be/auth/configuration.yaml | 740 +------------------ .../catalog-be/auth/error-configuration.yaml | 8 + .../resources/config/catalog-be/configuration.yaml | 798 ++++++++++++++------- 26 files changed, 1452 insertions(+), 1911 deletions(-) create mode 100644 catalog-be/src/test/resources/config/catalog-be/auth/error-configuration.yaml (limited to 'catalog-be/src') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java index 0192516bf0..dadd12f673 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java @@ -736,7 +736,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { artifactUid = newArtifact.getUniqueId(); artifactUUID = newArtifact.getArtifactUUID(); - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(newArtifact.getArtifactType()); + final ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(newArtifact.getArtifactType()); if (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_VOL) { ArtifactDefinition createHeatEnvPlaceHolder = artifactsBusinessLogic @@ -771,7 +771,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { private String checkAndGetHeatEnvId(ArtifactDefinition createdArtifact) { String artifactEnvUid = ""; - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(createdArtifact.getArtifactType()); + final ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(createdArtifact.getArtifactType()); if (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_VOL) { artifactEnvUid = createdArtifact.getUniqueId() + ArtifactsBusinessLogic.HEAT_ENV_SUFFIX; @@ -1245,7 +1245,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { if (!artifactsToDelete.isEmpty()) { for (ArtifactDefinition artifact : artifactsToDelete) { String artifactType = artifact.getArtifactType(); - ArtifactTypeEnum artifactTypeEnum = ArtifactTypeEnum.findType(artifactType); + final ArtifactTypeEnum artifactTypeEnum = ArtifactTypeEnum.parse(artifactType); if (artifactTypeEnum != ArtifactTypeEnum.HEAT_ENV) { Either, ResponseFormat> handleDelete = artifactsBusinessLogic .handleDelete(resourceId, artifact.getUniqueId(), user, AuditingActionEnum.ARTIFACT_DELETE, @@ -1460,7 +1460,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { ArtifactDefinition newArtifact = newArtifactEither.left().value(); artifactUid = newArtifact.getUniqueId(); artifactUUID = newArtifact.getArtifactUUID(); - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(newArtifact.getArtifactType()); + final ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(newArtifact.getArtifactType()); if (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_VOL) { ArtifactDefinition createHeatEnvPlaceHolder = artifactsBusinessLogic @@ -1619,7 +1619,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { ArtifactDefinition createdArtifact = createArtifactEither.left().value(); arifactsUids.add(createdArtifact.getUniqueId()); arifactsUuids.add(createdArtifact.getArtifactUUID()); - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(createdArtifact.getArtifactType()); + final ArtifactTypeEnum artifactType = ArtifactTypeEnum.parse(createdArtifact.getArtifactType()); if (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_VOL) { ArtifactDefinition createHeatEnvPlaceHolder = artifactsBusinessLogic diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java index f8f6726db8..98a8550b7a 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java @@ -20,11 +20,12 @@ package org.openecomp.sdc.be.components.distribution.engine; +import lombok.Getter; +import lombok.Setter; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.common.api.ArtifactTypeEnum; import java.util.ArrayList; import java.util.Collection; @@ -32,10 +33,12 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +@Getter +@Setter public class ArtifactInfoImpl implements IArtifactInfo { private String artifactName; - private ArtifactTypeEnum artifactType; + private String artifactType; private String artifactURL; private String artifactChecksum; private String artifactDescription; @@ -50,7 +53,7 @@ public class ArtifactInfoImpl implements IArtifactInfo { private ArtifactInfoImpl(ArtifactDefinition artifactDef, String generatedFromUUID, List relatedArtifacts) { artifactName = artifactDef.getArtifactName(); - artifactType = ArtifactTypeEnum.findType(artifactDef.getArtifactType()); + artifactType = artifactDef.getArtifactType(); artifactChecksum = artifactDef.getArtifactChecksum(); artifactDescription = artifactDef.getDescription(); artifactTimeout = artifactDef.getTimeout(); @@ -108,90 +111,10 @@ public class ArtifactInfoImpl implements IArtifactInfo { return requiredArtifacts; } - public String getArtifactName() { - return artifactName; - } - - public void setArtifactName(String artifactName) { - this.artifactName = artifactName; - } - - public ArtifactTypeEnum getArtifactType() { - return artifactType; - } - - public void setArtifactType(ArtifactTypeEnum artifactType) { - this.artifactType = artifactType; - } - - public String getArtifactURL() { - return artifactURL; - } - - public void setArtifactURL(String artifactURL) { - this.artifactURL = artifactURL; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - public String getArtifactDescription() { - return artifactDescription; - } - - public void setArtifactDescription(String artifactDescription) { - this.artifactDescription = artifactDescription; - } - - public Integer getArtifactTimeout() { - return artifactTimeout; - } - - public void setArtifactTimeout(Integer artifactTimeout) { - this.artifactTimeout = artifactTimeout; - } - - public List getRelatedArtifacts() { - return relatedArtifacts; - } - - public void setRelatedArtifacts(List relatedArtifacts) { - this.relatedArtifacts = relatedArtifacts; - } - @Override public String toString() { return "ArtifactInfoImpl [artifactName=" + artifactName + ", artifactType=" + artifactType + ", artifactURL=" + artifactURL + ", artifactChecksum=" + artifactChecksum + ", artifactDescription=" + artifactDescription + ", artifactTimeout=" + artifactTimeout + ", artifactUUID=" + artifactUUID + ", artifactVersion=" + artifactVersion + ", generatedFromUUID=" + generatedFromUUID + ", relatedArtifacts=" + relatedArtifacts + "]"; } - public String getArtifactUUID() { - return artifactUUID; - } - - public void setArtifactUUID(String artifactUUID) { - this.artifactUUID = artifactUUID; - } - - public String getArtifactVersion() { - return artifactVersion; - } - - public void setArtifactVersion(String artifactVersion) { - this.artifactVersion = artifactVersion; - } - - public String getGeneratedFromUUID() { - return generatedFromUUID; - } - - public void setGeneratedFromUUID(String generatedFromUUID) { - this.generatedFromUUID = generatedFromUUID; - } - } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/IArtifactInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/IArtifactInfo.java index 4a917710a9..b4919dfbfe 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/IArtifactInfo.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/IArtifactInfo.java @@ -20,8 +20,6 @@ package org.openecomp.sdc.be.components.distribution.engine; -import org.openecomp.sdc.common.api.ArtifactTypeEnum; - public interface IArtifactInfo { /** Artifact File name */ @@ -32,7 +30,7 @@ public interface IArtifactInfo { * Following are valid values : HEAT , DG_XML.
* List of values will be extended in post-1510 releases. */ - ArtifactTypeEnum getArtifactType(); + String getArtifactType(); /** * Relative artifact's URL. Should be used in REST GET API to download the artifact's payload.
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 103edd6497..b41d076e2a 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 @@ -22,13 +22,38 @@ package org.openecomp.sdc.be.components.impl; +import static org.openecomp.sdc.be.dao.api.ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE; + import com.google.common.annotations.VisibleForTesting; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import fj.data.Either; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import javax.servlet.http.HttpServletRequest; +import javax.xml.XMLConstants; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -43,7 +68,9 @@ import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction; import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction.LifecycleChanceActionEnum; import org.openecomp.sdc.be.components.utils.InterfaceOperationUtils; +import org.openecomp.sdc.be.config.ArtifactConfiguration; import org.openecomp.sdc.be.config.BeEcompErrorManager; +import org.openecomp.sdc.be.config.Configuration; import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -61,7 +88,6 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.info.ArtifactTemplateInfo; import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.ArtifactType; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.ComponentParametersView; @@ -121,31 +147,6 @@ import org.xml.sax.SAXNotSupportedException; import org.xml.sax.XMLReader; import org.yaml.snakeyaml.Yaml; -import javax.servlet.http.HttpServletRequest; -import javax.xml.XMLConstants; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParserFactory; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -import static org.openecomp.sdc.be.dao.api.ActionStatus.MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE; - @org.springframework.stereotype.Component("artifactBusinessLogic") public class ArtifactsBusinessLogic extends BaseBusinessLogic { private static final String RESOURCE_INSTANCE = "resource instance"; @@ -167,19 +168,14 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { private static final Logger log = Logger.getLogger(ArtifactsBusinessLogic.class.getName()); private static final String FAILED_UPDATE_GROUPS = "Failed to update groups of the component {}. "; - private static final String FAILED_UPDATE_ARTIFACT = "Failed to delete or update the artifact {}. Parent uniqueId is {}"; private static final String FAILED_SAVE_ARTIFACT = "Failed to save the artifact."; public static final String ARTIFACT_ACTION_LOCK = "Artifact action - lock "; - private static final String UPDATE_ARTIFACT_LOCK = "Update Artifact - lock "; - private static final String FAILED_DOWNLOAD_ARTIFACT = "Download artifact {} failed"; public static final String FAILED_UPLOAD_ARTIFACT_TO_COMPONENT = "Failed to upload artifact to component with type {} and uuid {}. Status is {}. "; - private static final String FAILED_UPLOAD_ARTIFACT_TO_INSTANCE = "Failed to upload artifact to component instance {} of component with type {} and uuid {}. Status is {}. "; private static final String FAILED_FETCH_COMPONENT = "Could not fetch component with type {} and uuid {}. Status is {}. "; private static final String NULL_PARAMETER = "One of the function parameteres is null"; public static final String COMPONENT_INSTANCE_NOT_FOUND = "Component instance {} was not found for component {}"; private static final String ROLLBACK = "all changes rollback"; private static final String COMMIT = "all changes committed"; - private static final String ARTIFACT_SAVED = "Artifact saved into ES - {}"; private static final String UPDATE_ARTIFACT = "Update Artifact"; private static final String FOUND_DEPLOYMENT_ARTIFACT = "Found deployment artifact {}"; private Gson gson = new GsonBuilder().setPrettyPrinting().create(); @@ -479,9 +475,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { String operationName, AuditingActionEnum auditingAction, User user, Component parent, boolean needUpdateGroup) { Either result; - ArtifactTypeEnum artifactType = validateAndReturnArtifactType(artifactInfo); - if (componentType == ComponentTypeEnum.RESOURCE_INSTANCE - && (artifactType == ArtifactTypeEnum.HEAT || artifactType == ArtifactTypeEnum.HEAT_VOL || artifactType == ArtifactTypeEnum.HEAT_NET || artifactType == ArtifactTypeEnum.HEAT_ENV)) { + validateArtifactType(artifactInfo); + final String artifactType = artifactInfo.getArtifactType(); + if (componentType == ComponentTypeEnum.RESOURCE_INSTANCE && + (ArtifactTypeEnum.HEAT.getType().equals(artifactType) || + ArtifactTypeEnum.HEAT_VOL.getType().equals(artifactType) || + ArtifactTypeEnum.HEAT_NET.getType().equals(artifactType) || + ArtifactTypeEnum.HEAT_ENV.getType().equals(artifactType))) { result = handleUpdateHeatEnvAndHeatMeta(componentId, artifactInfo, auditingAction, artifactId, user, componentType, parent, originData, origMd5, operation); if (needUpdateGroup) { ActionStatus error = updateGroupInstance(artifactInfo, result.left().value(), parent, componentId); @@ -490,7 +490,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } } } - else if (componentType == ComponentTypeEnum.RESOURCE && artifactType == ArtifactTypeEnum.HEAT_ENV) { + else if (componentType == ComponentTypeEnum.RESOURCE && ArtifactTypeEnum.HEAT_ENV.getType().equals(artifactType)) { result = handleUpdateHeatWithHeatEnvParams(componentId, artifactInfo, auditingAction, componentType, parent, originData, origMd5, operation, needUpdateGroup); } else { @@ -507,16 +507,70 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return result; } - private ArtifactTypeEnum validateAndReturnArtifactType(ArtifactDefinition artifactInfo) { - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactInfo.getArtifactType()); - if (artifactType == null) { + private void validateArtifactType(final ArtifactDefinition artifactInfo) { + if (!isArtifactSupported(artifactInfo.getArtifactType())) { throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo.getArtifactType()); } - return artifactType; } - public ActionStatus updateGroupForHeatEnv(ArtifactDefinition artifactInfo, ArtifactDefinition artAfterUpdate, Component parent) { - return ActionStatus.OK; + private void validateArtifactType(final ArtifactDefinition artifactInfo, + final ComponentTypeEnum componentType) { + final ArtifactConfiguration artifactConfiguration = + loadArtifactTypeConfig(artifactInfo.getArtifactType()).orElse(null); + if (artifactConfiguration == null) { + BeEcompErrorManager.getInstance() + .logBeMissingArtifactInformationError("Artifact Update / Upload", "artifactLabel"); + log.debug("Missing artifact type for artifact {}", artifactInfo.getArtifactName()); + final ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.MISSING_ARTIFACT_TYPE); + throw new ByResponseFormatComponentException(responseFormat); + } + + final ArtifactGroupTypeEnum artifactGroupType = artifactInfo.getArtifactGroupType(); + try { + validateArtifactType(componentType, artifactGroupType, artifactConfiguration); + } catch (final ComponentException e) { + log.debug("Artifact is invalid", e); + BeEcompErrorManager.getInstance() + .logBeInvalidTypeError("Artifact Upload / Delete / Update - Not supported artifact type", artifactInfo + .getArtifactType(), "Artifact " + artifactInfo.getArtifactName()); + log.debug("Not supported artifact type = {}", artifactInfo.getArtifactType()); + final ResponseFormat responseFormat = componentsUtils + .getResponseFormat(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo + .getArtifactType()); + throw new ByResponseFormatComponentException(responseFormat); + } + } + + private void validateArtifactType(final ComponentTypeEnum componentType, final ArtifactGroupTypeEnum groupType, + final ArtifactConfiguration artifactConfiguration) { + final boolean supportComponentType = + CollectionUtils.isNotEmpty(artifactConfiguration.getComponentTypes()) && + artifactConfiguration.getComponentTypes().stream() + .anyMatch(componentType1 -> componentType1.getValue().equalsIgnoreCase(componentType.getValue())); + if (!supportComponentType) { + log.debug("Artifact Type '{}' not supported for Component Type '{}'", + artifactConfiguration.getType(), componentType.getValue()); + throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, + artifactConfiguration.getType()); + } + + final boolean supportResourceType = artifactConfiguration.hasSupport(groupType); + if (!supportResourceType) { + log.debug("Artifact Type '{}' not supported for Component Type '{}' and Category '{}'", + artifactConfiguration.getType(), componentType.getValue(), groupType.getType()); + throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, + artifactConfiguration.getType()); + } + } + + private boolean isArtifactSupported(final String artifactType) { + final Configuration configuration = ConfigurationManager.getConfigurationManager().getConfiguration(); + final List artifactConfigurationList = configuration.getArtifacts(); + if (CollectionUtils.isEmpty(artifactConfigurationList)) { + return false; + } + return artifactConfigurationList.stream() + .anyMatch(artifactConfiguration -> artifactConfiguration.getType().equalsIgnoreCase(artifactType)); } @VisibleForTesting @@ -706,7 +760,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { // step 1 // detect auditing type Map resMap = null; -// Either, ResponseFormat> resultOp = null; new Wrapper<>(); // step 2 @@ -745,7 +798,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { throw new ByActionStatusComponentException(ActionStatus.MISSING_INFORMATION); } if (groupType == ArtifactGroupTypeEnum.DEPLOYMENT) { - List list = getDeploymentArtifacts(component, componentType.getNodeType(), componentId); + List list = getDeploymentArtifacts(component, componentId); if (list != null && !list.isEmpty()) { resMap = list.stream().collect(Collectors.toMap(ArtifactDataDefinition::getArtifactLabel, Function.identity())); } @@ -1011,14 +1064,31 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } } - private Either validateInput(String componentId, ArtifactDefinition artifactInfo, ArtifactOperationInfo operation, String artifactId, User user, String interfaceName, String operationName, - ComponentTypeEnum componentType, Component parentComponent) { + private Either validateInput(final String componentId, + final ArtifactDefinition artifactInfo, + final ArtifactOperationInfo operation, + final String artifactId, final User user, + String interfaceName, + String operationName, + final ComponentTypeEnum componentType, + final Component parentComponent) { + + final ArtifactDefinition existingArtifactInfo = + findArtifact(parentComponent, componentType, componentId, operation, artifactId); + final Component component; + if (parentComponent.getUniqueId().equals(componentId)) { + component = parentComponent; + } else { + final ComponentInstance componentInstance = findComponentInstance(componentId, parentComponent); + component = findComponent(componentInstance.getComponentUid()); + component.setComponentType(componentType); + } - ArtifactDefinition currentArtifactInfo = findArtifactOnParentComponent(parentComponent, componentType, componentId, operation, artifactId); - ignoreUnupdateableFieldsInUpdate(operation, artifactInfo, currentArtifactInfo); - validateInformationalArtifact(artifactInfo, parentComponent); - Either validateAndSetArtifactname = validateAndSetArtifactName( - artifactInfo); + ignoreUnupdateableFieldsInUpdate(operation, artifactInfo, existingArtifactInfo); + if (isInformationalArtifact(artifactInfo)) { + validateInformationalArtifact(artifactInfo, component); + } + Either validateAndSetArtifactname = validateAndSetArtifactName(artifactInfo); if (validateAndSetArtifactname.isRight()) { return Either.right(validateAndSetArtifactname.right().value()); } @@ -1036,37 +1106,43 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { // This is a patch to block possibility of updating service api fields // through other artifacts flow - ArtifactGroupTypeEnum artifactGroupType = operationName != null ? ArtifactGroupTypeEnum.LIFE_CYCLE : ArtifactGroupTypeEnum.INFORMATIONAL; - if (!ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum())) { - checkAndSetUnUpdatableFields(user, artifactInfo, currentArtifactInfo, artifactGroupType); - } - else { + final ArtifactGroupTypeEnum artifactGroupType = + operationName != null ? ArtifactGroupTypeEnum.LIFE_CYCLE : ArtifactGroupTypeEnum.INFORMATIONAL; + final boolean isCreateOrLink = ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum()); + if (!isCreateOrLink) { + checkAndSetUnUpdatableFields(user, artifactInfo, existingArtifactInfo, artifactGroupType); + } else { checkCreateFields(user, artifactInfo, artifactGroupType); } composeArtifactId(componentId, artifactId, artifactInfo, interfaceName, operationName); - if (currentArtifactInfo != null) { - artifactInfo.setMandatory(currentArtifactInfo.getMandatory()); + if (existingArtifactInfo != null) { + artifactInfo.setMandatory(existingArtifactInfo.getMandatory()); + if (!isCreateOrLink) { + validateArtifactTypeNotChanged(artifactInfo, existingArtifactInfo); + } } // artifactGroupType is not allowed to be updated - if (!ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum())) { - Either validateGroupType = validateOrSetArtifactGroupType(artifactInfo, currentArtifactInfo); + if (!isCreateOrLink) { + Either validateGroupType = validateOrSetArtifactGroupType(artifactInfo, existingArtifactInfo); if (validateGroupType.isRight()) { return Either.right(validateGroupType.right().value()); } } - // TODO TEMP !!! - NodeTypeEnum parentType = convertParentType(componentType); - // TODO TEMP !!! - boolean isCreate = ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum()); - - if (isDeploymentArtifact(artifactInfo)) { - validateDeploymentArtifact(parentComponent, componentId, isCreate, artifactInfo, currentArtifactInfo, parentType); + setArtifactTimeout(artifactInfo, existingArtifactInfo); + if (isHeatArtifact(artifactInfo)) { + validateHeatArtifact(parentComponent, componentId, artifactInfo); } - else { - artifactInfo.setTimeout(NodeTemplateOperation.NON_HEAT_TIMEOUT); + if (isDeploymentArtifact(artifactInfo)) { + if (componentType != ComponentTypeEnum.RESOURCE_INSTANCE) { + final String artifactName = artifactInfo.getArtifactName(); + if (isCreateOrLink || !artifactName.equalsIgnoreCase(existingArtifactInfo.getArtifactName())) { + validateSingleDeploymentArtifactName(artifactName, parentComponent); + } + } + validateDeploymentArtifact(artifactInfo, component); } Either descriptionResult = validateAndCleanDescription(artifactInfo); @@ -1074,11 +1150,9 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return Either.right(descriptionResult.right().value()); } - if (currentArtifactInfo != null && currentArtifactInfo.getArtifactGroupType() == ArtifactGroupTypeEnum.SERVICE_API) { - Either validateServiceApiType = validateArtifactType(user.getUserId(), artifactInfo, parentType); - if (validateServiceApiType.isRight()) { - return Either.right(validateServiceApiType.right().value()); - } + validateArtifactType(artifactInfo, component.getComponentType()); + artifactInfo.setArtifactType(artifactInfo.getArtifactType().toUpperCase()); + if (existingArtifactInfo != null && existingArtifactInfo.getArtifactGroupType() == ArtifactGroupTypeEnum.SERVICE_API) { // Change of type is not allowed and should be ignored artifactInfo.setArtifactType(ARTIFACT_TYPE_OTHER); @@ -1088,23 +1162,18 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return Either.right(validateUrl.right().value()); } - Either validateUpdate = validateFirstUpdateHasPayload(artifactInfo, currentArtifactInfo); + Either validateUpdate = validateFirstUpdateHasPayload(artifactInfo, existingArtifactInfo); if (validateUpdate.isRight()) { log.debug("serviceApi first update cnnot be without payload."); return Either.right(validateUpdate.right().value()); } - } - else { - Either validateArtifactType = validateArtifactType(user.getUserId(), artifactInfo, parentType); - if (validateArtifactType.isRight()) { - return Either.right(validateArtifactType.right().value()); - } + } else { if (artifactInfo.getApiUrl() != null) { artifactInfo.setApiUrl(null); log.error("Artifact URL cannot be set through this API - ignoring"); } - if (artifactInfo.getServiceApi() != null && artifactInfo.getServiceApi()) { + if (Boolean.TRUE.equals(artifactInfo.getServiceApi())) { artifactInfo.setServiceApi(false); log.error("Artifact service API flag cannot be changed - ignoring"); } @@ -1113,6 +1182,16 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return Either.left(artifactInfo); } + private Component findComponent(final String componentId) { + Either component = toscaOperationFacade.getToscaFullElement(componentId); + if (component.isRight()) { + log.debug("Component '{}' not found ", componentId); + throw new ByActionStatusComponentException(ActionStatus.COMPONENT_NOT_FOUND, componentId); + } + + return component.left().value(); + } + private void ignoreUnupdateableFieldsInUpdate(ArtifactOperationInfo operation, ArtifactDefinition artifactInfo, ArtifactDefinition currentArtifactInfo) { if (operation.getArtifactOperationEnum() == ArtifactOperationEnum.UPDATE) { artifactInfo.setArtifactType(currentArtifactInfo.getArtifactType()); @@ -1121,8 +1200,9 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } } - private ArtifactDefinition findArtifactOnParentComponent(Component parentComponent, ComponentTypeEnum componentType, String parentId, ArtifactOperationInfo operation, String artifactId) { - + private ArtifactDefinition findArtifact(final Component parentComponent, final ComponentTypeEnum componentType, + final String parentId, final ArtifactOperationInfo operation, + final String artifactId) { ArtifactDefinition foundArtifact = null; if (StringUtils.isNotEmpty(artifactId)) { foundArtifact = findArtifact(parentComponent, componentType, parentId, artifactId); @@ -1132,7 +1212,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_EXIST, foundArtifact.getArtifactLabel()); } if (foundArtifact == null && !ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum())) { - log.debug("The artifact {} was not found on parent {}. ", artifactId, parentId); + log.debug("The artifact {} was not found on parent component or instance {}. ", artifactId, parentId); throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_NOT_FOUND, ""); } return foundArtifact; @@ -1150,31 +1230,26 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return foundArtifact; } - private void validateInformationalArtifact(ArtifactDefinition artifactInfo, Component parentComponent) { - ComponentTypeEnum parentComponentType = parentComponent.getComponentType(); - ArtifactGroupTypeEnum groupType = artifactInfo.getArtifactGroupType(); - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactInfo.getArtifactType()); - if (artifactType == null) { - throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo.getArtifactType()); + private void validateInformationalArtifact(final ArtifactDefinition artifactInfo, final Component component) { + final ArtifactGroupTypeEnum groupType = artifactInfo.getArtifactGroupType(); + if (groupType != ArtifactGroupTypeEnum.INFORMATIONAL) { + return; } - else if (parentComponentType == ComponentTypeEnum.RESOURCE && groupType == ArtifactGroupTypeEnum.INFORMATIONAL) { - String artifactTypeName = artifactType.getType(); - ResourceTypeEnum parentResourceType = ((Resource) parentComponent).getResourceType(); - Map resourceInformationalArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceInformationalArtifacts(); - Set validArtifactTypes = resourceInformationalArtifacts.keySet(); - if (!validArtifactTypes.contains(artifactTypeName)) { - throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactTypeName); - } - else { - List validResourceType = resourceInformationalArtifacts.get(artifactTypeName) - .getValidForResourceTypes(); - if (!validResourceType.contains(parentResourceType.name())) { - throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactTypeName); - } - } + final ComponentTypeEnum parentComponentType = component.getComponentType(); + final String artifactType = artifactInfo.getArtifactType(); + final ArtifactConfiguration artifactConfiguration = loadArtifactTypeConfig(artifactType).orElse(null); + if (artifactConfiguration == null) { + throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactType); } + validateArtifactType(parentComponentType, artifactInfo.getArtifactGroupType(), artifactConfiguration); + + if (component.getComponentType() == ComponentTypeEnum.RESOURCE || + component.getComponentType() == ComponentTypeEnum.RESOURCE_INSTANCE) { + + final ResourceTypeEnum resourceType = ((Resource) component).getResourceType(); + validateResourceType(resourceType, artifactInfo, artifactConfiguration.getResourceTypes()); + } + validateArtifactExtension(artifactConfiguration, artifactInfo); } private NodeTypeEnum convertParentType(ComponentTypeEnum componentType) { @@ -1750,117 +1825,102 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return foundInstance; } - private void validateDeploymentArtifact(Component parentComponent, String parentId, boolean isCreate, ArtifactDefinition artifactInfo, ArtifactDefinition currentArtifact, NodeTypeEnum parentType) { - - ArtifactTypeEnum artifactType = getValidArtifactType(artifactInfo); - Map resourceDeploymentArtifacts = fillDeploymentArtifactTypeConf(parentType); - validateDeploymentArtifactTypeIsLegalForParent(artifactInfo, artifactType, resourceDeploymentArtifacts); - if (!isCreate) { - validateArtifactTypeNotChanged(artifactInfo, currentArtifact); + private void validateDeploymentArtifact(final ArtifactDefinition artifactInfo, final Component component) { + final ComponentTypeEnum componentType = component.getComponentType(); + if (componentType != ComponentTypeEnum.RESOURCE && + componentType != ComponentTypeEnum.SERVICE && + componentType != ComponentTypeEnum.RESOURCE_INSTANCE) { + log.debug("Invalid component type '{}' for artifact. " + + "Expected Resource, Component or Resource Instance", componentType.getValue()); + throw new ByActionStatusComponentException(MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE, + componentType.getValue(), "Service, Resource or ResourceInstance", componentType.getValue()); } - if (parentType == NodeTypeEnum.Resource) { - Resource resource = (Resource) parentComponent; - ResourceTypeEnum resourceType = resource.getResourceType(); - ArtifactTypeConfig config = resourceDeploymentArtifacts.get(artifactType.getType()); - if (config == null) { - throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo.getArtifactType()); - } - List myList = config.getValidForResourceTypes(); - validateResourceType(resourceType, artifactInfo, myList); + final String artifactType = artifactInfo.getArtifactType(); + final ArtifactConfiguration artifactConfiguration = loadArtifactTypeConfig(artifactType).orElse(null); + if (artifactConfiguration == null) { + throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactType); } + validateArtifactType(componentType, artifactInfo.getArtifactGroupType(), artifactConfiguration); + if (componentType == ComponentTypeEnum.RESOURCE || componentType == ComponentTypeEnum.RESOURCE_INSTANCE) { + final Resource resource = (Resource) component; + final ResourceTypeEnum resourceType = resource.getResourceType(); - validateFileExtension(() -> getDeploymentArtifactTypeConfig(parentType, artifactType), artifactInfo, parentType, artifactType); + validateResourceType(resourceType, artifactInfo, artifactConfiguration.getResourceTypes()); + } - if (NodeTypeEnum.ResourceInstance != parentType) { - String artifactName = artifactInfo.getArtifactName(); - if (isCreate || !artifactName.equalsIgnoreCase(currentArtifact.getArtifactName())) { - validateSingleDeploymentArtifactName(artifactName, parentComponent, parentType); - } + validateArtifactExtension(artifactConfiguration, artifactInfo); + } + + private void validateHeatArtifact(final Component parentComponent, final String componentId, + final ArtifactDefinition artifactDefinition) { + final String artifactType = artifactDefinition.getArtifactType(); + final ArtifactTypeEnum artifactTypeEnum = ArtifactTypeEnum.parse(artifactType); + if (artifactTypeEnum == null) { + return; } - switch (artifactType) { + switch (artifactTypeEnum) { case HEAT: case HEAT_VOL: case HEAT_NET: - validateHeatTimeoutValue(isCreate, artifactInfo, currentArtifact); + validateHeatTimeoutValue(artifactDefinition); break; case HEAT_ENV: - validateHeatEnvDeploymentArtifact(parentComponent, parentId, artifactInfo, parentType); - artifactInfo.setTimeout(NodeTemplateOperation.NON_HEAT_TIMEOUT); + validateHeatEnvDeploymentArtifact(parentComponent, componentId, artifactDefinition); break; - case DCAE_INVENTORY_TOSCA: - case DCAE_INVENTORY_JSON: - case DCAE_INVENTORY_POLICY: - // Validation is done in handle payload. - case DCAE_INVENTORY_DOC: - case DCAE_INVENTORY_BLUEPRINT: - case DCAE_INVENTORY_EVENT: - // No specific validation default: - artifactInfo.setTimeout(NodeTemplateOperation.NON_HEAT_TIMEOUT); break; } } - @VisibleForTesting - void validateDeploymentArtifactTypeIsLegalForParent(ArtifactDefinition artifactInfo, ArtifactTypeEnum artifactType, Map resourceDeploymentArtifacts) { - if ((resourceDeploymentArtifacts == null) || !resourceDeploymentArtifacts.containsKey(artifactType.name())) { - log.debug("Artifact Type: {} Not found !", artifactInfo.getArtifactType()); - throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo.getArtifactType()); - } - } + private void setArtifactTimeout(final ArtifactDefinition newArtifactInfo, + final ArtifactDefinition existingArtifactInfo) { - private Map fillDeploymentArtifactTypeConf(NodeTypeEnum parentType) { - Map resourceDeploymentArtifacts; - if (parentType == NodeTypeEnum.Resource) { - resourceDeploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceDeploymentArtifacts(); - } - else if (parentType == NodeTypeEnum.ResourceInstance) { - resourceDeploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceInstanceDeploymentArtifacts(); + final String artifactType = newArtifactInfo.getArtifactType(); + final ArtifactTypeEnum artifactTypeEnum = ArtifactTypeEnum.parse(artifactType); + if (artifactTypeEnum == null) { + newArtifactInfo.setTimeout(NodeTemplateOperation.NON_HEAT_TIMEOUT); + return; } - else { - resourceDeploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getServiceDeploymentArtifacts(); + switch (artifactTypeEnum) { + case HEAT: + case HEAT_VOL: + case HEAT_NET: + if (newArtifactInfo.getTimeout() == null) { + if (existingArtifactInfo == null) { + newArtifactInfo.setTimeout(NodeTemplateOperation.getDefaultHeatTimeout()); + } else { + newArtifactInfo.setTimeout(existingArtifactInfo.getTimeout()); + } + } + break; + default: + newArtifactInfo.setTimeout(NodeTemplateOperation.NON_HEAT_TIMEOUT); + break; } - return resourceDeploymentArtifacts; } - public ArtifactTypeEnum getValidArtifactType(ArtifactDefinition artifactInfo) { - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactInfo.getArtifactType()); - if (artifactType == null) { + @VisibleForTesting + void validateDeploymentArtifactTypeIsLegalForParent(ArtifactDefinition artifactInfo, ArtifactTypeEnum artifactType, Map resourceDeploymentArtifacts) { + if ((resourceDeploymentArtifacts == null) || !resourceDeploymentArtifacts.containsKey(artifactType.name())) { log.debug("Artifact Type: {} Not found !", artifactInfo.getArtifactType()); throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo.getArtifactType()); } - return artifactType; } - private ArtifactTypeConfig getDeploymentArtifactTypeConfig(NodeTypeEnum parentType, ArtifactTypeEnum artifactType) { - ArtifactTypeConfig retConfig = null; - String fileType = artifactType.getType(); - if (parentType == NodeTypeEnum.Resource) { - retConfig = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceDeploymentArtifacts() - .get(fileType); - } - else if (parentType == NodeTypeEnum.Service) { - retConfig = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getServiceDeploymentArtifacts() - .get(fileType); + Optional loadArtifactTypeConfig(final String artifactType) { + if (artifactType == null) { + return Optional.empty(); } - else if (parentType == NodeTypeEnum.ResourceInstance) { - retConfig = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceInstanceDeploymentArtifacts() - .get(fileType); + final List artifactConfigurationList = + ConfigurationManager.getConfigurationManager().getConfiguration().getArtifacts(); + if (CollectionUtils.isEmpty(artifactConfigurationList)) { + return Optional.empty(); } - return retConfig; + + return artifactConfigurationList.stream() + .filter(artifactConfiguration -> artifactConfiguration.getType().equalsIgnoreCase(artifactType)) + .findFirst(); } private Either extractHeatParameters(ArtifactDefinition artifactInfo) { @@ -1884,42 +1944,33 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } @VisibleForTesting - public void validateFileExtension(IDeploymentArtifactTypeConfigGetter deploymentConfigGetter, ArtifactDefinition artifactInfo, NodeTypeEnum parentType, ArtifactTypeEnum artifactType) { - if (parentType != NodeTypeEnum.Resource && parentType != NodeTypeEnum.Service && parentType != NodeTypeEnum.ResourceInstance) { - log.debug("parent type of artifact can be either resource or service"); - throw new ByActionStatusComponentException(MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE, artifactType.name(), "Service, Resource or ResourceInstance", parentType.getName()); - } - - String fileType = artifactType.getType(); - ArtifactTypeConfig deploymentAcceptedTypes = deploymentConfigGetter.getDeploymentArtifactConfig(); - if (deploymentAcceptedTypes == null) { - log.debug("invalid artifact type {}", fileType); - throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, fileType); - } + void validateArtifactExtension(final ArtifactConfiguration artifactConfiguration, + final ArtifactDefinition artifactDefinition) { + final List acceptedTypes = artifactConfiguration.getAcceptedTypes(); /* * No need to check specific types. In case there are no acceptedTypes in configuration, then any type is accepted. */ + if (CollectionUtils.isEmpty(acceptedTypes)) { + return; + } + final String artifactName = artifactDefinition.getArtifactName(); + final String fileExtension = FilenameUtils.getExtension(artifactName); - List acceptedTypes = deploymentAcceptedTypes.getAcceptedTypes(); - String artifactName = artifactInfo.getArtifactName(); - String fileExtension = GeneralUtility.getFilenameExtension(artifactName); - // Pavel - File extension validation is case-insensitive - Ella, - // 21/02/2016 - if (CollectionUtils.isNotEmpty(acceptedTypes) && !acceptedTypes.contains(fileExtension.toLowerCase())) { - log.debug("File extension \"{}\" is not allowed for {} which is of type:{}", fileExtension, artifactName, fileType); - throw new ByActionStatusComponentException(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION, fileType); + if (fileExtension == null || !acceptedTypes.contains(fileExtension.toLowerCase())) { + final String artifactType = artifactDefinition.getArtifactType(); + log.debug("File extension \"{}\" is not allowed for artifact type \"{}\"", fileExtension, artifactType); + throw new ByActionStatusComponentException(ActionStatus.WRONG_ARTIFACT_FILE_EXTENSION, artifactType); } } @VisibleForTesting - void validateHeatEnvDeploymentArtifact(Component parentComponent, String parentId, ArtifactDefinition artifactInfo, NodeTypeEnum parentType) { - - Wrapper heatMDWrapper = new Wrapper<>(); - Wrapper payloadWrapper = new Wrapper<>(); + void validateHeatEnvDeploymentArtifact(final Component parentComponent, final String parentId, + final ArtifactDefinition artifactInfo) { + final Wrapper heatMDWrapper = new Wrapper<>(); + final Wrapper payloadWrapper = new Wrapper<>(); validateYaml(artifactInfo); - validateHeatExist(parentComponent.getUniqueId(), parentId, heatMDWrapper, artifactInfo, - parentType, parentComponent.getComponentType()); + validateHeatExist(parentComponent.getUniqueId(), parentId, heatMDWrapper, artifactInfo, parentComponent.getComponentType()); if (!heatMDWrapper.isEmpty()) { fillArtifactPayload(payloadWrapper, heatMDWrapper.getInnerElement()); @@ -2005,42 +2056,38 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } } - private void validateSingleDeploymentArtifactName(String artifactName, Component parentComponent, NodeTypeEnum parentType) { + private void validateSingleDeploymentArtifactName(final String artifactName, final Component parentComponent) { boolean artifactNameFound = false; - Iterator parentDeploymentArtifactsItr = getDeploymentArtifacts(parentComponent, parentType, null) - .iterator(); + final Iterator parentDeploymentArtifactsItr = + getDeploymentArtifacts(parentComponent, null).iterator(); while (!artifactNameFound && parentDeploymentArtifactsItr.hasNext()) { artifactNameFound = artifactName.equalsIgnoreCase(parentDeploymentArtifactsItr.next().getArtifactName()); } if (artifactNameFound) { + final ComponentTypeEnum componentType = parentComponent.getComponentType(); log.debug("Can't upload artifact: {}, because another artifact with this name already exist.", artifactName); - throw new ByActionStatusComponentException(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS, parentType.name(), - parentComponent.getName(), artifactName); + throw new ByActionStatusComponentException(ActionStatus.DEPLOYMENT_ARTIFACT_NAME_ALREADY_EXISTS, + componentType.getValue(), parentComponent.getName(), artifactName); } } - private void validateHeatExist(String componentId, String parentRiId, Wrapper heatArtifactMDWrapper, ArtifactDefinition heatEnvArtifact, NodeTypeEnum parentType, + private void validateHeatExist(String componentId, String parentRiId, Wrapper heatArtifactMDWrapper, ArtifactDefinition heatEnvArtifact, ComponentTypeEnum componentType) { - Either res = artifactToscaOperation.getHeatArtifactByHeatEnvId(parentRiId, heatEnvArtifact, parentType, componentId, componentType); + final Either res = artifactToscaOperation + .getHeatArtifactByHeatEnvId(parentRiId, heatEnvArtifact, componentId, componentType); if (res.isRight()) { throw new ByActionStatusComponentException(ActionStatus.MISSING_HEAT); - } else { - heatArtifactMDWrapper.setInnerElement(res.left().value()); } + + heatArtifactMDWrapper.setInnerElement(res.left().value()); } @VisibleForTesting - void validateHeatTimeoutValue(boolean isCreate, ArtifactDefinition artifactInfo, ArtifactDefinition currentArtifact) { + void validateHeatTimeoutValue(final ArtifactDefinition artifactInfo) { log.trace("Started HEAT pre-payload validation for artifact {}", artifactInfo.getArtifactLabel()); // timeout > 0 for HEAT artifacts - Integer timeout = artifactInfo.getTimeout(); - if (timeout == null) { - Integer defaultTimeout = isCreate ? NodeTemplateOperation.getDefaultHeatTimeout() : currentArtifact.getTimeout(); - artifactInfo.setTimeout(defaultTimeout); - // HEAT artifact but timeout is invalid - } - else if (timeout < 1) { + if (artifactInfo.getTimeout() == null || artifactInfo.getTimeout() < 1) { throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_INVALID_TIMEOUT); } // US649856 - Allow several HEAT files on Resource @@ -2048,12 +2095,14 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } @VisibleForTesting - void validateResourceType(ResourceTypeEnum resourceType, ArtifactDefinition artifactInfo, List typeList) { - if (typeList == null || !typeList.contains(resourceType.name())) { - String listToString = (typeList != null) ? typeList.toString() : ""; - throw new ByActionStatusComponentException(MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE, artifactInfo.getArtifactName(), - listToString, resourceType.getValue()); + void validateResourceType(final ResourceTypeEnum resourceType, final ArtifactDefinition artifactInfo, + final List typeList) { + if (CollectionUtils.isEmpty(typeList) || typeList.contains(resourceType.getValue())) { + return; } + final String listToString = typeList.stream().collect(Collectors.joining(", ")); + throw new ByActionStatusComponentException(MISMATCH_BETWEEN_ARTIFACT_TYPE_AND_COMPONENT_TYPE, + artifactInfo.getArtifactGroupType().getType(), listToString, resourceType.getValue()); } @VisibleForTesting @@ -2082,22 +2131,24 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return Either.left(artifactInfo); } - public List getDeploymentArtifacts(Component parentComponent, NodeTypeEnum parentType, String ciId) { - List deploymentArtifacts = new ArrayList<>(); - if (parentComponent.getDeploymentArtifacts() != null) { - if (NodeTypeEnum.ResourceInstance == parentType && ciId != null) { - Either getRI = getRIFromComponent(parentComponent, ciId, null, null, null); - if (getRI.isRight()) { - return deploymentArtifacts; - } - ComponentInstance ri = getRI.left().value(); - if (ri.getDeploymentArtifacts() != null) { - deploymentArtifacts.addAll(ri.getDeploymentArtifacts().values()); - } + public List getDeploymentArtifacts(final Component component, final String ciId) { + final ComponentTypeEnum componentType = component.getComponentType(); + if (component.getDeploymentArtifacts() == null) { + return Collections.emptyList(); + } + final List deploymentArtifacts = new ArrayList<>(); + if (ComponentTypeEnum.RESOURCE == componentType && ciId != null) { + final Either getRI = + getRIFromComponent(component, ciId, null, null, null); + if (getRI.isRight()) { + return Collections.emptyList(); } - else if (parentComponent.getDeploymentArtifacts() != null) { - deploymentArtifacts.addAll(parentComponent.getDeploymentArtifacts().values()); + final ComponentInstance ri = getRI.left().value(); + if (ri.getDeploymentArtifacts() != null) { + deploymentArtifacts.addAll(ri.getDeploymentArtifacts().values()); } + } else { + deploymentArtifacts.addAll(component.getDeploymentArtifacts().values()); } return deploymentArtifacts; } @@ -2184,90 +2235,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return id; } - private Either validateArtifactType(String userId, ArtifactDefinition artifactInfo, NodeTypeEnum parentType) { - if (artifactInfo.getArtifactType() == null || artifactInfo.getArtifactType().isEmpty()) { - BeEcompErrorManager.getInstance() - .logBeMissingArtifactInformationError("Artifact Update / Upload", "artifactLabel"); - log.debug("Missing artifact type for artifact {}", artifactInfo.getArtifactName()); - return Either.right(componentsUtils.getResponseFormat(ActionStatus.MISSING_ARTIFACT_TYPE)); - } - - boolean artifactTypeExist = false; - Either, ActionStatus> allArtifactTypes = null; - ArtifactGroupTypeEnum artifactGroupType = artifactInfo.getArtifactGroupType(); - - if ((artifactGroupType != null) && artifactGroupType == ArtifactGroupTypeEnum.DEPLOYMENT) { - allArtifactTypes = getDeploymentArtifactTypes(parentType); - } - else { - - allArtifactTypes = elementOperation.getAllArtifactTypes(); - } - if (allArtifactTypes.isRight()) { - BeEcompErrorManager.getInstance() - .logBeInvalidConfigurationError("Artifact Upload / Update", "artifactTypes", allArtifactTypes - .right() - .value() - .name()); - log.debug("Failed to retrieve list of suported artifact types. error: {}", allArtifactTypes.right() - .value()); - return Either.right(componentsUtils.getResponseFormatByUserId(allArtifactTypes.right().value(), userId)); - } - - for (ArtifactType type : allArtifactTypes.left().value()) { - if (type.getName().equalsIgnoreCase(artifactInfo.getArtifactType())) { - artifactInfo.setArtifactType(artifactInfo.getArtifactType().toUpperCase()); - artifactTypeExist = true; - break; - } - } - - if (!artifactTypeExist) { - BeEcompErrorManager.getInstance() - .logBeInvalidTypeError("Artifact Upload / Delete / Update - Not supported artifact type", artifactInfo - .getArtifactType(), "Artifact " + artifactInfo.getArtifactName()); - log.debug("Not supported artifact type = {}", artifactInfo.getArtifactType()); - return Either.right(componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_TYPE_NOT_SUPPORTED, artifactInfo - .getArtifactType())); - } - - return Either.left(ActionStatus.OK); - } - - private Either, ActionStatus> getDeploymentArtifactTypes(NodeTypeEnum parentType) { - - Map deploymentArtifacts ; - List artifactTypes = new ArrayList<>(); - - if (parentType == NodeTypeEnum.Service) { - deploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getServiceDeploymentArtifacts(); - } - else if (parentType == NodeTypeEnum.ResourceInstance) { - deploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceInstanceDeploymentArtifacts(); - } - else { - deploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration() - .getResourceDeploymentArtifacts(); - } - if (deploymentArtifacts != null) { - for (String artifactType : deploymentArtifacts.keySet()) { - ArtifactType artifactT = new ArtifactType(); - artifactT.setName(artifactType); - artifactTypes.add(artifactT); - } - return Either.left(artifactTypes); - } - else { - return Either.right(ActionStatus.GENERAL_ERROR); - } - - } - private Either validateFirstUpdateHasPayload(ArtifactDefinition artifactInfo, ArtifactDefinition currentArtifact) { if (currentArtifact.getEsId() == null && (artifactInfo.getPayloadData() == null || artifactInfo.getPayloadData().length == 0)) { return Either.right(componentsUtils.getResponseFormat(ActionStatus.MISSING_DATA, ARTIFACT_PAYLOAD)); @@ -2922,18 +2889,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return resourceListBySystemName.left().value(); } - /*private Either validateResourceNameAndVersion(String resourceName, String resourceVersion) { - - Either resourceListBySystemName = toscaOperationFacade.getComponentByNameAndVersion(ComponentTypeEnum.RESOURCE, resourceName, resourceVersion, JsonParseFlagEnum.ParseMetadata); - if (resourceListBySystemName.isRight()) { - log.debug("Couldn't fetch any resource with name {} and version {}. ", resourceName, resourceVersion); - return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(resourceListBySystemName - .right() - .value()), resourceName)); - } - return Either.left(resourceListBySystemName.left().value()); - }*/ - public byte[] downloadServiceArtifactByNames(String serviceName, String serviceVersion, String artifactName) { // Validation log.trace("Starting download of service interface artifact, serviceName {}, serviceVersion {}, artifact name {}", serviceName, serviceVersion, artifactName); @@ -3242,6 +3197,29 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return ArtifactGroupTypeEnum.DEPLOYMENT == artifactInfo.getArtifactGroupType(); } + private boolean isInformationalArtifact(final ArtifactDefinition artifactInfo) { + return ArtifactGroupTypeEnum.INFORMATIONAL == artifactInfo.getArtifactGroupType(); + } + + private boolean isHeatArtifact(final ArtifactDefinition artifactInfo) { + final String artifactType = artifactInfo.getArtifactType(); + final ArtifactTypeEnum artifactTypeEnum = ArtifactTypeEnum.parse(artifactType); + if (artifactTypeEnum == null) { + artifactInfo.setTimeout(NodeTemplateOperation.NON_HEAT_TIMEOUT); + return false; + } + switch (artifactTypeEnum) { + case HEAT: + case HEAT_VOL: + case HEAT_NET: + case HEAT_ENV: + return true; + default: + return false; + } + } + + public ArtifactDefinition createArtifactPlaceHolderInfo(String resourceId, String logicalName, Map artifactInfoMap, String userUserId, ArtifactGroupTypeEnum groupType, boolean inTransaction) { User user = userBusinessLogic.getUser(userUserId, inTransaction); return createArtifactPlaceHolderInfo(resourceId, logicalName, artifactInfoMap, user, groupType); @@ -3670,7 +3648,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { if (origMd5 != null) { validateMd5(origMd5, originData, artifactInfo.getPayloadData(), operation); if (ArrayUtils.isNotEmpty(artifactInfo.getPayloadData())) { - validateDeploymentArtifact(parent, componentId, false, artifactInfo, artifactInfo, NodeTypeEnum.ResourceInstance); + validateDeploymentArtifact(artifactInfo, parent); handlePayload(artifactInfo, isArtifactMetadataUpdate(auditingAction)); } else { // duplicate throw new ByActionStatusComponentException(ActionStatus.MISSING_DATA, ARTIFACT_PAYLOAD); @@ -4305,7 +4283,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { Either getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata, true); if (getComponentRes.isRight()) { StorageOperationStatus status = getComponentRes.right().value(); - log.debug("Could not fetch component with type {} and uuid {}. Status is {}. ", componentType, componentUuid, status); + log.debug(FAILED_FETCH_COMPONENT, componentType, componentUuid, status); errorWrapper.setInnerElement(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status))); } @@ -4346,7 +4324,8 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { if (errorWrapper.isEmpty()) { NodeTypeEnum parentType = convertParentType(componentType); - List existingDeploymentArtifacts = getDeploymentArtifacts(toscaComponentEither.left().value(), parentType,null); + final List existingDeploymentArtifacts = + getDeploymentArtifacts(toscaComponentEither.left().value(),null); for (ArtifactDefinition artifactDefinition: existingDeploymentArtifacts){ if(artifactInfo.getArtifactName().equalsIgnoreCase(artifactDefinition.getArtifactName())){ existingArtifactInfo = artifactDefinition; @@ -4909,5 +4888,9 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { this.nodeTemplateOperation = nodeTemplateOperation; } + public List getConfiguration() { + return ConfigurationManager.getConfigurationManager().getConfiguration().getArtifacts(); + } + } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java index 711e6648ed..9c092da300 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java @@ -948,16 +948,12 @@ public class ElementBusinessLogic extends BaseBusinessLogic { return elementOperation.getAllPropertyScopes(); } - public Either, ActionStatus> getAllArtifactTypes(String userId) { + public Either, ActionStatus> getAllArtifactTypes(final String userId) { ActionStatus status = validateUserExistsActionStatus(userId); if (ActionStatus.OK != status) { return Either.right(status); } - return elementOperation.getAllArtifactTypes(); - } - - public Either, ActionStatus> getAllDeploymentArtifactTypes() { - return elementOperation.getAllDeploymentArtifactTypes(); + return Either.left(elementOperation.getAllArtifactTypes()); } public Either getDefaultHeatTimeout() { 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 45f2434482..74f78b2ce1 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 @@ -2448,8 +2448,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { .stream() // create each artifact .map(e -> createOrUpdateSingleNonMetaArtifact(resource, csarInfo, e.getPath(), - e.getArtifactName(), e.getArtifactType() - .getType(), + e.getArtifactName(), e.getArtifactType(), e.getArtifactGroupType(), e.getArtifactLabel(), e.getDisplayName(), CsarUtils.ARTIFACT_CREATED_FROM_CSAR, e.getArtifactUniqueId(), artifactsBusinessLogic.new ArtifactOperationInfo(false, false, @@ -2555,8 +2554,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { private boolean isValidArtifactType(ArtifactDefinition artifact) { boolean result = true; if (artifact.getArtifactType() == null - || ArtifactTypeEnum.findType(artifact.getArtifactType()) == ArtifactTypeEnum.VENDOR_LICENSE - || ArtifactTypeEnum.findType(artifact.getArtifactType()) == ArtifactTypeEnum.VF_LICENSE) { + || ArtifactTypeEnum.parse(artifact.getArtifactType()) == ArtifactTypeEnum.VENDOR_LICENSE + || ArtifactTypeEnum.parse(artifact.getArtifactType()) == ArtifactTypeEnum.VF_LICENSE) { result = false; } return result; @@ -2833,10 +2832,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { private void setResourceInstanceRelationsOnComponent(Resource resource, List relations) { if (resource.getComponentInstancesRelations() != null) { - /*Map relationsMapByUid = resource.getComponentInstancesRelations().stream().collect(Collectors.toMap(r -> r.getUid(), r -> r)); - Map updatedRelationsByUid = relations.stream().collect(Collectors.toMap(r -> r.getUid(), r -> r)); - relationsMapByUid.putAll(updatedRelationsByUid); - resource.setComponentInstancesRelations(new ArrayList<>(relationsMapByUid.values()));*/ resource.getComponentInstancesRelations().addAll(relations); } else { resource.setComponentInstancesRelations(relations); @@ -5816,8 +5811,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { .findFirst() .orElse(null); if (foundArtifact != null) { - if (ArtifactTypeEnum.findType(foundArtifact.getArtifactType()) == currNewArtifact - .getArtifactType()) { + if (foundArtifact.getArtifactType().equals(currNewArtifact.getArtifactType())) { if (!foundArtifact.getArtifactChecksum() .equals(currNewArtifact.getArtifactChecksum())) { currNewArtifact.setArtifactUniqueId(foundArtifact.getUniqueId()); @@ -5839,8 +5833,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { currNewArtifact.getArtifactName()); ResponseFormat responseFormat = ResponseFormatManager.getInstance() .getResponseFormat(ActionStatus.ARTIFACT_ALREADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR, - currNewArtifact.getArtifactName(), currNewArtifact.getArtifactType() - .name(), + currNewArtifact.getArtifactName(), currNewArtifact.getArtifactType(), foundArtifact.getArtifactType()); AuditingActionEnum auditingAction = artifactsBusinessLogic .detectAuditingType(artifactsBusinessLogic.new ArtifactOperationInfo(false, false, @@ -5858,14 +5851,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { for (ArtifactDefinition currArtifact : existingArtifactsToHandle) { if (currArtifact.getIsFromCsar()) { artifactsToDelete.add(new NonMetaArtifactInfo(currArtifact.getArtifactName(), null, - ArtifactTypeEnum.findType(currArtifact.getArtifactType()), - currArtifact.getArtifactGroupType(), null, currArtifact.getUniqueId(), - currArtifact.getIsFromCsar())); + currArtifact.getArtifactType(), + currArtifact.getArtifactGroupType(), null, currArtifact.getUniqueId(), + currArtifact.getIsFromCsar())); } else { artifactsToUpdate.add(new NonMetaArtifactInfo(currArtifact.getArtifactName(), null, - ArtifactTypeEnum.findType(currArtifact.getArtifactType()), - currArtifact.getArtifactGroupType(), null, currArtifact.getUniqueId(), - currArtifact.getIsFromCsar())); + currArtifact.getArtifactType(), + currArtifact.getArtifactGroupType(), null, currArtifact.getUniqueId(), + currArtifact.getIsFromCsar())); } } 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 ba04c00cdb..e946f72851 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 @@ -1909,7 +1909,10 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic { private ArtifactDefinition getVfModuleInstArtifactForCompInstance(ComponentInstance currVF, Service service, Wrapper payloadWrapper, Wrapper responseWrapper) { ArtifactDefinition vfModuleAertifact = null; if (MapUtils.isNotEmpty(currVF.getDeploymentArtifacts())) { - Optional optionalVfModuleArtifact = currVF.getDeploymentArtifacts().values().stream().filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.name())).findAny(); + final Optional optionalVfModuleArtifact = + currVF.getDeploymentArtifacts().values().stream() + .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.getType())) + .findAny(); if (optionalVfModuleArtifact.isPresent()) { vfModuleAertifact = optionalVfModuleArtifact.get(); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java index e4f19355dc..6a74428a90 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java @@ -55,7 +55,7 @@ public class ComponentInstanceArtifactsMerge implements ComponentInstanceMergeIn Map deploymentArtifactsCreatedOnTheInstance = componentInstancesDeploymentArtifacts.entrySet() .stream() .filter(i -> !originalComponentDeploymentArtifacts.containsKey(i.getKey())) - .filter(i -> !ArtifactTypeEnum.VF_MODULES_METADATA.name().equals(i.getValue().getArtifactType())) + .filter(i -> !ArtifactTypeEnum.VF_MODULES_METADATA.getType().equals(i.getValue().getArtifactType())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); dataHolder.setOrigComponentDeploymentArtifactsCreatedOnTheInstance(deploymentArtifactsCreatedOnTheInstance); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java index ccb6960c08..21589e0723 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactTemplateInfo.java @@ -23,27 +23,29 @@ package org.openecomp.sdc.be.info; import com.google.gson.Gson; import com.google.gson.JsonObject; import fj.data.Either; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; import lombok.Getter; import lombok.NoArgsConstructor; - import lombok.Setter; +import org.apache.commons.collections.CollectionUtils; +import org.openecomp.sdc.be.config.ArtifactConfiguration; import org.openecomp.sdc.be.config.BeEcompErrorManager; -import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; +import org.openecomp.sdc.be.config.ComponentType; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.ArtifactType; +import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - @Getter @Setter @NoArgsConstructor @@ -281,27 +283,36 @@ public class ArtifactTemplateInfo { return Either.left(true); } - private static Either, ActionStatus> getDeploymentArtifactTypes(NodeTypeEnum parentType) { + private static Either, ActionStatus> getDeploymentArtifactTypes(final NodeTypeEnum parentType) { - Map deploymentArtifacts = null; - List artifactTypes = new ArrayList<>(); + final List deploymentArtifacts; + final List artifactConfigurationList = + ConfigurationManager.getConfigurationManager().getConfiguration().getArtifacts(); - if (parentType.equals(NodeTypeEnum.Service)) { - deploymentArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration().getServiceDeploymentArtifacts(); + if (parentType == NodeTypeEnum.Service) { + deploymentArtifacts = artifactConfigurationList.stream() + .filter(artifactConfiguration -> + artifactConfiguration.hasSupport(ArtifactGroupTypeEnum.DEPLOYMENT) + && artifactConfiguration.hasSupport(ComponentType.SERVICE)) + .collect(Collectors.toList()); } else { - deploymentArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration().getResourceDeploymentArtifacts(); + deploymentArtifacts = artifactConfigurationList.stream() + .filter(artifactConfiguration -> + artifactConfiguration.hasSupport(ArtifactGroupTypeEnum.DEPLOYMENT) + && artifactConfiguration.hasSupport(ComponentType.RESOURCE)) + .collect(Collectors.toList()); } - if (deploymentArtifacts != null) { - for (String artifactType : deploymentArtifacts.keySet()) { - ArtifactType artifactT = new ArtifactType(); - artifactT.setName(artifactType); - artifactTypes.add(artifactT); - } + final List artifactTypes = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(deploymentArtifacts)) { + deploymentArtifacts.forEach(artifactConfiguration -> { + final ArtifactType artifactType = new ArtifactType(); + artifactType.setName(artifactConfiguration.getType()); + artifactTypes.add(artifactType); + }); return Either.left(artifactTypes); - } else { - return Either.right(ActionStatus.GENERAL_ERROR); } + return Either.right(ActionStatus.GENERAL_ERROR); } public static int compareByGroupName(ArtifactTemplateInfo art1, ArtifactTemplateInfo art2) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java index c350812ce4..befdac48b0 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java @@ -31,6 +31,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.servers.Server; import io.swagger.v3.oas.annotations.servers.Servers; import io.swagger.v3.oas.annotations.tags.Tags; +import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic; import org.openecomp.sdc.be.components.impl.ElementBusinessLogic; import org.openecomp.sdc.be.components.impl.aaf.AafPermission; import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed; @@ -85,7 +86,7 @@ import java.util.Map; @Path("/v1/") -/**** +/** * * UI oriented servlet - to return elements in specific format UI needs * @@ -101,17 +102,18 @@ public class ElementServlet extends BeGenericServlet { private static final String START_HANDLE_REQUEST_OF = "Start handle request of {}"; private final ComponentsCleanBusinessLogic componentsCleanBusinessLogic; private final ElementBusinessLogic elementBusinessLogic; - private final UserBusinessLogic userBusinessLogic; + private final ArtifactsBusinessLogic artifactsBusinessLogic; @Inject - public ElementServlet(UserBusinessLogic userBusinessLogic, - ComponentsUtils componentsUtils, - ComponentsCleanBusinessLogic componentsCleanBusinessLogic, - ElementBusinessLogic elementBusinessLogic) { + public ElementServlet(final UserBusinessLogic userBusinessLogic, + final ComponentsUtils componentsUtils, + final ComponentsCleanBusinessLogic componentsCleanBusinessLogic, + final ElementBusinessLogic elementBusinessLogic, + final ArtifactsBusinessLogic artifactsBusinessLogic) { super(userBusinessLogic, componentsUtils); this.componentsCleanBusinessLogic = componentsCleanBusinessLogic; this.elementBusinessLogic = elementBusinessLogic; - this.userBusinessLogic = userBusinessLogic; + this.artifactsBusinessLogic = artifactsBusinessLogic; } /* @@ -163,33 +165,6 @@ public class ElementServlet extends BeGenericServlet { } } - //TODO remove after UI alignment and tests after API consolidation ASDC-191 - /* @GET - @Path("/categories") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Retrieve the all resource, service and product categories", httpMethod = "GET", notes = "Retrieve the all resource, service and product categories", response = Response.class) - @ApiResponses(value = {@ApiResponse(code = 200, message = "Returns categories Ok"), @ApiResponse(code = 403, message = "Missing information"), - @ApiResponse(code = 409, message = "Restricted operation"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public Response getAllCategories(@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) { - - try { - ElementBusinessLogic elementBL = getElementBL(request.getSession().getServletContext()); - Either either = elementBL.getAllCategories(userId); - if (either.isRight()) { - log.debug("No categories were found"); - return buildErrorResponse(either.right().value()); - } else { - return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), either.left().value()); - } - } catch (Exception e) { - BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get All Categories"); - log.debug("getAllCategories failed with exception", e); - return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR)); - } - }*/ - - @POST @Path("/category/{componentType}") @Consumes(MediaType.APPLICATION_JSON) @@ -712,7 +687,7 @@ public class ElementServlet extends BeGenericServlet { try { ServletContext servletContext = request.getSession().getServletContext(); - Map configuration = getConfigurationUi(elementBusinessLogic, userId); + Map configuration = getConfigurationUi(elementBusinessLogic); if (!configuration.isEmpty()) { consolidatedObject.put("configuration", configuration); } else { @@ -743,22 +718,12 @@ public class ElementServlet extends BeGenericServlet { return version; } - private Map getConfigurationUi(ElementBusinessLogic elementBL, String userId) { + private Map getConfigurationUi(final ElementBusinessLogic elementBL) { Either defaultHeatTimeout = elementBL.getDefaultHeatTimeout(); - Either, ActionStatus> deploymentEither = elementBL.getAllDeploymentArtifactTypes(); Either, ActionStatus> resourceTypesMap = elementBL.getResourceTypesMap(); - Either, ActionStatus> otherEither = elementBL.getAllArtifactTypes(userId); Map configuration = new HashMap<>(); - if (otherEither.isRight() || otherEither.left().value() == null) { - log.debug("No other artifact types were found"); - return configuration; - } - if (deploymentEither.isRight() || deploymentEither.left().value() == null) { - log.debug("No deployment artifact types were found"); - return configuration; - } if (defaultHeatTimeout.isRight() || defaultHeatTimeout.left().value() == null) { log.debug("heat default timeout was not found"); return configuration; @@ -767,10 +732,7 @@ public class ElementServlet extends BeGenericServlet { log.debug("No resource types were found"); return configuration; } - Map artifacts = new HashMap<>(); - artifacts.put("other", otherEither.left().value()); - artifacts.put("deployment", deploymentEither.left().value()); - configuration.put("artifacts", artifacts); + configuration.put("artifact", artifactsBusinessLogic.getConfiguration()); configuration.put("heatDeploymentTimeout", defaultHeatTimeout.left().value()); configuration.put("componentTypes", elementBL.getAllComponentTypesParamNames()); configuration.put("roles", elementBL.getAllSupportedRoles()); 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 604715d05d..92a1f8016c 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 @@ -41,6 +41,8 @@ import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; @@ -50,10 +52,12 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutableTriple; import org.apache.commons.lang3.tuple.Triple; import org.onap.sdc.tosca.services.YamlUtil; +import org.openecomp.sdc.be.config.ArtifactConfigManager; import org.openecomp.sdc.be.components.impl.ImportUtils; import org.openecomp.sdc.be.components.impl.ImportUtils.Constants; import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException; -import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; +import org.openecomp.sdc.be.config.ArtifactConfiguration; +import org.openecomp.sdc.be.config.ComponentType; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao; @@ -68,7 +72,6 @@ import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Product; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; @@ -115,7 +118,7 @@ public class CsarUtils { private ToscaExportHandler toscaExportUtils; @Autowired protected ToscaOperationFacade toscaOperationFacade; - + @Autowired(required = false) private List generators; @@ -754,19 +757,23 @@ public class CsarUtils { return artifact; } + @Getter public static final class NonMetaArtifactInfo { + @Setter + private String artifactUniqueId; private final String path; private final String artifactName; private final String displayName; private final String artifactLabel; - private final ArtifactTypeEnum artifactType; + private final String artifactType; private final ArtifactGroupTypeEnum artifactGroupType; - private String payloadData; - private String artifactChecksum; - private String artifactUniqueId; + private final String payloadData; + private final String artifactChecksum; private final boolean isFromCsar; - public NonMetaArtifactInfo(String artifactName, String path, ArtifactTypeEnum artifactType, ArtifactGroupTypeEnum artifactGroupType, byte[] payloadData, String artifactUniqueId, boolean isFromCsar) { + public NonMetaArtifactInfo(final String artifactName, final String path, final String artifactType, + final ArtifactGroupTypeEnum artifactGroupType, final byte[] payloadData, + final String artifactUniqueId, final boolean isFromCsar) { super(); this.path = path; this.isFromCsar = isFromCsar; @@ -780,57 +787,16 @@ public class CsarUtils { displayName = artifactName; } this.artifactLabel = ValidationUtils.normalizeArtifactLabel(artifactName); - if (payloadData != null) { + if (payloadData == null) { + this.payloadData = null; + this.artifactChecksum = null; + } else { this.payloadData = Base64.encodeBase64String(payloadData); this.artifactChecksum = GeneralUtility.calculateMD5Base64EncodedByByteArray(payloadData); } this.artifactUniqueId = artifactUniqueId; } - public String getPath() { - return path; - } - - public String getArtifactName() { - return artifactName; - } - - public ArtifactTypeEnum getArtifactType() { - return artifactType; - } - - public String getDisplayName() { - return displayName; - } - - public ArtifactGroupTypeEnum getArtifactGroupType() { - return artifactGroupType; - } - - public String getArtifactLabel() { - return artifactLabel; - } - - public boolean isFromCsar(){ - return isFromCsar; - } - - public String getPayloadData() { - return payloadData; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public String getArtifactUniqueId() { - return artifactUniqueId; - } - - public void setArtifactUniqueId(String artifactUniqueId) { - this.artifactUniqueId = artifactUniqueId; - } - } /** @@ -855,7 +821,7 @@ public class CsarUtils { artifactType = detectArtifactTypeVF(groupTypeEnum, artifactType, collectedWarningMessages); String artifactFileNameType = parsedArtifactPath[3]; - ret = Either.left(new NonMetaArtifactInfo(artifactFileNameType, artifactPath, ArtifactTypeEnum.findType(artifactType), groupTypeEnum, payloadData, null, true)); + ret = Either.left(new NonMetaArtifactInfo(artifactFileNameType, artifactPath, artifactType, groupTypeEnum, payloadData, null, true)); } else { ret = Either.right(eitherGroupType.right().value()); @@ -878,37 +844,21 @@ public class CsarUtils { return detectArtifactType(artifactGroupType, receivedTypeName, warningMessage, collectedWarningMessages); } - private static String detectArtifactType(ArtifactGroupTypeEnum artifactGroupType, String receivedTypeName, String warningMessage, Map>> collectedWarningMessages, String... arguments) { - - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(receivedTypeName); - Map resourceValidTypeArtifacts = null; - - if(artifactGroupType != null){ - switch (artifactGroupType) { - case INFORMATIONAL: - resourceValidTypeArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration() - .getResourceInformationalArtifacts(); - break; - case DEPLOYMENT: - resourceValidTypeArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration() - .getResourceDeploymentArtifacts(); - break; - default: - break; - } - } - - Set validArtifactTypes = null; - if(resourceValidTypeArtifacts != null){ - validArtifactTypes = resourceValidTypeArtifacts.keySet(); - } - - if (validArtifactTypes == null || artifactType == null || !validArtifactTypes.contains(artifactType.getType())) { - List messageArguments = new ArrayList<>(); + private static String detectArtifactType(final ArtifactGroupTypeEnum artifactGroupType, + final String receivedTypeName, final String warningMessage, + final Map>> collectedWarningMessages, + final String... arguments) { + final ArtifactConfiguration artifactConfiguration = + ArtifactConfigManager.getInstance() + .find(receivedTypeName, artifactGroupType, ComponentType.RESOURCE) + .orElse(null); + + if (artifactConfiguration == null) { + final List messageArguments = new ArrayList<>(); messageArguments.add(receivedTypeName); messageArguments.addAll(Arrays.asList(arguments)); if (!collectedWarningMessages.containsKey(warningMessage)) { - Set> messageArgumentLists = new HashSet<>(); + final Set> messageArgumentLists = new HashSet<>(); messageArgumentLists.add(messageArguments); collectedWarningMessages.put(warningMessage, messageArgumentLists); } else { @@ -916,7 +866,7 @@ public class CsarUtils { } } - return artifactType == null ? ArtifactTypeEnum.OTHER.getType() : artifactType.getType(); + return artifactConfiguration == null ? ArtifactTypeEnum.OTHER.getType() : receivedTypeName; } private Either writeAllFilesToCsar(Component mainComponent, CsarDefinition csarDefinition, ZipOutputStream zipstream, boolean isInCertificationRequest) throws IOException{ @@ -929,7 +879,7 @@ public class CsarUtils { } ComponentTypeArtifacts mainTypeAndCIArtifacts = componentArtifacts.getMainTypeAndCIArtifacts(); - writeComponentArtifactsToSpecifiedPath = writeArtifactsInfoToSpecifiedtPath(mainComponent, mainTypeAndCIArtifacts.getComponentArtifacts(), zipstream, ARTIFACTS_PATH, isInCertificationRequest); + writeComponentArtifactsToSpecifiedPath = writeArtifactsInfoToSpecifiedPath(mainComponent, mainTypeAndCIArtifacts.getComponentArtifacts(), zipstream, ARTIFACTS_PATH, isInCertificationRequest); if(writeComponentArtifactsToSpecifiedPath.isRight()){ return Either.right(writeComponentArtifactsToSpecifiedPath.right().value()); @@ -942,7 +892,7 @@ public class CsarUtils { for (String keyAssetName : keySet) { ArtifactsInfo artifactsInfo = componentInstancesArtifacts.get(keyAssetName); String pathWithAssetName = currentPath + keyAssetName + PATH_DELIMITER; - writeComponentArtifactsToSpecifiedPath = writeArtifactsInfoToSpecifiedtPath(mainComponent, artifactsInfo, zipstream, pathWithAssetName, isInCertificationRequest); + writeComponentArtifactsToSpecifiedPath = writeArtifactsInfoToSpecifiedPath(mainComponent, artifactsInfo, zipstream, pathWithAssetName, isInCertificationRequest); if(writeComponentArtifactsToSpecifiedPath.isRight()){ return Either.right(writeComponentArtifactsToSpecifiedPath.right().value()); @@ -1036,7 +986,7 @@ public class CsarUtils { ComponentTypeArtifacts componentInstanceArtifacts = componentTypeArtifacts.get(keyAssetName); ArtifactsInfo componentArtifacts2 = componentInstanceArtifacts.getComponentArtifacts(); String pathWithAssetName = currentPath + keyAssetName + PATH_DELIMITER; - Either writeArtifactsInfoToSpecifiedPath = writeArtifactsInfoToSpecifiedtPath(mainComponent, componentArtifacts2, zipstream, pathWithAssetName, isInCertificationRequest); + Either writeArtifactsInfoToSpecifiedPath = writeArtifactsInfoToSpecifiedPath(mainComponent, componentArtifacts2, zipstream, pathWithAssetName, isInCertificationRequest); if(writeArtifactsInfoToSpecifiedPath.isRight()){ return writeArtifactsInfoToSpecifiedPath; @@ -1046,32 +996,34 @@ public class CsarUtils { return Either.left(zipstream); } - private Either writeArtifactsInfoToSpecifiedtPath(Component mainComponent, ArtifactsInfo currArtifactsInfo, ZipOutputStream zip, String path, boolean isInCertificationRequest) throws IOException { - Map>> artifactsInfo = currArtifactsInfo - .getArtifactsInfo(); - Set groupTypeEnumKeySet = artifactsInfo.keySet(); - - for (ArtifactGroupTypeEnum artifactGroupTypeEnum : groupTypeEnumKeySet) { - String groupTypeFolder = path + WordUtils.capitalizeFully(artifactGroupTypeEnum.getType()) + PATH_DELIMITER; + private Either writeArtifactsInfoToSpecifiedPath(final Component mainComponent, + final ArtifactsInfo currArtifactsInfo, + final ZipOutputStream zip, + final String path, + final boolean isInCertificationRequest) throws IOException { + final Map>> artifactsInfo = + currArtifactsInfo.getArtifactsInfo(); + for (final ArtifactGroupTypeEnum artifactGroupTypeEnum : artifactsInfo.keySet()) { + final String groupTypeFolder = path + WordUtils.capitalizeFully(artifactGroupTypeEnum.getType()) + PATH_DELIMITER; - Map> artifactTypesMap = artifactsInfo.get(artifactGroupTypeEnum); - Set artifactTypeEnumKeySet = artifactTypesMap.keySet(); + final Map> artifactTypesMap = artifactsInfo.get(artifactGroupTypeEnum); - for (ArtifactTypeEnum artifactTypeEnum : artifactTypeEnumKeySet) { - List artifactDefinitionList = artifactTypesMap.get(artifactTypeEnum); - String artifactTypeFolder = groupTypeFolder + artifactTypeEnum.toString() + PATH_DELIMITER; + for (final String artifactType : artifactTypesMap.keySet()) { + final List artifactDefinitionList = artifactTypesMap.get(artifactType); + String artifactTypeFolder = groupTypeFolder + artifactType + PATH_DELIMITER; - if(artifactTypeEnum == ArtifactTypeEnum.WORKFLOW && path.contains(ARTIFACTS_PATH + RESOURCES_PATH)){ + if(ArtifactTypeEnum.WORKFLOW.getType().equals(artifactType) && path.contains(ARTIFACTS_PATH + RESOURCES_PATH)){ // Ignore this packaging as BPMN artifacts needs to be packaged in different manner continue; } - if (artifactTypeEnum == ArtifactTypeEnum.WORKFLOW) { + if (ArtifactTypeEnum.WORKFLOW.getType().equals(artifactType)) { artifactTypeFolder += OperationArtifactUtil.BPMN_ARTIFACT_PATH + File.separator; } - Either writeArtifactDefinition = writeArtifactDefinition(mainComponent, zip, artifactDefinitionList, artifactTypeFolder, isInCertificationRequest); + Either writeArtifactDefinition = + writeArtifactDefinition(mainComponent, zip, artifactDefinitionList, artifactTypeFolder, isInCertificationRequest); - if(writeArtifactDefinition.isRight()){ + if (writeArtifactDefinition.isRight()) { return writeArtifactDefinition; } } @@ -1121,29 +1073,22 @@ public class CsarUtils { private class ArtifactsInfo { //Key is the type of artifacts(Informational/Deployment) //Value is a map between an artifact type and a list of all artifacts of this type - private Map>> artifactsInfoField; + private Map>> artifactsInfoField; public ArtifactsInfo() { this.artifactsInfoField = new EnumMap<>(ArtifactGroupTypeEnum.class); } - public Map>> getArtifactsInfo() { + public Map>> getArtifactsInfo() { return artifactsInfoField; } - public List getFlatArtifactsListByType(ArtifactTypeEnum artifactType){ - List artifacts = new ArrayList<>(); - for (List artifactsByType:artifactsInfoField.get(artifactType).values()){ - artifacts.addAll(artifactsByType); - } - return artifacts; - } - - public void addArtifactsToGroup(ArtifactGroupTypeEnum artifactGroup,Map> artifactsDefinition){ + public void addArtifactsToGroup(ArtifactGroupTypeEnum artifactGroup, + Map> artifactsDefinition) { if (artifactsInfoField.get(artifactGroup) == null) { artifactsInfoField.put(artifactGroup, artifactsDefinition); } else { - Map> artifactTypeEnumListMap = + Map> artifactTypeEnumListMap = artifactsInfoField.get(artifactGroup); artifactTypeEnumListMap.putAll(artifactsDefinition); artifactsInfoField.put(artifactGroup, artifactTypeEnumListMap); @@ -1295,8 +1240,8 @@ public class CsarUtils { private String printArtifacts(ComponentTypeArtifacts componentInstanceArtifacts) { StringBuilder result = new StringBuilder(); ArtifactsInfo artifactsInfo = componentInstanceArtifacts.getComponentArtifacts(); - Map>> componetArtifacts = artifactsInfo.getArtifactsInfo(); - printArtifacts(componetArtifacts); + Map>> componentArtifacts = artifactsInfo.getArtifactsInfo(); + printArtifacts(componentArtifacts); result = result.append("Resources\n"); for (Map.Entry resourceInstance:componentInstanceArtifacts.getComponentInstancesArtifacts().entrySet()){ result.append("Folder" + resourceInstance.getKey() + "\n"); @@ -1306,12 +1251,12 @@ public class CsarUtils { return result.toString(); } - private String printArtifacts(Map>> componetArtifacts) { + private String printArtifacts(Map>> componetArtifacts) { StringBuilder result = new StringBuilder(); - for (Map.Entry>> artifactGroup:componetArtifacts.entrySet()){ + for (Map.Entry>> artifactGroup:componetArtifacts.entrySet()){ result.append(" " + artifactGroup.getKey().getType()); - for (Map.Entry> groupArtifacts:artifactGroup.getValue().entrySet()){ - result.append(" " + groupArtifacts.getKey().getType()); + for (Map.Entry> groupArtifacts:artifactGroup.getValue().entrySet()){ + result.append(" " + groupArtifacts.getKey()); for (ArtifactDefinition artifact:groupArtifacts.getValue()){ result.append(" " + artifact.getArtifactDisplayName()); } @@ -1361,10 +1306,10 @@ public class CsarUtils { ComponentTypeArtifacts componentParentArtifacts = collectComponentTypeArtifacts(resourcesTypeArtifacts, componentInstance, fetchedComponent); //3. find the artifacts specific to the instance - Map> componentInstanceSpecificInformationalArtifacts = + Map> componentInstanceSpecificInformationalArtifacts = getComponentInstanceSpecificArtifacts(componentInstance.getArtifacts(), componentParentArtifacts.getComponentArtifacts().getArtifactsInfo(), ArtifactGroupTypeEnum.INFORMATIONAL); - Map> componentInstanceSpecificDeploymentArtifacts = + Map> componentInstanceSpecificDeploymentArtifacts = getComponentInstanceSpecificArtifacts(componentInstance.getDeploymentArtifacts(), componentParentArtifacts.getComponentArtifacts().getArtifactsInfo(), ArtifactGroupTypeEnum.DEPLOYMENT); @@ -1402,24 +1347,23 @@ public class CsarUtils { public void setVersionFirstThreeOctets(String versionFirstThreeOctetes) { this.versionFirstThreeOctets = versionFirstThreeOctetes; } - private Map> getComponentInstanceSpecificArtifacts(Map componentArtifacts, - Map>> componentTypeArtifacts, ArtifactGroupTypeEnum artifactGroupTypeEnum) { - Map> parentArtifacts = componentTypeArtifacts.get(artifactGroupTypeEnum); //the artfiacts of the component itself and not the instance + private Map> getComponentInstanceSpecificArtifacts(Map componentArtifacts, + Map>> componentTypeArtifacts, ArtifactGroupTypeEnum artifactGroupTypeEnum) { + Map> parentArtifacts = componentTypeArtifacts.get(artifactGroupTypeEnum); //the artfiacts of the component itself and not the instance - Map> artifactsByTypeOfComponentInstance = new EnumMap<>(ArtifactTypeEnum.class); + Map> artifactsByTypeOfComponentInstance = new HashMap<>(); if (componentArtifacts!=null){ for (ArtifactDefinition artifact:componentArtifacts.values()){ - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifact.getArtifactType()); List parentArtifactsByType = null; if (parentArtifacts!=null){ - parentArtifactsByType = parentArtifacts.get(artifactType); + parentArtifactsByType = parentArtifacts.get(artifact.getArtifactType()); } //the artifact is of instance if (parentArtifactsByType == null || !parentArtifactsByType.contains(artifact)){ - List typeArtifacts = artifactsByTypeOfComponentInstance.get(artifactType); + List typeArtifacts = artifactsByTypeOfComponentInstance.get(artifact.getArtifactType()); if (typeArtifacts == null){ typeArtifacts = new ArrayList<>(); - artifactsByTypeOfComponentInstance.put(artifactType, typeArtifacts); + artifactsByTypeOfComponentInstance.put(artifact.getArtifactType(), typeArtifacts); } typeArtifacts.add(artifact); } @@ -1431,12 +1375,12 @@ public class CsarUtils { private ArtifactsInfo collectComponentArtifacts(Component component) { Map informationalArtifacts = component.getArtifacts(); - Map> informationalArtifactsByType = collectGroupArtifacts(informationalArtifacts); + Map> informationalArtifactsByType = collectGroupArtifacts(informationalArtifacts); Map deploymentArtifacts = component.getDeploymentArtifacts(); - Map> deploymentArtifactsByType = collectGroupArtifacts(deploymentArtifacts); + Map> deploymentArtifactsByType = collectGroupArtifacts(deploymentArtifacts); Map interfaceOperationArtifacts = OperationArtifactUtil.getDistinctInterfaceOperationArtifactsByName(component); - Map> interfaceOperationArtifactsByType = collectGroupArtifacts( + Map> interfaceOperationArtifactsByType = collectGroupArtifacts( interfaceOperationArtifacts); ArtifactsInfo artifactsInfo = new ArtifactsInfo(); if (!informationalArtifactsByType.isEmpty()){ @@ -1453,16 +1397,13 @@ public class CsarUtils { return artifactsInfo; } - private Map> collectGroupArtifacts(Map componentArtifacts) { - Map> artifactsByType = new EnumMap<>(ArtifactTypeEnum.class); - for (ArtifactDefinition artifact:componentArtifacts.values()){ - if (artifact.getArtifactUUID()!=null){ - ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifact.getArtifactType()); - List typeArtifacts = artifactsByType.get(artifactType); - if (typeArtifacts==null){ - typeArtifacts = new ArrayList<>(); - artifactsByType.put(artifactType, typeArtifacts); - } + private Map> collectGroupArtifacts( + final Map componentArtifacts) { + final Map> artifactsByType = new HashMap<>(); + for (final ArtifactDefinition artifact : componentArtifacts.values()) { + if (artifact.getArtifactUUID() != null) { + artifactsByType.putIfAbsent(artifact.getArtifactType(), new ArrayList<>()); + final List typeArtifacts = artifactsByType.get(artifact.getArtifactType()); typeArtifacts.add(artifact); } } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java index bab82ada1b..08e4406d6a 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java @@ -16,6 +16,13 @@ package org.openecomp.sdc.be.tosca.utils; +import java.io.File; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.WordUtils; import org.openecomp.sdc.be.components.impl.ImportUtils.Constants; @@ -33,15 +40,6 @@ import org.openecomp.sdc.be.tosca.CsarUtils; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.common.api.ArtifactTypeEnum; - -import java.io.File; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - public class OperationArtifactUtil { public static final String BPMN_ARTIFACT_PATH = "BPMN"; @@ -86,11 +84,11 @@ public class OperationArtifactUtil { return implementationArtifactName.substring(1, implementationArtifactName.length()-1); } else { return CsarUtils.ARTIFACTS + File.separator + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) - + File.separator + ArtifactTypeEnum.WORKFLOW.name() + File.separator + BPMN_ARTIFACT_PATH + + File.separator + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + File.separator + operation.getImplementation().getArtifactName(); } } - + private static boolean artifactNameIsALiteralValue(final String artifactName) { return artifactName.startsWith(Constants.ESCAPED_DOUBLE_QUOTE) && artifactName.endsWith(Constants.ESCAPED_DOUBLE_QUOTE); } @@ -99,7 +97,7 @@ public class OperationArtifactUtil { OperationDataDefinition operation) { return CsarUtils.ARTIFACTS + File.separator + toscaComponentName + File.separator + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) + File.separator + - ArtifactTypeEnum.WORKFLOW.name() + File.separator + BPMN_ARTIFACT_PATH + File.separator + + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + File.separator + operation.getImplementation().getArtifactName(); } diff --git a/catalog-be/src/main/resources/config/configuration.yaml b/catalog-be/src/main/resources/config/configuration.yaml index f6d12fcfa0..b56c243093 100644 --- a/catalog-be/src/main/resources/config/configuration.yaml +++ b/catalog-be/src/main/resources/config/configuration.yaml @@ -121,31 +121,6 @@ cassandraConfig: - { name: sdccomponent, replicationStrategy: NetworkTopologyStrategy, replicationInfo: ['DC-sdc-iltlv650', '1']} - { name: sdcrepository, replicationStrategy: NetworkTopologyStrategy, replicationInfo: ['DC-sdc-iltlv650', '1']} -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - - CONTROLLER_BLUEPRINT_ARCHIVE - - PNF_SW_INFORMATION - licenseTypes: - User - Installation diff --git a/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java b/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java index b1c0330d4f..48a317bcf0 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java @@ -110,13 +110,7 @@ public class ElementOperationMock implements IElementOperation { } @Override - public Either, ActionStatus> getAllArtifactTypes() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Either, ActionStatus> getAllDeploymentArtifactTypes() { + public List getAllArtifactTypes() { // TODO Auto-generated method stub return null; } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java index 0b9542c269..bbe453e755 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java @@ -20,6 +20,9 @@ package org.openecomp.sdc.be.components.distribution.engine; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + import mockit.Deencapsulation; import org.junit.Assert; import org.junit.Test; @@ -130,23 +133,11 @@ public class ArtifactInfoImplTest extends BeConfDependentTest { } @Test - public void testGetArtifactType() throws Exception { - ArtifactInfoImpl testSubject; - ArtifactTypeEnum result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getArtifactType(); - } - - @Test - public void testSetArtifactType() throws Exception { - ArtifactInfoImpl testSubject; - ArtifactTypeEnum artifactType = null; - - // default test - testSubject = createTestSubject(); - testSubject.setArtifactType(ArtifactTypeEnum.AAI_SERVICE_MODEL); + public void testSetArtifactType() { + final ArtifactInfoImpl testSubject = createTestSubject(); + final String expectedType = ArtifactTypeEnum.AAI_SERVICE_MODEL.getType(); + testSubject.setArtifactType(expectedType); + assertThat("Artifact type should be the same", testSubject.getArtifactType(), is(expectedType)); } @Test 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 e401df3920..3fb25dfc77 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 @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import fj.data.Either; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,11 +38,12 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnitRunner; import org.openecomp.sdc.be.components.ArtifactsResolver; +import org.openecomp.sdc.be.config.ArtifactConfigManager; import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; import org.openecomp.sdc.be.components.utils.ArtifactBuilder; import org.openecomp.sdc.be.components.utils.ObjectGenerator; -import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; -import org.openecomp.sdc.be.config.ConfigurationManager; +import org.openecomp.sdc.be.config.ArtifactConfiguration; +import org.openecomp.sdc.be.config.ComponentType; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao; import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; @@ -432,15 +434,22 @@ public class ArtifactBusinessLogicTest extends BaseBusinessLogicMock{ } @Test - public void testValidMibAritactsConfiguration() { - Map componentDeploymentArtifacts = - ConfigurationManager.getConfigurationManager().getConfiguration().getResourceDeploymentArtifacts(); - Map componentInstanceDeploymentArtifacts = - ConfigurationManager.getConfigurationManager().getConfiguration().getResourceInstanceDeploymentArtifacts(); - assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue(); - assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue(); - assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue(); - assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue(); + public void testValidMibArtifactsConfiguration() { + final ArtifactConfigManager artifactConfigManager = ArtifactConfigManager.getInstance(); + Optional artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_POLL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_TRAP.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_POLL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE_INSTANCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_TRAP.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE_INSTANCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java index edf561b717..cd7d9d556a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java @@ -22,6 +22,28 @@ package org.openecomp.sdc.be.components.impl; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_ENV_NAME; +import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_VF_ENV_NAME; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; @@ -30,6 +52,15 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import fj.data.Either; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; import mockit.Deencapsulation; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections.CollectionUtils; @@ -48,11 +79,15 @@ import org.openecomp.sdc.be.MockGenerator; import org.openecomp.sdc.be.components.ArtifactsResolver; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo; +import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException; import org.openecomp.sdc.be.components.impl.exceptions.ComponentException; import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; import org.openecomp.sdc.be.components.utils.ArtifactBuilder; import org.openecomp.sdc.be.components.utils.ObjectGenerator; import org.openecomp.sdc.be.components.validation.UserValidations; +import org.openecomp.sdc.be.config.ArtifactConfigManager; +import org.openecomp.sdc.be.config.ArtifactConfiguration; +import org.openecomp.sdc.be.config.ComponentType; import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -107,42 +142,13 @@ import org.openecomp.sdc.common.datastructure.Wrapper; import org.openecomp.sdc.common.util.GeneralUtility; import org.openecomp.sdc.exception.ResponseFormat; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_ENV_NAME; -import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_VF_ENV_NAME; - @RunWith(MockitoJUnitRunner.Silent.class) -public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ +public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { private static final User USER = new User("John", "Doh", "jh0003", "jh0003@gmail.com", "ADMIN", System.currentTimeMillis()); private static final String RESOURCE_INSTANCE_NAME = "Service-111"; private static final String INSTANCE_ID = "S-123-444-ghghghg"; - private static final String ARTIFACT_NAME = "service-Myservice-template.yml"; private static final String ARTIFACT_LABEL = "assettoscatemplate"; private static final String ES_ARTIFACT_ID = "123123dfgdfgd0"; @@ -150,7 +156,6 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ private static final String RESOURCE_NAME = "My-Resource_Name with space"; private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3"; private static final String RESOURCE_SUBCATEGORY = "Router"; - public static final String RESOURCE_CATEGORY = "Network Layer 2-3/Router"; private static final String ARTIFACT_PLACEHOLDER_FILE_EXTENSION = "fileExtension"; public static final Resource resource = Mockito.mock(Resource.class); @@ -158,7 +163,6 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ private ArtifactsBusinessLogic artifactBL; private static User user = null; private static Resource resourceResponse = null; - private static ResponseFormatManager responseManager = null; final ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class); @Mock public ComponentsUtils componentsUtils; @@ -196,15 +200,13 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ private Gson gson = new GsonBuilder().setPrettyPrinting().create(); private static List getAllTypes() { - List artifactTypes = new ArrayList(); - List artifactTypesList = ConfigurationManager.getConfigurationManager().getConfiguration() - .getArtifactTypes(); - for (String artifactType : artifactTypesList) { - ArtifactType artifactT = new ArtifactType(); - artifactT.setName(artifactType); - artifactTypes.add(artifactT); - } - return artifactTypes; + final List artifactConfigurationList = ConfigurationManager.getConfigurationManager() + .getConfiguration().getArtifacts(); + return artifactConfigurationList.stream().map(artifactConfiguration -> { + final ArtifactType artifactType = new ArtifactType(); + artifactType.setName(artifactConfiguration.getType()); + return artifactType; + }).collect(Collectors.toList()); } @Before @@ -227,8 +229,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ when(userOperation.getUserData("jh0003", false)).thenReturn(Either.left(USER)); - Either, ActionStatus> getType = Either.left(getAllTypes()); - when(elementOperation.getAllArtifactTypes()).thenReturn(getType); + when(elementOperation.getAllArtifactTypes()).thenReturn(getAllTypes()); when(resource.getResourceType()).thenReturn(ResourceTypeEnum.VFC); @@ -665,15 +666,22 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ } @Test - public void testValidMibAritactsConfiguration() { - Map componentDeploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration().getResourceDeploymentArtifacts(); - Map componentInstanceDeploymentArtifacts = ConfigurationManager - .getConfigurationManager().getConfiguration().getResourceInstanceDeploymentArtifacts(); - assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue(); - assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue(); - assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue(); - assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue(); + public void testValidMibArtifactsConfiguration() { + final ArtifactConfigManager artifactConfigManager = ArtifactConfigManager.getInstance(); + Optional artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_POLL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_TRAP.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_POLL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE_INSTANCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_TRAP.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE_INSTANCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); } @Test @@ -1051,7 +1059,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ } @Test - public void testFindArtifactOnParentComponent() throws Exception { + public void testFindArtifactOnParentComponent() { ArtifactsBusinessLogic testSubject; Component component = createResourceObject(true); ComponentTypeEnum componentType = ComponentTypeEnum.RESOURCE; @@ -1063,7 +1071,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ // default test testSubject = createTestSubject(); - result = Deencapsulation.invoke(testSubject, "findArtifactOnParentComponent", new Object[]{component, + result = Deencapsulation.invoke(testSubject, "findArtifact", new Object[]{component, componentType, parentId, operation, artifactId}); } @@ -1154,9 +1162,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ new Object[]{componentId, instanceId, componentType}); } - @Test - public void testFindComponentInstance() throws Exception { + public void testFindComponentInstance() { ArtifactsBusinessLogic testSubject; String componentInstanceId = ""; Component component = createResourceObject(true); @@ -1168,9 +1175,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ new Object[]{componentInstanceId, component}); } - - @Test(expected= ComponentException.class) - public void testDeploymentArtifactTypeIsLegalForParent_shouldThrowException() throws Exception { + @Test(expected = ComponentException.class) + public void testDeploymentArtifactTypeIsLegalForParent_shouldThrowException() { ArtifactsBusinessLogic testSubject; ArtifactDefinition artifactInfo = buildArtifactPayload(); ArtifactTypeEnum artifactType = ArtifactTypeEnum.AAI_SERVICE_MODEL; @@ -1180,56 +1186,83 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ testSubject.validateDeploymentArtifactTypeIsLegalForParent(artifactInfo, artifactType, resourceDeploymentArtifacts); } - @Test - public void testFillDeploymentArtifactTypeConf() throws Exception { - ArtifactsBusinessLogic testSubject; - NodeTypeEnum parentType = NodeTypeEnum.AdditionalInfoParameters; - Map result; + public void testLoadArtifactTypeConfig() { + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + //null artifactType + Optional artifactConfiguration = artifactsBusinessLogic.loadArtifactTypeConfig(null); + assertThat(artifactConfiguration.isPresent()).isFalse(); + //not configured artifactType + artifactConfiguration = artifactsBusinessLogic.loadArtifactTypeConfig("NotConfiguredArtifactType"); + assertThat(artifactConfiguration.isPresent()).isFalse(); - // default test - testSubject = createTestSubject(); - result = Deencapsulation.invoke(testSubject, "fillDeploymentArtifactTypeConf", - new Object[]{parentType}); + //valid artifactType + final String artifactType = ArtifactTypeEnum.YANG.getType(); + artifactConfiguration = artifactsBusinessLogic.loadArtifactTypeConfig(artifactType); + assertThat(artifactConfiguration.isPresent()).isTrue(); + final ArtifactConfiguration artifactConfiguration1 = artifactConfiguration.get(); + assertThat(artifactConfiguration1.getType()).isEqualTo(artifactType); + assertThat(artifactConfiguration1.getCategories()).hasSize(1); + assertThat(artifactConfiguration1.getCategories()).contains(ArtifactGroupTypeEnum.INFORMATIONAL); + assertThat(artifactConfiguration1.getComponentTypes()).hasSize(1); + assertThat(artifactConfiguration1.getComponentTypes()).contains(ComponentType.RESOURCE); + assertThat(artifactConfiguration1.getResourceTypes()).hasSize(7); + assertThat(artifactConfiguration1.getResourceTypes()) + .contains(ResourceTypeEnum.VFC.getValue(), ResourceTypeEnum.CP.getValue(), ResourceTypeEnum.VL.getValue(), + ResourceTypeEnum.VF.getValue(), ResourceTypeEnum.VFCMT.getValue(), "Abstract", + ResourceTypeEnum.CVFC.getValue()); } - @Test - public void testValidateArtifactTypeExists() throws Exception { - ArtifactsBusinessLogic testSubject; - Wrapper responseWrapper = null; - ArtifactDefinition artifactInfo = buildArtifactPayload(); + public void testValidateArtifactExtension_acceptedExtension() { + final ArtifactDefinition artifactInfo = new ArtifactDefinition(); + artifactInfo.setArtifactName("artifact.yml"); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + //empty accepted types + assertThatCode(() -> artifactsBusinessLogic.validateArtifactExtension(new ArtifactConfiguration(), artifactInfo)) + .doesNotThrowAnyException(); - // default test - testSubject = createTestSubject(); - testSubject.getValidArtifactType(artifactInfo); + final ArtifactConfiguration artifactConfiguration = new ArtifactConfiguration(); + artifactConfiguration.setAcceptedTypes(Arrays.asList("yml", "yaml")); + assertThatCode(() -> artifactsBusinessLogic.validateArtifactExtension(artifactConfiguration, artifactInfo)) + .doesNotThrowAnyException(); } + @Test(expected = ComponentException.class) + public void testValidateArtifactExtension_notAcceptedExtension() { + final ArtifactConfiguration artifactConfiguration = new ArtifactConfiguration(); + artifactConfiguration.setAcceptedTypes(Arrays.asList("yml", "yaml")); + final ArtifactDefinition artifactInfo = new ArtifactDefinition(); + //not accepted extension + artifactInfo.setArtifactName("artifact.xml"); - @Test - public void testGetDeploymentArtifactTypeConfig() throws Exception { - ArtifactsBusinessLogic testSubject; - NodeTypeEnum parentType = NodeTypeEnum.AdditionalInfoParameters; - ArtifactTypeEnum artifactType = ArtifactTypeEnum.AAI_SERVICE_MODEL; - ArtifactTypeConfig result; + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); - // default test - testSubject = createTestSubject(); - result = Deencapsulation.invoke(testSubject, "getDeploymentArtifactTypeConfig", - new Object[]{parentType, artifactType}); + artifactsBusinessLogic.validateArtifactExtension(artifactConfiguration, artifactInfo); } + @Test(expected = ComponentException.class) + public void testValidateArtifactExtension_noExtension() { + final ArtifactConfiguration artifactConfiguration = new ArtifactConfiguration(); + artifactConfiguration.setAcceptedTypes(Arrays.asList("yml", "yaml")); + final ArtifactDefinition artifactInfo = new ArtifactDefinition(); + //no extension in the artifact name + artifactInfo.setArtifactName("artifact"); + + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); - @Test(expected= ComponentException.class) - public void testValidateHeatEnvDeploymentArtifact_shouldThrowException() throws Exception { + artifactsBusinessLogic.validateArtifactExtension(artifactConfiguration, artifactInfo); + } + + @Test(expected = ComponentException.class) + public void testValidateHeatEnvDeploymentArtifact_shouldThrowException() { ArtifactsBusinessLogic testSubject; Component component = createResourceObject(true); String parentId = ""; ArtifactDefinition artifactInfo = buildArtifactPayload(); - NodeTypeEnum parentType = NodeTypeEnum.AdditionalInfoParameters; // default test testSubject = createTestSubject(); - testSubject.validateHeatEnvDeploymentArtifact(component, parentId, artifactInfo, parentType); + testSubject.validateHeatEnvDeploymentArtifact(component, parentId, artifactInfo); } @Test @@ -1257,47 +1290,46 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ result = Deencapsulation.invoke(testSubject, "isValidXml", new Object[]{xmlToParse}); } - @Test - public void testHeatTimeoutValue() throws Exception { - ArtifactsBusinessLogic testSubject; - boolean isCreate = false; - ArtifactDefinition artifactInfo = buildArtifactPayload(); - ArtifactDefinition currentArtifact = null; - Either result; - - // default test - testSubject = createTestSubject(); - testSubject.validateHeatTimeoutValue(isCreate, artifactInfo, artifactInfo); + @Test(expected = ByActionStatusComponentException.class) + public void testHeatTimeoutValue() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + artifactInfo.setTimeout(1); + artifactsBusinessLogic.validateHeatTimeoutValue(artifactInfo); + artifactInfo.setTimeout(0); + artifactsBusinessLogic.validateHeatTimeoutValue(artifactInfo); } @Test - public void testValidateHeatDeploymentArtifact() throws Exception { - ArtifactsBusinessLogic testSubject; - boolean isCreate = false; - ArtifactDefinition artifactInfo = buildArtifactPayload(); - ArtifactDefinition currentArtifact = null; - Either result; - - // default test - testSubject = createTestSubject(); - testSubject.validateHeatTimeoutValue(isCreate, artifactInfo, artifactInfo); + public void testValidateResourceType_resourceTypeIsAccepted() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + final List typeList = Arrays + .asList(ResourceTypeEnum.VF.getValue(), ResourceTypeEnum.PNF.getValue(), ResourceTypeEnum.VFC.getValue()); + assertThatCode(() -> { + artifactsBusinessLogic.validateResourceType(ResourceTypeEnum.VF, artifactInfo, typeList); + }).doesNotThrowAnyException(); } - - @Test(expected= ComponentException.class) - public void testValidateResourceType_shouldThrowException() throws Exception { - ArtifactsBusinessLogic testSubject; - ResourceTypeEnum resourceType = ResourceTypeEnum.VF; - ArtifactDefinition artifactInfo = buildArtifactPayload(); - List typeList = new ArrayList<>(); - Either result; - - // test 1 - testSubject = createTestSubject(); - testSubject.validateResourceType(resourceType, artifactInfo, typeList); - result = Deencapsulation.invoke(testSubject, "validateResourceType", new Object[]{resourceType, artifactInfo, typeList}); + @Test(expected=ComponentException.class) + public void testValidateResourceType_invalidResourceType() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + final List typeList = Collections.singletonList(ResourceTypeEnum.PNF.getValue()); + artifactsBusinessLogic.validateResourceType(ResourceTypeEnum.VF, artifactInfo, typeList); } + @Test + public void testValidateResourceType_emptyResourceTypeConfig_resourceTypeIsAccepted() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + assertThatCode(() -> { + artifactsBusinessLogic.validateResourceType(ResourceTypeEnum.VF, artifactInfo, null); + }).doesNotThrowAnyException(); + assertThatCode(() -> { + artifactsBusinessLogic.validateResourceType(ResourceTypeEnum.VF, artifactInfo, new ArrayList<>()); + }).doesNotThrowAnyException(); + } @Test public void testValidateAndConvertHeatParameters() throws Exception { @@ -1321,7 +1353,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ // default test testSubject = createTestSubject(); - result = testSubject.getDeploymentArtifacts(component, parentType, ciId); + result = testSubject.getDeploymentArtifacts(component, ciId); } @@ -1349,6 +1381,36 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ testSubject.validateAndSetArtifactName(artifactInfo); } + @Test(expected = ComponentException.class) + public void testValidateArtifactType_notConfiguredArtifactType() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + artifactInfo.setArtifactType("notConfiguredType"); + Deencapsulation + .invoke(artifactsBusinessLogic, "validateArtifactType", artifactInfo, ComponentTypeEnum.RESOURCE); + } + + @Test(expected = ComponentException.class) + public void testValidateArtifactType_componentTypeNotSupportedByArtifactType() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + artifactInfo.setArtifactType(ArtifactTypeEnum.WORKFLOW.getType()); + + Deencapsulation + .invoke(artifactsBusinessLogic, "validateArtifactType", artifactInfo, ComponentTypeEnum.RESOURCE); + } + + @Test(expected = ComponentException.class) + public void testValidateArtifactType_groupTypeNotSupportedByArtifactType() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + artifactInfo.setArtifactType(ArtifactTypeEnum.WORKFLOW.getType()); + artifactInfo.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL); + + Deencapsulation + .invoke(artifactsBusinessLogic, "validateArtifactType", artifactInfo, ComponentTypeEnum.SERVICE); + } + @Test public void testValidateArtifactTypeNotChanged() throws Exception { ArtifactsBusinessLogic testSubject; @@ -1883,6 +1945,172 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ assertEquals(Deencapsulation.getField(testSubject, "nodeTemplateOperation"), nodeTemplateOperation); } + + @Test(expected = ComponentException.class) + public void validateDeploymentArtifact_invalidComponentType() { + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + Component component = new Resource(); + component.setComponentType(ComponentTypeEnum.PRODUCT); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + Deencapsulation + .invoke(artifactsBusinessLogic, "validateDeploymentArtifact", artifactDefinition, component); + } + + @Test(expected = ComponentException.class) + public void validateDeploymentArtifact_notConfiguredArtifactType() { + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + Component component = new Resource(); + component.setComponentType(ComponentTypeEnum.RESOURCE); + artifactDefinition.setArtifactType("NotConfiguredType"); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + Deencapsulation + .invoke(artifactsBusinessLogic, "validateDeploymentArtifact", artifactDefinition, component); + } + + @Test(expected = ComponentException.class) + public void validateDeploymentArtifact_unsupportedResourceType() { + final ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setArtifactType(ArtifactTypeEnum.YANG.getType()); + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL); + final Resource resourceComponent = new Resource(); + resourceComponent.setComponentType(ComponentTypeEnum.RESOURCE); + resourceComponent.setResourceType(ResourceTypeEnum.ServiceProxy); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + Deencapsulation + .invoke(artifactsBusinessLogic, "validateDeploymentArtifact", artifactDefinition, resourceComponent); + } + + @Test + public void validateDeploymentArtifact_validArtifact() { + final ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setArtifactType(ArtifactTypeEnum.YANG.getType()); + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL); + final Resource resourceComponent = new Resource(); + resourceComponent.setComponentType(ComponentTypeEnum.RESOURCE); + resourceComponent.setResourceType(ResourceTypeEnum.VF); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + assertThatCode(() -> { + Deencapsulation + .invoke(artifactsBusinessLogic, "validateDeploymentArtifact", artifactDefinition, resourceComponent); + }).doesNotThrowAnyException(); + + } + + @Test + public void validateHeatArtifact_validArtifact() { + final ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setArtifactType(ArtifactTypeEnum.HEAT.getType()); + artifactDefinition.setTimeout(1); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + assertThatCode(() -> { + Deencapsulation + .invoke(artifactsBusinessLogic, "validateHeatArtifact", new Resource(), "componentId", artifactDefinition); + }).doesNotThrowAnyException(); + } + + @Test + public void validateInputForResourceInstance() { + final String artifactId = "artifactId"; + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setUniqueId(artifactId); + artifactDefinition.setArtifactName(ARTIFACT_NAME); + artifactDefinition.setArtifactType(ArtifactTypeEnum.SNMP_POLL.getType()); + artifactDefinition.setArtifactLabel(ARTIFACT_LABEL); + artifactDefinition.setEsId(ES_ARTIFACT_ID); + artifactDefinition.setPayload(PAYLOAD); + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL); + artifactDefinition.setDescription("artifact description"); + artifactDefinition.setServiceApi(true); + artifactDefinition.setApiUrl("dumbUrl"); + + final User user = new User(); + user.setUserId("userId"); + user.setRole(Role.ADMIN.name()); + + final String parentId = "parentId"; + final Service service = new Service(); + service.setComponentType(ComponentTypeEnum.SERVICE); + service.setUniqueId(parentId); + service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + service.setLastUpdaterUserId(user.getUserId()); + + final ArtifactOperationInfo operationInfo = + artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE); + + final String componentId = "componentId"; + final ComponentInstance componentInstance = new ComponentInstance(); + componentInstance.setUniqueId(componentId); + componentInstance.setComponentUid(componentId); + service.setComponentInstances(Collections.singletonList(componentInstance)); + + final Resource resource = new Resource(); + when(toscaOperationFacade.getToscaFullElement(componentId)).thenReturn(Either.left(resource)); + when(artifactToscaOperation.getAllInstanceArtifacts(parentId, componentId)).thenReturn(Either.left(new HashMap<>())); + + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + artifactsBusinessLogic.setToscaOperationFacade(toscaOperationFacade); + Object result = Deencapsulation + .invoke(artifactsBusinessLogic, "validateInput", componentId, artifactDefinition, operationInfo, artifactId, + user, "interfaceName", ARTIFACT_LABEL, ComponentTypeEnum.RESOURCE_INSTANCE, service); + assertTrue(result instanceof Either); + assertTrue(((Either) result).isLeft()); + + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); + + result = Deencapsulation + .invoke(artifactsBusinessLogic, "validateInput", componentId, artifactDefinition, operationInfo, artifactId, + user, "interfaceName", ARTIFACT_LABEL, ComponentTypeEnum.RESOURCE_INSTANCE, service); + assertTrue(result instanceof Either); + assertTrue(((Either) result).isLeft()); + } + + @Test + public void validateInputForResourceInstanceDeploymentArtifact() { + final String artifactId = "artifactId"; + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setUniqueId(artifactId); + artifactDefinition.setArtifactName(ARTIFACT_NAME); + artifactDefinition.setArtifactType(ArtifactTypeEnum.SNMP_POLL.getType()); + artifactDefinition.setArtifactLabel(ARTIFACT_LABEL); + artifactDefinition.setEsId(ES_ARTIFACT_ID); + artifactDefinition.setPayload(PAYLOAD); + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); + artifactDefinition.setDescription("artifact description"); + + final User user = new User(); + user.setUserId("userId"); + user.setRole(Role.ADMIN.name()); + + final String parentId = "parentId"; + final Service service = new Service(); + service.setComponentType(ComponentTypeEnum.SERVICE); + service.setUniqueId(parentId); + service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + service.setLastUpdaterUserId(user.getUserId()); + + final ArtifactOperationInfo operationInfo = + artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE); + + final String componentId = "componentId"; + final ComponentInstance componentInstance = new ComponentInstance(); + componentInstance.setUniqueId(componentId); + componentInstance.setComponentUid(componentId); + service.setComponentInstances(Collections.singletonList(componentInstance)); + + final Resource resource = new Resource(); + when(toscaOperationFacade.getToscaFullElement(componentId)).thenReturn(Either.left(resource)); + when(artifactToscaOperation.getAllInstanceArtifacts(parentId, componentId)).thenReturn(Either.left(new HashMap<>())); + + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + artifactsBusinessLogic.setToscaOperationFacade(toscaOperationFacade); + final Object result = Deencapsulation + .invoke(artifactsBusinessLogic, "validateInput", componentId, artifactDefinition, operationInfo, artifactId, + user, "interfaceName", ARTIFACT_LABEL, ComponentTypeEnum.RESOURCE_INSTANCE, service); + assertTrue(result instanceof Either); + assertTrue(((Either) result).isLeft()); + } + + @Test public void testHandleArtifactRequest() { @@ -1894,7 +2122,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ artifactDefinition.setPayload("Test".getBytes()); artifactDefinition.setArtifactLabel("other"); artifactDefinition.setDescription("Test artifact"); - artifactDefinition.setArtifactType(ArtifactTypeEnum.OTHER.name()); + artifactDefinition.setArtifactType(ArtifactTypeEnum.OTHER.getType()); artifactDefinition.setArtifactUUID("artifactUId"); artifactDefinition.setArtifactLabel("test"); artifactDefinition.setArtifactDisplayName("Test"); @@ -1979,7 +2207,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ ArtifactDefinition artifactDefinition = new ArtifactDefinition(); artifactDefinition.setUniqueId("artifactId"); - artifactDefinition.setArtifactType(ArtifactTypeEnum.TOSCA_CSAR.name()); + artifactDefinition.setArtifactType(ArtifactTypeEnum.TOSCA_CSAR.getType()); User user = new User(); boolean inCertificationRequest = false; boolean fetchTemplatesFromDB = false; @@ -2013,7 +2241,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ ArtifactDefinition csarArtifact = new ArtifactDefinition(); csarArtifact.setArtifactName("csarArtifact"); - csarArtifact.setArtifactType(ArtifactTypeEnum.HEAT_ENV.name()); + csarArtifact.setArtifactType(ArtifactTypeEnum.HEAT_ENV.getType()); csarArtifact.setArtifactGroupType(ArtifactGroupTypeEnum.TOSCA); when(csarUtils.createCsar(any(Component.class), anyBoolean(), anyBoolean())) @@ -2039,7 +2267,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ artifactDefinition.setArtifactName("test.csar"); artifactDefinition.setArtifactType(ComponentTypeEnum.RESOURCE.name()); - artifactDefinition.setArtifactType(ArtifactTypeEnum.HEAT.name()); + artifactDefinition.setArtifactType(ArtifactTypeEnum.HEAT.getType()); artifactDefinition.setUniqueId(artifactId); artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.TOSCA); @@ -2143,7 +2371,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ resource.setComponentInstances(componentInstanceList); componentInstance.setDeploymentArtifacts(deploymentArtifacts); - List result = artifactBL.getDeploymentArtifacts(resource, parentType, ciId); + List result = artifactBL.getDeploymentArtifacts(resource, ciId); assertThat(result.size() == 1).isTrue(); Assert.assertEquals(artifactDefinition.getArtifactName(), result.get(0).getArtifactName()); } @@ -2249,8 +2477,12 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ } private ArtifactsBusinessLogic getTestSubject() { - return new ArtifactsBusinessLogic(artifactCassandraDao, toscaExportHandler, csarUtils, lifecycleBusinessLogic, - userBusinessLogic, artifactsResolver, elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + final ArtifactsBusinessLogic artifactsBusinessLogic = new ArtifactsBusinessLogic(artifactCassandraDao, + toscaExportHandler, csarUtils, lifecycleBusinessLogic, + userBusinessLogic, artifactsResolver, elementDao, groupOperation, groupInstanceOperation, + groupTypeOperation, interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + artifactsBusinessLogic.setComponentsUtils(componentsUtils); + return artifactsBusinessLogic; } } \ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java index 9e563fc34c..c19d997d73 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java @@ -1842,27 +1842,27 @@ public class ResourceBusinessLogicTest { List artifactPathAndNameList = new ArrayList<>(); NonMetaArtifactInfo deploymentArtifactInfoToUpdate = new NonMetaArtifactInfo( deploymentArtifactToUpdate.getArtifactName(), null, - ArtifactTypeEnum.findType(deploymentArtifactToUpdate.getArtifactType()), + deploymentArtifactToUpdate.getArtifactType(), ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, deploymentArtifactToUpdate.getArtifactName(), false); NonMetaArtifactInfo informationalArtifactInfoToUpdate = new NonMetaArtifactInfo( - artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()), + artifactToUpdate.getArtifactName(), null, artifactToUpdate.getArtifactType(), ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, artifactToUpdate.getArtifactName(), false); NonMetaArtifactInfo informationalArtifactInfoToUpdateFromCsar = new NonMetaArtifactInfo( - artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()), + artifactToUpdate.getArtifactName(), null, artifactToUpdate.getArtifactType(), ArtifactGroupTypeEnum.INFORMATIONAL, newPayloadData, artifactToUpdate.getArtifactName(), true); NonMetaArtifactInfo deploymentArtifactInfoToUpdateFromCsar = new NonMetaArtifactInfo( - artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()), + artifactToUpdate.getArtifactName(), null, artifactToUpdate.getArtifactType(), ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, artifactToUpdate.getArtifactName(), true); NonMetaArtifactInfo deploymentArtifactInfoToCreate = new NonMetaArtifactInfo(deploymentArtifactToCreateFileName, - null, ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, + null, ArtifactTypeEnum.OTHER.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, deploymentArtifactToCreateFileName, false); NonMetaArtifactInfo informationalArtifactInfoToCreate = new NonMetaArtifactInfo(artifactInfoToCreateFileName, - null, ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.INFORMATIONAL, newPayloadData, + null, ArtifactTypeEnum.OTHER.getType(), ArtifactGroupTypeEnum.INFORMATIONAL, newPayloadData, artifactInfoToCreateFileName, false); artifactPathAndNameList.add(deploymentArtifactInfoToUpdate); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java index 06b06b08ad..160f595e95 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java @@ -154,7 +154,7 @@ public class ComponentInstanceArtifactsMergeTest { artifactCreatedOnTheInstance.setTimeout(30); ArtifactDefinition artifactGeneratedBySubmitForTesting = new ArtifactDefinition(); artifactGeneratedBySubmitForTesting.setArtifactLabel("artifactThree"); - artifactGeneratedBySubmitForTesting.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.name()); + artifactGeneratedBySubmitForTesting.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.getType()); artifactGeneratedBySubmitForTesting.setTimeout(30); Map componentInstanceArtifacts = new HashMap<>(); componentInstanceArtifacts.put(artifactFromTheOriginalResource.getArtifactLabel(), artifactFromTheOriginalResource); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java index 71513c36bd..c488a9a6ca 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java @@ -53,7 +53,7 @@ import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.Silent.class) public class RoleAuthorizationHandlerTest { - private RoleAuthorizationHandler roleAuthorizationHandler = new RoleAuthorizationHandler(); + private RoleAuthorizationHandler roleAuthorizationHandler; @Mock JoinPoint joinPoint; @Mock @@ -72,6 +72,7 @@ public class RoleAuthorizationHandlerTest { when(beGenericServlet.getServletRequest()).thenReturn(httpServletRequest); ThreadLocalsHolder.setApiType(FilterDecisionEnum.EXTERNAL); new ConfigurationManager(new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be/auth")); + roleAuthorizationHandler = new RoleAuthorizationHandler(); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java index f90ef19293..974f286098 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java @@ -305,7 +305,6 @@ public class ElementServletTest extends JerseyTest { Either getAllCategoriesEither = Either.left(new UiCategories()); Either, ActionStatus> otherEither = Either.left(new ArrayList<>()); when(elementBusinessLogic.getDefaultHeatTimeout()).thenReturn(Either.left(configurationManager.getConfiguration().getHeatArtifactDeploymentTimeout())); - when(elementBusinessLogic.getAllDeploymentArtifactTypes()).thenReturn(Either.left(new HashMap())); when(elementBusinessLogic.getResourceTypesMap()).thenReturn(Either.left(new HashMap())); when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId())) .thenReturn(otherEither); @@ -961,15 +960,12 @@ public class ElementServletTest extends JerseyTest { Configuration.HeatDeploymentArtifactTimeout heatDeploymentArtifactTimeout = new Configuration.HeatDeploymentArtifactTimeout(); heatDeploymentArtifactTimeout.setDefaultMinutes(1); Either defaultHeatTimeoutEither = Either.left(heatDeploymentArtifactTimeout); - Either, ActionStatus> deploymentEither = Either.left(new HashMap<>()); Either, ActionStatus> resourceTypesMapEither = Either.left(new HashMap<>()); when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId())) .thenReturn(otherEither); when(elementBusinessLogic.getDefaultHeatTimeout()) .thenReturn(defaultHeatTimeoutEither); - when(elementBusinessLogic.getAllDeploymentArtifactTypes()) - .thenReturn(deploymentEither); when(elementBusinessLogic.getResourceTypesMap()) .thenReturn(resourceTypesMapEither); @@ -1065,6 +1061,7 @@ public class ElementServletTest extends JerseyTest { bind(componentUtils).to(ComponentsUtils.class); bind(componentsCleanBusinessLogic).to(ComponentsCleanBusinessLogic.class); bind(elementBusinessLogic).to(ElementBusinessLogic.class); + bind(artifactsBusinessLogic).to(ArtifactsBusinessLogic.class); } }) .property("contextConfig", context); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java index cdea369fe8..c7dced79c5 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java @@ -20,6 +20,8 @@ package org.openecomp.sdc.be.tosca; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -115,7 +117,7 @@ public class CsarUtilsTest extends BeConfDependentTest { private final List nodesFromPackage = Arrays.asList("tosca.nodes.Root", "tosca.nodes.Container.Application"); private NonMetaArtifactInfo createNonMetaArtifactInfoTestSubject() { - return new CsarUtils.NonMetaArtifactInfo("mock", "mock", ArtifactTypeEnum.AAI_SERVICE_MODEL, + return new CsarUtils.NonMetaArtifactInfo("mock", "mock", ArtifactTypeEnum.AAI_SERVICE_MODEL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, new byte[0], "mock", true); } @@ -706,9 +708,9 @@ public class CsarUtilsTest extends BeConfDependentTest { @Test public void testNonMetaArtifactInfoGetArtifactType() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.getArtifactType(); + final NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); + assertThat("The artifact type should be as expected", + testSubject.getArtifactType(), is(ArtifactTypeEnum.AAI_SERVICE_MODEL.getType())); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java index 23288582ca..c9f21e41b7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java @@ -62,7 +62,7 @@ public class OperationArtifactUtilTest { final String actualArtifactPath = OperationArtifactUtil.createOperationArtifactPath(component, null, op, false); String expectedArtifactPath = CsarUtils.ARTIFACTS + File.separator + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) + File.separator + - ArtifactTypeEnum.WORKFLOW.name() + File.separator + BPMN_ARTIFACT_PATH + File.separator + + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + File.separator + "createBPMN.bpmn"; @@ -84,7 +84,7 @@ public class OperationArtifactUtilTest { String expectedArtifactPath = CsarUtils.ARTIFACTS + File.separator + "org.openecomp.resource.vf.TestResource_v1.0" + File.separator + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) + File.separator + - ArtifactTypeEnum.WORKFLOW.name() + + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + File.separator + "createBPMN.bpmn"; diff --git a/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml index 0e68b3294b..f13e74bdcc 100644 --- a/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml +++ b/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml @@ -1,739 +1 @@ -identificationHeaderFields: - - HTTP_IV_USER - - HTTP_CSP_FIRSTNAME - - HTTP_CSP_LASTNAME - - HTTP_IV_REMOTE_ADDRESS - - HTTP_CSP_WSTYPE - -# catalog backend hostname -beFqdn: localhost -# sdccatalog.com - -# catalog backend http port -beHttpPort: 8080 - -# catalog backend http context -beContext: /sdc/rest/config/get - -# catalog backend protocol -beProtocol: http - -# catalog backend ssl port -beSslPort: 8443 - -version: 1.1.0 -released: 2012-11-30 -toscaConformanceLevel: 8.0 -minToscaConformanceLevel: 3.0 - -janusGraphCfgFile: /home/vagrant/catalog-be/config/catalog-be/janusGraph.properties -janusGraphInMemoryGraph: false -janusGraphLockTimeout: 1800 - -# The interval to try and reconnect to janusGraph DB when it is down during ASDC startup: -janusGraphReconnectIntervalInSeconds: 3 - -# The read timeout towards Titan DB when health check is invoked: -janusGraphHealthCheckReadTimeout: 1 - -uebHealthCheckReconnectIntervalInSeconds: 15 -uebHealthCheckReadTimeout: 4 - -# Protocols -protocols: - - http - - https - -# Default imports -defaultImports: - - nodes: - file: nodes.yml - - datatypes: - file: data.yml - - capabilities: - file: capabilities.yml - - relationships: - file: relationships.yml - - groups: - file: groups.yml - - policies: - file: policies.yml - -# Users -users: - tom: passwd - bob: passwd - -neo4j: - host: neo4jhost - port: 7474 - user: neo4j - password: "12345" - -cassandraConfig: - cassandraHosts: ['localhost'] - localDataCenter: datacenter1 - reconnectTimeout : 30000 - authenticate: false - username: koko - password: bobo - ssl: false - truststorePath : /path/path - truststorePassword : 123123 - keySpaces: - - { name: sdcaudit, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - - { name: sdcartifact, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - - { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - - -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - -licenseTypes: - - User - - Installation - - CPU - -#Deployment artifacts placeHolder -resourceTypes: &allResourceTypes - - VFC - - CP - - VL - - VF - - VFCMT - - Abstract - - CVFC - -# validForResourceTypes usage -# validForResourceTypes: -# - VF -# - VL -deploymentResourceArtifacts: -# heat: -# displayName: "Base HEAT Template" -# type: HEAT -# validForResourceTypes: *allResourceTypes -# heatVol: -# displayName: "Volume HEAT Template" -# type: HEAT_VOL -# validForResourceTypes: *allResourceTypes -# heatNet: -# displayName: "Network HEAT Template" -# type: HEAT_NET -# validForResourceTypes: *allResourceTypes - -deploymentResourceInstanceArtifacts: - heatEnv: - displayName: "HEAT ENV" - type: HEAT_ENV - description: "Auto-generated HEAT Environment deployment artifact" - fileExtension: "env" - VfHeatEnv: - displayName: "VF HEAT ENV" - type: HEAT_ENV - description: "VF Auto-generated HEAT Environment deployment artifact" - fileExtension: "env" - -#tosca artifacts placeholders -toscaArtifacts: - assetToscaTemplate: - artifactName: -template.yml - displayName: Tosca Template - type: TOSCA_TEMPLATE - description: TOSCA representation of the asset - assetToscaCsar: - artifactName: -csar.csar - displayName: Tosca Model - type: TOSCA_CSAR - description: TOSCA definition package of the asset - - -#Informational artifacts placeHolder -excludeResourceCategory: - - Generic -excludeResourceType: - - PNF -informationalResourceArtifacts: - features: - displayName: Features - type: OTHER - capacity: - displayName: Capacity - type: OTHER - vendorTestResult: - displayName: Vendor Test Result - type: OTHER - testScripts: - displayName: Test Scripts - type: OTHER - CloudQuestionnaire: - displayName: Cloud Questionnaire (completed) - type: OTHER - HEATTemplateFromVendor: - displayName: HEAT Template from Vendor - type: HEAT - resourceSecurityTemplate: - displayName: Resource Security Template - type: OTHER - -excludeServiceCategory: - -informationalServiceArtifacts: - serviceArtifactPlan: - displayName: Service Artifact Plan - type: OTHER - summaryOfImpactsToECOMPElements: - displayName: Summary of impacts to ECOMP elements,OSSs, BSSs - type: OTHER - controlLoopFunctions: - displayName: Control Loop Functions - type: OTHER - dimensioningInfo: - displayName: Dimensioning Info - type: OTHER - affinityRules: - displayName: Affinity Rules - type: OTHER - operationalPolicies: - displayName: Operational Policies - type: OTHER - serviceSpecificPolicies: - displayName: Service-specific Policies - type: OTHER - engineeringRules: - displayName: Engineering Rules (ERD) - type: OTHER - distributionInstructions: - displayName: Distribution Instructions - type: OTHER - certificationTestResults: - displayName: TD Certification Test Results - type: OTHER - deploymentVotingRecord: - displayName: Deployment Voting Record - type: OTHER - serviceQuestionnaire: - displayName: Service Questionnaire - type: OTHER - serviceSecurityTemplate: - displayName: Service Security Template - type: OTHER - -serviceApiArtifacts: - configuration: - displayName: Configuration - type: OTHER - instantiation: - displayName: Instantiation - type: OTHER - monitoring: - displayName: Monitoring - type: OTHER - reporting: - displayName: Reporting - type: OTHER - logging: - displayName: Logging - type: OTHER - testing: - displayName: Testing - type: OTHER - -additionalInformationMaxNumberOfKeys: 50 - -systemMonitoring: - enabled: false - isProxy: false - probeIntervalInSeconds: 15 - -heatArtifactDeploymentTimeout: - defaultMinutes: 30 - minMinutes: 1 - maxMinutes: 120 - -serviceDeploymentArtifacts: - YANG_XML: - acceptedTypes: - - xml - VNF_CATALOG: - acceptedTypes: - - xml - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - -#AAI Artifacts - AAI_SERVICE_MODEL: - acceptedTypes: - - xml - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - AAI_VF_INSTANCE_MODEL: - acceptedTypes: - - xml - OTHER: - acceptedTypes: - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_VOL: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NET: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NESTED: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_ARTIFACT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VNF_CATALOG: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VF_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VENDOR_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - LIFECYCLE_OPERATIONS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - VFC - VES_EVENTS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - validForResourceTypes: *allResourceTypes - APPC_CONFIG: - acceptedTypes: - validForResourceTypes: - - VF - DCAE_TOSCA: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - VF - - VFCMT - DCAE_JSON: - acceptedTypes: - - json - validForResourceTypes: - - VF - - VFCMT - DCAE_POLICY: - acceptedTypes: - - emf - validForResourceTypes: - - VF - - VFCMT - DCAE_DOC: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - DCAE_EVENT: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - AAI_VF_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - OTHER: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInstanceDeploymentArtifacts: - HEAT_ENV: - acceptedTypes: - - env - VF_MODULES_METADATA: - acceptedTypes: - - json - VES_EVENTS: - acceptedTypes: - - yaml - - yml - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - DCAE_INVENTORY_TOSCA: - acceptedTypes: - - yml - - yaml - DCAE_INVENTORY_JSON: - acceptedTypes: - - json - DCAE_INVENTORY_POLICY: - acceptedTypes: - - emf - DCAE_INVENTORY_DOC: - acceptedTypes: - DCAE_INVENTORY_BLUEPRINT: - acceptedTypes: - DCAE_INVENTORY_EVENT: - acceptedTypes: - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInformationalArtifacts: - CHEF: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PUPPET: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SHELL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - HEAT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - BPEL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - DG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - MURANO_PKG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - GUIDE: - acceptedTypes: - validForResourceTypes: - - VF - - VFC - - CVFC - -unLoggedUrls: - - /sdc2/rest/healthCheck - -cleanComponentsConfiguration: - cleanIntervalInMinutes: 1440 - componentsToClean: - - Resource - - Service - -artifactsIndex: resources - -heatEnvArtifactHeader: "" -heatEnvArtifactFooter: "" - -onboarding: - protocol: http - host: localhost - port: 8080 - downloadCsarUri: "/onboarding-api/v1.0/vendor-software-products/packages" - healthCheckUri: "/onboarding-api/v1.0/healthcheck" - -dcae: - protocol: http - host: 127.0.0.1 - port: 8080 - healthCheckUri: "/dcae/healthCheck" - -switchoverDetector: - gBeFqdn: AIO-BE.ecomp.idns.cip.com - gFeFqdn: AIO-FE.ecomp.idns.cip.com - beVip: 0.0.0.0 - feVip: 0.0.0.0 - beResolveAttempts: 3 - feResolveAttempts: 3 - enabled: false - interval: 60 - changePriorityUser: ecompasdc - changePriorityPassword: ecompasdc123 - publishNetworkUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/update_network?user=root" - publishNetworkBody: '{"note":"publish network"}' - groups: - beSet: { changePriorityUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.com?user=root", - changePriorityBody: '{"name":"AIO-BE.ecomp.idns.com","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.com","no_ad_redirection":false,"v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_be","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_be"],"failover_policy":["FAILALL"]},"comment":"AIO BE G-fqdn","intended_app_proto":"DNS"}'} - feSet: { changePriorityUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.com?user=root", - changePriorityBody: '{"comment":"AIO G-fqdn","name":"AIO-FE.ecomp.idns.com","v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_fe","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_fe"],"failover_policy":["FAILALL"]},"no_ad_redirection":false,"intended_app_proto":"DNS","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.com"}'} - -applicationL1Cache: - datatypes: - enabled: true - firstRunDelay: 10 - pollIntervalInSec: 60 - -applicationL2Cache: - enabled: true - catalogL1Cache: - enabled: true - resourcesSizeInCache: 300 - servicesSizeInCache: 200 - productsSizeInCache: 100 - queue: - syncIntervalInSecondes: 43200 - waitOnShutDownInMinutes: 10 - numberOfCacheWorkers: 4 - -toscaValidators: - stringMaxLength: 2500 - -disableAudit: false - -vfModuleProperties: - min_vf_module_instances: - forBaseModule: 1 - forNonBaseModule: 0 - max_vf_module_instances: - forBaseModule: 1 - forNonBaseModule: - initial_count: - forBaseModule: 1 - forNonBaseModule: 0 - vf_module_type: - forBaseModule: Base - forNonBaseModule: Expansion - -genericAssetNodeTypes: - VFC: org.openecomp.resource.abstract.nodes.VFC - CVFC: org.openecomp.resource.abstract.nodes.VFC - VF : org.openecomp.resource.abstract.nodes.VF - PNF: org.openecomp.resource.abstract.nodes.PNF - Service: org.openecomp.resource.abstract.nodes.service - -workloadContext: Production -environmentContext: - defaultValue: General_Revenue-Bearing - validValues: - - Critical_Revenue-Bearing - - Vital_Revenue-Bearing - - Essential_Revenue-Bearing - - Important_Revenue-Bearing - - Needed_Revenue-Bearing - - Useful_Revenue-Bearing - - General_Revenue-Bearing - - Critical_Non-Revenue - - Vital_Non-Revenue - - Essential_Non-Revenue - - Important_Non-Revenue - - Needed_Non-Revenue - - Useful_Non-Revenue - - General_Non-Revenue - -dmaapConsumerConfiguration: - active: true - hosts: olsd004.wnsnet.com:3905 - consumerGroup: asdc - consumerId: invalidMamaUser #mama - in Order To Consume Remove This String And Replace It With -> mama - timeoutMs: 15000 - limit: 1 - pollingInterval: 2 - topic: com.sdc.23911-SDCforTestDev-v001 - latitude: 32.109333 - longitude: 34.855499 - version: 1.0 - serviceName: dmaap-v1.dev.dmaap.dt.saat.acsi.com/events - environment: TEST - partner: BOT_R - routeOffer: MR1 - protocol: https - contenttype: application/json - dme2TraceOn: true - aftEnvironment: AFTUAT - aftDme2ConnectionTimeoutMs: 15000 - aftDme2RoundtripTimeoutMs: 240000 - aftDme2ReadTimeoutMs: 50000 - dme2preferredRouterFilePath: DME2preferredRouter.txt - timeLimitForNotificationHandleMs: 0 - credential: - username: m09875@sdc.com - password: hmXYcznAljMSisdy8zgcag== - aftDme2SslEnable: true - aftDme2ClientIgnoreSslConfig: false - aftDme2ClientKeystore: /opt/app/jetty/base/be/config/.truststore - aftDme2ClientKeystorePassword: hmXYcznAljMSisdy8zgcag== - aftDme2ClientSslCertAlias: certman - -dmaapProducerConfiguration: - active: true - hosts: olsd004.wnsnet.attws.com:3904 - consumerGroup: asdc - consumerId: mama #mama - in Order To Consume Remove This String And Replace It With -> mama - timeoutMs: 15000 - limit: 1 - pollingInterval: 2 - topic: com.att.sdc.23911-msfacadesdc-v1 - latitude: 32.109333 - longitude: 34.855499 - version: 1.0 - serviceName: dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events - environment: TEST - partner: BOT_R - routeOffer: MR1 - protocol: http - contenttype: application/json - dme2TraceOn: true - aftEnvironment: AFTUAT - aftDme2ConnectionTimeoutMs: 15000 - aftDme2RoundtripTimeoutMs: 240000 - aftDme2ReadTimeoutMs: 50000 - dme2preferredRouterFilePath: DME2preferredRouter.txt - timeLimitForNotificationHandleMs: 120000 - credential: - username: m09875@sdc.att.com - password: hmXYcznAljMSisdy8zgcag== -# isActive: false -# transportType: HTTPAAF -# hosts: olsd004.wnsnet.attws.com:3904 -# consumerGroup: asdc -# consumerId: mama #mama - in Order To Consume Remove This String And Replace It With -> mama -# limit: 1000 -# timeout: 15000 -# topic: com.att.sdc.23911-msfacadesdc-v1 -# protocol: http -# contenttype: application/json -# authKey: d8fWpPuZ3JJEs8Gf:XyQeXFoxIJZGAUaJUfx+oV6JO -# authDate: 2018-05-18T13:57:37-0800 -# dme2preferredRouterFilePath: DME2preferredRouter.txt #stub , used only cause exception is thrown without it -# credential: -# username: m09875@sdc.att.com -# password: hmXYcznAljMSisdy8zgcag== -dmeConfiguration: - lookupUriFormat: "http://DME2RESOLVE/service=%s/version=1.0.0/envContext=%s/routeOffer=DEFAULT" - -excludedGroupTypesMapping: - CR: - - org.openecomp.groups.VfModule - - org.openecomp.groups.heat.HeatStack - - tosca.groups.Root - VF: - - org.openecomp.groups.VfModule - - org.openecomp.groups.heat.HeatStack - - tosca.groups.Root - Service: - - org.openecomp.groups.VfModule - - org.openecomp.groups.heat.HeatStack - - tosca.groups.Root -healthStatusExclude: - - DE - - ES - - DMAAP - -aafNamespace: com.att.sdc - -aafAuthNeeded: true - -cadiFilterParams: - AFT_LATITUDE: "32.780140" - AFT_LONGITUDE: "-96.800451" - hostname: 192.168.33.10 - aaf_id: m09875@sdc.att.com - aaf_env: TEST - aaf_url: https://aaftest.test.att.com/locate/com.att.aaf.service:2.0 - csp_domain: PROD - cadi_keyfile: /opt/app/jetty/base/be/etc/keyfile - aaf_password: enc:uI_J4jBL4YUcIZZa5uZKj3QMUC63hbS8TmDn5PSp5nO - cadi_loglevel: DEBUG - AFT_ENVIRONMENT: AFTUAT - cadiX509Issuers: CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US - cadi_truststore: /opt/app/jetty/base/be/etc/cadi_truststore.jks - cadi_truststore_password: changeit - - +aafAuthNeeded: true \ No newline at end of file diff --git a/catalog-be/src/test/resources/config/catalog-be/auth/error-configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/auth/error-configuration.yaml new file mode 100644 index 0000000000..d1b2df7b42 --- /dev/null +++ b/catalog-be/src/test/resources/config/catalog-be/auth/error-configuration.yaml @@ -0,0 +1,8 @@ +# Errors +errors: + #---------POL5003------------------------------ + AUTH_FAILED: { + code: 403 , + message: "Error: Not authorized to use the API.", + messageId: "POL5003" + } \ No newline at end of file diff --git a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml index 64b730b046..ca7c636ff6 100644 --- a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml +++ b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml @@ -87,31 +87,6 @@ cassandraConfig: - { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - - PNF_SW_INFORMATION - licenseTypes: - User - Installation @@ -274,248 +249,6 @@ heatArtifactDeploymentTimeout: minMinutes: 1 maxMinutes: 120 -serviceDeploymentArtifacts: - YANG_XML: - acceptedTypes: - - xml - VNF_CATALOG: - acceptedTypes: - - xml - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - -#AAI Artifacts - AAI_SERVICE_MODEL: - acceptedTypes: - - xml - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - AAI_VF_INSTANCE_MODEL: - acceptedTypes: - - xml - OTHER: - acceptedTypes: - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_VOL: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NET: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NESTED: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_ARTIFACT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VNF_CATALOG: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VF_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VENDOR_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - LIFECYCLE_OPERATIONS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - VFC - VES_EVENTS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - validForResourceTypes: *allResourceTypes - APPC_CONFIG: - acceptedTypes: - validForResourceTypes: - - VF - DCAE_TOSCA: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - VF - - VFCMT - DCAE_JSON: - acceptedTypes: - - json - validForResourceTypes: - - VF - - VFCMT - DCAE_POLICY: - acceptedTypes: - - emf - validForResourceTypes: - - VF - - VFCMT - DCAE_DOC: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - DCAE_EVENT: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - AAI_VF_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - OTHER: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInstanceDeploymentArtifacts: - HEAT_ENV: - acceptedTypes: - - env - VF_MODULES_METADATA: - acceptedTypes: - - json - VES_EVENTS: - acceptedTypes: - - yaml - - yml - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - DCAE_INVENTORY_TOSCA: - acceptedTypes: - - yml - - yaml - DCAE_INVENTORY_JSON: - acceptedTypes: - - json - DCAE_INVENTORY_POLICY: - acceptedTypes: - - emf - DCAE_INVENTORY_DOC: - acceptedTypes: - DCAE_INVENTORY_BLUEPRINT: - acceptedTypes: - DCAE_INVENTORY_EVENT: - acceptedTypes: - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInformationalArtifacts: - CHEF: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PUPPET: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SHELL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - HEAT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - BPEL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - DG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - MURANO_PKG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - GUIDE: - acceptedTypes: - validForResourceTypes: - - VF - - VFC - - CVFC - PNF_SW_INFORMATION: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - PNF - unLoggedUrls: - /sdc2/rest/healthCheck @@ -746,4 +479,533 @@ cadiFilterParams: # This configuration entry lists all node type names prefix that shall be allowed on SDC. definedResourceNamespace: - - org.openecomp.resource. \ No newline at end of file + - org.openecomp.resource. + +artifacts: + - type: CONTROLLER_BLUEPRINT_ARCHIVE + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - zip + - type: YANG_XML + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - SERVICE + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: VNF_CATALOG + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: MODEL_INVENTORY_PROFILE + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: MODEL_QUERY_SPEC + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: UCPE_LAYER_2_CONFIGURATION + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + #AAI Artifacts + - type: AAI_SERVICE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: AAI_VF_MODULE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: AAI_VF_INSTANCE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + #Plan + - type: PLAN + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: + - VF + - VFC + acceptedTypes: + - xml + - type: WORKFLOW + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + - VFC + - CP + - VL + - VF + - CR + - VFCMT + - Abstract + - CVFC + - PNF + acceptedTypes: + - xml + - type: HEAT + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_VOL + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_NET + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_NESTED + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_ARTIFACT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - zip + - tgz + - csar + - type: VNF_CATALOG + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: VF_LICENSE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: VENDOR_LICENSE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: MODEL_INVENTORY_PROFILE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: MODEL_QUERY_SPEC + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: LIFECYCLE_OPERATIONS + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFC + acceptedTypes: + - yaml + - yml + - type: VES_EVENTS + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: + - VFC + - CP + - VL + - VF + - CR + - VFCMT + - Abstract + - CVFC + - PNF + acceptedTypes: + - yaml + - yml + - type: PERFORMANCE_COUNTER + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: *allResourceTypes + acceptedTypes: + - csv + - type: APPC_CONFIG + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + acceptedTypes: + - type: DCAE_TOSCA + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - yml + - yaml + - type: DCAE_JSON + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - json + - type: DCAE_POLICY + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - emf + - type: DCAE_DOC + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - type: DCAE_EVENT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - type: AAI_VF_MODEL + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + acceptedTypes: + - xml + - type: AAI_VF_MODULE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + acceptedTypes: + - xml + - type: OTHER + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: + - VFC + - CVFC + - CP + - VL + - VF + - VFCMT + - Abstract + - PNF + acceptedTypes: + - type: SNMP_POLL + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: SNMP_TRAP + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: PM_DICTIONARY + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - yaml + - yml + - type: YANG_MODULE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - yang + - type: ANSIBLE_PLAYBOOK + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - yaml + - yml + - type: ONBOARDED_PACKAGE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - csar + - zip + - type: HEAT_ENV + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - env + - type: VF_MODULES_METADATA + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - json + - type: DCAE_INVENTORY_TOSCA + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - yml + - yaml + - type: DCAE_INVENTORY_JSON + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - json + - type: DCAE_INVENTORY_POLICY + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - emf + - type: DCAE_INVENTORY_DOC + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - type: DCAE_INVENTORY_BLUEPRINT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - type: DCAE_INVENTORY_EVENT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - type: CHEF + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: PUPPET + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: SHELL + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: YANG + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: BPEL + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: DG_XML + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: MURANO_PKG + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: PNF_SW_INFORMATION + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: + - PNF + acceptedTypes: + - yaml + - yml + - type: GUIDE + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFC + - CVFC + - PNF + acceptedTypes: + - yaml + - yml -- cgit 1.2.3-korg