diff options
author | Michael Lando <ml636r@att.com> | 2017-07-20 01:29:49 +0300 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2017-07-20 01:30:06 +0300 |
commit | 3c3c833897dbfc0e85feaf36086a505f990ecb76 (patch) | |
tree | 8c308fbe7298aa65066ba0fc8a71e51d20d8e0de /catalog-be/src/main | |
parent | 30db4407bab8cfea48e278d29e55b11c6c0a528c (diff) |
[SDC] 1710 rebase + pom modifications
Change-Id: I1f9c0a5201576c7a6b124f6a786db12c1a8cd7c0
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-be/src/main')
7 files changed, 72 insertions, 10 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java index 77900efd82..e4c75eab05 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 @@ -111,9 +111,7 @@ import org.openecomp.sdc.exception.ResponseFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; +import org.xml.sax.*; import org.yaml.snakeyaml.Yaml; import com.google.gson.Gson; @@ -2038,6 +2036,17 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { @SuppressWarnings("restriction") public boolean isValidXml(byte[] xmlToParse) { XMLReader parser = new SAXParser(); + try { + parser.setFeature("http://apache.org/xml/features/validation/schema", false); + } catch (SAXNotRecognizedException e) { + e.printStackTrace(); + log.debug("Xml parser couldn't set feature: \"http://apache.org/xml/features/validation/schema\", false", e.getMessage(), e); + + } catch (SAXNotSupportedException e) { + e.printStackTrace(); + log.debug("Xml parser couldn't set feature: \"http://apache.org/xml/features/validation/schema\", false", e.getMessage(), e); + + } boolean isXmlValid = true; try { parser.parse(new InputSource(new ByteArrayInputStream(xmlToParse))); @@ -4007,7 +4016,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } private Either<Either<ArtifactDefinition,Operation>,ResponseFormat> getResponseAndAuditInvalidEmptyHeatEnvFile(AuditingActionEnum auditingAction, Component parent, String uniqueId, User user, ArtifactDefinition currHeatArtifact, String artifactId, ComponentTypeEnum componentType) { - ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_YAML); + ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_YAML, currHeatArtifact.getArtifactName()); handleAuditing(auditingAction, parent, parent.getUniqueId(), user, currHeatArtifact, null, artifactId, responseFormat, componentType, ""); return Either.right(responseFormat); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java index 56cd91d754..5b6488d788 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java @@ -42,12 +42,15 @@ import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.info.CreateAndAssotiateInfo; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.be.model.Component; @@ -65,11 +68,13 @@ import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache; import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.IComponentInstanceOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; +import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; import org.openecomp.sdc.be.resources.data.ComponentInstanceData; @@ -487,7 +492,7 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } Component origComponent = eitherResourceName.left().value(); - resultOp = updateComponentInstanceMetadata(containerComponent, containerComponentType, origComponent, componentInstanceId, componentInstance, inTransaction); + resultOp = updateComponentInstanceMetadata(containerComponent, containerComponentType, origComponent, componentInstanceId, componentInstance); return resultOp; } finally { @@ -562,7 +567,8 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic { Optional<ComponentInstance> op = componentInstanceList.stream().filter(ci -> ci.getUniqueId().equals(origInst.getUniqueId())).findAny(); if(op.isPresent()){ ComponentInstance updatedCi = op.get(); - updatedCi.setCustomizationUUID(origInst.getCustomizationUUID()); + updatedCi = buildComponentInstance(updatedCi, origInst); + Boolean isUniqueName = validateInstanceNameUniquenessUponUpdate(containerComponent, origInst, updatedCi.getName()); if(!isUniqueName){ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to update the name of the component instance {} to {}. A component instance with the same name already exists. ", @@ -617,7 +623,7 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } private Either<ComponentInstance, ResponseFormat> updateComponentInstanceMetadata(Component containerComponent, ComponentTypeEnum containerComponentType, org.openecomp.sdc.be.model.Component origComponent, String componentInstanceId, - ComponentInstance componentInstance, boolean inTransaction) { + ComponentInstance componentInstance) { Either<ComponentInstance, ResponseFormat> resultOp = null; Optional<ComponentInstance> componentInstanceOptional = null; @@ -1872,4 +1878,40 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } return result; } + + private ComponentInstance buildComponentInstance(ComponentInstance resourceInstanceForUpdate, ComponentInstance origInstanceForUpdate) { + + Long creationDate = origInstanceForUpdate.getCreationTime(); + + Long modificationTime = System.currentTimeMillis(); + resourceInstanceForUpdate.setCreationTime(creationDate); + resourceInstanceForUpdate.setModificationTime(modificationTime); + + resourceInstanceForUpdate.setCustomizationUUID(origInstanceForUpdate.getCustomizationUUID()); + + if (StringUtils.isEmpty(resourceInstanceForUpdate.getName())) { + resourceInstanceForUpdate.setName(origInstanceForUpdate.getName()); + + } + if (StringUtils.isEmpty(resourceInstanceForUpdate.getNormalizedName())) + resourceInstanceForUpdate.setNormalizedName(origInstanceForUpdate.getNormalizedName()); + + if (StringUtils.isEmpty(resourceInstanceForUpdate.getIcon())) + resourceInstanceForUpdate.setIcon(origInstanceForUpdate.getIcon()); + + + if (StringUtils.isEmpty(resourceInstanceForUpdate.getComponentVersion())) + resourceInstanceForUpdate.setComponentVersion(origInstanceForUpdate.getComponentVersion()); + + if (StringUtils.isEmpty(resourceInstanceForUpdate.getComponentName())) + resourceInstanceForUpdate.setComponentName(origInstanceForUpdate.getComponentName()); + + if (StringUtils.isEmpty(resourceInstanceForUpdate.getToscaComponentName())) + resourceInstanceForUpdate.setToscaComponentName(origInstanceForUpdate.getToscaComponentName()); + + if (resourceInstanceForUpdate.getOriginType() == null) { + resourceInstanceForUpdate.setOriginType(origInstanceForUpdate.getOriginType()); + } + return resourceInstanceForUpdate; + } } diff --git a/catalog-be/src/main/resources/config/SDC.zip b/catalog-be/src/main/resources/config/SDC.zip Binary files differindex 6df1b13f2b..a4ff817216 100644 --- a/catalog-be/src/main/resources/config/SDC.zip +++ b/catalog-be/src/main/resources/config/SDC.zip diff --git a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml index da15414d9d..621274796f 100644 --- a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml +++ b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml @@ -67,7 +67,7 @@ tosca.datatypes.TimeInterval: tosca.datatypes.network.NetworkInfo: derived_from: tosca.datatypes.Root - properties: + properties: network_name: type: string network_id: @@ -1045,7 +1045,13 @@ org.openecomp.datatypes.network.IpRequirements: required: false floating_ip_count_required: type: org.openecomp.datatypes.AssignmentRequirements - required: false + required: false + ip_address_plan_name: + type: string + required: false + vrf_name: + type: string + required: false org.openecomp.datatypes.network.MacAssignments: derived_from: org.openecomp.datatypes.Root diff --git a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zip b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zip Binary files differindex 08d4bfc3a5..ffbe146f9b 100644 --- a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zip +++ b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zip diff --git a/catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json b/catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json index 1ef72856a4..5c8e84abe2 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json +++ b/catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json @@ -1,5 +1,9 @@ { "heat": [ + "contrailPort", + "extCp", + "contrailV2VirtualMachineInterface", + "neutronPort", "Generic_PNF" ], "normative": [ diff --git a/catalog-be/src/main/resources/scripts/import/tosca/upgradeHeatAndNormativeTypes.py b/catalog-be/src/main/resources/scripts/import/tosca/upgradeHeatAndNormativeTypes.py index 75afe33eba..e35e2d28eb 100644 --- a/catalog-be/src/main/resources/scripts/import/tosca/upgradeHeatAndNormativeTypes.py +++ b/catalog-be/src/main/resources/scripts/import/tosca/upgradeHeatAndNormativeTypes.py @@ -107,4 +107,5 @@ def main(argv): if __name__ == "__main__": - main(sys.argv[1:])
\ No newline at end of file + main(sys.argv[1:]) + |