summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-08-02 19:57:39 +0000
committerGerrit Code Review <gerrit@onap.org>2017-08-02 19:57:39 +0000
commitd1d771bed17c6a5beea19af8da0bf9113972f25a (patch)
tree6e7420dd3d82200849e51c2af3f2696f11815d12
parentf15292dd1b262f0a4300c3e7a5bdc5430a6f2a63 (diff)
parentf5854fd32c19c44d32a3e6739b30271d4dccd393 (diff)
Merge "[SDC] code rebase for sdc resync to LF"
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/Migration1707Task.java41
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/MigrationMsg.java56
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/MigrationOperationUtils.java139
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AddGroupUuid.java131
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AllowMultipleHeats.java144
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AppConfig.java602
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/DerivedFromAlignment.java232
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/GroupsAlignment.java201
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/MigrationCategory.java48
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/MigrationSubCategory.java36
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/ServiceMigration.java1515
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/VfcNamingAlignment.java184
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1607/CsarMigration.java93
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1610/TitanFixUtils.java384
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1610/ToscaArtifactsAlignment.java461
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1702/DataTypesUpdate.java428
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1702/Migration1702.java1406
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/DistributionStatusUpdate.java160
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707.java58
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707ArtifactUuidFix.java585
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707Config.java279
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707MissingInfoFix.java220
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707RelationsFix.java151
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707VnfFix.java120
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/MigrationTitanStrategy.java33
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/MigrationUtils.java47
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/RenameGraphPropertyKeys.java56
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/ToscaNamesUpdate.java388
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/ToscaTemplateRegeneration.java175
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/VfModulesPropertiesAdding.java257
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/CategoriesUtils.java45
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ComponentMigration.java132
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ConsumersMigration.java67
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/InvariantUUIDResolver.java61
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/JsonModelMigration.java112
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/MigrationByIdDerivedNodeTypeResolver.java43
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/NodeTemplateMissingDataResolver.java353
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/NormativesMigration.java86
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/NormativesResolver.java101
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ResourceVersionMigration.java42
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ResourcesCategoriesMigration.java181
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ServiceCategoriesMigration.java71
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ServiceVersionMigration.java43
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ServicesMigration.java180
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/UserStatesMigration.java187
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/UsersMigration.java78
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/VFResourcesMigration.java79
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/VersionMigration.java118
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/FulfilledCapabilitiesMigrationService.java104
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/FulfilledCapabilityRequirementMigrationService.java184
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/FulfilledRequirementsMigrationService.java104
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/RequirementsCapabilitiesMigrationService.java111
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java14
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java1
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java18
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java3
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java21
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactsVertexResult.java30
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java5
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java27
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java66
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/VertexResult.java30
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/MigrationMenu.java345
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java4
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java6
-rw-r--r--asdctool/src/main/resources/scripts/dataMigration.sh56
-rw-r--r--asdctool/src/main/resources/scripts/dataMigration1607.sh33
-rw-r--r--asdctool/src/main/resources/scripts/dataMigration1610.sh41
-rw-r--r--asdctool/src/main/resources/scripts/dataMigration1702.sh35
-rw-r--r--asdctool/src/main/resources/scripts/dataMigration1707.sh35
-rw-r--r--asdctool/src/main/resources/scripts/validationTool.sh3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java48
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java58
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java1
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java52
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java11
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java114
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java11
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java37
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java63
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java5
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java10
-rw-r--r--catalog-be/src/main/webapp/WEB-INF/web.xml7
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java1
-rw-r--r--catalog-fe/src/main/webapp/WEB-INF/web.xml8
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java57
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java10
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java12
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java6
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java8
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java43
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaFunctions.java19
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/DataTypePropertyConverter.java130
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/HeatJsonConverter.java13
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaConverterUtils.java13
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java18
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/DataTypePropertyConverterTest.java187
-rw-r--r--catalog-ui/package.json2
-rw-r--r--catalog-ui/src/app/models.ts1
-rw-r--r--catalog-ui/src/app/models/modal.ts4
-rw-r--r--catalog-ui/src/app/models/server-error-response.ts84
-rw-r--r--catalog-ui/src/app/ng2/app.module.ts19
-rw-r--r--catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/integer-input/ui-element-integer-input.component.ts2
-rw-r--r--catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.html2
-rw-r--r--catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.ts2
-rw-r--r--catalog-ui/src/app/ng2/components/loader/loader.component.html3
-rw-r--r--catalog-ui/src/app/ng2/components/loader/loader.component.less16
-rw-r--r--catalog-ui/src/app/ng2/components/loader/loader.component.ts66
-rw-r--r--catalog-ui/src/app/ng2/components/modal/error-message/error-message.component.html5
-rw-r--r--catalog-ui/src/app/ng2/components/modal/error-message/error-message.component.ts (renamed from asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/MigrationException.java)17
-rw-r--r--catalog-ui/src/app/ng2/components/modal/modal.component.html8
-rw-r--r--catalog-ui/src/app/ng2/components/modal/modal.component.less15
-rw-r--r--catalog-ui/src/app/ng2/components/modal/modal.component.ts6
-rw-r--r--catalog-ui/src/app/ng2/components/modal/modal.module.ts9
-rw-r--r--catalog-ui/src/app/ng2/components/properties-table/properties-table.component.html2
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts3
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html2
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.less15
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts24
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts4
-rw-r--r--catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts4
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/component.service.ts8
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/service.service.ts4
-rw-r--r--catalog-ui/src/app/ng2/services/data-type.service.ts2
-rw-r--r--catalog-ui/src/app/ng2/services/http.interceptor.service.ts162
-rw-r--r--catalog-ui/src/app/ng2/services/http.service.ts29
-rw-r--r--catalog-ui/src/app/ng2/services/modal.service.ts27
-rw-r--r--catalog-ui/src/app/services/event-listener-service.ts2
-rw-r--r--catalog-ui/src/app/utils/constants.ts6
-rw-r--r--catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view-model.ts10
-rw-r--r--catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view.html2
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/activity-log/activity-log.ts1
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/attributes/attributes-view-model.ts1
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/composition/composition-view-model.ts7
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model.ts3
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.ts1
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/deployment/deployment-view-model.ts1
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/distribution/distribution-view-model.ts1
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts1
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/information-artifacts/information-artifacts-view-model.ts1
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model.ts1
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs-view-model.ts1
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view-model.ts225
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view.html5
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model.ts10
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view.html3
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view-model.ts1
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model.ts1
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model.ts1
-rw-r--r--catalog-ui/src/app/view-models/workspace/workspace-view-model.ts8
-rw-r--r--catalog-ui/src/assets/styles/app.less2
-rw-r--r--catalog-ui/src/assets/styles/sdc-ui.css361
-rw-r--r--catalog-ui/src/index.html2
-rw-r--r--catalog-ui/src/third-party/PunchOutRegistry.js27
-rw-r--r--catalog-ui/src/third-party/cytoscape.js-edge-editation/CytoscapeEdgeEditation.js3
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java13
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java3
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java10
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java4
-rw-r--r--test-apis-ci/src/main/resources/ci/scripts/copyToStorage.sh13
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTest.java11
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CustomizationUUID.java11
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java12
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java45
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java12
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Onboard.java63
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Product.java18
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java10
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java13
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java212
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java4
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java17
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java9
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/GeneralUIUtils.java1
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java5
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java2
-rw-r--r--ui-ci/src/main/resources/ci/conf/attsdc.yaml13
-rw-r--r--ui-ci/src/main/resources/ci/scripts/copyToStorage.sh12
-rw-r--r--ui-ci/src/main/resources/ci/testSuites/extendedSanity.xml2
-rw-r--r--ui-ci/src/main/resources/ci/testSuites/onboardingVNFs.xml10
-rw-r--r--ui-ci/src/main/resources/ci/testSuites/onboardingVNFsShortFlow.xml18
186 files changed, 1652 insertions, 12971 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/Migration1707Task.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/Migration1707Task.java
deleted file mode 100644
index 2c19c94cff..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/Migration1707Task.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration;
-
-/**
- * for 1707 migration only!!!
- * please don't implement this interface unless you are sure you want to run with 1707 migration classes
- */
-public interface Migration1707Task {
-
- /**
- * performs a migration operation
- * @return true if migration completed successfully or false otherwise
- */
- boolean migrate();
-
- /**
- *
- * @return a description of what this migration does
- */
- String description();
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/MigrationMsg.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/MigrationMsg.java
deleted file mode 100644
index e743e5387b..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/MigrationMsg.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration;
-
-public enum MigrationMsg {
- RENMAE_KEY_PROPERTIES_1707("renaming key properties"),
- KEY_PROPERTY_NOT_EXIST("key propery %s not exist"),
- RENAME_KEY_PROPERTY_FAILED("failed to rename key property %s"),
- FAILED_TO_RETRIEVE_GRAPH("failed to get graph %s"),
- PROPERTY_KEY_NOT_EXIST("property key %s not found."),
- FAILED_TO_RETRIEVE_NODES("failed to retrieve nodes from graph. error status: %s"),
- FAILED_TO_GET_NODE_FROM_GRAPH("failed to retrieve node from graph. error status : %s"),
- FAILED_TO_CREATE_NODE("failed to create node of type %s. reason: %s"),
- FAILED_TO_RETRIEVE_CATEGORIES("failed to retrieve categories. error status: %s"),
- FAILED_TO_RETRIEVE_CATEGORY("failed to retrieve category %s. error status: %s"),
- FAILED_TO_CREATE_SUB_CATEGORY("failed to create sub category %s of category %s. error status: %s"),
- FAILED_TO_CREATE_CATEGORY("failed to create category %s. error status: %s"),
- FAILED_TO_RETRIEVE_USER_STATES("failed to retrieve user %s states. error status: %s"),
- FAILED_TO_RETRIEVE_MIGRATION_USER_STATES("failed to retrieve migrating user %s states for deletion. error status: %s"),
- FAILED_TO_RETRIEVE_MIGRATION_USER("failed to retrieve migration user %s. error status: %s"),
- FAILED_TO_RETRIEVE_VERSION_RELATION("failed to retrieve version relation from component with id %s to component with id %s. error status: %s"),
- FAILED_TO_RETRIEVE_REQ_CAP("failed to retrieve fulfilled requirements or capabilities for instance %s. error status: %s"),
- FAILED_TO_RETRIEVE_VERTEX("failed to retrieve vertex with id: %s. error status: %s"),
- FAILED_TO_RETRIEVE_CAP_REQ_VERTEX("failed to retrieve capabilities or requirements vertex for component %s. error status: %s"),
- FAILED_TO_ASSOCIATE_CAP_REQ("failed to associate fulfilled capabilities or requirements for components %s. error status: %s"),
- FAILED_TO_RETRIEVE_TOSCA_DEF("failed to retrieve tosca definition for requirement or capability %s. error status %s"),
- ;
-
- private String message;
-
- MigrationMsg(String migrationDescription) {
- this.message = migrationDescription;
- }
-
- public String getMessage(String ... msgProperties) {
- return String.format(this.message, msgProperties);
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/MigrationOperationUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/MigrationOperationUtils.java
deleted file mode 100644
index 7a34521d93..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/MigrationOperationUtils.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration;
-
-import com.thinkaurelius.titan.core.PropertyKey;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanVertex;
-import com.thinkaurelius.titan.core.schema.TitanManagement;
-import fj.data.Either;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.Map;
-import java.util.Optional;
-
-@Component("migrationUtils")
-public class MigrationOperationUtils {
-
- private static Logger log = LoggerFactory.getLogger(MigrationOperationUtils.class);
-
- @Autowired
- private TitanGenericDao titanGenericDao;
-
- /**
- * rename a set or property keys
- *
- * @param propertyKeys a mapping between the old property key name and the property key name to replace it with
- *
- * @return true if rename ended successfully or false otherwise
- */
- public boolean renamePropertyKeys(Map<String, String> propertyKeys) {
- Either<TitanGraph, TitanOperationStatus> graph = titanGenericDao.getGraph();
- return graph.either((titanGraph) -> renamePropertyKeys(titanGraph, propertyKeys),
- (titanOperationStatus) -> operationFailed(MigrationMsg.FAILED_TO_RETRIEVE_GRAPH.getMessage(titanOperationStatus.name())));
- }
-
- private boolean renamePropertyKeys(TitanGraph titanGraph, Map<String, String> propertyKeys) {
- try {
- for (Map.Entry<String, String> propertyKeyEntry : propertyKeys.entrySet()) {
- boolean renameSucceeded = renamePropertyKey(titanGraph, propertyKeyEntry);
- if (!renameSucceeded) {
- return false;
- }
- }
- return true;
- } catch (RuntimeException e) {
- log.error(e.getMessage(), e);
- return false;
- }
- }
-
- private Boolean renamePropertyKey(TitanGraph titanGraph, Map.Entry<String, String> propertyKeyEntry) {
- String renameFromKey = propertyKeyEntry.getKey();
- String renameToKey = propertyKeyEntry.getValue();
- log.info(String.format("renaming property key %s to %s", renameFromKey, renameToKey));
- return renameProperty(titanGraph, renameFromKey, renameToKey);
- }
-
- private Boolean renameProperty(TitanGraph titanGraph, String renameFromKey, String renameToKey) {
- if (titanGraph.containsPropertyKey(renameFromKey) && titanGraph.containsPropertyKey(renameToKey)) {//new property already exist, we cant rename to it we need to add new and remove old on every vertices which has the old one.
- return renamePropertyOnEachVertex(titanGraph, renameFromKey, renameToKey);
- }
- return renamePropertyOnGraphLevel(titanGraph, renameFromKey, renameToKey);
- }
-
- private Boolean renamePropertyOnGraphLevel(TitanGraph titanGraph, String renameFromKey, String renameToKey) {
- TitanManagement titanManagement = titanGraph.openManagement();
- return Optional.ofNullable(titanManagement.getPropertyKey(renameFromKey))
- .map(propertyKey -> renamePropertyOnGraph(titanManagement, propertyKey, renameToKey))
- .orElseGet(() -> {log.info(MigrationMsg.PROPERTY_KEY_NOT_EXIST.getMessage(renameFromKey)); return true;}) ;//if property key not exist rename is considered to be successful
- }
-
- private boolean renamePropertyOnEachVertex(TitanGraph graph, String oldKey, String newKey) {
- addNewPropertyKeyOnVertices(graph, oldKey, newKey);
- removeOldPropertyKeyFromGraph(graph, oldKey);
- graph.tx().commit();
- return true;
- }
-
- private void removeOldPropertyKeyFromGraph(TitanGraph graph, String oldKey) {
- graph.getPropertyKey(oldKey).remove();
- }
-
- private void addNewPropertyKeyOnVertices(TitanGraph graph, String oldKey, String newKey) {
- graph.query().has(oldKey).vertices().forEach(titanVertex -> {
- copyOldKeyValueAndDropKey(oldKey, newKey, (TitanVertex) titanVertex);
- });
- }
-
- private void copyOldKeyValueAndDropKey(String oldKey, String newKey, TitanVertex titanVertex) {
- VertexProperty<Object> oldProperty = titanVertex.property(oldKey);
- Object oldKeyValue = oldProperty.value();
-
- titanVertex.property(newKey, oldKeyValue);
- oldProperty.remove();
- }
-
- private boolean renamePropertyOnGraph(TitanManagement titanManagement, PropertyKey fromPropertyKey, String toKey) {
- try {
- titanManagement.changeName(fromPropertyKey, toKey);
- titanManagement.commit();
- return true;
- } catch (RuntimeException e) {
- log.error(MigrationMsg.RENAME_KEY_PROPERTY_FAILED.getMessage(fromPropertyKey.name()), e.getMessage());
- titanManagement.rollback();
- return false;
- }
- }
-
- private boolean operationFailed(String errorMessage) {
- log.error(errorMessage);
- return false;
- }
-
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AddGroupUuid.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AddGroupUuid.java
deleted file mode 100644
index 03583fdfec..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AddGroupUuid.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1604;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.openecomp.sdc.be.resources.data.GroupData;
-import org.slf4j.Logger;
-
-import fj.data.Either;
-
-public class AddGroupUuid {
-
- public static boolean addGroupUuids(TitanGenericDao titanGenericDao, Logger log, boolean inTrsansaction) {
-
- boolean result = true;
-
- try {
-
- log.debug("========================================================");
- log.debug("Before find all groups");
-
- Either<List<GroupData>, TitanOperationStatus> allGroups = titanGenericDao.getByCriteria(NodeTypeEnum.Group,
- null, null, GroupData.class);
-
- if (allGroups.isRight()) {
- TitanOperationStatus status = allGroups.right().value();
- log.debug("After finding all groups. Status is {}", status);
- if (status != TitanOperationStatus.NOT_FOUND && status != TitanOperationStatus.OK) {
- result = false;
- return result;
- } else {
- return result;
- }
- }
-
- List<GroupData> groups = allGroups.left().value();
-
- log.info("The number of groups fetched is {}", groups == null ? 0 : groups.size());
-
- int numberOfUpdates = 0;
- if (false == groups.isEmpty()) {
- Map<String, List<GroupData>> invariantIdToGroups = groups.stream()
- .collect(Collectors.groupingBy(p -> p.getGroupDataDefinition().getInvariantUUID()));
-
- // All the groups with the same invariantUUID should have the
- // same group UUID since update VF flow with CSAR was not
- // supported in the E2E environment.
-
- log.info("The number of different invariantUuids is {}",
- invariantIdToGroups == null ? 0 : invariantIdToGroups.size());
-
- for (Entry<String, List<GroupData>> entry : invariantIdToGroups.entrySet()) {
-
- String invariantUuid = entry.getKey();
- List<GroupData> groupsData = entry.getValue();
-
- StringBuilder builder = new StringBuilder();
- groupsData.forEach(p -> builder.append(p.getGroupDataDefinition().getUniqueId() + ","));
-
- String groupUUID = groupsData.get(0).getGroupDataDefinition().getGroupUUID();
-
- if (groupUUID == null) {
-
- groupUUID = UniqueIdBuilder.generateUUID();
-
- log.debug("Before updating groups {} with groupUUID {}",builder.toString(),groupUUID);
-
- for (GroupData groupData : groupsData) {
-
- numberOfUpdates++;
- groupData.getGroupDataDefinition().setGroupUUID(groupUUID);
- Either<GroupData, TitanOperationStatus> updateNode = titanGenericDao.updateNode(groupData,
- GroupData.class);
- if (updateNode.isRight()) {
- log.error("Failed to update group {}. Error is {}",groupData,updateNode.right().value().toString());
- result = false;
- return result;
- }
-
- }
-
- log.debug("After updating groups {} with groupUUID {}",builder.toString(),groupUUID);
- }
-
- }
- }
-
- log.info("The number of groups updated with groupUUID is {}", numberOfUpdates);
-
- return result;
-
- } finally {
- log.info("Finish updating groupUUIDs. Status is {}.", result);
- if (inTrsansaction == false) {
- if (result == false) {
- titanGenericDao.rollback();
- } else {
- titanGenericDao.commit();
- }
- }
- }
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AllowMultipleHeats.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AllowMultipleHeats.java
deleted file mode 100644
index 3c9d6fa08f..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AllowMultipleHeats.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1604;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.resources.data.ArtifactData;
-import org.slf4j.Logger;
-
-import fj.data.Either;
-
-public class AllowMultipleHeats {
-
- public static boolean removeAndUpdateHeatPlaceHolders(TitanGenericDao titanGenericDao, Logger log,
- boolean inTrsansaction) {
-
- boolean result = true;
-
- try {
-
- List<ArtifactData> artifactsToDelete = new ArrayList<>();
- List<ArtifactData> artifactsToUpdate = new ArrayList<>();
-
- String[] phLabels = { "heat", "heatvol", "heatnet" };
-
- for (String artifactLabel : phLabels) {
- Map<String, Object> properties = new HashMap<>();
-
- properties.put(GraphPropertiesDictionary.ARTIFACT_LABEL.getProperty(), artifactLabel);
-
- Either<List<ArtifactData>, TitanOperationStatus> allHeatArtifacts = titanGenericDao
- .getByCriteria(NodeTypeEnum.ArtifactRef, properties, null, ArtifactData.class);
-
- if (allHeatArtifacts.isRight()) {
- TitanOperationStatus status = allHeatArtifacts.right().value();
- if (status == TitanOperationStatus.NOT_FOUND) {
- continue;
- } else {
- result = false;
- return result;
- }
-
- }
-
- List<ArtifactData> list = allHeatArtifacts.left().value();
- log.debug("Found {} artifacts with label {}",(list == null ? 0 : list.size()),artifactLabel);
-
- if (list != null && false == list.isEmpty()) {
-
- for (ArtifactData artifactData : list) {
- String esId = artifactData.getArtifactDataDefinition().getEsId();
- if (esId == null || true == esId.isEmpty()) {
- artifactsToDelete.add(artifactData);
- } else {
- artifactsToUpdate.add(artifactData);
- }
- }
- }
- }
-
- if (false == artifactsToDelete.isEmpty()) {
- for (ArtifactData artifactData : artifactsToDelete) {
- // System.out.println("Going to delete artifact " +
- // artifactData);
- log.debug("Going to delete artifact {}",artifactData);
- Either<ArtifactData, TitanOperationStatus> deleteNode = titanGenericDao.deleteNode(artifactData,
- ArtifactData.class);
- if (deleteNode.isRight()) {
- log.error("Failed to delete artifact node {}", deleteNode.left().value());
- result = false;
- return result;
- } else {
- log.debug("Delete artifact node {}",deleteNode.left().value());
- }
- }
- }
-
- log.debug("Number of deleted artifacts is {}",artifactsToDelete.size());
-
- int counter = 0;
- if (false == artifactsToUpdate.isEmpty()) {
- for (ArtifactData artifactData : artifactsToUpdate) {
- // System.out.println("Going to update artifact " +
- // artifactData);
-
- if (artifactData.getArtifactDataDefinition().getMandatory() != null
- && true == artifactData.getArtifactDataDefinition().getMandatory()) {
- log.debug("Going to update artifact {}",artifactData);
- counter++;
- artifactData.getArtifactDataDefinition().setMandatory(false);
- Either<ArtifactData, TitanOperationStatus> updatedNode = titanGenericDao
- .updateNode(artifactData, ArtifactData.class);
- if (updatedNode.isRight()) {
- log.error("Failed to update artifact node {}", updatedNode.left().value());
- result = false;
- return result;
- } else {
- log.debug("Update artifact node {}",updatedNode.left().value());
- }
- }
- }
- }
-
- log.debug("Number of updated artifacts is {}",counter);
-
- return result;
-
- } finally {
- if (inTrsansaction == false) {
- if (result == false) {
- titanGenericDao.rollback();
- } else {
- titanGenericDao.commit();
- }
- }
- }
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AppConfig.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AppConfig.java
deleted file mode 100644
index 3218ed262e..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/AppConfig.java
+++ /dev/null
@@ -1,602 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1604;
-
-import org.openecomp.sdc.asdctool.impl.PopulateComponentCache;
-import org.openecomp.sdc.asdctool.impl.migration.MigrationOperationUtils;
-import org.openecomp.sdc.asdctool.impl.migration.v1607.CsarMigration;
-import org.openecomp.sdc.asdctool.impl.migration.v1610.TitanFixUtils;
-import org.openecomp.sdc.asdctool.impl.migration.v1610.ToscaArtifactsAlignment;
-import org.openecomp.sdc.asdctool.impl.migration.v1702.DataTypesUpdate;
-import org.openecomp.sdc.asdctool.impl.migration.v1702.Migration1702;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.Migration1707ArtifactUuidFix;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.Migration1707RelationsFix;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.Migration1707VnfFix;
-import org.openecomp.sdc.be.auditing.api.IAuditingManager;
-import org.openecomp.sdc.be.auditing.impl.AuditingManager;
-import org.openecomp.sdc.be.components.ArtifactsResolver;
-import org.openecomp.sdc.be.components.distribution.engine.IDistributionEngine;
-import org.openecomp.sdc.be.components.distribution.engine.ServiceDistributionArtifactsBuilder;
-import org.openecomp.sdc.be.components.impl.*;
-import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
-import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
-import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
-import org.openecomp.sdc.be.dao.cassandra.CassandraClient;
-import org.openecomp.sdc.be.dao.cassandra.ComponentCassandraDao;
-import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao;
-import org.openecomp.sdc.be.dao.config.DAOSpringConfig;
-import org.openecomp.sdc.be.dao.es.ElasticSearchClient;
-import org.openecomp.sdc.be.dao.impl.AuditingDao;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
-import org.openecomp.sdc.be.model.cache.ComponentCache;
-import org.openecomp.sdc.be.model.jsontitan.operations.GroupsOperation;
-import org.openecomp.sdc.be.model.operations.api.IAdditionalInformationOperation;
-import org.openecomp.sdc.be.model.operations.api.IElementOperation;
-import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
-import org.openecomp.sdc.be.model.operations.api.IUserAdminOperation;
-import org.openecomp.sdc.be.model.operations.impl.AdditionalInformationOperation;
-import org.openecomp.sdc.be.model.operations.impl.ArtifactOperation;
-import org.openecomp.sdc.be.model.operations.impl.AttributeOperation;
-import org.openecomp.sdc.be.model.operations.impl.CacheMangerOperation;
-import org.openecomp.sdc.be.model.operations.impl.CapabilityInstanceOperation;
-import org.openecomp.sdc.be.model.operations.impl.CapabilityOperation;
-import org.openecomp.sdc.be.model.operations.impl.CapabilityTypeOperation;
-import org.openecomp.sdc.be.model.operations.impl.ComponentInstanceOperation;
-import org.openecomp.sdc.be.model.operations.impl.ConsumerOperation;
-import org.openecomp.sdc.be.model.operations.impl.CsarOperation;
-import org.openecomp.sdc.be.model.operations.impl.ElementOperation;
-import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
-import org.openecomp.sdc.be.model.operations.impl.GroupInstanceOperation;
-import org.openecomp.sdc.be.model.operations.impl.GroupOperation;
-import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation;
-import org.openecomp.sdc.be.model.operations.impl.HeatParametersOperation;
-import org.openecomp.sdc.be.model.operations.impl.InputsOperation;
-import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
-import org.openecomp.sdc.be.model.operations.impl.LifecycleOperation;
-import org.openecomp.sdc.be.model.operations.impl.OnboardingClient;
-import org.openecomp.sdc.be.model.operations.impl.ProductOperation;
-import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
-import org.openecomp.sdc.be.model.operations.impl.RequirementOperation;
-import org.openecomp.sdc.be.model.operations.impl.ResourceOperation;
-import org.openecomp.sdc.be.model.operations.impl.ServiceOperation;
-import org.openecomp.sdc.be.model.operations.impl.UserAdminOperation;
-import org.openecomp.sdc.be.tosca.CsarUtils;
-import org.openecomp.sdc.be.tosca.ToscaExportHandler;
-import org.openecomp.sdc.be.user.IUserBusinessLogic;
-import org.openecomp.sdc.be.user.UserBusinessLogic;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import org.springframework.context.annotation.Primary;
-
-@Configuration
-@Import(DAOSpringConfig.class)
-public class AppConfig {
-
- @Bean(name="artifact-resolver")
- public ArtifactsResolver artifactsResolver() {
- return new ArtifactResolverImpl();
- }
-
- @Bean(name = "sdc-schema-files-cassandra-dao")
- public SdcSchemaFilesCassandraDao sdcSchemaFilesCassandraDao() {
- return new SdcSchemaFilesCassandraDao();
- }
- @Bean(name = "componentsUtils")
- public ComponentsUtils componentsUtils() {
- return new ComponentsUtils();
- }
- @Bean(name = "updateDataTypes")
- public DataTypesUpdate dataTypesUpdate() {
- return new DataTypesUpdate();
- }
- @Bean(name = "serviceMigrationBean")
- public ServiceMigration serviceMigration() {
- return new ServiceMigration();
- }
-
- @Bean(name = "vfcNamingAlignmentBean")
- public VfcNamingAlignment vfcNamingAlignment() {
- return new VfcNamingAlignment();
- }
-
- @Bean(name = "derivedFromAlignment")
- public DerivedFromAlignment derivedFromAlignment() {
- return new DerivedFromAlignment();
- }
-
- @Bean(name = "groupsAlignment")
- public GroupsAlignment groupsAlignment() {
- return new GroupsAlignment();
- }
-
- @Bean(name = "csarMigration")
- public CsarMigration csarMigration() {
- return new CsarMigration();
- }
-
- @Bean(name = "resource-operation")
- public ResourceOperation resourceOperation() {
- return new ResourceOperation();
- }
-
- @Bean(name = "service-operation")
- public ServiceOperation serviceOperation() {
- return new ServiceOperation();
- }
-
- @Bean(name = "component-instance-operation")
- public ComponentInstanceOperation componentInstanceOperation() {
- return new ComponentInstanceOperation();
- }
-
- @Bean(name = "capability-instanceOperation")
- public CapabilityInstanceOperation capabilityInstanceOperation() {
- return new CapabilityInstanceOperation();
- }
-
- @Bean(name = "property-operation")
- @Primary
- public PropertyOperation propertyOperation(@Qualifier("titan-generic-dao") TitanGenericDao titanGenericDao) {
- return new PropertyOperation(titanGenericDao);
- }
-
- @Bean(name = "attribute-operation")
- public AttributeOperation attribueOperation() {
- return new AttributeOperation();
- }
-
- @Bean(name = "application-datatype-cache")
- public ApplicationDataTypeCache applicationDataTypeCache() {
- return new ApplicationDataTypeCache();
- }
-
- @Bean(name = "requirement-operation")
- public RequirementOperation requirementOperation() {
- return new RequirementOperation();
- }
-
- @Bean(name = "capability-operation")
- public CapabilityOperation capabilityOperation() {
- return new CapabilityOperation();
- }
-
- @Bean(name = "interface-operation")
- public InterfaceLifecycleOperation interfaceLifecycleOperation() {
- return new InterfaceLifecycleOperation();
- }
-
- @Bean(name = "element-operation")
- @Primary
- public IElementOperation elementOperation(@Qualifier("titan-generic-dao") TitanGenericDao titanGenericDao) {
- return new ElementOperation(titanGenericDao);
- }
-
- @Bean(name = "additional-information-operation")
- public IAdditionalInformationOperation addioAdditionalInformationOperation() {
- return new AdditionalInformationOperation();
- }
-
- @Bean(name = "capability-type-operation")
- public CapabilityTypeOperation capabilityTypeOperation() {
- return new CapabilityTypeOperation();
- }
-
- @Bean(name = "artifact-operation")
- public ArtifactOperation artifactOperation() {
- return new ArtifactOperation();
- }
-
- @Bean(name = "heat-parameter-operation")
- public HeatParametersOperation heatParametersOperation() {
- return new HeatParametersOperation();
- }
-
- @Bean(name = "product-operation")
- public ProductOperation productOperation() {
- return new ProductOperation();
- }
-
- @Bean(name = "lifecycle-operation")
- public LifecycleOperation lifecycleOperation() {
- return new LifecycleOperation();
- }
-
- @Bean(name = "group-operation")
- public GroupOperation groupOperation() {
- return new GroupOperation();
- }
-
- @Bean(name = "groups-operation")
- public GroupsOperation jsonGroupsOperation() {
- return new GroupsOperation();
- }
-
- @Bean(name = "group-instance-operation")
- public GroupInstanceOperation groupInstanceOperation() {
- return new GroupInstanceOperation();
- }
-
- @Bean(name = "group-type-operation")
- @Primary
- public GroupTypeOperation groupTypeOperation(@Qualifier("titan-generic-dao") TitanGenericDao titanGenricDao, @Qualifier("property-operation")PropertyOperation propertyOperation) {
- return new GroupTypeOperation(titanGenricDao, propertyOperation);
- }
-
- @Bean(name = "attribute-operation")
- public AttributeOperation attributeOperation() {
- return new AttributeOperation();
- }
-
- @Bean(name = "titanFixUtils")
- public TitanFixUtils titanFixUtils() {
- return new TitanFixUtils();
- }
-
- @Bean(name = "populateComponentCache")
- public PopulateComponentCache populateComponentCache() {
- return new PopulateComponentCache();
- }
-
- @Bean(name = "artifact-cassandra-dao")
- public ArtifactCassandraDao artifactCassandraDao() {
- return new ArtifactCassandraDao();
- }
-
- @Bean(name = "component-cassandra-dao")
- public ComponentCassandraDao componentCassandraDao() {
- return new ComponentCassandraDao();
- }
-
- @Bean(name = "cassandra-client")
- public CassandraClient cassandraClient() {
- return new CassandraClient();
- }
-
- @Bean(name = "cacheManger-operation")
- public CacheMangerOperation cacheMangerOperation() {
- return new CacheMangerOperation();
- }
-
- @Bean(name = "component-cache")
- public ComponentCache componentCache() {
- return new ComponentCache();
- }
-
- @Bean(name = "input-operation")
- public InputsOperation inputsOperation() {
- return new InputsOperation();
- }
-
- /**
- * Returns new instance of AuditCassandraDao
- *
- * @return
- */
- @Bean(name = "audit-cassandra-dao")
- public AuditCassandraDao auditCassandraDao() {
- return new AuditCassandraDao();
- }
-
- /**
- * Returns new instance of UserBusinessLogic
- *
- * @return
- */
- @Bean(name = "userBusinessLogic")
- public IUserBusinessLogic userBusinessLogic() {
- return new UserBusinessLogic();
- }
-
- /**
- * Returns new instance of UserAdminOperation
- *
- * @return
- */
- @Bean(name = "user-operation")
- @Primary
- public IUserAdminOperation userOperation(@Qualifier("titan-generic-dao") TitanGenericDao titanGenericDao) {
- return new UserAdminOperation(titanGenericDao);
- }
-
- /**
- * Returns new instance of GraphLockOperation
- *
- * @return
- */
- @Bean(name = "graph-lock-operation")
- public IGraphLockOperation graphLockOperation() {
- return new GraphLockOperation();
- }
-
- /**
- * Returns new instance of AuditingDao
- *
- * @return
- */
- @Bean(name = "auditingDao")
- public AuditingDao auditingDao() {
- return new AuditingDao();
- }
-
- /**
- * Returns new instance of AuditingManager
- *
- * @return
- */
- @Bean(name = "auditingManager")
- public IAuditingManager auditingManager() {
- return new AuditingManager();
- }
-
- /**
- * Returns new instance of ServiceBusinessLogic
- *
- * @return
- */
- @Bean(name = "serviceBusinessLogic")
- public ServiceBusinessLogic serviceBusinessLogic() {
- return new ServiceBusinessLogic();
- }
-
- /**
- * Returns new instance of ComponentsUtils
- *
- * @return
- */
- @Bean(name = "componentUtils")
- public ComponentsUtils componentUtils() {
- return new ComponentsUtils();
- }
-
- /**
- * Returns new instance of ToscaArtifactsAlignment
- *
- * @return
- */
- @Bean(name = "toscaArtifactsAlignment")
- public ToscaArtifactsAlignment toscaArtifactsAlignment() {
- return new ToscaArtifactsAlignment();
- }
-
- /**
- * Returns new instance of ArtifactsBusinessLogic
- *
- * @return
- */
- @Bean(name = "artifactBusinessLogic")
- public ArtifactsBusinessLogic artifactBusinessLogic() {
- return new ArtifactsBusinessLogic();
- }
-
- /**
- * Returns new instance of ResourceBusinessLogic
- *
- * @return
- */
- @Bean(name = "resourceBusinessLogic")
- public ResourceBusinessLogic resourceBusinessLogic() {
- return new ResourceBusinessLogic();
- }
-
- /**
- * Returns new instance of LifecycleBusinessLogic
- *
- * @return
- */
- @Bean(name = "lifecycleBusinessLogic")
- public LifecycleBusinessLogic lifecycleBusinessLogic() {
- return new LifecycleBusinessLogic();
- }
-
- /**
- * Returns new instance of ServiceDistributionArtifactsBuilder
- *
- * @return
- */
- @Bean(name = "serviceDistributionArtifactsBuilder")
- public ServiceDistributionArtifactsBuilder serviceDistributionArtifactsBuilder() {
- return new ServiceDistributionArtifactsBuilder();
- }
-
- /**
- * Returns new instance of DistributionEngine
- *
- * @return
- */
- @Bean(name = "distributionEngine")
- public IDistributionEngine distributionEngine() {
- // This dependency is needed for initializing context but is not used
- return null;
- }
-
- /**
- * Returns new instance of ElasticSearchClient
- *
- * @return
- */
- @Bean(name = "elasticsearch-client")
- public ElasticSearchClient elasticsearchClient() {
- // This dependency is needed for initializing context but is not used
- return null;
- }
-
- /**
- * Returns new instance of ProductBusinessLogic
- *
- * @return
- */
- @Bean(name = "productBusinessLogic")
- public ProductBusinessLogic productBusinessLogic() {
- return new ProductBusinessLogic();
- }
-
- /**
- * Returns new instance of ProductComponentInstanceBusinessLogic
- *
- * @return
- */
- @Bean(name = "productComponentInstanceBusinessLogic")
- public ProductComponentInstanceBusinessLogic productComponentInstanceBusinessLogic() {
- return new ProductComponentInstanceBusinessLogic();
- }
-
- /**
- * Returns new instance of ToscaExportHandler
- *
- * @return
- */
- @Bean(name = "tosca-export-handler")
- public ToscaExportHandler toscaExportHandler() {
- return new ToscaExportHandler();
- }
-
- /**
- * Returns new instance of CsarOperation
- *
- * @return
- */
- @Bean(name = "csar-operation")
- public CsarOperation csarOperation() {
- return new CsarOperation();
- }
-
- /**
- * Returns new instance of OnboardingClient
- *
- * @return
- */
- @Bean(name = "onboarding-client")
- public OnboardingClient onboardingClient() {
- return new OnboardingClient();
- }
-
- /**
- * Returns new instance of VFComponentInstanceBusinessLogic
- *
- * @return
- */
- @Bean(name = "vfComponentInstanceBusinessLogic")
- public VFComponentInstanceBusinessLogic vfComponentInstanceBusinessLogic() {
- return new VFComponentInstanceBusinessLogic();
- }
-
- /**
- * Returns new instance of ResourceImportManager
- *
- * @return
- */
- @Bean(name = "resourceImportManager")
- public ResourceImportManager resourceImportManager() {
- return new ResourceImportManager();
- }
-
- /**
- * Returns new instance of GroupBusinessLogic
- *
- * @return
- */
- @Bean(name = "groupBusinessLogic")
- public GroupBusinessLogic groupBusinessLogic() {
- return new GroupBusinessLogic();
- }
-
- /**
- * Returns new instance of InputsBusinessLogic
- *
- * @return
- */
- @Bean(name = "inputsBusinessLogic")
- public InputsBusinessLogic inputsBusinessLogic() {
- return new InputsBusinessLogic();
- }
-
- /**
- * Returns new instance of CompositionBusinessLogic
- *
- * @return
- */
- @Bean(name = "compositionBusinessLogic")
- public CompositionBusinessLogic compositionBusinessLogic() {
- return new CompositionBusinessLogic();
- }
-
- /**
- * Returns new instance of CsarUtils
- *
- * @return
- */
- @Bean(name = "csar-utils")
- public CsarUtils csarUtils() {
- return new CsarUtils();
- }
-
- /**
- * Returns new instance of ServiceComponentInstanceBusinessLogic
- *
- * @return
- */
- @Bean(name = "serviceComponentInstanceBusinessLogic")
- public ServiceComponentInstanceBusinessLogic serviceComponentInstanceBusinessLogic() {
- return new ServiceComponentInstanceBusinessLogic();
- }
- /**
- *
- * @return new instance of migration1702
- */
- @Bean(name = "migration1702")
- public Migration1702 migration1702() {
- return new Migration1702();
- }
-
-
- @Bean(name = "migrationUtils")
- public MigrationOperationUtils migrationUtils() {
- return new MigrationOperationUtils();
- }
-
- @Bean("consumer-operation")
- public ConsumerOperation consumerOperation(@Qualifier("titan-generic-dao") TitanGenericDao titanGenericDao) {
- return new ConsumerOperation(titanGenericDao);
- }
-
- @Bean(name = "migration1707relationsFix")
- public Migration1707RelationsFix migration1707RelationsFix() {
- return new Migration1707RelationsFix();
- }
- @Bean(name = "migration1707vnfFix")
- public Migration1707VnfFix migration1707VnfFix() {
- return new Migration1707VnfFix();
- }
- @Bean(name = "migration1707UuidFix")
- public Migration1707ArtifactUuidFix migration1707ArtifactUuidFix() {
- return new Migration1707ArtifactUuidFix();
- }
-
-
-// @Bean(name = "migration1707relationsFix")
-// public Migration1707RelationsFix migration1707RelationsFix() {
-// return new Migration1707RelationsFix();
-// }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/DerivedFromAlignment.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/DerivedFromAlignment.java
deleted file mode 100644
index c1ddc4fee0..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/DerivedFromAlignment.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1604;
-
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
-import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import fj.data.Either;
-
-public class DerivedFromAlignment {
- private static Logger log = LoggerFactory.getLogger(VfcNamingAlignment.class.getName());
- private Map<String, String> newDerivedFromValuesHM = new HashMap<String, String>();
- @Autowired
- protected TitanGenericDao titanGenericDao;
-
- public boolean alignDerivedFrom1604(String appConfigDir, String dataInputFileDir) {
- log.debug("Started alignDerivedFrom1604 procedure..");
- boolean result = false;
- try {
- if (!getDerivedFromValuesFromFile(dataInputFileDir)) {
- log.error("Started alignDerivedFrom1604 procedure was failed. Missing data in the input data file.");
- return result;
- }
- result = changeDerivedFrom();
- } finally {
- if (!result) {
- titanGenericDao.rollback();
- log.debug("**********************************************");
- log.debug("alignDerivedFrom1604 procedure FAILED!!");
- log.debug("**********************************************");
- } else {
- titanGenericDao.commit();
- log.debug("**********************************************");
- log.debug("alignDerivedFrom1604 procedure ended successfully!");
- log.debug("**********************************************");
- }
- }
- return result;
- }
-
- private boolean changeDerivedFrom() {
- Map<String, ResourceMetadataData> resourcesHM = getLatestVersionsOfResources();
- if (resourcesHM == null)
- return false;
- Map<String, ResourceMetadataData> derivedFromResourcesHM = getLatestCertifiedVersionsOfDerivedFromResources();
- if (derivedFromResourcesHM == null)
- return false;
- return updateEdges(resourcesHM, derivedFromResourcesHM);
- }
-
- private boolean updateEdges(Map<String, ResourceMetadataData> resourcesHM,
- Map<String, ResourceMetadataData> derivedFromResourcesHM) {
- log.debug("Updating of Edges has been started..");
- for (Entry<String, ResourceMetadataData> pair : resourcesHM.entrySet()) {
- ResourceMetadataData curResource = pair.getValue();
- String uniqeID = (String) curResource.getUniqueId();
- Either<ImmutablePair<ResourceMetadataData, GraphEdge>, TitanOperationStatus> parentResourceRes = titanGenericDao
- .getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Resource), uniqeID,
- GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.Resource, ResourceMetadataData.class);
- if (parentResourceRes.isLeft()) {
- ImmutablePair<ResourceMetadataData, GraphEdge> value = parentResourceRes.left().value();
- ResourceMetadataData parentResourceData = value.getKey();
- log.debug("Deleting old relation..");
- Either<GraphRelation, TitanOperationStatus> deletingRelationRes = titanGenericDao
- .deleteRelation(curResource, parentResourceData, GraphEdgeLabels.DERIVED_FROM);
- if (deletingRelationRes.isRight()) {
- log.error("Couldn't delete relation from resource {} to resource {}, error: {}",
- curResource.getMetadataDataDefinition().getName(),
- parentResourceData.getMetadataDataDefinition().getName(),
- deletingRelationRes.right().value());
- return false;
- }
- ResourceMetadataData newDerivedFromResource = derivedFromResourcesHM.get(pair.getKey());
- Either<GraphRelation, TitanOperationStatus> creatingRelationRes = titanGenericDao
- .createRelation(curResource, newDerivedFromResource, GraphEdgeLabels.DERIVED_FROM, null);
- if (creatingRelationRes.isRight()) {
- log.error("Couldn't create relation from resource {} to resource {}, error: {}",
- curResource.getMetadataDataDefinition().getName(),
- newDerivedFromResource.getMetadataDataDefinition().getName(),
- creatingRelationRes.right().value());
- return false;
- }
- } else {
- log.error("Couldn't get derived from resource for child resource {}, error: {}", pair.getKey(),
- parentResourceRes.right().value());
- return false;
- }
- }
- return true;
- }
-
- private Map<String, ResourceMetadataData> getLatestCertifiedVersionsOfDerivedFromResources() {
- log.debug("Getting latest certified versions of derived from resources according input file");
- Map<String, ResourceMetadataData> resourcesHM = new HashMap<String, ResourceMetadataData>();
- Map<String, Object> props = null;
- for (Entry<String, String> pair : newDerivedFromValuesHM.entrySet()) {
- props = new HashMap<String, Object>();
- props.put(GraphPropertiesDictionary.TOSCA_RESOURCE_NAME.getProperty(), pair.getValue());
- props.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true);
- Either<List<ResourceMetadataData>, TitanOperationStatus> highestVersionResource = titanGenericDao
- .getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
- if (highestVersionResource.isRight()) {
- log.error("Couldn't get resource {} from DB, error: {}", pair.getValue(),
- highestVersionResource.right().value());
- return null;
- }
- List<ResourceMetadataData> highestVersionResourceAL = highestVersionResource.left().value();
- if (highestVersionResourceAL == null) {
- log.error("Couldn't get resource {}. No resource found", pair.getValue());
- return null;
- }
- ResourceMetadataData resource = highestVersionResourceAL.get(0);
- String state = resource.getMetadataDataDefinition().getState();
- if (!state.equals(LifecycleStateEnum.CERTIFIED.name())) {
- log.error(
- "alignDerivedFrom1604 procedure FAILED!! Derived from resource {} is not certified. Please certify manually and repeat the procedure.",
- pair.getValue());
- return null;
- }
- resourcesHM.put(pair.getKey(), resource);
- }
- return resourcesHM;
- }
-
- private Map<String, ResourceMetadataData> getLatestVersionsOfResources() {
- log.debug("Getting latest versions of resources according input file");
- Map<String, ResourceMetadataData> resourcesHM = new HashMap<String, ResourceMetadataData>();
- ResourceMetadataData foundResource = null;
- Map<String, Object> props = null;
- for (Entry<String, String> pair : newDerivedFromValuesHM.entrySet()) {// filter
- props = new HashMap<String, Object>();
- props.put(GraphPropertiesDictionary.NAME.getProperty(), pair.getKey());
- props.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true);
-
- Either<List<ResourceMetadataData>, TitanOperationStatus> highestVersionResource = titanGenericDao
- .getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
- if (highestVersionResource.isRight()) {
- log.error("Couldn't get resource {} from DB, error: {}", pair.getKey(),
- highestVersionResource.right().value());
- return null;
- }
- List<ResourceMetadataData> highestVersionResourceAL = highestVersionResource.left().value();
- if (highestVersionResourceAL == null) {
- log.error("Couldn't get resource {}. No resource found", pair.getKey());
- return null;
- }
- if (highestVersionResourceAL.size() > 2) {
- log.error("Invalid response. Found more than two highest version resources with name {}.",
- pair.getKey());
- return null;
- }
- foundResource = highestVersionResourceAL.get(0);
- if (highestVersionResourceAL.size() == 2) {
- foundResource = foundResource.getMetadataDataDefinition().getState()
- .equals(LifecycleStateEnum.CERTIFIED.name()) ? highestVersionResourceAL.get(1) : foundResource;
- }
- resourcesHM.put(pair.getKey(), foundResource);
- }
- return resourcesHM;
- }
-
- private boolean getDerivedFromValuesFromFile(String dataInputFileDir) {
- BufferedReader br = null;
- String curPair = null;
- try {
- br = new BufferedReader(new FileReader(dataInputFileDir));
- while ((curPair = br.readLine()) != null) {
- String[] pair = curPair.split(" ");
- if (pair.length < 2) {
- log.error(
- "Expected at least two tokens in every line. Usage: <resource_name> <new_derived_from_name>");
- return false;
- }
- String derivedFrom = pair[pair.length - 1];
- String name = curPair.substring(0, curPair.length() - derivedFrom.length() - 1);
- newDerivedFromValuesHM.put(name, derivedFrom);
- }
- return true;
- } catch (FileNotFoundException e) {
- log.error("Started alignDerivedFrom1604 procedure was failed. Missing input data file.", e);
- } catch (IOException e) {
- log.error("Started alignDerivedFrom1604 procedure was failed. The input data file is empty.", e);
- } finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- log.debug("failed to close file reader", e);
- }
- }
- }
- return false;
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/GroupsAlignment.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/GroupsAlignment.java
deleted file mode 100644
index aebcddfee2..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/GroupsAlignment.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1604;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.GroupTypeDefinition;
-import org.openecomp.sdc.be.model.operations.api.IArtifactOperation;
-import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-import org.openecomp.sdc.common.api.ArtifactTypeEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import fj.data.Either;
-
-public class GroupsAlignment {
-
- private static Logger log = LoggerFactory.getLogger(ServiceMigration.class.getName());
-
- public static String INITIAL_VERSION = "1.0";
- private static final String DEFAULT_GROUP_VF_MODULE = "org.openecomp.groups.VfModule";
- private static final String MODULE = "::module-";
-
- @Autowired
- protected TitanGenericDao titanGenericDao;
- @Autowired
- protected IArtifactOperation artifactOperation;
- @Autowired
- protected IGroupOperation groupOperation;
- @Autowired
- protected GroupTypeOperation groupTypeOperation;
-
- public boolean alignGroups(String appConfigDir) {
-
- log.debug("Started the align groups procedure ...");
- log.debug("Getting all resources with resources");
- boolean result = false;
- try {
-
- Map<String, Object> properties = new HashMap<>();
- properties.put(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty(), ResourceTypeEnum.VF.name());
- Either<List<ResourceMetadataData>, TitanOperationStatus> allVfResources = titanGenericDao
- .getByCriteria(NodeTypeEnum.Resource, properties, ResourceMetadataData.class);
-
- if (allVfResources.isRight()) {
- log.error("Couldn't get VF resources from DB, error: {}", allVfResources.right().value());
- result = false;
- return result;
- }
- List<ResourceMetadataData> resourcesList = allVfResources.left().value();
- if (resourcesList == null) {
- log.error("Couldn't get VF resources from DB, no resources found");
- result = false;
- return result;
- }
- log.debug("Found {} VF resources", resourcesList.size());
- for (ResourceMetadataData resource : resourcesList) {
- result = createGroupIfContainsArtifacts(resource);
- }
- } finally {
- if (!result) {
- titanGenericDao.rollback();
- log.debug("**********************************************");
- log.debug("The align groups procedure FAILED!!");
- log.debug("**********************************************");
- } else {
- titanGenericDao.commit();
- log.debug("**********************************************");
- log.debug("The align groups procedure ended successfully!");
- log.debug("**********************************************");
- }
- }
-
- return result;
- }
-
- private boolean createGroupIfContainsArtifacts(ResourceMetadataData resource) {
-
- String uniqueId = resource.getMetadataDataDefinition().getUniqueId();
- StorageOperationStatus result = StorageOperationStatus.OK;
- Either<Map<String, ArtifactDefinition>, StorageOperationStatus> allArtifactsRes = artifactOperation
- .getArtifacts(uniqueId, NodeTypeEnum.Resource, true);
- if (allArtifactsRes.isRight()) {
- log.error("Couldn't get resource artifacts from DB, error: {}", allArtifactsRes.right().value());
- return false;
- }
- Map<String, ArtifactDefinition> artifactsHM = allArtifactsRes.left().value();
- ArrayList<String> foundArtifactsAL = new ArrayList<String>();
- for (ArtifactDefinition curArtifact : artifactsHM.values()) {
- String atrifactType = curArtifact.getArtifactType();
- if (atrifactType.equalsIgnoreCase(ArtifactTypeEnum.HEAT_VOL.getType())
- || atrifactType.equalsIgnoreCase(ArtifactTypeEnum.HEAT_NET.getType())
- || atrifactType.equalsIgnoreCase(ArtifactTypeEnum.HEAT.getType())) {
- foundArtifactsAL.add(curArtifact.getUniqueId());
- }
- }
- if (foundArtifactsAL.size() > 0) {
- Either<List<GroupDefinition>, TitanOperationStatus> allGroupsRes = groupOperation
- .getAllGroupsFromGraph(uniqueId, NodeTypeEnum.Resource);
- int groupCounter = 1;
- if (allGroupsRes.isRight()) {
- if (allGroupsRes.right().value().name().equals(TitanOperationStatus.OK.name())
- || allGroupsRes.right().value().name().equals(TitanOperationStatus.NOT_FOUND.name())) {
- log.debug("Not found groups resource related to resource {}, response: {}",
- resource.getMetadataDataDefinition().getName(), allGroupsRes.right().value());
- } else {
- log.error("Not found groups resource related to resource {}, DB error: {}",
- resource.getMetadataDataDefinition().getName(), allGroupsRes.right().value());
- return false;
- }
- } else if (allGroupsRes.left().value() != null && allGroupsRes.left().value().size() > 0) {
- groupCounter += allGroupsRes.left().value().size();
- for (GroupDefinition curGroup : allGroupsRes.left().value()) {
- for (String curGroupArtifact : curGroup.getArtifacts()) {
- if (foundArtifactsAL.contains(curGroupArtifact)) {
- foundArtifactsAL.remove(curGroupArtifact);
- }
- }
- }
- }
- if (foundArtifactsAL.size() > 0) {
- GroupDefinition groupDefinition = new GroupDefinition();
- groupDefinition.setName(resource.getMetadataDataDefinition().getName() + MODULE + groupCounter);
- groupDefinition.setType(DEFAULT_GROUP_VF_MODULE);
- groupDefinition.setArtifacts(foundArtifactsAL);
- log.debug("Creating new group {} for VF resource {}", groupDefinition.getName(),
- resource.getMetadataDataDefinition().getName());
- return createGroup(resource.getUniqueId(), ComponentTypeEnum.RESOURCE, groupDefinition);
-
- }
- }
- return true;
- }
-
- private boolean createGroup(Object uniqueId, ComponentTypeEnum componentType, GroupDefinition groupDefinition) {
-
- NodeTypeEnum nodeTypeEnum = componentType.getNodeType();
- String groupType = groupDefinition.getType();
-
- Either<GroupTypeDefinition, StorageOperationStatus> getGroupTypeRes = groupTypeOperation
- .getLatestGroupTypeByType(groupType, true);
- if (getGroupTypeRes.isRight()) {
- log.error("Couldn't get grouptype by type {} from DB, error: {}", groupType,
- getGroupTypeRes.right().value());
- return false;
- }
-
- GroupTypeDefinition groupTypeDefinition = getGroupTypeRes.left().value();
-
- String invariantUUID = UniqueIdBuilder.buildInvariantUUID();
- groupDefinition.setInvariantUUID(invariantUUID);
- groupDefinition.setVersion(INITIAL_VERSION);
- groupDefinition.setTypeUid(groupTypeDefinition.getUniqueId());
-
- Either<GroupDefinition, StorageOperationStatus> addGroupToGraphRes = groupOperation.addGroup(nodeTypeEnum,
- (String) uniqueId, groupDefinition, true);
-
- if (addGroupToGraphRes.isRight()) {
- log.error("Couldn't add group {} to graph, error: {}", groupDefinition.getName(),
- addGroupToGraphRes.right().value());
- return false;
- }
- log.debug("The group {} has been created", groupDefinition.getName());
- return true;
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/MigrationCategory.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/MigrationCategory.java
deleted file mode 100644
index 5605f0980d..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/MigrationCategory.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1604;
-
-import java.util.List;
-
-import org.openecomp.sdc.be.datatypes.category.CategoryDataDefinition;
-
-public class MigrationCategory extends CategoryDataDefinition {
- private String oldName;
-
- List<MigrationSubCategory> subcategories;
-
- public String getOldName() {
- return oldName;
- }
-
- public void setOldName(String oldName) {
- this.oldName = oldName;
- }
-
- public List<MigrationSubCategory> getSubcategories() {
- return subcategories;
- }
-
- public void setSubcategories(List<MigrationSubCategory> subcategories) {
- this.subcategories = subcategories;
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/MigrationSubCategory.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/MigrationSubCategory.java
deleted file mode 100644
index f1886622be..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/MigrationSubCategory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1604;
-
-import org.openecomp.sdc.be.datatypes.category.SubCategoryDataDefinition;
-
-public class MigrationSubCategory extends SubCategoryDataDefinition {
- private String oldName;
-
- public String getOldName() {
- return oldName;
- }
-
- public void setOldName(String oldName) {
- this.oldName = oldName;
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/ServiceMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/ServiceMigration.java
deleted file mode 100644
index 0ef435e1c3..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/ServiceMigration.java
+++ /dev/null
@@ -1,1515 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1604;
-
-import static java.nio.file.Files.readAllBytes;
-import static java.nio.file.Paths.get;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.UUID;
-
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
-import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint;
-import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
-import org.openecomp.sdc.be.dao.neo4j.GraphEdgePropertiesDictionary;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-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.enums.ComponentTypeEnum;
-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.model.AdditionalInformationDefinition;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
-import org.openecomp.sdc.be.model.operations.api.IElementOperation;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.AdditionalInformationOperation;
-import org.openecomp.sdc.be.model.operations.impl.ComponentInstanceOperation;
-import org.openecomp.sdc.be.model.operations.impl.ComponentOperation;
-import org.openecomp.sdc.be.model.operations.impl.LifecycleOperation;
-import org.openecomp.sdc.be.model.operations.impl.ProductOperation;
-import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
-import org.openecomp.sdc.be.model.operations.impl.ResourceOperation;
-import org.openecomp.sdc.be.model.operations.impl.ServiceOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.openecomp.sdc.be.resources.data.CapabilityData;
-import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
-import org.openecomp.sdc.be.resources.data.ComponentMetadataData;
-import org.openecomp.sdc.be.resources.data.ProductMetadataData;
-import org.openecomp.sdc.be.resources.data.RelationshipInstData;
-import org.openecomp.sdc.be.resources.data.RequirementData;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-import org.openecomp.sdc.be.resources.data.ServiceMetadataData;
-import org.openecomp.sdc.be.resources.data.TagData;
-import org.openecomp.sdc.be.resources.data.category.CategoryData;
-import org.openecomp.sdc.be.resources.data.category.SubCategoryData;
-import org.openecomp.sdc.be.utils.CommonBeUtils;
-import org.openecomp.sdc.common.util.ValidationUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.yaml.snakeyaml.Yaml;
-
-import com.thinkaurelius.titan.core.TitanEdge;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanVertex;
-
-import fj.data.Either;
-
-public class ServiceMigration {
-
- private static final String[] NORMATIVE_OLD_NAMES = { "tosca.nodes.network.Network", "tosca.nodes.network.Port", "tosca.nodes.BlockStorage", "tosca.nodes.Compute", "tosca.nodes.Container.Application", "tosca.nodes.Container.Runtime",
- "tosca.nodes.Database", "tosca.nodes.DBMS", "tosca.nodes.LoadBalancer", "tosca.nodes.ObjectStorage", "tosca.nodes.Root", "tosca.nodes.SoftwareComponent", "tosca.nodes.WebApplication", "tosca.nodes.WebServer", };
-
- private static Logger log = LoggerFactory.getLogger(ServiceMigration.class.getName());
-
- @Autowired
- protected TitanGenericDao titanGenericDao;
- @Autowired
- protected ResourceOperation resourceOperation;
- @Autowired
- protected ServiceOperation serviceOperation;
- @Autowired
- protected ProductOperation productOperation;
- @Autowired
- protected LifecycleOperation lifecycleOperaion;
- @Autowired
- protected PropertyOperation propertyOperation;
- @Autowired
- protected AdditionalInformationOperation additionalInformationOperation;
- @Autowired
- protected ComponentInstanceOperation componentInstanceOperaion;
- @Autowired
- protected IElementOperation elementOperation;
-
- public boolean migrate1602to1604(String appConfigDir) {
-
- boolean result = false;
-
- try {
-
- if (!addResourceCounterToResources()) {
- log.debug("Failed to update resource instance counter on resources");
- result = false;
- return result;
- }
- if (!updateComponentInstanceType()) {
- log.debug("Failed to update component instance type");
- result = false;
- return result;
- }
- // fix VF
- if (!fixDerivedVf()) {
- log.debug("Failed to fix VFs");
- result = false;
- return result;
- }
- // update instances and relation
- if (!updateCalculatedEdges()) {
- log.debug("Failed to update calculated edges for VF instances");
- result = false;
- return result;
- }
- // update instances and relation
- if (!updateRelations()) {
- log.debug("Failed to update Instance And Relations in services");
- result = false;
- return result;
- }
- if (!updateCategories(appConfigDir)) {
- log.debug("Failed to update categories");
- result = false;
- return result;
- }
-
- if (!AllowMultipleHeats.removeAndUpdateHeatPlaceHolders(titanGenericDao, log, true)) {
- log.error("Failed to update heat place holders");
- result = false;
- return result;
- }
-
- if (!AddGroupUuid.addGroupUuids(titanGenericDao, log, true)) {
- log.error("Failed to update group UUIDs");
- result = false;
- return result;
- }
-
- result = true;
- } finally {
- if (!result) {
- titanGenericDao.rollback();
- } else {
- titanGenericDao.commit();
- }
- }
- return result;
- }
-
- private boolean updateCategories(String appConfigDir) {
- // String categoryMigrationFile = appConfigDir + File.separator +
- // "categoryMigration.yaml";
- String categoryMigrationFile = appConfigDir + "categoryMigration.yaml";
-
- Map<String, List<MigrationCategory>> categoriesFromYml;
- try {
- categoriesFromYml = createCategoriesFromYml(categoryMigrationFile);
- if (categoriesFromYml == null || categoriesFromYml.isEmpty()) {
- log.debug("updateCategories failed to load categories form migration file {}", categoryMigrationFile);
- return false;
- }
- } catch (Exception e) {
- log.debug("Failed to load category migration file : {}", categoryMigrationFile, e);
- return false;
- }
- for (Map.Entry<String, List<MigrationCategory>> entry : categoriesFromYml.entrySet()) {
- ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(entry.getKey());
- if (componentType != null) {
- switch (componentType) {
- case RESOURCE:
- if (updateResourceCategories(entry.getValue()) == false) {
- log.debug("updateCategories failed to update resource categories");
- return false;
- }
- break;
- case SERVICE:
- if (updateServiceCategories(entry.getValue()) == false) {
- log.debug("updateCategories failed to update service categories");
- return false;
- }
- break;
- default:
- log.debug("updateCategories no changes for categories from type {}", componentType);
- }
- } else {
- log.debug("updateCategories failed not supported component file in migration categories file" + entry.getKey());
- return false;
- }
- }
- return true;
- }
-
- private boolean updateServiceCategories(List<MigrationCategory> categories) {
- log.debug("updateServiceCategories STARTED");
- Either<List<CategoryDefinition>, ActionStatus> serviceCategories = elementOperation.getAllCategories(NodeTypeEnum.ServiceNewCategory, true);
- if (serviceCategories.isRight()) {
- log.debug("updateServiceCategories failed fetch all service categories ,error " + serviceCategories.right().value());
- return false;
- }
- for (MigrationCategory newCat : categories) {
-
- if (newCat.getOldName() == null) {
- // add new
- boolean exist = false;
- for (CategoryDefinition catInDB : serviceCategories.left().value()) {
- if (newCat.getName().equals(catInDB.getName())) {
- exist = true;
- break;
- }
- }
- if (!exist) {
- CategoryDefinition categoryDefinition = new CategoryDefinition(newCat);
- Either<CategoryDefinition, ActionStatus> result = elementOperation.createCategory(categoryDefinition, NodeTypeEnum.ServiceNewCategory, true);
- if (result.isRight()) {
- log.debug("Failed to create service category {} error {}", categoryDefinition, result.right().value());
- return false;
- }
- log.debug("service category {} created", categoryDefinition);
- }
- } else {
- // update exist
- for (CategoryDefinition catInDB : serviceCategories.left().value()) {
- if (newCat.getOldName().equals(catInDB.getName())) {
- Either<CategoryData, TitanOperationStatus> updateSingleResult = updateSingleResourceCategory(newCat, NodeTypeEnum.ServiceNewCategory);
- if (updateSingleResult.isRight()) {
- return false;
- }
- break;
- }
- }
- }
- }
- log.debug("updateServiceCategories ENDED");
- return true;
- }
-
- private Either<CategoryData, TitanOperationStatus> updateSingleResourceCategory(MigrationCategory newCat, NodeTypeEnum nodetype) {
- Map<String, Object> properties = new HashMap<>();
- properties.put(GraphPropertiesDictionary.NAME.getProperty(), newCat.getOldName());
- Either<List<CategoryData>, TitanOperationStatus> categoryEither = titanGenericDao.getByCriteria(nodetype, properties, CategoryData.class);
- if (categoryEither.isRight() && categoryEither.right().value() != TitanOperationStatus.NOT_FOUND) {
- log.debug("Failed to get {} categories, for name {} error {}", nodetype, newCat.getOldName(), categoryEither.right().value());
- return Either.right(categoryEither.right().value());
- }
- List<CategoryData> categoryList = (categoryEither.isLeft() ? categoryEither.left().value() : null);
- if (categoryList == null) {
- log.debug("No {} categories, for name {} error {}", nodetype, newCat.getOldName());
- return Either.right(TitanOperationStatus.NOT_FOUND);
- }
- CategoryData categoryData = categoryList.get(0);
- categoryData.getCategoryDataDefinition().setName(newCat.getName());
- categoryData.getCategoryDataDefinition().setIcons(newCat.getIcons());
- categoryData.getCategoryDataDefinition().setNormalizedName(ValidationUtils.normalizeCategoryName4Uniqueness(newCat.getName()));
- Either<CategoryData, TitanOperationStatus> updateNode = titanGenericDao.updateNode(categoryData, CategoryData.class);
- if (updateNode.isRight()) {
- log.debug("Failed to update {} category {} error {}", nodetype, categoryData, updateNode.right().value());
- return Either.right(updateNode.right().value());
- }
- log.debug("Update {} category {} ", nodetype, categoryData);
- return Either.left(updateNode.left().value());
- }
-
- private boolean updateResourceCategories(List<MigrationCategory> categories) {
- log.debug("updateResourceCategories STARTED");
- Either<List<CategoryDefinition>, ActionStatus> resourceCategories = elementOperation.getAllCategories(NodeTypeEnum.ResourceNewCategory, true);
- if (resourceCategories.isRight()) {
- log.debug("updateResourceCategories failed fetch all resource categories ,error " + resourceCategories.right().value());
- return false;
- }
- for (MigrationCategory newCat : categories) {
- if (newCat.getOldName() == null) {
- // add new
- // check if already created in previous running
- boolean exist = false;
- for (CategoryDefinition catInDB : resourceCategories.left().value()) {
- if (newCat.getName().equals(catInDB.getName())) {
- exist = true;
- }
- }
- if (!exist) {
- CategoryDefinition categoryDefinition = new CategoryDefinition(newCat);
- Either<CategoryDefinition, ActionStatus> resultCat = elementOperation.createCategory(categoryDefinition, NodeTypeEnum.ResourceNewCategory, true);
- if (resultCat.isRight()) {
- log.debug("Failed to create resource category {} error {}", categoryDefinition, resultCat.right().value());
- return false;
- }
- log.debug("resource category {} created", categoryDefinition);
-
- List<MigrationSubCategory> nSubCat = newCat.getSubcategories();
- List<MigrationSubCategory> newSubcat = nSubCat;
- List<MigrationSubCategory> subcategories = newSubcat;
- for (MigrationSubCategory msubcat : subcategories) {
- SubCategoryDefinition subcat = new SubCategoryDefinition(msubcat);
- Either<SubCategoryDefinition, ActionStatus> resultSubcat = elementOperation.createSubCategory(resultCat.left().value().getUniqueId(), subcat, NodeTypeEnum.ResourceSubcategory, true);
- if (resultSubcat.isRight()) {
- log.debug("Failed to create resource sub category {} error {}", subcat, resultSubcat.right().value());
- return false;
- }
- log.debug("resource sub category {} created for category {}", categoryDefinition, resultCat.left().value().getName());
- }
- }
- } else {
- // update exist
- for (CategoryDefinition catInDB : resourceCategories.left().value()) {
- if (newCat.getOldName().equals(catInDB.getName())) {
- Either<CategoryData, TitanOperationStatus> updateSingleResult = updateSingleResourceCategory(newCat, NodeTypeEnum.ResourceNewCategory);
- if (updateSingleResult.isRight()) {
- return false;
- }
-
- CategoryData categoryData = updateSingleResult.left().value();
- for (MigrationSubCategory migSubCat : newCat.getSubcategories()) {
- if (migSubCat.getOldName() == null) {
- // create new one
- boolean existSub = false;
- for (SubCategoryDefinition subCatInDb : catInDB.getSubcategories()) {
- if (subCatInDb.getName().equals(migSubCat.getName())) {
- existSub = true;
- }
- }
- if (!existSub) {
- SubCategoryDefinition subcat = new SubCategoryDefinition(migSubCat);
-
- Either<SubCategoryDefinition, ActionStatus> resultSubcat = elementOperation.createSubCategory((String) categoryData.getUniqueId(), subcat, NodeTypeEnum.ResourceSubcategory, true);
- if (resultSubcat.isRight()) {
- log.debug("Failed to create resource sub category {} error {}", subcat, resultSubcat.right().value());
- return false;
- }
- log.debug("resource sub category {} created for category {}", categoryData, resultSubcat.left().value().getName());
- }
- } else {
- if (updateSingleSubCategory(newCat, migSubCat, updateSingleResult.left().value()) == false) {
- return false;
- }
- }
- }
- break;
- }
- }
- }
- }
- return true;
- }
-
- private boolean updateSingleSubCategory(MigrationCategory newCat, MigrationSubCategory migSubCat, CategoryData categoryData) {
-
- Either<List<ImmutablePair<SubCategoryData, GraphEdge>>, TitanOperationStatus> subcategories = titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceNewCategory), (String) categoryData.getUniqueId(),
- GraphEdgeLabels.SUB_CATEGORY, NodeTypeEnum.ResourceSubcategory, SubCategoryData.class);
-
- if (subcategories.isRight()) {
- log.debug("Failed to get resource sub categories, for name {} error {}", newCat.getOldName(), subcategories.right().value());
- return false;
- }
-
- for (ImmutablePair<SubCategoryData, GraphEdge> pair : subcategories.left().value()) {
- if (pair.getKey().getSubCategoryDataDefinition().getName().equals(migSubCat.getOldName())) {
- SubCategoryData subCategoryData = pair.getKey();
- subCategoryData.getSubCategoryDataDefinition().setName(migSubCat.getName());
- subCategoryData.getSubCategoryDataDefinition().setIcons(migSubCat.getIcons());
- subCategoryData.getSubCategoryDataDefinition().setNormalizedName(ValidationUtils.normalizeCategoryName4Uniqueness(migSubCat.getName()));
- Either<SubCategoryData, TitanOperationStatus> updateSubNode = titanGenericDao.updateNode(subCategoryData, SubCategoryData.class);
- if (updateSubNode.isRight()) {
- log.debug("Failed to update resource sub category {} error {}", subCategoryData, updateSubNode.right().value());
- return false;
- }
- log.debug("Update resource subcategory category {} ", subCategoryData);
- break;
- }
- }
- return true;
- }
-
- private Map<String, List<MigrationCategory>> createCategoriesFromYml(String categoriesTypesYml) {
- String yamlAsString;
- try {
- yamlAsString = new String(readAllBytes(get(categoriesTypesYml)));
- } catch (Exception e) {
- log.debug("Failed to load category import file exception : ", e);
- return null;
- }
-
- log.debug("received yaml: {}", yamlAsString);
-
- Map<String, Object> toscaJson = (Map<String, Object>) new Yaml().load(yamlAsString);
- Map<String, List<MigrationCategory>> allCategories = new HashMap<>();
-
- Iterator<Entry<String, Object>> categoryEntryItr = toscaJson.entrySet().iterator();
- while (categoryEntryItr.hasNext()) {
- Entry<String, Object> categoryTypeEntry = categoryEntryItr.next();
- String categoryType = categoryTypeEntry.getKey();
- List<MigrationCategory> categoriesPerType = null;
- Map<String, Object> categoryPerType = null;
- switch (categoryType) {
- case ComponentTypeEnum.SERVICE_PARAM_NAME:
- categoryPerType = (Map<String, Object>) categoryTypeEntry.getValue();
- categoriesPerType = createServiceCategories(categoryPerType);
- break;
- case ComponentTypeEnum.RESOURCE_PARAM_NAME:
- categoryPerType = (Map<String, Object>) categoryTypeEntry.getValue();
- categoriesPerType = createResourceCategories(categoryPerType);
- break;
- case ComponentTypeEnum.PRODUCT_PARAM_NAME:
- // TODO
- break;
- default:
- log.debug("Not supported category type - {}", categoryType);
- break;
- }
- if (categoriesPerType != null) {
- allCategories.put(categoryType, categoriesPerType);
- }
- }
- return allCategories;
- }
-
- private List<MigrationCategory> createServiceCategories(Map<String, Object> categories) {
- List<MigrationCategory> categroiesDef = new ArrayList<>();
- String catName = null;
- List<String> icons = null;
- String oldName = null;
- for (Entry<String, Object> entry : categories.entrySet()) {
- MigrationCategory catDef = new MigrationCategory();
- Map<String, Object> category = (Map<String, Object>) entry.getValue();
- catName = (String) category.get("name");
- catDef.setName(catName);
- icons = (List<String>) category.get("icons");
- catDef.setIcons(icons);
- String normalizedName = ValidationUtils.normalizeCategoryName4Uniqueness(catName);
- catDef.setNormalizedName(normalizedName);
- oldName = (String) category.get("oldName");
- catDef.setOldName(oldName);
- categroiesDef.add(catDef);
- }
-
- return categroiesDef;
- }
-
- private List<MigrationCategory> createResourceCategories(Map<String, Object> categoryPerType) {
- List<MigrationCategory> categroiesDef = new ArrayList<>();
- for (Map.Entry<String, Object> entry : categoryPerType.entrySet()) {
- Map<String, Object> category = (Map<String, Object>) entry.getValue();
- MigrationCategory catDef = new MigrationCategory();
- String catName = (String) category.get("name");
- catDef.setName(catName);
- String normalizedName = ValidationUtils.normalizeCategoryName4Uniqueness(catName);
- catDef.setNormalizedName(normalizedName);
- String oldName = (String) category.get("oldName");
- catDef.setOldName(oldName);
-
- Map<String, Object> subcategories = (Map<String, Object>) category.get("subcategories");
- List<MigrationSubCategory> subcateDef = new ArrayList<>();
- for (Entry<String, Object> subcategory : subcategories.entrySet()) {
- Map<String, Object> subcategoryInfo = (Map<String, Object>) subcategory.getValue();
- MigrationSubCategory subDef = new MigrationSubCategory();
- String subcategoryName = (String) subcategoryInfo.get("name");
- subDef.setName(subcategoryName);
- List<String> subcategoryIcons = (List<String>) subcategoryInfo.get("icons");
- subDef.setIcons(subcategoryIcons);
- normalizedName = ValidationUtils.normalizeCategoryName4Uniqueness(subcategoryName);
- subDef.setNormalizedName(normalizedName);
- oldName = (String) subcategoryInfo.get("oldName");
- subDef.setOldName(oldName);
-
- subcateDef.add(subDef);
- }
-
- catDef.setSubcategories(subcateDef);
- categroiesDef.add(catDef);
- }
- return categroiesDef;
- }
-
- private boolean updateCalculatedEdges() {
- log.debug("update calculated edges STARTED");
-
- Either<List<ComponentInstanceData>, TitanOperationStatus> allInstances = titanGenericDao.getByCriteria(NodeTypeEnum.ResourceInstance, null, ComponentInstanceData.class);
- if (allInstances.isRight() && !allInstances.right().value().equals(TitanOperationStatus.NOT_FOUND)) {
- log.debug("updateCalculatedEdges failed fetch all resource instances ,error " + allInstances.right().value());
- return false;
- }
- if (allInstances.isRight() && allInstances.right().value().equals(TitanOperationStatus.NOT_FOUND)) {
- log.debug("updateCalculatedEdges - no VFs");
- return true;
- }
- List<ComponentInstanceData> listOfInstances = allInstances.left().value();
- for (ComponentInstanceData instance : listOfInstances) {
- // check if already have calculated edges
- log.debug("start handle instance {}", instance.getUniqueId());
- boolean needProcess = true;
- Either<List<ImmutablePair<CapabilityData, GraphEdge>>, TitanOperationStatus> vfci = titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceInstance), instance.getUniqueId(),
- GraphEdgeLabels.CALCULATED_CAPABILITY, NodeTypeEnum.Capability, CapabilityData.class);
- if (vfci.isRight()) {
- if (!vfci.right().value().equals(TitanOperationStatus.NOT_FOUND)) {
- log.debug("createCalculatedCapabilitiesForInstance failed to fetch instance for resource " + instance.getComponentInstDataDefinition().getComponentUid() + " error " + vfci.right().value());
- return false;
- }
- } else {
- if (vfci.left().value().size() > 0) {
- needProcess = false;
- }
- }
- Either<List<ImmutablePair<RequirementData, GraphEdge>>, TitanOperationStatus> vfciReq = titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceInstance), instance.getUniqueId(),
- GraphEdgeLabels.CALCULATED_REQUIREMENT, NodeTypeEnum.Requirement, RequirementData.class);
- if (vfciReq.isRight()) {
- if (!vfciReq.right().value().equals(TitanOperationStatus.NOT_FOUND)) {
- log.debug("createCalculatedCapabilitiesForInstance failed to fetch instance for resource " + instance.getComponentInstDataDefinition().getComponentUid() + " error " + vfciReq.right().value());
- return false;
- }
- } else {
- if (vfciReq.left().value().size() > 0) {
- needProcess = false;
- }
- }
- Either<List<ImmutablePair<RequirementData, GraphEdge>>, TitanOperationStatus> vfciReqFF = titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceInstance), instance.getUniqueId(),
- GraphEdgeLabels.CALCULATED_REQUIREMENT_FULLFILLED, NodeTypeEnum.Requirement, RequirementData.class);
- if (vfciReqFF.isRight()) {
-
- if (!vfciReqFF.right().value().equals(TitanOperationStatus.NOT_FOUND)) {
- log.debug("createCalculatedCapabilitiesForInstance failed to fetch instance for resource " + instance.getComponentInstDataDefinition().getComponentUid() + " error " + vfciReqFF.right().value());
- return false;
- }
- } else {
- if (vfciReqFF.left().value().size() > 0) {
- needProcess = false;
- }
- }
-
- if (needProcess == false) {
- log.debug("updateCalculatedEdges : for instance {} calculated capabilty/requirement already created", instance.getUniqueId());
- continue;
- }
- String originId = instance.getComponentInstDataDefinition().getComponentUid();
- Either<Resource, StorageOperationStatus> resourceE = resourceOperation.getResource(originId, true);
- if (resourceE.isRight()) {
- log.debug("updateCalculatedEdges failed to fetch origin resource with id {} error {}", originId, resourceE.right().value());
- return false;
- }
- Resource resource = resourceE.left().value();
- Map<String, List<RequirementDefinition>> requirements = resource.getRequirements();
- if (createCalculatedRequirementsForInstance(instance, requirements) != true) {
- return false;
- }
- Map<String, List<CapabilityDefinition>> capabilities = resource.getCapabilities();
- if (createCalculatedCapabilitiesForInstance(instance, capabilities) != true) {
- return false;
- }
- log.debug("finish handle instance {}", instance.getUniqueId());
- }
- log.debug("update calculated edges ENDED");
- return true;
- }
-
- private boolean createCalculatedCapabilitiesForInstance(ComponentInstanceData instance, Map<String, List<CapabilityDefinition>> capabilities) {
- for (Map.Entry<String, List<CapabilityDefinition>> entry : capabilities.entrySet()) {
- for (CapabilityDefinition capability : entry.getValue()) {
- Either<CapabilityData, TitanOperationStatus> capNode = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Capability), capability.getUniqueId(), CapabilityData.class);
- if (capNode.isRight()) {
- log.debug("createCalculatedCapabilitiesForInstance failed to fetch capability node with id " + capability.getUniqueId() + " error " + capNode.right().value());
- return false;
- }
- Map<String, Object> props = new HashMap<>();
- props.put(GraphEdgePropertiesDictionary.NAME.getProperty(), capability.getName());
- if (fillEdgeProperties(instance, props) != true) {
- return false;
- }
-
- Either<GraphRelation, TitanOperationStatus> createRelation = titanGenericDao.createRelation(instance, capNode.left().value(), GraphEdgeLabels.CALCULATED_CAPABILITY, props);
- if (createRelation.isRight()) {
- TitanOperationStatus titanOperationStatus = createRelation.right().value();
- log.debug("Failed to create calculated requirement from component instance {} to requirement {}, error: {}", instance.getUniqueId(), capNode.left().value().getUniqueId(), titanOperationStatus);
- return false;
- }
- log.debug("CALCULATED_CAPABILITY was created from {} to {} with props : {}", capNode.left().value().getUniqueId(), instance.getUniqueId(), props);
- }
- }
- return true;
- }
-
- private boolean fillEdgeProperties(ComponentInstanceData instance, Map<String, Object> props) {
- if (instance.getComponentInstDataDefinition().getOriginType().equals(OriginTypeEnum.VF)) {
- Either<List<ImmutablePair<ComponentInstanceData, GraphEdge>>, TitanOperationStatus> vfci = titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Resource),
- instance.getComponentInstDataDefinition().getComponentUid(), GraphEdgeLabels.RESOURCE_INST, NodeTypeEnum.ResourceInstance, ComponentInstanceData.class);
- if (vfci.isRight()) {
- log.debug("createCalculatedCapabilitiesForInstance failed to fetch instance for resource " + instance.getComponentInstDataDefinition().getComponentUid() + " error " + vfci.right().value());
- return false;
- }
- ImmutablePair<ComponentInstanceData, GraphEdge> immutablePair = vfci.left().value().get(0);
- String vfciId = immutablePair.getLeft().getUniqueId();
- props.put(GraphEdgePropertiesDictionary.OWNER_ID.getProperty(), vfciId);
- props.put(GraphEdgePropertiesDictionary.SOURCE.getProperty(), immutablePair.getLeft().getComponentInstDataDefinition().getComponentUid());
-
- } else {
- props.put(GraphEdgePropertiesDictionary.OWNER_ID.getProperty(), instance.getUniqueId());
- props.put(GraphEdgePropertiesDictionary.SOURCE.getProperty(), instance.getComponentInstDataDefinition().getComponentUid());
- }
- return true;
- }
-
- private boolean createCalculatedRequirementsForInstance(ComponentInstanceData instance, Map<String, List<RequirementDefinition>> requirements) {
- for (Map.Entry<String, List<RequirementDefinition>> entry : requirements.entrySet()) {
- for (RequirementDefinition requirement : entry.getValue()) {
- Either<RequirementData, TitanOperationStatus> reqNode = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Requirement), requirement.getUniqueId(), RequirementData.class);
- if (reqNode.isRight()) {
- log.debug("updateCalculatedEdges failed to fetch requirement node with id " + requirement.getUniqueId() + " error " + reqNode.right().value());
- return false;
- }
- Map<String, Object> props = new HashMap<>();
- props.put(GraphEdgePropertiesDictionary.NAME.getProperty(), requirement.getName());
-
- if (fillEdgeProperties(instance, props) != true) {
- return false;
- }
-
- Either<GraphRelation, TitanOperationStatus> createRelation = titanGenericDao.createRelation(instance, reqNode.left().value(), GraphEdgeLabels.CALCULATED_REQUIREMENT, props);
- if (createRelation.isRight()) {
- TitanOperationStatus titanOperationStatus = createRelation.right().value();
- log.debug("Failed to create calculated requirement from component instance {} to requirement {}, error: {}", instance.getUniqueId(), reqNode.left().value().getUniqueId(), titanOperationStatus);
- return false;
- }
- log.debug("CALCULATED_REQUIREMENT was created from {} to {} with props : {}", reqNode.left().value().getUniqueId(), instance.getUniqueId(), props);
- }
- }
- return true;
- }
-
- private boolean updateRelations() {
- log.debug("update relations and edges STARTED");
- Either<List<RelationshipInstData>, TitanOperationStatus> allRelations = titanGenericDao.getByCriteria(NodeTypeEnum.RelationshipInst, null, RelationshipInstData.class);
- if (allRelations.isRight()) {
- if (allRelations.right().value().equals(TitanOperationStatus.NOT_FOUND)) {
- log.debug("updateRelations : No relations to update. updateRelations ENDED");
- return true;
- }
- log.debug("updateRelations : failed to fetch all relation nodes , error ", allRelations.right().value());
- return false;
- }
- for (RelationshipInstData rel : allRelations.left().value()) {
- // rel.set
- if (rel.getCapabilityOwnerId() != null && rel.getRequirementOwnerId() != null) {
- log.debug("updateRelations : for relation {} all fields alredy fixed -> {}", rel.getUniqueId(), rel);
- continue;
- }
- // update capability parameters
- if (updateCapabiltyFieldsInRelation(rel) != true) {
- return false;
- }
-
- // update requirement parameters and set calculated edge to full
- // filled
- if (updateRequirementFieldsInRelation(rel) != true) {
- return false;
- }
-
- Either<RelationshipInstData, TitanOperationStatus> updateNode = titanGenericDao.updateNode(rel, RelationshipInstData.class);
- if (updateNode.isRight()) {
- log.debug("updateRelations : failed to update relation node with id {} , error {}", rel.getUniqueId(), updateNode.right().value());
- return false;
- }
- log.debug("Relations was updated with values {}", rel);
- }
- log.debug("update relations and edges ENDED");
- return true;
- }
-
- private boolean updateRequirementFieldsInRelation(RelationshipInstData rel) {
- Either<ImmutablePair<ComponentInstanceData, GraphEdge>, TitanOperationStatus> reqInst = titanGenericDao.getParentNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.RelationshipInst), rel.getUniqueId(), GraphEdgeLabels.RELATIONSHIP_INST,
- NodeTypeEnum.ResourceInstance, ComponentInstanceData.class);
- if (reqInst.isRight()) {
- log.debug("updateRelations : failed to fetch capability component instance for relation {}, error {}", rel.getUniqueId(), reqInst.right().value());
- return false;
- }
- ComponentInstanceData requirementInstanceData = reqInst.left().value().getLeft();
- ComponentInstanceDataDefinition reqRI = requirementInstanceData.getComponentInstDataDefinition();
- if (reqRI.getOriginType().equals(OriginTypeEnum.VF)) {
- Either<ImmutablePair<ComponentInstanceData, GraphEdge>, TitanOperationStatus> vfcInstInOrigVf = titanGenericDao.getChildByEdgeCriteria(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Resource), reqRI.getComponentUid(),
- GraphEdgeLabels.RESOURCE_INST, NodeTypeEnum.ResourceInstance, ComponentInstanceData.class, null);
- if (vfcInstInOrigVf.isRight()) {
- log.debug("updateRelations : failed to fetch VFC instance in origin VF with id " + reqRI.getComponentUid() + ", error ", vfcInstInOrigVf.right().value());
- return false;
- }
- rel.setRequirementOwnerId(vfcInstInOrigVf.left().value().getLeft().getUniqueId());
- } else {
- rel.setRequirementOwnerId(reqRI.getUniqueId());
- }
- // get vertex
- Either<TitanVertex, TitanOperationStatus> vertexReqRI = titanGenericDao.getVertexByProperty(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceInstance), requirementInstanceData.getUniqueId());
- if (vertexReqRI.isRight()) {
- log.debug("updateRelations : failed to fetch veterx for instance {}, error {}", requirementInstanceData.getUniqueId(), vertexReqRI.right().value());
- return false;
- }
- String[] splitIds = rel.getUniqueId().split("\\.");
- String reqName = splitIds[splitIds.length - 1];
- Map<String, Object> props = new HashMap<>();
- props.put(GraphEdgePropertiesDictionary.NAME.getProperty(), reqName);
- Either<List<Edge>, TitanOperationStatus> edgesForNode = titanGenericDao.getOutgoingEdgesByCriteria(vertexReqRI.left().value(), GraphEdgeLabels.CALCULATED_REQUIREMENT, props);
- if (edgesForNode.isRight()) {
- log.debug("updateRelations : failed to fetch edges for instance {} error {}", requirementInstanceData.getUniqueId(), edgesForNode.right().value());
- return false;
- }
- Edge edge = edgesForNode.left().value().get(0);
- String reqId = (String) titanGenericDao.getProperty((TitanVertex) edge.inVertex(), GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- rel.setRequirementId(reqId);
-
- // change edge label
- TitanEdge newEdge = (TitanEdge) vertexReqRI.left().value().addEdge(GraphEdgeLabels.CALCULATED_REQUIREMENT_FULLFILLED.getProperty(), edge.inVertex());
- titanGenericDao.setProperties(newEdge, titanGenericDao.getProperties(edge));
- edge.remove();
-
- log.debug("Edge was changed to CALCULATED_REQUIREMENT_FULLFILLED for relation between {} and {}", reqId, requirementInstanceData.getUniqueId());
-
- return true;
- }
-
- public boolean updateCapabiltyFieldsInRelation(RelationshipInstData rel) {
- // update capability parameters
- Either<ImmutablePair<ComponentInstanceData, GraphEdge>, TitanOperationStatus> capInst = titanGenericDao.getChildByEdgeCriteria(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.RelationshipInst), rel.getUniqueId(),
- GraphEdgeLabels.CAPABILITY_NODE, NodeTypeEnum.ResourceInstance, ComponentInstanceData.class, null);
- if (capInst.isRight()) {
- log.debug("updateRelations : failed to fetch capabilty component instance for relation {}, error {}", rel.getUniqueId(), capInst.right().value());
- return false;
- }
- ComponentInstanceData capabiltyInstanceData = capInst.left().value().getLeft();
- ComponentInstanceDataDefinition capRI = capabiltyInstanceData.getComponentInstDataDefinition();
- if (capRI.getOriginType().equals(OriginTypeEnum.VF)) {
- Either<ImmutablePair<ComponentInstanceData, GraphEdge>, TitanOperationStatus> vfcInstInOrigVf = titanGenericDao.getChildByEdgeCriteria(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Resource), capRI.getComponentUid(),
- GraphEdgeLabels.RESOURCE_INST, NodeTypeEnum.ResourceInstance, ComponentInstanceData.class, null);
- if (vfcInstInOrigVf.isRight()) {
- log.debug("updateRelations : failed to fetch VFC instance in origin VF with id " + capRI.getComponentUid() + ", error ", vfcInstInOrigVf.right().value());
- return false;
- }
- rel.setCapabilityOwnerId(vfcInstInOrigVf.left().value().getLeft().getUniqueId());
- } else {
- rel.setCapabilityOwnerId(capRI.getUniqueId());
- }
-
- // get vertex
- Either<TitanVertex, TitanOperationStatus> vertexCapRI = titanGenericDao.getVertexByProperty(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceInstance), capabiltyInstanceData.getUniqueId());
- if (vertexCapRI.isRight()) {
- log.debug("updateRelations : failed to fetch veterx for instance {} , error {}", capabiltyInstanceData.getUniqueId(), vertexCapRI.right().value());
- return false;
- }
- // String[] splitIds = rel.getUniqueId().split("\\.");
- String capName = (String) capInst.left().value().getRight().getProperties().get(GraphEdgePropertiesDictionary.NAME.getProperty());// splitIds[splitIds.length
- // - 1];
- Map<String, Object> props = new HashMap<>();
- props.put(GraphEdgePropertiesDictionary.NAME.getProperty(), capName);
- Either<List<Edge>, TitanOperationStatus> edgesForNode = titanGenericDao.getOutgoingEdgesByCriteria(vertexCapRI.left().value(), GraphEdgeLabels.CALCULATED_CAPABILITY, props);
- if (edgesForNode.isRight()) {
- log.debug("updateRelations : failed to fetch edges for instance {} , error {}", capabiltyInstanceData.getUniqueId(), edgesForNode.right().value());
- return false;
- }
- Edge edge = edgesForNode.left().value().get(0);
- String capId = (String) titanGenericDao.getProperty((TitanVertex) edge.inVertex(), GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- rel.setCapabiltyId(capId);
-
- return true;
- }
-
- private Either<List<String>, StorageOperationStatus> handleVfGroup(ResourceMetadataData metadata) {
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty(), ResourceTypeEnum.VF.name());
- props.put(GraphPropertiesDictionary.NAME.getProperty(), metadata.getMetadataDataDefinition().getName());
-
- List<String> finished = new ArrayList<>();
-
- Either<List<ResourceMetadataData>, TitanOperationStatus> allVFByName = titanGenericDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
- if (allVFByName.isRight()) {
- log.debug("fixDerivedFv failed fetch all VF resources,error {}", allVFByName.right().value());
- return Either.right(StorageOperationStatus.GENERAL_ERROR);
- }
- Set<String> nonDuplicatedId = new HashSet<>();
- String uuid10 = null;
- for (ResourceMetadataData mdata : allVFByName.left().value()) {
- String version = mdata.getMetadataDataDefinition().getVersion();
- if (version.equals("1.0")) {
- uuid10 = mdata.getMetadataDataDefinition().getUUID();
- // break;
- }
- nonDuplicatedId.add((String) mdata.getUniqueId());
- }
- if (uuid10 == null) {
- uuid10 = allVFByName.left().value().get(0).getMetadataDataDefinition().getUUID();
- }
- props.put(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty(), ResourceTypeEnum.VF.name());
- props.put(GraphPropertiesDictionary.UUID.getProperty(), uuid10);
-
- Either<List<ResourceMetadataData>, TitanOperationStatus> allVFByUUID = titanGenericDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
- if (allVFByUUID.isRight()) {
- log.debug("fixDerivedFv failed fetch all VF resources by UUID {} ,error {}", uuid10, allVFByUUID.right().value());
- return Either.right(StorageOperationStatus.GENERAL_ERROR);
- }
- for (ResourceMetadataData mdata : allVFByUUID.left().value()) {
- nonDuplicatedId.add((String) mdata.getUniqueId());
- }
- Either<TitanGraph, TitanOperationStatus> graph = titanGenericDao.getGraph();
- if (graph.isRight()) {
- log.debug("fixDerivedFv failed - No titan graph ,error {}", graph.right().value());
- return Either.right(StorageOperationStatus.GENERAL_ERROR);
- }
- // Map<String, String> derivedMapping = new HashMap<>();
- for (String resourceId : nonDuplicatedId) {
- // StorageOperationStatus handleSingleVfResult =
- // handleSingleVf(finished, derivedMapping, resourceId);
- StorageOperationStatus handleSingleVfResult = handleSingleVf(finished, resourceId);
- if (!handleSingleVfResult.equals(StorageOperationStatus.OK)) {
- log.debug("fixDerivedFv failed - handleSingleVfResult failed for resource {} ,error {}", resourceId, handleSingleVfResult);
- return Either.right(StorageOperationStatus.GENERAL_ERROR);
- }
- }
- return Either.left(finished);
- }
-
- // private StorageOperationStatus handleSingleVf(List<String> finished,
- // Map<String, String> derivedMapping, String resourceId) {
- private StorageOperationStatus handleSingleVf(List<String> finished, String resourceId) {
- Either<TitanVertex, TitanOperationStatus> vertexByProperty = titanGenericDao.getVertexByProperty(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), resourceId);
- if (vertexByProperty.isRight()) {
- log.debug("fixDerivedFv failed to fetch resource by id {} ,error {}", resourceId, vertexByProperty.right().value());
- return StorageOperationStatus.GENERAL_ERROR;
- }
- Vertex vertexR = vertexByProperty.left().value();
- Iterator<Vertex> vertexDIter = vertexR.vertices(Direction.OUT, GraphEdgeLabels.DERIVED_FROM.getProperty());
- if (vertexDIter != null && vertexDIter.hasNext()) {
- // move edges
- // must be only one
- TitanVertex vertexD = (TitanVertex) vertexDIter.next();
- String idDerived = (String) titanGenericDao.getProperty(vertexD, GraphPropertiesDictionary.UNIQUE_ID.getProperty());
-
- // TODO clone resource
-
- // TODO add instance of new resource to VF
-
- // add to vf instance of vfc
- finished.add(resourceId);
- } else {
- log.debug("No derived edges for resource id {}", resourceId);
- }
- return StorageOperationStatus.OK;
- }
-
- private boolean updateComponentInstanceType() {
- log.debug("update component instances type STARTED");
- Either<List<ComponentInstanceData>, TitanOperationStatus> allInstances = titanGenericDao.getByCriteria(NodeTypeEnum.ResourceInstance, null, ComponentInstanceData.class);
- if (allInstances.isRight()) {
- if (allInstances.right().value().equals(TitanOperationStatus.NOT_FOUND)) {
- log.debug("updateComponentInstanceType: no instances ti update ");
- return true;
- }
- log.debug("updateComponentInstanceType failed fetch all resource instances ,error " + allInstances.right().value());
- return false;
- }
-
- List<ComponentInstanceData> listOfInstances = allInstances.left().value();
- for (ComponentInstanceData instance : listOfInstances) {
- String originId = instance.getComponentInstDataDefinition().getComponentUid();
- Either<ComponentMetadataData, TitanOperationStatus> nodeResource = titanGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Resource), originId, ComponentMetadataData.class);
- if (nodeResource.isRight()) {
- log.debug("updateComponentInstanceType failed to fetch origin resource with id {} error {}", originId, nodeResource.right().value());
- return false;
- }
- ResourceTypeEnum resourceType = ((ResourceMetadataDataDefinition) nodeResource.left().value().getMetadataDataDefinition()).getResourceType();
- if (resourceType == null) {
- log.debug("updateComponentInstanceType failed, no resource type for origin resource with id " + originId);
- return false;
- }
- OriginTypeEnum originType;
- switch (resourceType) {
- case VF:
- originType = OriginTypeEnum.VF;
- break;
- case VFC:
- originType = OriginTypeEnum.VFC;
- break;
- case VL:
- originType = OriginTypeEnum.VL;
- break;
- case CP:
- originType = OriginTypeEnum.CP;
- break;
- case CVFC:
- originType = OriginTypeEnum.CVFC;
- break;
- default:
- log.debug("updateComponentInstanceType failed, no supported resource type {} for origin resource with id {}", resourceType, originId);
- return false;
- }
- instance.getComponentInstDataDefinition().setOriginType(originType);
-
- Either<ComponentInstanceData, TitanOperationStatus> updateNode = titanGenericDao.updateNode(instance, ComponentInstanceData.class);
- if (updateNode.isRight()) {
- log.debug("updateComponentInstanceType failed, failed to update component instance node with id " + instance.getUniqueId() + " error " + updateNode.right().value());
- return false;
- }
- log.debug("For instance with id {} the origin type was detected as {}", instance.getUniqueId(), originType);
- }
- log.debug("update component instances type ENDED");
- return true;
- }
-
- private boolean addResourceCounterToResources() {
-
- Either<List<ResourceMetadataData>, TitanOperationStatus> allResources = titanGenericDao.getByCriteria(NodeTypeEnum.Resource, null, ResourceMetadataData.class);
- if (allResources.isRight()) {
- if (allResources.right().value().equals(TitanOperationStatus.NOT_FOUND)) {
- log.debug("addResourceCounterToResources - no resources");
- return true;
- }
- log.debug("addResourceCounterToResources failed fetch all resources,error {}", allResources.right().value());
- return false;
- }
- for (ResourceMetadataData resource : allResources.left().value()) {
- Either<TitanVertex, TitanOperationStatus> vertexByProperty = titanGenericDao.getVertexByProperty(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Resource), resource.getUniqueId());
- if (vertexByProperty.isRight()) {
- log.error("failed to add instanceCounter to VF {} . error is: {}", resource.getUniqueId(), vertexByProperty.right().value().name());
- return false;
- }
- Vertex vfVertex = vertexByProperty.left().value();
- if (!vfVertex.property(GraphPropertiesDictionary.INSTANCE_COUNTER.getProperty()).isPresent()) {
- vfVertex.property(GraphPropertiesDictionary.INSTANCE_COUNTER.getProperty(), 0);
- }
- }
- return true;
- }
-
- private boolean fixDerivedVf() {
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty(), ResourceTypeEnum.VF.name());
- Either<List<ResourceMetadataData>, TitanOperationStatus> allVF = titanGenericDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
- if (allVF.isRight()) {
- if (allVF.right().value().equals(TitanOperationStatus.NOT_FOUND)) {
- log.debug("fixDerivedVf - no VFs");
- return true;
- }
- log.debug("fixDerivedFv failed fetch all VF resources,error {}", allVF.right().value());
- return false;
- }
-
- Map<String, String> vfUuidToVfcUuid = new HashMap<String, String>();
- for (ResourceMetadataData metadata : allVF.left().value()) {
- Either<Resource, StorageOperationStatus> eitherResource = resourceOperation.getResource(metadata.getMetadataDataDefinition().getUniqueId(), true);
- if (eitherResource.isRight()) {
- log.error("failed to migrate VF {} from version 1602 to version 1604. error is: {}", metadata.getMetadataDataDefinition().getUniqueId(), eitherResource.right().value().name());
- return false;
- }
- Resource vfResource = eitherResource.left().value();
- if (vfResource.getDerivedFrom() == null || vfResource.getDerivedFrom().isEmpty()) {
- continue;
- }
- Boolean isVfDeleted = vfResource.getIsDeleted();
- String vfUUID = vfResource.getUUID();
- String vfcUUID = vfUuidToVfcUuid.getOrDefault(vfUUID, null);
- if (vfcUUID == null) {
- vfcUUID = UUID.randomUUID().toString();
- vfUuidToVfcUuid.put(vfUUID, vfcUUID);
- }
-
- // handle lifecycle
- String vfUniqueId = vfResource.getUniqueId();
- LifecycleStateEnum vfcTargetState = vfResource.getLifecycleState();
- if (vfcTargetState.equals(LifecycleStateEnum.READY_FOR_CERTIFICATION) || vfcTargetState.equals(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS)) {
- User user = new User();
- user.setUserId(vfResource.getLastUpdaterUserId());
- Either<? extends Component, StorageOperationStatus> checkinComponent = lifecycleOperaion.checkinComponent(NodeTypeEnum.Resource, vfResource, user, user, true);
- if (checkinComponent.isRight()) {
- log.error("failed to checkin VF {}. error={}", vfUniqueId, checkinComponent.right().value().name());
- return false;
- }
- } else if (vfcTargetState.equals(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT)) {
- vfcTargetState = LifecycleStateEnum.NOT_CERTIFIED_CHECKIN;
- }
-
- // delete VF Properties
- List<PropertyDefinition> properties = vfResource.getProperties();
- if (properties != null && !properties.isEmpty()) {
- Either<Map<String, PropertyDefinition>, StorageOperationStatus> deleteAllProperties = propertyOperation.deleteAllPropertiesAssociatedToNode(NodeTypeEnum.Resource, vfUniqueId);
- if (deleteAllProperties.isRight() && !deleteAllProperties.right().value().equals(StorageOperationStatus.NOT_FOUND) && !deleteAllProperties.right().value().equals(StorageOperationStatus.OK)) {
- log.error("failed to delete properties of VF {} . error is: {}", metadata.getMetadataDataDefinition().getUniqueId(), deleteAllProperties.right().value().name());
- return false;
- }
- }
- // delete VF Additional Info
- List<AdditionalInformationDefinition> additionalInformation = vfResource.getAdditionalInformation();
- if (additionalInformation != null && !additionalInformation.isEmpty()) {
- Either<AdditionalInformationDefinition, StorageOperationStatus> deleteAllAdditionalInformationParameters = additionalInformationOperation.deleteAllAdditionalInformationParameters(NodeTypeEnum.Resource, vfUniqueId, true);
- if (deleteAllAdditionalInformationParameters.isRight() && !deleteAllAdditionalInformationParameters.right().value().equals(StorageOperationStatus.OK)
- && !deleteAllAdditionalInformationParameters.right().value().equals(StorageOperationStatus.NOT_FOUND)) {
- log.error("failed to delete properties of VF {} . error is: {}", metadata.getMetadataDataDefinition().getUniqueId(), deleteAllAdditionalInformationParameters.right().value().name());
- return false;
- }
- }
- // delete VF derivedFrom
- GraphRelation derivedFromRelation = new GraphRelation(GraphEdgeLabels.DERIVED_FROM.getProperty());
- derivedFromRelation.setFrom(new RelationEndPoint(NodeTypeEnum.Resource, UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Resource), vfUniqueId));
- Either<GraphRelation, TitanOperationStatus> deleteDerivedFromRelation = titanGenericDao.deleteOutgoingRelation(derivedFromRelation);
- if (deleteDerivedFromRelation.isRight()) {
- log.error("failed to delete derivedFrom relation of VF {} . error is: {}", metadata.getMetadataDataDefinition().getUniqueId(), deleteDerivedFromRelation.right().value().name());
- return false;
- }
-
- // create VFC
- Either<Resource, StorageOperationStatus> createVFC = createVFC(metadata, vfResource, vfcUUID, vfcTargetState);
- if (createVFC.isRight()) {
- log.error("failed to split VF {} to VFC. error is: {}", metadata.getMetadataDataDefinition().getUniqueId(), createVFC.right().value().name());
- return false;
- }
- Resource vfcResource = createVFC.left().value();
- if (!createVfcInstanceOnVf(vfcResource, vfUniqueId)) {
- return false;
- }
- // update VFC to deleted if required
- if (isVfDeleted != null && isVfDeleted) {
- Either<Component, StorageOperationStatus> markResourceToDelete = resourceOperation.markComponentToDelete(vfcResource, true);
- if (markResourceToDelete.isRight()) {
- log.error("failed to mark isDeleted on VFC {} . error is: {}", vfcResource.getUniqueId(), markResourceToDelete.right().value().name());
- return false;
- }
- }
-
- }
- return true;
- }
-
- private Either<Resource, StorageOperationStatus> createVFC(ResourceMetadataData metadata, Resource vfcResource, String uuid, LifecycleStateEnum vfcTargetState) {
-
- Boolean highestVersion = vfcResource.isHighestVersion();
- // Resource vfcResource = new Resource((ResourceMetadataDefinition)
- // vfResource.getComponentMetadataDefinition());
- // String componentName = vfcResource.getName()+"VFC";
- // vfcResource.setName(componentName);
- // vfcResource.setNormalizedName(ValidationUtils.normaliseComponentName(componentName));
- // vfcResource.setSystemName(ValidationUtils.convertToSystemName(componentName));
- vfcResource.setUniqueId(null);
- vfcResource.setUUID(uuid);
- vfcResource.setAllVersions(null);
- vfcResource.setArtifacts(null);
- vfcResource.setDeploymentArtifacts(null);
- vfcResource.setComponentInstances(null);
- vfcResource.setComponentInstancesProperties(null);
- vfcResource.setComponentInstancesRelations(null);
- vfcResource.setResourceType(ResourceTypeEnum.VFC);
- vfcResource.setIsDeleted(false);
-
- vfcResource.setLifecycleState(vfcTargetState);
- // vfcResource.setDerivedFrom(vfResource.getDerivedFrom());
- // vfcResource.setProperties(vfResource.getProperties());
- // vfcResource.setAdditionalInformation(vfResource.getAdditionalInformation());
- // vfcResource.setCategories(vfResource.getCategories());
- // vfcResource.setTags(vfResource.getTags());
-
- Either<Resource, StorageOperationStatus> createResource = resourceOperation.createResource(vfcResource, true);
- if (createResource.isRight()) {
- return createResource;
- }
- Resource afterCreateResource = createResource.left().value();
- Either<TitanVertex, TitanOperationStatus> vertexByProperty = titanGenericDao.getVertexByProperty(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Resource), afterCreateResource.getUniqueId());
- if (vertexByProperty.isRight()) {
- return createResource;
- }
- Vertex newVfcVertex = vertexByProperty.left().value();
- newVfcVertex.property(GraphPropertiesDictionary.UUID.getProperty(), uuid);
- if (!highestVersion) {
- newVfcVertex.property(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), false);
- }
- return createResource;
- }
-
- private boolean createVfcInstanceOnVf(Resource vfcResource, String vfUniqueId) {
- // create VFC instance on VF
- ComponentInstance componentInstance = new ComponentInstance();
- componentInstance.setComponentUid(vfcResource.getUniqueId());
- componentInstance.setPosX("550");
- componentInstance.setPosY("300");
- componentInstance.setName(vfcResource.getName());
- componentInstance.setIcon(vfcResource.getIcon());
- componentInstance.setToscaComponentName(vfcResource.getToscaResourceName());
- Either<String, Boolean> handleNameLogic = handleNameLogic(componentInstance, vfUniqueId, vfcResource.getName());
- if (handleNameLogic.isRight()) {
- log.error("failed to create logical name for vfc instance");
- return false;
- }
- Either<ComponentInstance, StorageOperationStatus> createComponentInstance = componentInstanceOperaion.createComponentInstance(vfUniqueId, NodeTypeEnum.Resource, handleNameLogic.left().value(), componentInstance, NodeTypeEnum.Resource, true);
-
- if (createComponentInstance.isRight()) {
- log.error("failed to create vfc instance on vf {}. error: {}", vfUniqueId, createComponentInstance.right().value().name());
- return false;
- }
- return true;
- }
-
- private Either<String, Boolean> handleNameLogic(ComponentInstance componentInstance, String containerComponentId, String resourceName) {
-
- Either<Integer, StorageOperationStatus> componentInNumberStatus = resourceOperation.increaseAndGetComponentInstanceCounter(containerComponentId, true);
-
- if (componentInNumberStatus.isRight()) {
- log.debug("Failed to get component instance number for container component {} ", containerComponentId);
- return Either.right(false);
- }
- String resourceInNumber = componentInNumberStatus.left().value().toString();
- componentInstance.setComponentName(resourceName);
- componentInstance.setName(resourceName);
- String logicalName = componentInstanceOperaion.createComponentInstLogicalName(resourceInNumber, resourceName);
-
- Boolean eitherValidation = validateComponentInstanceName(logicalName, componentInstance, true);
- if (!eitherValidation) {
- return Either.right(false);
- }
-
- return Either.left(resourceInNumber);
- }
-
- private Boolean validateComponentInstanceName(String resourceInstanceName, ComponentInstance resourceInstance, boolean isCreate) {
-
- if (!ValidationUtils.validateStringNotEmpty(resourceInstanceName)) {
- return false;
- }
- resourceInstance.setNormalizedName(ValidationUtils.normalizeComponentInstanceName(resourceInstanceName));
- if (!isCreate) {
- if (!ValidationUtils.validateResourceInstanceNameLength(resourceInstanceName)) {
- return false;
- }
- if (!ValidationUtils.validateResourceInstanceName(resourceInstanceName)) {
- return false;
- }
- }
-
- return true;
-
- }
-
- public boolean migrate1604to1607(String appConfigDir) {
- log.debug("Started the migration procedure from version 1604 to version 1607 ...");
- log.debug("Getting all resources with resources");
- boolean result = false;
- Either<Boolean, StorageOperationStatus> resourceEither = null;
- try {
- Either<List<ResourceMetadataData>, TitanOperationStatus> allResources = titanGenericDao.getByCriteria(NodeTypeEnum.Resource, null, ResourceMetadataData.class);
- if (allResources.isRight()) {
- log.error("Couldn't get resources from DB, error: {}", allResources.right().value());
- result = false;
- return result;
- }
- List<ResourceMetadataData> resourcesList = allResources.left().value();
- if (resourcesList == null) {
- log.error("Couldn't get resources from DB, no resources found");
- result = false;
- return result;
- }
- log.debug("Found {} resources", resourcesList.size());
- for (ResourceMetadataData resource : resourcesList) {
- String resourceName = resource.getMetadataDataDefinition().getName();
- log.debug("Checking resource {}", resourceName);
- if (isNormative(resourceName)) {
- resourceEither = changeNormativeTypeName(resource);
- if (resourceEither.isRight()) {
- log.error("DB error during name changing");
- result = false;
- return result;
- }
- }
- if (((ResourceMetadataDataDefinition) resource.getMetadataDataDefinition()).getResourceType().name().equals("VF")) {
- resourceEither = setVfToscaResourceName(resource);
- if (resourceEither.isRight()) {
- log.error("DB error during tosca resource name setting");
- result = false;
- return result;
- }
- }
- }
- result = addInvariantUUIDs(appConfigDir);
- } finally {
- if (!result) {
- titanGenericDao.rollback();
- log.debug("**********************************************");
- log.debug("The migration procedure from version 1604 to version 1607 FAILED!!");
- log.debug("**********************************************");
- } else {
- titanGenericDao.commit();
- log.debug("**********************************************");
- log.debug("The migration procedure from version 1604 to version 1607 ended successfully!");
- log.debug("**********************************************");
- }
- }
-
- return result;
- }
-
- private boolean addInvariantUUIDs(String appConfigDir) {
- log.debug("Started adding of InvariantUUID ...");
- log.debug("Getting all resources with highest version");
-
- Map<String, Object> props = new HashMap<>();
- props.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true);
-
- List<ComponentMetadataData> fullComponentList = new ArrayList<ComponentMetadataData>();
-
- // getting resources
- Either<List<ResourceMetadataData>, TitanOperationStatus> allHighestVersionResources = titanGenericDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
- if (allHighestVersionResources.isRight()) {
- log.error("Couldn't get resources with highest version from DB, error: {}", allHighestVersionResources.right().value());
- return false;
- }
- List<ResourceMetadataData> allHighestVersionResourcesAL = allHighestVersionResources.left().value();
- if (allHighestVersionResourcesAL == null) {
- log.error("Couldn't get resources with highest version from DB, no resources found");
- return false;
- }
- log.debug("Found {} resources", allHighestVersionResourcesAL.size());
- fullComponentList.addAll(allHighestVersionResourcesAL);
-
- // getting services
- Either<List<ServiceMetadataData>, TitanOperationStatus> allHighestVersionServices = titanGenericDao.getByCriteria(NodeTypeEnum.Service, props, ServiceMetadataData.class);
- if (allHighestVersionServices.isRight()) {
- log.error("Couldn't get services with highest version from DB, error: {}", allHighestVersionServices.right().value());
- return false;
- }
- List<ServiceMetadataData> allHighestVersionServicesAL = allHighestVersionServices.left().value();
- if (allHighestVersionServicesAL == null) {
- log.error("Couldn't get services with highest version from DB, no services found");
- return false;
- }
- log.debug("Found {} services", allHighestVersionServicesAL.size());
- fullComponentList.addAll(allHighestVersionServicesAL);
-
- List<ComponentMetadataData> reducedComponentsAL = reduceHighestVersionResourcesList(fullComponentList);
-
- // getting products
- Either<List<ProductMetadataData>, TitanOperationStatus> allHighestVersionProducts = titanGenericDao.getByCriteria(NodeTypeEnum.Product, props, ProductMetadataData.class);
- if (allHighestVersionProducts.isRight()) {
- log.error("Couldn't get products with highest version from DB, error: {}", allHighestVersionProducts.right().value());
- return false;
- }
- List<ProductMetadataData> allHighestVersionProductsAL = allHighestVersionProducts.left().value();
- if (allHighestVersionProductsAL == null) {
- log.error("Couldn't get products with highest version from DB, no products found");
- return false;
- }
- log.debug("Found {} products", allHighestVersionProductsAL.size());
-
- List<ComponentMetadataData> fullProductList = new ArrayList<ComponentMetadataData>();
- fullProductList.addAll(allHighestVersionProductsAL);
- List<ComponentMetadataData> reducedProductAL = reduceHighestVersionResourcesList(fullProductList);
-
- for (ComponentMetadataData product : reducedProductAL) {
- if (!setProductInvariantUUIDIfExists((ProductMetadataData) product)) {
- return false;
- }
- }
- reducedComponentsAL.addAll(reducedProductAL);
-
- log.debug("Reduced list of Highest Version Components contains {} components", reducedComponentsAL.size());
- for (ComponentMetadataData componentMetaData : reducedComponentsAL) {
-
- String invariantUUID = componentMetaData.getMetadataDataDefinition().getInvariantUUID();
- log.debug("old invariantUUID {}", invariantUUID);
- if (invariantUUID == null || invariantUUID.isEmpty()) {
- invariantUUID = UniqueIdBuilder.buildInvariantUUID();
- componentMetaData.getMetadataDataDefinition().setInvariantUUID(invariantUUID);
- }
- log.debug("new invariantUUID {}", componentMetaData.getMetadataDataDefinition().getInvariantUUID());
- Either<ComponentMetadataData, TitanOperationStatus> updateNode = titanGenericDao.updateNode(componentMetaData, ComponentMetadataData.class);
- if (updateNode.isRight()) {
- log.error("DB error during while updating component {}, error: {}", componentMetaData.getMetadataDataDefinition().getName(), updateNode.right().value());
- return false;
- }
- log.debug("updated invariantUUID {}", updateNode.left().value().getMetadataDataDefinition().getInvariantUUID());
- if (!isOnlyVersion(componentMetaData)) {
- ComponentOperation componentOperation = null;
- switch (NodeTypeEnum.getByName(componentMetaData.getLabel())) {
- case Resource:
- componentOperation = resourceOperation;
- break;
- case Service:
- componentOperation = serviceOperation;
- break;
- case Product:
- componentOperation = productOperation;
- break;
- default:
- break;
- }
- Either<Component, StorageOperationStatus> getComponentResult = componentOperation.getComponent((String) componentMetaData.getUniqueId(), true);
- if (getComponentResult.isRight()) {
- log.error("DB error during while getting component with uniqueID {}, error: {}", componentMetaData.getUniqueId(), getComponentResult.right().value());
- return false;
- }
- Component component = getComponentResult.left().value();
- if (component == null) {
- log.error("The component received from DB is empty");
- return false;
- }
-
- Map<String, String> allVersions = component.getAllVersions();
- log.debug("found {} versions for component {}", allVersions.size(), component.getName());
- Either<Boolean, StorageOperationStatus> resEither = updateAllVersions(allVersions, invariantUUID);
- if (resEither.isRight()) {
- log.error("DB error during invariantUUID adding");
- return false;
- }
- }
- }
- return true;
- }
-
- private boolean isOnlyVersion(ComponentMetadataData componentMetaData) {
- String version = componentMetaData.getMetadataDataDefinition().getVersion();
- if (version.equals("0.1"))
- return true;
- return false;
- }
-
- private boolean setProductInvariantUUIDIfExists(ProductMetadataData product) {
- Either<TitanVertex, TitanOperationStatus> getVertexRes = titanGenericDao.getVertexByProperty(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), product.getUniqueId());
- if (getVertexRes.isRight()) {
- log.error("DB error during retrieving product vertex {}", product.getMetadataDataDefinition().getName());
- return false;
- }
- Vertex productVertex = getVertexRes.left().value();
- String invariantUUID = productVertex.value(GraphPropertiesDictionary.CONSTANT_UUID.getProperty());
- if (invariantUUID != null && !invariantUUID.isEmpty()) {
- product.getMetadataDataDefinition().setInvariantUUID(invariantUUID);
- }
- return true;
- }
-
- private Either<Boolean, StorageOperationStatus> updateAllVersions(Map<String, String> allVersions, String invariantUUID) {
-
- if (allVersions != null) {
- for (String uniqueID : allVersions.values()) {
- Either<ComponentMetadataData, TitanOperationStatus> getNodeResult = titanGenericDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), uniqueID, ComponentMetadataData.class);
- if (getNodeResult.isRight()) {
- log.error("DB error during while getting component with uniqueID {}, error: {}", uniqueID, getNodeResult.right().value());
- return Either.right(StorageOperationStatus.GENERAL_ERROR);
- }
- ComponentMetadataData component = getNodeResult.left().value();
- component.getMetadataDataDefinition().setInvariantUUID(invariantUUID);
- Either<ComponentMetadataData, TitanOperationStatus> updateNodeResult = titanGenericDao.updateNode(component, ComponentMetadataData.class);
- log.debug("updated child invariantUUID {}", updateNodeResult.left().value().getMetadataDataDefinition().getInvariantUUID());
- if (updateNodeResult.isRight()) {
- log.error("DB error during while updating component {}, error: {}", component.getMetadataDataDefinition().getName(), updateNodeResult.right().value());
- return Either.right(StorageOperationStatus.GENERAL_ERROR);
- }
- }
- }
- return Either.left(true);
- }
-
- private List<ComponentMetadataData> reduceHighestVersionResourcesList(List<ComponentMetadataData> allHighestVersionResources) {
- List<ComponentMetadataData> resultList = null;
- Map<String, ComponentMetadataData> resultHM = new HashMap<String, ComponentMetadataData>();
- for (ComponentMetadataData resource : allHighestVersionResources) {
- if (resource.getMetadataDataDefinition().getInvariantUUID() != null && !resource.getMetadataDataDefinition().getInvariantUUID().isEmpty()) {
- log.debug("invariantUUID {} ", resource.getMetadataDataDefinition().getInvariantUUID());
- continue;
- }
- String curUUID = resource.getMetadataDataDefinition().getUUID();
- if (resultHM.containsKey(curUUID)) {
- int isHighest = resultHM.get(curUUID).getMetadataDataDefinition().getVersion().compareTo(resource.getMetadataDataDefinition().getVersion());
- if (isHighest > 0) {
- log.debug("version {} is great than {} ", resultHM.get(curUUID).getMetadataDataDefinition().getVersion(), resource.getMetadataDataDefinition().getVersion());
- continue;
- }
- }
- resultHM.put(curUUID, resource);
- }
- resultList = new ArrayList<ComponentMetadataData>(resultHM.values());
- return resultList;
- }
-
- private boolean isNormative(String resourceName) {
- for (int i = 0; i < NORMATIVE_OLD_NAMES.length; ++i) {
- if (NORMATIVE_OLD_NAMES[i].equals(resourceName))
- return true;
- }
- return false;
- }
-
- private Either<Boolean, StorageOperationStatus> changeNormativeTypeName(ResourceMetadataData resource) {
-
- String resourceName = resource.getMetadataDataDefinition().getName();
-
- if (resourceName != null && !resourceName.isEmpty()) {
- log.debug("Found normative type to change - {}", resourceName);
- String oldName = resourceName;
- String[] splitedName = resourceName.split("\\.");
- String newName = splitedName[splitedName.length - 1];
- String newSystemName = ValidationUtils.convertToSystemName(newName);
- String newNormalizedName = ValidationUtils.normaliseComponentName(newName);
- log.debug("Setting name to be {}", newName);
-
- resource.getMetadataDataDefinition().setName(newName);
- log.debug("Setting system name to be {}", newSystemName);
- resource.getMetadataDataDefinition().setSystemName(newSystemName);
- log.debug("Setting normalized name to be {}", newNormalizedName);
- resource.getMetadataDataDefinition().setNormalizedName(newNormalizedName);
- log.debug("Updating tag in metadata to be {}", newName);
- resource.getMetadataDataDefinition().getTags().remove(oldName);
- resource.getMetadataDataDefinition().getTags().add(newName);
-
- log.debug("Creating tag node with name {}", newName);
- TagData tagData = new TagData();
- tagData.setName(newName);
- Either<TagData, TitanOperationStatus> createNode = titanGenericDao.createNode(tagData, TagData.class);
- if (createNode.isRight()) {
- log.error("Error while creating tag node {}, error: {}.", newName, createNode.right().value());
- return Either.right(StorageOperationStatus.GENERAL_ERROR);
- }
-
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanGenericDao.updateNode(resource, ResourceMetadataData.class);
- if (updateNode.isRight()) {
- log.error("DB error during while updating normative type {}, error: {}", resource.getMetadataDataDefinition().getName(), updateNode.right().value());
- return Either.right(StorageOperationStatus.GENERAL_ERROR);
- }
- log.debug("Normative type {} was successfully updated", resource.getMetadataDataDefinition().getName());
- return Either.left(true);
- }
-
- return Either.left(false);
- }
-
- private Either<Boolean, StorageOperationStatus> generateAndSetToscaResourceName(ResourceMetadataData resource, String toscaResourceName) {
- if (toscaResourceName == null) {
- toscaResourceName = CommonBeUtils.generateToscaResourceName(((ResourceMetadataDataDefinition) resource.getMetadataDataDefinition()).getResourceType().name(), resource.getMetadataDataDefinition().getSystemName());
- }
- Either<Boolean, StorageOperationStatus> validateToscaResourceNameExists = resourceOperation.validateToscaResourceNameExists(toscaResourceName);
- if (validateToscaResourceNameExists.isRight()) {
- StorageOperationStatus storageOperationStatus = validateToscaResourceNameExists.right().value();
- log.error("Couldn't validate toscaResourceName uniqueness - error: {}", storageOperationStatus);
- return Either.right(storageOperationStatus);
- }
- if (validateToscaResourceNameExists.left().value()) {
- log.debug("Setting tosca resource name to be {}", toscaResourceName);
- ((ResourceMetadataDataDefinition) resource.getMetadataDataDefinition()).setToscaResourceName(toscaResourceName);
- return Either.left(true);
- } else {
- // As agreed with Renana - cannot be fixed automatically
- log.warn("toscaResourceName {} is not unique! Cannot set it. Continuing...");
- return Either.left(false);
- }
- }
-
- public boolean testRemoveHeatPlaceHolders(String appConfigDir) {
-
- if (!AllowMultipleHeats.removeAndUpdateHeatPlaceHolders(titanGenericDao, log, false)) {
- log.error("Failed to update heat place holders");
- return false;
- }
- return true;
- }
-
- private Either<Boolean, StorageOperationStatus> setVfToscaResourceName(ResourceMetadataData resource) {
- String resourceName = resource.getMetadataDataDefinition().getName();
- String resourceType = ((ResourceMetadataDataDefinition) resource.getMetadataDataDefinition()).getResourceType().name();
- String toscaResourceName = CommonBeUtils.generateToscaResourceName(resourceType, resource.getMetadataDataDefinition().getSystemName());
- log.debug("Setting tosca resource name {} to VF {}", toscaResourceName, resourceName);
- ((ResourceMetadataDataDefinition) resource.getMetadataDataDefinition()).setToscaResourceName(toscaResourceName);
-
- Either<ResourceMetadataData, TitanOperationStatus> updateNode = titanGenericDao.updateNode(resource, ResourceMetadataData.class);
- if (updateNode.isRight()) {
- log.error("DB error during while updating VF tosca resource name {}, error: {}", resource.getMetadataDataDefinition().getName(), updateNode.right().value());
- return Either.right(StorageOperationStatus.GENERAL_ERROR);
- }
- log.debug("Tosca resource name of VF {} was successfully updated", resource.getMetadataDataDefinition().getName());
- return Either.left(true);
- }
-
- public boolean testAddGroupUuids(String appConfigDir) {
-
- if (!AddGroupUuid.addGroupUuids(titanGenericDao, log, false)) {
- log.error("Failed to update group UUIDs");
- return false;
- }
- return true;
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/VfcNamingAlignment.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/VfcNamingAlignment.java
deleted file mode 100644
index e488017679..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1604/VfcNamingAlignment.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1604;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.ResourceOperation;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-import org.openecomp.sdc.be.resources.data.TagData;
-import org.openecomp.sdc.be.utils.CommonBeUtils;
-import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.util.ValidationUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import fj.data.Either;
-
-public class VfcNamingAlignment {
-
- private static Logger log = LoggerFactory.getLogger(VfcNamingAlignment.class.getName());
-
- @Autowired
- protected TitanGenericDao titanGenericDao;
- @Autowired
- protected ResourceOperation resourceOperation;
-
- public boolean alignVfcNames1604(String appConfigDir) {
- log.debug("Started alignVfcNames1604 procedure..");
- log.debug("Getting all resources with resourceType = VFC/CP/VL");
- boolean result = false;
- try {
- Map<String, Object> notProperties = new HashMap<>();
- notProperties.put(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty(), ResourceTypeEnum.VF.name());
- Either<List<ResourceMetadataData>, TitanOperationStatus> allVfcResources = titanGenericDao
- .getByCriteria(NodeTypeEnum.Resource, null, notProperties, ResourceMetadataData.class);
- if (allVfcResources.isRight()) {
- log.error("Couldn't get VFC resources from DB, error: {}", allVfcResources.right().value());
- result = false;
- return result;
- }
- List<ResourceMetadataData> vfcList = allVfcResources.left().value();
- if (vfcList == null) {
- log.error("Couldn't get VFC/CP/VL resources from DB, no resources found");
- result = false;
- return result;
- }
- log.debug("Found {} VFC/CP/VL resources", vfcList.size());
- for (ResourceMetadataData vfc : vfcList) {
- log.debug("Checking resource {}", vfc.getMetadataDataDefinition().getName());
- boolean wasChanged = false;
-
- Either<Boolean, StorageOperationStatus> vfcEither = fixToscaNameEmpty(vfc);
- if (vfcEither.isRight()) {
- log.error("DB error during checkIsToscaNameEmpty - exiting...");
- result = false;
- return result;
- }
- wasChanged = wasChanged | vfcEither.left().value();
-
- vfcEither = fixVfcToscaNameHasVf(vfc);
- if (vfcEither.isRight()) {
- log.error("DB error during checkIsVfcToscaNameHasVf - exiting...");
- result = false;
- return result;
- }
- wasChanged = wasChanged | vfcEither.left().value();
-
- if (wasChanged) {
- Either<ResourceMetadataData, TitanOperationStatus> updateVfc = updateVfc(vfc);
- if (updateVfc.isRight()) {
- log.error("DB error during while updating resource {}, error: {} - exiting...",
- vfc.getMetadataDataDefinition().getName(), updateVfc.right().value());
- result = false;
- return result;
- }
- log.debug("Resource {} was successfully updated", vfc.getMetadataDataDefinition().getName());
- }
-
- }
- result = true;
- } finally {
- if (!result) {
- titanGenericDao.rollback();
- log.debug("**********************************************");
- log.debug("alignVfcNames1604 procedure FAILED!!");
- log.debug("**********************************************");
- } else {
- titanGenericDao.commit();
- log.debug("**********************************************");
- log.debug("alignVfcNames1604 procedure ended successfully!");
- log.debug("**********************************************");
- }
- }
-
- return result;
- }
-
- private Either<ResourceMetadataData, TitanOperationStatus> updateVfc(ResourceMetadataData vfc) {
- return titanGenericDao.updateNode(vfc, ResourceMetadataData.class);
- }
-
- private Either<Boolean, StorageOperationStatus> fixToscaNameEmpty(ResourceMetadataData vfc) {
- String toscaResourceName = ((ResourceMetadataDataDefinition) vfc.getMetadataDataDefinition())
- .getToscaResourceName();
- if (toscaResourceName == null || toscaResourceName.trim().equals(Constants.EMPTY_STRING)) {
- log.debug("Tosca resource name is empty - setting new tosca name...");
- Either<Boolean, StorageOperationStatus> generateAndSetToscaResourceName = generateAndSetToscaResourceName(
- vfc, null);
- if (generateAndSetToscaResourceName.isRight()) {
- return Either.right(generateAndSetToscaResourceName.right().value());
- }
- return Either.left(true);
- }
- return Either.left(false);
- }
-
- private Either<Boolean, StorageOperationStatus> fixVfcToscaNameHasVf(ResourceMetadataData vfc) {
- String toscaResourceName = ((ResourceMetadataDataDefinition) vfc.getMetadataDataDefinition())
- .getToscaResourceName();
- if (toscaResourceName.contains(".vf.")) {
- log.debug("Tosca resource name {} is VF-style - setting new tosca name...", toscaResourceName);
- Either<Boolean, StorageOperationStatus> generateAndSetToscaResourceName = generateAndSetToscaResourceName(
- vfc, null);
- if (generateAndSetToscaResourceName.isRight()) {
- return Either.right(generateAndSetToscaResourceName.right().value());
- }
- return Either.left(true);
- }
- return Either.left(false);
- }
-
- private Either<Boolean, StorageOperationStatus> generateAndSetToscaResourceName(ResourceMetadataData vfc,
- String toscaResourceName) {
- if (toscaResourceName == null) {
- toscaResourceName = CommonBeUtils.generateToscaResourceName(
- ((ResourceMetadataDataDefinition) vfc.getMetadataDataDefinition()).getResourceType().name(),
- vfc.getMetadataDataDefinition().getSystemName());
- }
- Either<Boolean, StorageOperationStatus> validateToscaResourceNameExists = resourceOperation
- .validateToscaResourceNameExists(toscaResourceName);
- if (validateToscaResourceNameExists.isRight()) {
- StorageOperationStatus storageOperationStatus = validateToscaResourceNameExists.right().value();
- log.error("Couldn't validate toscaResourceName uniqueness - error: {}", storageOperationStatus);
- return Either.right(storageOperationStatus);
- }
- if (validateToscaResourceNameExists.left().value()) {
- log.debug("Setting tosca resource name to be {}", toscaResourceName);
- ((ResourceMetadataDataDefinition) vfc.getMetadataDataDefinition()).setToscaResourceName(toscaResourceName);
- return Either.left(true);
- } else {
- // As agreed with Renana - cannot be fixed automatically
- log.warn("toscaResourceName {} is not unique! Cannot set it. Continuing...");
- return Either.left(false);
- }
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1607/CsarMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1607/CsarMigration.java
deleted file mode 100644
index b141eecb87..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1607/CsarMigration.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1607;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.thinkaurelius.titan.core.TitanVertex;
-
-import fj.data.Either;
-
-public class CsarMigration {
- private static Logger log = LoggerFactory.getLogger(CsarMigration.class.getName());
-
- @Autowired
- protected TitanGenericDao titanGenericDao;
-
- public boolean removeCsarResources() {
- Map<String, Object> props = new HashMap<>();
- props.put(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty(), ResourceTypeEnum.VF.name());
-
- Either<List<ResourceMetadataData>, TitanOperationStatus> byCriteria = titanGenericDao
- .getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
- if (byCriteria.isRight()) {
- log.debug("Failed to fetch VF resources by criteria ", byCriteria.right().value());
- return false;
- }
- List<ResourceMetadataData> resources = byCriteria.left().value();
-
- try {
- for (ResourceMetadataData data : resources) {
- if (data.getMetadataDataDefinition().getCsarUUID() != null) {
- log.debug("VF {} with CSAR {}", data.getUniqueId(), data.getMetadataDataDefinition().getCsarUUID());
- Either<TitanVertex, TitanOperationStatus> vertexByProperty = titanGenericDao
- .getVertexByProperty(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), data.getUniqueId());
- if (vertexByProperty.isRight()) {
- log.debug("Failed to fetch vertex with id {} . skip resource {} ", data.getUniqueId(),
- data.getMetadataDataDefinition().getName());
- continue;
- }
- Vertex vertex = vertexByProperty.left().value();
- Iterator<VertexProperty<Object>> properties = vertex
- .properties(GraphPropertiesDictionary.CSAR_UUID.getProperty());
- while (properties.hasNext()) {
- VertexProperty<Object> next = properties.next();
- next.remove();
- }
-
- }
- }
- titanGenericDao.commit();
- } catch (Exception e) {
- log.debug("Failed to clean CSAR UUID. rollback");
- titanGenericDao.rollback();
- }
-
- return true;
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1610/TitanFixUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1610/TitanFixUtils.java
deleted file mode 100644
index fedd4d2545..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1610/TitanFixUtils.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1610;
-
-import com.google.gson.Gson;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanVertex;
-import fj.data.Either;
-
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.operations.impl.CacheMangerOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.*;
-
-public class TitanFixUtils {
- private static Logger log = LoggerFactory.getLogger(TitanFixUtils.class.getName());
-
- @Autowired
- protected TitanGenericDao titanGenericDao;
- @Autowired
- protected CacheMangerOperation cacheMangerOperation;
-
- public boolean fixIconsInNormatives() {
- log.info("starting fix");
- String vlName = "VL";
- String elineName = "VL_ELINE";
- String elineFixedName = "VL ELINE";
- Either<TitanGraph, TitanOperationStatus> graphResult = titanGenericDao.getGraph();
- if (graphResult.isRight()) {
- log.error("failed to get graph object.");
- return false;
- }
-
- boolean operationFailed = false;
- Map<String, Object> vlVerticeProperties = null;
- Map<String, Object> elineVerticeProperties = null;
-
- try {
- TitanGraph titanGraph = graphResult.left().value();
- log.info("look up vl :{}", vlName);
-
- Iterable<TitanVertex> vertices = titanGraph.query()
- .has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Resource.getName())
- .has(GraphPropertiesDictionary.NAME.getProperty(), vlName)
- .has(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true).vertices();
-
- if (vertices == null) {
- log.error("failed to get vernice for resource name {}", vlName);
- operationFailed = true;
- return false;
- }
-
- Iterator<TitanVertex> iterator = vertices.iterator();
- List<TitanVertex> vertexList = new ArrayList<>();
-
- if (iterator == null) {
- log.error("failed to get iterator over vertices object returned for resource id {}", vlName);
- operationFailed = true;
- return false;
- }
-
- while (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
- vertexList.add(vertex);
- }
-
- if (!(vertexList.size() == 1)) {
- log.error("failed to get 1 vertex for resource {} with highest true. instead got {}", vlName,
- vertexList.size());
- operationFailed = true;
- return false;
- }
-
- TitanVertex vlVertex = vertexList.get(0);
-
- log.info("look up eline:{}", elineName);
-
- boolean vl_eline_found = true;
-
- vertices = titanGraph.query()
- .has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Resource.getName())
- .has(GraphPropertiesDictionary.NAME.getProperty(), elineName)
- .has(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true).vertices();
-
- if (vertices == null) {
- log.error("failed to get vertices object returned for resource {}", elineName);
- operationFailed = true;
-
- vl_eline_found = false;
- }
-
- if (vl_eline_found) {
- iterator = vertices.iterator();
- vertexList = new ArrayList<>();
- if (iterator == null) {
- log.error("failed to get iterator over vertices object returned for resource id {}", elineName);
- operationFailed = true;
-
- vl_eline_found = false;
- }
-
- if (vl_eline_found) {
- while (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
- vertexList.add(vertex);
- }
-
- if (!(vertexList.size() == 1)) {
- log.error("failed to get 1 vertex for resource {} with highest true. instead got {}",
- elineName, vertexList.size());
- operationFailed = true;
-
- vl_eline_found = false;
- }
- }
- }
-
- if (!vl_eline_found) {
- log.info("look up eline:{}", elineFixedName);
- vl_eline_found = true;
- operationFailed = false;
-
- vertices = titanGraph.query()
- .has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.Resource.getName())
- .has(GraphPropertiesDictionary.NAME.getProperty(), elineFixedName)
- .has(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true).vertices();
-
- if (vertices == null) {
- log.error("failed to get vertices object returned for resource {}", elineFixedName);
- operationFailed = true;
-
- vl_eline_found = false;
- }
-
- if (vl_eline_found) {
- iterator = vertices.iterator();
- vertexList = new ArrayList<>();
- if (iterator == null) {
- log.error("failed to get iterator over vertices object returned for resource id {}",
- elineFixedName);
- operationFailed = true;
-
- vl_eline_found = false;
- }
-
- if (vl_eline_found) {
- while (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
- vertexList.add(vertex);
- }
-
- if (!(vertexList.size() == 1)) {
- log.error("failed to get 1 vertex for resource {} with highest true. instead got {}",
- elineFixedName, vertexList.size());
- operationFailed = true;
-
- vl_eline_found = false;
- }
- }
- }
- }
-
- if (!vl_eline_found) {
- return false;
- } else {
- TitanVertex elineVertex = vertexList.get(0);
-
- vlVerticeProperties = titanGenericDao.getProperties(vlVertex);
-
- log.info("VL Vertice Properties {}", vlVerticeProperties);
- if ("network".equals(vlVerticeProperties.get(GraphPropertiesDictionary.ICON.getProperty()))) {
- log.info("nothing to update in vl");
- } else {
- log.info("updating property icon of vl");
- vlVertex.property(GraphPropertiesDictionary.ICON.getProperty(), "network");
- }
-
- elineVerticeProperties = titanGenericDao.getProperties(elineVertex);
-
- log.info("eline vertice Properties {}", elineVerticeProperties);
- if ("network".equals(elineVerticeProperties.get(GraphPropertiesDictionary.ICON.getProperty()))) {
- log.info("nothing to update in eline");
- } else {
- log.info("updating property icon of eline");
- elineVertex.property(GraphPropertiesDictionary.ICON.getProperty(), "network");
- }
-
- if ("VL ELINE".equals(elineVerticeProperties.get(GraphPropertiesDictionary.NAME.getProperty()))) {
- log.info("nothing to update in eline");
- } else {
- log.info("updating property name and tag of eline");
- elineVertex.property(GraphPropertiesDictionary.NAME.getProperty(), elineFixedName);
- List<String> tags = new ArrayList<>();
- tags.add("VL ELINE");
- elineVertex.property(GraphPropertiesDictionary.TAGS.getProperty(), new Gson().toJson(tags));
- }
-
- log.info("print current properties state");
-
- vlVerticeProperties = titanGenericDao.getProperties(vlVertex);
-
- log.info("vertice vl Properties {}", vlVerticeProperties);
- elineVerticeProperties = titanGenericDao.getProperties(elineVertex);
-
- log.info("vertice eline Properties {}", elineVerticeProperties);
- }
-
- try {
- Thread.sleep(30 * 1000);
- } catch (InterruptedException e) {
- log.error("exception", e);
- }
- return true;
- } finally {
- if (operationFailed) {
- titanGenericDao.rollback();
- } else {
- titanGenericDao.commit();
- long time = System.currentTimeMillis();
- if (vlVerticeProperties != null) {
- cacheMangerOperation.updateComponentInCache(
- (String) vlVerticeProperties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()), time,
- NodeTypeEnum.Resource);
- }
- if (elineVerticeProperties != null) {
- cacheMangerOperation.updateComponentInCache(
- (String) elineVerticeProperties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()),
- time, NodeTypeEnum.Resource);
- }
- }
- }
- }
-
- /**
- * in 1610 we encounter an issue that if a capability property overrides a
- * property of a derived capability then it was created with out a property
- * type when it was first imported as part of the capability types. this
- * will add property type to the properties missing it.
- */
- public boolean fixCapabiltyPropertyTypes() {
-
- String propertyIdSecure = "tosca.capabilities.Endpoint.Admin.secure";
- String propertyIdNetworkName = "tosca.capabilities.Endpoint.Public.network_name";
- Either<TitanGraph, TitanOperationStatus> graphResult = titanGenericDao.getGraph();
-
- if (graphResult.isRight()) {
- log.error("failed to get graph object.");
- return false;
- }
-
- boolean operationFailed = false;
- try {
- TitanGraph titanGraph = graphResult.left().value();
- log.info("look up propertyIdSecure:{}", propertyIdSecure);
- Iterable<TitanVertex> vertices = titanGraph.query()
- .has(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Property), propertyIdSecure).vertices();
- if (vertices == null) {
- log.error("failed to get vertices object returned for resource id {}", propertyIdSecure);
- operationFailed = true;
- return false;
- }
- Iterator<TitanVertex> iterator = vertices.iterator();
- List<TitanVertex> vertexList = new ArrayList<>();
-
- if (iterator == null) {
- log.error("failed to get iterator over vertices object returned for resource id {}", propertyIdSecure);
- operationFailed = true;
- return false;
- }
-
- while (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
- vertexList.add(vertex);
- }
-
- if (vertexList.size() != 1) {
- log.error("failed to get 1 vertex for resource id {} instead got {}", propertyIdSecure,
- vertexList.size());
- operationFailed = true;
- return false;
- }
-
- TitanVertex propertyVerticeSecure = vertexList.get(0);
-
- log.info("look up propertyIdNetworkName:{}", propertyIdNetworkName);
- vertices = titanGraph.query()
- .has(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Property), propertyIdNetworkName).vertices();
- if (vertices == null) {
- log.error("failed to get vertices object returned for resource id {}", propertyIdNetworkName);
- operationFailed = true;
- return false;
- }
-
- iterator = vertices.iterator();
- vertexList = new ArrayList<>();
-
- if (iterator == null) {
- log.error("failed to get iterator over vertices object returned for resource id {}",
- propertyIdNetworkName);
- operationFailed = true;
- return false;
- }
-
- while (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
- vertexList.add(vertex);
- }
-
- if (!(vertexList.size() == 1)) {
- log.error("failed to get 1 vertex for resource id {} instead got {}", propertyIdNetworkName,
- vertexList.size());
- operationFailed = true;
- return false;
- }
-
- TitanVertex propertyVerticeNetworkName = vertexList.get(0);
-
- Map<String, Object> verticeNetworkNameProperties = titanGenericDao
- .getProperties(propertyVerticeNetworkName);
-
- log.info("vertice NetworkName Properties {}", verticeNetworkNameProperties);
- Object type = verticeNetworkNameProperties.get(GraphPropertiesDictionary.TYPE.getProperty());
- if (type == null || "".equals(type)) {
- log.info("updating property Vertice Network Name");
- propertyVerticeNetworkName.property(GraphPropertiesDictionary.TYPE.getProperty(), "string");
- }
-
- Map<String, Object> verticeSecureProperties = titanGenericDao.getProperties(propertyVerticeSecure);
-
- log.info("vertice Secure Properties {}", verticeSecureProperties);
-
- type = verticeSecureProperties.get(GraphPropertiesDictionary.TYPE.getProperty());
-
- if (type == null || "".equals(type)) {
- log.info("updating property Vertice Secure");
- propertyVerticeSecure.property(GraphPropertiesDictionary.TYPE.getProperty(), "boolean");
- }
-
- log.info("print current properties state");
-
- verticeNetworkNameProperties = titanGenericDao.getProperties(propertyVerticeNetworkName);
-
- log.info("vertice NetworkName Properties {}", verticeNetworkNameProperties);
-
- verticeSecureProperties = titanGenericDao.getProperties(propertyVerticeSecure);
-
- log.info("vertice Secure Properties {}", verticeSecureProperties);
-
- return true;
- } finally {
- if (operationFailed) {
- titanGenericDao.rollback();
- } else {
- titanGenericDao.commit();
- }
- }
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1610/ToscaArtifactsAlignment.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1610/ToscaArtifactsAlignment.java
deleted file mode 100644
index 673190e8c1..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1610/ToscaArtifactsAlignment.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1610;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
-import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
-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.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Operation;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.model.operations.api.IArtifactOperation;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.AbstractOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.openecomp.sdc.be.resources.data.ArtifactData;
-import org.openecomp.sdc.be.resources.data.ComponentMetadataData;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-import org.openecomp.sdc.be.resources.data.ServiceMetadataData;
-import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
-import org.openecomp.sdc.common.api.ArtifactTypeEnum;
-import org.openecomp.sdc.common.datastructure.Wrapper;
-import org.openecomp.sdc.common.util.StreamUtils;
-import org.openecomp.sdc.exception.ResponseFormat;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import fj.data.Either;
-
-/**
- * This Class holds the logic to add Tosca Artifacts placeholder and payload.<br>
- * This addition is done for old version of Services and Resources (pre 1610) that weren't created with them.<br>
- *
- * @author mshitrit <br>
- *
- *
- */
-public class ToscaArtifactsAlignment extends AbstractOperation {
- @Autowired
- private IArtifactOperation artifactOperation;
-
- @Autowired
- private ServiceBusinessLogic serviceBusinessLogic;
-
- private static Logger log = LoggerFactory.getLogger(ToscaArtifactsAlignment.class.getName());
-
- private static final String ERROR_PREFIX = "Tosca Artifact Alignment Error: ";
-
- // API that Fetches Resource
- private final Function<ComponentMetadataData, Resource> resourceFetcher = componentMD -> getComponent(componentMD, ComponentTypeEnum.RESOURCE);
- // API that Fetches Service
- private final Function<ComponentMetadataData, Service> serviceFetcher = componentMD -> getComponent(componentMD, ComponentTypeEnum.SERVICE);
- // Class Getters
- private final Supplier<Class<ResourceMetadataData>> resourceClassGetter = () -> ResourceMetadataData.class;
- private final Supplier<Class<ServiceMetadataData>> serviceClassGetter = () -> ServiceMetadataData.class;
-
- /**
- * This method holds the logic to add Tosca Artifacts placeholder and payload.<br>
- *
- * @return true if succeed otherwise returns false
- */
- public boolean alignToscaArtifacts() {
- Wrapper<TitanOperationStatus> errorWrapper = new Wrapper<>();
- List<ResourceMetadataData> allResources = new ArrayList<>();
- List<ResourceMetadataData> resourcesWithoutToscaPlaceHolder = new ArrayList<>();
- List<ServiceMetadataData> allServices = new ArrayList<>();
- List<ServiceMetadataData> servicesWithoutToscaPlaceHolder = new ArrayList<>();
- log.debug("alignToscaArtifacts Start");
- try {
-
- if (errorWrapper.isEmpty()) {
- log.info("Fetching all resources");
- fillAllComponetOfSpecificType(allResources, NodeTypeEnum.Resource, resourceClassGetter, errorWrapper);
- }
-
- if (errorWrapper.isEmpty()) {
- // Filter Resources Without Tosca Artifacts
- log.info("filtering resources to add tosca placeholder");
- Either<List<ResourceMetadataData>, TitanOperationStatus> eitherRelevantResources = getComponentsWithMissingToscaArtifacts(resourceClassGetter, NodeTypeEnum.Resource, allResources);
- fillListOrWrapper(errorWrapper, resourcesWithoutToscaPlaceHolder, eitherRelevantResources);
- }
-
- if (errorWrapper.isEmpty()) {
- // Add PlaceHolders To Resources
- log.info("adding tosca placeholders artifacts to resources");
- addToscaArtifactToComponents(resourcesWithoutToscaPlaceHolder, resourceFetcher, NodeTypeEnum.Resource, errorWrapper);
- }
- if (errorWrapper.isEmpty()) {
- // Add payload to Resources
- log.info("generating payload to tosca artifacts on resources");
- fillResourcesPayload(allResources, errorWrapper);
- }
-
- if (errorWrapper.isEmpty()) {
- log.info("Fetching all services");
- fillAllComponetOfSpecificType(allServices, NodeTypeEnum.Service, serviceClassGetter, errorWrapper);
- }
- if (errorWrapper.isEmpty()) {
- // Filter Services Without Tosca Artifacts
- log.info("filtering services to add tosca placeholder");
- Either<List<ServiceMetadataData>, TitanOperationStatus> eitherRelevantServices = getComponentsWithMissingToscaArtifacts(serviceClassGetter, NodeTypeEnum.Service, allServices);
- fillListOrWrapper(errorWrapper, servicesWithoutToscaPlaceHolder, eitherRelevantServices);
- }
-
- if (errorWrapper.isEmpty()) {
- // Add PlaceHolders To Services
- log.info("adding tosca placeholders artifacts to services");
- addToscaArtifactToComponents(servicesWithoutToscaPlaceHolder, serviceFetcher, NodeTypeEnum.Service, errorWrapper);
- }
-
- if (errorWrapper.isEmpty()) {
- // Filter Services for Payload Add
- // Add payload to Services
- log.info("generating payload to tosca artifacts on services");
- fillToscaArtifactPayload(allServices, serviceFetcher, errorWrapper);
- }
- } finally {
- titanGenericDao.commit();
- }
- return errorWrapper.isEmpty();
-
- }
-
- private void fillResourcesPayload(List<ResourceMetadataData> allResources, Wrapper<TitanOperationStatus> errorWrapper) {
- if (errorWrapper.isEmpty()) {
- // First Only Non VF (CP, VL & VFC)
- List<ResourceMetadataData> basicResources = allResources.stream().filter(e -> isBasicResource((ResourceMetadataDataDefinition) e.getMetadataDataDefinition())).collect(Collectors.toList());
- // Filter resources for Payload Add
- // Add payload to resources
- fillToscaArtifactPayload(basicResources, resourceFetcher, errorWrapper);
- }
- if (errorWrapper.isEmpty()) {
- // VFs
- List<ResourceMetadataData> complexResource = allResources.stream().filter(e -> ((ResourceMetadataDataDefinition) e.getMetadataDataDefinition()).getResourceType() == ResourceTypeEnum.VF).collect(Collectors.toList());
- // Filter resources for Payload Add
- // Add payload to resources
- fillToscaArtifactPayload(complexResource, resourceFetcher, errorWrapper);
- }
- }
-
- private boolean isBasicResource(ResourceMetadataDataDefinition resourceMetadataDataDefinition) {
- final ResourceTypeEnum resourceType = resourceMetadataDataDefinition.getResourceType();
- boolean isBasicResource = resourceType == ResourceTypeEnum.CP || resourceType == ResourceTypeEnum.VL || resourceType == ResourceTypeEnum.VFC;
- return isBasicResource;
- }
-
- private <T extends ComponentMetadataData> void fillAllComponetOfSpecificType(List<T> components, NodeTypeEnum nodeType, Supplier<Class<T>> classGetter, Wrapper<TitanOperationStatus> errorWrapper) {
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(GraphPropertiesDictionary.IS_DELETED.getProperty(), true);
- Either<List<T>, TitanOperationStatus> eitherComponentMD = titanGenericDao.getByCriteria(nodeType, null, props, classGetter.get());
- if (eitherComponentMD.isLeft()) {
- components.addAll(eitherComponentMD.left().value());
- } else {
- final TitanOperationStatus errorType = eitherComponentMD.right().value();
- if (errorType != TitanOperationStatus.NOT_FOUND) {
- log.error("{} When fetching all components of type:{} a titan error occured:{}", ERROR_PREFIX, nodeType.getName(), errorType.name());
- errorWrapper.setInnerElement(errorType);
- }
- }
-
- }
-
- private <T extends ComponentMetadataData, R extends Component> void addToscaArtifactToComponents(List<T> relevantResources, Function<ComponentMetadataData, R> componentConvertor, NodeTypeEnum nodeType,
- Wrapper<TitanOperationStatus> errorWrapper) {
-
- // This Stream contains all create tosca placeholder results
- Stream<StorageOperationStatus> addToscaToComponentsResultsStream = relevantResources.stream().map(e -> addToscaArtifacts(e, nodeType, componentConvertor));
- // Execute the stream, and collect error
- Optional<StorageOperationStatus> optionalError = addToscaToComponentsResultsStream.filter(e -> e != StorageOperationStatus.OK).findFirst();
-
- // Handle error
- if (optionalError.isPresent()) {
- errorWrapper.setInnerElement(TitanOperationStatus.NOT_CREATED);
- }
- }
-
- private <R extends Component> R getComponent(ComponentMetadataData md, ComponentTypeEnum componentTypeEnum) {
- R result = null;
- Either<R, StorageOperationStatus> eitherComponent = serviceBusinessLogic.getComponent(md.getMetadataDataDefinition().getUniqueId(), componentTypeEnum);
- if (eitherComponent.isRight()) {
- log.error("{} When fetching component {} of type:{} with uniqueId:{}", ERROR_PREFIX, md.getMetadataDataDefinition().getName(), componentTypeEnum.getValue(), md.getMetadataDataDefinition().getUniqueId());
- } else {
- result = eitherComponent.left().value();
- }
- return result;
- }
-
- private Either<Either<ArtifactDefinition, Operation>, ResponseFormat> populateToscaArtifactsWithLog(Component component, User user, boolean isInCertificationRequest, boolean inTransaction, boolean shouldLock) {
- Either<Either<ArtifactDefinition, Operation>, ResponseFormat> ret;
- try {
- ret = serviceBusinessLogic.populateToscaArtifacts(component, user, isInCertificationRequest, inTransaction, shouldLock);
- if (ret.isLeft()) {
- log.debug("Added payload to tosca artifacts of component {} of type:{} with uniqueId:{}", component.getName(), component.getComponentType().getValue(), component.getUniqueId());
- }
- return ret;
- } catch (Exception e) {
- log.error("{} Exception Occured When filling tosca artifact payload for component {} of type:{} with uniqueId:{}", ERROR_PREFIX, component.getName(), component.getComponentType().name(), component.getUniqueId(), e);
- throw e;
- }
- }
-
- private <R extends Component, T extends ComponentMetadataData> void fillToscaArtifactPayload(List<T> relevantComponents, Function<ComponentMetadataData, R> componentCreator, Wrapper<TitanOperationStatus> errorWrapper) {
-
- final User dummyUser = buildDummyUser();
- // Stream for all fill payload results
- Stream<ImmutablePair<Component, Either<Either<ArtifactDefinition, Operation>, ResponseFormat>>>
- // Filter elements that needs generation of tosca payload
- fillToscaPayloadResultsStream = relevantComponents.stream().filter(e -> isGenerateToscaPayload(e))
- // Converts ComponentMetadataData to Component
- .map(e -> componentCreator.apply(e))
- // For each component generate payload for tosca
- // artifacts
- .map(component -> {
- return new ImmutablePair<Component, Either<Either<ArtifactDefinition, Operation>, ResponseFormat>>(component, populateToscaArtifactsWithLog(component, dummyUser, true, true, false));
- });
-
- try {
- // execute and the stream
- Optional<Component> optionalError = fillToscaPayloadResultsStream.
- // filter in error
- filter(e -> e.getRight().isRight())
- // convert the result to error and execute the stream
- .map(e -> e.getLeft()).findFirst();
-
- // Check if error occurred
- if (optionalError.isPresent()) {
- Component component = optionalError.get();
- log.error("{} When filling tosca artifact payload for component {} of type:{} with uniqueId:{}", ERROR_PREFIX, component.getName(), component.getComponentType().name(), component.getUniqueId());
-
- errorWrapper.setInnerElement(TitanOperationStatus.GENERAL_ERROR);
- }
- } catch (Exception e) {
- log.error("{} When filling tosca artifact payload for components : {}", ERROR_PREFIX, e.getMessage(), e);
- errorWrapper.setInnerElement(TitanOperationStatus.GENERAL_ERROR);
- }
- }
-
- private <R extends Component> StorageOperationStatus addToscaArtifacts(ComponentMetadataData component, NodeTypeEnum nodeType, Function<ComponentMetadataData, R> componentCreator) {
-
- StorageOperationStatus result = StorageOperationStatus.OK;
- R componentDefinition = componentCreator.apply(component);
-
- // Fetch artifacts to be Added
- Either<List<ArtifactDefinition>, StorageOperationStatus> eitherToscaArtifacts = getToscaArtifactsToAdd(componentDefinition);
- if (eitherToscaArtifacts.isRight()) {
- result = eitherToscaArtifacts.right().value();
- } else {
- List<ArtifactDefinition> toscaArtifactsToAdd = eitherToscaArtifacts.left().value();
- if (!CollectionUtils.isEmpty(eitherToscaArtifacts.left().value())) {
- final Stream<ImmutablePair<ArtifactDefinition, Either<ArtifactDefinition, StorageOperationStatus>>> createdToscaPlaceHolderStream = toscaArtifactsToAdd.stream()
- // creates the artifact in the graph
- .map(artifactDef -> new ImmutablePair<ArtifactDefinition, Either<ArtifactDefinition, StorageOperationStatus>>(artifactDef,
- artifactOperation.addArifactToComponent(artifactDef, componentDefinition.getUniqueId(), nodeType, false, true)));
-
- // Execute the stream, and collect error
- Optional<ImmutablePair<ArtifactDefinition, StorageOperationStatus>> optionalError = createdToscaPlaceHolderStream.filter(e -> e.getRight().isRight()).map(e -> new ImmutablePair<>(e.getLeft(), e.getRight().right().value()))
- .findFirst();
-
- // In case error occurred
- if (optionalError.isPresent()) {
- ArtifactDefinition toscaArtifact = optionalError.get().getLeft();
- StorageOperationStatus storageError = optionalError.get().getRight();
- log.error("{} When adding tosca artifact of type {} to component {} of type:{} with uniqueId:{} a storageError occurred:{}", ERROR_PREFIX, toscaArtifact.getArtifactType(), component.getMetadataDataDefinition().getName(),
- nodeType.getName(), component.getMetadataDataDefinition().getUniqueId(), storageError.name());
-
- result = storageError;
- } else {
- log.debug("Added tosca artifacts to component {} of type:{} with uniqueId:{}", component.getMetadataDataDefinition().getName(), nodeType.getName(), component.getMetadataDataDefinition().getUniqueId());
- }
-
- }
- }
-
- return result;
- }
-
- private <R extends Component> Either<List<ArtifactDefinition>, StorageOperationStatus> getToscaArtifactsToAdd(R componentDefinition) {
-
- Either<List<ArtifactDefinition>, StorageOperationStatus> result;
- List<ArtifactDefinition> toscaArtifactsAlreadyExist = new ArrayList<>();
- if (!MapUtils.isEmpty(componentDefinition.getToscaArtifacts())) {
- toscaArtifactsAlreadyExist.addAll(componentDefinition.getToscaArtifacts().values());
- }
-
- // Set Tosca Artifacts on component
- serviceBusinessLogic.setToscaArtifactsPlaceHolders(componentDefinition, buildDummyUser());
-
- List<ArtifactDefinition> toscaArtifactsToAdd = new ArrayList<>();
- if (!MapUtils.isEmpty(componentDefinition.getToscaArtifacts())) {
- final Collection<ArtifactDefinition> allToscaArtifacts = componentDefinition.getToscaArtifacts().values();
- Set<String> artifactTypesExist = toscaArtifactsAlreadyExist.stream().map(e -> e.getArtifactType()).collect(Collectors.toSet());
- toscaArtifactsToAdd = allToscaArtifacts.stream().filter(e -> !artifactTypesExist.contains(e.getArtifactType())).collect(Collectors.toList());
- result = Either.left(toscaArtifactsToAdd);
- } else {
- log.error("{} failed to add tosca artifacts in bussiness logic to component {} of type:{} with uniqueId:{}", ERROR_PREFIX, componentDefinition.getName(), componentDefinition.getComponentType().getValue(),
- componentDefinition.getUniqueId());
- result = Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND);
- }
- return result;
- }
-
- private User buildDummyUser() {
- User user = new User();
- user.setUserId("migrationTask");
- return user;
- }
-
- private boolean isGenerateToscaPayload(ComponentMetadataData component) {
- final String state = component.getMetadataDataDefinition().getState();
- boolean componentLifeCycleStateIsValid = LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name().equals(state) || LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name().equals(state);
-
- return !componentLifeCycleStateIsValid;
-
- }
-
- private <T> void fillListOrWrapper(Wrapper<TitanOperationStatus> wrapper, List<T> listToFill, Either<List<T>, TitanOperationStatus> either) {
- if (either.isRight()) {
- final TitanOperationStatus errorType = either.right().value();
- if (errorType != TitanOperationStatus.NOT_FOUND) {
- wrapper.setInnerElement(errorType);
- }
- } else {
- listToFill.addAll(either.left().value());
- }
- }
-
- private <T extends ComponentMetadataData> Either<List<T>, TitanOperationStatus> getComponentsWithMissingToscaArtifacts(Supplier<Class<T>> classGetter, NodeTypeEnum nodeType, List<T> allComponents) {
-
- Either<List<T>, TitanOperationStatus> result;
- Stream<ImmutablePair<T, Either<List<ArtifactData>, TitanOperationStatus>>> componentsWithToscaStream =
- // Create a Stream of pairs : component and its Tosca Artifacts
- allComponents.stream().map(e -> new ImmutablePair<>(e, getToscaArtifatcs(e, nodeType)));
-
- List<ImmutablePair<T, Either<List<ArtifactData>, TitanOperationStatus>>> componentsWithToscaArtifacts =
- // Collect the stream to list.
- // in case getToscaArtifatcs failed, the first failure is
- // added to the list
- // (the collection stops after first failure)
- StreamUtils.takeWhilePlusOneNoEval(componentsWithToscaStream, e -> e.getRight().isLeft()).collect(Collectors.toList());
-
- // retrieve the failure optional (it may or may not exist)
- Optional<TitanOperationStatus> isErrorOccured = componentsWithToscaArtifacts.stream()
- // convert to the right side of the pair of type Either
- .map(e -> e.getRight())
- // Filter in only the errors
- .filter(e -> e.isRight()).
- // map the error from Either to TitanOperationStatus
- map(e -> e.right().value()).findFirst();
-
- // In case failure occurred
- if (isErrorOccured.isPresent()) {
- result = Either.right(isErrorOccured.get());
- // In case NO failure occurred
- } else {
- List<T> filteredComponents = componentsWithToscaArtifacts.stream()
- // Filter in only elements that does NOT have tosca
- // artifacts
- .filter(e -> isNotContainAllToscaArtifacts(e))
- // Convert back to Components List & collect
- .map(e -> e.getLeft()).collect(Collectors.toList());
-
- result = Either.left(filteredComponents);
- }
-
- return result;
- }
-
- private <T extends ComponentMetadataData> boolean isNotContainAllToscaArtifacts(ImmutablePair<T, Either<List<ArtifactData>, TitanOperationStatus>> pair) {
-
- final List<ArtifactData> artifactList = pair.getRight().left().value();
-
- Set<ArtifactTypeEnum> filteredToscaList = artifactList.stream().
- // Convert to ArtifactDataDefinition
- map(e -> e.getArtifactDataDefinition()).
- // Filter in Only Tosca Artifacts
- filter(e -> e.getArtifactGroupType() == ArtifactGroupTypeEnum.TOSCA).
- // Convert To ArtifactTypeEnum
- map(e -> ArtifactTypeEnum.findType(e.getArtifactType())).
- // Filter Out nulls in case of Type not found
- filter(e -> e != null).collect(Collectors.toSet());
-
- boolean toscaArifactContained = filteredToscaList.contains(ArtifactTypeEnum.TOSCA_CSAR) && filteredToscaList.contains(ArtifactTypeEnum.TOSCA_TEMPLATE);
- return !toscaArifactContained;
- }
-
- private <T extends ComponentMetadataData> Either<List<ArtifactData>, TitanOperationStatus> getToscaArtifatcs(T component, NodeTypeEnum nodeType) {
-
- Either<List<ArtifactData>, TitanOperationStatus> result;
- // All The Artifacts of the Component
- Either<List<ImmutablePair<ArtifactData, GraphEdge>>, TitanOperationStatus> eitherComponentArtifacts = titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(nodeType), component.getMetadataDataDefinition().getUniqueId(),
- GraphEdgeLabels.ARTIFACT_REF, NodeTypeEnum.ArtifactRef, ArtifactData.class);
-
- if (eitherComponentArtifacts.isLeft()) {
- // Convert Artifact Edge Pair to Artifact
- List<ArtifactData> toscaArtifacts = eitherComponentArtifacts.left().value().stream()
- // map ImmutablePair<ArtifactData, GraphEdge> to
- // ArtifactData
- .map(e -> e.getLeft())
- // Filter in only Tosca Artifacts
- .filter(artifact -> artifact.getArtifactDataDefinition().getArtifactGroupType() == ArtifactGroupTypeEnum.TOSCA)
- // Collect
- .collect(Collectors.toList());
- result = Either.left(toscaArtifacts);
- } else if (eitherComponentArtifacts.right().value() == TitanOperationStatus.NOT_FOUND) {
- result = Either.left(new ArrayList<>());
- } else {
- final TitanOperationStatus titanError = eitherComponentArtifacts.right().value();
- log.error("{} When fetching artifacts for component {} of type:{} with uniqueId:{} a titanError occurred:{}", ERROR_PREFIX, component.getMetadataDataDefinition().getName(), nodeType.getName(),
- component.getMetadataDataDefinition().getUniqueId(), titanError.name());
-
- result = Either.right(titanError);
- }
-
- return result;
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1702/DataTypesUpdate.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1702/DataTypesUpdate.java
deleted file mode 100644
index d7f36840c7..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1702/DataTypesUpdate.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1702;
-
-import java.io.File;
-import java.io.FileReader;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.components.impl.ImportUtils;
-import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
-import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaTagNamesEnum;
-import org.openecomp.sdc.be.config.BeEcompErrorManager;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.DataTypeDefinition;
-import org.openecomp.sdc.be.model.PropertyDefinition;
-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.tosca.ToscaPropertyType;
-import org.openecomp.sdc.be.resources.data.PropertyData;
-import org.openecomp.sdc.exception.ResponseFormat;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.yaml.snakeyaml.Yaml;
-
-import fj.data.Either;
-
-/**
- * Allows to update existing or create new data types according input file (yaml)
- * @author ns019t
- *
- */
-public class DataTypesUpdate {
-
- private static Logger log = LoggerFactory.getLogger(Migration1702.class.getName());
-
- @Autowired
- private PropertyOperation propertyOperation;
- @Autowired
- private ComponentsUtils componentsUtils;
-
- @SuppressWarnings("unchecked")
- /**
- * Updates existing or creates new data types according input file (yaml)
- * @param dataTypeYmlFilePath
- * @return
- */
- public boolean updateDataTypes(String dataTypeYmlFilePath) {
-
-
- List<String> dataTypesToUpdate = new ArrayList<>();
- dataTypesToUpdate.add("org.openecomp.datatypes.EcompHoming");
- dataTypesToUpdate.add("org.openecomp.datatypes.EcompNaming");
- dataTypesToUpdate.add("org.openecomp.datatypes.network.NetworkAssignments");
- dataTypesToUpdate.add("org.openecomp.datatypes.network.ProviderNetwork");
- dataTypesToUpdate.add("org.openecomp.datatypes.network.NetworkFlows");
- dataTypesToUpdate.add("org.openecomp.datatypes.Artifact");
- dataTypesToUpdate.add("org.openecomp.datatypes.network.VlanRequirements");
- dataTypesToUpdate.add("org.openecomp.datatypes.network.IpRequirements");
- dataTypesToUpdate.add("org.openecomp.datatypes.network.MacAssignments");
- dataTypesToUpdate.add("org.openecomp.datatypes.network.MacRequirements");
- dataTypesToUpdate.add("org.openecomp.datatypes.heat.contrailV2.virtual.machine.subInterface.AddressPairIp");
- dataTypesToUpdate.add("org.openecomp.datatypes.heat.contrailV2.virtual.machine.subInterface.MacAddress");
- dataTypesToUpdate.add("org.openecomp.datatypes.heat.contrailV2.virtual.machine.subInterface.Properties");
- dataTypesToUpdate.add("org.openecomp.datatypes.heat.contrailV2.virtual.machine.subInterface.AddressPair");
- dataTypesToUpdate.add("org.openecomp.datatypes.heat.contrailV2.virtual.machine.subInterface.AddressPairs");
-
- boolean isSuccessful = true;
- List<DataTypeDefinition> dataTypes = extractDataTypesFromYaml(dataTypeYmlFilePath);
-
- if(CollectionUtils.isEmpty(dataTypes)){
- isSuccessful = false;
- }
-
- List<ImmutablePair<DataTypeDefinition, Boolean>> createdElementTypes = new ArrayList<>();
-
- Iterator<DataTypeDefinition> elementTypeItr = dataTypes.iterator();
- if(isSuccessful ){
- try {
- while (elementTypeItr.hasNext()) {
- DataTypeDefinition elementType = elementTypeItr.next();
- String elementName = elementType.getName();
- Either<ActionStatus, ResponseFormat> validateElementType = validateDataType(elementType);
- if (validateElementType.isRight()) {
- log.debug("Failed to validate data type {}. Status is {}. ", elementName, validateElementType.right().value());
- isSuccessful = false;
- break;
- }
- log.debug("Going to get data type by name {}. ", elementName);
- Either<DataTypeDefinition, StorageOperationStatus> findElementType = propertyOperation.getDataTypeByNameWithoutDerived(elementName);
- if (findElementType.isRight()) {
- StorageOperationStatus status = findElementType.right().value();
- if (status != StorageOperationStatus.NOT_FOUND) {
- log.debug("Failed to fetch data type {}. Status is {}. ", elementName , validateElementType.right().value());
- isSuccessful = false;
- break;
- } else {
- log.debug("Going to add data type with name {}. ", elementName);
- Either<DataTypeDefinition, StorageOperationStatus> dataModelResponse = propertyOperation.addDataType(elementType);
-
- if (dataModelResponse.isRight()) {
- if (dataModelResponse.right().value() != StorageOperationStatus.SCHEMA_VIOLATION) {
- log.debug("Failed to add data type {}. Status is {}. ", elementName , dataModelResponse.right().value());
- isSuccessful = false;
- break;
- } else {
- createdElementTypes.add(new ImmutablePair<DataTypeDefinition, Boolean>(elementType, false));
- }
- } else {
- createdElementTypes.add(new ImmutablePair<DataTypeDefinition, Boolean>(elementType, true));
- }
-
- }
- } else {
- log.debug("Going to update data type with name {}. ", elementName);
- Either<DataTypeDefinition, StorageOperationStatus> updateDataTypeRes = propertyOperation.updateDataType(elementType, findElementType.left().value());
- if (updateDataTypeRes.isRight()) {
- StorageOperationStatus status = updateDataTypeRes.right().value();
- if (status == StorageOperationStatus.OK) {
- createdElementTypes.add(new ImmutablePair<DataTypeDefinition, Boolean>(elementType, false));
- } else {
- log.debug("Failed to update data type {}. Status is {}. ", elementName , updateDataTypeRes.right().value());
- isSuccessful = false;
- break;
- }
- } else {
- createdElementTypes.add(new ImmutablePair<DataTypeDefinition, Boolean>(elementType, true));
- }
- }
- }
- } finally {
- if(isSuccessful){
- propertyOperation.getTitanGenericDao().commit();
- }else{
- propertyOperation.getTitanGenericDao().rollback();
- }
- }
- }
- return isSuccessful;
- }
-
- @SuppressWarnings("unchecked")
- static public List<DataTypeDefinition> extractDataTypesFromYaml(String dataTypeYmlFilePath) {
- String dataTypeName;
- List<DataTypeDefinition> dataTypes = new ArrayList<>();
- try {
- File file = new File(dataTypeYmlFilePath);
- FileReader fr = new FileReader(file);
- Map<String, Object> toscaJson = (Map<String, Object>) new Yaml().load(fr);
-
- Iterator<Entry<String, Object>> elementTypesEntryItr = toscaJson.entrySet().iterator();
- while (elementTypesEntryItr.hasNext()) {
- Entry<String, Object> elementTypeNameDataEntry = elementTypesEntryItr.next();
- dataTypeName = elementTypeNameDataEntry.getKey();
- Map<String, Object> elementTypeJsonData = (Map<String, Object>) elementTypeNameDataEntry.getValue();
-
- DataTypeDefinition dataType = new DataTypeDefinition();
- dataType.setName(dataTypeName);
-
- if (elementTypeJsonData != null) {
-
- if (elementTypeJsonData.containsKey(ToscaTagNamesEnum.DESCRIPTION.getElementName())) {
- dataType.setDescription( (String)elementTypeJsonData.get(ToscaTagNamesEnum.DESCRIPTION.getElementName()));
- }
- if (elementTypeJsonData.containsKey(ToscaTagNamesEnum.DERIVED_FROM.getElementName())) {
- dataType.setDerivedFromName( (String)elementTypeJsonData.get(ToscaTagNamesEnum.DERIVED_FROM.getElementName()));
- }
- List<PropertyDefinition> properties = getProperties(elementTypeJsonData);
- if (elementTypeJsonData.containsKey(ToscaTagNamesEnum.PROPERTIES.getElementName())) {
- dataType.setProperties(properties);
- }
- }
- dataTypes.add(dataType);
- }
-
- } catch (Exception e) {
- log.debug("Failed to extract data types from Yaml file {}. ", dataTypeYmlFilePath);
- e.printStackTrace();
- }
- return dataTypes;
- }
-
- static public List<PropertyDefinition> getProperties(Map<String, Object> toscaJson) {
- List<PropertyDefinition> values = null;
- Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties = ImportUtils.getProperties(toscaJson);
-
- if (properties.isLeft()) {
- values = new ArrayList<>();
- Map<String, PropertyDefinition> propertiesMap = properties.left().value();
- if (propertiesMap != null && propertiesMap.isEmpty() == false) {
-
- for (Entry<String, PropertyDefinition> entry : propertiesMap.entrySet()) {
- String propName = entry.getKey();
- PropertyDefinition propertyDefinition = entry.getValue();
- PropertyDefinition newPropertyDefinition = new PropertyDefinition(propertyDefinition);
- newPropertyDefinition.setName(propName);
- values.add(newPropertyDefinition);
- }
- }
- }
-
- return values;
- }
-
- private Either<ActionStatus, ResponseFormat> validateDataType(DataTypeDefinition dataType) {
-
- String dataTypeName = dataType.getName();
- List<PropertyDefinition> properties = dataType.getProperties();
- if (properties == null) {
- // At least one parameter should be defined either in the properties
- // section or at one of the parents
- String derivedDataType = dataType.getDerivedFromName();
- // If there are no properties, then we can create a data type if it
- // is an abstract one or it derives from non abstract data type
- if ((derivedDataType == null || derivedDataType.isEmpty())) {
- if (false == isAbstract(dataType.getName())) {
- if (false == ToscaPropertyType.isScalarType(dataTypeName)) {
- log.debug("Data type {} must have properties unless it derives from non abstract data type",dataType.getName());
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_NOR_PROPERTIES_NEITHER_DERIVED_FROM, dataType, null);
-
- return Either.right(responseFormat);
- }
- }
- } else {
- // if it is not a scalar data type and it derives from abstract
- // data type, we should reject the request.
- if (false == ToscaPropertyType.isScalarType(dataTypeName) && true == isAbstract(derivedDataType)) {
- log.debug("Data type {} which derived from abstract data type must have at least one property",dataType.getName());
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_NOR_PROPERTIES_NEITHER_DERIVED_FROM, dataType, null);
-
- return Either.right(responseFormat);
- }
- }
- } else {
- // properties tag cannot be empty
- if (properties.isEmpty()) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_PROPERTIES_CANNOT_BE_EMPTY, dataType, null);
-
- return Either.right(responseFormat);
- }
-
- // check no duplicates
- Set<String> collect = properties.stream().map(p -> p.getName()).collect(Collectors.toSet());
- if (collect != null) {
- if (properties.size() != collect.size()) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_DUPLICATE_PROPERTY, dataType, null);
-
- return Either.right(responseFormat);
- }
- }
-
- List<String> propertiesWithSameTypeAsDataType = properties.stream().filter(p -> p.getType().equals(dataType.getName())).map(p -> p.getName()).collect(Collectors.toList());
- if (propertiesWithSameTypeAsDataType != null && propertiesWithSameTypeAsDataType.isEmpty() == false) {
- log.debug("The data type {} contains properties with the type {}",dataType.getName(),dataType.getName());
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_PROEPRTY_CANNOT_HAVE_SAME_TYPE_OF_DATA_TYPE, dataType, propertiesWithSameTypeAsDataType);
-
- return Either.right(responseFormat);
- }
- }
-
- String derivedDataType = dataType.getDerivedFromName();
- if (derivedDataType != null) {
- Either<DataTypeDefinition, StorageOperationStatus> derivedDataTypeByName = propertyOperation.getDataTypeByName(derivedDataType, true);
- if (derivedDataTypeByName.isRight()) {
- StorageOperationStatus status = derivedDataTypeByName.right().value();
- if (status == StorageOperationStatus.NOT_FOUND) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_DERIVED_IS_MISSING, dataType, null);
-
- return Either.right(responseFormat);
- } else {
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.GENERAL_ERROR, dataType, null);
-
- return Either.right(responseFormat);
-
- }
- } else {
-
- DataTypeDefinition derivedDataTypeDef = derivedDataTypeByName.left().value();
- if (properties != null && properties.isEmpty() == false) {
-
- if (true == isScalarType(derivedDataTypeDef)) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_CANNOT_HAVE_PROPERTIES, dataType, null);
-
- return Either.right(responseFormat);
- }
-
- Set<String> allParentsProps = new HashSet<>();
- do {
- List<PropertyDefinition> currentParentsProps = derivedDataTypeDef.getProperties();
- if (currentParentsProps != null) {
- for (PropertyDefinition propertyDefinition : currentParentsProps) {
- allParentsProps.add(propertyDefinition.getName());
- }
- }
- derivedDataTypeDef = derivedDataTypeDef.getDerivedFrom();
- } while (derivedDataTypeDef != null);
-
- // Check that no property is already defined in one of the
- // ancestors
- Set<String> alreadyExistPropsCollection = properties.stream().filter(p -> allParentsProps.contains(p.getName())).map(p -> p.getName()).collect(Collectors.toSet());
- if (alreadyExistPropsCollection != null && alreadyExistPropsCollection.isEmpty() == false) {
- List<String> duplicateProps = new ArrayList<>();
- duplicateProps.addAll(alreadyExistPropsCollection);
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_PROPERTY_ALREADY_DEFINED_IN_ANCESTOR, dataType, duplicateProps);
-
- return Either.right(responseFormat);
- }
-
- }
- }
- }
- return Either.left(ActionStatus.OK);
- }
-
- private boolean isAbstract(String dataTypeName) {
-
- ToscaPropertyType isPrimitiveToscaType = ToscaPropertyType.isValidType(dataTypeName);
-
- return isPrimitiveToscaType != null && isPrimitiveToscaType.isAbstract() == true;
-
- }
-
- private boolean isScalarType(DataTypeDefinition dataTypeDef) {
-
- boolean isScalar = false;
- DataTypeDefinition dataType = dataTypeDef;
-
- while (dataType != null) {
-
- String name = dataType.getName();
- if (ToscaPropertyType.isScalarType(name)) {
- isScalar = true;
- break;
- }
-
- dataType = dataType.getDerivedFrom();
- }
-
- return isScalar;
- }
-
-// public Either<DataTypeDefinition, StorageOperationStatus> updateDataType(DataTypeDefinition newDataTypeDefinition, DataTypeDefinition oldDataTypeDefinition) {
-//
-// Either<DataTypeDefinition, StorageOperationStatus> result = null;
-//
-// try {
-//
-// List<PropertyDefinition> newProperties = newDataTypeDefinition.getProperties();
-//
-// List<PropertyDefinition> oldProperties = oldDataTypeDefinition.getProperties();
-//
-// String newDerivedFromName = getDerivedFromName(newDataTypeDefinition);
-//
-// String oldDerivedFromName = getDerivedFromName(oldDataTypeDefinition);
-//
-// String dataTypeName = newDataTypeDefinition.getName();
-//
-// List<PropertyDefinition> propertiesToAdd = new ArrayList<>();
-// if (isPropertyOmitted(newProperties, oldProperties, dataTypeName) || isPropertyTypeChanged(dataTypeName, newProperties, oldProperties, propertiesToAdd) || isDerivedFromNameChanged(dataTypeName, newDerivedFromName, oldDerivedFromName)) {
-//
-// log.debug("The new data type " + dataTypeName + " is invalid.");
-//
-// result = Either.right(StorageOperationStatus.CANNOT_UPDATE_EXISTING_ENTITY);
-// return result;
-// }
-//
-// if (propertiesToAdd == null || propertiesToAdd.isEmpty()) {
-// log.debug("No new properties has been defined in the new data type " + newDataTypeDefinition);
-// result = Either.right(StorageOperationStatus.OK);
-// return result;
-// }
-//
-// Either<Map<String, PropertyData>, TitanOperationStatus> addPropertiesToDataType = addPropertiesToDataType(oldDataTypeDefinition.getUniqueId(), propertiesToAdd);
-//
-// if (addPropertiesToDataType.isRight()) {
-// log.debug("Failed to update data type {} to Graph. Status is {}", oldDataTypeDefinition, addPropertiesToDataType.right().value().name());
-// BeEcompErrorManager.getInstance().logBeFailedAddingNodeTypeError("UpdateDataType", "Property");
-// result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(addPropertiesToDataType.right().value()));
-// return result;
-// } else {
-//
-// Either<DataTypeDefinition, TitanOperationStatus> dataTypeByUid = this.getDataTypeByUid(oldDataTypeDefinition.getUniqueId());
-// if (dataTypeByUid.isRight()) {
-// TitanOperationStatus status = addPropertiesToDataType.right().value();
-// log.debug("Failed to get data type {} after update. Status is {}", oldDataTypeDefinition.getUniqueId(), status.name());
-// BeEcompErrorManager.getInstance().logBeFailedRetrieveNodeError("UpdateDataType", "Property", status.name());
-// result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status));
-// } else {
-// result = Either.left(dataTypeByUid.left().value());
-// }
-// }
-//
-// return result;
-//
-// }
-// }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1702/Migration1702.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1702/Migration1702.java
deleted file mode 100644
index 6fa8b45734..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1702/Migration1702.java
+++ /dev/null
@@ -1,1406 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1702;
-
-import java.io.BufferedWriter;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.Set;
-import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.math3.analysis.solvers.RiddersSolver;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
-import org.openecomp.sdc.be.components.impl.ImportUtils;
-import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
-import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaTagNamesEnum;
-import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
-import org.openecomp.sdc.be.config.BeEcompErrorManager;
-import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
-import org.openecomp.sdc.be.config.Configuration.VfModuleProperty;
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.graph.GraphElementFactory;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
-import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
-import org.openecomp.sdc.be.dao.neo4j.GraphEdgePropertiesDictionary;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentParametersView;
-import org.openecomp.sdc.be.model.DataTypeDefinition;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.GroupInstance;
-import org.openecomp.sdc.be.model.GroupProperty;
-import org.openecomp.sdc.be.model.GroupTypeDefinition;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Operation;
-import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.ResourceMetadataDefinition;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.ComponentInstanceOperation;
-import org.openecomp.sdc.be.model.operations.impl.ComponentOperation;
-import org.openecomp.sdc.be.model.operations.impl.GroupOperation;
-import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation;
-import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
-import org.openecomp.sdc.be.model.operations.impl.ResourceOperation;
-import org.openecomp.sdc.be.model.operations.impl.ServiceOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
-import org.openecomp.sdc.be.resources.data.ArtifactData;
-import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
-import org.openecomp.sdc.be.resources.data.ComponentMetadataData;
-import org.openecomp.sdc.be.resources.data.DataTypeData;
-import org.openecomp.sdc.be.resources.data.GroupData;
-import org.openecomp.sdc.be.resources.data.PropertyData;
-import org.openecomp.sdc.be.resources.data.PropertyValueData;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-import org.openecomp.sdc.be.resources.data.ServiceMetadataData;
-import org.openecomp.sdc.be.user.UserBusinessLogic;
-import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
-import org.openecomp.sdc.common.api.ArtifactTypeEnum;
-import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.util.ValidationUtils;
-import org.openecomp.sdc.exception.ResponseFormat;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.yaml.snakeyaml.Yaml;
-
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanGraphQuery;
-import com.thinkaurelius.titan.core.TitanVertex;
-
-import fj.data.Either;
-
-public class Migration1702 {
- private static final String CONFIG_GROUP_TYPES_YML = "/config/groupTypes.yml";
-
- private static final String CONFIG_DATA_TYPES_YML = "/config/dataTypes.yml";
-
- private static Logger log = LoggerFactory.getLogger(Migration1702.class.getName());
-
- @Autowired
- protected TitanGenericDao titanGenericDao;
- @Autowired
- protected ResourceOperation resourceOperation;
- @Autowired
- protected ServiceOperation serviceOperation;
- @Autowired
- private ServiceBusinessLogic serviceBusinessLogic;
- @Autowired
- private GroupTypeOperation groupTypeOperation;
- @Autowired
- private PropertyOperation propertyOperation;
- @Autowired
- private ComponentsUtils componentsUtils;
- @Autowired
- private GroupOperation groupOperation;
-
- @Autowired
- private ArtifactsBusinessLogic artifactsBusinessLogic;
-
- @Autowired
- private UserBusinessLogic userAdminManager;
-
- @Autowired
- private ComponentInstanceOperation componentInstanceOperation;
-
- public boolean migrate(String appConfigDir) {
- boolean result = true;
- String methodName = "alignCustomizationUUID";
-
- try {
- if (!alignCustomizationUUID()) {
- log.error("Failed to align customization UUID");
- result = false;
- return result;
- }
- methodName = "alignGroupDataType";
- if (!alignGroupDataType()) {
- log.error("Failed to align Group data type");
- result = false;
- return result;
- }
- methodName = "alignVfModuleProperties";
- if (!alignVfModuleProperties()) {
- log.error("Failed to align Vf Module Properties");
- result = false;
- return result;
- }
- methodName = "alignDataType";
- if (!alignDataType()) {
- log.error("Failed to align data type");
- result = false;
- return result;
- }
- methodName = "alignHeatEnv";
- if (!alignHeatEnv()) {
- log.error("Failed to align heat env on VF level");
- result = false;
- return result;
- }
- methodName = "alignModuleInstances";
- if (!alignModuleInstances()) {
- log.error("Failed to align module instances");
- result = false;
- return result;
- }
-
- } catch (Exception e) {
- log.error("Failed {} with exception: ", methodName, e);
- result = false;
- }
- return result;
- }
-
- private boolean alignModuleInstances() {
- log.info(" Align Module Instances");
- boolean result = true;
- boolean statusToReturn = true;
-
- Writer writer = null;
-
- try {
- long time = System.currentTimeMillis();
- writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("runstatusModules_" + time + ".csv"), "utf-8"));
-
- writer.write("resource id, instance id, group id, status\n");
-
- Either<List<ServiceMetadataData>, TitanOperationStatus> allServices = titanGenericDao.getByCriteria(NodeTypeEnum.Service, null, ServiceMetadataData.class);
- if (allServices.isRight()) {
- if (allServices.right().value() != TitanOperationStatus.NOT_FOUND) {
- log.error("Align heat env on Vf - Failed to fetch services {}", allServices.right().value());
- result = false;
- statusToReturn = false;
- return statusToReturn;
- } else {
- log.debug("No Services. ");
- return statusToReturn;
- }
- }
- log.info("Need to handle {} services", allServices.left().value().size());
- long handledServices = 0;
- for (ServiceMetadataData metadata : allServices.left().value()) {
- String serviceId = metadata.getMetadataDataDefinition().getUniqueId();
- Either<ImmutablePair<List<ComponentInstance>, List<RequirementCapabilityRelDef>>, TitanOperationStatus> riRes = componentInstanceOperation.getComponentInstancesOfComponent(serviceId, NodeTypeEnum.Service, NodeTypeEnum.Resource);
- if (riRes.isRight()) {
- if (riRes.right().value() == TitanOperationStatus.NOT_FOUND) {
- log.info("No instancces for service {}", serviceId);
- } else {
- log.info("Align vf modules - failed to fetch component instances for service {} error {}", riRes.right().value());
- writeModuleResultToFile(writer, serviceId, null, null, riRes.right().value());
- statusToReturn = false;
- }
- ++handledServices;
- continue;
- }
- List<ComponentInstance> componentInstances = riRes.left().value().left;
- for (ComponentInstance ci : componentInstances) {
- Either<TitanVertex, TitanOperationStatus> ciVertexRes = titanGenericDao.getVertexByProperty(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), ci.getUniqueId());
- if (ciVertexRes.isRight()) {
- log.info("Failed to fetch vertex for component instance {}, error {}", ci.getUniqueId(), ciVertexRes.right().value());
- writeModuleResultToFile(writer, serviceId, ci.getUniqueId(), null, ciVertexRes.right().value());
- statusToReturn = false;
- continue;
- }
- TitanVertex ciVertex = ciVertexRes.left().value();
- if (createGroupInstancesOnComponentInstance(writer, ci, ciVertex, serviceId) == false) {
- statusToReturn = false;
- continue;
- }
- }
- writer.flush();
- ++handledServices;
- }
-
- log.info("Handled {} services", handledServices);
- } catch (Exception e) {
- log.error("Failed {} with exception: ", "alignModuleInstances", e);
- result = false;
- statusToReturn = false;
- } finally {
-
- log.info(" Align Module Instances finished");
- if (!result) {
- log.info("Doing rollback");
- titanGenericDao.rollback();
- } else {
- log.info("Doing commit");
- titanGenericDao.commit();
- }
- try {
- writer.flush();
- writer.close();
- } catch (Exception ex) {
- /* ignore */}
- }
- return statusToReturn;
- }
-
- private boolean createGroupInstancesOnComponentInstance(Writer writer, ComponentInstance ci, TitanVertex ciVertex, String serviceId) {
- boolean statusToReturn = true;
-
- Map<String, Object> properties = titanGenericDao.getProperties(ciVertex);
- ComponentInstanceData createdComponentInstance = GraphElementFactory.createElement(NodeTypeEnum.ResourceInstance.getName(), GraphElementTypeEnum.Node, properties, ComponentInstanceData.class);
-
- Either<List<GroupDefinition>, TitanOperationStatus> groupEither = groupOperation.getAllGroupsFromGraph(ci.getComponentUid(), NodeTypeEnum.Resource);
- if (groupEither.isRight()) {
- if (groupEither.right().value() != TitanOperationStatus.OK && groupEither.right().value() != TitanOperationStatus.NOT_FOUND) {
- TitanOperationStatus status = groupEither.right().value();
- log.error("Failed to associate group instances to component instance {}. Status is {}", ci.getUniqueId(), status);
- writeModuleResultToFile(writer, serviceId, ci.getUniqueId(), null, status);
- return false;
- } else {
- log.debug("No groups for component instance {}. ", ci.getUniqueId());
-
- writeModuleResultToFile(writer, serviceId, ci.getUniqueId(), null, "No groups");
- return true;
- }
- }
- List<GroupDefinition> groupsIמResource = groupEither.left().value();
- if (groupsIמResource != null && !groupsIמResource.isEmpty()) {
- List<GroupDefinition> vfGroupsListInResource = groupsIמResource.stream().filter(p -> p.getType().equals("org.openecomp.groups.VfModule")).collect(Collectors.toList());
-
- for (GroupDefinition groupInResource : vfGroupsListInResource) {
- Iterator<Edge> edgesToInstances = ciVertex.edges(Direction.OUT, GraphEdgeLabels.GROUP_INST.getProperty());
- boolean exist = false;
- String normalizedName = ValidationUtils.normalizeComponentInstanceName(ci.getNormalizedName() + ".." + groupInResource.getName());
- String grInstId = UniqueIdBuilder.buildResourceInstanceUniuqeId(ci.getUniqueId(), groupInResource.getUniqueId(), normalizedName);
-
-
- while (edgesToInstances.hasNext()) {
- Edge edgeToInst = edgesToInstances.next();
- Vertex grInstVertex = edgeToInst.inVertex();
- String grId = (String) titanGenericDao.getProperty((TitanVertex) grInstVertex, GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- if (grId.equals(grInstId)) {
- exist = true;
- break;
- }
- }
- if (!exist) {
- Either<GroupInstance, StorageOperationStatus> status = componentInstanceOperation.createGroupInstance(ciVertex, groupInResource, ci);
- if (status.isRight()) {
- log.error("Failed to create group instance {} in component instance {}. Status is {}", grInstId, ci.getUniqueId(), status.right().value());
- statusToReturn = false;
- writeModuleResultToFile(writer, serviceId, ci.getUniqueId(), grInstId, status.right().value());
- } else {
- writeModuleResultToFile(writer, serviceId, ci.getUniqueId(), grInstId, "OK");
- }
- } else {
- writeModuleResultToFile(writer, serviceId, ci.getUniqueId(), grInstId, "Exist");
- }
-
- }
- }
- return statusToReturn;
- }
-
- @SuppressWarnings("resource")
- private boolean alignHeatEnv() {
- Writer writer = null;
- log.info(" Align heat env on Vf level");
- boolean statusToReturn = true;
-
- boolean result = true;
- try {
- long time = System.currentTimeMillis();
- writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("runstatusEnv_" + time + ".csv"), "utf-8"));
-
- writer.write("resource id, operation, artifact id, status\n");
- User user = buildDummyUser();
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty(), ResourceTypeEnum.VF.name());
-
- Either<List<ResourceMetadataData>, TitanOperationStatus> allResources = titanGenericDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
- if (allResources.isRight()) {
- if (allResources.right().value() != TitanOperationStatus.NOT_FOUND) {
- log.error("Align heat env on Vf - Failed to fetch resources {}", allResources.right().value());
- statusToReturn = false;
- result = false;
- return statusToReturn;
- } else {
- log.debug("No VF resources. ");
- return result;
- }
- }
- List<ResourceMetadataData> resources = allResources.left().value();
- log.debug("Need to handle {} resources", resources.size());
-
- long totalHandledArtifacts = 0;
- for (ResourceMetadataData metadata : resources) {
- Either<List<ImmutablePair<ArtifactData, GraphEdge>>, TitanOperationStatus> artifactNodesRes = titanGenericDao.getChildrenNodes(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), (String) metadata.getUniqueId(),
- GraphEdgeLabels.ARTIFACT_REF, NodeTypeEnum.ArtifactRef, ArtifactData.class);
- if (artifactNodesRes.isRight()) {
- if (artifactNodesRes.right().value() != TitanOperationStatus.NOT_FOUND) {
- log.error("Align heat env on Vf - Failed to fetch artifacts for resources {}", metadata.getUniqueId(), artifactNodesRes.right().value());
- writer.write(metadata.getUniqueId() + ",get artifacts, ,Failed to fetch artifacts " + artifactNodesRes.right().value() + "\n");
- statusToReturn = false;
- continue;
- } else {
- log.debug("No artifact for resource {} . ", metadata.getUniqueId());
- writer.write(metadata.getUniqueId() + ",get artifacts, ,No artfacts\n");
- continue;
- }
- }
- List<ImmutablePair<ArtifactData, GraphEdge>> artifacts = artifactNodesRes.left().value();
-
- for (ImmutablePair<ArtifactData, GraphEdge> pair : artifacts) {
- ArtifactData artifactData = pair.left;
- if (isNeedCreatePlaceHolder(artifactData)) {
- // check if exist heat env - if not -> create
- String heatEnvId = (String) artifactData.getUniqueId() + "env";
- if (validateOrCreateHeatEnv(user, metadata, artifactData, heatEnvId, writer) == false) {
- statusToReturn = false;
- }
- // check if connected to group - if not -> connect
- if (validateOrAssociateHeatAnv(metadata, artifactData, heatEnvId, writer) == false) {
- statusToReturn = false;
- }
- ++totalHandledArtifacts;
- writer.flush();
- }
-
- }
- }
- log.debug("Total handled {} artifacts", totalHandledArtifacts);
- } catch (Exception e) {
- log.error("Failed {} with exception: ", "alignHeatEnv", e);
- result = false;
- } finally {
-
- log.info("Aling heat env on VF level finished ");
- if (!result) {
- log.info("Doing rollback");
- titanGenericDao.rollback();
- } else {
- log.info("Doing commit");
- titanGenericDao.commit();
- }
- try {
- writer.flush();
- writer.close();
- } catch (Exception ex) {
- /* ignore */}
- }
- return statusToReturn;
- }
-
- private boolean validateOrAssociateHeatAnv(ResourceMetadataData metadata, ArtifactData artifactData, String heatEnvId, Writer writer) {
- boolean statusToReturn = true;
-
- String resourceId = (String) metadata.getUniqueId();
- Either<ArtifactData, TitanOperationStatus> heatEnvArtifactRes = titanGenericDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), heatEnvId, ArtifactData.class);
- if (heatEnvArtifactRes.isRight()) {
- log.error("Align heat env on Vf - Failed to fetch heat env node for id {} {}", heatEnvId, heatEnvArtifactRes.right().value());
- writeResultToFile(writer, "get artifact node for relation", resourceId, heatEnvId, heatEnvArtifactRes.right().value());
- return false;
- }
- ArtifactData heatEnvArtifact = heatEnvArtifactRes.left().value();
-
- Either<List<ImmutablePair<GroupData, GraphEdge>>, TitanOperationStatus> groupsForHeatRes = titanGenericDao.getParentNodes(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), (String) artifactData.getUniqueId(),
- GraphEdgeLabels.GROUP_ARTIFACT_REF, NodeTypeEnum.Group, GroupData.class);
- if (groupsForHeatRes.isRight()) {
- writeResultToFile(writer, "getChildrenNodes groups for heat", resourceId, (String) artifactData.getUniqueId(), groupsForHeatRes.right().value());
- if (groupsForHeatRes.right().value() != TitanOperationStatus.NOT_FOUND) {
- log.error("Align heat env on Vf - Failed to fetch groups for heat artifact {} in resources {} : {}", artifactData.getUniqueId(), metadata.getUniqueId(), groupsForHeatRes.right().value());
- return false;
- } else {
- log.debug("Align heat env on Vf - No groups for heat artifact {} in resources {} : {}", artifactData.getUniqueId(), metadata.getUniqueId(), groupsForHeatRes.right().value());
- return true;
- }
- }
- List<ImmutablePair<GroupData, GraphEdge>> groupsForHeat = groupsForHeatRes.left().value();
- Either<List<ImmutablePair<GroupData, GraphEdge>>, TitanOperationStatus> groupsForHeatEnvRes = titanGenericDao.getParentNodes(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), heatEnvId, GraphEdgeLabels.GROUP_ARTIFACT_REF, NodeTypeEnum.Group,
- GroupData.class);
- List<ImmutablePair<GroupData, GraphEdge>> groupsForHeatEnv;
- if (groupsForHeatEnvRes.isRight()) {
- if (groupsForHeatEnvRes.right().value() != TitanOperationStatus.NOT_FOUND) {
- log.error("Align heat env on Vf - Failed to fetch groups for heat env artifact {} in resources {} : ", artifactData.getUniqueId(), metadata.getUniqueId(), groupsForHeatEnvRes.right().value());
- writeResultToFile(writer, "getChildrenNodes groups for heat env", resourceId, heatEnvId, groupsForHeatEnvRes.right().value());
- return false;
- } else {
- groupsForHeatEnv = new ArrayList<>();
- }
- } else {
- groupsForHeatEnv = groupsForHeatEnvRes.left().value();
- }
-
- for (ImmutablePair<GroupData, GraphEdge> heatGroup : groupsForHeat) {
- // check if exist
- boolean exist = false;
- GroupDataDefinition groupDataDefinition = heatGroup.left.getGroupDataDefinition();
- for (ImmutablePair<GroupData, GraphEdge> heatEnvGroup : groupsForHeatEnv) {
- if (groupDataDefinition.getName().equals(heatEnvGroup.left.getGroupDataDefinition().getName())) {
- exist = true;
- break;
- }
- }
- String groupId = (String) heatGroup.left.getUniqueId();
- if (!exist) {
- // need associate
-
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put(GraphPropertiesDictionary.NAME.getProperty(), heatEnvArtifact.getLabel());
- Either<GraphRelation, TitanOperationStatus> createRelation = titanGenericDao.createRelation(heatGroup.left, heatEnvArtifact, GraphEdgeLabels.GROUP_ARTIFACT_REF, properties);
- log.trace("After associate group {} to artifact {}", groupDataDefinition.getName(), heatEnvArtifact.getUniqueIdKey());
- if (createRelation.isRight()) {
- log.error("Align heat env on Vf - Failed to associate heat env artifact {} to group {} : {}", artifactData.getUniqueId(), groupDataDefinition.getUniqueId(), createRelation.right().value());
-
- writeResultToFile(writer, "associate to group- relation" + groupId, resourceId, heatEnvId, groupsForHeatRes.right().value());
- statusToReturn = false;
- } else {
- writeResultToFile(writer, "associate to group " + groupId, resourceId, heatEnvId, "OK");
- }
- } else {
- writeResultToFile(writer, "associate group " + groupId, resourceId, heatEnvId, "Exist");
- }
- }
- return statusToReturn;
- }
-
- private boolean validateOrCreateHeatEnv(User user, ResourceMetadataData metadata, ArtifactData artifactData, String heatEnvId, Writer writer) {
- String resourceId = metadata.getMetadataDataDefinition().getUniqueId();
- boolean statusToReturn = true;
- Either<ArtifactData, TitanOperationStatus> node = titanGenericDao.getNode(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), heatEnvId, ArtifactData.class);
- boolean isContinue = true;
- if (node.isRight()) {
- if (TitanOperationStatus.NOT_FOUND == node.right().value()) {
- // create
- ArtifactDefinition heatArtifact = new ArtifactDefinition(artifactData.getArtifactDataDefinition());
- ResourceMetadataDefinition resourceMetadataDataDefinition = new ResourceMetadataDefinition((ResourceMetadataDataDefinition) metadata.getMetadataDataDefinition());
-
- Resource resource = new Resource(resourceMetadataDataDefinition);
-
- String heatUpdater = heatArtifact.getUserIdLastUpdater();
- Either<User, ActionStatus> userHeat = userAdminManager.getUser(heatUpdater, true);
-
- Either<ArtifactDefinition, ResponseFormat> createHeatEnvPlaceHolder = artifactsBusinessLogic.createHeatEnvPlaceHolder(heatArtifact, ArtifactsBusinessLogic.HEAT_VF_ENV_NAME, (String) metadata.getUniqueId(), NodeTypeEnum.Resource,
- metadata.getMetadataDataDefinition().getName(), userHeat.left().value(), resource, null, false);
- if (createHeatEnvPlaceHolder.isRight()) {
- log.error("Align heat env on Vf - Failed to create heat env {} for heat {} : {}", heatEnvId, heatArtifact.getUniqueId(), createHeatEnvPlaceHolder.right().value().getText());
- writeResultToFile(writer, "create placeholder", resourceId, heatEnvId, createHeatEnvPlaceHolder.right().value().getText());
- isContinue = false;
- statusToReturn = false;
- } else {
- writeResultToFile(writer, "create placeholder", resourceId, heatEnvId, "OK");
- }
- } else {
- log.error("Align heat env on Vf - Failed to fetch heat env node for id {} {}", heatEnvId, node.right().value());
- writeResultToFile(writer, "create placeholder - get", resourceId, heatEnvId, node.right().value());
- isContinue = false;
- statusToReturn = false;
- }
- } else {
- writeResultToFile(writer, "create placeholder - get", resourceId, heatEnvId, "Exist");
- }
- if (isContinue) {
- log.debug("associate heat env artifact to all resources ");
- String heatUniqueId = (String) artifactData.getUniqueId();
- Either<TitanVertex, TitanOperationStatus> heatVertexRes = titanGenericDao.getVertexByProperty(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), heatUniqueId);
- if (heatVertexRes.isRight()) {
- log.debug("Failed to fetch vertex for heat {} error {}", heatUniqueId, heatVertexRes.right().value());
- writeResultToFile(writer, "create placeholder - get heat vertex", resourceId, heatEnvId, heatVertexRes.right().value());
- statusToReturn = false;
- return statusToReturn;
- }
- TitanVertex heatVertex = heatVertexRes.left().value();
- Either<TitanVertex, TitanOperationStatus> heatEnvVertexRes = titanGenericDao.getVertexByProperty(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), heatEnvId);
- if (heatEnvVertexRes.isRight()) {
- log.debug("Failed to fetch vertex for heat env {} error {}", heatEnvId, heatEnvVertexRes.right().value());
- writeResultToFile(writer, "create placeholder - get heat env vertex", resourceId, heatEnvId, heatEnvVertexRes.right().value());
- statusToReturn = false;
- return statusToReturn;
- }
-
- Vertex heatEnvVertex = heatEnvVertexRes.left().value();
- Iterator<Edge> edgesToHeat = heatVertex.edges(Direction.IN, GraphEdgeLabels.ARTIFACT_REF.name());
- while (edgesToHeat.hasNext()) {
- Edge edgeToHeat = edgesToHeat.next();
- boolean exist = false;
- Vertex outVertexHeat = edgeToHeat.outVertex();
- Map<String, Object> outVertexProps = titanGenericDao.getProperties(outVertexHeat);
-
- String resIdToHeat = (String) outVertexProps.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty());
-
- Iterator<Edge> edgesToEnv = heatEnvVertex.edges(Direction.IN, GraphEdgeLabels.ARTIFACT_REF.name());
- while (edgesToEnv.hasNext()) {
- Edge edgeToEnv = edgesToEnv.next();
- Vertex outVertexEnv = edgeToEnv.outVertex();
- String resIdToEnv = (String) titanGenericDao.getProperty((TitanVertex) outVertexEnv, GraphPropertiesDictionary.UNIQUE_ID.getProperty());
- if (resIdToHeat.equals(resIdToEnv)) {
- exist = true;
- break;
- }
- }
- if (!exist) {
- Map<String, Object> properties = titanGenericDao.getProperties(edgeToHeat);
- // need to associate additional resource to heat env
- // update artifact label on edge
- String heatEnvLabel = (String) titanGenericDao.getProperty((TitanVertex) heatEnvVertex, GraphPropertiesDictionary.ARTIFACT_LABEL.getProperty());
- properties.put(GraphEdgePropertiesDictionary.NAME.getProperty(), heatEnvLabel);
-
- TitanOperationStatus createEdge = titanGenericDao.createEdge(outVertexHeat, heatEnvVertex, GraphEdgeLabels.ARTIFACT_REF, properties);
- if (createEdge == TitanOperationStatus.OK) {
- writeResultToFile(writer, "associate to resource " + resIdToHeat, resourceId, heatEnvId, "OK");
- } else {
- writeResultToFile(writer, "associate to resource " + resIdToHeat, resourceId, heatEnvId, createEdge);
- statusToReturn = false;
- }
- } else {
- writeResultToFile(writer, "associate to resource " + resIdToHeat, resourceId, heatEnvId, "Exist");
- }
- }
- }
- return statusToReturn;
- }
-
- private void writeResultToFile(Writer writer, String op, String resourceId, String artifactD, Object status) {
- try {
- StringBuffer sb = new StringBuffer(resourceId);
- sb.append(",").append(op).append(",").append(artifactD).append(",").append(status).append("\n");
- writer.write(sb.toString());
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- private void writeModuleResultToFile(Writer writer, String resourceId, String instanceId, String groupId, Object status) {
- try {
- StringBuffer sb = new StringBuffer(resourceId);
- sb.append(",").append(instanceId).append(",").append(groupId).append(",").append(status).append("\n");
- writer.write(sb.toString());
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- private boolean isNeedCreatePlaceHolder(ArtifactData artifactData) {
- String artifactType = artifactData.getArtifactDataDefinition().getArtifactType();
- ArtifactTypeEnum type = ArtifactTypeEnum.findType(artifactType);
- if (ArtifactGroupTypeEnum.DEPLOYMENT == artifactData.getArtifactDataDefinition().getArtifactGroupType() && (ArtifactTypeEnum.HEAT == type || ArtifactTypeEnum.HEAT_NET == type || ArtifactTypeEnum.HEAT_VOL == type)) {
- return true;
- }
- return false;
- }
-
- private boolean alignVfModuleProperties() {
- boolean result = true;
- try {
- log.info(" Align Vf module properties");
-
- final Pattern pattern = Pattern.compile("\\..(.*?)\\..");
- final String LABEL_NAME = "vf_module_label";
- final String VOLUME_GROUP_NAME = "volume_group";
-
- Either<TitanGraph, TitanOperationStatus> graph = titanGenericDao.getGraph();
- if (graph.isRight()) {
- log.error("Align Vf module properties - Failed to get graph {}", graph.right().value());
- result = false;
- return result;
- }
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty(), ResourceTypeEnum.VF.name());
-
- Either<List<ResourceMetadataData>, TitanOperationStatus> allResources = titanGenericDao.getByCriteria(NodeTypeEnum.Resource, props, ResourceMetadataData.class);
-
- if (allResources.isRight()) {
- if (allResources.right().value().equals(TitanOperationStatus.NOT_FOUND)) {
- log.debug("Align Vf module properties - no VF resources");
- result = true;
- return result;
- } else {
- log.error("Align Vf module properties - generateTosca failed fetch all resources,error {}", allResources.right().value());
- result = false;
- return result;
- }
- }
-
- List<ResourceMetadataData> listAllVFs = allResources.left().value();
-
- ComponentParametersView componentParametersView = new ComponentParametersView(true);
- componentParametersView.setIgnoreGroups(false);
- componentParametersView.setIgnoreArtifacts(false);
-
- log.info("Align Vf module properties - Starting to update the VF's");
- Map<String, VfModuleProperty> vfModuleProperties = ConfigurationManager.getConfigurationManager().getConfiguration().getVfModuleProperties();
- for (ResourceMetadataData resourceMetadataData : listAllVFs) {
- String uniqueId = (String) resourceMetadataData.getUniqueId();
-
- Either<Resource, StorageOperationStatus> resourceResponse = resourceOperation.getResource(uniqueId, componentParametersView, true);
-
- if (resourceResponse.isRight()) {
- log.error("Align Vf module properties - failed resource with UniqueID: {} , error {}", uniqueId, resourceResponse.right().value());
- result = false;
- return result;
- }
-
- Resource resource = resourceResponse.left().value();
- List<GroupDefinition> groups = resource.getGroups();
-
- if (groups == null || groups.isEmpty()) {
- log.debug("Align Vf module properties - resource UniqueID: {} does not contain groups", resource.getUniqueId());
- continue;
- } else {
-
- for (GroupDefinition groupDefinition : groups) {
-
- if (groupDefinition.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)) {
- log.info("update vf module proerties for group {} ", groupDefinition.getUniqueId());
-
- List<GroupProperty> properties = groupDefinition.convertToGroupProperties();
- if (properties == null) {
- properties = new ArrayList<>();
- }
- Boolean isBase = false;
- List<String> artifacts = groupDefinition.getArtifacts();
- if (artifacts == null) {
- artifacts = new ArrayList<>();
- }
- Boolean isVolumeGroup = false;
- for (String artifactId : artifacts) {
- ArtifactDefinition artifactDef = null;
- Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts();
- artifactDef = findArtifactInList(deploymentArtifacts, artifactId);
- if (artifactDef != null && artifactDef.getArtifactType().equalsIgnoreCase(ArtifactTypeEnum.HEAT_VOL.getType())) {
- isVolumeGroup = true;
- break;
- }
- }
- for (GroupProperty groupProperty : properties) {
- if (groupProperty.getName().equals(Constants.IS_BASE)) {
- isBase = Boolean.valueOf(groupProperty.getValue());
- break;
- }
- }
-
- if (null == isBase) {
- log.error("Align Vf module properties - isBase not found in DEFAULT_GROUP_VF_MODULE");
- result = false;
- return result;
- }
-
- String vfModuleLabel = null;
- String moduleName = groupDefinition.getName();
- Matcher matcher = pattern.matcher(moduleName);
-
- if (matcher.find()) {
- vfModuleLabel = matcher.group(1);
- } else {
- vfModuleLabel = moduleName;
- }
-
- boolean isBasePrimitive = isBase;
- boolean isVolumeGroupPrimitive = isVolumeGroup;
- String vfModuleLabelFinal = vfModuleLabel;
- List<GroupProperty> propertiesToAdd = new ArrayList<>();
- properties.stream().forEach(p -> {
- if (p.getValueUniqueUid() == null) {
- if (vfModuleProperties.containsKey(p.getName())) {
- if (isBasePrimitive) {
- p.setValue(vfModuleProperties.get(p.getName()).getForBaseModule());
- } else {
- p.setValue(vfModuleProperties.get(p.getName()).getForNonBaseModule());
- }
- } else if (p.getName().equals(VOLUME_GROUP_NAME)) {
- p.setValue(String.valueOf(isVolumeGroupPrimitive));
- } else if (p.getName().equals(LABEL_NAME)) {
- p.setValue(vfModuleLabelFinal);
- }
- propertiesToAdd.add(p);
- }
-
- });
-
- List<GroupProperty> propertiesAlreadyExistOnGraph = properties.stream().filter(p -> !(p.getValueUniqueUid() == null || p.getValueUniqueUid().isEmpty())).collect(Collectors.toList());
- int numOfPropertiesAlreadyExist = propertiesAlreadyExistOnGraph.size();
-
- log.debug("Need to update default values vfModule {} properties {} ", properties.size(), properties);
-
- Either<GroupTypeDefinition, TitanOperationStatus> groupTypeRes = groupTypeOperation.getGroupTypeByUid(groupDefinition.getTypeUid());
- if (groupTypeRes.isRight()) {
- TitanOperationStatus operationStatus = groupTypeRes.right().value();
- log.debug("Failed to find group type {}",groupDefinition.getTypeUid());
- if (operationStatus == TitanOperationStatus.NOT_FOUND) {
- result = false;
- return result;
- }
- }
-
- GroupTypeDefinition groupTypeDefinition = groupTypeRes.left().value();
- List<PropertyDefinition> groupTypeProperties = groupTypeDefinition.getProperties();
- Map<String, PropertyDefinition> groupTypePropertiesMap = groupTypeProperties.stream().collect(Collectors.toMap(p -> p.getName(), p -> p));
-
- int i = numOfPropertiesAlreadyExist + 1;
- for (GroupProperty prop : propertiesToAdd) {
- if (prop.getUniqueId() == null || prop.getUniqueId().isEmpty()) {
- continue;
- }
- GroupData groupData = new GroupData(groupDefinition);
-
- Either<PropertyValueData, TitanOperationStatus> addPropertyToGroup = groupOperation.addPropertyToGroup(groupData, prop, groupTypePropertiesMap.get(prop.getName()), i);
- if (addPropertyToGroup.isRight()) {
- log.info("Failed to add properties {} to group type :{} error {} ", prop.getName(), groupData.getUniqueId(), addPropertyToGroup.right().value());
- result = false;
- return result;
- }
- ++i;
- }
- }
- }
- }
- }
- } catch (Exception e) {
- log.error("Failed {} with exception: ", "alignVfModuleProperties", e);
- result = false;
- } finally {
- log.info(" Align Vf module properties finished");
- if (!result) {
- log.info("Doing rollback");
- titanGenericDao.rollback();
- } else {
- log.info("Doing commit");
- titanGenericDao.commit();
- }
- }
- return true;
- }
-
- private ArtifactDefinition findArtifactInList(Map<String, ArtifactDefinition> deploymentArtifacts, String artifactId) {
- Optional<ArtifactDefinition> op = deploymentArtifacts.values().stream().filter(p -> p.getUniqueId().equals(artifactId)).findAny();
- if (op.isPresent())
- return op.get();
- return null;
- }
-
- private boolean generateTosca() {
- log.info("Regenerate Tosca and CSAR for VFs and Services");
- Either<TitanGraph, TitanOperationStatus> graph = titanGenericDao.getGraph();
- if (graph.isRight()) {
- log.error("Failed to get graph {}", graph.right().value());
- return false;
- }
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty(), ResourceTypeEnum.VF.name());
-
- User user = buildDummyUser();
-
- Map<String, Object> propsHasNot = new HashMap<String, Object>();
- propsHasNot.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- propsHasNot.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
-
- Either<List<ResourceMetadataData>, TitanOperationStatus> allResources = titanGenericDao.getByCriteria(NodeTypeEnum.Resource, props, propsHasNot, ResourceMetadataData.class);
- if (allResources.isRight()) {
- if (allResources.right().value().equals(TitanOperationStatus.NOT_FOUND)) {
- log.debug("generateTosca - no VF resources");
- } else {
- log.info("generateTosca failed fetch all resources,error {}", allResources.right().value());
- return false;
- }
- } else {
- if (!handleComponents(user, allResources.left().value(), resourceOperation)) {
- log.info("generateTosca failed generate tosca artifacts for resources");
- return false;
-
- }
- }
- Either<List<ServiceMetadataData>, TitanOperationStatus> allServices = titanGenericDao.getByCriteria(NodeTypeEnum.Service, null, propsHasNot, ServiceMetadataData.class);
- if (allServices.isRight()) {
- if (allServices.right().value() == TitanOperationStatus.NOT_FOUND) {
- log.debug("generateTosca - no services");
-
- } else {
- log.debug("generateTosca failed fetch all services,error {}",allServices.right().value());
- return false;
- }
- } else {
- if (!handleComponents(user, allServices.left().value(), serviceOperation)) {
- log.info("generateTosca failed generate tosca artifacts for services");
- return false;
-
- }
- }
- log.info("Regenerate Tosca and CSAR for VFs and Services finished");
- return true;
- }
-
- private <T extends ComponentMetadataData> boolean handleComponents(User user, List<T> allResources, ComponentOperation operation) {
- for (ComponentMetadataData resource : allResources) {
- if (resource.getMetadataDataDefinition().isDeleted() == null || !resource.getMetadataDataDefinition().isDeleted()) {
- Either<Component, StorageOperationStatus> component = operation.getComponent((String) resource.getUniqueId(), true);
- if (component.isRight()) {
- log.info("generateTosca failed fetch component with id {} , error {}", (String) resource.getUniqueId(), component.right().value());
- return false;
- }
- if (populateToscaArtifactsWithLog(component.left().value(), user) != ActionStatus.OK) {
- return false;
- }
- }
- }
- return true;
- }
-
- private boolean alignCustomizationUUID() {
- boolean result = true;
- try {
- log.info("Update customization UUID for all component instances on graph");
- Either<TitanGraph, TitanOperationStatus> graph = titanGenericDao.getGraph();
- if (graph.isRight()) {
- log.error("Failed to get graph {}", graph.right().value());
- return result;
- }
- TitanGraph tGraph = graph.left().value();
- TitanGraphQuery<? extends TitanGraphQuery> query = tGraph.query();
- query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), NodeTypeEnum.ResourceInstance.getName());
- Iterable<TitanVertex> vertices = query.vertices();
- if (vertices == null) {
- log.info("No component instances on graph");
- return result;
- }
- Iterator<TitanVertex> iterator = vertices.iterator();
- if (!iterator.hasNext()) {
- log.info("No component instances on graph");
- }
- while (iterator.hasNext()) {
- TitanVertex vertex = iterator.next();
- String property = (String) titanGenericDao.getProperty(vertex, GraphPropertiesDictionary.CUSTOMIZATION_UUID.getProperty());
- if (!ValidationUtils.validateStringNotEmpty(property)) {
- UUID uuid = UUID.randomUUID();
- vertex.property(GraphPropertiesDictionary.CUSTOMIZATION_UUID.getProperty(), uuid.toString());
- }
- }
- } catch (Exception e) {
- log.error("Failed {} with exception: ", "alignCustomizationUUID", e);
- result = false;
- } finally {
- log.info("Update customization UUID finished ");
- if (!result) {
- log.info("Doing rollback");
- titanGenericDao.rollback();
- } else {
- log.info("Doing commit");
- titanGenericDao.commit();
- }
- }
- return result;
- }
-
- private ActionStatus populateToscaArtifactsWithLog(Component component, User user) {
- ActionStatus ret = ActionStatus.OK;
- LifecycleStateEnum lifecycleState = component.getLifecycleState();
- if (!needRegenarateTosca(lifecycleState)) {
- log.debug("Component {} is in state {}, don't generatate Tosca", component.getUniqueId(), lifecycleState);
- return ret;
- }
-
- try {
- Either<Either<ArtifactDefinition, Operation>, ResponseFormat> populateToscaArtifacts = serviceBusinessLogic.populateToscaArtifacts(component, user, true, false, true, true);
- if (populateToscaArtifacts.isLeft()) {
- log.debug("Added payload to tosca artifacts of component {} of type:{} with uniqueId:{}", component.getName(), component.getComponentType().getValue(), component.getUniqueId());
- } else {
- log.error("Failed to generate TOSCA artifacts for component {} of type:{} with uniqueId:{}", component.getName(), component.getComponentType().name(), component.getUniqueId());
- return ActionStatus.GENERAL_ERROR;
- }
- return ret;
- } catch (Exception e) {
- log.error("Exception Occured When filling tosca artifact payload for component {} of type:{} with uniqueId:{}", component.getName(), component.getComponentType().name(), component.getUniqueId(), e);
- return ActionStatus.GENERAL_ERROR;
- }
- }
-
- private boolean needRegenarateTosca(LifecycleStateEnum lifecycleState) {
- if (lifecycleState == LifecycleStateEnum.READY_FOR_CERTIFICATION || lifecycleState == LifecycleStateEnum.CERTIFICATION_IN_PROGRESS || lifecycleState == LifecycleStateEnum.CERTIFIED) {
- return true;
- }
- return false;
- }
-
- private User buildDummyUser() {
- User user = new User();
- user.setUserId("migrationTask");
- return user;
- }
-
- private boolean alignGroupDataType() {
- boolean result = true;
- try {
- log.info(" Align group data type properties");
- String categoryMigrationFile = CONFIG_GROUP_TYPES_YML;
- String yamlAsString;
- try {
-
- InputStream inputStream = getClass().getResourceAsStream(categoryMigrationFile);
- if (inputStream == null) {
- log.info("Failed to load input file : {}", categoryMigrationFile);
- result = false;
- return result;
- }
- yamlAsString = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
-
- } catch (Exception e) {
- log.info("Failed to load group types file exception : ", e);
- result = false;
- return result;
- }
-
- log.debug("received yaml: {}", yamlAsString);
-
- Map<String, Object> toscaJson = (Map<String, Object>) new Yaml().load(yamlAsString);
-
- if (toscaJson == null || toscaJson.isEmpty()) {
- log.info("group types file is empty");
- result = false;
- return result;
- }
-
- Map<String, Object> vfModule = (Map<String, Object>) toscaJson.get("org.openecomp.groups.VfModule");
- if (vfModule == null || vfModule.isEmpty()) {
- log.info("No vfModule in group types file");
- result = false;
- return result;
- }
- Map<String, Object> properties = (Map<String, Object>) vfModule.get("properties");
- if (properties == null || properties.isEmpty()) {
- log.info("No properties for vfModule in group types file");
- result = false;
- return result;
- }
- Either<GroupTypeDefinition, StorageOperationStatus> latestGroupTypeByType = groupTypeOperation.getLatestGroupTypeByType("org.openecomp.groups.VfModule", true);
- if (latestGroupTypeByType.isRight()) {
- log.info("Failed to fetch org.openecomp.groups.VfModule group type, error :{}", latestGroupTypeByType.right().value());
- result = false;
- return result;
- }
- GroupTypeDefinition groupTypeInGraph = latestGroupTypeByType.left().value();
- List<PropertyDefinition> propertiesInGraph = groupTypeInGraph.getProperties();
-
- List<PropertyDefinition> propertiesToAdd = new ArrayList<>();
-
- properties.entrySet().stream().filter(e -> !ifExistOnGraph(e.getKey(), propertiesInGraph)).forEach(fe -> {
- PropertyDefinition property = new PropertyDefinition();
- property.setName(fe.getKey());
- Map<String, Object> definitionInYaml = (Map<String, Object>) fe.getValue();
- property.setType((String) definitionInYaml.get("type"));
- property.setRequired((Boolean) definitionInYaml.get("required"));
- property.setDescription((String) definitionInYaml.get("description"));
- String defaultValue = definitionInYaml.get("default") == null ? null : definitionInYaml.get("default").toString();
- if (defaultValue != null) {
- property.setDefaultValue(defaultValue);
- }
- propertiesToAdd.add(property);
- });
-
- if (!propertiesToAdd.isEmpty()) {
- log.debug("Need to add to vfModule {} properties {} ", propertiesToAdd.size(), propertiesToAdd);
-
- Either<Map<String, PropertyData>, TitanOperationStatus> addPropertiesToCapablityType = propertyOperation.addPropertiesToElementType(groupTypeInGraph.getUniqueId(), NodeTypeEnum.GroupType, propertiesToAdd);
- if (addPropertiesToCapablityType.isRight()) {
- log.info("Failed to add properties to group type :{}", addPropertiesToCapablityType.right().value());
- result = false;
- return result;
- }
- } else {
- log.debug("No properties to add to vfModule");
- }
-
- } catch (Exception e) {
- log.error("Failed {} with exception: ", "alignGroupDataType", e);
- result = false;
- } finally {
- log.info(" Align group data type properties finished");
- if (!result) {
- log.info("Doing rollback");
- titanGenericDao.rollback();
- } else {
- log.info("Doing commit");
- titanGenericDao.commit();
- }
- }
- return result;
- }
-
- private boolean ifExistOnGraph(String name, List<PropertyDefinition> propertiesInGraph) {
- for (PropertyDefinition pd : propertiesInGraph) {
- if (pd.getName().equals(name)) {
- return true;
- }
- }
- return false;
- }
-
- public boolean alignDataType() {
-
- log.info(" Align data type properties");
-
- boolean isSuccessful = true;
- List<DataTypeDefinition> dataTypes = extractDataTypesFromYaml();
-
- if (CollectionUtils.isEmpty(dataTypes)) {
- isSuccessful = false;
- }
-
- List<ImmutablePair<DataTypeDefinition, Boolean>> createdElementTypes = new ArrayList<>();
-
- Iterator<DataTypeDefinition> elementTypeItr = dataTypes.iterator();
- if (isSuccessful) {
- try {
- while (elementTypeItr.hasNext()) {
- DataTypeDefinition elementType = elementTypeItr.next();
- String elementName = elementType.getName();
- Either<ActionStatus, ResponseFormat> validateElementType = validateDataType(elementType);
- if (validateElementType.isRight()) {
- log.debug("Failed to validate data type {}. Status is {}. ", elementName, validateElementType.right().value());
- isSuccessful = false;
- break;
- }
- log.debug("Going to get data type by name {}. ", elementName);
- Either<DataTypeDefinition, StorageOperationStatus> findElementType = propertyOperation.getDataTypeByNameWithoutDerived(elementName);
- if (findElementType.isRight()) {
- StorageOperationStatus status = findElementType.right().value();
- if (status != StorageOperationStatus.NOT_FOUND) {
- log.debug("Failed to fetch data type {}. Status is {}. ", elementName, validateElementType.right().value());
- isSuccessful = false;
- break;
- } else {
- log.debug("Going to add data type with name {}. ", elementName);
- Either<DataTypeDefinition, StorageOperationStatus> dataModelResponse = propertyOperation.addDataType(elementType);
-
- if (dataModelResponse.isRight()) {
- if (dataModelResponse.right().value() != StorageOperationStatus.SCHEMA_VIOLATION) {
- log.debug("Failed to add data type {}. Status is {}. ", elementName, dataModelResponse.right().value());
- isSuccessful = false;
- break;
- } else {
- createdElementTypes.add(new ImmutablePair<DataTypeDefinition, Boolean>(elementType, false));
- }
- } else {
- createdElementTypes.add(new ImmutablePair<DataTypeDefinition, Boolean>(dataModelResponse.left().value(), true));
- }
-
- }
- } else {
- DataTypeDefinition dataTypeDefinition = findElementType.left().value();
- log.debug("Going to update data type with name {}. ", elementName);
- Either<Map<String, PropertyDefinition>, StorageOperationStatus> deleteDataTypeRes = propertyOperation.deleteAllPropertiesAssociatedToNode(NodeTypeEnum.DataType, dataTypeDefinition.getUniqueId());
- if (deleteDataTypeRes.isRight()) {
- StorageOperationStatus status = deleteDataTypeRes.right().value();
- if (status != StorageOperationStatus.OK) {
-
- log.debug("Failed to update data type {}. Status is {}. ", elementName, deleteDataTypeRes.right().value());
- isSuccessful = false;
- break;
- }
- }
-
- Either<Map<String, PropertyData>, TitanOperationStatus> updateDataTypeRes = propertyOperation.addPropertiesToElementType(dataTypeDefinition.getUniqueId(), NodeTypeEnum.DataType, elementType.getProperties());
-
- if (updateDataTypeRes.isRight()) {
- TitanOperationStatus status = updateDataTypeRes.right().value();
-
- log.debug("Failed to update data type {}. Status is {}. ", elementName, updateDataTypeRes.right().value());
- isSuccessful = false;
- break;
-
- } else {
- createdElementTypes.add(new ImmutablePair<DataTypeDefinition, Boolean>(elementType, true));
- }
-
- DataTypeData dataTypeData = new DataTypeData();
- dataTypeData.setDataTypeDataDefinition(elementType);
- dataTypeData.getDataTypeDataDefinition().setUniqueId(dataTypeDefinition.getUniqueId());
- long modificationTime = System.currentTimeMillis();
- dataTypeData.getDataTypeDataDefinition().setModificationTime(modificationTime);
-
- Either<DataTypeData, TitanOperationStatus> updateNode = titanGenericDao.updateNode(dataTypeData, DataTypeData.class);
- if (updateNode.isRight()) {
- TitanOperationStatus operationStatus = updateNode.right().value();
- log.debug("Failed to update modification time data type {} from graph. status is {}",
- dataTypeDefinition.getUniqueId() ,operationStatus);
- BeEcompErrorManager.getInstance().logInternalFlowError("AddPropertyToDataType", "Failed to fetch data type. Status is " + operationStatus, ErrorSeverity.ERROR);
- isSuccessful = false;
- break;
- } else {
- log.debug("Update data type uid {}. Set modification time to {}", dataTypeDefinition.getUniqueId(), modificationTime);
- isSuccessful = true;
- }
- }
- }
- } finally {
- log.info(" Finish to align data type properties");
- if (isSuccessful) {
- propertyOperation.getTitanGenericDao().commit();
- } else {
- propertyOperation.getTitanGenericDao().rollback();
- }
- }
- }
- return isSuccessful;
- }
-
- @SuppressWarnings("unchecked")
- private List<DataTypeDefinition> extractDataTypesFromYaml() {
- String dataTypeYmlFilePath = CONFIG_DATA_TYPES_YML;
- String yamlAsString;
- try {
-
- InputStream inputStream = getClass().getResourceAsStream(dataTypeYmlFilePath);
- if (inputStream == null) {
- log.info("Failed to load input file : {}", dataTypeYmlFilePath);
- return null;
- }
- yamlAsString = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
-
- } catch (Exception e) {
- log.info("Failed to load group types file exception : ", e);
- return null;
- }
-
- log.debug("received yaml: {}", yamlAsString);
-
- String dataTypeName;
- List<DataTypeDefinition> dataTypes = new ArrayList<>();
-
- Map<String, Object> toscaJson = (Map<String, Object>) new Yaml().load(yamlAsString);
- Iterator<Entry<String, Object>> elementTypesEntryItr = toscaJson.entrySet().iterator();
- while (elementTypesEntryItr.hasNext()) {
- Entry<String, Object> elementTypeNameDataEntry = elementTypesEntryItr.next();
- dataTypeName = elementTypeNameDataEntry.getKey();
- Map<String, Object> elementTypeJsonData = (Map<String, Object>) elementTypeNameDataEntry.getValue();
-
- DataTypeDefinition dataType = new DataTypeDefinition();
- dataType.setName(dataTypeName);
-
- if (elementTypeJsonData != null) {
-
- if (elementTypeJsonData.containsKey(ToscaTagNamesEnum.DESCRIPTION.getElementName())) {
- dataType.setDescription((String) elementTypeJsonData.get(ToscaTagNamesEnum.DESCRIPTION.getElementName()));
- }
- if (elementTypeJsonData.containsKey(ToscaTagNamesEnum.DERIVED_FROM.getElementName())) {
- dataType.setDerivedFromName((String) elementTypeJsonData.get(ToscaTagNamesEnum.DERIVED_FROM.getElementName()));
- }
- List<PropertyDefinition> properties = getProperties(elementTypeJsonData);
- if (elementTypeJsonData.containsKey(ToscaTagNamesEnum.PROPERTIES.getElementName())) {
- dataType.setProperties(properties);
- }
- }
- dataTypes.add(dataType);
- }
-
- return dataTypes;
- }
-
- private List<PropertyDefinition> getProperties(Map<String, Object> toscaJson) {
- List<PropertyDefinition> values = null;
- Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties = ImportUtils.getProperties(toscaJson);
-
- if (properties.isLeft()) {
- values = new ArrayList<>();
- Map<String, PropertyDefinition> propertiesMap = properties.left().value();
- if (propertiesMap != null && propertiesMap.isEmpty() == false) {
-
- for (Entry<String, PropertyDefinition> entry : propertiesMap.entrySet()) {
- String propName = entry.getKey();
- PropertyDefinition propertyDefinition = entry.getValue();
- PropertyDefinition newPropertyDefinition = new PropertyDefinition(propertyDefinition);
- newPropertyDefinition.setName(propName);
- values.add(newPropertyDefinition);
- }
- }
- }
-
- return values;
- }
-
- private Either<ActionStatus, ResponseFormat> validateDataType(DataTypeDefinition dataType) {
-
- String dataTypeName = dataType.getName();
- List<PropertyDefinition> properties = dataType.getProperties();
- if (properties == null) {
- // At least one parameter should be defined either in the properties
- // section or at one of the parents
- String derivedDataType = dataType.getDerivedFromName();
- // If there are no properties, then we can create a data type if it
- // is an abstract one or it derives from non abstract data type
- if ((derivedDataType == null || derivedDataType.isEmpty())) {
- if (false == isAbstract(dataType.getName())) {
- if (false == ToscaPropertyType.isScalarType(dataTypeName)) {
- log.debug("Data type {} must have properties unless it derives from non abstract data type",dataType.getName());
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_NOR_PROPERTIES_NEITHER_DERIVED_FROM, dataType, null);
-
- return Either.right(responseFormat);
- }
- }
- } else {
- // if it is not a scalar data type and it derives from abstract
- // data type, we should reject the request.
- if (false == ToscaPropertyType.isScalarType(dataTypeName) && true == isAbstract(derivedDataType)) {
- log.debug("Data type {} which derived from abstract data type must have at least one property",dataType.getName());
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_NOR_PROPERTIES_NEITHER_DERIVED_FROM, dataType, null);
-
- return Either.right(responseFormat);
- }
- }
- } else {
- // properties tag cannot be empty
- if (properties.isEmpty()) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_PROPERTIES_CANNOT_BE_EMPTY, dataType, null);
-
- return Either.right(responseFormat);
- }
-
- // check no duplicates
- Set<String> collect = properties.stream().map(p -> p.getName()).collect(Collectors.toSet());
- if (collect != null) {
- if (properties.size() != collect.size()) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_DUPLICATE_PROPERTY, dataType, null);
-
- return Either.right(responseFormat);
- }
- }
-
- List<String> propertiesWithSameTypeAsDataType = properties.stream().filter(p -> p.getType().equals(dataType.getName())).map(p -> p.getName()).collect(Collectors.toList());
- if (propertiesWithSameTypeAsDataType != null && propertiesWithSameTypeAsDataType.isEmpty() == false) {
- log.debug("The data type contains properties with the type {}",dataType.getName(),dataType.getName());
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_PROEPRTY_CANNOT_HAVE_SAME_TYPE_OF_DATA_TYPE, dataType, propertiesWithSameTypeAsDataType);
-
- return Either.right(responseFormat);
- }
- }
-
- String derivedDataType = dataType.getDerivedFromName();
- if (derivedDataType != null) {
- Either<DataTypeDefinition, StorageOperationStatus> derivedDataTypeByName = propertyOperation.getDataTypeByName(derivedDataType, true);
- if (derivedDataTypeByName.isRight()) {
- StorageOperationStatus status = derivedDataTypeByName.right().value();
- if (status == StorageOperationStatus.NOT_FOUND) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_DERIVED_IS_MISSING, dataType, null);
-
- return Either.right(responseFormat);
- } else {
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.GENERAL_ERROR, dataType, null);
-
- return Either.right(responseFormat);
-
- }
- } else {
-
- DataTypeDefinition derivedDataTypeDef = derivedDataTypeByName.left().value();
- if (properties != null && properties.isEmpty() == false) {
-
- if (true == isScalarType(derivedDataTypeDef)) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_CANNOT_HAVE_PROPERTIES, dataType, null);
-
- return Either.right(responseFormat);
- }
-
- Set<String> allParentsProps = new HashSet<>();
- do {
- List<PropertyDefinition> currentParentsProps = derivedDataTypeDef.getProperties();
- if (currentParentsProps != null) {
- for (PropertyDefinition propertyDefinition : currentParentsProps) {
- allParentsProps.add(propertyDefinition.getName());
- }
- }
- derivedDataTypeDef = derivedDataTypeDef.getDerivedFrom();
- } while (derivedDataTypeDef != null);
-
- // Check that no property is already defined in one of the
- // ancestors
- Set<String> alreadyExistPropsCollection = properties.stream().filter(p -> allParentsProps.contains(p.getName())).map(p -> p.getName()).collect(Collectors.toSet());
- if (alreadyExistPropsCollection != null && alreadyExistPropsCollection.isEmpty() == false) {
- List<String> duplicateProps = new ArrayList<>();
- duplicateProps.addAll(alreadyExistPropsCollection);
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_PROPERTY_ALREADY_DEFINED_IN_ANCESTOR, dataType, duplicateProps);
-
- return Either.right(responseFormat);
- }
-
- }
- }
- }
- return Either.left(ActionStatus.OK);
- }
-
- private boolean isAbstract(String dataTypeName) {
-
- ToscaPropertyType isPrimitiveToscaType = ToscaPropertyType.isValidType(dataTypeName);
-
- return isPrimitiveToscaType != null && isPrimitiveToscaType.isAbstract() == true;
-
- }
-
- private boolean isScalarType(DataTypeDefinition dataTypeDef) {
-
- boolean isScalar = false;
- DataTypeDefinition dataType = dataTypeDef;
-
- while (dataType != null) {
-
- String name = dataType.getName();
- if (ToscaPropertyType.isScalarType(name)) {
- isScalar = true;
- break;
- }
-
- dataType = dataType.getDerivedFrom();
- }
-
- return isScalar;
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/DistributionStatusUpdate.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/DistributionStatusUpdate.java
deleted file mode 100644
index 744965ff68..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/DistributionStatusUpdate.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-import org.apache.commons.collections.MapUtils;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
-import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
-import org.openecomp.sdc.be.model.ComponentParametersView;
-import org.openecomp.sdc.be.model.DistributionStatusEnum;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import fj.data.Either;
-
-@Component("distributionStatusUpdate")
-public class DistributionStatusUpdate {
- private static Logger LOGGER = LoggerFactory.getLogger(DistributionStatusUpdate.class);
-
- @Autowired
- private ToscaOperationFacade toscaOperationFacade;
- @Autowired
- private TitanDao titanDao;
-
-
- public boolean migrate() {
- boolean result = true;
- Either<Map<GraphVertex, org.openecomp.sdc.be.model.Service>, StorageOperationStatus> getAllServiceComponentsRes = getAllServiceComponents();
- if(getAllServiceComponentsRes.isRight()){
- result = false;
- }
- if(result && MapUtils.isNotEmpty(getAllServiceComponentsRes.left().value())){
- updateDistributionStatusFromMetadata(getAllServiceComponentsRes.left().value());
- updateDistributionStatusToNotDistributed(getAllServiceComponentsRes.left().value());
- }
-
- toscaOperationFacade.commit();
-
- return result;
- }
-
-
- private void updateDistributionStatusToNotDistributed(Map<GraphVertex, org.openecomp.sdc.be.model.Service> components) {
-
- Map<GraphVertex, org.openecomp.sdc.be.model.Service> filteredComponents = components.entrySet()
- .stream()
- .filter(e -> e.getValue().getLifecycleState() != LifecycleStateEnum.CERTIFIED)
- .collect(Collectors.toMap(e -> e.getKey(), e -> (Service)e.getValue()));
-
- Service service;
- Either<GraphVertex, TitanOperationStatus> updateResponse;
- GraphVertex metadataV;
-
- for(Entry<GraphVertex, Service> currComponent : filteredComponents.entrySet()){
- metadataV = currComponent.getKey();
- service = currComponent.getValue();
- try {
- metadataV.addMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS, DistributionStatusEnum.DISTRIBUTION_NOT_APPROVED.name());
- updateResponse = titanDao.updateVertex(metadataV);
-
- if (updateResponse.isRight()) {
- LOGGER.debug("failed to updateDistributionStatusToNotDistributed service {} error {}", service.getUniqueId(), updateResponse.right().value());
- }
-
- } catch (Exception e) {
- LOGGER.debug("failed to updateDistributionStatusToNotDistributed service {} error {}", service.getUniqueId(), e.toString());
- }
- }
- }
-
- private void updateDistributionStatusFromMetadata(Map<GraphVertex, org.openecomp.sdc.be.model.Service> components) {
- Service service;
- String statusFromMetadata;
- Either<GraphVertex, TitanOperationStatus> updateResponse;
- GraphVertex metadataV;
-
- for(Entry<GraphVertex, Service> currComponent : components.entrySet()){
- metadataV = currComponent.getKey();
- service = currComponent.getValue();
- try {
- statusFromMetadata = (String) metadataV.getJsonMetadataField(JsonPresentationFields.DISTRIBUTION_STATUS);
- metadataV.addMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS, statusFromMetadata);
- updateResponse = titanDao.updateVertex(metadataV);
-
- if (updateResponse.isRight()) {
- LOGGER.debug("failed to updateDistributionStatusFromMetadata service {} error {}", service.getUniqueId(), updateResponse.right().value());
- }
-
- } catch (Exception e) {
- LOGGER.debug("failed to read distribution status of service {} error {}", service.getUniqueId(), e.toString());
- }
-
- }
- }
-
-
- public Either<Map<GraphVertex, org.openecomp.sdc.be.model.Service>, StorageOperationStatus> getAllServiceComponents() {
-
- Map<GraphVertex, org.openecomp.sdc.be.model.Service> components = new HashMap<>();
- Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
- Map<GraphPropertyEnum, Object> propertiesNotMatch = new EnumMap<>(GraphPropertyEnum.class);
- propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
- propertiesNotMatch.put(GraphPropertyEnum.IS_DELETED, true);
- Either<List<GraphVertex>, TitanOperationStatus> getVerticiesRes = toscaOperationFacade.getTitanDao().getByCriteria(null, propertiesToMatch, propertiesNotMatch, JsonParseFlagEnum.ParseAll);
-
- if (getVerticiesRes.isRight() && getVerticiesRes.right().value() != TitanOperationStatus.NOT_FOUND) {
- LOGGER.debug("Failed to fetch all service components. Status is {}", getVerticiesRes.right().value());
- return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getVerticiesRes.right().value()));
- }
- if(getVerticiesRes.isLeft()){
- List<GraphVertex> componentVerticies = getVerticiesRes.left().value();
- for (GraphVertex componentV : componentVerticies) {
- ComponentParametersView filters = new ComponentParametersView(true);
- Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentsRes = toscaOperationFacade.getToscaElement(componentV.getUniqueId(), filters);
- if (getComponentsRes.isRight()) {
- return Either.right(getComponentsRes.right().value());
- }
- components.put(componentV, (Service) getComponentsRes.left().value());
- }
- }
- return Either.left(components);
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707.java
deleted file mode 100644
index 1012ebddd4..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-import org.openecomp.sdc.asdctool.impl.migration.Migration1707Task;
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-import java.util.Optional;
-
-@Component("migration1707")
-public class Migration1707 {
-
- private static Logger LOGGER = LoggerFactory.getLogger(Migration1707.class);
-
- private List<Migration1707Task> migrations;
-
- public Migration1707(List<Migration1707Task> migrations) {
- this.migrations = migrations;
- }
-
- public boolean migrate() {
- int startMigrationFrom = Optional.ofNullable(ConfigurationManager.getConfigurationManager().getConfiguration().getStartMigrationFrom()).orElse(0);
- List<Migration1707Task> migrations = this.migrations.subList(startMigrationFrom, this.migrations.size());
- for (Migration1707Task migration : migrations) {
- LOGGER.info(String.format("Starting migration. %s", migration.description()));
- boolean migrationCompletedSuccessfully = migration.migrate();
- if (!migrationCompletedSuccessfully) {
- LOGGER.error(String.format("Migration of class %s has failed.", migration.getClass()));
- return false;
- }
- LOGGER.info(String.format("Completed migration. %s", migration.description()));
- }
- return true;
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707ArtifactUuidFix.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707ArtifactUuidFix.java
deleted file mode 100644
index b3f138241e..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707ArtifactUuidFix.java
+++ /dev/null
@@ -1,585 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-import java.io.BufferedWriter;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentParametersView;
-import org.openecomp.sdc.be.model.DistributionStatusEnum;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.GroupInstance;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
-import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.common.api.ArtifactTypeEnum;
-import org.openecomp.sdc.common.api.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import fj.data.Either;
-
-@org.springframework.stereotype.Component("migration1707UuidFix")
-public class Migration1707ArtifactUuidFix {
-
- @Autowired
- private TitanDao titanDao;
-
- @Autowired
- private ToscaOperationFacade toscaOperationFacade;
-
- private static Logger log = LoggerFactory.getLogger(Migration1707ArtifactUuidFix.class.getName());
-
- public boolean migrate(String fixComponent, String runMode) {
- List<Resource> vfLst = new ArrayList<>();
- List<Service> serviceList = new ArrayList<>();
-
- long time = System.currentTimeMillis();
-
- if (fixComponent.equals("vf_only")) {
- if (fetchFaultVf(fixComponent, vfLst, time) == false) {
- return false;
- }
- } else {
- if (fetchServices(fixComponent, serviceList, time) == false) {
- return false;
- }
- }
- if (runMode.equals("service_vf") || runMode.equals("fix")) {
- log.info("Mode {}. Find problem VFs", runMode);
- if (fetchVf(serviceList, vfLst, time) == false) {
- log.info("Mode {}. Find problem VFs finished with failure", runMode);
- return false;
- }
- log.info("Mode {}. Find problem VFs finished with success", runMode);
- }
- if (runMode.equals("fix") || runMode.equals("fix_only_services")) {
- log.info("Mode {}. Start fix", runMode);
- if (fix(vfLst, serviceList) == false) {
- log.info("Mode {}. Fix finished with failure", runMode);
- return false;
- }
- log.info("Mode {}. Fix finished with success", runMode);
- }
-
- return true;
- }
-
- private boolean fetchFaultVf(String fixComponent, List<Resource> vfLst, long time) {
- log.info("Find fault VF ");
- Writer writer = null;
- try {
- String fileName = "fault_" + time + ".csv";
- writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"));
- writer.write("vf name, vf id, state, version\n");
-
- Map<GraphPropertyEnum, Object> hasProps = new HashMap<>();
- hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name());
- hasProps.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.VF.name());
-
- Map<GraphPropertyEnum, Object> hasNotProps = new HashMap<>();
- hasNotProps.put(GraphPropertyEnum.IS_DELETED, true);
- log.info("Try to fetch resources with properties {} and not {}", hasProps, hasNotProps);
-
- Either<List<GraphVertex>, TitanOperationStatus> servicesByCriteria = titanDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps, hasNotProps, JsonParseFlagEnum.ParseAll);
- if (servicesByCriteria.isRight()) {
- log.info("Failed to fetch resources {}", servicesByCriteria.right().value());
- return false;
- }
- List<GraphVertex> resources = servicesByCriteria.left().value();
- for (GraphVertex gv : resources) {
- ComponentParametersView filter = new ComponentParametersView(true);
- filter.setIgnoreComponentInstances(false);
- filter.setIgnoreArtifacts(false);
- filter.setIgnoreGroups(false);
-
- Either<Resource, StorageOperationStatus> toscaElement = toscaOperationFacade.getToscaElement(gv.getUniqueId());
- if (toscaElement.isRight()) {
- log.info("Failed to fetch resources {} {}", gv.getUniqueId(), toscaElement.right().value());
- return false;
- }
-
- Resource resource = toscaElement.left().value();
- String resourceName = resource.getName();
- Map<String, ArtifactDefinition> deploymentArtifacts = resource.getDeploymentArtifacts();
- List<GroupDefinition> groups = resource.getGroups();
- if (groups == null || groups.isEmpty()) {
- log.info("No groups for resource {} id {} ", resourceName, gv.getUniqueId());
- continue;
- }
- boolean isProblematic = false;
- for (GroupDefinition gr : groups) {
- if (gr.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)) {
- if (isProblematicGroup(gr, resourceName, deploymentArtifacts)) {
- isProblematic = true;
- break;
- }
- }
- }
- if (isProblematic) {
- vfLst.add(resource);
- writeModuleResultToFile(writer, resource, null);
- writer.flush();
- }
- titanDao.commit();
- }
-
- } catch (Exception e) {
- log.info("Failed to fetch vf resources ", e);
- return false;
- } finally {
- titanDao.commit();
- try {
- writer.flush();
- writer.close();
- } catch (Exception ex) {
- /* ignore */}
- }
- return true;
- }
-
- private boolean fetchVf(List<Service> serviceList, List<Resource> vfLst, long time) {
- log.info("Find problem VF ");
- if (serviceList.isEmpty()) {
- log.info("No services as input");
- return true;
- }
- Writer writer = null;
- try {
- String fileName = "problemVf_" + time + ".csv";
- writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"));
- writer.write("vf name, vf id, state, version, example service name\n");
- Set<String> vfIds = new HashSet<>();
- for (Service service : serviceList) {
- List<ComponentInstance> componentInstances = service.getComponentInstances();
- for (ComponentInstance ci : componentInstances) {
- if (!vfIds.contains(ci.getComponentUid())) {
- vfIds.add(ci.getComponentUid());
- Either<Resource, StorageOperationStatus> toscaElement = toscaOperationFacade.getToscaElement(ci.getComponentUid());
- if (toscaElement.isRight()) {
- log.info("Failed to fetch resource {} {}", ci.getComponentUid(), toscaElement.right().value());
- return false;
- }
- Resource resource = toscaElement.left().value();
- vfLst.add(resource);
- writeModuleResultToFile(writer, resource, service);
- writer.flush();
- titanDao.commit();
- }
- }
- }
- log.info("output file with list of Vf : {}", fileName);
- } catch (Exception e) {
- log.info("Failed to fetch services ", e);
- return false;
- } finally {
- titanDao.commit();
- try {
- writer.flush();
- writer.close();
- } catch (Exception ex) {
- /* ignore */}
- }
- return true;
- }
-
- private boolean fetchServices(String fixServices, List<Service> serviceList, long time) {
- log.info("Find problem Services {}", fixServices);
- Writer writer = null;
-
- try {
- String fileName = "problemService_" + time + ".csv";
- writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"));
- writer.write("service name, service id, state, version\n");
-
- Map<GraphPropertyEnum, Object> hasProps = new HashMap<>();
- hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
- if (fixServices.equals("distributed_only")) {
- hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
- hasProps.put(GraphPropertyEnum.DISTRIBUTION_STATUS, DistributionStatusEnum.DISTRIBUTED.name());
- }
-
- Map<GraphPropertyEnum, Object> hasNotProps = new HashMap<>();
- hasNotProps.put(GraphPropertyEnum.IS_DELETED, true);
- log.info("Try to fetch services with properties {} and not {}", hasProps, hasNotProps);
-
- Either<List<GraphVertex>, TitanOperationStatus> servicesByCriteria = titanDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps, hasNotProps, JsonParseFlagEnum.ParseAll);
- if (servicesByCriteria.isRight()) {
- log.info("Failed to fetch services {}", servicesByCriteria.right().value());
- return false;
- }
- List<GraphVertex> services = servicesByCriteria.left().value();
- for (GraphVertex gv : services) {
- ComponentParametersView filter = new ComponentParametersView(true);
- filter.setIgnoreComponentInstances(false);
- filter.setIgnoreArtifacts(false);
- filter.setIgnoreGroups(false);
-
- Either<Service, StorageOperationStatus> toscaElement = toscaOperationFacade.getToscaElement(gv.getUniqueId());
- if (toscaElement.isRight()) {
- log.info("Failed to fetch service {} {}", gv.getUniqueId(), toscaElement.right().value());
- return false;
- }
- Service service = toscaElement.left().value();
- List<ComponentInstance> componentInstances = service.getComponentInstances();
- boolean isProblematic = false;
- if (componentInstances == null) {
- log.info("No instances for service {} ", gv.getUniqueId());
- continue;
- }
- String serviceName = (String) gv.getMetadataProperty(GraphPropertyEnum.NAME);
-
- for (ComponentInstance ci : componentInstances) {
- Map<String, ArtifactDefinition> deploymentArtifacts = ci.getDeploymentArtifacts();
- List<GroupInstance> groupInstances = ci.getGroupInstances();
- if (groupInstances == null || groupInstances.isEmpty()) {
- log.info("No instance groups for instance {} in service {} id {} ", ci.getName(), serviceName, gv.getUniqueId());
- continue;
- }
-
- for (GroupInstance gi : groupInstances) {
- if (gi.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)) {
- if (isProblematicGroupInstance(gi, ci.getName(), serviceName, deploymentArtifacts)) {
- isProblematic = true;
- break;
- }
- }
- }
- if (isProblematic) {
- serviceList.add(service);
- writeModuleResultToFile(writer, service, null);
- writer.flush();
- break;
- }
- }
- titanDao.commit();
- }
- log.info("output file with list of services : {}", fileName);
- } catch (Exception e) {
- log.info("Failed to fetch services ", e);
- return false;
- } finally {
- titanDao.commit();
- try {
- writer.flush();
- writer.close();
- } catch (Exception ex) {
- /* ignore */}
- }
- return true;
- }
-
- private boolean isProblematicGroup(GroupDefinition gr, String resourceName, Map<String, ArtifactDefinition> deploymentArtifacts) {
- List<String> artifacts = gr.getArtifacts();
- List<String> artifactsUuid = gr.getArtifactsUuid();
-
- if ((artifactsUuid == null || artifactsUuid.isEmpty()) && (artifacts == null || artifacts.isEmpty())) {
- log.info("No groups in resource {} ", resourceName);
- return false;
- }
- if (artifacts.size() < artifactsUuid.size()) {
- log.info(" artifacts.size() < artifactsUuid.size() group {} in resource {} ", gr.getName(), resourceName);
- return true;
- }
- if (artifacts.size() > 0 && (artifactsUuid == null || artifactsUuid.isEmpty())) {
- log.info(" artifacts.size() > 0 && (artifactsUuid == null || artifactsUuid.isEmpty() group {} in resource {} ", gr.getName(), resourceName);
- return true;
- }
- if (artifactsUuid.contains(null)) {
- log.info(" artifactsUuid.contains(null) group {} in resource {} ", gr.getName(), resourceName);
- return true;
- }
-
- for (String artifactId : artifacts) {
- String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
- ArtifactDefinition artifactDefinition = deploymentArtifacts.get(artifactlabel);
- if (artifactDefinition == null) {
- log.info(" artifactDefinition == null label {} group {} in resource {} ", artifactlabel, gr.getName(), resourceName);
- return true;
- }
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactDefinition.getArtifactType());
- if (artifactType != ArtifactTypeEnum.HEAT_ENV) {
- if (!artifactId.equals(artifactDefinition.getUniqueId())) {
- log.info(" !artifactId.equals(artifactDefinition.getUniqueId() artifact {} artId {} group {} in resource {} ", artifactlabel, artifactId, gr.getName(), resourceName);
- return true;
- }
- if (!artifactsUuid.contains(artifactDefinition.getArtifactUUID())) {
- log.info(" artifactsUuid.contains(artifactDefinition.getArtifactUUID() label {} group {} in resource {} ", artifactlabel, gr.getName(), resourceName);
- return true;
- }
- }
- }
- return false;
- }
-
- private boolean isProblematicGroupInstance(GroupInstance gi, String instName, String servicename, Map<String, ArtifactDefinition> deploymentArtifacts) {
- List<String> artifacts = gi.getArtifacts();
- List<String> artifactsUuid = gi.getArtifactsUuid();
- List<String> instArtifactsUuid = gi.getGroupInstanceArtifactsUuid();
-
- if ((artifactsUuid == null || artifactsUuid.isEmpty()) && (artifacts == null || artifacts.isEmpty())) {
- log.info("No instance groups for instance {} in service {} ", instName, servicename);
- return false;
- }
- if (artifacts.size() < artifactsUuid.size()) {
- log.info(" artifacts.size() < artifactsUuid.size() inst {} in service {} ", instName, servicename);
- return true;
- }
- if (artifacts.size() > 0 && (artifactsUuid == null || artifactsUuid.isEmpty())) {
- log.info(" artifacts.size() > 0 && (artifactsUuid == null || artifactsUuid.isEmpty() inst {} in service {} ", instName, servicename);
- return true;
- }
- if (artifactsUuid.contains(null)) {
- log.info(" artifactsUuid.contains(null) inst {} in service {} ", instName, servicename);
- return true;
- }
-
- for (String artifactId : artifacts) {
- String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
- ArtifactDefinition artifactDefinition = deploymentArtifacts.get(artifactlabel);
- if (artifactDefinition == null) {
- log.info(" artifactDefinition == null label {} inst {} in service {} ", artifactlabel, instName, servicename);
- return true;
- }
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactDefinition.getArtifactType());
- if (artifactType != ArtifactTypeEnum.HEAT_ENV) {
- if (!artifactId.equals(artifactDefinition.getUniqueId())) {
- log.info(" !artifactId.equals(artifactDefinition.getUniqueId() artifact {} artId {} inst {} in service {} ", artifactlabel, artifactId, instName, servicename);
- return true;
- }
- if (!artifactsUuid.contains(artifactDefinition.getArtifactUUID())) {
- log.info(" artifactsUuid.contains(artifactDefinition.getArtifactUUID() label {} inst {} in service {} ", artifactlabel, instName, servicename);
- return true;
- }
- } else {
- if (!instArtifactsUuid.contains(artifactDefinition.getArtifactUUID())) {
- log.info(" instArtifactsUuid.contains(artifactDefinition.getArtifactUUID() label {} inst {} in service {} ", artifactlabel, instName, servicename);
- return true;
- }
- }
- }
- return false;
- }
-
- private boolean fix(List<Resource> vfLst, List<Service> serviceList) {
- boolean res = true;
-
- if (vfLst != null && !vfLst.isEmpty()) {
- res = fixVf(vfLst);
- if (res) {
- for (Component component : vfLst) {
- TopologyTemplate topologyTemplate = ModelConverter.convertToToscaElement(component);
- Map<String, GroupDataDefinition> groups = topologyTemplate.getGroups();
- res = fixDataOnGraph(component.getUniqueId(), VertexTypeEnum.GROUPS, EdgeLabelEnum.GROUPS, groups);
- }
- }
- }
-
- if (res == true && serviceList != null && !serviceList.isEmpty()) {
- res = fixServices(serviceList);
- if (res) {
- for (Component component : serviceList) {
- TopologyTemplate topologyTemplate = ModelConverter.convertToToscaElement(component);
- Map<String, MapGroupsDataDefinition> groups = topologyTemplate.getInstGroups();
- res = fixDataOnGraph(component.getUniqueId(), VertexTypeEnum.INST_GROUPS, EdgeLabelEnum.INST_GROUPS, groups);
- }
- }
- }
-
- return res;
- }
-
- private <T extends ToscaDataDefinition> boolean fixDataOnGraph(String componentId, VertexTypeEnum vertexTypeEnum, EdgeLabelEnum edgeLabelEnum, Map<String, T> groups) {
- boolean res = true;
- Either<GraphVertex, TitanOperationStatus> getResponse = titanDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
- if (getResponse.isRight()) {
- log.debug("Couldn't fetch component unique id {}, error: {}", componentId, getResponse.right().value());
- res = false;
-
- }
- if (res) {
- GraphVertex componentVertex = getResponse.left().value();
-
- GraphVertex toscaDataVertex = null;
- Either<GraphVertex, TitanOperationStatus> groupVertexEither = titanDao.getChildVertex(componentVertex, edgeLabelEnum, JsonParseFlagEnum.ParseJson);
- if (groupVertexEither.isRight()) {
- res = false;
- log.debug("failed to get child {} vertex for component unique id {}, error: {}", edgeLabelEnum, componentId, groupVertexEither.right().value());
- }
- if (res) {
- toscaDataVertex = groupVertexEither.left().value();
- toscaDataVertex.setJson(groups);
- Either<GraphVertex, TitanOperationStatus> updatevertexEither = titanDao.updateVertex(toscaDataVertex);
- if (updatevertexEither.isRight()) {
- log.debug("failed to update vertex for component unique id {}, error: {}", componentId, updatevertexEither.right().value());
- titanDao.rollback();
- return false;
- }
- }
- }
-
- titanDao.commit();
-
- return res;
- }
-
- private boolean fixServices(List<Service> serviceList) {
- for (Service service : serviceList) {
- log.debug("Migration1707ArtifactUuidFix fix service: id {}, name {} ", service.getUniqueId(), service.getName());
- List<ComponentInstance> instances = service.getComponentInstances();
- for (ComponentInstance instance : instances) {
- Map<String, ArtifactDefinition> artifactsMap = instance.getDeploymentArtifacts();
- List<GroupInstance> groupsList = instance.getGroupInstances();
- if (groupsList != null && artifactsMap != null) {
- for (GroupInstance group : groupsList) {
- if (group.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)) {
- log.debug("Migration1707ArtifactUuidFix fix group: resource id {}, group name {} ", service.getUniqueId(), group.getName());
- List<String> groupArtifacts = new ArrayList<String>(group.getArtifacts());
-
- group.getArtifacts().clear();
- group.getArtifactsUuid().clear();
- group.getGroupInstanceArtifacts().clear();
- group.getGroupInstanceArtifactsUuid().clear();
-
- for (String artifactId : groupArtifacts) {
- String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
- log.debug("Migration1707ArtifactUuidFix fix group: group name {} artifactId for fix {} artifactlabel {} ", group.getName(), artifactId, artifactlabel);
- if (!artifactlabel.isEmpty() && artifactsMap.containsKey(artifactlabel)) {
- ArtifactDefinition artifact = artifactsMap.get(artifactlabel);
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifact.getArtifactType());
- String correctArtifactId = artifact.getUniqueId();
- String correctArtifactUUID = artifact.getArtifactUUID();
- if (artifactType != ArtifactTypeEnum.HEAT_ENV) {
-
- log.debug("Migration1707ArtifactUuidFix fix group: group name {} correct artifactId {} artifactUUID {} ", group.getName(), correctArtifactId, correctArtifactUUID);
- group.getArtifacts().add(correctArtifactId);
- if (correctArtifactUUID != null && !correctArtifactUUID.isEmpty()) {
- group.getArtifactsUuid().add(correctArtifactUUID);
- }
- } else {
- log.debug("Migration1707ArtifactUuidFix fix group: group name {} correct artifactId {} artifactUUID {} ", group.getName(), correctArtifactId, correctArtifactUUID);
- group.getGroupInstanceArtifacts().add(correctArtifactId);
- if (correctArtifactUUID != null && !correctArtifactUUID.isEmpty()) {
- group.getGroupInstanceArtifactsUuid().add(correctArtifactUUID);
- }
- }
- }
- }
- }
- }
- }
- }
-
- }
- return true;
-
- }
-
- private boolean fixVf(List<Resource> vfLst) {
- for (Resource resource : vfLst) {
- log.debug("Migration1707ArtifactUuidFix fix resource: id {}, name {} ", resource.getUniqueId(), resource.getName());
- Map<String, ArtifactDefinition> artifactsMap = resource.getDeploymentArtifacts();
- List<GroupDefinition> groupsList = resource.getGroups();
- if (groupsList != null && artifactsMap != null) {
- for (GroupDefinition group : groupsList) {
- if (group.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE) && group.getArtifacts() != null) {
- log.debug("Migration1707ArtifactUuidFix fix group: resource id {}, group name {} ", resource.getUniqueId(), group.getName());
- List<String> groupArtifacts = new ArrayList<String>(group.getArtifacts());
- group.getArtifacts().clear();
- group.getArtifactsUuid().clear();
- for (String artifactId : groupArtifacts) {
- String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
- log.debug("Migration1707ArtifactUuidFix fix group: group name {} artifactId for fix {} artifactlabel {} ", group.getName(), artifactId, artifactlabel);
- if (!artifactlabel.isEmpty() && artifactsMap.containsKey(artifactlabel)) {
- ArtifactDefinition artifact = artifactsMap.get(artifactlabel);
- String correctArtifactId = artifact.getUniqueId();
- String correctArtifactUUID = artifact.getArtifactUUID();
- log.debug("Migration1707ArtifactUuidFix fix group: group name {} correct artifactId {} artifactUUID {} ", group.getName(), correctArtifactId, correctArtifactUUID);
- group.getArtifacts().add(correctArtifactId);
- if (correctArtifactUUID != null && !correctArtifactUUID.isEmpty()) {
- group.getArtifactsUuid().add(correctArtifactUUID);
- }
-
- }
- }
- }
- }
- }
-
- }
-
- return true;
- }
-
- private String findArtifactLabelFromArtifactId(String artifactId) {
- String artifactLabel = "";
-
- int index = artifactId.lastIndexOf(".");
- if (index > 0 && index + 1 < artifactId.length())
- artifactLabel = artifactId.substring(index + 1);
- return artifactLabel;
- }
-
- private void writeModuleResultToFile(Writer writer, org.openecomp.sdc.be.model.Component component, Service service) {
- try {
- // "service name, service id, state, version
- StringBuffer sb = new StringBuffer(component.getName());
- sb.append(",").append(component.getUniqueId()).append(",").append(component.getLifecycleState()).append(",").append(component.getVersion());
- if (service != null) {
- sb.append(",").append(service.getName());
- }
- sb.append("\n");
- writer.write(sb.toString());
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707Config.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707Config.java
deleted file mode 100644
index 36919d7520..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707Config.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-
-import java.util.List;
-
-import org.openecomp.sdc.asdctool.impl.migration.Migration1707Task;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel.*;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel.relations.FulfilledCapabilitiesMigrationService;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel.relations.FulfilledRequirementsMigrationService;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel.relations.RequirementsCapabilitiesMigrationService;
-import org.openecomp.sdc.be.dao.TitanClientStrategy;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.model.DerivedNodeTypeResolver;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.jsontitan.operations.ArtifactsOperations;
-import org.openecomp.sdc.be.model.jsontitan.operations.CategoryOperation;
-import org.openecomp.sdc.be.model.jsontitan.operations.NodeTemplateOperation;
-import org.openecomp.sdc.be.model.jsontitan.operations.NodeTypeOperation;
-import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
-import org.openecomp.sdc.be.model.jsontitan.operations.ToscaDataOperation;
-import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementLifecycleOperation;
-import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.model.operations.api.IElementOperation;
-import org.openecomp.sdc.be.model.operations.api.IUserAdminOperation;
-import org.openecomp.sdc.be.model.operations.api.ToscaDefinitionPathCalculator;
-import org.openecomp.sdc.be.model.operations.impl.ConsumerOperation;
-import org.openecomp.sdc.be.model.operations.impl.ElementOperation;
-import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation;
-import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
-import org.openecomp.sdc.be.model.operations.impl.ToscaDefinitionPathCalculatorImpl;
-import org.openecomp.sdc.be.model.operations.impl.UserAdminOperation;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-import org.springframework.core.annotation.Order;
-
-@Configuration
-public class Migration1707Config {
-
-
- @Bean(name = "migration1707")
- public Migration1707 migration1707(List<Migration1707Task> migrations) {
- return new Migration1707(migrations);
- }
-
- @Bean(name = "renameGraphPropertyKeysMigration")
- @Order(1)
- public Migration1707Task renameGraphPropertyKeysMigration() {
- return new RenameGraphPropertyKeys();
- }
-
- @Bean(name = "toscaNamesUpdate")
- @Order(2)
- public Migration1707Task toscaNamesUpdate() {
- return new ToscaNamesUpdate();
- }
-
- @Bean(name = "users-migration")
- @Order(3)
- public Migration1707Task usersMigration() {
- return new UsersMigration();
- }
-
- @Bean(name = "resource-category-migration")
- @Order(4)
- public Migration1707Task resourceCategoriesMigration() {
- return new ResourcesCategoriesMigration();
- }
-
- @Bean(name = "service-category-migration")
- @Order(5)
- public Migration1707Task serviceCategoriesMigration() {
- return new ServiceCategoriesMigration();
- }
-
- @Bean(name = "normatives-migration")
- @Order(6)
- public Migration1707Task normativesMigration() {
- return new NormativesMigration();
- }
-
- @Bean(name = "vf-migration")
- @Order(7)
- public Migration1707Task vfMigration() {
- return new VFResourcesMigration();
- }
-
- @Bean(name = "service-migration")
- @Order(8)
- public Migration1707Task serviceMigration() {
- return new ServicesMigration();
- }
-
- @Bean(name = "consumers-migration")
- @Order(9)
- public Migration1707Task consumersMigration() { return new ConsumersMigration(); }
-
- @Bean(name = "tosca-template-regeneration")
- @Order(10)
- public Migration1707Task ToscaTemplateRegeneration() {
- return new ToscaTemplateRegeneration();
- }
-
- @Bean(name = "distributionStatusUpdate")
- public DistributionStatusUpdate distributionStatusUpdate() {
- return new DistributionStatusUpdate();
- }
-
- @Bean("resource-version-migration")
- public VersionMigration<Resource> resourceVersionMigration() {
- return new ResourceVersionMigration();
- }
-
- @Bean("service-version-migration")
- public VersionMigration<Service> serviceVersionMigration() {
- return new ServiceVersionMigration();
- }
-
- @Bean(name = "normatives-resolver")
- public NormativesResolver normativesResolver() {
- return new NormativesResolver();
- }
-
- @Bean(name = "property-operation-mig")
- public PropertyOperation propertyOperation(@Qualifier("titan-generic-dao-migration") TitanGenericDao titanGenericDao) {
- return new PropertyOperation(titanGenericDao);
- }
-
- @Bean(name = "group-type-operation-mig")
- public GroupTypeOperation groupTypeOperation(@Qualifier("titan-generic-dao-migration") TitanGenericDao titanGenericDao, @Qualifier("property-operation-mig") PropertyOperation propertyOperation) {
- return new GroupTypeOperation(titanGenericDao, propertyOperation);
- }
-
- @Bean(name = "titan-generic-dao-migration")
- public TitanGenericDao titanGenericDaoMigration(@Qualifier("migration-titan-client") TitanGraphClient titanGraphClient) {
- return new TitanGenericDao(titanGraphClient);
- }
-
- @Bean(name = "migration-titan-strategy")
- public TitanClientStrategy migrationStrategy() {
- return new MigrationTitanStrategy();
- }
-
- @Bean(name = "migration-titan-client", initMethod = "createGraph")
- public TitanGraphClient titanMigrationClient(@Qualifier("migration-titan-strategy") TitanClientStrategy titanClientStrategy) {
- return new TitanGraphClient(titanClientStrategy);
- }
-
- @Bean(name = "user-operation-migration")
- public IUserAdminOperation userOperationNewKeySpace(@Qualifier("titan-generic-dao-migration") TitanGenericDao titanGenericDao) {
- return new UserAdminOperation(titanGenericDao);
- }
-
- @Bean(name = "element-operation-migration")
- public IElementOperation elementOperationNewKeyspace(@Qualifier("titan-generic-dao-migration") TitanGenericDao titanGenericDao) {
- return new ElementOperation(titanGenericDao);
- }
-
- @Bean(name = "tosca-operation-facade")
- public ToscaOperationFacade toscaOperationFacade() {
- return new ToscaOperationFacade();
- }
-
- @Bean(name = "node-type-operation")
- public NodeTypeOperation nodeTypeOperation(@Qualifier("mig-derived-resolver") DerivedNodeTypeResolver migrationDerivedNodeTypeResolver) {
- return new NodeTypeOperation(migrationDerivedNodeTypeResolver);
- }
-
- @Bean(name = "topology-template-operation")
- public TopologyTemplateOperation topologyTemplateOperation() {
- return new TopologyTemplateOperation();
- }
-
- @Bean(name = "node-template-operation")
- public NodeTemplateOperation nodeTemplateOperation() {
- return new NodeTemplateOperation();
- }
-
- @Bean(name = "titan-dao")
- public TitanDao titanDao(@Qualifier("migration-titan-client") TitanGraphClient titanGraphClient) {
- return new TitanDao(titanGraphClient);
- }
-
- @Bean(name = "category-operation")
- public CategoryOperation categoryOperation() {
- return new CategoryOperation();
- }
-
- @Bean(name = "artifacts-operation")
- public ArtifactsOperations artifactsOperation() {
- return new ArtifactsOperations();
- }
-
- @Bean(name = "tosca-data-operation")
- public ToscaDataOperation toscaDataOperation() {
- return new ToscaDataOperation();
- }
-
- @Bean(name = "tosca-element-lifecycle-operation")
- public ToscaElementLifecycleOperation toscaElementLifecycleOperation() {
- return new ToscaElementLifecycleOperation();
- }
-
- @Bean(name = "tosca-path-calculator")
- public ToscaDefinitionPathCalculator pathCalculator() {
- return new ToscaDefinitionPathCalculatorImpl();
- }
-
- @Bean(name = "fulfilled-capabilities-mig-service")
- public FulfilledCapabilitiesMigrationService fulfilledCapabilitiesMigService() {
- return new FulfilledCapabilitiesMigrationService();
- }
-
- @Bean(name = "fulfilled-requirements-mig-service")
- public FulfilledRequirementsMigrationService requirementsMigService() {
- return new FulfilledRequirementsMigrationService();
- }
-
- @Bean(name ="req-cap-mig-service")
- public RequirementsCapabilitiesMigrationService reqCapMigService() {
- return new RequirementsCapabilitiesMigrationService();
- }
-
- @Bean(name = "mig-derived-resolver")
- public DerivedNodeTypeResolver migrationDerivedNodeTypeResolver() {
- return new MigrationByIdDerivedNodeTypeResolver();
- }
-
- @Bean(name = "invariant-uuid-resolver")
- public InvariantUUIDResolver invariantUUIDResolver() {
- return new InvariantUUIDResolver();
- }
-
- @Bean(name="consumer-operation-mig")
- @Primary
- public ConsumerOperation consumerOperation(@Qualifier("titan-generic-dao-migration") TitanGenericDao titanGenericDao) {
- return new ConsumerOperation(titanGenericDao);
- }
-
- @Bean(name = "vfModulesPropertiesAdding")
- public VfModulesPropertiesAdding vfModulesPropertiesAdding() {
- return new VfModulesPropertiesAdding();
- }
-
- @Bean(name = "node-template-missing-data-resolver")
- public NodeTemplateMissingDataResolver nodeTemplateMissingDataResolver() {
- return new NodeTemplateMissingDataResolver<>();
- }
-
- @Bean(name = "migration1707MissingInfoFix")
- public Migration1707MissingInfoFix migration1707MissingInfoFix() {
- return new Migration1707MissingInfoFix();
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707MissingInfoFix.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707MissingInfoFix.java
deleted file mode 100644
index ff41f12b8e..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707MissingInfoFix.java
+++ /dev/null
@@ -1,220 +0,0 @@
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-import fj.data.Either;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel.NodeTemplateMissingDataResolver;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.*;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
-import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import org.openecomp.sdc.be.model.*;
-import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
-import org.openecomp.sdc.be.model.jsontitan.enums.JsonConstantKeysEnum;
-import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.model.operations.api.IServiceOperation;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-
-@org.springframework.stereotype.Component("migration1707MissingInfoFix")
-public class Migration1707MissingInfoFix {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(Migration1707MissingInfoFix.class);
-
- @Resource(name = "service-operation")
- private IServiceOperation serviceOperation;
-
- @Resource(name = "node-template-missing-data-resolver")
- private NodeTemplateMissingDataResolver nodeTemplateMissingDataResolver;
-
- @Resource(name = "tosca-operation-facade")
- private ToscaOperationFacade toscaOperations;
-
- @Resource(name = "titan-dao")
- private TitanDao titanDao;
-
-
- public boolean migrate(){
- boolean res = updateVFs();
- if(res)
- res = updateServices();
- return res;
- }
-
- private ComponentParametersView getFilter() {
- ComponentParametersView filter = new ComponentParametersView(true);
- filter.setIgnoreComponentInstances(false);
- filter.setIgnoreArtifacts(false);
- filter.setIgnoreGroups(false);
- filter.setIgnoreComponentInstancesInputs(false);
- return filter;
- }
-
- // if new service has VF instances with no groups - try to fetch them from old graph
- private boolean oldServiceModelRequired(Component newService) {
- Predicate<ComponentInstance> vfInstanceWithNoGroups = p -> OriginTypeEnum.VF == p.getOriginType() && (null == p.getGroupInstances() || p.getGroupInstances().isEmpty());
- return null != newService.getComponentInstances() && newService.getComponentInstances().stream()
- .anyMatch(vfInstanceWithNoGroups);
- }
-
-
-
- private List<GraphVertex> fetchVertices(Map<GraphPropertyEnum, Object> hasProps){
- Either<List<GraphVertex>, TitanOperationStatus> componentsByCriteria = titanDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps, JsonParseFlagEnum.ParseAll);
- if (componentsByCriteria.isRight()) {
- LOGGER.debug("couldn't fetch assets from sdctitan");
- return null;
- }
- return componentsByCriteria.left().value();
- }
-
- private boolean updateVFs() {
-
- boolean res = true;
- Map<GraphPropertyEnum, Object> hasProps = new HashMap<>();
- hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name());
- hasProps.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.VF.name());
-
- List<GraphVertex> resources = fetchVertices(hasProps);
- if(null == resources)
- return false;
- ComponentParametersView filter = getFilter();
- Map<String, ToscaElement> origCompMap = new HashMap<>();
-
- for (GraphVertex gv : resources) {
- boolean fixed = true;
- Either<Component, StorageOperationStatus> toscaElement = toscaOperations.getToscaElement(gv.getUniqueId(), filter);
- if (toscaElement.isRight()) {
- LOGGER.debug("Failed to fetch resource {} {}", gv.getUniqueId(), toscaElement.right().value());
- return false;
- }
- Component resource = toscaElement.left().value();
- Map<String, Boolean> updateMap = new HashMap<>();
- nodeTemplateMissingDataResolver.updateVFComposition(resource, origCompMap, updateMap);
- if(updateMap.get(JsonConstantKeysEnum.COMPOSITION.name())){
- LOGGER.info("applying instance tosca name fix on VF {}", gv.getUniqueId());
- fixed = toscaOperations.updateComponentInstanceMetadataOfTopologyTemplate(resource).isLeft();
- }
- if(updateMap.get(EdgeLabelEnum.GROUPS.name())) {
- List<GroupDataDefinition> groups = new ArrayList<>(resource.getGroups());
- LOGGER.info("applying groups vertex fix on VF {}", gv.getUniqueId());
- fixed = fixed && toscaOperations.updateGroupsOnComponent(resource, ComponentTypeEnum.RESOURCE, groups).isLeft();
- }
-
- res = res && fixed;
- titanDao.commit();
- }
- return res;
- }
-
- private Map<String, MapPropertiesDataDefinition> buildInstancesInputsMap(Component component){
- Map<String, MapPropertiesDataDefinition> instanceInputsMap = new HashMap<>();
- for (Map.Entry<String, List<ComponentInstanceInput>> entry : component.getComponentInstancesInputs().entrySet()) {
- MapPropertiesDataDefinition inputsMap = new MapPropertiesDataDefinition();
- inputsMap.setMapToscaDataDefinition(entry.getValue().stream().map(e -> new PropertyDataDefinition(e)).collect(Collectors.toMap(e -> e.getName(), e -> e)));
- instanceInputsMap.put(entry.getKey(), inputsMap);
- }
- return instanceInputsMap;
- }
-
-
-
- private Map<String, MapGroupsDataDefinition> buildGroupInstanceMap(Component component) {
- Map<String, MapGroupsDataDefinition> instGroupsMap = new HashMap<>();
- for (ComponentInstance instance : component.getComponentInstances()) {
- if (instance.getGroupInstances() != null) {
- MapGroupsDataDefinition groupsMap = new MapGroupsDataDefinition();
- groupsMap.setMapToscaDataDefinition(instance.getGroupInstances().stream().map(e -> new GroupInstanceDataDefinition(e)).collect(Collectors.toMap(e -> e.getName(), e -> e)));
- instGroupsMap.put(instance.getUniqueId(), groupsMap);
- }
- }
- return instGroupsMap;
- }
-
- private <T extends ToscaDataDefinition> boolean updateDataVertex(GraphVertex componentVertex, VertexTypeEnum vertexType, EdgeLabelEnum edgeLabel, Map<String, T> dataMap){
- Either<GraphVertex, TitanOperationStatus> dataVertexEither = titanDao.getChildVertex(componentVertex, edgeLabel, JsonParseFlagEnum.ParseJson);
- if (dataVertexEither.isRight()) {
- if(TitanOperationStatus.NOT_FOUND != dataVertexEither.right().value())
- return false;
- return (nodeTemplateMissingDataResolver.topologyTemplateOperation.assosiateElementToData(componentVertex, vertexType, edgeLabel, dataMap)).isLeft();
- }
- GraphVertex dataVertex = dataVertexEither.left().value();
- dataVertex.setJson(dataMap);
- return (titanDao.updateVertex(dataVertex)).isLeft();
-
- }
-
-
- private boolean updateServices(){
-
- boolean res = true;
- Map<GraphPropertyEnum, Object> hasProps = new HashMap<>();
- hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
-
- List<GraphVertex> componentsByCriteria = fetchVertices(hasProps);
- if(null == componentsByCriteria)
- return false;
-
- ComponentParametersView filter = getFilter();
- Map<String, ToscaElement> origCompMap = new HashMap<>();
-
- Predicate<ComponentInstance> containsGroupInstances = p -> null != p.getGroupInstances() && !p.getGroupInstances().isEmpty();
-
- for (GraphVertex gv : componentsByCriteria) {
-
- boolean fixed = true;
- Either<org.openecomp.sdc.be.model.Service, StorageOperationStatus> toscaElement = toscaOperations.getToscaElement(gv.getUniqueId(), filter);
- if (toscaElement.isRight()) {
- LOGGER.debug("Failed to fetch service {} {}", gv.getUniqueId(), toscaElement.right().value());
- return false;
- }
- Component service = toscaElement.left().value();
- Component oldService = null;
-
- if(oldServiceModelRequired(service)){
- Either<Service, StorageOperationStatus> oldServiceEither = serviceOperation.getService(gv.getUniqueId(), filter, false);
- if (oldServiceEither.isRight()){
- LOGGER.debug("couldn't fetch service {} from old titan", gv.getUniqueId());
- }else {
- oldService = oldServiceEither.left().value();
- oldService = oldService.getComponentInstances().stream().anyMatch(containsGroupInstances) ? oldService : null;
- }
- }
-
- Map<String, Boolean> updateMap = new HashMap<>();
- nodeTemplateMissingDataResolver.updateServiceComposition(service, origCompMap, oldService, updateMap);
- if(updateMap.get(JsonConstantKeysEnum.COMPOSITION.name())) {
- LOGGER.info("applying instance tosca name fix on service {}", gv.getUniqueId());
- fixed = (toscaOperations.updateComponentInstanceMetadataOfTopologyTemplate(service)).isLeft();
- }
- if(updateMap.get(EdgeLabelEnum.INST_GROUPS.name())) {
- Map<String, MapGroupsDataDefinition> groupsMap = buildGroupInstanceMap(service);
- LOGGER.info("applying groups instances vertex fix on service {}", gv.getUniqueId());
- fixed = fixed && updateDataVertex(gv, VertexTypeEnum.INST_GROUPS, EdgeLabelEnum.INST_GROUPS, groupsMap);
- }
- if(updateMap.get(EdgeLabelEnum.INST_INPUTS.name())) {
- Map<String, MapPropertiesDataDefinition> instInputs = buildInstancesInputsMap(service);
- LOGGER.info("applying instances inputs vertex fix on service {}", gv.getUniqueId());
- fixed = fixed && updateDataVertex(gv, VertexTypeEnum.INST_INPUTS, EdgeLabelEnum.INST_INPUTS, instInputs);
- }
- res = res && fixed;
- titanDao.commit();
- }
- return res;
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707RelationsFix.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707RelationsFix.java
deleted file mode 100644
index 204f0a5fc8..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707RelationsFix.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-import java.util.EnumMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
-import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import fj.data.Either;
-@Component("migration1707relationsFix")
-public class Migration1707RelationsFix {
-
- private static Logger LOGGER = LoggerFactory.getLogger(Migration1707RelationsFix.class);
-
- @Autowired
- private TitanDao titanDao;
-
- public boolean migrate() {
- boolean result = true;
-
- try{
- Map<GraphPropertyEnum, Object> propsHasNot = new EnumMap<>(GraphPropertyEnum.class);
- propsHasNot.put(GraphPropertyEnum.IS_DELETED, true);
- Either<List<GraphVertex>, TitanOperationStatus> getAllTopologyTemplatesRes = titanDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, null, propsHasNot, JsonParseFlagEnum.ParseMetadata);
- if (getAllTopologyTemplatesRes.isRight() && getAllTopologyTemplatesRes.right().value() != TitanOperationStatus.NOT_FOUND) {
- LOGGER.debug("Failed to fetch all non marked as deleted topology templates , error {}", getAllTopologyTemplatesRes.right().value());
- result = false;
- }
- if(getAllTopologyTemplatesRes.isLeft()){
- fixComponentsRelations(getAllTopologyTemplatesRes.left().value());
- }
- if(result){
- Either<List<GraphVertex>, TitanOperationStatus> getAllNodeTypesRes = titanDao.getByCriteria(VertexTypeEnum.NODE_TYPE, null, propsHasNot, JsonParseFlagEnum.ParseMetadata);
- if (getAllNodeTypesRes.isRight() && getAllNodeTypesRes.right().value() != TitanOperationStatus.NOT_FOUND) {
- LOGGER.debug("Failed to fetch all non marked as deleted node types , error {}", getAllNodeTypesRes.right().value());
- result = false;
- }
- if(getAllNodeTypesRes.isLeft()){
- fixComponentsRelations(getAllNodeTypesRes.left().value());
- }
- }
- } catch (Exception e){
- LOGGER.debug("The exception {} occured upon migration 1707 relations fixing. ", e.getMessage());
- e.printStackTrace();
- result = false;
- }
- finally{
- if(result){
- titanDao.commit();
- } else {
- titanDao.rollback();
- }
- }
- return result;
- }
-
- private void fixComponentsRelations(List<GraphVertex> notDeletedComponentVerticies) {
- notDeletedComponentVerticies.stream().forEach(this::fixComponentRelations);
- }
-
- private void fixComponentRelations(GraphVertex componentV) {
- fixCreatorComponentRelation(componentV);
- fixLastModifierComponentRelation(componentV);
- fixStateComponentRelation(componentV);
- }
-
- private void fixStateComponentRelation(GraphVertex componentV) {
- boolean relevantEdgeFound = false;
- Iterator<Edge> edges = componentV.getVertex().edges(Direction.IN, EdgeLabelEnum.STATE.name());
- String getState = (String) componentV.getJsonMetadataField(JsonPresentationFields.LIFECYCLE_STATE);
- while(edges.hasNext()){
- Edge edge = edges.next();
- String edgeState = (String) edge.property(GraphPropertyEnum.STATE.getProperty()).orElse(null);
- if(getState.equals(edgeState) && !relevantEdgeFound){
- relevantEdgeFound = true;
- } else {
- removeEdge(edge);
- }
- }
- }
-
- private void fixCreatorComponentRelation(GraphVertex componentV) {
- boolean relevantUserFound = false;
- Iterator<Edge> edges = componentV.getVertex().edges(Direction.IN, EdgeLabelEnum.CREATOR.name());
- String getCreatorUserId = (String) componentV.getJsonMetadataField(JsonPresentationFields.USER_ID_CREATOR);
- while(edges.hasNext()){
- Edge edge = edges.next();
- String userId = (String) edge.outVertex().property(GraphPropertyEnum.USERID.getProperty()).orElse(null);
- if(getCreatorUserId.equals(userId) && !relevantUserFound){
- relevantUserFound = true;
- } else {
- removeEdge(edge);
- }
- }
- }
-
- private void fixLastModifierComponentRelation(GraphVertex componentV) {
- boolean relevantUserFound = false;
- Iterator<Edge> edges = componentV.getVertex().edges(Direction.IN, EdgeLabelEnum.LAST_MODIFIER.name());
- String getLastUpdaterUserId = (String) componentV.getJsonMetadataField(JsonPresentationFields.USER_ID_LAST_UPDATER);
- while(edges.hasNext()){
- Edge edge = edges.next();
- String updaterId = (String) edge.outVertex().property(GraphPropertyEnum.USERID.getProperty()).orElse(null);
- if(getLastUpdaterUserId.equals(updaterId) && !relevantUserFound){
- relevantUserFound = true;
- } else {
- removeEdge(edge);
- }
- }
- }
-
- private void removeEdge(Edge edge) {
- LOGGER.debug("Going to remove edge {} upon migration 1707 relations fixing. ", edge.id());
- edge.remove();
- LOGGER.debug("The edge {} has been removed. ", edge.id());
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707VnfFix.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707VnfFix.java
deleted file mode 100644
index 5d7a887a7f..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/Migration1707VnfFix.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-import java.util.EnumMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.dao.jsongraph.utils.JsonParserUtils;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.thinkaurelius.titan.core.TitanVertex;
-
-import fj.data.Either;
-
-@Component("migration1707vnfFix")
-public class Migration1707VnfFix{
-
- private static final String VF_MODULES_METADATA = "vfModulesMetadata";
-
- @Autowired
- private TitanDao titanDao;
-
- @Autowired
- private TopologyTemplateOperation topologyTemplateOperation;
-
- private static Logger LOGGER = LoggerFactory.getLogger(Migration1707RelationsFix.class);
-
- public boolean migrate() {
- boolean result = true;
-
- Map<GraphPropertyEnum, Object> propsHasNot = new EnumMap<>(GraphPropertyEnum.class);
- propsHasNot.put(GraphPropertyEnum.IS_DELETED, true);
-
- Map<GraphPropertyEnum, Object> propsHas = new EnumMap<>(GraphPropertyEnum.class);
- propsHas.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name());
- propsHas.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.VF.name());
- propsHas.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED);
-
- Either<List<GraphVertex>, TitanOperationStatus> getAllTopologyTemplatesRes = titanDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, null, propsHasNot, JsonParseFlagEnum.ParseMetadata);
- if (getAllTopologyTemplatesRes.isRight() && getAllTopologyTemplatesRes.right().value() != TitanOperationStatus.NOT_FOUND) {
- LOGGER.debug("Failed to fetch all non marked as deleted topology templates , error {}", getAllTopologyTemplatesRes.right().value());
- result = false;
- }
- List<GraphVertex> metadataVertices = getAllTopologyTemplatesRes.left().value();
- for (GraphVertex metadataV : metadataVertices) {
- Either<Map<String, ArtifactDataDefinition>, TitanOperationStatus> dataFromGraph = topologyTemplateOperation.getDataFromGraph(metadataV.getUniqueId(), EdgeLabelEnum.DEPLOYMENT_ARTIFACTS);
- if (dataFromGraph.isLeft()) {
- Map<String, ArtifactDataDefinition> artifacts = dataFromGraph.left().value();
- if (artifacts.containsKey(VF_MODULES_METADATA)) {
- artifacts.remove(VF_MODULES_METADATA);
- Either<GraphVertex, TitanOperationStatus> vertexById = titanDao.getVertexById(metadataV.getUniqueId());
- TitanVertex vertex = vertexById.left().value().getVertex();
- Iterator<Edge> edges = vertex.edges(Direction.OUT, EdgeLabelEnum.DEPLOYMENT_ARTIFACTS.name());
- if (edges.hasNext()) {
- Edge edge = edges.next();
- Vertex dataV = edge.inVertex();
-
- String jsonStr;
- try {
- jsonStr = JsonParserUtils.jsonToString(artifacts);
- dataV.property(GraphPropertyEnum.JSON.getProperty(), jsonStr);
- } catch (Exception e) {
- LOGGER.debug("Failed to update deployment artifacts for VF {}", metadataV.getUniqueId());
- }
- }
- }
- }
- TitanOperationStatus commit = titanDao.commit();
- if ( commit != TitanOperationStatus.OK){
- LOGGER.debug("Failed to commit changes for deployment artifacts for VF {} {}", metadataV.getUniqueId(), metadataV.getMetadataProperty(GraphPropertyEnum.NAME));
- }
- }
-
- return result;
- }
-
- public String description() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/MigrationTitanStrategy.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/MigrationTitanStrategy.java
deleted file mode 100644
index 0274ca425e..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/MigrationTitanStrategy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.dao.TitanClientStrategy;
-
-public class MigrationTitanStrategy implements TitanClientStrategy {
-
- @Override
- public String getConfigFile() {
- return ConfigurationManager.getConfigurationManager().getConfiguration().getTitanMigrationKeySpaceCfgFile();
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/MigrationUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/MigrationUtils.java
deleted file mode 100644
index 04f810af5e..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/MigrationUtils.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-import org.apache.commons.lang.enums.Enum;
-import org.openecomp.sdc.asdctool.impl.migration.MigrationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class MigrationUtils {
-
- private static Logger LOGGER = LoggerFactory.getLogger(MigrationUtils.class);
-
- public static boolean handleError(String errorMsg) {
- LOGGER.error(errorMsg);
- return false;
- }
-
- public static <T> T handleError(T errorStatus, String errorMsg) {
- LOGGER.error(errorMsg);
- return errorStatus;
- }
-
- public static <A> A willThrowException(String withMsg) {
- throw new MigrationException(withMsg);
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/RenameGraphPropertyKeys.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/RenameGraphPropertyKeys.java
deleted file mode 100644
index 9f571167db..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/RenameGraphPropertyKeys.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-import org.openecomp.sdc.asdctool.impl.migration.*;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.HashMap;
-import java.util.Map;
-
-@Component("renameGraphPropertyKeysMigration")
-public class RenameGraphPropertyKeys implements Migration1707Task {
-
- private final static Map<String, String> KEY_PROPERTIES_TO_RENAME;
-
- @Autowired
- private MigrationOperationUtils migrationUtils;
-
- static {
- KEY_PROPERTIES_TO_RENAME = new HashMap<>();
- KEY_PROPERTIES_TO_RENAME.put("attuid", GraphPropertiesDictionary.USERID.getProperty());
- KEY_PROPERTIES_TO_RENAME.put("pmatt", GraphPropertiesDictionary.PROJECT_CODE.getProperty());
- KEY_PROPERTIES_TO_RENAME.put("attContact", GraphPropertiesDictionary.CONTACT_ID.getProperty());
- KEY_PROPERTIES_TO_RENAME.put("attCreator", GraphPropertiesDictionary.CREATOR_ID.getProperty());
- }
-
- @Override
- public boolean migrate() {
- return migrationUtils.renamePropertyKeys(KEY_PROPERTIES_TO_RENAME);
- }
-
- @Override
- public String description() {
- return MigrationMsg.RENMAE_KEY_PROPERTIES_1707.getMessage();
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/ToscaNamesUpdate.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/ToscaNamesUpdate.java
deleted file mode 100644
index 665fe15315..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/ToscaNamesUpdate.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.ImmutableTriple;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.openecomp.sdc.asdctool.impl.migration.Migration1707Task;
-import org.openecomp.sdc.be.dao.graph.GraphElementFactory;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.resources.data.AttributeData;
-import org.openecomp.sdc.be.resources.data.AttributeValueData;
-import org.openecomp.sdc.be.resources.data.CapabilityData;
-import org.openecomp.sdc.be.resources.data.CapabilityTypeData;
-import org.openecomp.sdc.be.resources.data.DataTypeData;
-import org.openecomp.sdc.be.resources.data.GroupData;
-import org.openecomp.sdc.be.resources.data.GroupTypeData;
-import org.openecomp.sdc.be.resources.data.InputValueData;
-import org.openecomp.sdc.be.resources.data.InputsData;
-import org.openecomp.sdc.be.resources.data.PolicyTypeData;
-import org.openecomp.sdc.be.resources.data.PropertyData;
-import org.openecomp.sdc.be.resources.data.PropertyValueData;
-import org.openecomp.sdc.be.resources.data.RelationshipInstData;
-import org.openecomp.sdc.be.resources.data.RelationshipTypeData;
-import org.openecomp.sdc.be.resources.data.RequirementData;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.thinkaurelius.titan.core.TitanVertex;
-
-import fj.data.Either;
-
-@Component("toscaNamesUpdate")
-public class ToscaNamesUpdate implements Migration1707Task {
- private static Logger log = LoggerFactory.getLogger(ToscaNamesUpdate.class.getName());
-
- @Override
- public String description() {
- return "toscaNamesUpdate";
- }
-
- @Autowired
- protected TitanGenericDao titanGenericDao;
-
- @Override
- public boolean migrate() {
- boolean result = true;
- List<ImmutableTriple<NodeTypeEnum, Class<GraphNode>, Function<GraphNode, ImmutablePair<String, GraphNode>>>> updateInfoList = new ArrayList<>();
- for (NodeTypeEnum nodeType : NodeTypeEnum.values()){
- ImmutableTriple<NodeTypeEnum, Class<GraphNode>, Function<GraphNode, ImmutablePair<String, GraphNode>>> updateInfo = getInfo(nodeType);
- if(null == updateInfo)
- continue;
- updateInfoList.add(updateInfo);
- }
-
- for(ImmutableTriple<NodeTypeEnum, Class<GraphNode>, Function<GraphNode, ImmutablePair<String, GraphNode>>> nodeTypeData : updateInfoList){
- log.debug("before updating namespace on nodeType {}", nodeTypeData.left.getName());
- result = updateNamespaceByNodeType(nodeTypeData);
- if(!result){
- log.debug("alignNamespace procedure failed during execution of updating namespace on nodeType {}", nodeTypeData.left.getName());
- return false;
- }
- }
- return true;
- }
-
- private <T extends GraphNode> ImmutableTriple<NodeTypeEnum, Class<T>, Function<T, ImmutablePair<String, T>>> getInfo(NodeTypeEnum nodeType) {
- switch (nodeType) {
- case Resource:
- Function<ResourceMetadataData, ImmutablePair<String, ResourceMetadataData>> resourceFunc = r -> updateResource(r);
- return new ImmutableTriple(nodeType, ResourceMetadataData.class, resourceFunc);
- case GroupType:
- Function<GroupTypeData, ImmutablePair<String, GroupTypeData>> groupTypeFunc = g -> updateGroupType(g);
- return new ImmutableTriple(nodeType, GroupTypeData.class, groupTypeFunc);
- case Group:
- Function<GroupData, ImmutablePair<String, GroupData>> groupFunc = g -> updateGroupNode(g);
- return new ImmutableTriple(nodeType, GroupData.class, groupFunc);
- case PolicyType:
- Function<PolicyTypeData, ImmutablePair<String , PolicyTypeData>> policyFunc = p -> updatePolicyType(p);
- return new ImmutableTriple(nodeType, PolicyTypeData.class, policyFunc);
- case RelationshipType:
- Function<RelationshipTypeData, ImmutablePair<String, RelationshipTypeData>> relTypeFunc = r -> updateRelationshipType(r);
- return new ImmutableTriple(nodeType, RelationshipTypeData.class, relTypeFunc);
- case RelationshipInst:
- Function<RelationshipInstData, ImmutablePair<String, RelationshipInstData>> relFunc = r -> updateRelationshipNode(r);
- return new ImmutableTriple(nodeType, RelationshipInstData.class, relFunc);
- case Requirement:
- Function<RequirementData, ImmutablePair<String, RequirementData>> reqFunc = r -> updateRequirementType(r);
- return new ImmutableTriple(nodeType, RequirementData.class, reqFunc);
- case CapabilityType:
- Function<CapabilityTypeData, ImmutablePair<String, CapabilityTypeData>> capTypeFunc = c -> updateCapabilityType(c);
- return new ImmutableTriple(nodeType, CapabilityTypeData.class, capTypeFunc);
- case Capability:
- Function<CapabilityData, ImmutablePair<String, CapabilityData>> capFunc = c -> updateCapabilityNode(c);
- return new ImmutableTriple(nodeType, CapabilityData.class, capFunc);
- case Property:
- Function<PropertyData, ImmutablePair<String, PropertyData>> propFunc = p -> updatePropNode(p);
- return new ImmutableTriple(nodeType, PropertyData.class, propFunc);
- case PropertyValue:
- Function<PropertyValueData, ImmutablePair<String, PropertyValueData>> propValueFunc = p -> updatePropValueNode(p);
- return new ImmutableTriple(nodeType, PropertyValueData.class, propValueFunc);
- case Attribute:
- Function<AttributeData, ImmutablePair<String, AttributeData>> attrFunc = a -> updateAttributeNode(a);
- return new ImmutableTriple(nodeType, AttributeData.class, attrFunc);
- case AttributeValue:
- Function<AttributeValueData, ImmutablePair<String, AttributeValueData>> attrValueFunc = a -> updateAttrValueNode(a);
- return new ImmutableTriple(nodeType, AttributeValueData.class, attrValueFunc);
- case Input:
- Function<InputsData, ImmutablePair<String, InputsData>> inputFunc = i -> updateInputNode(i);
- return new ImmutableTriple(nodeType, InputsData.class, inputFunc);
- case InputValue:
- Function<InputValueData, ImmutablePair<String, InputValueData>> inputValueFunc = i -> updateInputValueNode(i);
- return new ImmutableTriple(nodeType, InputValueData.class, inputValueFunc);
- case DataType:
- Function<DataTypeData, ImmutablePair<String, DataTypeData>> dataTypeFunc = d -> updateDataType(d);
- return new ImmutableTriple(nodeType, DataTypeData.class, dataTypeFunc);
- default:
- return null;
- }
-
- }
-
-
-
- private boolean ifRight(TitanOperationStatus status){
- return TitanOperationStatus.NOT_FOUND == status;
- }
-
- private <T extends GraphNode> boolean ifLeft(List<T> allNodes, ImmutableTriple<NodeTypeEnum, Class<T>, Function<T, ImmutablePair<String, T>>> nodeTypeData){
- boolean result = true;
- try {
- for (T node : allNodes) {
- ImmutablePair<String, T> nodeToUpdate = nodeTypeData.right.apply(node);
- Either<T, TitanOperationStatus> updatedNode = updateNodeIncludingUID(nodeToUpdate.left, nodeToUpdate.right, nodeTypeData.middle);
- if (updatedNode.isRight()) {
- result = false;
- break;
- }
- }
- } finally {
- if (!result) {
- titanGenericDao.rollback();
- } else {
- titanGenericDao.commit();
- }
- }
- return result;
- }
-
- private <T extends GraphNode> boolean updateNamespaceByNodeType(ImmutableTriple<NodeTypeEnum, Class<T>, Function<T, ImmutablePair<String, T>>> nodeTypeData) {
- Either<List<T>, TitanOperationStatus> getAllNodes = titanGenericDao.getByCriteria(nodeTypeData.left, null, nodeTypeData.middle);
- return getAllNodes.either(list -> ifLeft(list, nodeTypeData), status -> ifRight(status));
- }
-
- private ImmutablePair<String, ResourceMetadataData> updateResource(ResourceMetadataData resource) {
- String toscaResourceName = updateNamespace(((ResourceMetadataDataDefinition) resource.getMetadataDataDefinition()).getToscaResourceName());
- ((ResourceMetadataDataDefinition) resource.getMetadataDataDefinition()).setToscaResourceName(toscaResourceName);
- return new ImmutablePair<>((String) resource.getUniqueId(), resource);
- }
-
- private ImmutablePair<String, GroupTypeData> updateGroupType(GroupTypeData group) {
- String originId = group.getUniqueId();
- group.getGroupTypeDataDefinition().setUniqueId(updateNamespace(originId));
- String type = updateNamespace(group.getGroupTypeDataDefinition().getType());
- group.getGroupTypeDataDefinition().setType(type);
- return new ImmutablePair<>(originId, group);
- }
-
- private ImmutablePair<String, GroupData> updateGroupNode(GroupData group) {
- String type = updateNamespace(group.getGroupDataDefinition().getType());
- group.getGroupDataDefinition().setType(type);
- return new ImmutablePair<>((String) group.getUniqueId(), group);
- }
-
-
- private ImmutablePair<String, PolicyTypeData> updatePolicyType(PolicyTypeData policy) {
- String originId = policy.getUniqueId();
- policy.getPolicyTypeDataDefinition().setUniqueId(updateNamespace(originId));
- String type = updateNamespace(policy.getPolicyTypeDataDefinition().getType());
- policy.getPolicyTypeDataDefinition().setType(type);
- return new ImmutablePair<>(originId, policy);
- }
-
- private ImmutablePair<String, RelationshipTypeData> updateRelationshipType(RelationshipTypeData relation) {
- String type = updateNamespace(relation.getRelationshipTypeDataDefinition().getType());
- relation.getRelationshipTypeDataDefinition().setType(type);
- List<String> validSources = relation.getRelationshipTypeDataDefinition().getValidSourceTypes();
- if(null != validSources){
- List<String> validSourceTypes = new ArrayList<>();
- for (String validSourceType : validSources) {
- validSourceTypes.add(updateNamespace(validSourceType));
- }
- relation.getRelationshipTypeDataDefinition().setValidSourceTypes(validSourceTypes);
- }
- return new ImmutablePair<>(relation.getUniqueId(), relation);
- }
-
- private ImmutablePair<String, RelationshipInstData> updateRelationshipNode(RelationshipInstData relation) {
- String type = updateNamespace(relation.getType());
- relation.setType(type);
- return new ImmutablePair<>(relation.getUniqueId(), relation);
- }
-
- private ImmutablePair<String, RequirementData> updateRequirementType(RequirementData req) {
- String node = req.getNode();
- if(null != node)
- req.setNode(updateNamespace(node));
- String type = updateNamespace(req.getRelationshipType());
- req.setRelationshipType(type);
- return new ImmutablePair<>(req.getUniqueId(), req);
- }
-
- private ImmutablePair<String, CapabilityTypeData> updateCapabilityType(CapabilityTypeData capType) {
- String originId = capType.getUniqueId();
- capType.getCapabilityTypeDataDefinition().setUniqueId(updateNamespace(originId));
- String type = updateNamespace(capType.getCapabilityTypeDataDefinition().getType());
- capType.getCapabilityTypeDataDefinition().setType(type);
- List<String> validSources = capType.getCapabilityTypeDataDefinition().getValidSourceTypes();
- if(null != validSources){
- List<String> validSourceTypes = new ArrayList<>();
- for (String validSourceType : validSources) {
- validSourceTypes.add(updateNamespace(validSourceType));
- }
- capType.getCapabilityTypeDataDefinition().setValidSourceTypes(validSourceTypes);
- }
- return new ImmutablePair<>(originId, capType);
-
- }
-
- private ImmutablePair<String, CapabilityData> updateCapabilityNode(CapabilityData capNode) {
- List<String> validSources = capNode.getValidSourceTypes();
- if(null != validSources){
- List<String> validSourceTypes = new ArrayList<>();
- for (String validSourceType : validSources) {
- validSourceTypes.add(updateNamespace(validSourceType));
- }
- capNode.setValidSourceTypes(validSourceTypes);
- }
- return new ImmutablePair<>(capNode.getUniqueId(), capNode);
- }
-
-
- private ImmutablePair<String, PropertyData> updatePropNode(PropertyData propType) {
- String originId = (String)propType.getUniqueId();
- propType.getPropertyDataDefinition().setUniqueId(updateNamespace(originId));
- String type = updateNamespace(propType.getPropertyDataDefinition().getType());
- propType.getPropertyDataDefinition().setType(type);
- if ("list".equalsIgnoreCase(type) || "map".equalsIgnoreCase(type)){
- SchemaDefinition schema = propType.getPropertyDataDefinition().getSchema();
- if(null != schema && null != schema.getProperty())
- handleSchemaTypeDef(schema.getProperty());
- }
- return new ImmutablePair<>(originId, propType);
- }
-
- private ImmutablePair<String, PropertyValueData> updatePropValueNode(PropertyValueData prop) {
- String type = updateNamespace(prop.getType());
- prop.setType(type);
- return new ImmutablePair<>(prop.getUniqueId(), prop);
- }
-
- private ImmutablePair<String, AttributeValueData> updateAttrValueNode(AttributeValueData attr) {
- String type = updateNamespace(attr.getType());
- attr.setType(type);
- return new ImmutablePair<>(attr.getUniqueId(), attr);
- }
-
- private ImmutablePair<String, InputValueData> updateInputValueNode(InputValueData input) {
- String type = updateNamespace(input.getType());
- input.setType(type);
- return new ImmutablePair<>(input.getUniqueId(), input);
- }
-
- private ImmutablePair<String, InputsData> updateInputNode(InputsData input){
- String type = updateNamespace(input.getPropertyDataDefinition().getType());
- input.getPropertyDataDefinition().setType(type);
- if ("list".equalsIgnoreCase(type) || "map".equalsIgnoreCase(type)){
- SchemaDefinition schema = input.getPropertyDataDefinition().getSchema();
- if(null != schema && null != schema.getProperty())
- handleSchemaTypeDef(schema.getProperty());
- }
- return new ImmutablePair<>((String)input.getUniqueId(), input);
- }
-
-
- private void handleSchemaTypeDef(PropertyDataDefinition schemaProp) {
- String schemaType = updateNamespace(schemaProp.getType());
- schemaProp.setType(schemaType);
- }
-
- private ImmutablePair<String, DataTypeData> updateDataType(DataTypeData dataType) {
- String originId = dataType.getUniqueId();
- dataType.getDataTypeDataDefinition().setUniqueId(updateNamespace(originId));
- String name = updateNamespace(dataType.getDataTypeDataDefinition().getName());
- dataType.getDataTypeDataDefinition().setName(name);
- String derivedFromName = updateNamespace(dataType.getDataTypeDataDefinition().getDerivedFromName());
- dataType.getDataTypeDataDefinition().setDerivedFromName(derivedFromName);
- return new ImmutablePair<>(originId, dataType);
-
- }
-
- private ImmutablePair<String, AttributeData> updateAttributeNode(AttributeData attr){
- String type = updateNamespace(attr.getAttributeDataDefinition().getType());
- attr.getAttributeDataDefinition().setType(type);
- if("list".equalsIgnoreCase(type) || "map".equalsIgnoreCase(type)){
- SchemaDefinition schema = attr.getAttributeDataDefinition().getSchema();
- if(null != schema && null != schema.getProperty())
- handleSchemaTypeDef(schema.getProperty());
- }
- return new ImmutablePair<>(attr.getUniqueId(), attr);
- }
-
-
-
- private String updateNamespace(String oldName) {
- if (oldName == null) {
- return null;
- }
- String name = oldName.replace("com.att.d2.", "org.openecomp.");
- // correcting naming convention
- return name.replace("org.openecomp.resources.", "org.openecomp.resource.");
- }
-
- private <T extends GraphNode> T onSuccess(TitanVertex vertex, GraphNode node, Class<T> clazz){
- Map<String, Object> newProp = titanGenericDao.getProperties(vertex);
- return GraphElementFactory.createElement(node.getLabel(), GraphElementTypeEnum.Node, newProp, clazz);
- }
-
- private <T extends GraphNode> Either<T, TitanOperationStatus> handleNode(Vertex vertex, GraphNode node, Class<T> clazz){
- try {
-
- Map<String, Object> mapProps = node.toGraphMap();
-
- for (Map.Entry<String, Object> entry : mapProps.entrySet()) {
- vertex.property(entry.getKey(), entry.getValue());
- }
-
- Either<TitanVertex, TitanOperationStatus> vertexByPropertyAndLabel = titanGenericDao.getVertexByProperty(node.getUniqueIdKey(), node.getUniqueId());
- return vertexByPropertyAndLabel.either(v -> Either.left(onSuccess(v, node, clazz)), status -> Either.right(status));
-
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed to update node for {}", node.getKeyValueId(), e);
- }
- return Either.right(TitanGraphClient.handleTitanException(e));
- }
- }
-
- private <T extends GraphNode> Either<T, TitanOperationStatus> updateNodeIncludingUID(String originId, GraphNode node, Class<T> clazz) {
- Either<TitanVertex, TitanOperationStatus> vertexByProperty = titanGenericDao.getVertexByProperty(node.getUniqueIdKey(), originId);
- return vertexByProperty.either(vertex -> handleNode(vertex, node, clazz), status -> Either.right(status));
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/ToscaTemplateRegeneration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/ToscaTemplateRegeneration.java
deleted file mode 100644
index 7d009fe158..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/ToscaTemplateRegeneration.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-import java.util.EnumMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.openecomp.sdc.asdctool.impl.migration.Migration1707Task;
-import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
-import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
-import org.openecomp.sdc.be.resources.data.ESArtifactData;
-import org.openecomp.sdc.be.tosca.ToscaError;
-import org.openecomp.sdc.be.tosca.ToscaExportHandler;
-import org.openecomp.sdc.be.tosca.ToscaRepresentation;
-import org.openecomp.sdc.common.util.GeneralUtility;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import fj.data.Either;
-
-@Component("toscaTemplateRegeneration")
-public class ToscaTemplateRegeneration implements Migration1707Task {
-
- private static Logger LOGGER = LoggerFactory.getLogger(ToscaTemplateRegeneration.class);
-
- @Autowired
- protected ArtifactCassandraDao artifactCassandraDao;
-
- @Autowired
- private ToscaExportHandler toscaExportUtils;
-
- @Autowired
- private ToscaOperationFacade toscaOperationFacade;
-
- @Override
- public boolean migrate() {
- boolean result = true;
- Either<List<GraphVertex>, StorageOperationStatus> getAllCertifiedComponentsRes;
- try{
- getAllCertifiedComponentsRes = getAllCertifiedComponents();
- if(getAllCertifiedComponentsRes.isRight()){
- result = false;
- }
- if(result && CollectionUtils.isNotEmpty(getAllCertifiedComponentsRes.left().value())){
- result = regenerateToscaTemplateArtifacts(getAllCertifiedComponentsRes.left().value());
- }
- } catch(Exception e){
- LOGGER.error("The exception {} has been occured upon tosca template regeneration migration. ", e);
- result = false;
- } finally {
- if(result){
- toscaOperationFacade.commit();
- } else {
- toscaOperationFacade.rollback();
- }
- }
- return result;
- }
-
- private boolean regenerateToscaTemplateArtifacts(List<GraphVertex> components) {
- boolean result = true;
- for(GraphVertex componentV : components){
- String componentId = componentV.getUniqueId();
- Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentsRes = toscaOperationFacade.getToscaElement(componentId);
- if (getComponentsRes.isRight()) {
- result = false;
- break;
- }
- if(getComponentsRes.left().value().getToscaArtifacts()!=null && getComponentsRes.left().value().getToscaArtifacts().containsKey(ToscaExportHandler.ASSET_TOSCA_TEMPLATE)){
- result = regenerateToscaTemplateArtifact(getComponentsRes.left().value(), componentV);
- }
- if(result){
- toscaOperationFacade.commit();
- } else {
- toscaOperationFacade.rollback();
- break;
- }
- }
- return result;
- }
-
- @SuppressWarnings("unchecked")
- private boolean regenerateToscaTemplateArtifact(org.openecomp.sdc.be.model.Component parent, GraphVertex parentV) {
- boolean result = true;
- Either<GraphVertex, TitanOperationStatus> toscaDataVertexRes = null;
- ArtifactDataDefinition data = null;
- LOGGER.debug("tosca artifact generation");
- Either<ToscaRepresentation, ToscaError> exportComponent = toscaExportUtils.exportComponent(parent);
- if (exportComponent.isRight()) {
- LOGGER.debug("Failed export tosca yaml for component {} error {}", parent.getUniqueId(), exportComponent.right().value());
- result = false;
- }
- if(result){
- LOGGER.debug("Tosca yaml exported for component {} ", parent.getUniqueId());
- toscaDataVertexRes = toscaOperationFacade.getTitanDao().getChildVertex(parentV, EdgeLabelEnum.TOSCA_ARTIFACTS, JsonParseFlagEnum.ParseJson);
- if(toscaDataVertexRes.isRight()){
- LOGGER.debug("Failed to fetch tosca data vertex {} for component {}. Status is {}", EdgeLabelEnum.TOSCA_ARTIFACTS, parent.getUniqueId(), exportComponent.right().value());
- result = false;
- }
- }
- if(result){
- data = parent.getToscaArtifacts().get(ToscaExportHandler.ASSET_TOSCA_TEMPLATE);
- data.setArtifactChecksum(GeneralUtility.calculateMD5ByByteArray(exportComponent.left().value().getMainYaml().getBytes()));
-
- ((Map<String, ArtifactDataDefinition>) toscaDataVertexRes.left().value().getJson()).put(ToscaExportHandler.ASSET_TOSCA_TEMPLATE, data);
-
- Either<GraphVertex, TitanOperationStatus> updateVertexRes = toscaOperationFacade.getTitanDao().updateVertex(toscaDataVertexRes.left().value());
- if(updateVertexRes.isRight()){
- result = false;
- }
- }
- if(result){
- ESArtifactData artifactData = new ESArtifactData(data.getEsId(), exportComponent.left().value().getMainYaml().getBytes());
- CassandraOperationStatus status = artifactCassandraDao.saveArtifact(artifactData);
- if(status != CassandraOperationStatus.OK){
- result = false;
- }
- }
- return result;
- }
-
- public Either<List<GraphVertex>, StorageOperationStatus> getAllCertifiedComponents() {
-
- Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
- propertiesToMatch.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
- List<GraphVertex> components = null;
- Either<List<GraphVertex>, TitanOperationStatus> getVerticiesRes = toscaOperationFacade.getTitanDao().getByCriteria(null, propertiesToMatch,JsonParseFlagEnum.NoParse);
-
- if (getVerticiesRes.isRight() && getVerticiesRes.right().value() != TitanOperationStatus.NOT_FOUND) {
- LOGGER.debug("Failed to fetch all certified components. Status is {}", getVerticiesRes.right().value());
- return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getVerticiesRes.right().value()));
- }
- if(getVerticiesRes.isLeft()){
- components = getVerticiesRes.left().value();
- }
- return Either.left(components);
- }
-
- @Override
- public String description() {
- return "toscaTemplateRegeneration";
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/VfModulesPropertiesAdding.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/VfModulesPropertiesAdding.java
deleted file mode 100644
index 89ac6f7cb6..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/VfModulesPropertiesAdding.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707;
-
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-import javax.annotation.Resource;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.openecomp.sdc.asdctool.impl.migration.v1702.DataTypesUpdate;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
-import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.DataTypeDefinition;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.GroupInstance;
-import org.openecomp.sdc.be.model.GroupInstanceProperty;
-import org.openecomp.sdc.be.model.GroupProperty;
-import org.openecomp.sdc.be.model.GroupTypeDefinition;
-import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.jsontitan.operations.BaseOperation;
-import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
-import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation;
-import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
-import org.openecomp.sdc.be.resources.data.PropertyData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import fj.data.Either;
-
-@Component("vfModulesPropertiesAdding")
-public class VfModulesPropertiesAdding {
-
- private static Logger LOGGER = LoggerFactory.getLogger(VfModulesPropertiesAdding.class);
-
- @Autowired
- private ToscaOperationFacade toscaOperationFacade;
-
- @Autowired
- private TopologyTemplateOperation topologyTemplateOperation;
-
- @Resource(name ="group-type-operation-mig")
- private GroupTypeOperation groupTypeOperation;
-
- @Resource(name = "property-operation-mig")
- private PropertyOperation propertyOperation;
-
-
- public boolean migrate(String groupsTypeYmlFilePath) {
- LOGGER.debug("Going to add new properties to vfModules. ");
- boolean result = true;
- GroupTypeDefinition vfModule;
- Either<List<GraphVertex>, TitanOperationStatus> getAllTopologyTemplatesRes = null;
- String vfModuleUid = "org.openecomp.groups.VfModule.1.0.grouptype";
- Either<GroupTypeDefinition, TitanOperationStatus> getGroupTypeVfModuleRes ;
- List<PropertyDefinition> updatedProperties = null;
- try{
- LOGGER.debug("Going to fetch {}. ", vfModuleUid);
- getGroupTypeVfModuleRes = groupTypeOperation.getGroupTypeByUid(vfModuleUid);
-
- if(getGroupTypeVfModuleRes.isRight() && getGroupTypeVfModuleRes.right().value() != TitanOperationStatus.NOT_FOUND){
- LOGGER.debug("Failed to fetch the group type {}. The status is {}. ", vfModuleUid, getGroupTypeVfModuleRes.right().value());
- result = false;
- }
- if(getGroupTypeVfModuleRes.isRight() && getGroupTypeVfModuleRes.right().value() == TitanOperationStatus.NOT_FOUND){
- LOGGER.debug("The group type with id {} was not found. Skipping adding the new properties. ", vfModuleUid);
- return true;
- }
- if(result){
- LOGGER.debug("Going to add the new properties {} to org.openecomp.groups.VfModule.1.0.grouptype. ");
- vfModule = getGroupTypeVfModuleRes.left().value();
- updatedProperties = getAllVfModuleTypePropertiesFromYaml(groupsTypeYmlFilePath);
- result = addNewPropertiesToGroupType(vfModule, getNewVfModuleTypeProperties(updatedProperties, vfModule));
- if(!result){
- LOGGER.debug("Failed to add the new properties {} to org.openecomp.groups.VfModule.1.0.grouptype. ");
- }
- }
- if(result && CollectionUtils.isNotEmpty(updatedProperties)){
- Map<GraphPropertyEnum, Object> propsHasNot = new EnumMap<>(GraphPropertyEnum.class);
- propsHasNot.put(GraphPropertyEnum.IS_DELETED, true);
- getAllTopologyTemplatesRes = toscaOperationFacade.getTitanDao().getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, null, propsHasNot, JsonParseFlagEnum.ParseAll);
- if (getAllTopologyTemplatesRes.isRight() && getAllTopologyTemplatesRes.right().value() != TitanOperationStatus.NOT_FOUND) {
- LOGGER.debug("Failed to fetch all non marked topology templates , propsHasNot {}, error {}", propsHasNot, getAllTopologyTemplatesRes.right().value());
- result = false;
- }
- }
- if(result && getAllTopologyTemplatesRes!=null && getAllTopologyTemplatesRes.isLeft()){
- result = addNewVfModulesProperties(getAllTopologyTemplatesRes.left().value(), updatedProperties);
- }
- } catch (Exception e){
- result = false;
- }
- finally{
- if(result){
- toscaOperationFacade.commit();
- } else {
- toscaOperationFacade.rollback();
- }
- }
- return result;
- }
-
- private boolean addNewVfModulesProperties(List<GraphVertex> components, List<PropertyDefinition> updatedProperties) {
- boolean result = true;
- for(GraphVertex component : components){
- LOGGER.debug("Going to add the new properties {} to component {}. ", updatedProperties, component.getUniqueId());
- result = addNewPropertiesToVfModules(component, updatedProperties);
- if(!result){
- LOGGER.debug("Failed to add the new properties {} to component {}. ", updatedProperties, component.getUniqueId());
- break;
- }
- toscaOperationFacade.commit();
- }
- return result;
- }
-
- private boolean addNewPropertiesToVfModules(GraphVertex componentV, List<PropertyDefinition> updatedProperties) {
- boolean result = true;
- List<GroupDefinition> vfModules = null;
- Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getToscaElementRes = toscaOperationFacade.getToscaElement(componentV);
- if(getToscaElementRes.isRight()){
- LOGGER.debug("Failed to fetch the component {}. ", componentV.getUniqueId());
- result = false;
- }
- else if(CollectionUtils.isNotEmpty(getToscaElementRes.left().value().getGroups())){
- vfModules = getToscaElementRes.left().value().getGroups().stream().filter(g -> g.getType().equals(BaseOperation.VF_MODULE)).collect(Collectors.toList());
- }
- if(vfModules != null){
- vfModules.forEach(vfModule -> addAllNewProperties(vfModule.getProperties(), updatedProperties));
- StorageOperationStatus status = topologyTemplateOperation.updateToscaDataOfToscaElement(componentV, EdgeLabelEnum.GROUPS, VertexTypeEnum.GROUPS, vfModules, JsonPresentationFields.NAME);
- if(status!= StorageOperationStatus.OK){
- LOGGER.debug("Failed to add the new properties {} to groups of component {}. ", updatedProperties, componentV.getUniqueId());
- result = false;
- }
- }
- if(result && CollectionUtils.isNotEmpty(getToscaElementRes.left().value().getComponentInstances())){
- result = addPropertiesToVfModuleInstances(getToscaElementRes.left().value(), componentV, updatedProperties);
- }
- return result;
- }
-
- private void addAllNewProperties(List<PropertyDataDefinition> vfModuleProperties, List<PropertyDefinition> updatedProperties) {
- Map<String, PropertyDataDefinition> propertiesMap = vfModuleProperties.stream().collect(Collectors.toMap(p->p.getName(), p->p));
-
- for(PropertyDefinition property : updatedProperties){
- if(!propertiesMap.containsKey(property.getName())){
- vfModuleProperties.add(property);
- }
- }
- }
-
- private boolean addPropertiesToVfModuleInstances(org.openecomp.sdc.be.model.Component component, GraphVertex componentV, List<PropertyDefinition> updatedProperties) {
- boolean result = true;
- List<GroupInstance> vfModuleInstances;
- List<String> pathKeys;
- LOGGER.debug("Going to add the new properties {} to group instances of component {}. ", updatedProperties, componentV.getUniqueId());
- for(ComponentInstance componentInstance : component.getComponentInstances()){
- vfModuleInstances = null;
- if(CollectionUtils.isNotEmpty(componentInstance.getGroupInstances())){
- vfModuleInstances = componentInstance.getGroupInstances()
- .stream()
- .filter(gi -> gi.getType().equals(BaseOperation.VF_MODULE))
- .collect(Collectors.toList());
- }
- if(vfModuleInstances != null){
- for(GroupInstance vfModuleInstance :vfModuleInstances){
- addAllNewProperties(vfModuleInstance.getProperties(),updatedProperties);
- pathKeys = new ArrayList<>();
- pathKeys.add(componentInstance.getUniqueId());
- StorageOperationStatus status = topologyTemplateOperation
- .updateToscaDataDeepElementOfToscaElement(componentV, EdgeLabelEnum.INST_GROUPS, VertexTypeEnum.INST_GROUPS, vfModuleInstance, pathKeys, JsonPresentationFields.NAME);
- if(status!= StorageOperationStatus.OK){
- result = false;
- LOGGER.debug("Failed to add the new properties {} to group instances of component {}. ", updatedProperties, componentV.getUniqueId());
- break;
- }
- }
- if(!result){
- LOGGER.debug("Failed to add the new properties {} to group instances of component {}. ", updatedProperties, componentV.getUniqueId());
- break;
- }
- }
- }
- return result;
- }
-
- private boolean addNewPropertiesToGroupType(GroupTypeDefinition vfModule, List<PropertyDefinition> newProperties) {
- boolean result = true;
- Either<Map<String, PropertyData>, TitanOperationStatus> addPropertiesRes = propertyOperation
- .addPropertiesToElementType(vfModule.getUniqueId(), NodeTypeEnum.GroupType, newProperties);
- if(addPropertiesRes.isRight()){
- result = false;
- }
- return result;
- }
-
- private List<PropertyDefinition> getAllVfModuleTypePropertiesFromYaml(String groupsTypeYmlFilePath) {
- List<DataTypeDefinition> groupTypes = DataTypesUpdate.extractDataTypesFromYaml(groupsTypeYmlFilePath);
- DataTypeDefinition vfModule = groupTypes.stream().filter(g -> g.getName().equals(BaseOperation.VF_MODULE)).findFirst().orElse(null);
- return vfModule.getProperties();
- }
-
- private List<PropertyDefinition> getNewVfModuleTypeProperties(List<PropertyDefinition> allVfModuleTypeProperties, GroupTypeDefinition vfModule) {
- Map<String, PropertyDefinition> existingVfModuleTypeProperties = vfModule.getProperties()
- .stream()
- .collect(Collectors.toMap(p -> p.getName(), p -> p));
-
- List<PropertyDefinition> newGroupTypeProperties = new ArrayList<>();
- for(PropertyDefinition property : allVfModuleTypeProperties){
- if(!existingVfModuleTypeProperties.containsKey(property.getName())){
- newGroupTypeProperties.add(property);
- }
- }
- return newGroupTypeProperties;
- }
-
- public String description() {
- return "vfModulesPropertiesAdding";
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/CategoriesUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/CategoriesUtils.java
deleted file mode 100644
index 44d95395d0..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/CategoriesUtils.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class CategoriesUtils {
-
- public static final String OLD_CATEGORY_ID_SUB_STR = "layer";
-
- public static List<CategoryDefinition> filterOldCategories(List<CategoryDefinition> categoryDefinitions) {
- return categoryDefinitions.stream()
- .filter(categoryDefinition -> !categoryDefinition.getUniqueId().contains(OLD_CATEGORY_ID_SUB_STR))
- .collect(Collectors.toList());
- }
-
- public static List<SubCategoryDefinition> filterOldSubCategories(List<SubCategoryDefinition> categoryDefinitions) {
- return categoryDefinitions.stream()
- .filter(categoryDefinition -> !categoryDefinition.getUniqueId().contains(OLD_CATEGORY_ID_SUB_STR))
- .collect(Collectors.toList());
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ComponentMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ComponentMigration.java
deleted file mode 100644
index 7603a5704a..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ComponentMigration.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import fj.data.Either;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel.relations.RequirementsCapabilitiesMigrationService;
-import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.GroupInstance;
-import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
-import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementLifecycleOperation;
-import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.migration.MigrationMalformedDataLogger;
-import org.openecomp.sdc.common.api.ArtifactTypeEnum;
-import org.openecomp.sdc.common.api.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Resource;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import static org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationUtils.handleError;
-
-public abstract class ComponentMigration <T extends Component> extends JsonModelMigration<T> {
-
- private static Logger LOGGER = LoggerFactory.getLogger(ComponentMigration.class);
-
- @Resource(name = "tosca-operation-facade")
- private ToscaOperationFacade toscaOperations;
-
- @Resource(name = "req-cap-mig-service")
- RequirementsCapabilitiesMigrationService<T> requirementsCapabilitiesMigrationService;
-
- @Resource(name = "invariant-uuid-resolver")
- private InvariantUUIDResolver <T> invariantUUIDResolver;
-
- @Resource(name = "node-template-missing-data-resolver")
- private NodeTemplateMissingDataResolver nodeTemplateMissingDataResolver;
-
- @Override
- boolean save(T element) {
- LOGGER.debug(String.format("creating component %s in new graph", element.getName()));
- return toscaOperations.createToscaComponent(element)
- .either(savedNode -> true,
- err -> handleError(String.format("failed to create component %s with id %s. reason: %s", element.getName(), element.getUniqueId(), err.name())));
- }
-
- @Override
- Either<T, StorageOperationStatus> getElementFromNewGraph(T element) {
- LOGGER.debug(String.format("checking if component %s already exists on new graph", element.getName()));
- return toscaOperations.getToscaElement(element.getUniqueId(), JsonParseFlagEnum.ParseMetadata);
- }
-
- @Override
- public StorageOperationStatus getNotFoundErrorStatus() {
- return StorageOperationStatus.NOT_FOUND;
- }
-
- @Override
- void doPreMigrationOperation(List<T> elements) {
- setMissingInvariantUids(elements);
- }
-
- //some invariants uids are missing in production
- private void setMissingInvariantUids(List<T> components) {
- List<T> missingInvariantCmpts = getComponentsWithNoInvariantUUIDs(components);
- for (T missingInvariantCmpt : missingInvariantCmpts) {
- missingInvariantCmpt.setInvariantUUID(invariantUUIDResolver.resolveInvariantUUID(components, missingInvariantCmpt));
- }
- }
-
- private List<T> getComponentsWithNoInvariantUUIDs(List<T> components) {
- List<T> cmptsWithoutInvariant = components.stream().filter(c -> c.getInvariantUUID() == null).collect(Collectors.toList());
- if (!cmptsWithoutInvariant.isEmpty()) {
- cmptsWithoutInvariant.forEach(cmpt -> MigrationMalformedDataLogger.logMalformedDataMsg(String.format("component %s is missing invariant uuid", cmpt.getUniqueId())));
- }
- return cmptsWithoutInvariant;
- }
-
-
- protected void setMissingTemplateInfo(List<T> components) {
- Map<String, ToscaElement> origCompMap = new HashMap<>();
- for (T component : components) {
- List<ComponentInstance> instances = component.getComponentInstances();
- if(null != instances) {
- for (ComponentInstance instance : instances) {
- nodeTemplateMissingDataResolver.resolveNodeTemplateInfo(instance, origCompMap, component);
- nodeTemplateMissingDataResolver.fixVFGroupInstances(component, instance);
- }
- }
- nodeTemplateMissingDataResolver.fixVFGroups(component);
- }
- }
-
-
-
-
-
-
-
-
-
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ConsumersMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ConsumersMigration.java
deleted file mode 100644
index c455f870aa..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ConsumersMigration.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import fj.data.Either;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.ConsumerOperation;
-import org.openecomp.sdc.be.resources.data.ConsumerData;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-import static org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationUtils.handleError;
-
-public class ConsumersMigration extends JsonModelMigration<ConsumerData> {
-
- @Resource(name = "consumer-operation")
- private ConsumerOperation consumerOperation;
-
- @Resource(name = "consumer-operation-mig")
- private ConsumerOperation consumerOperationMigration;
-
- @Override
- Either<List<ConsumerData>, ?> getElementsToMigrate() {
- return consumerOperation.getAll();
- }
-
- @Override
- Either<ConsumerData, ?> getElementFromNewGraph(ConsumerData element) {
- return consumerOperationMigration.getCredentials(element.getConsumerDataDefinition().getConsumerName());
- }
-
- @Override
- boolean save(ConsumerData element) {
- return consumerOperationMigration.createCredentials(element)
- .either(savedConsumer -> true,
- err -> handleError(String.format("failed to save consumer %s. reason: %s", element.getConsumerDataDefinition().getConsumerName(), err.name())));
- }
-
- @Override
- StorageOperationStatus getNotFoundErrorStatus() {
- return StorageOperationStatus.NOT_FOUND;
- }
-
- @Override
- public String description() {
- return "consumers migration";
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/InvariantUUIDResolver.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/InvariantUUIDResolver.java
deleted file mode 100644
index e26a01e1b4..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/InvariantUUIDResolver.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.operations.migration.MigrationMalformedDataLogger;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Optional;
-
-public class InvariantUUIDResolver <T extends Component> {
-
- public String resolveInvariantUUID(List<T> components, T missingInvariantCmpt) {
- String uuid = missingInvariantCmpt.getUUID();
- String systemName = missingInvariantCmpt.getSystemName();
- String invariantUid = findInvariantUUidByAllVersionsMap(missingInvariantCmpt, components).orElseGet(() -> findInvariantUUidByUUIDOrSystemName(components, uuid, systemName));
- if (invariantUid == null) {
- MigrationMalformedDataLogger.logMalformedDataMsg(String.format("could not find invariant uuid for component %s with id %s", missingInvariantCmpt.getName(), missingInvariantCmpt.getUniqueId()));
- }
- return invariantUid;
- }
-
- private String findInvariantUUidByUUIDOrSystemName(List<T> components, String uuid, String systemName) {
- return components.stream()
- .filter(c -> c.getUUID().equals(uuid) || c.getSystemName().equals(systemName))
- .map(Component::getInvariantUUID)
- .filter(c -> c != null)
- .findAny().orElse(null);
- }
-
- private Optional<String> findInvariantUUidByAllVersionsMap(T component, List<T> allComponents) {
- if (component.getAllVersions() == null) return Optional.empty();
- Collection<String> allVersionsComponentIds = component.getAllVersions().values();
- return allComponents.stream().filter(c -> allVersionsComponentIds.contains(c.getUniqueId()))
- .map(Component::getInvariantUUID)
- .filter(c -> c != null)
- .findAny();
-
-
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/JsonModelMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/JsonModelMigration.java
deleted file mode 100644
index 76c66de1c9..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/JsonModelMigration.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import fj.data.Either;
-import org.openecomp.sdc.asdctool.impl.migration.Migration1707Task;
-import org.openecomp.sdc.asdctool.impl.migration.MigrationMsg;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationUtils;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-public abstract class JsonModelMigration<T> implements Migration1707Task {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(JsonModelMigration.class);
-
- @Resource(name = "titan-dao")
- TitanDao titanDao;
-
- @Override
- public boolean migrate() {
- Either<List<T>, ?> elementsToMigrate = getElementsToMigrate();
- return elementsToMigrate.either(this::migrateElementsToNewGraph,
- errorStatus -> MigrationUtils.handleError(MigrationMsg.FAILED_TO_RETRIEVE_NODES.getMessage(errorStatus.toString())));
- }
-
- boolean doPostSaveOperation(T element) {
- return true;
- }
-
- boolean doPostMigrateOperation(List<T> elements) {
- return true;
- }
-
- void doPreMigrationOperation(List<T> elements){}
-
- private boolean migrateElementsToNewGraph(List<T> elementsToMigrate) {
- LOGGER.info(this.description() + ": starting to migrate elements to new graph. elements to migrate: {}", elementsToMigrate.size());
- doPreMigrationOperation(elementsToMigrate);
- for (T node : elementsToMigrate) {
- boolean migratedSuccessfully = migrateElement(node);
- if (!migratedSuccessfully) {
- titanDao.rollback();
- return false;
- }
- titanDao.commit();
- }
- return postMigrate(elementsToMigrate);
- }
-
- private boolean migrateElement(T node) {
- boolean savedSuccessfully = saveElementIfNotExists(node);
- return savedSuccessfully && doPostSaveOperation(node);
- }
-
- private boolean postMigrate(List<T> elements) {
- boolean postMigrateSuccessfully = doPostMigrateOperation(elements);
- if (!postMigrateSuccessfully) {
- titanDao.rollback();
- return false;
- }
- titanDao.commit();
- return true;
- }
-
- private boolean saveElementIfNotExists(T element) {
- return isExists(element).either(isExist -> isExist || save(element),
- status -> MigrationUtils.handleError(MigrationMsg.FAILED_TO_GET_NODE_FROM_GRAPH.getMessage(status.toString())));
- }
-
-
- private Either<Boolean, ?> isExists(T element) {
- Either<T, ?> byId = getElementFromNewGraph(element);
- return byId.either(existingVal -> Either.left(true),
- this::getEitherNotExistOrErrorStatus);
- }
-
- private <S> Either<Boolean, S> getEitherNotExistOrErrorStatus(S status) {
- return status == getNotFoundErrorStatus() ? Either.left(false) : Either.right(status);
- }
-
- abstract Either<List<T>, ?> getElementsToMigrate();
-
- abstract Either<T, ?> getElementFromNewGraph(T element);
-
- abstract boolean save(T element);
-
- abstract <S extends Enum> S getNotFoundErrorStatus();
-
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/MigrationByIdDerivedNodeTypeResolver.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/MigrationByIdDerivedNodeTypeResolver.java
deleted file mode 100644
index 066ab9a01a..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/MigrationByIdDerivedNodeTypeResolver.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import fj.data.Either;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.model.DerivedNodeTypeResolver;
-
-import javax.annotation.Resource;
-import java.util.Collections;
-import java.util.List;
-
-public class MigrationByIdDerivedNodeTypeResolver implements DerivedNodeTypeResolver {
-
- @Resource(name = "titan-dao")
- private TitanDao titanDao;
-
- @Override
- public Either<List<GraphVertex>, TitanOperationStatus> findDerivedResources(String parentResource) {
- return titanDao.getVertexById(parentResource, JsonParseFlagEnum.ParseMetadata).left().map(Collections::singletonList);
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/NodeTemplateMissingDataResolver.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/NodeTemplateMissingDataResolver.java
deleted file mode 100644
index c83421066c..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/NodeTemplateMissingDataResolver.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-import fj.data.Either;
-import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
-import fj.data.Either;
-import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
-import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import org.openecomp.sdc.be.model.*;
-import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
-import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
-import org.openecomp.sdc.be.model.jsontitan.enums.JsonConstantKeysEnum;
-import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
-import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementLifecycleOperation;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.common.api.ArtifactTypeEnum;
-import org.openecomp.sdc.common.api.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-
-public class NodeTemplateMissingDataResolver <T extends Component> {
-
- private static Logger LOGGER = LoggerFactory.getLogger(NodeTemplateMissingDataResolver.class);
-
- @Resource(name = "tosca-element-lifecycle-operation")
- private ToscaElementLifecycleOperation lifecycleOperation;
-
- @Resource(name = "topology-template-operation")
- public TopologyTemplateOperation topologyTemplateOperation;
-
- public void resolveNodeTemplateInfo(ComponentInstanceDataDefinition vfInst, Map<String, ToscaElement> origCompMap, T component) {
- lifecycleOperation.resolveToscaComponentName(vfInst, origCompMap);
- if(OriginTypeEnum.VF == vfInst.getOriginType()) {
- collectVFInstanceInputs(component, origCompMap, vfInst);
- }
- }
-
-
-
-
- public void updateServiceComposition(Component component, Map<String, ToscaElement> origCompMap, Component oldModelService, Map<String, Boolean> updateMap){
-
- boolean composition = false;
- boolean instInputs = false;
- boolean instGroups = false;
- List<ComponentInstance> instances = component.getComponentInstances();
- if(null != instances) {
- for (ComponentInstance instance : instances) {
- composition = composition || lifecycleOperation.resolveToscaComponentName(instance, origCompMap);
- if(OriginTypeEnum.VF == instance.getOriginType()) {
- instInputs = instInputs || collectVFInstanceInputs(component, origCompMap, instance);
- instGroups = instGroups || resolveInstGroupsFromOldTitanGraphAndApplyFix(component, instance, oldModelService);
- }
- }
- }
- updateMap.put(JsonConstantKeysEnum.COMPOSITION.name(), composition);
- updateMap.put(EdgeLabelEnum.INST_INPUTS.name(), instInputs);
- updateMap.put(EdgeLabelEnum.INST_GROUPS.name(), instGroups);
- }
-
-
- public void updateVFComposition(Component component, Map<String, ToscaElement> origCompMap, Map<String, Boolean> updateMap) {
-
- boolean composition = false;
- boolean groups = fixVFGroups(component);
- List<ComponentInstance> instances = component.getComponentInstances();
- if(null != instances) {
- for (ComponentInstance instance : instances) {
- composition = composition || lifecycleOperation.resolveToscaComponentName(instance, origCompMap);
- }
- }
- updateMap.put(JsonConstantKeysEnum.COMPOSITION.name(), composition);
- updateMap.put(EdgeLabelEnum.GROUPS.name(), groups);
- }
-
-
-
- private boolean resolveInstGroupsFromOldTitanGraphAndApplyFix(Component component, ComponentInstance instance, Component oldService){
-
- boolean res = false;
- //info already exists, apply fix if needed
- if(null != instance.getGroupInstances() && !instance.getGroupInstances().isEmpty()) {
- res = fixVFGroupInstances(component, instance);
- //get group instances from old model
- }else if(null != oldService){
- ComponentInstance origInstance = oldService.getComponentInstances().stream()
- .filter(p -> instance.getUniqueId().equals(p.getUniqueId()))
- .findAny().orElse(null);
- if(null != origInstance && null != origInstance.getGroupInstances()) {
- fixVFGroupInstances(oldService, origInstance);
- instance.setGroupInstances(origInstance.getGroupInstances());
- res = true;
- }
- }
- return res;
- }
-
- private boolean collectVFInstanceInputs(Component component, Map<String, ToscaElement> origCompMap, ComponentInstanceDataDefinition vfInst) {
- boolean res = false;
- String ciUid = vfInst.getUniqueId();
- String origCompUid = vfInst.getComponentUid();
- if(null == component.getComponentInstancesInputs())
- component.setComponentInstancesInputs(new HashMap<>());
- Map<String, List<ComponentInstanceInput>> componentInstInputs = component.getComponentInstancesInputs();
- Either<ToscaElement, StorageOperationStatus> origComp = fetchToscaElement(origCompMap, vfInst, origCompUid);
- if(origComp.isRight())
- return false;
- Map<String, PropertyDataDefinition> origVFInputs = ((TopologyTemplate)origComp.left().value()).getInputs();
- if (origVFInputs != null && !origVFInputs.isEmpty()) {
- res = true;
- Map<String, ComponentInstanceInput> collectedVFInputs = origVFInputs.values().stream()
- .collect(Collectors.toMap(PropertyDataDefinition::getName, ComponentInstanceInput::new));
-
- List<ComponentInstanceInput> instInputList = componentInstInputs.get(ciUid);
- Map<String, ComponentInstanceInput> existingInstInputs = ToscaDataDefinition.listToMapByName(instInputList);
- collectedVFInputs.putAll(existingInstInputs);
- List<ComponentInstanceInput> mergedList = new ArrayList<>(collectedVFInputs.values());
- componentInstInputs.put(ciUid, mergedList);
- }
- return res;
- }
-
- private Either<ToscaElement, StorageOperationStatus> fetchToscaElement(Map<String, ToscaElement> origCompMap, ComponentInstanceDataDefinition vfInst, String origCompUid) {
- Either<ToscaElement, StorageOperationStatus> origCompEither;
- if (!origCompMap.containsKey(origCompUid)) {
- origCompEither = topologyTemplateOperation.getToscaElement(origCompUid);
- if (origCompEither.isRight()) {
- LOGGER.error("failed to fetch Tosca element {} with id {}", vfInst.getComponentName(), origCompUid);
- return origCompEither;
- }
- origCompMap.put(origCompUid, origCompEither.left().value());
- }
- return Either.left(origCompMap.get(origCompUid));
- }
-
- protected boolean isProblematicGroup(GroupDefinition gr, String resourceName, Map<String, ArtifactDefinition> deploymentArtifacts) {
- List<String> artifacts = gr.getArtifacts();
- List<String> artifactsUuid = gr.getArtifactsUuid();
-
- if ((artifactsUuid == null || artifactsUuid.isEmpty()) && (artifacts == null || artifacts.isEmpty())) {
- LOGGER.debug("No groups in resource {} ", resourceName);
- return false;
- }
- if (artifacts.size() < artifactsUuid.size()) {
- LOGGER.debug(" artifacts.size() < artifactsUuid.size() group {} in resource {} ", gr.getName(), resourceName);
- return true;
- }
- if (artifacts.size() > 0 && (artifactsUuid == null || artifactsUuid.isEmpty())) {
- LOGGER.debug(" artifacts.size() > 0 && (artifactsUuid == null || artifactsUuid.isEmpty() group {} in resource {} ", gr.getName(), resourceName);
- return true;
- }
- if (artifactsUuid.contains(null)) {
- LOGGER.debug(" artifactsUuid.contains(null) group {} in resource {} ", gr.getName(), resourceName);
- return true;
- }
-
- for (String artifactId : artifacts) {
- String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
- ArtifactDefinition artifactDefinition = deploymentArtifacts.get(artifactlabel);
- if (artifactDefinition == null) {
- LOGGER.debug(" artifactDefinition == null label {} group {} in resource {} ", artifactlabel, gr.getName(), resourceName);
- return true;
- }
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactDefinition.getArtifactType());
- if (artifactType != ArtifactTypeEnum.HEAT_ENV) {
- if (!artifactId.equals(artifactDefinition.getUniqueId())) {
- LOGGER.debug(" !artifactId.equals(artifactDefinition.getUniqueId() artifact {} artId {} group {} in resource {} ", artifactlabel, artifactId, gr.getName(), resourceName);
- return true;
- }
- if (!artifactsUuid.contains(artifactDefinition.getArtifactUUID())) {
- LOGGER.debug(" artifactsUuid.contains(artifactDefinition.getArtifactUUID() label {} group {} in resource {} ", artifactlabel, gr.getName(), resourceName);
- return true;
- }
- }
- }
- return false;
- }
-
- protected boolean isProblematicGroupInstance(GroupInstance gi, String instName, String servicename, Map<String, ArtifactDefinition> deploymentArtifacts) {
- List<String> artifacts = gi.getArtifacts();
- List<String> artifactsUuid = gi.getArtifactsUuid();
- List<String> instArtifactsUuid = gi.getGroupInstanceArtifactsUuid();
-
- if ((artifactsUuid == null || artifactsUuid.isEmpty()) && (artifacts == null || artifacts.isEmpty())) {
- LOGGER.debug("No instance groups for instance {} in service {} ", instName, servicename);
- return false;
- }
- if (artifacts.size() < artifactsUuid.size()) {
- LOGGER.debug(" artifacts.size() < artifactsUuid.size() inst {} in service {} ", instName, servicename);
- return true;
- }
- if (artifacts.size() > 0 && (artifactsUuid == null || artifactsUuid.isEmpty())) {
- LOGGER.debug(" artifacts.size() > 0 && (artifactsUuid == null || artifactsUuid.isEmpty() inst {} in service {} ", instName, servicename);
- return true;
- }
- if (artifactsUuid.contains(null)) {
- LOGGER.debug(" artifactsUuid.contains(null) inst {} in service {} ", instName, servicename);
- return true;
- }
-
- for (String artifactId : artifacts) {
- String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
- ArtifactDefinition artifactDefinition = deploymentArtifacts.get(artifactlabel);
- if (artifactDefinition == null) {
- LOGGER.debug(" artifactDefinition == null label {} inst {} in service {} ", artifactlabel, instName, servicename);
- return true;
- }
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifactDefinition.getArtifactType());
- if (artifactType != ArtifactTypeEnum.HEAT_ENV) {
- if (!artifactId.equals(artifactDefinition.getUniqueId())) {
- LOGGER.debug(" !artifactId.equals(artifactDefinition.getUniqueId() artifact {} artId {} inst {} in service {} ", artifactlabel, artifactId, instName, servicename);
- return true;
- }
- if (!artifactsUuid.contains(artifactDefinition.getArtifactUUID())) {
- LOGGER.debug(" artifactsUuid.contains(artifactDefinition.getArtifactUUID() label {} inst {} in service {} ", artifactlabel, instName, servicename);
- return true;
- }
- } else {
- if (!instArtifactsUuid.contains(artifactDefinition.getArtifactUUID())) {
- LOGGER.debug(" instArtifactsUuid.contains(artifactDefinition.getArtifactUUID() label {} inst {} in service {} ", artifactlabel, instName, servicename);
- return true;
- }
- }
- }
- return false;
- }
-
- private String findArtifactLabelFromArtifactId(String artifactId) {
- String artifactLabel = "";
-
- int index = artifactId.lastIndexOf(".");
- if (index > 0 && index + 1 < artifactId.length())
- artifactLabel = artifactId.substring(index + 1);
- return artifactLabel;
- }
-
- public boolean fixVFGroups(Component component){
- boolean res = false;
-
- Map<String, ArtifactDefinition> deploymentArtifacts = component.getDeploymentArtifacts();
- List<GroupDefinition> groups = component.getGroups();
- if (groups == null || groups.isEmpty()) {
- LOGGER.debug("No groups in component {} id {} ", component.getName(), component.getUniqueId());
- return res;
- }
-
- for (GroupDefinition group : groups) {
- if (group.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE) && deploymentArtifacts != null) {
- if (isProblematicGroup(group, component.getName(), deploymentArtifacts)) {
- res = true;
- List<String> groupArtifacts = null == group.getArtifacts()? new ArrayList<>() : new ArrayList<>(group.getArtifacts());
- group.setArtifacts(new ArrayList<>());
- group.setArtifactsUuid(new ArrayList<>());
- for (String artifactId : groupArtifacts) {
- String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
- LOGGER.debug("fix group: group name {} artifactId for fix {} artifactlabel {} ", group.getName(), artifactId, artifactlabel);
- if (!artifactlabel.isEmpty() && deploymentArtifacts.containsKey(artifactlabel)) {
- ArtifactDefinition artifact = deploymentArtifacts.get(artifactlabel);
- String correctArtifactId = artifact.getUniqueId();
- String correctArtifactUUID = artifact.getArtifactUUID();
- LOGGER.debug(" fix group: group name {} correct artifactId {} artifactUUID {} ", group.getName(), correctArtifactId, correctArtifactUUID);
- group.getArtifacts().add(correctArtifactId);
- if (correctArtifactUUID != null && !correctArtifactUUID.isEmpty()) {
- group.getArtifactsUuid().add(correctArtifactUUID);
- }
- }
- }
- }
- }
- }
- return res;
- }
-
- public boolean fixVFGroupInstances(Component component, ComponentInstance instance){
- boolean res = false;
-
- Map<String, ArtifactDefinition> deploymentArtifacts = instance.getDeploymentArtifacts();
- List<GroupInstance> groupInstances = instance.getGroupInstances();
- if (groupInstances == null || groupInstances.isEmpty()) {
- LOGGER.debug("No instance groups for instance {} in service {} id {} ", instance.getName(), component.getName(), component.getUniqueId());
- return res;
- }
- for (GroupInstance group : groupInstances) {
- if (group.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)) {
- if (isProblematicGroupInstance(group, instance.getName(), component.getName(), deploymentArtifacts)) {
- res = true;
- LOGGER.debug("Migration1707ArtifactUuidFix fix group: resource id {}, group name {} ", component.getUniqueId(), group.getName());
- List<String> groupArtifacts = null == group.getArtifacts()? new ArrayList<>() : new ArrayList<>(group.getArtifacts());
- group.setArtifacts(new ArrayList<>());
- group.setArtifactsUuid(new ArrayList<>());
- group.setGroupInstanceArtifacts(new ArrayList<>());
- group.setGroupInstanceArtifactsUuid(new ArrayList<>());
-
- for (String artifactId : groupArtifacts) {
- String artifactlabel = findArtifactLabelFromArtifactId(artifactId);
- LOGGER.debug("Migration1707ArtifactUuidFix fix group: group name {} artifactId for fix {} artifactlabel {} ", group.getName(), artifactId, artifactlabel);
- if (!artifactlabel.isEmpty() && deploymentArtifacts.containsKey(artifactlabel)) {
- ArtifactDefinition artifact = deploymentArtifacts.get(artifactlabel);
- ArtifactTypeEnum artifactType = ArtifactTypeEnum.findType(artifact.getArtifactType());
- String correctArtifactId = artifact.getUniqueId();
- String correctArtifactUUID = artifact.getArtifactUUID();
- if (artifactType != ArtifactTypeEnum.HEAT_ENV) {
-
- LOGGER.debug("Migration1707ArtifactUuidFix fix group: group name {} correct artifactId {} artifactUUID {} ", group.getName(), correctArtifactId, correctArtifactUUID);
- group.getArtifacts().add(correctArtifactId);
- if (correctArtifactUUID != null && !correctArtifactUUID.isEmpty()) {
- group.getArtifactsUuid().add(correctArtifactUUID);
- }
- } else {
- LOGGER.debug("Migration1707ArtifactUuidFix fix group: group name {} correct artifactId {} artifactUUID {} ", group.getName(), correctArtifactId, correctArtifactUUID);
- group.getGroupInstanceArtifacts().add(correctArtifactId);
- if (correctArtifactUUID != null && !correctArtifactUUID.isEmpty()) {
- group.getGroupInstanceArtifactsUuid().add(correctArtifactUUID);
- }
- }
- }
- }
- }
- }
- }
- return res;
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/NormativesMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/NormativesMigration.java
deleted file mode 100644
index 1717b1fa83..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/NormativesMigration.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import fj.data.Either;
-import jersey.repackaged.com.google.common.collect.Sets;
-import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-
-public class NormativesMigration extends ComponentMigration<Resource> {
-
- private static Logger LOGGER = LoggerFactory.getLogger(NormativesMigration.class);
- private static final String JCP_VERSION_PROPERTY = "jcp-version";
- private static final Set<String> e2eMalformedVfcs = Sets.newHashSet("59da26b4-edd0-4412-a2e6-d6711f376340");
-
- @javax.annotation.Resource(name = "normatives-resolver")
- private NormativesResolver normativesResolver;
-
- @javax.annotation.Resource(name = "resource-version-migration")
- private VersionMigration<Resource> versionMigration;
-
- @Override
- public String description() {
- return "migration of node types";
- }
-
- @Override
- Either<List<Resource>, ?> getElementsToMigrate() {
- return normativesResolver.getAllNodeTypeNormatives();
- }
-
- @Override
- boolean save(Resource element) {
- if (e2eMalformedVfcs.contains(element.getUniqueId())) {
- replaceJcpVersionPropertyTypeToVersion(element);
- }
- return super.save(element);
- }
-
- private void replaceJcpVersionPropertyTypeToVersion(Resource element) {
- getJcpIntegerProperty(element).ifPresent(propertyDefinition -> {
- LOGGER.info("resource {} with id {}: found property jcp-version with type 'integer', changing type to 'version'", element.getName(), element.getUniqueId());
- propertyDefinition.setType(ToscaPropertyType.VERSION.getType());
- });
- }
-
- private Optional<PropertyDefinition> getJcpIntegerProperty(Resource element) {
- if (element.getProperties() == null) return Optional.empty();
- return element.getProperties().stream()
- .filter(prop -> prop.getName().equals(JCP_VERSION_PROPERTY))
- .filter(prop -> prop.getType().equals(ToscaPropertyType.INTEGER.getType()))
- .findAny();
-
- }
-
- @Override
- boolean doPostMigrateOperation(List<Resource> elements) {
- LOGGER.info("migrating node types versions");
- return versionMigration.buildComponentsVersionChain(elements);
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/NormativesResolver.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/NormativesResolver.java
deleted file mode 100644
index cc9e6ec972..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/NormativesResolver.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import fj.data.Either;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.operations.api.IResourceOperation;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Queue;
-import java.util.stream.Collectors;
-
-public class NormativesResolver {
-
- @javax.annotation.Resource(name = "resource-operation")
- private IResourceOperation resourceOperation;
-
- /**
- *
- * @return list of all normatives sorted by neighboring order
- */
- public Either<List<Resource>, StorageOperationStatus> getAllNodeTypeNormatives() {
- Either<List<Resource>, StorageOperationStatus> rootNormatives = resourceOperation.getRootResources();
- return rootNormatives.either(this::getAllNormatives,
- Either::right);
-
- }
-
- private Either<List<Resource>, StorageOperationStatus> getAllNormatives(List<Resource> rootResources) {
- List<Resource> allNormatives = new ArrayList<>();
- for (Resource rootResource : rootResources) {
- Either<List<Resource>, StorageOperationStatus> normativesOfRoot = getAllNodeTypeNormatives(rootResource);
- if (normativesOfRoot.isRight()) {
- return Either.right(normativesOfRoot.right().value());
- }
- allNormatives.addAll(normativesOfRoot.left().value());
- }
- return Either.left(allNormatives);
- }
-
- private Either<List<Resource>, StorageOperationStatus> getAllNodeTypeNormatives(Resource root) {
- List<Resource> normativeResources = new ArrayList<>();
- Queue<Resource> resources = new ArrayDeque<>();
- resources.add(root);
- while (!resources.isEmpty()) {
- Resource currentResource = resources.poll();
- normativeResources.add(currentResource);
- Either<List<Resource>, StorageOperationStatus> allDerivedResources = getAllNonVFDerivedResources(currentResource);
- if (allDerivedResources.isRight()) {
- return Either.right(allDerivedResources.right().value());
- }
- List<Resource> derivedResources = allDerivedResources.left().value();
- replaceDerivedNameWithDerivedUniqueId(currentResource, derivedResources);
- resources.addAll(derivedResources);
- }
- return Either.left(normativeResources);
- }
-
- private void replaceDerivedNameWithDerivedUniqueId(Resource currentResource, List<Resource> derivedResources) {
- derivedResources.forEach(resource -> resource.setDerivedFrom(Collections.singletonList(currentResource.getUniqueId())));
- }
-
- private Either<List<Resource>, StorageOperationStatus> getAllNonVFDerivedResources(Resource resource) {
- Either<List<Resource>, StorageOperationStatus> childrenNodes = resourceOperation.getAllDerivedResources(resource);
- return childrenNodes.either(resourceList -> Either.left(filterNonVFResources(resourceList)),
- this::resolveEmptyListOrErrorStatus);
- }
-
- private List<Resource> filterNonVFResources(List<Resource> resources) {
- return resources.stream().filter(resource -> resource.getResourceType() != ResourceTypeEnum.VF).collect(Collectors.toList());
- }
-
- private Either<List<Resource>, StorageOperationStatus> resolveEmptyListOrErrorStatus(StorageOperationStatus storageOperationStatus) {
- return storageOperationStatus == StorageOperationStatus.NOT_FOUND ? Either.left(Collections.emptyList()) : Either.right(storageOperationStatus);
- }
-
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ResourceVersionMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ResourceVersionMigration.java
deleted file mode 100644
index aeb85a7d35..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ResourceVersionMigration.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import fj.data.Either;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.operations.api.IResourceOperation;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-
-import java.util.List;
-
-public class ResourceVersionMigration extends VersionMigration<Resource> {
-
- @javax.annotation.Resource(name = "resource-operation")
- private IResourceOperation resourceOperation;
-
- @Override
- NodeTypeEnum getNodeTypeEnum() {
- return NodeTypeEnum.Resource;
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ResourcesCategoriesMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ResourcesCategoriesMigration.java
deleted file mode 100644
index f605d8c3fa..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ResourcesCategoriesMigration.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import fj.data.Either;
-import org.openecomp.sdc.asdctool.impl.migration.MigrationMsg;
-import org.openecomp.sdc.asdctool.impl.migration.Migration1707Task;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationUtils;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.datatypes.category.CategoryDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
-import org.openecomp.sdc.be.model.operations.api.IElementOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import static org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel.CategoriesUtils.filterOldCategories;
-import static org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel.CategoriesUtils.filterOldSubCategories;
-
-
-public class ResourcesCategoriesMigration implements Migration1707Task {
-
- @Resource(name = "element-operation")
- private IElementOperation elementOperation;
-
- @Resource(name = "element-operation-migration")
- private IElementOperation elementOperationMigration;
-
- @Resource(name = "titan-dao")
- TitanDao titanDao;
-
- @Override
- public String description() {
- return "migrate resource categories";
- }
-
- @Override
- public boolean migrate() {
- return getCategoriesToMigrate().either(this::migrateCategories,
- errorStatus -> MigrationUtils.handleError(MigrationMsg.FAILED_TO_RETRIEVE_CATEGORIES.getMessage(errorStatus.name())));
- }
-
- private Either<List<CategoryDefinition>, ActionStatus> getCategoriesToMigrate() {
- return elementOperation.getAllCategories(NodeTypeEnum.ResourceNewCategory, false);
- }
-
- private boolean migrateCategories(List<CategoryDefinition> categoryDefinitions) {
- List<CategoryDefinition> categoriesToMigrate = filterOldCategoriesAndSubCategories(categoryDefinitions);
- for (CategoryDefinition categoryDefinition : categoriesToMigrate) {
- boolean isMigrated = migrateCategoryIfNotExists(categoryDefinition);
- if (!isMigrated) {
- titanDao.rollback();
- return false;
- }
- titanDao.commit();
- }
- return true;
- }
-
-
- //since production was malformed we need to fixed it by removing wrong categories and sub categories
- private List<CategoryDefinition> filterOldCategoriesAndSubCategories(List<CategoryDefinition> categoryDefinitions) {
- Map<String, List<CategoryDefinition>> categoriesByNormalName = categoryDefinitions.stream().collect(Collectors.groupingBy(CategoryDataDefinition::getNormalizedName));
- List<CategoryDefinition> categoriesToMigrate = filterOldCategories(categoryDefinitions);
- for (CategoryDefinition categoryDefinition : categoriesToMigrate) {
- List<SubCategoryDefinition> newSubCategories = getAllDistinctSubCategories(categoriesByNormalName.get(categoryDefinition.getNormalizedName()));
- categoryDefinition.setSubcategories(newSubCategories);
- }
- return categoriesToMigrate;
- }
-
- private List<SubCategoryDefinition> getAllDistinctSubCategories (List<CategoryDefinition> categoriesDefinitions) {
- Map<String, List<SubCategoryDefinition>> subCategoriesByNormalName = categoriesDefinitions.stream()
- .filter(ct -> ct.getSubcategories()!=null)
- .flatMap(ct -> ct.getSubcategories().stream())
- .collect(Collectors.groupingBy(SubCategoryDefinition::getNormalizedName));
- return getDistinctSubCategories(subCategoriesByNormalName);
- }
-
- private List<SubCategoryDefinition> getDistinctSubCategories(Map<String, List<SubCategoryDefinition>> subCategoriesByNormalName) {
- List<SubCategoryDefinition> allSubCategories = new ArrayList<>();
- for (List<SubCategoryDefinition> subCategoryDefinitions : subCategoriesByNormalName.values()) {
- if (subCategoryDefinitions.size() == 1) {
- allSubCategories.addAll(subCategoryDefinitions);
- } else {
- allSubCategories.addAll(filterOldSubCategories(subCategoryDefinitions));
- }
- }
- return allSubCategories;
- }
-
- private boolean migrateCategoryIfNotExists(CategoryDefinition categoryDefinition) {
- return isExists(categoryDefinition).either(isExist -> isExist ? migrateSubCategories(categoryDefinition) : migrateCategoryAndSubCategories(categoryDefinition),
- error -> MigrationUtils.handleError(MigrationMsg.FAILED_TO_RETRIEVE_CATEGORY.getMessage(categoryDefinition.getName(), error.name())));
- }
-
- private boolean migrateCategoryAndSubCategories(CategoryDefinition resourceCategory) {
- return elementOperationMigration.createCategory(resourceCategory, NodeTypeEnum.ResourceNewCategory)
- .either(createdCategory -> this.migrateSubCategories(resourceCategory),
- status -> MigrationUtils.handleError(MigrationMsg.FAILED_TO_CREATE_CATEGORY.getMessage(resourceCategory.getName(), status.name())));
- }
-
- private boolean migrateSubCategories(CategoryDefinition categoryDefinition) {
- for (SubCategoryDefinition subCategory : categoryDefinition.getSubcategories()) {
- boolean isMigrated = migrateSubcategoryIfNotExists(categoryDefinition, subCategory);
- if (!isMigrated) {
- return false;
- }
- }
- return true;
- }
-
- private boolean migrateSubcategoryIfNotExists(CategoryDefinition parentCategory, SubCategoryDefinition subCategory) {
- return isExists(parentCategory, subCategory).either(isExists -> isExists || migrateSubCategory(parentCategory, subCategory),
- status -> MigrationUtils.handleError(MigrationMsg.FAILED_TO_RETRIEVE_CATEGORY.getMessage(subCategory.getName(), status.name())));
- }
-
- private boolean migrateSubCategory(CategoryDefinition categoryDefinition, SubCategoryDefinition subCategory) {
- return elementOperationMigration.createSubCategory(categoryDefinition.getUniqueId(), subCategory, NodeTypeEnum.ResourceSubcategory)
- .either(createdSubCategory -> true,
- errorStatus -> MigrationUtils.handleError(MigrationMsg.FAILED_TO_CREATE_SUB_CATEGORY.getMessage(subCategory.getName(), categoryDefinition.getName(), errorStatus.name())));
-
- }
-
- private Either<Boolean, ActionStatus> isExists(CategoryDefinition category) {
- Either<CategoryDefinition, ActionStatus> byId = getCategoryById(category);
- return byId.either(existingVal -> Either.left(true),
- this::getEitherNotExistOrErrorStatus);
- }
-
- private Either<Boolean, ActionStatus> isExists(CategoryDefinition parentCategory, SubCategoryDefinition subCategory) {
- return getSubCategoryById(parentCategory, subCategory).either(existingVal -> Either.left(true),
- this::getEitherNotExistOrErrorStatus);
- }
-
- private Either<Boolean, ActionStatus> getEitherNotExistOrErrorStatus(ActionStatus status) {
- return status == ActionStatus.COMPONENT_CATEGORY_NOT_FOUND ? Either.left(false) : Either.right(status);
- }
-
- private Either<CategoryDefinition, ActionStatus> getCategoryById(CategoryDefinition category) {
- return elementOperationMigration.getCategory(NodeTypeEnum.ResourceNewCategory, category.getUniqueId());
- }
-
- private Either<SubCategoryDefinition, ActionStatus> getSubCategoryById(CategoryDefinition parentCategory, SubCategoryDefinition subCategory) {
- String subCategoryUid = getExpectedSubCategoryId(parentCategory, subCategory);
- return elementOperationMigration.getSubCategory(NodeTypeEnum.ResourceSubcategory, subCategoryUid);
- }
-
- //since a sub category might belong to a different category in old graph its new graph id is different than its old graph id
- private String getExpectedSubCategoryId(CategoryDefinition parentCategory, SubCategoryDefinition subCategory) {
- String parentId = UniqueIdBuilder.buildCategoryUid(parentCategory.getNormalizedName(), NodeTypeEnum.ResourceNewCategory);
- return UniqueIdBuilder.buildSubCategoryUid(parentId, subCategory.getNormalizedName());
- }
-
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ServiceCategoriesMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ServiceCategoriesMigration.java
deleted file mode 100644
index 857bcd9b43..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ServiceCategoriesMigration.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import fj.data.Either;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.be.model.operations.api.IElementOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-import static org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationUtils.handleError;
-
-public class ServiceCategoriesMigration extends JsonModelMigration<CategoryDefinition> {
-
- @Resource(name = "element-operation")
- private IElementOperation elementOperation;
-
- @Resource(name = "element-operation-migration")
- private IElementOperation elementOperationMigration;
-
-
- @Override
- public String description() {
- return "migrate services categories";
- }
-
- @Override
- Either<List<CategoryDefinition>, ?> getElementsToMigrate() {
- return elementOperation.getAllCategories(NodeTypeEnum.ServiceNewCategory, false).left().map(CategoriesUtils::filterOldCategories);
- }
-
- @Override
- Either<CategoryDefinition, ?> getElementFromNewGraph(CategoryDefinition node) {
- String categoryUid = UniqueIdBuilder.buildCategoryUid(node.getNormalizedName(), NodeTypeEnum.ServiceNewCategory);//in malformed graph there are some categories with different id but same normalized name. so in new graph they same id
- return elementOperationMigration.getCategory(NodeTypeEnum.ServiceNewCategory, categoryUid);
- }
-
- @Override
- boolean save(CategoryDefinition graphNode) {
- return elementOperationMigration.createCategory(graphNode, NodeTypeEnum.ServiceNewCategory)
- .either(savedCategory -> true,
- err -> handleError(String.format("failed to save category %s. error: %s", graphNode.getName(), err.name())));
- }
-
- @Override
- ActionStatus getNotFoundErrorStatus() {
- return ActionStatus.COMPONENT_CATEGORY_NOT_FOUND;
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ServiceVersionMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ServiceVersionMigration.java
deleted file mode 100644
index 32ef06a220..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ServiceVersionMigration.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import fj.data.Either;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.operations.api.IResourceOperation;
-import org.openecomp.sdc.be.model.operations.api.IServiceOperation;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-
-import java.util.List;
-
-public class ServiceVersionMigration extends VersionMigration<Service> {
-
- @javax.annotation.Resource(name = "service-operation")
- private IServiceOperation serviceOperation;
-
- @Override
- NodeTypeEnum getNodeTypeEnum() {
- return NodeTypeEnum.Service;
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ServicesMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ServicesMigration.java
deleted file mode 100644
index 040d220912..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/ServicesMigration.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import javax.annotation.Resource;
-
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.operations.api.IServiceOperation;
-import org.openecomp.sdc.be.model.operations.migration.MigrationMalformedDataLogger;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import fj.data.Either;
-
-public class ServicesMigration extends ComponentMigration<Service> {
-
- private static final String DEFAULT_CONFORMANCE_LEVEL = "0.0";
- private static Logger LOGGER = LoggerFactory.getLogger(ServicesMigration.class);
-
- @Resource(name = "service-operation")
- private IServiceOperation serviceOperation;
-
- @Resource(name = "service-version-migration")
- private VersionMigration<Service> versionMigration;
-
- @Override
- public String description() {
- return "migrate services";
- }
-
- @Override
- Either<List<Service>, ?> getElementsToMigrate() {
- return serviceOperation.getAll();
- }
-
- @Override
- boolean save(Service element) {
- MigrationMalformedDataLogger.logIfServiceUsingMalformedVfs(element);
- filterOutDuplicatePropsAndAttrs(element);
- element.setConformanceLevel(DEFAULT_CONFORMANCE_LEVEL);
- requirementsCapabilitiesMigrationService.overrideInstanceCapabilitiesRequirements(element);
- return super.save(element);
- }
-
- @Override
- boolean doPostSaveOperation(Service element) {
- return element.getComponentInstances() == null ||
- (requirementsCapabilitiesMigrationService.associateFulfilledRequirements(element, NodeTypeEnum.Service) &&
- requirementsCapabilitiesMigrationService.associateFulfilledCapabilities(element, NodeTypeEnum.Service));
- }
-
- @Override
- boolean doPostMigrateOperation(List<Service> elements) {
- LOGGER.info("migrating services versions");
- return versionMigration.buildComponentsVersionChain(elements);
- }
-
- @Override
- void doPreMigrationOperation(List<Service> elements) {
- super.doPreMigrationOperation(elements);
- setMissingTemplateInfo(elements);
- }
-
- private void filterOutDuplicatePropsAndAttrs(Service element) {
- if (element.getComponentInstancesProperties() != null) {
- removeDuplicatedNameProperties(element);
- }
- if (element.getComponentInstancesAttributes() != null) {
- removeDuplicatedNameAttributes(element);
- }
- }
-
- private void removeDuplicatedNameProperties(Service service) {
- Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = service.getComponentInstancesProperties();
- componentInstancesProperties.forEach((uid, properties) -> {
- componentInstancesProperties.put(uid, getUniquedNamePropertyList(service, properties));
- });
- }
-
- private List<ComponentInstanceProperty> getUniquedNamePropertyList(Service service, List<ComponentInstanceProperty> properties) {
- if (properties == null) {
- return null;
- }
- List<ComponentInstanceProperty> uniqueNameProperties = new ArrayList<>();
- Map<String, List<ComponentInstanceProperty>> collect = properties.stream().collect(Collectors.groupingBy(ComponentInstanceProperty::getName));
- collect.forEach((name, duplicatedProperties) -> {
- logServiceDuplicateProperties(service, name, duplicatedProperties);
- uniqueNameProperties.add(duplicatedProperties.get(0));
- });
- return uniqueNameProperties;
- }
-
- private void logServiceDuplicateProperties(Service service, String name, List<ComponentInstanceProperty> duplicatedProperties) {
- if (duplicatedProperties.size() > 1) {
- LOGGER.debug("service {} with id {} has instance {} with duplicate property {}", service.getName(), service.getUniqueId(), duplicatedProperties.get(0).getUniqueId(), name);
- }
- }
-
- private void removeDuplicatedNameAttributes(Service service) {
- Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes = service.getComponentInstancesAttributes();
- componentInstancesAttributes.forEach((uid, attributes) -> {
- componentInstancesAttributes.put(uid, getUniquedNameAttributeList(service, attributes));
- });
- }
-
- private List<ComponentInstanceProperty> getUniquedNameAttributeList(Service service, List<ComponentInstanceProperty> attributes) {
- if (attributes == null) {
- return null;
- }
- List<ComponentInstanceProperty> uniqueNameAttributes = new ArrayList<>();
- Map<String, List<ComponentInstanceProperty>> collect = attributes.stream().collect(Collectors.groupingBy(ComponentInstanceProperty::getName));
- collect.forEach((name, duplicatedAttributess) -> {
- logServiceMalformedAttributes(service, name, duplicatedAttributess);
- uniqueNameAttributes.add(duplicatedAttributess.get(0));
- });
- return uniqueNameAttributes;
- }
-
- private void logServiceMalformedAttributes(Service service, String name, List<ComponentInstanceProperty> duplicatedAttributess) {
- if (duplicatedAttributess.size() > 1) {
- MigrationMalformedDataLogger.logMalformedDataMsg(String.format("service %s with id %s has instance %s with duplicate attribute %s",
- service.getName(), service.getUniqueId(), duplicatedAttributess.get(0).getUniqueId(), name));
- }
- }
-
- // private void filterOutVFInstanceAttrs(Service element, List<String> vfInstancesIds) {
-// Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes = element.getComponentInstancesAttributes();
-// if (componentInstancesAttributes != null) {
-// element.setComponentInstancesAttributes(filterOutVFInstanceAttributes(componentInstancesAttributes, vfInstancesIds));
-// }
-// }
-//
-// private void filterOutVFInstacnecProps(Service element, List<String> vfInstancesIds) {
-// Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = element.getComponentInstancesProperties();
-// if (componentInstancesProperties != null) {
-// element.setComponentInstancesProperties(filterOutVFInstanceProperties(componentInstancesProperties, vfInstancesIds));
-// }
-// }
-//
-// private Map<String, List<ComponentInstanceProperty>> filterOutVFInstanceProperties(Map<String, List<ComponentInstanceProperty>> instances, List<String> vfInstanceIds) {
-// return instances.entrySet()
-// .stream()
-// .filter(entry -> !vfInstanceIds.contains(entry.getKey()))
-// .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-// }
-//
-// private Map<String, List<ComponentInstanceAttribute>> filterOutVFInstanceAttributes(Map<String, List<ComponentInstanceAttribute>> instances, List<String> vfInstanceIds) {
-// return instances.entrySet()
-// .stream()
-// .filter(entry -> !vfInstanceIds.contains(entry.getKey()))
-// .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-// }
-
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/UserStatesMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/UserStatesMigration.java
deleted file mode 100644
index 3f62273931..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/UserStatesMigration.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import com.thinkaurelius.titan.core.TitanVertex;
-import fj.data.Either;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Property;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.openecomp.sdc.asdctool.impl.migration.MigrationMsg;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.openecomp.sdc.be.resources.data.UserData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static fj.data.List.list;
-import static org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationUtils.handleError;
-
-public class UserStatesMigration extends JsonModelMigration<Edge> {
-
- private static final String MIGRATING_USER_ID = "jh0003";
- private static final int OUT_VERTEX_INDEX = 0;
- private static final int IN_VERTEX_INDEX = 1;
- private static Logger LOGGER = LoggerFactory.getLogger(UserStatesMigration.class);
-
- @Resource(name = "titan-generic-dao")
- private TitanGenericDao genericDao;
-
- @Resource(name = "titan-generic-dao-migration")
- private TitanGenericDao genericDaoMigration;
-
- @Override
- public String description() {
- return "migrate user states";
- }
-
-
- @Override
- public boolean migrate() {
-// return removeMigratingUserStates() && super.migrate();
- return super.migrate();
- }
-
- @Override
- Either<List<Edge>, TitanOperationStatus> getElementsToMigrate() {
- LOGGER.debug("fetching user states edges from old graph");
- return genericDao.getAll(NodeTypeEnum.User, UserData.class)
- .left().bind(this::getEdgesForUsers);
- }
-
- @Override
- Either<Edge, TitanOperationStatus> getElementFromNewGraph(Edge edge) {
- LOGGER.debug("finding user state edge in new graph");
- Vertex outVertex = edge.outVertex();
- String outVertexUIDKey = getVertexUniqueId(outVertex);
- String outVertexUIDValue = outVertex.property(outVertexUIDKey).value().toString();
-
- Vertex inVertex = edge.inVertex();
- String inVertexUIDKey = getVertexUniqueId(inVertex);
- String inVertexUIDValue = inVertex.property(inVertexUIDKey).value().toString();
-
- return genericDaoMigration.getEdgeByVerticies(outVertexUIDKey, outVertexUIDValue, inVertexUIDKey, inVertexUIDValue, edge.label());
- }
-
- @Override
- boolean save(Edge userState) {
- Either<InOutVertices, TitanOperationStatus> titanVertices = findEdgeInOutVerticesInNewGraph(userState);
- return titanVertices.either(inOutVertices -> saveUserState(inOutVertices, userState),
- err -> handleError(String.format("could not find user edge %s in vertx. error: %s", userState.label(), err.name())));
- }
-
- private boolean saveUserState(InOutVertices inOutVertices, Edge userState) {
- return genericDaoMigration.copyEdge(inOutVertices.getOutVertex(), inOutVertices.getInVertex(), userState)
- .either(edge -> true,
- err -> handleError(String.format("failed to save user state edge %s. reason: %s", userState.label(), err.name())));
- }
-
- @Override
- TitanOperationStatus getNotFoundErrorStatus() {
- return TitanOperationStatus.NOT_FOUND;
- }
-
-// private boolean removeMigratingUserStates() {
-// Either<UserData, TitanOperationStatus> migratingUser = genericDaoMigration.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), MIGRATING_USER_ID, UserData.class);
-// return migratingUser.either(user -> deleteAllEdges(user, Direction.OUT),
-// errorStatus -> MigrationUtils.handleError(MigrationMsg.FAILED_TO_RETRIEVE_MIGRATION_USER.getMessage(MIGRATING_USER_ID, errorStatus.name())));
-// }
-
- private Either<List<Edge>, TitanOperationStatus> getEdgesForUsers(List<UserData> users) {
- List<Edge> edges = new ArrayList<>();
- for (UserData user : users) {
- Either<List<Edge>, TitanOperationStatus> edgesForNode = genericDao.getEdgesForNode(user, Direction.OUT);
- if (edgesForNode.isRight()) {
- TitanOperationStatus errorStatus = edgesForNode.right().value();
- LOGGER.error(MigrationMsg.FAILED_TO_RETRIEVE_USER_STATES.getMessage(user.getEmail(), errorStatus.name()));
- return Either.right(errorStatus);
- }
- edges.addAll(edgesForNode.left().value());
- }
- return Either.left(ignoreProductEdges(edges));
- }
-
- private List<Edge> ignoreProductEdges(List<Edge> edges) {
- return edges.stream().filter(edge -> !isInEdgeOfProductType(edge.inVertex())).collect(Collectors.toList());
- }
-
- private boolean isInEdgeOfProductType(Vertex inVertex) {
- Property<Object> nodeLabelProperty = inVertex.property(GraphPropertiesDictionary.LABEL.getProperty());
- return nodeLabelProperty != null && nodeLabelProperty.value().equals(NodeTypeEnum.Product.getName());
- }
-
- private String getVertexUniqueId(Vertex vertex) {
- String nodeLabel = vertex.property(GraphPropertiesDictionary.LABEL.getProperty()).value().toString();
- return UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.getByName(nodeLabel));
- }
-
- private Either<InOutVertices, TitanOperationStatus> findEdgeInOutVerticesInNewGraph(Edge userEdge) {
- Either<TitanVertex, TitanOperationStatus> outVertex = getMigratedVertexByOldVertex(userEdge.outVertex());
- Either<TitanVertex, TitanOperationStatus> inVertex = getMigratedVertexByOldVertex(userEdge.inVertex());
- return Either.sequenceLeft(list(outVertex, inVertex)).left().map(InOutVertices::new);
- }
-
- private Either<TitanVertex, TitanOperationStatus> getMigratedVertexByOldVertex(Vertex vertex) {
- String vertexUniqueId = getVertexUniqueId(vertex);
- LOGGER.debug(String.format("fetching vertex %s from new graph", vertexUniqueId));
- return genericDaoMigration.getVertexByProperty(vertexUniqueId, vertex.property(vertexUniqueId).value())
- .right().map(err -> handleError(err, String.format("could not find vertex %s in new graph.", vertexUniqueId))) ;
- }
-
-// private boolean deleteAllEdges(UserData userData, Direction direction) {
-// Either<List<Edge>, TitanOperationStatus> edgesForNode = genericDaoMigration.getEdgesForNode(userData, direction);
-// if (edgesForNode.isRight()) {
-// LOGGER.error(MigrationMsg.FAILED_TO_RETRIEVE_MIGRATION_USER_STATES.getMessage(MIGRATING_USER_ID, edgesForNode.right().value().name()));
-// return false;
-// }
-// edgesForNode.left().value().forEach(Edge::remove);
-// return true;
-// }
-
- private class InOutVertices {
- private TitanVertex outVertex;
- private TitanVertex inVertex;
-
- InOutVertices(fj.data.List<TitanVertex> inOutVertices) {
- outVertex = inOutVertices.index(OUT_VERTEX_INDEX);
- inVertex = inOutVertices.index(IN_VERTEX_INDEX);
- }
-
- TitanVertex getOutVertex() {
- return outVertex;
- }
-
- TitanVertex getInVertex() {
- return inVertex;
- }
-
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/UsersMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/UsersMigration.java
deleted file mode 100644
index 6e0a8a9247..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/UsersMigration.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import fj.data.Either;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.model.operations.api.IUserAdminOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-import static org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationUtils.handleError;
-
-public class UsersMigration extends JsonModelMigration<User> {
-
- private static Logger LOGGER = LoggerFactory.getLogger(UsersMigration.class);
-
- @Resource(name = "user-operation")
- IUserAdminOperation userAdminOperation;
-
- @Resource(name = "user-operation-migration")
- IUserAdminOperation userAdminOperationMigration;
-
-
- @Override
- Either<List<User>, ActionStatus> getElementsToMigrate() {
- LOGGER.debug("fetching users to migrate from old graph");
- return userAdminOperation.getAllUsers();
- }
-
- @Override
- Either<User, ActionStatus> getElementFromNewGraph(User user) {
- LOGGER.debug(String.format("trying to load user %s from new graph", user.getUserId()));
- return user.getStatus().equals(UserStatusEnum.ACTIVE) ? userAdminOperationMigration.getUserData(user.getUserId(), false) :
- userAdminOperationMigration.getInactiveUserData(user.getUserId());
- }
-
- @Override
- boolean save(User user) {
- LOGGER.debug(String.format("trying to save user %s to new graph", user.getUserId()));
- return userAdminOperationMigration.saveUserData(user)
- .either(savedUser -> true,
- err -> handleError(String.format("failed when saving user %s. error %s", user.getUserId(), err.name())));
- }
-
- @Override
- public ActionStatus getNotFoundErrorStatus() {
- return ActionStatus.USER_NOT_FOUND;
- }
-
- @Override
- public String description() {
- return "migrate users";
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/VFResourcesMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/VFResourcesMigration.java
deleted file mode 100644
index 82d22addf3..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/VFResourcesMigration.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import java.util.List;
-
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.operations.api.IResourceOperation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import fj.data.Either;
-
-public class VFResourcesMigration extends ComponentMigration<Resource> {
-
- private static Logger LOGGER = LoggerFactory.getLogger(VFResourcesMigration.class);
-
- @javax.annotation.Resource(name = "resource-operation")
- private IResourceOperation resourceOperation;
-
- @javax.annotation.Resource(name = "resource-version-migration")
- private VersionMigration<Resource> versionMigration;
-
- @Override
- public String description() {
- return "migrate VFs";
- }
-
- @Override
- Either<List<Resource>, ?> getElementsToMigrate() {
- return resourceOperation.getVFResources();
- }
-
- @Override
- boolean save(Resource element) {
- requirementsCapabilitiesMigrationService.overrideInstanceCapabilitiesRequirements(element);
- return super.save(element);
- }
-
- @Override
- boolean doPostSaveOperation(Resource element) {
- return element.getComponentInstances() == null ||
- (requirementsCapabilitiesMigrationService.associateFulfilledRequirements(element, NodeTypeEnum.Resource) &&
- requirementsCapabilitiesMigrationService.associateFulfilledCapabilities(element, NodeTypeEnum.Resource));
- }
-
- @Override
- boolean doPostMigrateOperation(List<Resource> elements) {
- LOGGER.info("migrating VFs versions");
- return versionMigration.buildComponentsVersionChain(elements);
- }
-
- @Override
- void doPreMigrationOperation(List<Resource> elements) {
- super.doPreMigrationOperation(elements);
- setMissingTemplateInfo(elements);
- }
-
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/VersionMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/VersionMigration.java
deleted file mode 100644
index 514760fba2..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/VersionMigration.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel;
-
-import fj.data.Either;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.openecomp.sdc.asdctool.impl.migration.MigrationMsg;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationUtils;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Resource;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-public abstract class VersionMigration<T extends Component> {
-
- private static Logger LOGGER = LoggerFactory.getLogger(VersionMigration.class);
-
- @Resource(name = "titan-generic-dao-migration")
- private TitanGenericDao titanGenericDaoMigration;
-
- @Resource(name = "titan-dao")
- private TitanDao titanDao;
-
- public boolean buildComponentsVersionChain(List<T> components) {
- Map<String, List<T>> componentsByInvariant = components.stream().filter(c -> c.getInvariantUUID() != null).collect(Collectors.groupingBy(Component::getInvariantUUID));
- for (List<T> componentsList : componentsByInvariant.values()) {
- boolean versionChainBuilt = buildVersionChainForInvariant(componentsList);
- if (!versionChainBuilt) {
- titanDao.rollback();
- return false;
- }
- titanDao.commit();
- }
- return true;
- }
-
- private boolean buildVersionChainForInvariant(List<T> components) {
- sortComponentsByVersion(components);
- for (int i = 0; i < components.size() -1; i++) {
- String lowerVersionUid = components.get(i).getUniqueId();
- String higherVersionUid = components.get(i + 1).getUniqueId();
- boolean versionCreated = createVersionRelationIfNotExist(lowerVersionUid, higherVersionUid);
- if (!versionCreated) {
- return false;
- }
- }
- return true;
- }
-
- private void sortComponentsByVersion(List<T> components) {
- Collections.sort(components, (o1, o2) -> Double.valueOf(o1.getVersion()).compareTo(Double.valueOf(o2.getVersion())));
- }
-
- private boolean createVersionRelationIfNotExist(String fromUid, String toUid) {
- Either<Boolean, TitanOperationStatus> isVersionExists = isVersionExists(fromUid, toUid);
- return isVersionExists.either(versionExists -> versionExists || createVersionRelation(fromUid, toUid),
- errorStatus -> MigrationUtils.handleError(MigrationMsg.FAILED_TO_RETRIEVE_VERSION_RELATION.getMessage(fromUid, toUid, isVersionExists.right().value().name())));
- }
-
- private boolean createVersionRelation(String fromUid, String toUid) {
- LOGGER.debug(String.format("creating version edge between vertex %s and vertex %s", fromUid, toUid));
- Either<GraphVertex, TitanOperationStatus> fromVertex = titanDao.getVertexById(fromUid);
- Either<GraphVertex, TitanOperationStatus> toVertex = titanDao.getVertexById(toUid);
- if (toVertex.isLeft() && fromVertex.isLeft()) {
- TitanOperationStatus versionCreated = titanDao.createEdge(fromVertex.left().value(), toVertex.left().value(), EdgeLabelEnum.VERSION, new HashMap<>());
- return versionCreated == TitanOperationStatus.OK;
- }
- return MigrationUtils.handleError(String.format("could not create version edge between vertex %s and vertex %s.", fromUid, toUid));
- }
-
- private Either<Boolean, TitanOperationStatus> isVersionExists(String fromUid, String toUid) {
- LOGGER.debug(String.format("checking if version edge between vertex %s and vertex %s already exist", fromUid, toUid));
- String uidKey = UniqueIdBuilder.getKeyByNodeType(getNodeTypeEnum());
- Either<Edge, TitanOperationStatus> edgeByVertices = titanGenericDaoMigration.getEdgeByVerticies(uidKey, fromUid, uidKey, toUid, EdgeLabelEnum.VERSION.name());
- if (isNotFoundStatus(edgeByVertices)) {
- return Either.left(false);
- }
- return edgeByVertices.bimap(foundEdge -> true,
- error -> error);
- }
-
- private boolean isNotFoundStatus(Either<Edge, TitanOperationStatus> edgeByVertices) {
- return edgeByVertices.isRight() && edgeByVertices.right().value() == TitanOperationStatus.NOT_FOUND;
- }
-
- abstract NodeTypeEnum getNodeTypeEnum();
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/FulfilledCapabilitiesMigrationService.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/FulfilledCapabilitiesMigrationService.java
deleted file mode 100644
index 23b1afec93..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/FulfilledCapabilitiesMigrationService.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel.relations;
-
-import fj.data.Either;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapListCapabiltyDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.operations.api.ICapabilityOperation;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.ComponentInstanceOperation;
-import org.openecomp.sdc.be.resources.data.CapabilityData;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-public class FulfilledCapabilitiesMigrationService extends FulfilledCapabilityRequirementMigrationService<CapabilityDefinition, CapabilityData> {
-
- @Resource(name = "capability-operation")
- private ICapabilityOperation capabilityOperation;
-
- @Resource(name = "component-instance-operation")
- private ComponentInstanceOperation componentInstanceOperation;
-
- @Override
- Either<CapabilityDefinition, StorageOperationStatus> getToscaDefinition(CapabilityData data) {
- return capabilityOperation.getCapability(data.getUniqueId());
- }
-
- @Override
- void setPath(CapabilityDefinition def, List<String> path) {
- def.setPath(path);
- }
-
- @Override
- String getType(CapabilityDefinition def) {
- return def.getType();
- }
-
- @Override
- Either<List<ImmutablePair<CapabilityData, GraphEdge>>, TitanOperationStatus> getFulfilledCapReqs(ComponentInstance instance, NodeTypeEnum nodeTypeEnum) {
- return componentInstanceOperation.getFulfilledCapabilities(instance, nodeTypeEnum);
- }
-
- @Override
- ListDataDefinition convertToDefinitionListObject(List<CapabilityDefinition> capReqDefList) {
- List<CapabilityDataDefinition> capabilityDataDefinitions = new ArrayList<>();
- capabilityDataDefinitions.addAll(capReqDefList);
- return new ListCapabilityDataDefinition(capabilityDataDefinitions);
- }
-
- @Override
- MapDataDefinition convertToDefinitionMapObject(Map<String, ListDataDefinition> reqCapForInstance) {
- Map<String, ListCapabilityDataDefinition> capabilitiesList = castDataDefinitionListToCapabilityList(reqCapForInstance);
- return new MapListCapabiltyDataDefinition(capabilitiesList);
- }
-
- @Override
- Either<GraphVertex, TitanOperationStatus> getAssociatedDefinitions(GraphVertex component) {
- return titanDao.getChildVertex(component, EdgeLabelEnum.FULLFILLED_REQUIREMENTS, JsonParseFlagEnum.NoParse);
- }
-
- @Override
- Either<GraphVertex, StorageOperationStatus> associateToGraph(GraphVertex graphVertex, Map<String, MapDataDefinition> defsByInstance) {
- return topologyTemplateOperation.assosiateElementToData(graphVertex, VertexTypeEnum.FULLFILLED_CAPABILITIES, EdgeLabelEnum.FULLFILLED_CAPABILITIES, defsByInstance);
- }
-
- private Map<String, ListCapabilityDataDefinition> castDataDefinitionListToCapabilityList(Map<String, ListDataDefinition> reqCapForInstance) {
- return reqCapForInstance.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> (ListCapabilityDataDefinition) entry.getValue()));
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/FulfilledCapabilityRequirementMigrationService.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/FulfilledCapabilityRequirementMigrationService.java
deleted file mode 100644
index 33b5574408..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/FulfilledCapabilityRequirementMigrationService.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel.relations;
-
-import fj.Function;
-import fj.data.Either;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.asdctool.impl.migration.MigrationException;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationUtils;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.api.ToscaDefinitionPathCalculator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Resource;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import static org.openecomp.sdc.asdctool.impl.migration.MigrationMsg.*;
-import static org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationUtils.willThrowException;
-
-public abstract class FulfilledCapabilityRequirementMigrationService<T extends ToscaDataDefinition, S extends GraphNode> {
-
- private static Logger LOGGER = LoggerFactory.getLogger(FulfilledCapabilityRequirementMigrationService.class);
-
- @Resource(name = "topology-template-operation")
- TopologyTemplateOperation topologyTemplateOperation;
-
- @Resource(name = "tosca-path-calculator")
- private ToscaDefinitionPathCalculator toscaDefinitionPathCalculator;
-
- @Resource(name = "titan-dao")
- TitanDao titanDao;
-
- public boolean associateToscaDefinitions(Component component, NodeTypeEnum componentType) {
- try {
- return isDefinitionsAlreadyAssociated(component) || doAssociateToscaDefinitions(component, componentType);
- } catch (MigrationException e) {
- LOGGER.error(e.getMessage(), e);
- return false;
- }
- }
-
- private boolean isDefinitionsAlreadyAssociated(Component component) {
- GraphVertex componentVertex = titanDao.getVertexById(component.getUniqueId()).left().on((err) -> willThrowException(FAILED_TO_RETRIEVE_VERTEX.getMessage(component.getName(), err.name())));
- return this.getAssociatedDefinitions(componentVertex)
- .either(vertex -> true,
- errorStatus -> notFoundStatusOrFail(component, errorStatus));
-
- }
-
- private boolean notFoundStatusOrFail(Component component, TitanOperationStatus error) {
- if (error.equals(TitanOperationStatus.NOT_FOUND)) {
- return false;
- }
- throw new MigrationException(FAILED_TO_RETRIEVE_CAP_REQ_VERTEX.getMessage(component.getName(), error.name()));
- }
-
- private boolean doAssociateToscaDefinitions(Component component, NodeTypeEnum componentType) {
- try {
- Map<String, MapDataDefinition> toscaDefByInstance = groupToscaDefinitionByInstance(component, componentType);
- return toscaDefByInstance.isEmpty() || updateOnGraph(component, toscaDefByInstance);
- } catch (MigrationException e) {
- LOGGER.error(e.getMessage(), e);
- return false;
- }
- }
-
- private Map<String, MapDataDefinition> groupToscaDefinitionByInstance(Component component, NodeTypeEnum componentType) {
- Map<String, MapDataDefinition> toscaDefByInstance = new HashMap<>();
- for (ComponentInstance componentInstance : component.getComponentInstances()) {
- List<ImmutablePair<S, GraphEdge>> fulfilledCapReq = getFulfilledCapReqs(componentType, componentInstance);
- if (fulfilledCapReq.isEmpty()) {
- continue;
- }
- toscaDefByInstance.put(componentInstance.getUniqueId(), getReqCapToscaDefs(fulfilledCapReq, componentInstance));
- }
- return toscaDefByInstance;
- }
-
- private MapDataDefinition getReqCapToscaDefs(List<ImmutablePair<S, GraphEdge>> capReqsData, ComponentInstance componentInstance) {
- Map<String, List<T>> capReqDefinitions = getCapReqDefinitions(componentInstance, capReqsData);
- return convertToMapDefinition(capReqDefinitions);
- }
-
- private List<ImmutablePair<S, GraphEdge>> getFulfilledCapReqs(NodeTypeEnum componentType, ComponentInstance componentInstance) {
- return getFulfilledCapReqs(componentInstance, componentType)
- .either(Function.identity(),
- error -> emptyListOrFail(error, componentInstance.getName()));
- }
-
- private List<ImmutablePair<S, GraphEdge>> emptyListOrFail(TitanOperationStatus error, String instanceName) {
- if (error.equals(TitanOperationStatus.NOT_FOUND)) {
- return Collections.emptyList();
- }
- String errorMsg = FAILED_TO_RETRIEVE_REQ_CAP.getMessage(instanceName, error.name());
- throw new MigrationException(errorMsg);
- }
-
- private Map<String, List<T>> getCapReqDefinitions(ComponentInstance componentInstance, List<ImmutablePair<S, GraphEdge>> capReqDataList) {
- return capReqDataList.stream()
- .map(capReqData -> convertToToscaDef(componentInstance, capReqData))
- .collect(Collectors.groupingBy(this::getType));
- }
-
- private T convertToToscaDef(ComponentInstance componentInstance, ImmutablePair<S, GraphEdge> data) {
- T def = getReqCapDataDefinition(data);
- List<String> definitionPath = toscaDefinitionPathCalculator.calculateToscaDefinitionPath(componentInstance, data.getRight());
- setPath(def, definitionPath);
- return def;
- }
-
- private T getReqCapDataDefinition(ImmutablePair<S, GraphEdge> data) {
- S capReqData = data.getLeft();
- return getToscaDefinition(capReqData).left().on(err -> willThrowException(FAILED_TO_RETRIEVE_TOSCA_DEF.getMessage(capReqData.getUniqueId().toString(), err.toString())));
- }
-
- private boolean updateOnGraph(Component component, Map<String, MapDataDefinition> defsByInstance) {
- GraphVertex graphVertex = getComponentGraphVertex(component);
- Either<GraphVertex, StorageOperationStatus> associatedVertex = associateToGraph(graphVertex, defsByInstance);
- return associatedVertex.either(vertex -> true, err -> MigrationUtils.handleError(FAILED_TO_ASSOCIATE_CAP_REQ.getMessage(component.getName(), err.name())));
- }
-
- private GraphVertex getComponentGraphVertex(Component component) {
- return titanDao.getVertexById(component.getUniqueId())
- .left().on(error -> willThrowException(FAILED_TO_RETRIEVE_VERTEX.getMessage(component.getUniqueId(), error.name())));
- }
-
- private MapDataDefinition convertToMapDefinition(Map<String, List<T>> toscaDefs) {
- Map<String, ListDataDefinition> defsListByType = toscaDefs.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, entry -> convertToDefinitionListObject(entry.getValue())));
- return convertToDefinitionMapObject(defsListByType);
- }
-
- abstract Either<T, ?> getToscaDefinition(S data);
-
- abstract void setPath(T def, List<String> path);
-
- abstract String getType(T def);
-
- abstract Either<List<ImmutablePair<S, GraphEdge>>, TitanOperationStatus> getFulfilledCapReqs(ComponentInstance instance, NodeTypeEnum nodeTypeEnum);
-
- abstract ListDataDefinition convertToDefinitionListObject(List<T> capReqDefList);
-
- abstract MapDataDefinition convertToDefinitionMapObject(Map<String, ListDataDefinition> reqCapForInstance);
-
- abstract Either<GraphVertex, TitanOperationStatus> getAssociatedDefinitions(GraphVertex component);
-
- abstract Either<GraphVertex, StorageOperationStatus> associateToGraph(GraphVertex graphVertex, Map<String, MapDataDefinition> defsByInstance);
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/FulfilledRequirementsMigrationService.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/FulfilledRequirementsMigrationService.java
deleted file mode 100644
index 2b720af751..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/FulfilledRequirementsMigrationService.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel.relations;
-
-import fj.data.Either;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.operations.api.IComponentInstanceOperation;
-import org.openecomp.sdc.be.model.operations.api.IRequirementOperation;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.resources.data.RequirementData;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-public class FulfilledRequirementsMigrationService extends FulfilledCapabilityRequirementMigrationService<RequirementDefinition, RequirementData> {
-
- @Resource(name = "requirement-operation")
- IRequirementOperation requirementOperation;
-
- @Resource(name = "component-instance-operation")
- IComponentInstanceOperation componentInstanceOperation;
-
- @Override
- Either<RequirementDefinition, TitanOperationStatus> getToscaDefinition(RequirementData data) {
- return requirementOperation.getRequirement(data.getUniqueId());
- }
-
- @Override
- void setPath(RequirementDefinition def, List<String> path) {
- def.setPath(path);
- }
-
- @Override
- String getType(RequirementDefinition def) {
- return def.getCapability();
- }
-
- @Override
- Either<List<ImmutablePair<RequirementData, GraphEdge>>, TitanOperationStatus> getFulfilledCapReqs(ComponentInstance instance, NodeTypeEnum nodeTypeEnum) {
- return componentInstanceOperation.getFulfilledRequirements(instance, nodeTypeEnum);
- }
-
- @Override
- ListDataDefinition convertToDefinitionListObject(List<RequirementDefinition> capReqDefList) {
- List<RequirementDataDefinition> requirementDataDefinitions = new ArrayList<>();
- requirementDataDefinitions.addAll(capReqDefList);
- return new ListRequirementDataDefinition(requirementDataDefinitions);
- }
-
- @Override
- MapDataDefinition convertToDefinitionMapObject(Map<String, ListDataDefinition> reqCapForInstance) {
- Map<String, ListRequirementDataDefinition> reqDefList = castDefinitionListToRequirementList(reqCapForInstance);
- return new MapListRequirementDataDefinition(reqDefList);
- }
-
- @Override
- Either<GraphVertex, TitanOperationStatus> getAssociatedDefinitions(GraphVertex component) {
- return titanDao.getChildVertex(component, EdgeLabelEnum.FULLFILLED_REQUIREMENTS, JsonParseFlagEnum.NoParse);
- }
-
- @Override
- Either<GraphVertex, StorageOperationStatus> associateToGraph(GraphVertex graphVertex, Map<String, MapDataDefinition> defsByInstance) {
- return topologyTemplateOperation.assosiateElementToData(graphVertex, VertexTypeEnum.FULLFILLED_REQUIREMENTS, EdgeLabelEnum.FULLFILLED_REQUIREMENTS, defsByInstance);
- }
-
- private Map<String, ListRequirementDataDefinition> castDefinitionListToRequirementList(Map<String, ListDataDefinition> reqCapForInstance) {
- return reqCapForInstance.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> (ListRequirementDataDefinition) entry.getValue()));
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/RequirementsCapabilitiesMigrationService.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/RequirementsCapabilitiesMigrationService.java
deleted file mode 100644
index e468dd2fc5..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/v1707/jsonmodel/relations/RequirementsCapabilitiesMigrationService.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.migration.v1707.jsonmodel.relations;
-
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-public class RequirementsCapabilitiesMigrationService<T extends Component> {
-
- @Resource(name = "fulfilled-capabilities-mig-service")
- FulfilledCapabilitiesMigrationService fulfilledCapabilityUpdate;
-
- @Resource(name = "fulfilled-requirements-mig-service")
- FulfilledRequirementsMigrationService fulfilledRequirementUpdate;
-
- public boolean associateFulfilledCapabilities(T component, NodeTypeEnum nodeType) {
- return fulfilledCapabilityUpdate.associateToscaDefinitions(component, nodeType);
- }
-
- public boolean associateFulfilledRequirements(T component, NodeTypeEnum nodeType) {
- return fulfilledRequirementUpdate.associateToscaDefinitions(component, nodeType);
- }
-
- public void overrideInstanceCapabilitiesRequirements(T element) {
- if (element.getComponentInstances() != null) {
- clearInstancesCapabilitiesRequirements(element);
- setInstancesRequirementsFromComponent(element);
- setInstancesCapabilitiesFromComponent(element);
- }
- }
-
- private void clearInstancesCapabilitiesRequirements(T element) {
- element.getComponentInstances().forEach(componentInstance -> {
- if (componentInstance.getCapabilities() != null) {
- componentInstance.getCapabilities().clear();
- }
- if (componentInstance.getRequirements() != null) {
- componentInstance.getRequirements().clear();
- }
- });
- }
-
- private void setInstancesCapabilitiesFromComponent(T element) {
- if (element.getCapabilities() != null) {
- Map<String, ComponentInstance> instancesById = groupInstancesById(element);
- element.getCapabilities().forEach((type, definitions) -> { setCapabilitiesOnInstance(instancesById, type, definitions);});
- }
- }
-
- private void setInstancesRequirementsFromComponent(T element) {
- if (element.getRequirements() != null) {
- Map<String, ComponentInstance> instancesById = groupInstancesById(element);
- element.getRequirements().forEach((type, requirements) -> { setRequirementsOnInstance(instancesById, type, requirements);});
- }
- }
-
- private void setCapabilitiesOnInstance(Map<String, ComponentInstance> instances, String capabilityType, List<CapabilityDefinition> definitions) {
- Map<String, List<CapabilityDefinition>> capByInstance = definitions.stream().collect(Collectors.groupingBy(CapabilityDefinition::getOwnerId));
- capByInstance.forEach((instanceId, capabilityDefinitions) -> { setCapabilitiesOnInstanceByType(instances.get(instanceId), capabilityType, capabilityDefinitions); });
- }
-
- private void setRequirementsOnInstance(Map<String, ComponentInstance> instances, String requirementType, List<RequirementDefinition> requirements) {
- Map<String, List<RequirementDefinition>> reqByInstance = requirements.stream().collect(Collectors.groupingBy(RequirementDefinition::getOwnerId));
- reqByInstance.forEach((instanceId, reqDefinitions) -> { setRequirementsOnInstanceByType(instances.get(instanceId), requirementType, reqDefinitions);});
- }
-
- private void setCapabilitiesOnInstanceByType(ComponentInstance instance, String capabilityType, List<CapabilityDefinition> capabilityDefinitions) {
- instance.getCapabilities().putIfAbsent(capabilityType, new ArrayList<>());
- instance.getCapabilities().get(capabilityType).addAll(capabilityDefinitions);
- }
-
- private void setRequirementsOnInstanceByType(ComponentInstance instance, String requirementType, List<RequirementDefinition> reqDefinitions) {
- instance.getRequirements().putIfAbsent(requirementType, new ArrayList<>());
- instance.getRequirements().get(requirementType).addAll(reqDefinitions);
- }
-
- private Map<String, ComponentInstance> groupInstancesById(T element) {
- return element.getComponentInstances()
- .stream()
- .collect(Collectors.toMap(ComponentInstance::getUniqueId, Function.identity()));
- }
-
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java
index facb9d70f2..79b36f0004 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java
@@ -16,12 +16,22 @@ public class ValidationConfigManager {
return outputFilePath;
}
- public static void setOutputFilePath(String outputFilePath) {
- ValidationConfigManager.outputFilePath = outputFilePath;
+ public static void setOutputFilePath(String outputPath) {
+ ValidationConfigManager.outputFilePath = outputPath+ "/reportOutput.txt";
}
private static String outputFilePath;
+ public static String getCsvReportFilePath() {
+ return csvReportFilePath;
+ }
+
+ public static void setCsvReportFilePath(String outputPath) {
+ ValidationConfigManager.csvReportFilePath = outputPath +"/csvSummary_"+System.currentTimeMillis()+".csv";
+ }
+
+ private static String csvReportFilePath = "summary.csv";
+
public static Properties setValidationConfiguration(String path){
InputStream input = null;
try {
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java
index 038134bbfe..80e80ab472 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.asdctool.impl.validator.config;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.MigrationTitanStrategy;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ArtifactValidationUtils;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ServiceArtifactValidationTask;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.VfArtifactValidationTask;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
index 84d881c168..15f25738c0 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
@@ -3,6 +3,7 @@ package org.openecomp.sdc.asdctool.impl.validator.executers;
import fj.data.Either;
import org.openecomp.sdc.asdctool.impl.validator.tasks.TopologyTemplateValidationTask;
import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
+import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
@@ -29,9 +30,6 @@ public class TopologyTemplateValidatorExecuter {
protected TitanDao titanDao;
@Autowired
- protected ToscaOperationFacade toscaOperationFacade;
-
- @Autowired
protected TopologyTemplateOperation topologyTemplateOperation;
protected String name;
@@ -44,10 +42,6 @@ public class TopologyTemplateValidatorExecuter {
return name;
}
- public void reportValidateTaskStatus(TopologyTemplateValidationTask validationTask, boolean success, GraphVertex vertexScanned) {
- ReportManager.reportValidationTaskStatus(vertexScanned, validationTask.getTaskName(), validationTask.getTaskResultStatus(), success);
- }
-
protected List<GraphVertex> getVerticesToValidate(ComponentTypeEnum type) {
Map<GraphPropertyEnum, Object> props = new EnumMap<>(GraphPropertyEnum.class);
props.put(GraphPropertyEnum.COMPONENT_TYPE, type.name());
@@ -58,7 +52,7 @@ public class TopologyTemplateValidatorExecuter {
Either<List<GraphVertex>, TitanOperationStatus> results = titanDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, props);
if (results.isRight()) {
System.out.println("getVerticesToValidate failed "+ results.right().value());
- return new ArrayList<GraphVertex>();
+ return new ArrayList<>();
}
System.out.println("getVerticesToValidate: "+results.left().value().size()+" vertices to scan");
return results.left().value();
@@ -71,20 +65,22 @@ public class TopologyTemplateValidatorExecuter {
boolean successAllVertices = true;
int vertexNum = 0;
int verticesSize = vertices.size();
+
for (GraphVertex vertex: vertices) {
vertexNum++;
boolean successAllTasks = true;
for (TopologyTemplateValidationTask task: tasks) {
ReportManager.reportStartTaskRun(vertex, task.getTaskName());
- boolean success = task.validate(vertex);
- if (!success) {
+ VertexResult result = task.validate(vertex);
+ if (!result.getStatus()) {
failedTasks.add(task.getTaskName());
successAllVertices = false;
successAllTasks = false;
} else if (successAllTasks && vertexNum == verticesSize) {
successTasks.add(task.getTaskName());
}
- reportValidateTaskStatus(task, success, vertex);
+ ReportManager.printValidationTaskStatus(vertex, task.getTaskName(), result.getStatus());
+ ReportManager.reportTaskEnd(vertex.getUniqueId(), task.getTaskName(), result);
}
String componentScanStatus = successAllTasks? "success" : "failed";
System.out.println("Topology Template "+vertex.getUniqueId()+" Validation finished with "+componentScanStatus);
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java
index 6ca012546b..d73b197ac7 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java
@@ -1,12 +1,13 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks;
+import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
/**
* Created by chaya on 7/5/2017.
*/
public interface TopologyTemplateValidationTask {
- boolean validate(GraphVertex vertex);
+ VertexResult validate(GraphVertex vertex);
String getTaskName();
String getTaskResultStatus();
void setTaskResultStatus(String status);
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
index dd79943885..faccd647c2 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
@@ -27,21 +27,21 @@ public class ArtifactValidationUtils {
@Autowired
private TopologyTemplateOperation topologyTemplateOperation;
- public boolean validateArtifactsAreInCassandra(GraphVertex vertex, String taskName, List<ArtifactDataDefinition> artifacts) {
- boolean allArtifactsExist = true;
+ public ArtifactsVertexResult validateArtifactsAreInCassandra(GraphVertex vertex, String taskName, List<ArtifactDataDefinition> artifacts) {
+ ArtifactsVertexResult result = new ArtifactsVertexResult(true);
for(ArtifactDataDefinition artifact:artifacts) {
boolean isArtifactExist = isArtifcatInCassandra(artifact.getEsId());
String status = isArtifactExist ? "Artifact " + artifact.getEsId() + " is in Cassandra" :
"Artifact " + artifact.getEsId() + " doesn't exist in Cassandra";
- if (!isArtifactExist) {
- ReportManager.addFailedVertex(taskName, vertex.getUniqueId());
- }
+
ReportManager.writeReportLineToFile(status);
if (!isArtifactExist) {
- allArtifactsExist = false;
+ ReportManager.addFailedVertex(taskName, vertex.getUniqueId());
+ result.setStatus(false);
+ result.addNotFoundArtifact(artifact.getUniqueId());
}
}
- return allArtifactsExist;
+ return result;
}
public boolean isArtifcatInCassandra(String uniueId) {
@@ -54,7 +54,6 @@ public class ArtifactValidationUtils {
}
Long count = countOfArtifactsEither.left().value();
if (count <1) {
- //System.out.print("Artifact "+uniueId+" count is: "+count);
return false;
}
return true;
@@ -70,14 +69,16 @@ public class ArtifactValidationUtils {
return artifacts;
}
- public boolean validateTopologyTemplateArtifacts(GraphVertex vertex, String taskName) {
+ public ArtifactsVertexResult validateTopologyTemplateArtifacts(GraphVertex vertex, String taskName) {
+ ArtifactsVertexResult result = new ArtifactsVertexResult();
ComponentParametersView paramView = new ComponentParametersView();
paramView.disableAll();
paramView.setIgnoreArtifacts(false);
paramView.setIgnoreComponentInstances(false);
Either<ToscaElement, StorageOperationStatus> toscaElementEither = topologyTemplateOperation.getToscaElement(vertex.getUniqueId(), paramView);
if (toscaElementEither.isRight()) {
- return false;
+ result.setStatus(false);
+ return result;
}
TopologyTemplate element = (TopologyTemplate) toscaElementEither.left().value();
Map<String, ArtifactDataDefinition> deploymentArtifacts = element.getDeploymentArtifacts();
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactsVertexResult.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactsVertexResult.java
new file mode 100644
index 0000000000..c010148644
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactsVertexResult.java
@@ -0,0 +1,30 @@
+package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
+
+import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Created by chaya on 7/25/2017.
+ */
+public class ArtifactsVertexResult extends VertexResult{
+ Set<String> notFoundArtifacts = new HashSet<>();
+
+ public ArtifactsVertexResult() {
+
+ }
+
+ public ArtifactsVertexResult(boolean status) {
+ super(status);
+ }
+
+ public void addNotFoundArtifact(String artifactId) {
+ notFoundArtifacts.add(artifactId);
+ }
+
+ @Override
+ public String getResult() {
+ return notFoundArtifacts.toString();
+ }
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java
index 410691fb47..0a224f8d84 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java
@@ -20,7 +20,7 @@ public class ServiceArtifactValidationTask extends ServiceValidationTask {
}
@Override
- public boolean validate(GraphVertex vertex) {
+ public ArtifactsVertexResult validate(GraphVertex vertex) {
return artifactValidationUtils.validateTopologyTemplateArtifacts(vertex, getTaskName());
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java
index 01bc26fe2b..bb25d25e2b 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
import org.openecomp.sdc.asdctool.impl.validator.tasks.VfValidationTask;
+import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
import org.springframework.beans.factory.annotation.Autowired;
@@ -18,11 +19,11 @@ public class VfArtifactValidationTask extends VfValidationTask {
protected TopologyTemplateOperation topologyTemplateOperation;
public VfArtifactValidationTask() {
- this.name = "Artifact Validation Task";
+ this.name = "VF Artifact Validation Task";
}
@Override
- public boolean validate(GraphVertex vertex) {
+ public VertexResult validate(GraphVertex vertex) {
return artifactValidationUtils.validateTopologyTemplateArtifacts(vertex, getTaskName());
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java
index f8de1d3264..187359f127 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java
@@ -4,10 +4,12 @@ import fj.data.Either;
import org.apache.cassandra.cql3.CQL3Type;
import org.openecomp.sdc.asdctool.impl.validator.tasks.ServiceValidationTask;
import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
+import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
@@ -32,7 +34,11 @@ public class ModuleJsonTask extends ServiceValidationTask {
}
@Override
- public boolean validate(GraphVertex vertex) {
+ public VertexResult validate(GraphVertex vertex) {
+ if (!isAfterSubmitForTesting(vertex)) {
+ return new VertexResult(true);
+ }
+
ComponentParametersView paramView = new ComponentParametersView();
paramView.disableAll();
paramView.setIgnoreArtifacts(false);
@@ -40,23 +46,20 @@ public class ModuleJsonTask extends ServiceValidationTask {
paramView.setIgnoreComponentInstances(false);
Either<ToscaElement, StorageOperationStatus> toscaElementEither = topologyTemplateOperation.getToscaElement(vertex.getUniqueId(), paramView);
if (toscaElementEither.isRight()) {
- return false;
+ return new VertexResult(false);
}
TopologyTemplate element = (TopologyTemplate) toscaElementEither.left().value();
- if (!isAfterSubmitForTesting(element)) {
- return true;
- }
Map<String, MapGroupsDataDefinition> instGroups = element.getInstGroups();
Map<String, MapArtifactDataDefinition> instDeploymentArtifacts = element.getInstDeploymentArtifacts();
for (Map.Entry<String, MapGroupsDataDefinition> pair : Optional.ofNullable(instGroups).orElse(Collections.emptyMap()).entrySet()) {
MapGroupsDataDefinition groups = pair.getValue();
if (groups != null && !groups.getMapToscaDataDefinition().isEmpty()) {
- return findCoordinateModuleJson(pair, instDeploymentArtifacts, vertex);
+ return new VertexResult(findCoordinateModuleJson(pair, instDeploymentArtifacts, vertex));
}
- return true;
+ return new VertexResult(true);
}
- return true;
+ return new VertexResult(true);
}
private boolean findCoordinateModuleJson(Map.Entry<String, MapGroupsDataDefinition> pair, Map<String, MapArtifactDataDefinition> instDeploymentArtifacts, GraphVertex vertex) {
@@ -84,9 +87,9 @@ public class ModuleJsonTask extends ServiceValidationTask {
return false;
}
- private boolean isAfterSubmitForTesting(TopologyTemplate element){
- List allowedStates = new ArrayList<>(Arrays.asList(LifecycleStateEnum.READY_FOR_CERTIFICATION,
- LifecycleStateEnum.CERTIFICATION_IN_PROGRESS, LifecycleStateEnum.CERTIFIED));
- return allowedStates.contains(element.getLifecycleState());
+ private boolean isAfterSubmitForTesting(GraphVertex vertex){
+ List allowedStates = new ArrayList<>(Arrays.asList(LifecycleStateEnum.READY_FOR_CERTIFICATION.name(),
+ LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.name(), LifecycleStateEnum.CERTIFIED.name()));
+ return allowedStates.contains(vertex.getMetadataProperty(GraphPropertyEnum.STATE));
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java
index 116883967a..64bea12957 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java
@@ -1,7 +1,6 @@
package org.openecomp.sdc.asdctool.impl.validator.utils;
import org.apache.commons.lang.text.StrBuilder;
-import org.openecomp.sdc.asdctool.impl.validator.tasks.TopologyTemplateValidationTask;
import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
@@ -16,23 +15,42 @@ import java.util.*;
*/
public class ReportManager {
- private static List<ValidationTaskResult> taskResults;
private static String reportOutputFilePath;
+ private static String csvReportFilePath;
private static Map<String, Set<String>> failedVerticesPerTask = new HashMap<>();
+ private static Map<String, Map<String, VertexResult>> resultsPerVertex = new HashMap<>();
public ReportManager() {
try {
- taskResults = new ArrayList<>();
- // open file for first time
- reportOutputFilePath = ValidationConfigManager.getOutputFilePath();
- StrBuilder sb = new StrBuilder();
- sb.appendln("-----------------------Validation Tool Results:-------------------------");
- Files.write(Paths.get(reportOutputFilePath), sb.toString().getBytes());
+ initCsvFile();
+ initReportFile();
} catch (IOException e) {
e.printStackTrace();
}
}
+ private void initReportFile() throws IOException {
+ reportOutputFilePath = ValidationConfigManager.getOutputFilePath();
+ StrBuilder sb = new StrBuilder();
+ sb.appendln("-----------------------Validation Tool Results:-------------------------");
+ Files.write(Paths.get(reportOutputFilePath), sb.toString().getBytes());
+ }
+
+ private void initCsvFile() throws IOException {
+ csvReportFilePath = ValidationConfigManager.getCsvReportFilePath();
+ StrBuilder sb = new StrBuilder();
+ sb.append("Vertex ID,"+"Task Name,"+"Success,"+"Result Details"+","+"Result Description");
+ sb.appendNewLine();
+ Files.write(Paths.get(csvReportFilePath), sb.toString().getBytes());
+ }
+
+ public static void reportTaskEnd(String vertexId, String taskName, VertexResult result) {
+ Map<String, VertexResult> vertexTasksResults =
+ Optional.ofNullable(resultsPerVertex.get(vertexId)).orElse(new HashMap<>());
+ vertexTasksResults.put(taskName, result);
+ resultsPerVertex.put(vertexId, vertexTasksResults);
+ }
+
public static void addFailedVertex (String taskName, String vertexId) {
Set<String> failedVertices = failedVerticesPerTask.get(taskName);
if (failedVertices == null) {
@@ -42,12 +60,7 @@ public class ReportManager {
failedVerticesPerTask.put(taskName, failedVertices);
}
- public static void reportValidationTaskStatus(GraphVertex vertexScanned, String taskName, String taskResultMessage, boolean success) {
- taskResults.add(new ValidationTaskResult(vertexScanned, taskName, taskResultMessage, success));
- printValidationTaskStatus(vertexScanned, taskName, success);
- }
-
- private static void printValidationTaskStatus(GraphVertex vertexScanned, String taskName, boolean success) {
+ public static void printValidationTaskStatus(GraphVertex vertexScanned, String taskName, boolean success) {
String successStatus = success ? "success" : "failed";
String line = "-----------------------Vertex: "+vertexScanned.getUniqueId()+", Task " + taskName + " " +successStatus+"-----------------------";
StrBuilder sb = new StrBuilder();
@@ -57,16 +70,6 @@ public class ReportManager {
writeReportLineToFile(line);
}
- public static void reportValidationTaskSummary(TopologyTemplateValidationTask task, int numOfFailedComponents, int numOfSuccessComponents) {
- StrBuilder sb = new StrBuilder();
- sb.appendNewLine();
- sb.appendln("-----------------------Task " + task.getTaskName() + " Validation Summary-----------------------");
- sb.appendln("Num of failed components: "+ numOfFailedComponents);
- sb.appendln("Num of success components: "+ numOfSuccessComponents);
- sb.appendln("Total components scanned: " + numOfFailedComponents+numOfSuccessComponents);
- writeReportLineToFile(sb.toString());
- }
-
public static void writeReportLineToFile(String message) {
try {
Files.write(Paths.get(reportOutputFilePath), new StrBuilder().appendNewLine().toString().getBytes(), StandardOpenOption.APPEND);
@@ -110,5 +113,20 @@ public class ReportManager {
sb.appendNewLine();
});
writeReportLineToFile(sb.toString());
+ printAllResults();
+ }
+
+ public static void printAllResults() {
+ resultsPerVertex.forEach((vertex, tasksResults)->{
+ tasksResults.forEach((task, result) -> {
+ try {
+ String resultLine = vertex +","+task+","+result.getStatus()+","+result.getResult();
+ Files.write(Paths.get(csvReportFilePath), resultLine.getBytes(), StandardOpenOption.APPEND);
+ Files.write(Paths.get(csvReportFilePath), new StrBuilder().appendNewLine().toString().getBytes(), StandardOpenOption.APPEND);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+ });
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/VertexResult.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/VertexResult.java
new file mode 100644
index 0000000000..4fe8ec30f5
--- /dev/null
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/VertexResult.java
@@ -0,0 +1,30 @@
+package org.openecomp.sdc.asdctool.impl.validator.utils;
+
+/**
+ * Created by chaya on 7/25/2017.
+ */
+public class VertexResult {
+
+ boolean status;
+
+ public VertexResult() {
+
+ }
+
+ public VertexResult(boolean status) {
+ this.status = status;
+ }
+
+ public boolean getStatus() {
+ return status;
+ }
+
+ public void setStatus(boolean status) {
+ this.status = status;
+ }
+
+ public String getResult() {
+ return String.valueOf(status);
+ }
+
+}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java
index b82b62b551..d563f2cf33 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/EsToCassandraDataMigrationMenu.java
@@ -32,7 +32,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
public class EsToCassandraDataMigrationMenu {
- private static Logger log = LoggerFactory.getLogger(MigrationMenu.class.getName());
+ private static Logger log = LoggerFactory.getLogger(EsToCassandraDataMigrationMenu.class.getName());
public static void main(String[] args) throws Exception {
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/MigrationMenu.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/MigrationMenu.java
deleted file mode 100644
index 600ebf848a..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/MigrationMenu.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.main;
-
-import java.util.Arrays;
-import java.util.Optional;
-
-import org.openecomp.sdc.asdctool.impl.PopulateComponentCache;
-import org.openecomp.sdc.asdctool.impl.migration.v1604.AppConfig;
-import org.openecomp.sdc.asdctool.impl.migration.v1604.DerivedFromAlignment;
-import org.openecomp.sdc.asdctool.impl.migration.v1604.GroupsAlignment;
-import org.openecomp.sdc.asdctool.impl.migration.v1604.ServiceMigration;
-import org.openecomp.sdc.asdctool.impl.migration.v1604.VfcNamingAlignment;
-import org.openecomp.sdc.asdctool.impl.migration.v1607.CsarMigration;
-import org.openecomp.sdc.asdctool.impl.migration.v1610.TitanFixUtils;
-import org.openecomp.sdc.asdctool.impl.migration.v1610.ToscaArtifactsAlignment;
-import org.openecomp.sdc.asdctool.impl.migration.v1702.Migration1702;
-import org.openecomp.sdc.asdctool.impl.migration.v1707.*;
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.common.api.ConfigurationSource;
-import org.openecomp.sdc.common.impl.ExternalConfiguration;
-import org.openecomp.sdc.common.impl.FSConfigurationSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-
-public class MigrationMenu {
-
- private static Logger log = LoggerFactory.getLogger(MigrationMenu.class.getName());
- private static final String SERVICE_MIGARTION_BEAN = "serviceMigrationBean";
-
- private static enum MigrationOperationEnum {
- MIGRATION_1602_1604("migrate-1602-1604", SERVICE_MIGARTION_BEAN),
- ALIGN_DERIVED_FROM_1604("align-derived-from-1604", "derivedFromAlignment"),
- MIGRATE_1604_1607("migrate-1604-1607", SERVICE_MIGARTION_BEAN),
- ALIGN_VFC_NAMES_1604("align-vfc-names-1604", "vfcNamingAlignmentBean"),
- TEST_REMOVE_HEAT_PLACEHOLDERS("testremoveheatplaceholders", SERVICE_MIGARTION_BEAN),
- TEST_ADD_GROUP_UUIDS("testaddgroupuuids", SERVICE_MIGARTION_BEAN),
- ALIGN_GROUPS("align-groups", "groupsAlignment"),
- CLEAN_CSAR("clean-csar", "csarMigration"),
- POPULATE_COMPONENT_CACHE("populate-component-cache", "populateComponentCache"),
- FIX_PROPERTIES("fix-properties", "titanFixUtils"),
- ALIGN_TOSCA_ARTIFACTS("align-tosca-artifacts", "toscaArtifactsAlignment"),
- FIX_ICONS("fix-icons", "titanFixUtils"),
- MIGRATION_1610_1702("migrate-1610-1702", "migration1702"),
- MIGRATION_1702_1707("migrate-1702-1707", "migration1707"),
- DISTRIBUTION_STATUS_UPDATE_1707("distribution-status-update-1707", "distributionStatusUpdate"),
- VFMODULES_PROPERTIES_ADDING("vfModules-properties-adding", "vfModulesPropertiesAdding"),
- MIGRATION_1707_RELATIONS_FIX("fix-relations-after-migration-1707", "migration1707relationsFix"),
- MIGRATION_1707_VNF_FIX("fix-vnf-after-migration-1707", "migration1707vnfFix"),
- MIGRATION_1707_UUID_FIX("fix-UUID-1707", "migration1707UuidFix"),
- MIGRATION_1707_MISSING_INFO_FIX("fix-missing-info-1707", "migration1707MissingInfoFix");
- // UPDATE_DATA_TYPES("update_data_types", "updateDataTypes");
-
- private String value, beanName;
-
- public static MigrationOperationEnum findByValue(String value) {
- Optional<MigrationOperationEnum> optionalFound = Arrays.asList(MigrationOperationEnum.values()).stream().filter(e -> e.getValue().equalsIgnoreCase(value)).findAny();
- return optionalFound.isPresent() ? optionalFound.get() : null;
- }
-
- MigrationOperationEnum(String value, String beanName) {
- this.value = value;
- this.beanName = beanName;
- }
-
- public String getValue() {
- return value;
- }
-
- public String getBeanName() {
- return beanName;
- }
- };
-
- //arguments will be [operation] [version] [config path] [align derived - optional]
- //example : migrate-1610-1702 1702 /home/config
- public static void main(String[] args) throws Exception {
-
- if (args == null || args.length < 3) {
- usageAndExit();
- }
- MigrationOperationEnum operationEnum = MigrationOperationEnum.findByValue(args[0]);
- String appConfigDir = args[2];
- String dataInputFileDir = null;
- if (operationEnum == MigrationOperationEnum.ALIGN_DERIVED_FROM_1604 ) {
- dataInputFileDir = args[3];
- }
- log.info("Run with configuration folder {}", appConfigDir);
- AnnotationConfigApplicationContext context = initContext(appConfigDir);
- try {
- ServiceMigration serviceMigration = (ServiceMigration) context.getBean(SERVICE_MIGARTION_BEAN);
- switch (operationEnum) {
- case MIGRATION_1602_1604:
- log.info("Start Titan migration from 1602 version to 1604");
- if (serviceMigration.migrate1602to1604(appConfigDir)) {
- log.info("Titan migration from 1602 version to 1604 was finished successfull");
- System.exit(0);
- } else {
- log.info("Titan migration from 1602 version to 1604 was failed");
- System.exit(2);
- }
- break;
- case MIGRATE_1604_1607:
- log.info("Start Titan migration from 1604 version to 1607");
- if (serviceMigration.migrate1604to1607(appConfigDir)) {
- log.info("Titan migration from 1604 version to 1607 was finished successfull");
- System.exit(0);
- } else {
- log.info("Titan migration from 1604 version to 1607 was failed");
- System.exit(2);
- }
- break;
- case ALIGN_VFC_NAMES_1604:
- VfcNamingAlignment vfcNamingAlignment = (VfcNamingAlignment) context.getBean(operationEnum.getBeanName());
- log.info("Start VFC naming alignment on 1604");
- if (vfcNamingAlignment.alignVfcNames1604(appConfigDir)) {
- log.info("VFC naming alignment on 1604 was finished successfull");
- System.exit(0);
- } else {
- log.info("VFC naming alignment on 1604 was failed");
- System.exit(2);
- }
- break;
- case TEST_REMOVE_HEAT_PLACEHOLDERS:
- boolean check = serviceMigration.testRemoveHeatPlaceHolders(appConfigDir);
- if (check == true) {
- System.exit(0);
- } else {
- System.exit(2);
- }
- break;
- case TEST_ADD_GROUP_UUIDS:
- check = serviceMigration.testAddGroupUuids(appConfigDir);
- if (check == true) {
- System.exit(0);
- } else {
- System.exit(2);
- }
- break;
- case ALIGN_DERIVED_FROM_1604:
- DerivedFromAlignment derivedFromAlignment = (DerivedFromAlignment) context.getBean(operationEnum.getBeanName());
- log.info("Start derived from alignment on 1604");
- if (derivedFromAlignment.alignDerivedFrom1604(appConfigDir, dataInputFileDir)) {
- log.info("Derived from alignment on 1604 was finished successfull");
- System.exit(0);
- } else {
- log.info("Derived from alignment on 1604 was failed");
- System.exit(2);
- }
- break;
- case ALIGN_GROUPS:
- GroupsAlignment groupsAlignment = (GroupsAlignment) context.getBean(operationEnum.getBeanName());
- log.debug("Start derived from alignment on 1604");
- if (groupsAlignment.alignGroups(appConfigDir)) {
- log.debug("Groups alignment was finished successfull");
- System.exit(0);
- } else {
- log.debug("Groups alignment was failed");
- System.exit(2);
- }
- break;
- case CLEAN_CSAR:
- log.info("Start remove CSAR resources");
- CsarMigration csarMigration = (CsarMigration) context.getBean(operationEnum.getBeanName());
- if (csarMigration.removeCsarResources()) {
- log.info("Remove CSAR resources finished successfully");
- System.exit(0);
- } else {
- log.info("Remove CSAR resources failed");
- System.exit(2);
- }
- break;
- case POPULATE_COMPONENT_CACHE:
- PopulateComponentCache populateComponentCache = (PopulateComponentCache) context.getBean(operationEnum.getBeanName());
- populateComponentCache.populateCache();
- System.exit(0);
- break;
- case FIX_PROPERTIES:
- log.debug("Start fix capability properties types");
- TitanFixUtils titanFixUtils = (TitanFixUtils) context.getBean(operationEnum.getBeanName());
- if (titanFixUtils.fixCapabiltyPropertyTypes()) {
- log.debug("Fix capability properties types finished successfully");
- System.exit(0);
- } else {
- log.debug("Fix capability properties types failed");
- System.exit(2);
- }
- break;
- case FIX_ICONS:
- log.info("Start fix icons of vl and eline");
- titanFixUtils = (TitanFixUtils) context.getBean(operationEnum.getBeanName());
- if (titanFixUtils.fixIconsInNormatives()) {
- log.info("Fix icons of vl and eline finished successfully");
- System.exit(0);
- } else {
- log.info("Fix icons of vl and eline failed");
- System.exit(2);
- }
- break;
- case ALIGN_TOSCA_ARTIFACTS:
- log.info("Start align tosca artifacts");
- ToscaArtifactsAlignment toscaArtifactsAlignment = (ToscaArtifactsAlignment) context.getBean(operationEnum.getBeanName());
- boolean isSuccessful = toscaArtifactsAlignment.alignToscaArtifacts();
- if (isSuccessful) {
- log.info("Tosca Artifacts alignment was finished successfully");
- System.exit(0);
- } else {
- log.info("Tosca Artifacts alignment has failed");
- System.exit(2);
- }
- break;
- case MIGRATION_1610_1702:
- log.info("Start SDC migration from 1610 to 1702");
- Migration1702 migration = (Migration1702) context.getBean(operationEnum.getBeanName());
- isSuccessful = migration.migrate(appConfigDir);
- if (isSuccessful) {
- log.info("SDC migration from 1610 to 1702 was finished successful");
- System.exit(0);
- } else{
- log.info("SDC migration from 1610 to 1702 has failed");
- System.exit(2);
- }
-
- break;
- case MIGRATION_1702_1707://this migration is currently not needed, but will be commented out for production env
-// log.info("Start SDC migration from 1702 to 1707");
- Migration1707 migration1707 = (Migration1707) context.getBean(operationEnum.getBeanName());
- isSuccessful = migration1707.migrate();
- if (isSuccessful) {
- log.info("SDC migration from 1702 to 1707 was finished successfully");
- System.exit(0);
- } else{
- log.info("SDC migration from 1702 to 1707 has failed");
- System.exit(2);
- }
- System.exit(0);
- break;
- case VFMODULES_PROPERTIES_ADDING://this migration is currently not needed, but will be commented out for production env
- log.info("Start adding new properties to vfModules");
- VfModulesPropertiesAdding migrationVfModulesProperties = (VfModulesPropertiesAdding) context.getBean(operationEnum.getBeanName());
- isSuccessful = migrationVfModulesProperties.migrate(args[1]);
- if (isSuccessful) {
- log.info("Adding new properties to vfModules was finished successfully");
- System.exit(0);
- } else{
- log.info("Adding new properties to vfModules has failed");
- System.exit(2);
- }
- System.exit(0);
- break;
- case MIGRATION_1707_UUID_FIX:
- if (args == null || args.length < 5) {
- System.out.println("Usage: fix-UUID-1707 <configuration dir> <all/distributed_only> <services/service_vf/fix/fix_only_services>");
- System.exit(1);
- }
- String fixServices = args[3];
- String runMode = args[4];
- log.info("Start fixing artifact UUID after 1707 migration with arguments run with configuration [{}] , for [{}] services", runMode, fixServices);
-
- Migration1707ArtifactUuidFix migrationFix = (Migration1707ArtifactUuidFix) context.getBean(operationEnum.getBeanName());
- isSuccessful = migrationFix.migrate(fixServices, runMode);
- if (isSuccessful) {
- log.info("Fixing artifacts UUID for 1707 was finished successfully");
- } else{
- log.info("Fixing artifacts UUID for 1707 has failed");
- System.exit(2);
- }
- System.exit(0);
- break;
- case MIGRATION_1707_MISSING_INFO_FIX:
-
- log.info("Start fixing missing group and instance info after 1707 migration");
-
- Migration1707MissingInfoFix migration1707Fix = (Migration1707MissingInfoFix) context.getBean(operationEnum.getBeanName());
- isSuccessful = migration1707Fix.migrate();
- if (isSuccessful) {
- log.info("Fixing groups and node templates missing info was finished successfully");
- } else{
- log.info("Fixing groups and node templates missing info has failed");
- System.exit(2);
- }
- System.exit(0);
- break;
- default:
- usageAndExit();
- }
- } catch (Exception t) {
- log.info("Failed {} with exception: {}", operationEnum, t.toString());
- t.printStackTrace();
- log.debug("Error while Running MigrationMenu {}", t.getMessage(), t);
- System.exit(3);
- } finally {
- context.close();
- }
- }
-
- private static AnnotationConfigApplicationContext initContext(String appConfigDir) {
- ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
- ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
- AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class, Migration1707Config.class);
- return context;
- }
-
- private static void usageAndExit() {
- MigrationUsage();
- System.exit(1);
- }
-
- private static void MigrationUsage() {
- System.out.println("Usage: migrate-1602-1604 <configuration dir>");
- System.out.println("Usage: migrate-1604-1607 <configuration dir>");
- System.out.println("Usage: align-vfc-names-1604 <configuration dir>");
- System.out.println("Usage: align-derived-from-1604 <configuration dir> <data_input_file dir>");
- System.out.println("Usage: align-groups <configuration dir>");
- System.out.println("Usage: fix-properties <configuration dir>");
- System.out.println("Usage: migrate-1610-1702 <configuration dir>");
- System.out.println("Usage: migrate-1702-1707 <configuration dir>");
- System.out.println("Usage: update_data_types <configuration dir> <data_types_input_file path>");
- System.out.println("Usage: distribution-status-update-1707");
- System.out.println("Usage: vfModules-properties-adding <group_types_input_file path> <configuration dir>");
- System.out.println("Usage: fix-relations-after-migration-1707 <configuration dir>");
- System.out.println("Usage: fix-vnf-after-migration-1707 <configuration dir>");
- System.out.println("Usage: fix-UUID-1707 <configuration dir> <all/distributed_only> <services/service_vf/fix/fix_only_services>");
- System.out.println("Usage: fix-missing-info-1707 <configuration dir>");
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java
index 758dae0342..394683bbc5 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java
@@ -130,9 +130,9 @@ public class SdcSchemaFileImport {
System.err.println("Failed to pack SDC.zip file, error: "+ex);
System.exit(1);
}
-
- //Generation flow end - generating SDC from normatives
+ //Generation flow end - generating SDC from normatives
+
AnnotationConfigApplicationContext context = initContext(appConfigDir);
schemaFilesCassandraDao = (SdcSchemaFilesCassandraDao) context.getBean("sdc-schema-files-cassandra-dao");
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java
index db87a66cd3..1ee006a49f 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java
@@ -3,7 +3,6 @@ package org.openecomp.sdc.asdctool.main;
import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL;
import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
import org.openecomp.sdc.asdctool.impl.validator.config.ValidationToolConfiguration;
-import org.openecomp.sdc.asdctool.impl.migration.v1604.AppConfig;
import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.common.api.ConfigurationSource;
@@ -22,8 +21,9 @@ public class ValidationTool {
public static void main(String[] args) throws Exception {
- String outputFilePath = args[0];
- ValidationConfigManager.setOutputFilePath(outputFilePath);
+ String outputPath = args[0];
+ ValidationConfigManager.setOutputFilePath(outputPath);
+ ValidationConfigManager.setCsvReportFilePath(outputPath);
String appConfigDir = args[1];
AnnotationConfigApplicationContext context = initContext(appConfigDir);
diff --git a/asdctool/src/main/resources/scripts/dataMigration.sh b/asdctool/src/main/resources/scripts/dataMigration.sh
deleted file mode 100644
index e1f4f24a30..0000000000
--- a/asdctool/src/main/resources/scripts/dataMigration.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-##############################
-# Data Migration
-##############################
-
-CURRENT_DIR=`pwd`
-BASEDIR=$(dirname $1)
-
-if [ ${BASEDIR:0:1} = "/" ]
-then
- FULL_PATH=$BASEDIR
-else
- FULL_PATH=$CURRENT_DIR/$BASEDIR
-fi
-
-source ${FULL_PATH}/baseOperation.sh
-
-mainClass="org.openecomp.sdc.asdctool.main.MigrationMenu"
-
-case $1 in
- 1604)
- command="java $JVM_LOG_FILE -cp $JARS $mainClass migrate-1602-1604 $@"
- echo $command
- ;;
- 1607)
- command="sh ./dataMigration1607.sh $@"
- echo $command
- ;;
- 1610)
- command="sh ./dataMigration1610.sh $@"
- echo $command
- ;;
- 1702)
- command="sh ./dataMigration1702.sh $@"
- echo $command
- ;;
- 1707)
- command="sh ./dataMigration1707.sh $@"
- echo $command
- ;;
- *)
- echo "No migration for this version $1"
- ;;
-esac
-
-$command
-result=$?
-
-echo "***********************************"
-echo "***** $result *********************"
-echo "***********************************"
-
-exit $result
-
-
diff --git a/asdctool/src/main/resources/scripts/dataMigration1607.sh b/asdctool/src/main/resources/scripts/dataMigration1607.sh
deleted file mode 100644
index 027852d882..0000000000
--- a/asdctool/src/main/resources/scripts/dataMigration1607.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-
-##############################
-# Data Migration 1607
-##############################
-
-CURRENT_DIR=`pwd`
-BASEDIR=$(dirname $0)
-
-if [ ${BASEDIR:0:1} = "/" ]
-then
- FULL_PATH=$BASEDIR
-else
- FULL_PATH=$CURRENT_DIR/$BASEDIR
-fi
-
-source ${FULL_PATH}/baseOperation.sh
-
-mainClass="org.openecomp.sdc.asdctool.main.MigrationMenu"
-
-command="java $JVM_LOG_FILE -cp $JARS $mainClass migrate-1604-1607 $@"
-echo $command
-
-$command
-result=$?
-
-echo "***********************************"
-echo "***** $result *********************"
-echo "***********************************"
-
-exit $result
-
-
diff --git a/asdctool/src/main/resources/scripts/dataMigration1610.sh b/asdctool/src/main/resources/scripts/dataMigration1610.sh
deleted file mode 100644
index 45d61adeee..0000000000
--- a/asdctool/src/main/resources/scripts/dataMigration1610.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-
-##############################
-# Data Migration 1610
-##############################
-
-CURRENT_DIR=`pwd`
-BASEDIR=$(dirname $0)
-
-if [ ${BASEDIR:0:1} = "/" ]
-then
- FULL_PATH=$BASEDIR
-else
- FULL_PATH=$CURRENT_DIR/$BASEDIR
-fi
-
-source ${FULL_PATH}/baseOperation.sh
-
-mainClass="org.openecomp.sdc.asdctool.main.MigrationMenu"
-
-command="java $JVM_LOG_FILE -cp $JARS $mainClass fix-properties $@"
-echo $command
-
-$command
-result=$?
-
-if [ $result -eq 0 ]
-then
- command="java $JVM_LOG_FILE -cp $JARS $mainClass align-tosca-artifacts $@"
- echo $command
- $command
- result=$?
-fi
-
-echo "***********************************"
-echo "***** $result *********************"
-echo "***********************************"
-
-exit $result
-
-
diff --git a/asdctool/src/main/resources/scripts/dataMigration1702.sh b/asdctool/src/main/resources/scripts/dataMigration1702.sh
deleted file mode 100644
index f2bf56e4ef..0000000000
--- a/asdctool/src/main/resources/scripts/dataMigration1702.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-
-##############################
-# Data Migration 1702
-##############################
-
-CURRENT_DIR=`pwd`
-BASEDIR=$(dirname $0)
-
-if [ ${BASEDIR:0:1} = "/" ]
-then
- FULL_PATH=$BASEDIR
-else
- FULL_PATH=$CURRENT_DIR/$BASEDIR
-fi
-
-source ${FULL_PATH}/baseOperation.sh
-
-mainClass="org.openecomp.sdc.asdctool.main.MigrationMenu"
-
-command="java $JVM_LOG_FILE -cp $JARS $mainClass migrate-1610-1702 $@"
-echo $command
-
-$command
-result=$?
-
-
-
-echo "***********************************"
-echo "***** $result *********************"
-echo "***********************************"
-
-exit $result
-
-
diff --git a/asdctool/src/main/resources/scripts/dataMigration1707.sh b/asdctool/src/main/resources/scripts/dataMigration1707.sh
deleted file mode 100644
index 11a151a7c3..0000000000
--- a/asdctool/src/main/resources/scripts/dataMigration1707.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-
-##############################
-# Data Migration 1707
-##############################
-
-CURRENT_DIR=`pwd`
-BASEDIR=$(dirname $0)
-
-if [ ${BASEDIR:0:1} = "/" ]
-then
- FULL_PATH=$BASEDIR
-else
- FULL_PATH=$CURRENT_DIR/$BASEDIR
-fi
-
-source ${FULL_PATH}/baseOperation.sh
-
-mainClass="org.openecomp.sdc.asdctool.main.MigrationMenu"
-
-command="java $JVM_LOG_FILE -Xmx6000M -cp $JARS $mainClass migrate-1702-1707 $@"
-echo $command
-
-$command
-result=$?
-
-
-
-echo "***********************************"
-echo "***** $result *********************"
-echo "***********************************"
-
-exit $result
-
-
diff --git a/asdctool/src/main/resources/scripts/validationTool.sh b/asdctool/src/main/resources/scripts/validationTool.sh
index 23eaeb8da7..58cd7f3f6a 100644
--- a/asdctool/src/main/resources/scripts/validationTool.sh
+++ b/asdctool/src/main/resources/scripts/validationTool.sh
@@ -18,7 +18,8 @@ source ${FULL_PATH}/baseOperation.sh
mainClass="org.openecomp.sdc.asdctool.main.ValidationTool"
-command="java $JVM_LOG_FILE -cp $JARS $mainClass reportOutput.txt /home/vagrant/catalog-be/config/catalog-be/"
+#command="java $JVM_LOG_FILE -cp $JARS $mainClass reportOutput.txt /home/vagrant/catalog-be/config/catalog-be/"
+command="java $JVM_LOG_FILE -cp $JARS $mainClass . /apps/jetty/base/be/config/catalog-be/"
echo $command
$command
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
index e4c75eab05..902bc8a298 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
@@ -1526,7 +1526,14 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
handleAuditing(auditingAction, parent, componentId, user, null, null, artifactId, responseFormat, componentType, null);
return Either.right(responseFormat);
}
- Either<ArtifactDefinition, Operation> insideEither = Either.left(artifactDefinition);
+ if(artifactDefinition.getPayloadData() == null) {
+ log.debug("Empty payload data returned from DB by artifat id {}", artifactId);
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, artifactId);
+ handleAuditing(auditingAction, parent, componentId, user, null, null, artifactId, responseFormat, componentType, null);
+ return Either.right(responseFormat);
+
+ }
+ Either<ArtifactDefinition, Operation> insideEither = Either.left(artifactDefinition);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.OK);
handleAuditing(auditingAction, parent, componentId, user, artifactDefinition, null, artifactId, responseFormat, componentType, null);
return Either.left(insideEither);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index 5b6488d788..6dc83bfc2b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -401,6 +401,15 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(result)));
}
componentInstance.setDeploymentArtifacts(finalDeploymentArtifacts);
+
+
+ artStatus = toscaOperationFacade.addInformationalArtifactsToInstance(containerComponent.getUniqueId(), componentInstance, originComponent.getArtifacts());
+ if ( artStatus != StorageOperationStatus.OK){
+ log.debug("Failed to add informational artifacts to the instance {} belonging to the conatiner {}. Status is {}", componentInstance.getUniqueId(), containerComponent.getUniqueId(), artStatus);
+ return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponseForResourceInstance(artStatus, false)));
+
+ }
+ componentInstance.setArtifacts(originComponent.getArtifacts());
return Either.left(ActionStatus.OK);
}
@@ -1828,23 +1837,23 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
return result;
}
+
+ public Either<ComponentInstance, ResponseFormat> deleteServiceProxy(String containerComponentType, String containerComponentId, String serviceProxyId, String userId) {
+ // TODO Add implementation
+ Either<ComponentInstance, ResponseFormat> result = Either.left(new ComponentInstance());
+ return result;
+ }
- private Boolean validateInstanceNameUniqueness(Component containerComponent, ComponentInstance oldComponentInstance, String newInstanceName) {
- Boolean isUnique = true;
- String newInstanceNormalizedName = ValidationUtils.normalizeComponentInstanceName(newInstanceName);
- if (!oldComponentInstance.getNormalizedName().equals(newInstanceNormalizedName)) {
- Optional<ComponentInstance> foundComponentInstance = containerComponent.getComponentInstances().stream().filter(ci -> ci.getNormalizedName().equals(newInstanceNormalizedName)).findFirst();
- if (foundComponentInstance.isPresent()) {
- isUnique = false;
- }
- if (isUnique) {
- foundComponentInstance = containerComponent.getComponentInstances().stream().filter(ci -> ci.getUniqueId().endsWith(newInstanceNormalizedName)).findFirst();
- if (foundComponentInstance.isPresent()) {
- isUnique = false;
- }
- }
- }
- return isUnique;
+ public Either<ComponentInstance, ResponseFormat> createServiceProxy(String containerComponentType, String containerComponentId, String userId, ComponentInstance componentInstance) {
+ // TODO Add implementation
+ Either<ComponentInstance, ResponseFormat> result = Either.left(new ComponentInstance());
+ return result;
+ }
+
+ public Either<ComponentInstance, ResponseFormat> changeServiceProxyVersion(String containerComponentType, String containerComponentId, String serviceProxyId, String userId) {
+ // TODO Add implementation
+ Either<ComponentInstance, ResponseFormat> result = Either.left(new ComponentInstance());
+ return result;
}
private Boolean validateInstanceNameUniquenessUponUpdate(Component containerComponent, ComponentInstance oldComponentInstance, String newInstanceName) {
@@ -1889,12 +1898,11 @@ public abstract class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
resourceInstanceForUpdate.setCustomizationUUID(origInstanceForUpdate.getCustomizationUUID());
- if (StringUtils.isEmpty(resourceInstanceForUpdate.getName())) {
+ if (StringUtils.isEmpty(resourceInstanceForUpdate.getName()) && StringUtils.isNotEmpty(origInstanceForUpdate.getName())) {
resourceInstanceForUpdate.setName(origInstanceForUpdate.getName());
-
}
- if (StringUtils.isEmpty(resourceInstanceForUpdate.getNormalizedName()))
- resourceInstanceForUpdate.setNormalizedName(origInstanceForUpdate.getNormalizedName());
+
+ resourceInstanceForUpdate.setNormalizedName(ValidationUtils.normalizeComponentInstanceName(resourceInstanceForUpdate.getName()));
if (StringUtils.isEmpty(resourceInstanceForUpdate.getIcon()))
resourceInstanceForUpdate.setIcon(origInstanceForUpdate.getIcon());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
index 838cd53458..1755d0b20c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
@@ -21,12 +21,7 @@
package org.openecomp.sdc.be.components.impl;
import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -61,22 +56,55 @@ public final class ImportUtils {
private ImportUtils() {
}
- public static Yaml STRICT_MAPPING_YAML_LOADER = new YamlLoader().getStrictYamlLoader();
private static CustomResolver customResolver = new CustomResolver();
+ private static Yaml STRICT_MAPPING_YAML_LOADER = new YamlLoader().getStrictYamlLoader();
private static class CustomResolver extends Resolver {
- @Override
+ @Override
protected void addImplicitResolvers() {
- // avoid implicit resolvers for strings that can be interpreted as boolean values
- addImplicitResolver(Tag.STR, EMPTY, "");
- addImplicitResolver(Tag.STR, NULL, null);
- addImplicitResolver(Tag.NULL, NULL, "~nN\0");
- addImplicitResolver(Tag.NULL, EMPTY, null);
- addImplicitResolver(Tag.YAML, YAML, "!&*");
+ // avoid implicit resolvers for strings that can be interpreted as boolean values
+ addImplicitResolver(Tag.STR, EMPTY, "");
+ addImplicitResolver(Tag.STR, NULL, null);
+ addImplicitResolver(Tag.NULL, NULL, "~nN\0");
+ addImplicitResolver(Tag.NULL, EMPTY, null);
+ addImplicitResolver(Tag.INT, INT, "-+0123456789");
+ addImplicitResolver(Tag.FLOAT, FLOAT, "-+0123456789.");
+ addImplicitResolver(Tag.YAML, YAML, "!&*");
}
}
-
+
+
+ private static void buildMap(Map<String, Object> output, Map<String, Object> map) {
+ for (Entry<String, Object> entry : map.entrySet()) {
+ String key = entry.getKey();
+ Object value = entry.getValue();
+ if (value instanceof Map) {
+ Map<String, Object> result = new LinkedHashMap<>();
+ buildMap(result, (Map) value);
+ output.put(key, result);
+ }
+ else if (value instanceof Collection) {
+ Map<String, Object> result = new LinkedHashMap<>();
+ int i = 0;
+ for(Object item : (Collection<Object>) value) {
+ buildMap(result, Collections.singletonMap("[" + (i++) + "]", item));
+ }
+ output.put(key, new ArrayList<>(result.values()));
+ }
+ else {
+ output.put(key, value);
+ }
+ }
+ }
+
+ public static Map<String, Object> loadYamlAsStrictMap(String content){
+ Map<String, Object> result = new LinkedHashMap<>();
+ Object map = STRICT_MAPPING_YAML_LOADER.load(content);
+ buildMap(result, (Map<String, Object>)map);
+ return result;
+ }
+
private static class YamlLoader extends YamlProcessor {
public Yaml getStrictYamlLoader() {
return createYaml();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index f85e25e5fb..892da8af9d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -1274,6 +1274,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
input.setName(inputName + "_" + prop.getName());
}
+ input.setDefaultValue(prop.getValue());
input.setName(inputName);
input.setUniqueId(UniqueIdBuilder.buildPropertyUniqueId(component.getUniqueId(), input.getName()));
input.setInputPath(propertiesName);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 0aa4a6f006..a8d841387b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -154,6 +154,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import fj.data.Either;
+import org.yaml.snakeyaml.parser.ParserException;
@org.springframework.stereotype.Component("resourceBusinessLogic")
public class ResourceBusinessLogic extends ComponentBusinessLogic {
@@ -686,7 +687,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return result;
}
-
private Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandle(Map<String, NodeTypeInfo> nodeTypesInfo, Map<String, byte[]> csar, String csarUUID, String yamlFileName, Resource oldResource, User user) {
Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = CsarUtils.extractVfcsArtifactsFromCsar(csar);
@@ -695,8 +695,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
try {
nodeTypesArtifactsToHandleRes = Either.left(nodeTypesArtifactsToHandle);
- Map<String, String> extractedVfcToscaNames = extractVfcToscaNames(nodeTypesInfo, yamlFileName, oldResource.getSystemName());
- Either<EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>, ResponseFormat> curNodeTypeArtifactsToHandleRes = null;
+ Map<String, String> extractedVfcToscaNames = extractVfcToscaNames(nodeTypesInfo, yamlFileName, oldResource.getName());
+ Either<EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>, ResponseFormat> curNodeTypeArtifactsToHandleRes;
EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>> curNodeTypeArtifactsToHandle = null;
log.debug("Going to fetch node types for resource with name {} during import csar with UUID {}. ", oldResource.getName(), csarUUID);
@@ -3348,7 +3348,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resStatus = Either.right(responseFormat);
return resStatus;
}
- currHeatParam.setCurrentValue(HeatParameterType.isValidType(currHeatParam.getType()).getConverter().convert(updatedParamValue, null, null));
+ currHeatParam.setCurrentValue(paramType.getConverter().convert(updatedParamValue, null, null));
// newHeatEnvParams.add(currHeatParam);
break;
}
@@ -3558,6 +3558,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>();
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties = new HashMap<>();
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
+ Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
Map<String, List<PropertyDefinition>> instAttributes = new HashMap<>();
Map<String, Resource> originCompMap = new HashMap<>();
@@ -3629,7 +3630,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
instRequirements.put(currentCompInstance, originRequirements);
}
if (originResource.getDeploymentArtifacts() != null && !originResource.getDeploymentArtifacts().isEmpty())
- instArtifacts.put(resourceInstanceId, originResource.getDeploymentArtifacts());
+ instDeploymentArtifacts.put(resourceInstanceId, originResource.getDeploymentArtifacts());
+ if (originResource.getArtifacts() != null && !originResource.getArtifacts().isEmpty())
+ instArtifacts.put(resourceInstanceId, originResource.getArtifacts());
if (originResource.getAttributes() != null && !originResource.getAttributes().isEmpty())
instAttributes.put(resourceInstanceId, originResource.getAttributes());
if (originResource.getResourceType() != ResourceTypeEnum.CVFC) {
@@ -3667,7 +3670,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.right(responseFormat);
}
}
- StorageOperationStatus addArtToInst = toscaOperationFacade.associateArtifactToInstances(instArtifacts, resource.getUniqueId(), user);
+ StorageOperationStatus addArtToInst = toscaOperationFacade.associateDeploymentArtifactsToInstances(instDeploymentArtifacts, resource.getUniqueId(), user);
+ if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
+ log.debug("failed to associate artifact of resource {} status is {}", resource.getUniqueId(), addArtToInst);
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName);
+ return Either.right(responseFormat);
+ }
+
+ addArtToInst = toscaOperationFacade.associateArtifactsToInstances(instArtifacts, resource.getUniqueId(), user);
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate artifact of resource {} status is {}", resource.getUniqueId(), addArtToInst);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName);
@@ -4212,7 +4222,15 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
mappedToscaTemplate = nodeTypesInfo.get(nodeName).getMappedToscaTemplate();
}
else {
- mappedToscaTemplate = (Map<String, Object>) new Yaml().load(resourceYml);
+ try {
+ //DE154502 Fail if duplicate key found in file
+ mappedToscaTemplate = ImportUtils.loadYamlAsStrictMap(resourceYml);
+
+ } catch(ParserException e) {
+ log.error("Failed to load yaml file {}", yamlFileName, e);
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.TOSCA_PARSE_ERROR, yamlFileName, e.getMessage());
+ return Either.right(responseFormat);
+ }
}
Either<Object, ResultStatusEnum> toscaElementEither = ImportUtils.findToscaElement(mappedToscaTemplate, ToscaTagNamesEnum.TOPOLOGY_TEMPLATE, ToscaElementTypeEnum.ALL);
if (toscaElementEither.isRight()) {
@@ -5573,10 +5591,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
// IResourceOperation dataModel = getResourceOperation();
Either<Resource, StorageOperationStatus> storageStatus = toscaOperationFacade.getToscaElement(resourceId);
-
if (storageStatus.isRight()) {
log.debug("failed to get resource by id {}", resourceId);
- return Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageStatus.right().value()), ""));
+ return Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageStatus.right().value()), resourceId));
+ }
+ if(!(storageStatus.left().value() instanceof Resource)){
+ return Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND), resourceId));
}
return Either.left(storageStatus.left().value());
@@ -6807,14 +6827,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
try {
if (groupTemplateJson != null && groupTemplateJson instanceof Map) {
Map<String, Object> groupTemplateJsonMap = (Map<String, Object>) groupTemplateJson;
- // Type
- String groupType = null;
- if (groupTemplateJsonMap.containsKey(ToscaTagNamesEnum.TYPE.getElementName())) {
- groupType = (String) groupTemplateJsonMap.get(ToscaTagNamesEnum.TYPE.getElementName());
+ String groupType = (String) groupTemplateJsonMap.get(ToscaTagNamesEnum.TYPE.getElementName());
+ if (!StringUtils.isEmpty(groupType)) {
groupInfo.setType(groupType);
} else {
log.debug("The 'type' member is not found under group {}", groupName);
- result = Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE));
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_MISSING_GROUP_TYPE, groupName));
}
if (groupTemplateJsonMap.containsKey(ToscaTagNamesEnum.DESCRIPTION.getElementName())) {
@@ -6832,8 +6850,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
groupInfo.setMembers(membersLoaded);
} else {
- log.debug("The 'type' member is not found under group {}", groupName);
- result = Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE));
+ log.debug("The 'members' member is not of type list under group {}", groupName);
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE));
}
}
}
@@ -6873,7 +6891,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Either<GroupTypeDefinition, StorageOperationStatus> groupTypeRes = groupTypeOperation.getLatestGroupTypeByType(groupType, true);
if (groupTypeRes.isRight()) {
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_MISSING_GROUP_TYPE, groupType));
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_TYPE_IS_INVALID, groupType));
}
Map<String, PropertyDefinition> gtProperties = new HashMap<>();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index ae7ae31ed9..85db9a2c0f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -1144,17 +1144,22 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (eitherCreator.isRight()) {
return Either.right(eitherCreator.right().value());
}
- user = eitherCreator.left().value();
Either<Service, StorageOperationStatus> storageStatus = toscaOperationFacade.getToscaElement(serviceId);
if (storageStatus.isRight()) {
log.debug("failed to get service by id {}", serviceId);
return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(storageStatus.right().value(), ComponentTypeEnum.SERVICE), serviceId));
}
- // Service service =
- // createServiceApiArtifactLIst(storageStatus.left().value());
+
+ if(!(storageStatus.left().value() instanceof Service)){
+ return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND), serviceId));
+ }
Service service = storageStatus.left().value();
return Either.left(service);
+
+
+
+
}
public Either<Service, ResponseFormat> getServiceByNameAndVersion(String serviceName, String serviceVersion, String userId) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.java b/catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.java
index 34a56cdd13..6be300d6db 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.java
@@ -74,7 +74,8 @@ public class EsGateway extends ProxyServlet {
esPort = monitoringBL.getEsPort();
}
- String scheme = request.getScheme();
+ //String scheme = request.getScheme(); esGateway HTTP
+ String scheme = "http";
String contextPath = request.getContextPath(); // /mywebapp
String servletPath = request.getServletPath(); // /servlet/MyServlet
String pathInfo = request.getPathInfo(); // /a/b;c=123
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java
index d7db4ec3a3..a89d8b109b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java
@@ -880,6 +880,120 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet {
}
+ @POST
+ @Path("/{containerComponentType}/{containerComponentId}/serviceProxy")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Create service proxy", httpMethod = "POST", notes = "Returns created service proxy", response = Response.class)
+ @ApiResponses(value = { @ApiResponse(code = 201, message = "Service proxy created"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 400, message = "Invalid content / Missing content"),
+ @ApiResponse(code = 409, message = "Service proxy already exist") })
+ public Response createServiceProxy(@ApiParam(value = "RI object to be created", required = true) String data, @PathParam("containerComponentId") final String containerComponentId,
+ @ApiParam(value = "valid values: resources / services", allowableValues = ComponentTypeEnum.RESOURCE_PARAM_NAME + "," + ComponentTypeEnum.SERVICE_PARAM_NAME) @PathParam("containerComponentType") final String containerComponentType,
+ @HeaderParam(value = Constants.USER_ID_HEADER) @ApiParam(value = "USER_ID of modifier user", required = true) String userId, @Context final HttpServletRequest request) {
+ ServletContext context = request.getSession().getServletContext();
+
+ try {
+
+ ComponentInstance componentInstance = RepresentationUtils.fromRepresentation(data, ComponentInstance.class);
+ componentInstance.setInvariantName(null);
+ ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
+ if(componentTypeEnum != ComponentTypeEnum.SERVICE){
+ log.debug("Unsupported container component type {}", containerComponentType);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
+ }
+ ComponentInstanceBusinessLogic componentInstanceLogic = getComponentInstanceBL(context, componentTypeEnum);
+ if (componentInstanceLogic == null) {
+ log.debug("Unsupported component type {}", containerComponentType);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
+ }
+ Either<ComponentInstance, ResponseFormat> actionResponse = componentInstanceLogic.createServiceProxy(containerComponentType, containerComponentId, userId, componentInstance);
+
+ if (actionResponse.isRight()) {
+ return buildErrorResponse(actionResponse.right().value());
+ }
+ return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.CREATED), actionResponse.left().value());
+
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Create service proxy");
+ log.debug("Create service proxy failed with exception", e);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
+ }
+ }
+
+ @DELETE
+ @Path("/{containerComponentType}/{containerComponentId}/serviceProxy/{serviceProxyId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Delete service proxy", httpMethod = "DELETE", notes = "Returns delete service proxy", response = Response.class)
+ @ApiResponses(value = { @ApiResponse(code = 201, message = "Service proxy deleted"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 400, message = "Invalid content / Missing content") })
+ public Response deleteServiceProxy(@PathParam("containerComponentId") final String containerComponentId, @PathParam("serviceProxyId") final String serviceProxyId,
+ @ApiParam(value = "valid values: resources / services / products", allowableValues = ComponentTypeEnum.RESOURCE_PARAM_NAME + "," + ComponentTypeEnum.SERVICE_PARAM_NAME + ","
+ + ComponentTypeEnum.PRODUCT_PARAM_NAME) @PathParam("containerComponentType") final String containerComponentType,
+ @Context final HttpServletRequest request) {
+ ServletContext context = request.getSession().getServletContext();
+ String url = request.getMethod() + " " + request.getRequestURI();
+ Response response = null;
+ try {
+ log.debug("Start handle request of {}", url);
+ ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
+ ComponentInstanceBusinessLogic componentInstanceLogic = getComponentInstanceBL(context, componentTypeEnum);
+ if (componentInstanceLogic == null) {
+ log.debug("Unsupported component type {}", containerComponentType);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
+ }
+ String userId = request.getHeader(Constants.USER_ID_HEADER);
+ Either<ComponentInstance, ResponseFormat> actionResponse = componentInstanceLogic.deleteServiceProxy(containerComponentType, containerComponentId, serviceProxyId, userId);
+
+ if (actionResponse.isRight()) {
+ response = buildErrorResponse(actionResponse.right().value());
+ } else {
+ response = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.NO_CONTENT), null);
+ }
+ return response;
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Delete service proxy");
+ log.debug("Delete service proxy failed with exception", e);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
+ }
+ }
+
+ @POST
+ @Path("/{containerComponentType}/{containerComponentId}/serviceProxy/{serviceProxyId}/changeVersion/{newServiceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Update service proxy with new version", httpMethod = "POST", notes = "Returns updated service proxy", response = Response.class)
+ @ApiResponses(value = { @ApiResponse(code = 201, message = "Service proxy created"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 400, message = "Invalid content / Missing content") })
+ public Response changeServiceProxyVersion(@PathParam("containerComponentId") final String containerComponentId, @PathParam("serviceProxyId") final String serviceProxyId,
+ @ApiParam(value = "valid values: resources / services", allowableValues = ComponentTypeEnum.RESOURCE_PARAM_NAME + "," + ComponentTypeEnum.SERVICE_PARAM_NAME) @PathParam("containerComponentType") final String containerComponentType,
+ @Context final HttpServletRequest request) {
+ ServletContext context = request.getSession().getServletContext();
+
+ String url = request.getMethod() + " " + request.getRequestURI();
+ log.debug("Start handle request of {}", url);
+ try {
+
+ String userId = request.getHeader(Constants.USER_ID_HEADER);
+
+ ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
+ ComponentInstanceBusinessLogic componentInstanceLogic = getComponentInstanceBL(context, componentTypeEnum);
+ if (componentInstanceLogic == null) {
+ log.debug("Unsupported component type {}", containerComponentType);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
+ }
+ Either<ComponentInstance, ResponseFormat> actionResponse = componentInstanceLogic.changeServiceProxyVersion(containerComponentType, containerComponentId, serviceProxyId, userId);
+
+ if (actionResponse.isRight()) {
+ return buildErrorResponse(actionResponse.right().value());
+ }
+ return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), actionResponse.left().value());
+
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Update service proxy with new version");
+ log.debug("Update service proxy with new version failed with exception", e);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
+ }
+ }
+
private Either<ComponentInstance, ResponseFormat> convertToResourceInstance(String data) {
// Either<ComponentInstance, ActionStatus> convertStatus =
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
index 22943bccea..2e961f294b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.be.servlets;
+import java.lang.reflect.Type;
import java.util.Map;
import javax.inject.Singleton;
@@ -39,7 +40,9 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintSerialiser;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.config.EcompErrorName;
import org.openecomp.sdc.common.datastructure.Wrapper;
@@ -48,6 +51,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
import com.jcabi.aspects.Loggable;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -95,9 +101,12 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
// return buildErrorResponse(allDataTypes.right().value());
} else {
+
Map<String, DataTypeDefinition> dataTypes = allDataTypes.left().value();
- Response okResponse = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), dataTypes);
+ String dataTypeJson = gson.toJson(dataTypes);
+ Response okResponse = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), dataTypeJson);
responseWrapper.setInnerElement(okResponse);
+
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java
index 3fd5297439..6c4c5fafe1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabiltyRequirementConvertor.java
@@ -122,7 +122,7 @@ public class CapabiltyRequirementConvertor {
if (prop.getSchema() != null && prop.getSchema().getProperty() != null) {
innerType = prop.getSchema().getProperty().getType();
}
- Object convertedValue = PropertyConvertor.getInstance().convertToToscaObject(propertyType, prop.getName(), prop.getValue(), innerType, dataTypes);
+ Object convertedValue = PropertyConvertor.getInstance().convertToToscaObject(propertyType, prop.getValue(), innerType, dataTypes);
return convertedValue;
}
@@ -183,9 +183,19 @@ public class CapabiltyRequirementConvertor {
if (requirements != null) {
for (Map.Entry<String, List<RequirementDefinition>> entry : requirements.entrySet()) {
entry.getValue().stream().forEach(r -> {
- String fullReqName = getRequirementPath(r);
+ String fullReqName;
+ String sourceCapName;
+ if(ToscaUtils.isComplexVfc(component)){
+ fullReqName = r.getName();
+ sourceCapName = getSourceCvfcDataTypeName(r.getName(), r.getOwnerName());
+ } else {
+ fullReqName = getRequirementPath(r);
+ sourceCapName = getSubPathByFirstDelimiterAppearance(fullReqName);
+ }
log.debug("the requirement {} belongs to resource {} ", fullReqName, component.getUniqueId());
- toscaRequirements.put(fullReqName, new String[]{r.getOwnerName(), getSubPathByFirstDelimiterAppearance(fullReqName)});
+ if(sourceCapName!= null){
+ toscaRequirements.put(fullReqName, new String[]{r.getOwnerName(), sourceCapName});
+ }
});
log.debug("Finish convert Requirements for node type");
}
@@ -195,6 +205,13 @@ public class CapabiltyRequirementConvertor {
return toscaRequirements;
}
+ private String getSourceCvfcDataTypeName(String name, String ownerName) {
+ if(name.contains(ownerName)){
+ return name.substring(0, name.length() - ownerName.length() - 1);
+ }
+ return null;
+ }
+
private String getRequirementPath(RequirementDefinition r) {
List<String> pathArray = Lists.reverse(r.getPath().stream()
.map(path -> ValidationUtils.normalizeComponentInstanceName(getSubPathByLastDelimiterAppearance(path)))
@@ -254,9 +271,19 @@ public class CapabiltyRequirementConvertor {
if (capabilities != null) {
for (Map.Entry<String, List<CapabilityDefinition>> entry : capabilities.entrySet()) {
entry.getValue().stream().forEach(c -> {
- String fullCapName = getCapabilityPath(c);
+ String fullCapName;
+ String sourceReqName;
+ if(ToscaUtils.isComplexVfc(component)){
+ fullCapName = c.getName();
+ sourceReqName = getSourceCvfcDataTypeName(c.getName(), c.getOwnerName());
+ } else {
+ fullCapName = getCapabilityPath(c);
+ sourceReqName = getSubPathByFirstDelimiterAppearance(fullCapName);
+ }
log.debug("the capabilty {} belongs to resource {} ", fullCapName, component.getUniqueId());
- toscaCapabilities.put(fullCapName, new String[]{c.getOwnerName(), getSubPathByFirstDelimiterAppearance(fullCapName)});
+ if(sourceReqName!= null){
+ toscaCapabilities.put(fullCapName, new String[]{c.getOwnerName(), sourceReqName});
+ }
});
}
} else {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
index b8414367aa..646a7ecc8b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
@@ -20,12 +20,11 @@
package org.openecomp.sdc.be.tosca;
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import com.google.gson.stream.JsonReader;
+import fj.data.Either;
import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.model.Component;
@@ -33,6 +32,7 @@ import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
+import org.openecomp.sdc.be.model.tosca.converters.DataTypePropertyConverter;
import org.openecomp.sdc.be.model.tosca.converters.ToscaMapValueConverter;
import org.openecomp.sdc.be.model.tosca.converters.ToscaValueConverter;
import org.openecomp.sdc.be.tosca.model.EntrySchema;
@@ -41,14 +41,10 @@ import org.openecomp.sdc.be.tosca.model.ToscaProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonSyntaxException;
-import com.google.gson.stream.JsonReader;
-
-import fj.data.Either;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class PropertyConvertor {
private static PropertyConvertor instance;
@@ -101,7 +97,7 @@ public class PropertyConvertor {
prop.setEntry_schema(eschema);
}
log.trace("try to convert property {} from type {} with default value [{}]", property.getName(), property.getType(), property.getDefaultValue());
- prop.setDefaultp(convertToToscaObject(property.getType(), property.getName(), property.getDefaultValue(), innerType, dataTypes));
+ prop.setDefaultp(convertToToscaObject(property.getType(), property.getDefaultValue(), innerType, dataTypes));
prop.setType(property.getType());
prop.setDescription(property.getDescription());
if (isCapabiltyProperty) {
@@ -111,10 +107,10 @@ public class PropertyConvertor {
return prop;
}
- public Object convertToToscaObject(String propertyType, String propertyName, String value, String innerType, Map<String, DataTypeDefinition> dataTypes) {
+ public Object convertToToscaObject(String propertyType, String value, String innerType, Map<String, DataTypeDefinition> dataTypes) {
log.trace("try to convert propertyType {} , value [{}], innerType {}", propertyType, value, innerType);
- if (value == null) {
- value = getDataTypeDefaultValue(propertyName, dataTypes.get(propertyType));
+ if (StringUtils.isEmpty(value)) {
+ value = DataTypePropertyConverter.getInstance().getDataTypePropertiesDefaultValuesRec(propertyType, dataTypes);
if(StringUtils.isEmpty(value)){
return null;
}
@@ -193,35 +189,4 @@ public class PropertyConvertor {
}
- private String getDataTypeDefaultValue(String propertyName, DataTypeDefinition dataTypeDefinition) {
-
- String delaultValue = null;
- JsonObject asJsonObjectIn = new JsonObject();
- Map<String, PropertyDefinition> allParentsProps = new HashMap<>();
- while (dataTypeDefinition != null) {
-
- List<PropertyDefinition> currentParentsProps = dataTypeDefinition.getProperties();
- if (currentParentsProps != null) {
- currentParentsProps.stream().forEach(p -> allParentsProps.put(p.getName(), p));
- }
-
- dataTypeDefinition = dataTypeDefinition.getDerivedFrom();
- }
- for (Entry<String, PropertyDefinition> entry : allParentsProps.entrySet()) {
- String propName = entry.getKey();
- PropertyDefinition propertyDefinition = entry.getValue();
- JsonElement elementValue = asJsonObjectIn.get(propName);
- if(elementValue == null && propertyDefinition.getDefaultValue() != null){
- JsonReader jsonReader = new JsonReader(new StringReader(propertyDefinition.getDefaultValue()));
- jsonReader.setLenient(true);
- elementValue = jsonParser.parse(jsonReader);
- asJsonObjectIn.add(propName, elementValue);
- }
- }
- if(!asJsonObjectIn.isJsonNull()){
- delaultValue = gson.toJson(asJsonObjectIn);
- }
- return delaultValue;
- }
-
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index f802d0f412..8e0c312f1a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -634,7 +634,8 @@ public class ToscaExportHandler {
List<ComponentInstanceInput> instanceInputsList = componentInstancesInputs.get(instanceUniqueId);
if (instanceInputsList != null) {
instanceInputsList.forEach(input -> {
- Supplier<String> supplier = () -> input.getValue();
+
+ Supplier<String> supplier = () -> input.getValue() != null && !input.getValue().isEmpty()? input.getValue(): input.getDefaultValue();
convertAndAddValue(dataTypes, componentInstance, props, input, supplier);
});
}
@@ -695,7 +696,7 @@ public class ToscaExportHandler {
if (input.getSchema() != null && input.getSchema().getProperty() != null) {
innerType = input.getSchema().getProperty().getType();
}
- return propertyConvertor.convertToToscaObject(propertyType, input.getName(), supplier.get(), innerType, dataTypes);
+ return propertyConvertor.convertToToscaObject(propertyType, supplier.get(), innerType, dataTypes);
}
private ToscaGroupTemplate convertGroup(GroupDefinition group) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java
index dce3b3bbc0..24586d9ea0 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaUtils.java
@@ -44,6 +44,16 @@ public class ToscaUtils {
}
return false;
}
+
+ public static boolean isComplexVfc(Component component) {
+ if (ComponentTypeEnum.RESOURCE == component.getComponentType()) {
+ ResourceTypeEnum resourceType = ((ResourceMetadataDataDefinition) component.getComponentMetadataDefinition().getMetadataDataDefinition()).getResourceType();
+ if (ResourceTypeEnum.CVFC == resourceType) {
+ return true;
+ }
+ }
+ return false;
+ }
public static Map<String, Object> objectToMap(Object objectToConvert, Class clazz) throws IllegalArgumentException, IllegalAccessException {
Map<String, Object> map = new HashMap<>();
diff --git a/catalog-be/src/main/webapp/WEB-INF/web.xml b/catalog-be/src/main/webapp/WEB-INF/web.xml
index 889b1fac60..16c6fd6756 100644
--- a/catalog-be/src/main/webapp/WEB-INF/web.xml
+++ b/catalog-be/src/main/webapp/WEB-INF/web.xml
@@ -158,7 +158,7 @@
<url-pattern>/lbClassicStatus</url-pattern>
</servlet-mapping>
- <filter>
+<!-- <filter>
<filter-name>GzipFilter</filter-name>
<filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
<async-supported>true</async-supported>
@@ -175,7 +175,7 @@
<filter-name>GzipFilter</filter-name>
<url-pattern>/sdc2/rest/*</url-pattern>
</filter-mapping>
-
+-->
<context-param>
<param-name>contextConfigLocation</param-name>
@@ -190,9 +190,6 @@
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
-
-
-
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java
index d7b0800e03..e1a3265c6a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java
@@ -149,6 +149,7 @@ public class ResourceInstanceBusinessLogicTest {
StorageOperationStatus status = StorageOperationStatus.OK;
Mockito.when(toscaOperationFacade.addDeploymentArtifactsToInstance(Mockito.any(String.class), Mockito.any(ComponentInstance.class), Mockito.any(Map.class))).thenReturn(status);
+ Mockito.when(toscaOperationFacade.addInformationalArtifactsToInstance(Mockito.any(String.class), Mockito.any(ComponentInstance.class), Mockito.any(Map.class))).thenReturn(status);
Mockito.when(toscaOperationFacade.addGroupInstancesToComponentInstance(Mockito.any(Component.class), Mockito.any(ComponentInstance.class), Mockito.any(List.class), Mockito.any(Map.class))).thenReturn(status);
}
diff --git a/catalog-fe/src/main/webapp/WEB-INF/web.xml b/catalog-fe/src/main/webapp/WEB-INF/web.xml
index 725c041c51..b217cc0bf4 100644
--- a/catalog-fe/src/main/webapp/WEB-INF/web.xml
+++ b/catalog-fe/src/main/webapp/WEB-INF/web.xml
@@ -80,7 +80,7 @@
</servlet-mapping>
- <filter>
+<!-- <filter>
<filter-name>GzipFilter</filter-name>
<filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
<async-supported>true</async-supported>
@@ -103,14 +103,12 @@
<filter-name>GzipFilter</filter-name>
<url-pattern>/sdc1/*</url-pattern>
</filter-mapping>
-
-
-
+ -->
+
<filter>
<filter-name>gzipFilter</filter-name>
<filter-class>org.openecomp.sdc.fe.GzipFilter</filter-class>
</filter>
-
<filter-mapping>
<filter-name>gzipFilter</filter-name>
<url-pattern>*.jsgz</url-pattern>
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java
index 0b60a07a28..1726c397ad 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java
@@ -53,8 +53,6 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElementTypeEnum;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -1189,13 +1187,8 @@ public abstract class BaseOperation {
}
if (result == null) {
toscaDataVertex = toscaDataVertexRes.left().value();
- existingToscaDataMap = (Map<String, ToscaDataDefinition>) getDeepElements(toscaDataVertexRes.left().value(), pathKeys);
- for (String uniqueKey : uniqueKeys) {
- result = removeToscaDataElement(toscaElement, edgeLabel, uniqueKey, toscaDataVertex, existingToscaDataMap);
- if (result != StorageOperationStatus.OK) {
- break;
- }
- }
+ existingToscaDataMap = getDeepElements(toscaDataVertexRes.left().value(), pathKeys);
+ result = deleteElementsFromDataVertex(toscaElement, edgeLabel, uniqueKeys, toscaDataVertex, existingToscaDataMap);
}
if (result == null) {
result = StorageOperationStatus.OK;
@@ -1203,6 +1196,19 @@ public abstract class BaseOperation {
return result;
}
+ private StorageOperationStatus deleteElementsFromDataVertex(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, List<String> uniqueKeys, GraphVertex toscaDataVertex, Map<String, ToscaDataDefinition> existingToscaDataMap) {
+ StorageOperationStatus result;
+ for (String uniqueKey : uniqueKeys) {
+ result = removeKeyFromDataVertex(uniqueKey, existingToscaDataMap);
+ if (result != StorageOperationStatus.OK) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete tosca data element of the tosca element {} by label {}. Status is {}. ", toscaElement.getUniqueId(), edgeLabel, result);
+ break;
+ }
+ }
+ result = updateToscaDataElement(toscaElement, edgeLabel, toscaDataVertex);
+ return result;
+ }
+
/**
* Deletes tosca data element belonging to tosca element according label
*
@@ -1229,7 +1235,6 @@ public abstract class BaseOperation {
* @return
*/
public StorageOperationStatus deleteToscaDataElements(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, List<String> uniqueKeys) {
-
StorageOperationStatus result = null;
GraphVertex toscaDataVertex;
Map<String, ToscaDataDefinition> existingToscaDataMap;
@@ -1242,12 +1247,7 @@ public abstract class BaseOperation {
if (result == null) {
toscaDataVertex = toscaDataVertexRes.left().value();
existingToscaDataMap = (Map<String, ToscaDataDefinition>) toscaDataVertex.getJson();
- for (String uniqueKey : uniqueKeys) {
- result = removeToscaDataElement(toscaElement, edgeLabel, uniqueKey, toscaDataVertex, existingToscaDataMap);
- if (result != StorageOperationStatus.OK) {
- break;
- }
- }
+ result = deleteElementsFromDataVertex(toscaElement, edgeLabel, uniqueKeys, toscaDataVertex, existingToscaDataMap);
}
if (result == null) {
result = StorageOperationStatus.OK;
@@ -1255,23 +1255,24 @@ public abstract class BaseOperation {
return result;
}
- private <T extends ToscaDataDefinition> StorageOperationStatus removeToscaDataElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, String uniqueKey, GraphVertex toscaDataVertex, Map<String, T> existingToscaDataMap) {
-
+ private <T extends ToscaDataDefinition> StorageOperationStatus updateToscaDataElement(GraphVertex toscaElement, EdgeLabelEnum edgeLabel, GraphVertex toscaDataVertex) {
StorageOperationStatus result = StorageOperationStatus.OK;
- if (!existingToscaDataMap.containsKey(uniqueKey)) {
- result = StorageOperationStatus.NOT_FOUND;
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete tosca data element of the tosca element {} by label {}. Status is {}. ", toscaElement.getUniqueId(), edgeLabel, result);
- } else {
- existingToscaDataMap.remove(uniqueKey);
- Either<GraphVertex, TitanOperationStatus> updateOrCopyRes = updateOrCopyOnUpdate(toscaDataVertex, toscaElement, edgeLabel);
- if (updateOrCopyRes.isRight()) {
- result = DaoStatusConverter.convertTitanStatusToStorageStatus(updateOrCopyRes.right().value());
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update tosca data {} of the tosca element {}. Status is {}. ", edgeLabel, toscaElement.getUniqueId(), result);
- }
+ Either<GraphVertex, TitanOperationStatus> updateOrCopyRes = updateOrCopyOnUpdate(toscaDataVertex, toscaElement, edgeLabel);
+ if (updateOrCopyRes.isRight()) {
+ result = DaoStatusConverter.convertTitanStatusToStorageStatus(updateOrCopyRes.right().value());
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update tosca data {} of the tosca element {}. Status is {}. ", edgeLabel, toscaElement.getUniqueId(), result);
}
return result;
}
+ private <T extends ToscaDataDefinition> StorageOperationStatus removeKeyFromDataVertex(String uniqueKey, Map<String, T> existingToscaDataMap) {
+ if (!existingToscaDataMap.containsKey(uniqueKey)) {
+ return StorageOperationStatus.NOT_FOUND;
+ }
+ existingToscaDataMap.remove(uniqueKey);
+ return StorageOperationStatus.OK;
+ }
+
protected <K extends ToscaDataDefinition> StorageOperationStatus handleToscaData(GraphVertex toscaElement, VertexTypeEnum vertexLabel, EdgeLabelEnum edgeLabel, GraphVertex toscaDataVertex, Map<String, K> mergedToscaDataMap) {
StorageOperationStatus result = StorageOperationStatus.OK;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java
index 66d26c748f..b642410548 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java
@@ -1620,6 +1620,14 @@ public class NodeTemplateOperation extends BaseOperation {
}
public StorageOperationStatus addDeploymentArtifactsToInstance(String toscaElementId, String instanceId, Map<String, ArtifactDataDefinition> instDeplArtifacts) {
+ return addArtifactsToInstance(toscaElementId, instanceId, instDeplArtifacts, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS, VertexTypeEnum.INST_DEPLOYMENT_ARTIFACTS);
+ }
+
+ public StorageOperationStatus addInformationalArtifactsToInstance(String toscaElementId, String instanceId, Map<String, ArtifactDataDefinition> instDeplArtifacts) {
+ return addArtifactsToInstance(toscaElementId, instanceId, instDeplArtifacts, EdgeLabelEnum.INSTANCE_ARTIFACTS, VertexTypeEnum.INSTANCE_ARTIFACTS);
+ }
+
+ public StorageOperationStatus addArtifactsToInstance(String toscaElementId, String instanceId, Map<String, ArtifactDataDefinition> instDeplArtifacts, EdgeLabelEnum edgeLabel, VertexTypeEnum vertexType) {
Either<GraphVertex, TitanOperationStatus> metadataVertex = titanDao.getVertexById(toscaElementId, JsonParseFlagEnum.NoParse);
if (metadataVertex.isRight()) {
TitanOperationStatus status = metadataVertex.right().value();
@@ -1629,7 +1637,7 @@ public class NodeTemplateOperation extends BaseOperation {
return DaoStatusConverter.convertTitanStatusToStorageStatus(status);
}
MapArtifactDataDefinition instArtifacts = new MapArtifactDataDefinition(instDeplArtifacts);
- return addToscaDataDeepElementsBlockToToscaElement(metadataVertex.left().value(), EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS, VertexTypeEnum.INST_DEPLOYMENT_ARTIFACTS, instArtifacts, instanceId);
+ return addToscaDataDeepElementsBlockToToscaElement(metadataVertex.left().value(),edgeLabel, vertexType, instArtifacts, instanceId);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java
index 2d160bfc82..989707bf0c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java
@@ -349,9 +349,17 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
return StorageOperationStatus.OK;
}
- public StorageOperationStatus associateInstArtifactToComponent(GraphVertex nodeTypeVertex, Map<String, MapArtifactDataDefinition> instProps) {
+ public StorageOperationStatus associateInstDeploymentArtifactsToComponent(GraphVertex nodeTypeVertex, Map<String, MapArtifactDataDefinition> instArtifacts) {
+ return associateInstanceArtifactsToComponent(nodeTypeVertex, instArtifacts, VertexTypeEnum.INST_DEPLOYMENT_ARTIFACTS, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS);
+ }
+
+ public StorageOperationStatus associateInstArtifactsToComponent(GraphVertex nodeTypeVertex, Map<String, MapArtifactDataDefinition> instArtifacts) {
+ return associateInstanceArtifactsToComponent(nodeTypeVertex, instArtifacts, VertexTypeEnum.INSTANCE_ARTIFACTS, EdgeLabelEnum.INSTANCE_ARTIFACTS);
+ }
+
+ private StorageOperationStatus associateInstanceArtifactsToComponent(GraphVertex nodeTypeVertex, Map<String, MapArtifactDataDefinition> instProps, VertexTypeEnum vertexType, EdgeLabelEnum edgeLabel) {
if (instProps != null && !instProps.isEmpty()) {
- Either<GraphVertex, StorageOperationStatus> assosiateElementToData = assosiateElementToData(nodeTypeVertex, VertexTypeEnum.INST_DEPLOYMENT_ARTIFACTS, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS, instProps);
+ Either<GraphVertex, StorageOperationStatus> assosiateElementToData = assosiateElementToData(nodeTypeVertex, vertexType, edgeLabel, instProps);
if (assosiateElementToData.isRight()) {
return assosiateElementToData.right().value();
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java
index d34d3aa9f9..51d122524c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java
@@ -767,6 +767,12 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
}
}
if (result == null) {
+ Either<GraphVertex, StorageOperationStatus> updateRelationsRes = updateLastModifierEdge(toscaElement, owner, modifier);
+ if (updateRelationsRes.isRight()) {
+ result = updateRelationsRes.right().value();
+ }
+ }
+ if (result == null) {
result = StorageOperationStatus.OK;
}
return result;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java
index 5aceb2ffd2..708ef783f1 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java
@@ -1068,7 +1068,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
public <T extends ToscaElement> Either<List<T>, StorageOperationStatus> getElementCatalogData(ComponentTypeEnum componentType, List<ResourceTypeEnum> excludeTypes, boolean isHighestVersions) {
Either<List<GraphVertex>, TitanOperationStatus> listOfComponents;
if (isHighestVersions) {
- listOfComponents = getListOfHighestComponents(componentType, excludeTypes);
+ listOfComponents = getListOfHighestComponents(componentType, excludeTypes, JsonParseFlagEnum.NoParse);
}
else {
listOfComponents = getListOfHighestAndAllCertifiedComponents(componentType, excludeTypes);
@@ -1095,7 +1095,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
return Either.left(result);
}
- private Either<List<GraphVertex>, TitanOperationStatus> getListOfHighestComponents(ComponentTypeEnum componentType, List<ResourceTypeEnum> excludeTypes) {
+ private Either<List<GraphVertex>, TitanOperationStatus> getListOfHighestComponents(ComponentTypeEnum componentType, List<ResourceTypeEnum> excludeTypes, JsonParseFlagEnum parseFlag) {
Map<GraphPropertyEnum, Object> propertiesToMatch = new HashMap<>();
Map<GraphPropertyEnum, Object> propertiesHasNotToMatch = new HashMap<>();
propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
@@ -1107,13 +1107,13 @@ public abstract class ToscaElementOperation extends BaseOperation {
}
propertiesHasNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
- return titanDao.getByCriteria(null, propertiesToMatch, propertiesHasNotToMatch, JsonParseFlagEnum.ParseMetadata);
+ return titanDao.getByCriteria(null, propertiesToMatch, propertiesHasNotToMatch, parseFlag);
}
// highest + (certified && !highest)
public Either<List<GraphVertex>, TitanOperationStatus> getListOfHighestAndAllCertifiedComponents(ComponentTypeEnum componentType, List<ResourceTypeEnum> excludeTypes) {
long startFetchAllStates = System.currentTimeMillis();
- Either<List<GraphVertex>, TitanOperationStatus> highestNodes = getListOfHighestComponents(componentType, excludeTypes);
+ Either<List<GraphVertex>, TitanOperationStatus> highestNodes = getListOfHighestComponents(componentType, excludeTypes, JsonParseFlagEnum.ParseMetadata);
Map<GraphPropertyEnum, Object> propertiesToMatchCertified = new HashMap<>();
Map<GraphPropertyEnum, Object> propertiesHasNotToMatchCertified = new HashMap<>();
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
index 45a1f2bd31..e3ed9d6471 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
@@ -25,6 +25,7 @@ import fj.data.Either;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@@ -1097,7 +1098,34 @@ public class ToscaOperationFacade {
}
- public StorageOperationStatus associateArtifactToInstances(Map<String, Map<String, ArtifactDefinition>> instArtifacts, String componentId, User user) {
+ public StorageOperationStatus associateDeploymentArtifactsToInstances(Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts, String componentId, User user) {
+
+ Either<GraphVertex, TitanOperationStatus> getVertexEither = titanDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
+ if (getVertexEither.isRight()) {
+ log.debug("Couldn't fetch component with and unique id {}, error: {}", componentId, getVertexEither.right().value());
+ return DaoStatusConverter.convertTitanStatusToStorageStatus(getVertexEither.right().value());
+
+ }
+
+ GraphVertex vertex = getVertexEither.left().value();
+ Map<String, MapArtifactDataDefinition> instArtMap = new HashMap<>();
+ if (instDeploymentArtifacts != null) {
+
+ MapArtifactDataDefinition artifactsMap;
+ for (Entry<String, Map<String, ArtifactDefinition>> entry : instDeploymentArtifacts.entrySet()) {
+ Map<String, ArtifactDefinition> artList = entry.getValue();
+ Map<String, ArtifactDataDefinition> artifacts = artList.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> new ArtifactDataDefinition(e.getValue())));
+ artifactsMap = nodeTemplateOperation.prepareInstDeploymentArtifactPerInstance(artifacts, entry.getKey(), user, NodeTemplateOperation.HEAT_VF_ENV_NAME);
+
+ instArtMap.put(entry.getKey(), artifactsMap);
+ }
+ }
+
+ return topologyTemplateOperation.associateInstDeploymentArtifactsToComponent(vertex, instArtMap);
+
+ }
+
+ public StorageOperationStatus associateArtifactsToInstances(Map<String, Map<String, ArtifactDefinition>> instArtifacts, String componentId, User user) {
Either<GraphVertex, TitanOperationStatus> getVertexEither = titanDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
if (getVertexEither.isRight()) {
@@ -1114,13 +1142,13 @@ public class ToscaOperationFacade {
for (Entry<String, Map<String, ArtifactDefinition>> entry : instArtifacts.entrySet()) {
Map<String, ArtifactDefinition> artList = entry.getValue();
Map<String, ArtifactDataDefinition> artifacts = artList.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> new ArtifactDataDefinition(e.getValue())));
- artifactsMap = nodeTemplateOperation.prepareInstDeploymentArtifactPerInstance(artifacts, entry.getKey(), user, NodeTemplateOperation.HEAT_VF_ENV_NAME);
+ artifactsMap = new MapArtifactDataDefinition(artifacts);
instArtMap.put(entry.getKey(), artifactsMap);
}
}
- return topologyTemplateOperation.associateInstArtifactToComponent(vertex, instArtMap);
+ return topologyTemplateOperation.associateInstArtifactsToComponent(vertex, instArtMap);
}
@@ -1913,6 +1941,15 @@ public class ToscaOperationFacade {
return nodeTemplateOperation.addDeploymentArtifactsToInstance(componentId, componentInstance.getUniqueId(), instDeplArtifacts);
}
+
+ public StorageOperationStatus addInformationalArtifactsToInstance(String componentId, ComponentInstance componentInstance, Map<String, ArtifactDefinition> artifacts) {
+ StorageOperationStatus status = StorageOperationStatus.OK;
+ if(MapUtils.isNotEmpty(artifacts)){
+ Map<String, ArtifactDataDefinition> instDeplArtifacts = artifacts.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> new ArtifactDataDefinition(e.getValue())));
+ status= nodeTemplateOperation.addInformationalArtifactsToInstance(componentId, componentInstance.getUniqueId(), instDeplArtifacts);
+ }
+ return status;
+ }
public StorageOperationStatus generateCustomizationUUIDOnInstance(String componentId, String instanceId) {
return nodeTemplateOperation.generateCustomizationUUIDOnInstance(componentId, instanceId);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaFunctions.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaFunctions.java
new file mode 100644
index 0000000000..e6969bc5c2
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaFunctions.java
@@ -0,0 +1,19 @@
+package org.openecomp.sdc.be.model.tosca;
+
+/**
+ * tosca functions supported by sdc
+ */
+public enum ToscaFunctions {
+
+ GET_INPUT("get_input");
+
+ private String functionName;
+
+ ToscaFunctions(String functionName) {
+ this.functionName = functionName;
+ }
+
+ public String getFunctionName() {
+ return functionName;
+ }
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/DataTypePropertyConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/DataTypePropertyConverter.java
new file mode 100644
index 0000000000..2d389f5fe5
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/DataTypePropertyConverter.java
@@ -0,0 +1,130 @@
+package org.openecomp.sdc.be.model.tosca.converters;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.stream.JsonReader;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.common.util.JsonUtils;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DataTypePropertyConverter {
+
+ private static final DataTypePropertyConverter INSTANCE = new DataTypePropertyConverter();
+ private static final JsonParser jsonParser = new JsonParser();
+ private static final Gson gson = new Gson();
+
+ private DataTypePropertyConverter() {
+ }
+
+ public static DataTypePropertyConverter getInstance() {
+ return INSTANCE;
+ }
+
+ /**
+ *
+ * @param propertyDataType the data type
+ * @param dataTypes all data types in the system mapped by their name
+ * @return a json representation of all the given data type properties default values and recursively their data type properties
+ */
+ public String getDataTypePropertiesDefaultValuesRec(String propertyDataType, Map<String, DataTypeDefinition> dataTypes) {
+ JsonObject defaultValues = getDataTypePropsDefaultValuesRec(propertyDataType, dataTypes);
+ return !defaultValues.isJsonNull() ? gson.toJson(defaultValues) : null;
+ }
+
+ /**
+ * Takes a json representation of a tosca property value and merges all the default values of the property data type
+ * @param value the json representation of a tosca property value
+ * @param propertyDataType data type from which to merge default values
+ * @param dataTypes all data types in the system mapped by their name
+ * for example: for value {a: {b: c}} we could have a default value {a: {d: e}} (property a has two sub properties but only b was overridden)
+ * so the complete value is {a: {b: c, d: e}}
+ */
+ public void mergeDataTypeDefaultValuesWithPropertyValue(JsonObject value, String propertyDataType, Map<String, DataTypeDefinition> dataTypes) {
+ JsonObject dataTypeDefaultValues = getDataTypePropsDefaultValuesRec(propertyDataType, dataTypes);
+ mergeDefaultValuesRec(dataTypeDefaultValues, value);
+ }
+
+ private void mergeDefaultValuesRec(JsonObject defaultValue, JsonObject value) {
+ if (ToscaConverterUtils.isGetInputValue(value)) {
+ return;
+ }
+ for (Map.Entry<String, JsonElement> defVal : defaultValue.entrySet()) {
+ mergeDefaultValue(value, defVal.getKey(), defVal.getValue());
+ }
+ }
+
+ private void mergeDefaultValue(JsonObject value, String propName, JsonElement defValue) {
+ if (defValueWasNotOverridden(value, propName)) {
+ value.add(propName, defValue);
+ } else if (notPrimitivePropValue(value, defValue, propName)) {
+ JsonElement propValue = value.get(propName);
+ mergeDefaultValuesRec(defValue.getAsJsonObject(), propValue.getAsJsonObject());
+ }
+ }
+
+ private boolean notPrimitivePropValue(JsonObject value, JsonElement defValue, String propName) {
+ return value.get(propName).isJsonObject() && defValue.isJsonObject();
+ }
+
+ private boolean defValueWasNotOverridden(JsonObject value, String propName) {
+ return !value.has(propName);
+ }
+
+ private JsonObject getDataTypePropsDefaultValuesRec(String propertyDataType, Map<String, DataTypeDefinition> dataTypes) {
+ Map<String, PropertyDefinition> allParentsProps = getAllDataTypeProperties(dataTypes.get(propertyDataType));
+ JsonObject dataTypeDefaultsJson = new JsonObject();
+ for (Map.Entry<String, PropertyDefinition> propertyEntry : allParentsProps.entrySet()) {
+ PropertyDefinition propertyDefinition = propertyEntry.getValue();
+ addDefaultValueToJson(dataTypes, dataTypeDefaultsJson, propertyDefinition);
+ }
+ return dataTypeDefaultsJson;
+ }
+
+ private void addDefaultValueToJson(Map<String, DataTypeDefinition> dataTypes, JsonObject dataTypePropsDefaults, PropertyDefinition propertyDefinition) {
+ String propName = propertyDefinition.getName();
+ JsonElement defVal = getDefaultValue(dataTypes, dataTypePropsDefaults, propertyDefinition);
+ if (!JsonUtils.isEmptyJson(defVal)) {
+ dataTypePropsDefaults.add(propName, defVal);
+ }
+ }
+
+ private JsonElement getDefaultValue(Map<String, DataTypeDefinition> dataTypes, JsonObject dataTypePropsDefaults, PropertyDefinition propertyDefinition) {
+ JsonElement defVal = new JsonObject();
+ String propName = propertyDefinition.getName();
+ String propDefaultVal = propertyDefinition.getDefaultValue();
+ if(!JsonUtils.containsEntry(dataTypePropsDefaults, propName) && propDefaultVal != null){
+ defVal = convertToJson(propDefaultVal);
+ } else if (!JsonUtils.containsEntry(dataTypePropsDefaults, propName)) {
+ defVal = getDataTypePropsDefaultValuesRec(propertyDefinition.getType(), dataTypes);
+ }
+ return defVal;
+ }
+
+ private JsonElement convertToJson(String propDefaultVal) {
+ JsonReader jsonReader = new JsonReader(new StringReader(propDefaultVal));
+ jsonReader.setLenient(true);
+ return jsonParser.parse(jsonReader);
+ }
+
+ private Map<String, PropertyDefinition> getAllDataTypeProperties(DataTypeDefinition dataTypeDefinition) {
+ Map<String, PropertyDefinition> allParentsProps = new HashMap<>();
+ while (dataTypeDefinition != null) {
+
+ List<PropertyDefinition> currentParentsProps = dataTypeDefinition.getProperties();
+ if (currentParentsProps != null) {
+ currentParentsProps.stream().forEach(p -> allParentsProps.put(p.getName(), p));
+ }
+
+ dataTypeDefinition = dataTypeDefinition.getDerivedFrom();
+ }
+ return allParentsProps;
+ }
+
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/HeatJsonConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/HeatJsonConverter.java
index 6e077d60a1..9922c0f05d 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/HeatJsonConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/HeatJsonConverter.java
@@ -39,12 +39,15 @@ public class HeatJsonConverter implements PropertyValueConverter {
@Override
public String convert(String original, String innerType, Map<String, DataTypeDefinition> dataTypes) {
- String coverted = ValidationUtils.removeNoneUtf8Chars(original);
- coverted = ValidationUtils.removeHtmlTagsOnly(coverted);
- coverted = ValidationUtils.normaliseWhitespace(coverted);
- coverted = ValidationUtils.stripOctets(coverted);
+ if (original == null) {
+ return null;
+ }
+ String converted = ValidationUtils.removeNoneUtf8Chars(original);
+ converted = ValidationUtils.removeHtmlTagsOnly(converted);
+ converted = ValidationUtils.normaliseWhitespace(converted);
+ converted = ValidationUtils.stripOctets(converted);
// As opposed to string converter, keeping the " and ' symbols
- return coverted;
+ return converted;
}
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaConverterUtils.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaConverterUtils.java
new file mode 100644
index 0000000000..159addcbc9
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaConverterUtils.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdc.be.model.tosca.converters;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+
+public class ToscaConverterUtils {
+
+ public static boolean isGetInputValue(JsonObject value) {
+ return value.get(ToscaFunctions.GET_INPUT.getFunctionName()) != null;
+ }
+
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java
index 0673033546..5b565bf62a 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java
@@ -193,22 +193,8 @@ public class ToscaMapValueConverter extends ToscaValueBaseConverter implements T
}
JsonObject asJsonObjectIn = entryValue.getAsJsonObject();
- DataTypeDefinition dataTypeDefinition = dataTypes.get(innerType);
- Map<String, PropertyDefinition> allProperties = getAllProperties(dataTypeDefinition);
+ DataTypePropertyConverter.getInstance().mergeDataTypeDefaultValuesWithPropertyValue(asJsonObjectIn, innerType, dataTypes);
Map<String, Object> toscaObjectPresentation = new HashMap<>();
-
- for (Entry<String, PropertyDefinition> entry : allProperties.entrySet()) {
- String propName = entry.getKey();
- PropertyDefinition propertyDefinition = entry.getValue();
- JsonElement elementValue = asJsonObjectIn.get(propName);
- if(elementValue == null && propertyDefinition.getDefaultValue() != null){
- JsonReader jsonReader = new JsonReader(new StringReader(propertyDefinition.getDefaultValue()));
- jsonReader.setLenient(true);
- elementValue = jsonParser.parse(jsonReader);
- asJsonObjectIn.add(propName, elementValue);
- }
- }
-
Set<Entry<String, JsonElement>> entrySetIn = asJsonObjectIn.entrySet();
for (Entry<String, JsonElement> entry : entrySetIn) {
@@ -217,6 +203,8 @@ public class ToscaMapValueConverter extends ToscaValueBaseConverter implements T
JsonElement elementValue = entry.getValue();
Object convValue;
if (isScalarF == false) {
+ DataTypeDefinition dataTypeDefinition = dataTypes.get(innerType);
+ Map<String, PropertyDefinition> allProperties = getAllProperties(dataTypeDefinition);
PropertyDefinition propertyDefinition = allProperties.get(propName);
if (propertyDefinition == null) {
log.trace("The property {} was not found under data type . Parse as map", propName);
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/DataTypePropertyConverterTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/DataTypePropertyConverterTest.java
new file mode 100644
index 0000000000..84f2254bbb
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/DataTypePropertyConverterTest.java
@@ -0,0 +1,187 @@
+package org.openecomp.sdc.be.model.tosca.converters;
+
+import com.google.gson.JsonObject;
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+
+import javax.json.Json;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class DataTypePropertyConverterTest {
+
+ private static final String EMPTY_JSON_STR = "{}";
+ public static final String PROPERTY2_DEFAULT = "{\"prop1\":\"def1\",\"prop3\":\"def3\"}";
+ private DataTypePropertyConverter testInstance = DataTypePropertyConverter.getInstance();
+ private Map<String, DataTypeDefinition> dataTypes;
+ private DataTypeDefinition noDefaultValue, dataType1, dataType2, dataType3;
+ private PropertyDefinition prop1, prop2, prop3, noDefaultProp;
+
+ @Before
+ public void setUp() throws Exception {
+ dataTypes = new HashMap<>();
+
+ prop1 = new PropertyDefinition();
+ prop1.setDefaultValue("def1");
+ prop1.setName("prop1");
+
+ prop2 = new PropertyDefinition();
+ prop2.setType("dataType1");
+ prop2.setName("prop2");
+
+ prop3 = new PropertyDefinition();
+ prop3.setDefaultValue("def3");
+ prop3.setName("prop3");
+
+ noDefaultProp = new PropertyDefinition();
+ noDefaultProp.setName("noDefaultProp");
+
+ noDefaultValue = new DataTypeDefinition();
+ noDefaultValue.setProperties(Collections.singletonList(noDefaultProp));
+
+ dataType1 = new DataTypeDefinition();
+ dataType1.setProperties(Arrays.asList(prop1, prop3));
+
+ dataType2 = new DataTypeDefinition();
+ dataType2.setDerivedFrom(dataType1);
+
+ dataType3 = new DataTypeDefinition();
+ dataType3.setProperties(Collections.singletonList(prop2));
+ dataType3.setDerivedFrom(noDefaultValue);
+
+ dataTypes.put("noDefault", noDefaultValue);
+ dataTypes.put("dataType1", dataType1);
+ dataTypes.put("dataType2", dataType2);
+ dataTypes.put("dataType3", dataType3);
+ }
+
+ @Test
+ public void testGetPropertyDefaultValuesRec_dataTypeNotExist() throws Exception {
+ String defaultValue = testInstance.getDataTypePropertiesDefaultValuesRec("someType", dataTypes);
+ assertEquals(EMPTY_JSON_STR, defaultValue);
+ }
+
+ @Test
+ public void testGetPropertyDefaultValuesRec_NoDefaultValue() throws Exception {
+ String defaultValue = testInstance.getDataTypePropertiesDefaultValuesRec("noDefault", dataTypes);
+ assertEquals(EMPTY_JSON_STR, defaultValue);
+ }
+
+ @Test
+ public void testGetPropertyDefaultValuesRec() throws Exception {
+ String defaultValue = testInstance.getDataTypePropertiesDefaultValuesRec("dataType1", dataTypes);
+ assertEquals(PROPERTY2_DEFAULT, defaultValue);
+ }
+
+ @Test
+ public void testGetPropertyDefaultValuesRec_defaultFromDerivedDataType_derivedDataTypeHasNoDefaults() throws Exception {
+ dataType2.setDerivedFrom(noDefaultValue);
+ String defaultValue = testInstance.getDataTypePropertiesDefaultValuesRec("dataType2", dataTypes);
+ assertEquals(EMPTY_JSON_STR, defaultValue);
+ }
+
+ @Test
+ public void testGetPropertyDefaultValuesRec_defaultFromDerivedDataType() throws Exception {
+ String defaultValue = testInstance.getDataTypePropertiesDefaultValuesRec("dataType2", dataTypes);
+ assertEquals(PROPERTY2_DEFAULT, defaultValue);
+ }
+
+ @Test
+ public void testGetPropertyDefaultValuesRec_defaultFromDataTypesOfProperties_dataTypeOfPropertyHasNoDefault() throws Exception {
+ dataType3.getProperties().get(0).setType(noDefaultValue.getName());
+ String defaultValue = testInstance.getDataTypePropertiesDefaultValuesRec("dataType3", dataTypes);
+ assertEquals(EMPTY_JSON_STR, defaultValue);
+ }
+
+ @Test
+ public void testGetPropertyDefaultValuesRec_defaultFromDataTypesOfProperties() throws Exception {
+ String defaultValue = testInstance.getDataTypePropertiesDefaultValuesRec("dataType3", dataTypes);
+ assertEquals("{\"prop2\":" + PROPERTY2_DEFAULT + "}", defaultValue);//data type 3 has property prop2 which has a data type with property prop1 which has a default value
+ }
+
+ @Test
+ public void testMergeDefaultValues_allDefaultValuesAreOverridden() throws Exception {
+ JsonObject value = new JsonObject();
+ value.addProperty(noDefaultProp.getName(), "override1");
+
+ JsonObject prop1Val = new JsonObject();
+ prop1Val.addProperty(prop1.getName(), "prop1Override");
+
+ JsonObject prop3Val = new JsonObject();
+ prop3Val.addProperty(prop3.getName(), "prop3Override");
+
+ JsonObject prop2Value = new JsonObject();
+ prop2Value.add(prop3.getName(), prop3Val);
+ prop2Value.add(prop1.getName(), prop1Val);
+
+ value.add(prop2.getName(), prop2Value);
+
+ String valBeforeMerge = value.toString();
+
+ testInstance.mergeDataTypeDefaultValuesWithPropertyValue(value, "dataType3", dataTypes);
+ assertEquals(valBeforeMerge, value.toString());
+ }
+
+ @Test
+ public void testMergeDefaultValues() throws Exception {
+ JsonObject value = new JsonObject();
+ value.addProperty(noDefaultProp.getName(), "override1");
+
+ JsonObject prop1Val = new JsonObject();
+ prop1Val.addProperty(prop1.getName(), "prop1Override");
+
+ value.add(prop2.getName(), prop1Val);
+
+ testInstance.mergeDataTypeDefaultValuesWithPropertyValue(value, "dataType3", dataTypes);
+
+ assertEquals("{\"noDefaultProp\":\"override1\",\"prop2\":{\"prop1\":\"prop1Override\",\"prop3\":\"def3\"}}",
+ value.toString());//expect to merge prop 3 default as it was not overridden
+ }
+
+ @Test
+ public void testMergeDefaultValues_mergeAll() throws Exception {
+ JsonObject value = new JsonObject();
+ testInstance.mergeDataTypeDefaultValuesWithPropertyValue(value, "dataType3", dataTypes);
+
+ assertEquals("{\"prop2\":" + PROPERTY2_DEFAULT + "}",
+ value.toString());//expect to merge prop 3 default as it was not overridden
+ }
+
+ @Test
+ public void testMergeDefaultValues_doNotAddDefaultsForGetInputValues() throws Exception {
+
+ JsonObject getInputValue = new JsonObject();
+ getInputValue.addProperty("get_input", "in1");
+
+ JsonObject value = new JsonObject();
+ value.add(prop2.getName(), getInputValue);
+
+ testInstance.mergeDataTypeDefaultValuesWithPropertyValue(value, "dataType3", dataTypes);
+
+ assertEquals("{\"prop2\":{\"get_input\":\"in1\"}}", value.toString());
+ }
+
+ @Test
+ public void testMergeDefaultValues_doNotAddDefaultsForGetInputInnerValues() throws Exception {
+ JsonObject getInputValue = new JsonObject();
+ getInputValue.addProperty("get_input", "in1");
+
+ JsonObject prop1Val = new JsonObject();
+ prop1Val.add(prop1.getName(), getInputValue);
+
+ JsonObject value = new JsonObject();
+ value.add(prop2.getName(), prop1Val);
+
+ testInstance.mergeDataTypeDefaultValuesWithPropertyValue(value, "dataType3", dataTypes);
+
+ assertEquals("{\"prop2\":{\"prop1\":{\"get_input\":\"in1\"},\"prop3\":\"def3\"}}", value.toString());
+
+ }
+}
diff --git a/catalog-ui/package.json b/catalog-ui/package.json
index 6e86b46dd0..3e13e69a2b 100644
--- a/catalog-ui/package.json
+++ b/catalog-ui/package.json
@@ -45,6 +45,7 @@
"raw-loader": "^0.5.1",
"sass-loader": "^4.1.1",
"script-loader": "^0.7.0",
+ "sdc-ui": "^1.6.2",
"source-map-loader": "^0.1.5",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
@@ -105,7 +106,6 @@
"js-md5": "^0.4.2",
"lodash": "^4.17.2",
"ng-infinite-scroll": "^1.3.0",
- "ng2-interceptors": "^1.3.0-1",
"perfect-scrollbar": "^0.6.16",
"qtip2": "^3.0.3",
"reflect-metadata": "^0.1.10",
diff --git a/catalog-ui/src/app/models.ts b/catalog-ui/src/app/models.ts
index f3eb5d5fa6..ec70ebe8b1 100644
--- a/catalog-ui/src/app/models.ts
+++ b/catalog-ui/src/app/models.ts
@@ -95,6 +95,7 @@ export * from './models/member';
export * from './models/modules/base-module';
export * from './models/properties';
export * from './models/requirement';
+export * from './models/server-error-response';
export * from './models/tab';
export * from './models/tooltip-data';
export * from './models/user';
diff --git a/catalog-ui/src/app/models/modal.ts b/catalog-ui/src/app/models/modal.ts
index 51aa5e19a7..b7bdf251fe 100644
--- a/catalog-ui/src/app/models/modal.ts
+++ b/catalog-ui/src/app/models/modal.ts
@@ -5,12 +5,14 @@ export class ModalModel {
title: string;
content: any;
buttons: Array<ButtonModel>;
+ type: string; 'standard|error|alert'
- constructor(size?: string, title?: string, content?: any, buttons?: Array<ButtonModel>) {
+ constructor(size?: string, title?: string, content?: any, buttons?: Array<ButtonModel>, type?:string) {
this.size = size;
this.title = title;
this.content = content;
this.buttons = buttons;
+ this.type = type || 'standard';
}
}
diff --git a/catalog-ui/src/app/models/server-error-response.ts b/catalog-ui/src/app/models/server-error-response.ts
new file mode 100644
index 0000000000..61d09af48b
--- /dev/null
+++ b/catalog-ui/src/app/models/server-error-response.ts
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ * Created by ngordon on 7/27/2017.
+ */
+
+import { Response } from '@angular/http';
+import { SEVERITY, ServerErrors } from "../utils/constants";
+
+export class ServerErrorResponse {
+
+ title: string;
+ message: string;
+ messageId: string;
+ status: number;
+ severity: SEVERITY;
+
+ constructor(response?: Response) {
+
+ if (response) {
+ let rejectionObj: any = {};
+ if (response.text().length) {
+ let rejection = response.json();
+ rejectionObj = rejection.serviceException || rejection.requestError && (rejection.requestError.serviceException || rejection.requestError.policyException);
+ rejectionObj.text = this.getFormattedMessage(rejectionObj.text || ServerErrors.MESSAGE_ERROR, rejectionObj.variables);
+ }
+
+ this.title = ServerErrors.ERROR_TITLE;
+ this.message = rejectionObj.text || response.statusText || ServerErrors.DEFAULT_ERROR;
+ this.messageId = rejectionObj.messageId;
+ this.status = response.status;
+ this.severity = SEVERITY.ERROR;
+ }
+ }
+
+
+ private getFormattedMessage = (text: string, variables: Array<string>): string => { //OLD CODE
+ // Remove the "Error: " text at the begining
+ if (text.trim().indexOf("Error:") === 0) {
+ text = text.replace("Error:", "").trim();
+ }
+
+ //mshitrit DE199895 bug fix
+ let count: number = 0;
+ variables.forEach(function (item) {
+ variables[count] = item ? item.replace('<', '&lt').replace('>', '&gt') : '';
+ count++;
+ });
+
+ // Format the message in case has array to <ul><li>
+ text = text.replace(/\[%(\d+)\]/g, function (_, m) {
+ let tmp = [];
+ let list = variables[--m].split(";");
+ list.forEach(function (item) {
+ tmp.push("<li>" + item + "</li>");
+ });
+ return "<ul>" + tmp.join("") + "</ul>";
+ });
+
+ // Format the message %1 %2
+ text = text.format(variables);
+
+ return text;
+
+ };
+} \ No newline at end of file
diff --git a/catalog-ui/src/app/ng2/app.module.ts b/catalog-ui/src/app/ng2/app.module.ts
index 57adb8fd66..88c2d876c4 100644
--- a/catalog-ui/src/app/ng2/app.module.ts
+++ b/catalog-ui/src/app/ng2/app.module.ts
@@ -32,14 +32,13 @@ import {
} from "./utils/ng1-upgraded-provider";
import {ConfigService} from "./services/config.service";
import {HttpModule} from '@angular/http';
+import {HttpService} from './services/http.service';
import {AuthenticationService} from './services/authentication.service';
import {Cookie2Service} from "./services/cookie.service";
import {ComponentServiceNg2} from "./services/component-services/component.service";
import {ServiceServiceNg2} from "./services/component-services/service.service";
import {ComponentInstanceServiceNg2} from "./services/component-instance-services/component-instance.service";
-import { InterceptorService } from 'ng2-interceptors';
import { XHRBackend, RequestOptions } from '@angular/http';
-import {HttpInterceptor} from "./services/http.interceptor.service";
import { SearchBarComponent } from './shared/search-bar/search-bar.component';
import { SearchWithAutoCompleteComponent } from './shared/search-with-autocomplete/search-with-autocomplete.component';
@@ -49,16 +48,6 @@ export function configServiceFactory(config:ConfigService) {
return () => config.loadValidationConfiguration();
}
-export function interceptorFactory(xhrBackend: XHRBackend, requestOptions: RequestOptions){
- let service = new InterceptorService(xhrBackend, requestOptions);
- service.addInterceptor(new HttpInterceptor());
- return service;
-}
-
-
-// export function httpServiceFactory(backend: XHRBackend, options: RequestOptions) {
-// return new HttpService(backend, options);
-// }
@NgModule({
declarations: [
@@ -87,6 +76,7 @@ export function interceptorFactory(xhrBackend: XHRBackend, requestOptions: Reque
ConfigService,
ComponentServiceNg2,
ServiceServiceNg2,
+ HttpService,
ComponentInstanceServiceNg2,
{
provide: APP_INITIALIZER,
@@ -94,11 +84,6 @@ export function interceptorFactory(xhrBackend: XHRBackend, requestOptions: Reque
deps: [ConfigService],
multi: true
},
- {
- provide: InterceptorService,
- useFactory: interceptorFactory,
- deps: [XHRBackend, RequestOptions]
- }
],
bootstrap: [AppComponent]
})
diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/integer-input/ui-element-integer-input.component.ts b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/integer-input/ui-element-integer-input.component.ts
index 8b27ab7e3a..3339b605ca 100644
--- a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/integer-input/ui-element-integer-input.component.ts
+++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/integer-input/ui-element-integer-input.component.ts
@@ -35,7 +35,7 @@ export class UiElementIntegerInputComponent extends UiElementBase implements UiE
onSave() {
if (!this.control.invalid){
- this.baseEmitter.emit(JSON.parse(this.value));
+ this.baseEmitter.emit(this.value ? JSON.parse(this.value) : this.value);
}
}
}
diff --git a/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.html b/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.html
index 38de3ce649..2b58d0f086 100644
--- a/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.html
+++ b/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.html
@@ -1,5 +1,5 @@
<div class="properties-table">
- <loader [display]="isLoading" size="large" [relative]="false"></loader>
+ <loader [display]="isLoading" [size]="'large'" [relative]="true"></loader>
<div class="table-header">
<div class="table-cell col1">Property Name</div>
<div class="table-cell col3">From Instance</div>
diff --git a/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.ts b/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.ts
index 30cdb89d8e..736655f3f7 100644
--- a/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.ts
+++ b/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.ts
@@ -57,7 +57,7 @@ export class InputsTableComponent {
openDeleteModal = (input:InputFEModel) => {
this.selectedInputToDelete = input;
- this.modalService.openActionModal("Delete Input", "Are you sure you want to delete this input?", "Delete", this.onDeleteInput, "Close");
+ this.modalService.createActionModal("Delete Input", "Are you sure you want to delete this input?", "Delete", this.onDeleteInput, "Close").instance.open();
}
}
diff --git a/catalog-ui/src/app/ng2/components/loader/loader.component.html b/catalog-ui/src/app/ng2/components/loader/loader.component.html
index 0e13cee674..a62aa114d9 100644
--- a/catalog-ui/src/app/ng2/components/loader/loader.component.html
+++ b/catalog-ui/src/app/ng2/components/loader/loader.component.html
@@ -1,4 +1,5 @@
-<div *ngIf="display" data-tests-id="tlv-loader">
+<div *ngIf="isVisible" data-tests-id="tlv-loader" [ngClass]="relative ? 'loader-relative' : 'loader-fixed'"
+ [style.top]="offset.top" [style.left]="offset.left" [style.width]="offset.width" [style.height]="offset.height">
<div class="tlv-loader-back" [ngClass]="{'tlv-loader-relative':relative}"></div>
<div class="tlv-loader {{size}}"></div>
</div>
diff --git a/catalog-ui/src/app/ng2/components/loader/loader.component.less b/catalog-ui/src/app/ng2/components/loader/loader.component.less
index 054b6021a1..ddb9915176 100644
--- a/catalog-ui/src/app/ng2/components/loader/loader.component.less
+++ b/catalog-ui/src/app/ng2/components/loader/loader.component.less
@@ -16,6 +16,22 @@
z-index: 10002;
}
+.loader-relative {
+ display: block;
+ position:absolute;
+ width: 100%;
+ height:100%;
+}
+
+.loader-fixed {
+ display: block;
+ position:fixed;
+ top:0;
+ left:0;
+ width: 100%;
+ height:100%;
+}
+
@keyframes fadein {
from { opacity: 0; }
to { opacity: 0.8; }
diff --git a/catalog-ui/src/app/ng2/components/loader/loader.component.ts b/catalog-ui/src/app/ng2/components/loader/loader.component.ts
index 92278d3ff5..f66aa551e2 100644
--- a/catalog-ui/src/app/ng2/components/loader/loader.component.ts
+++ b/catalog-ui/src/app/ng2/components/loader/loader.component.ts
@@ -21,7 +21,7 @@
/**
* Created by rc2122 on 6/6/2017.
*/
-import {Component, Input, ElementRef, Renderer, SimpleChanges} from "@angular/core";
+import { Component, Input, ViewContainerRef, SimpleChanges} from "@angular/core";
@Component({
selector: 'loader',
templateUrl: './loader.component.html',
@@ -29,13 +29,20 @@ import {Component, Input, ElementRef, Renderer, SimpleChanges} from "@angular/co
})
export class LoaderComponent {
- @Input() display:boolean;
- @Input() size:string;// small || medium || large
- @Input() relative: boolean;
- @Input() elementSelector: string; // optional. If is relative is set to true, option to pass in element that loader should be relative to. Otherwise, will be relative to parent element.
+ @Input() display: boolean;
+ @Input() size: string;// small || medium || large
+ @Input() relative: boolean; // If is relative is set to true, loader will appear over parent element. Otherwise, will be fixed over the entire page.
+ @Input() loaderDelay: number; //optional - number of ms to delay loader display.
+ private isVisible: boolean = false;
+ private offset : {
+ top: string;
+ left: string;
+ width: string;
+ height: string;
+ };
- constructor (private el: ElementRef, private renderer: Renderer){
+ constructor(private viewContainerRef: ViewContainerRef) {
}
ngOnInit() {
@@ -49,46 +56,31 @@ export class LoaderComponent {
ngOnChanges(changes: SimpleChanges) {
if(changes.display){
- if (this.display) {
- this.changeLoaderDisplay(false); //display is set to true, so loader will appear unless we explicitly tell it not to.
- window.setTimeout((): void => {
- this.display && this.changeLoaderDisplay(true); //only show loader if we still need to display it.
- }, 500);
- } else {
- window.setTimeout(():void => {
- this.changeLoaderDisplay(false);
- }, 0);
- }
+ this.changeLoaderDisplay(this.display);
}
}
- changeLoaderDisplay = (display: boolean): void => {
+ private changeLoaderDisplay = (display: boolean): void => {
if (display) {
- this.calculateLoaderPosition();
- this.renderer.setElementStyle(this.el.nativeElement, 'display', 'block');
+ window.setTimeout((): void => {
+ this.display && this.showLoader(); //only show loader if this.display has not changed in the meanwhile.
+ }, this.loaderDelay || 0);
} else {
- this.renderer.setElementStyle(this.el.nativeElement, 'display', 'none');
+ this.isVisible = false;
}
}
- calculateLoaderPosition = () => {
- if (this.relative === true) { // Can change the parent position to relative without causing style issues.
- let parent = (this.elementSelector) ? angular.element(this.elementSelector).get(0) : this.el.nativeElement.parentElement;
- this.renderer.setElementStyle(parent, 'position', 'relative');
- this.setLoaderPosition(0, 0); //will be relative to parent and appear over specified element
- //TODO: DONT force parent to have position relative; set inner div's style instead of outer element
- // let parentPos: ClientRect = this.el.nativeElement.parentElement.getBoundingClientRect();
- // this.setLoaderPosition(parentPos.top, parentPos.left, parentPos.width, parentPos.height);
- } else {
- this.setLoaderPosition(0, 0); //will appear over whole page
+ private showLoader = () => {
+ if (this.relative === true) {
+ let parentElement = this.viewContainerRef.element.nativeElement.parentElement;
+ this.offset = {
+ left: (parentElement.offsetLeft) ? parentElement.offsetLeft + "px" : undefined,
+ top: (parentElement.offsetTop) ? parentElement.offsetTop + "px" : undefined,
+ width: (parentElement.offsetWidth) ? parentElement.offsetWidth + "px" : undefined,
+ height: (parentElement.offsetHeight) ? parentElement.offsetHeight + "px" : undefined
+ };
}
+ this.isVisible = true;
}
- setLoaderPosition = (top:number, left:number, width?:number, height?:number): void => {
- this.renderer.setElementStyle(this.el.nativeElement, 'position', 'absolute');
- this.renderer.setElementStyle(this.el.nativeElement, 'top', top? top.toString() : "0");
- this.renderer.setElementStyle(this.el.nativeElement, 'left', left? left.toString() : "0");
- this.renderer.setElementStyle(this.el.nativeElement, 'width', width? width.toString() : "100%");
- this.renderer.setElementStyle(this.el.nativeElement, 'height', height? height.toString() : "100%");
- };
}
diff --git a/catalog-ui/src/app/ng2/components/modal/error-message/error-message.component.html b/catalog-ui/src/app/ng2/components/modal/error-message/error-message.component.html
new file mode 100644
index 0000000000..433bd4fd6f
--- /dev/null
+++ b/catalog-ui/src/app/ng2/components/modal/error-message/error-message.component.html
@@ -0,0 +1,5 @@
+<div class="error-message-component">
+ <div>Error code: {{input.messageId}}</div>
+ <div>Status code: {{input.status}}</div>
+ <div class="error-message">{{input.message}}</div>
+</div> \ No newline at end of file
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/MigrationException.java b/catalog-ui/src/app/ng2/components/modal/error-message/error-message.component.ts
index 8e958b9ad1..c0d6673412 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/migration/MigrationException.java
+++ b/catalog-ui/src/app/ng2/components/modal/error-message/error-message.component.ts
@@ -18,12 +18,21 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.asdctool.impl.migration;
+/**
+ * Created by ngordon on 7/30/2017.
+ */
+import { Component, Input } from '@angular/core';
+import { ServerErrorResponse } from 'app/models';
+
+@Component({
+ selector: 'error-message',
+ templateUrl: './error-message.component.html'
+})
-public class MigrationException extends RuntimeException {
+export class ErrorMessageComponent {
+ @Input() input: ServerErrorResponse;
- public MigrationException(String message) {
- super(message);
+ constructor() {
}
}
diff --git a/catalog-ui/src/app/ng2/components/modal/modal.component.html b/catalog-ui/src/app/ng2/components/modal/modal.component.html
index cc411bc751..d843867cdb 100644
--- a/catalog-ui/src/app/ng2/components/modal/modal.component.html
+++ b/catalog-ui/src/app/ng2/components/modal/modal.component.html
@@ -1,10 +1,14 @@
<div class="custom-modal {{input.size}}">
<div class="ng2-modal-content">
- <div class="ng2-modal-header">
+ <div class="ng2-modal-header modal-type-{{input.type}}">
<span class="title">{{ input.title }}</span>
<span class="close-button" (click)="close()"></span>
</div>
- <div class="ng2-modal-body" >{{input.content}}</div>
+ <div class="ng2-modal-body" >
+ <div *ngIf="input.content">{{input.content}}</div>
+ <div #dynamicContentContainer></div>
+ </div>
+
<div class="ng2-modal-footer">
<button *ngFor="let button of input.buttons"
class="tlv-btn {{button.cssClass}}"
diff --git a/catalog-ui/src/app/ng2/components/modal/modal.component.less b/catalog-ui/src/app/ng2/components/modal/modal.component.less
index a35f829e6a..c87162afb0 100644
--- a/catalog-ui/src/app/ng2/components/modal/modal.component.less
+++ b/catalog-ui/src/app/ng2/components/modal/modal.component.less
@@ -37,12 +37,25 @@
display: -ms-flexbox;
display: flex;
text-align: left;
- border-bottom: solid 1px @main_color_o;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
margin: 0px 20px;
+
+ &.modal-type-standard {
+ border-bottom: solid 3px @main_color_a;
+ }
+
+ &.modal-type-error {
+ border-bottom: solid 3px @func_color_q;
+ }
+
+ &.modal-type-alert{
+ border-bottom: solid 3px @main_color_h;
+ }
+
.title{
+ .s_18_m;
-webkit-box-flex: 999;
-ms-flex-positive: 999;
flex-grow: 999;
diff --git a/catalog-ui/src/app/ng2/components/modal/modal.component.ts b/catalog-ui/src/app/ng2/components/modal/modal.component.ts
index 09fb9abdd1..89db8d1140 100644
--- a/catalog-ui/src/app/ng2/components/modal/modal.component.ts
+++ b/catalog-ui/src/app/ng2/components/modal/modal.component.ts
@@ -22,7 +22,7 @@
* Created by rc2122 on 6/1/2017.
*/
import { Component, ElementRef, Input, OnInit, OnDestroy } from '@angular/core';
-//import {ViewContainerRef, ViewChild} from '@angular/core';
+import {ViewContainerRef, ViewChild} from '@angular/core';
import * as $ from 'jquery';
import { ButtonsModelMap, ModalModel } from 'app/models';
@@ -34,9 +34,9 @@ import { ButtonsModelMap, ModalModel } from 'app/models';
export class ModalComponent implements OnInit, OnDestroy {
@Input() input: ModalModel;
+ @Input() dynamicContent: any;
+ @ViewChild('dynamicContentContainer', { read: ViewContainerRef }) dynamicContentContainer: ViewContainerRef; //Allows for custom component as body instead of simple message. See ModalService.createActionModal for implementation details, and HttpService's catchError() for example.
private modalElement: JQuery;
- //@ViewChild('modalBody', { read: ViewContainerRef }) modalContainer: ViewContainerRef; //TODO: allow for custom component as body instead of simple message
-
constructor( el: ElementRef ) {
this.modalElement = $(el.nativeElement);
diff --git a/catalog-ui/src/app/ng2/components/modal/modal.module.ts b/catalog-ui/src/app/ng2/components/modal/modal.module.ts
index d77be2cd23..892f6993dd 100644
--- a/catalog-ui/src/app/ng2/components/modal/modal.module.ts
+++ b/catalog-ui/src/app/ng2/components/modal/modal.module.ts
@@ -1,16 +1,19 @@
import { NgModule } from "@angular/core";
import { CommonModule } from '@angular/common';
import { ModalService } from 'app/ng2/services/modal.service';
-import { ModalComponent } from "app/ng2/components/modal/modal.component"
+import { ModalComponent } from "app/ng2/components/modal/modal.component";
+import { ErrorMessageComponent } from "./error-message/error-message.component";
@NgModule({
declarations: [
ModalComponent,
+ ErrorMessageComponent
],
imports: [CommonModule],
exports: [],
- entryComponents: [
- ModalComponent
+ entryComponents: [ //need to add anything that will be dynamically created
+ ModalComponent,
+ ErrorMessageComponent
],
providers: [ModalService]
})
diff --git a/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.html b/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.html
index c57998af5e..a9dc499e7d 100644
--- a/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.html
+++ b/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.html
@@ -1,5 +1,5 @@
<div class="properties-table">
- <loader [display]="isLoading" size="large" [relative]="false"></loader>
+ <loader [display]="isLoading" [size]="'large'" [relative]="true" [loaderDelay]="500"></loader>
<div class="table-header">
<div class="table-cell col1">Property Name</div>
<div class="table-cell col2">Type</div>
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts
index 3a5daba711..1c6f51314d 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts
@@ -45,7 +45,6 @@ import { KeysPipe } from 'app/ng2/pipes/keys.pipe';
import {TooltipModule} from "../../components/tooltip/tooltip.module";
import { ComponentModeService } from "app/ng2/services/component-mode.service"
import {LoaderComponent} from "app/ng2/components/loader/loader.component"
-import {HttpInterceptor} from "../../services/http.interceptor.service";
@NgModule({
declarations: [
@@ -81,7 +80,7 @@ import {HttpInterceptor} from "../../services/http.interceptor.service";
// PopoverContentComponent,
// PopoverComponent
],
- providers: [PropertiesService, HierarchyNavService, PropertiesUtils, DataTypeService,HttpInterceptor, ContentAfterLastDotPipe, GroupByPipe, KeysPipe, ComponentModeService]
+ providers: [PropertiesService, HierarchyNavService, PropertiesUtils, DataTypeService, ContentAfterLastDotPipe, GroupByPipe, KeysPipe, ComponentModeService]
})
export class PropertiesAssignmentModule {
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html
index 0b50357a5c..be7e03dccd 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html
@@ -43,7 +43,7 @@
<tabs #hierarchyNavTabs tabStyle="simple-tabs">
<tab tabTitle="Composition">
<div class="hierarchy-nav-container">
- <loader [display]="loadingInstances" size="medium" [relative]="true"></loader>
+ <loader [display]="loadingInstances" [size]="'medium'" [relative]="true" [loaderDelay]="500"></loader>
<div class="hierarchy-header white-sub-header">
<span tooltip="{{component.name}}">{{component.name}}</span>
</div>
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.less b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.less
index 8151d001e8..03974bf723 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.less
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.less
@@ -1,5 +1,5 @@
@import '../../../../assets/styles/variables';
-//@import url('https://fonts.googleapis.com/css?family=Open+Sans');
+@import '../../../../assets/styles/mixins';
@ng2-shadow-gray: #f8f8f8;
@ng2-light-gray: #eaeaea;
@ng2-medium-gray: #d2d2d2;
@@ -36,7 +36,7 @@
/deep/ .tab {
padding: 12px;
flex: 1;
- font-weight:bold;
+ font-family: @font-opensans-regular;
&.active {
color:#009fdb;
@@ -44,6 +44,7 @@
border-top: solid 4px #009fdb;
background-color: white;
padding-top:9px;
+ font-family: @font-opensans-medium;
}
.tab-indication {
@@ -129,8 +130,12 @@
flex: none;
padding: 8px 20px 0;
font-size: 14px;
- font-weight:bold;
line-height:30px;
+ font-family: @font-opensans-regular;
+
+ &.active {
+ font-family: @font-opensans-medium;
+ }
}
}
@@ -146,8 +151,6 @@
background-color: #fffefe;
box-shadow: 0px 1px 0.99px 0.01px rgba(34, 31, 31, 0.15);
border-bottom: #d2d2d2 solid 1px;
- color:#009fdb;
- font-weight:bold;
font-size:14px;
text-align:left;
flex:0 0 auto;
@@ -155,6 +158,8 @@
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
+ .a_13_r;
+ text-transform: uppercase;
&.hierarchy-header {
padding-left:20px;
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
index 6782b72fa2..82754f13f0 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
@@ -105,7 +105,7 @@ export class PropertiesAssignmentComponent {
});
this.loadingInputs = false;
- });
+ }, error => {}); //ignore error
this.componentServiceNg2
.getComponentResourceInstances(this.component)
.subscribe(response => {
@@ -120,7 +120,7 @@ export class PropertiesAssignmentComponent {
this.loadingProperties = false;
}
this.selectFirstInstanceByDefault();
- });
+ }, error => {}); //ignore error
};
@@ -159,7 +159,7 @@ export class PropertiesAssignmentComponent {
this.processInstancePropertiesResponse(instanceBePropertiesMap, true);
this.loadingProperties = false;
- });
+ }, error => {}); //ignore error
} else {
this.componentInstanceServiceNg2
.getComponentInstanceProperties(this.component, resourceInstance.uniqueId)
@@ -167,7 +167,7 @@ export class PropertiesAssignmentComponent {
instanceBePropertiesMap[resourceInstance.uniqueId] = response;
this.processInstancePropertiesResponse(instanceBePropertiesMap, false);
this.loadingProperties = false;
- });
+ }, error => {}); //ignore error
}
if(resourceInstance.componentName === "vnfConfiguration") {
@@ -203,16 +203,16 @@ export class PropertiesAssignmentComponent {
this.componentInstanceServiceNg2
.updateInstanceInput(this.component, this.selectedInstanceData.uniqueId, inputToUpdate)
.subscribe(response => {
- console.log("update resource instance input and got this response: ", response);
- })
+ console.log("Update resource instance input response: ", response);
+ }, error => {}); //ignore error
}
else {
let propertyBe = new PropertyBEModel(event);
this.componentInstanceServiceNg2
.updateInstanceProperty(this.component, this.selectedInstanceData.uniqueId, propertyBe)
.subscribe(response => {
- console.log("updated resource instance property and got this response: ", response);
- });
+ console.log("Update resource instance property response: ", response);
+ }, error => {}); //ignore error
console.log(event);
}
@@ -226,7 +226,7 @@ export class PropertiesAssignmentComponent {
.updateComponentInput(this.component, inputToUpdate)
.subscribe(response => {
console.log("updated the component input and got this response: ", response);
- })
+ }, error => {}); //ignore error
};
@@ -322,7 +322,7 @@ export class PropertiesAssignmentComponent {
this.inputs.push(newInput);
this.updatePropertyValueAfterDeclare(newInput);
});
- });
+ }, error => {}); //ignore error
};
@@ -373,7 +373,7 @@ export class PropertiesAssignmentComponent {
// this.propertiesService.undoDisableRelatedProperties(propToEnable, response.inputPath);
// }
// }
- });
+ }, error => {}); //ignore error
};
@@ -391,7 +391,7 @@ export class PropertiesAssignmentComponent {
this.renderer.invokeElementMethod(this.hierarchyNavTabs, 'triggerTabChange', ['Composition']);
this.propertiesNavigationData = [];
this.displayClearSearch = true;
- });
+ }, error => {}); //ignore error
};
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts
index a04d23a16a..d8d991d218 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts
@@ -44,9 +44,7 @@ export class PropertiesUtils {
let propertyFeArray: Array<PropertyFEModel> = [];
_.forEach(properties, (property: PropertyBEModel) => {
- if (!this.dataTypeService.getDataTypeByTypeName(property.type)) { // if type not exist in data types remove property from list
- console.log("ERROR: missing type " + property.type + " in dataTypes , of property ", property);
- } else {
+ if (this.dataTypeService.getDataTypeByTypeName(property.type)) { // if type not exist in data types remove property from list
let newFEProp: PropertyFEModel = new PropertyFEModel(property); //Convert property to FE
diff --git a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts
index 0c499facff..27de59de82 100644
--- a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts
@@ -25,14 +25,14 @@ import {sdc2Config} from "../../../../main";
import {PropertyBEModel} from "app/models";
import {CommonUtils} from "app/utils";
import {Component, ComponentInstance, InputModel} from "app/models";
-import {InterceptorService} from "ng2-interceptors/index";
+import { HttpService } from '../http.service';
@Injectable()
export class ComponentInstanceServiceNg2 {
protected baseUrl;
- constructor(private http: InterceptorService) {
+ constructor(private http: HttpService) {
this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root;
}
diff --git a/catalog-ui/src/app/ng2/services/component-services/component.service.ts b/catalog-ui/src/app/ng2/services/component-services/component.service.ts
index cd593d5e3e..c648711d5d 100644
--- a/catalog-ui/src/app/ng2/services/component-services/component.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-services/component.service.ts
@@ -30,8 +30,8 @@ import {ComponentGenericResponse} from "../responses/component-generic-response"
import {sdc2Config} from "../../../../main";
import {InstanceBePropertiesMap} from "../../../models/properties-inputs/property-fe-map";
import {API_QUERY_PARAMS} from "app/utils";
-import {ComponentType, ServerTypeUrl} from "../../../utils/constants";
-import {InterceptorService} from "ng2-interceptors/index";
+import { ComponentType, ServerTypeUrl } from "../../../utils/constants";
+import { HttpService } from '../http.service';
declare var angular:angular.IAngularStatic;
@@ -40,7 +40,7 @@ export class ComponentServiceNg2 {
protected baseUrl;
- constructor(private http:InterceptorService) {
+ constructor(private http:HttpService) {
this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root;
}
@@ -54,7 +54,7 @@ export class ComponentServiceNg2 {
return this.http.get(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/filteredDataByParams', {search: params})
.map((res:Response) => {
return new ComponentGenericResponse().deserialize(res.json());
- }).do(error => console.log('server data:', error));
+ });
}
private getServerTypeUrl = (componentType:string):string => {
diff --git a/catalog-ui/src/app/ng2/services/component-services/service.service.ts b/catalog-ui/src/app/ng2/services/component-services/service.service.ts
index 1f5de18c04..ec912bbcf5 100644
--- a/catalog-ui/src/app/ng2/services/component-services/service.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-services/service.service.ts
@@ -26,7 +26,7 @@ import { Response } from '@angular/http';
import {Service} from "app/models";
import { downgradeInjectable } from '@angular/upgrade/static';
import {sdc2Config} from "../../../../main";
-import {InterceptorService} from "ng2-interceptors/index";
+import { HttpService } from '../http.service';
@Injectable()
@@ -34,7 +34,7 @@ export class ServiceServiceNg2 {
protected baseUrl = "";
- constructor(private http: InterceptorService) {
+ constructor(private http: HttpService) {
this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root;
}
diff --git a/catalog-ui/src/app/ng2/services/data-type.service.ts b/catalog-ui/src/app/ng2/services/data-type.service.ts
index 48d32b7e69..30c02a4141 100644
--- a/catalog-ui/src/app/ng2/services/data-type.service.ts
+++ b/catalog-ui/src/app/ng2/services/data-type.service.ts
@@ -38,12 +38,14 @@ export class DataTypeService {
}
public getDataTypeByTypeName(typeName: string): DataTypeModel {
+ if (!this.dataTypes[typeName]) console.log("MISSING Datatype: " + typeName);
return this.dataTypes[typeName];
}
public getDerivedDataTypeProperties(dataTypeObj: DataTypeModel, propertiesArray: Array<DerivedFEProperty>, parentName: string) {
//push all child properties to array
+ if (!dataTypeObj) return;
if (dataTypeObj.properties) {
dataTypeObj.properties.forEach((derivedProperty) => {
if(dataTypeObj.name !== PROPERTY_DATA.OPENECOMP_ROOT || derivedProperty.name !== PROPERTY_DATA.SUPPLEMENTAL_DATA){//The requirement is to not display the property supplemental_data
diff --git a/catalog-ui/src/app/ng2/services/http.interceptor.service.ts b/catalog-ui/src/app/ng2/services/http.interceptor.service.ts
deleted file mode 100644
index c90bfd2848..0000000000
--- a/catalog-ui/src/app/ng2/services/http.interceptor.service.ts
+++ /dev/null
@@ -1,162 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-import 'rxjs/add/operator/map';
-import 'rxjs/add/operator/toPromise';
-import 'rxjs/Rx';
-import {sdc2Config} from './../../../main';
-import {Interceptor, InterceptedRequest, InterceptedResponse} from 'ng2-interceptors';
-import {SharingService} from "../../services/sharing-service";
-import {ReflectiveInjector} from '@angular/core';
-import {Cookie2Service} from "./cookie.service";
-import {UUID} from "angular2-uuid";
-import {Dictionary} from "../../utils/dictionary/dictionary";
-import {SEVERITY} from "../../utils/constants";
-import {IServerMessageModalModel} from "../../view-models/modals/message-modal/message-server-modal/server-message-modal-view-model";
-
-
-export class HttpInterceptor implements Interceptor {
-
- private cookieService:Cookie2Service;
- private sharingService:SharingService;
-
- constructor() {
- let injector = ReflectiveInjector.resolveAndCreate([Cookie2Service, SharingService]);
- this.cookieService = injector.get(Cookie2Service);
- this.sharingService = injector.get(SharingService);
- }
-
- public interceptBefore(request:InterceptedRequest):InterceptedRequest {
- /**
- * For every request to the server, that the service id, or resource id is sent in the URL, need to pass UUID in the header.
- * Check if the unique id exists in uuidMap, and if so get the UUID and add it to the header.
- */
- request.options.headers.append(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId());
- request.options.withCredentials = true;
- var uuidValue = this.getUuidValue(request.url);
- if (uuidValue != '') {
- request.options.headers.set('X-ECOMP-ServiceID', uuidValue);
- }
- request.options.headers.set('X-ECOMP-RequestID', UUID.UUID());
- return request;
- }
-
- public interceptAfter(response:InterceptedResponse):InterceptedResponse {
-
- if (response.response.status !== 200 && response.response.status !== 201) {
- this.responseError(response.response.json());
- //console.log("Error from BE:",response);
- }
- return response;
- }
-
- private getUuidValue = (url:string):string => {
- let map:Dictionary<string, string> = this.sharingService.getUuidMap();
- if (map && url.indexOf(sdc2Config.api.root) > 0) {
- map.forEach((key:string) => {
- if (url.indexOf(key) !== -1) {
- return this.sharingService.getUuidValue(key);
- }
- });
- }
- return '';
- };
-
- public formatMessageArrays = (message:string, variables:Array<string>)=> {
- return message.replace(/\[%(\d+)\]/g, function (_, m) {
- let tmp = [];
- let list = variables[--m].split(";");
- list.forEach(function (item) {
- tmp.push("<li>" + item + "</li>");
- });
- return "<ul>" + tmp.join("") + "</ul>";
- });
- };
-
- public responseError = (rejection:any)=> {
-
- let text:string;
- let variables;
- let messageId:string = "";
- let isKnownException = false;
-
- if (rejection && rejection.serviceException) {
- text = rejection.serviceException.text;
- variables = rejection.serviceException.variables;
- messageId = rejection.serviceException.messageId;
- isKnownException = true;
- } else if (rejection && rejection.requestError && rejection.requestError.serviceException) {
- text = rejection.requestError.serviceException.text;
- variables = rejection.requestError.serviceException.variables;
- messageId = rejection.requestError.serviceException.messageId;
- isKnownException = true;
- } else if (rejection && rejection.requestError && rejection.requestError.policyException) {
- text = rejection.requestError.policyException.text;
- variables = rejection.requestError.policyException.variables;
- messageId = rejection.requestError.policyException.messageId;
- isKnownException = true;
- } else if (rejection) {
- text = 'Wrong error format from server';
- console.error(text);
- isKnownException = false;
- }
-
- let data:IServerMessageModalModel;
- if (isKnownException) {
- // Remove the "Error: " text at the begining
- if (text.trim().indexOf("Error:") === 0) {
- text = text.replace("Error:", "").trim();
- }
-
- //mshitrit DE199895 bug fix
- let count:number = 0;
- variables.forEach(function (item) {
- variables[count] = item ? item.replace('<', '&lt').replace('>', '&gt') : '';
- count++;
- });
-
- // Format the message in case has array to <ul><li>
- text = this.formatMessageArrays(text, variables);
-
- // Format the message %1 %2
- text = text.format(variables);
-
- // Need to inject the MessageService manually to prevent circular dependencies (because MessageService use $templateCache that use $http).
- data = {
- title: 'Error',
- message: text,
- messageId: messageId,
- status: rejection.status,
- severity: SEVERITY.ERROR
- };
- } else {
- // Need to inject the MessageService manually to prevent circular dependencies (because MessageService use $templateCache that use $http).
- data = {
- title: 'Error',
- message: rejection.status !== -1 ? rejection.statusText : "Error getting response from server",
- messageId: messageId,
- status: rejection.status,
- severity: SEVERITY.ERROR
- };
- }
-
- console.error('ERROR data',data);
- }
-}
diff --git a/catalog-ui/src/app/ng2/services/http.service.ts b/catalog-ui/src/app/ng2/services/http.service.ts
index 5cd5a10000..21fe09023a 100644
--- a/catalog-ui/src/app/ng2/services/http.service.ts
+++ b/catalog-ui/src/app/ng2/services/http.service.ts
@@ -24,14 +24,18 @@ import {Observable} from 'rxjs/Observable';
import {UUID} from 'angular2-uuid';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
+import 'rxjs/add/observable/throw';
import {Dictionary} from "../../utils/dictionary/dictionary";
import {SharingService, CookieService} from "app/services";
import {sdc2Config} from './../../../main';
+import { ModalService } from "app/ng2/services/modal.service";
+import { ServerErrorResponse } from "app/models";
+import { ErrorMessageComponent } from 'app/ng2/components/modal/error-message/error-message.component';
@Injectable()
export class HttpService extends Http {
- constructor(backend:XHRBackend, options:RequestOptions, private sharingService:SharingService, private cookieService: CookieService) {
+ constructor(backend: XHRBackend, options: RequestOptions, private sharingService: SharingService, private cookieService: CookieService, private modalService: ModalService) {
super(backend, options);
this._defaultOptions.withCredentials = true;
this._defaultOptions.headers.append(cookieService.getUserIdSuffix(), cookieService.getUserId());
@@ -64,7 +68,7 @@ export class HttpService extends Http {
}
request.headers.set('X-ECOMP-RequestID', UUID.UUID());
}
- return super.request(request, options).catch(this.catchAuthError(this));
+ return super.request(request, options).catch((err) => this.catchError(err));
}
private getUuidValue = (url: string) :string => {
@@ -79,15 +83,14 @@ export class HttpService extends Http {
return '';
}
- private catchAuthError(self:HttpService) {
- // we have to pass HttpService's own instance here as `self`
- return (res:Response) => {
- console.log(res);
- if (res.status === 401 || res.status === 403) {
- // if not authenticated
- console.log(res);
- }
- return Observable.throw(res);
- };
- }
+ private catchError = (response: Response): Observable<any> => {
+
+ let modalInstance = this.modalService.createErrorModal("OK");
+ let errorResponse: ServerErrorResponse = new ServerErrorResponse(response);
+ this.modalService.addDynamicContentToModal(modalInstance, ErrorMessageComponent, errorResponse);
+ modalInstance.instance.open();
+
+ return Observable.throw(response);
+ };
+
}
diff --git a/catalog-ui/src/app/ng2/services/modal.service.ts b/catalog-ui/src/app/ng2/services/modal.service.ts
index 32192f40c2..65ff870769 100644
--- a/catalog-ui/src/app/ng2/services/modal.service.ts
+++ b/catalog-ui/src/app/ng2/services/modal.service.ts
@@ -11,10 +11,10 @@ export class ModalService {
constructor(private componentFactoryResolver: ComponentFactoryResolver, private applicationRef: ApplicationRef) { }
- /* Shortcut method to open a simple modal with title, message, and close button that simply closes the modal. */
+ /* Shortcut method to open an alert modal with title, message, and close button that simply closes the modal. */
public openAlertModal(title: string, message: string, closeButtonText?:string) {
let closeButton: ButtonModel = new ButtonModel(closeButtonText || 'Close', 'grey', this.closeCurrentModal);
- let modalModel: ModalModel = new ModalModel('sm', title, message, [closeButton]);
+ let modalModel: ModalModel = new ModalModel('sm', title, message, [closeButton], 'alert');
this.createCustomModal(modalModel).instance.open();
}
@@ -22,19 +22,28 @@ export class ModalService {
/**
* Shortcut method to open a basic modal with title, message, and an action button with callback, as well as close button.
* NOTE: To close the modal from within the callback, use modalService.closeCurrentModal() //if you run into zone issues with callbacks see:https://stackoverflow.com/questions/36566698/how-to-dynamically-create-bootstrap-modals-as-angular2-components
+ * NOTE: To add dynamic content to the modal, use modalService.addDynamicContentToModal(). First param is the return value of this function -- componentRef<ModalComponent>.
* @param title Heading for modal
* @param message Message for modal
* @param actionButtonText Blue call to action button
* @param actionButtonCallback function to invoke when button is clicked
* @param cancelButtonText text for close/cancel button
*/
- public openActionModal = (title:string, message:string, actionButtonText:string, actionButtonCallback:Function, cancelButtonText:string) => {
+ public createActionModal = (title: string, message: string, actionButtonText: string, actionButtonCallback: Function, cancelButtonText: string): ComponentRef<ModalComponent> => {
let actionButton: ButtonModel = new ButtonModel(actionButtonText, 'blue', actionButtonCallback);
let cancelButton: ButtonModel = new ButtonModel(cancelButtonText, 'grey', this.closeCurrentModal);
let modalModel: ModalModel = new ModalModel('sm', title, message, [actionButton, cancelButton]);
- this.createCustomModal(modalModel).instance.open();
+ let modalInstance: ComponentRef<ModalComponent> = this.createCustomModal(modalModel);
+ return modalInstance;
+ }
+
+
+ public createErrorModal = (closeButtonText?: string, errorMessage?: string):ComponentRef<ModalComponent> => {
+ let closeButton: ButtonModel = new ButtonModel(closeButtonText || 'Close', 'grey', this.closeCurrentModal);
+ let modalModel: ModalModel = new ModalModel('sm', 'Error', errorMessage, [closeButton], 'error');
+ let modalInstance: ComponentRef<ModalComponent> = this.createCustomModal(modalModel);
+ return modalInstance;
}
-
/* Use this method to create a modal with title, message, and completely custom buttons. Use response.instance.open() to open */
public createCustomModal = (customModalData: ModalModel): ComponentRef<ModalComponent> => {
@@ -53,6 +62,14 @@ export class ModalService {
}
+ public addDynamicContentToModal = (modalInstance: ComponentRef<ModalComponent>, dynamicComponentType: Type<any>, dynamicComponentInput: any) => {
+
+ let dynamicContent = this.createDynamicComponent(dynamicComponentType, modalInstance.instance.dynamicContentContainer);
+ dynamicContent.instance.input = dynamicComponentInput;
+ modalInstance.instance.dynamicContent = dynamicContent;
+ return modalInstance;
+ }
+
//Creates a component dynamically (aka during runtime). If a view container is not specified, it will append the new component to the app root.
//To subscribe to an event from invoking component: componentRef.instance.clicked.subscribe((m) => console.log(m.name));
private createDynamicComponent<T>(componentType: Type<T>, viewContainerRef?:ViewContainerRef): ComponentRef<any> {
diff --git a/catalog-ui/src/app/services/event-listener-service.ts b/catalog-ui/src/app/services/event-listener-service.ts
index 1c796230c6..96f9e17641 100644
--- a/catalog-ui/src/app/services/event-listener-service.ts
+++ b/catalog-ui/src/app/services/event-listener-service.ts
@@ -48,7 +48,7 @@ export class EventListenerService implements IEventListenerService {
// Only insert the callback if the callback is different from existing callbacks.
for (let i = 0; i < callbacks.length; i++) {
- if (callbacks[i].toString() === callback.toString()) {
+ if (callbacks[i].callback.toString() === callback.toString()) {
return; // Do not add this callback.
}
}
diff --git a/catalog-ui/src/app/utils/constants.ts b/catalog-ui/src/app/utils/constants.ts
index ffdf6fdaa2..6ec6a7762b 100644
--- a/catalog-ui/src/app/utils/constants.ts
+++ b/catalog-ui/src/app/utils/constants.ts
@@ -167,6 +167,12 @@ export class ModalType {
static ALERT = 'alert';
}
+export class ServerErrors {
+ static ERROR_TITLE = 'Error';
+ static DEFAULT_ERROR = 'Error getting response from server';
+ static MESSAGE_ERROR = 'Wrong error format from server';
+}
+
export class GraphColors {
public static NOT_CERTIFIED_LINK = 'rgb(218,31,61)';
public static VL_LINK = 'rgb(216,216,216)';
diff --git a/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view-model.ts b/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view-model.ts
index 37b9b9db9c..f77a29b003 100644
--- a/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view-model.ts
+++ b/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view-model.ts
@@ -22,6 +22,7 @@
import {IUserProperties} from "app/models";
import {MenuItemGroup, MenuItem} from "app/utils";
import {CacheService} from "app/services";
+declare var PunchOutRegistry;
export class BreadcrumbsMenuItem {
key:string;
@@ -48,7 +49,7 @@ export interface IOnboardVendorViewModelScope extends ng.IScope {
topNavRootMenu:MenuItemGroup;
user:IUserProperties;
version:string;
- isLoading: boolean;
+ isLoading:boolean;
}
export class OnboardVendorViewModel {
@@ -66,10 +67,13 @@ export class OnboardVendorViewModel {
this.$scope.isLoading = true;
- $.getScript("/onboarding/punch-outs_en.js", () => {
+ PunchOutRegistry.loadOnBoarding(()=> {
this.$scope.isLoading = false;
});
+ this.initScope();
+ }
+ private initScope = ():void => {
this.$scope.vendorData = {
breadcrumbs: {
selectedKeys: []
@@ -89,6 +93,7 @@ export class OnboardVendorViewModel {
this.$scope.topNavMenuModel = [];
this.$scope.user = this.cacheService.get('user');
+
}
updateBreadcrumbsPath = (selectedKeys:Array<string>):ng.IPromise<boolean> => {
@@ -140,6 +145,7 @@ export class OnboardVendorViewModel {
let topNavRootMenu = topNavMenuModel[0];
let onboardItem = topNavRootMenu.menuItems[topNavRootMenu.selectedIndex];
let originalCallback = onboardItem.callback;
+ //noinspection TypeScriptValidateTypes
onboardItem.callback = (...args) => {
let ret = this.updateBreadcrumbsPath([]);
return originalCallback && originalCallback.apply(undefined, args) || ret;
diff --git a/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view.html b/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view.html
index 56a36863e1..eec7c4758d 100644
--- a/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view.html
+++ b/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view.html
@@ -1,6 +1,6 @@
<div class="sdc-catalog-container">
- <loader ng-init="isLoading=true" data-display="isLoading"></loader>
+ <loader data-display="isLoading"></loader>
<div class="w-sdc-main-container">
<punch-out name="'onboarding/vendor'" data="vendorData" user="user" on-event="onVendorEvent"></punch-out>
</div>
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/activity-log/activity-log.ts b/catalog-ui/src/app/view-models/workspace/tabs/activity-log/activity-log.ts
index f4ce1d8bc4..5d22d65f52 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/activity-log/activity-log.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/activity-log/activity-log.ts
@@ -54,7 +54,6 @@ export class ActivityLogViewModel {
this.initScope();
this.$scope.setValidState(true);
this.initSortedTableScope();
- this.$scope.updateSelectedMenuItem();
// Set default sorting
this.$scope.sortBy = 'logDate';
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/attributes/attributes-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/attributes/attributes-view-model.ts
index ce7296cf04..312a663e8f 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/attributes/attributes-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/attributes/attributes-view-model.ts
@@ -53,7 +53,6 @@ export class AttributesViewModel {
private ComponentServiceNg2: ComponentServiceNg2) {
this.initComponentAttributes();
- this.$scope.updateSelectedMenuItem();
}
private initComponentAttributes = () => {
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/composition/composition-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/composition/composition-view-model.ts
index 0e5a5fcd6c..4b9dd6fc00 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/composition/composition-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/composition-view-model.ts
@@ -47,6 +47,7 @@ export interface ICompositionViewModelScope extends IWorkspaceViewModelScope {
onBackgroundClick():void;
setSelectedInstance(componentInstance:ComponentInstance):void;
printScreen():void;
+ isPNF():boolean;
cacheComponentsInstancesFullData:Component;
}
@@ -90,7 +91,6 @@ export class CompositionViewModel {
this.$scope.setValidState(true);
this.initScope();
this.initGraphData();
- this.$scope.updateSelectedMenuItem();
this.registerGraphEvents(this.$scope);
}
@@ -242,7 +242,10 @@ export class CompositionViewModel {
this.$scope.setComponent(this.$scope.currentComponent);
this.$scope.updateSelectedComponent();
};
-
+
+ this.$scope.isPNF = (): boolean => {
+ return this.$scope.selectedComponent.isResource() && (<Resource>this.$scope.selectedComponent).resourceType === ResourceType.PNF;
+ };
this.eventListenerService.registerObserverCallback(EVENTS.ON_CHECKOUT, this.$scope.reload);
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model.ts
index c4c63fae06..f0c8b1d86b 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model.ts
@@ -249,7 +249,6 @@ export class ResourceArtifactsViewModel {
this.$scope.isLoading = false;
this.$scope.artifactType = this.artifactsUtils.getArtifactTypeByState(this.$state.current.name);
- this.loadArtifacts();
this.$scope.getTitle = ():string => {
return this.artifactsUtils.getTitle(this.$scope.artifactType, this.$scope.currentComponent);
};
@@ -335,5 +334,7 @@ export class ResourceArtifactsViewModel {
this.eventListenerService.unRegisterObserver(GRAPH_EVENTS.ON_NODE_SELECTED, this.loadArtifacts);
this.eventListenerService.unRegisterObserver(GRAPH_EVENTS.ON_GRAPH_BACKGROUND_CLICKED, this.loadArtifacts);
});
+
+ this.loadArtifacts();
}
}
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.ts
index 6990ad7241..86bc478048 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.ts
@@ -74,7 +74,6 @@ export class DeploymentArtifactsViewModel {
private ModalsHandler:ModalsHandler,
private ComponentServiceNg2: ComponentServiceNg2) {
this.initScope();
- this.$scope.updateSelectedMenuItem();
}
private initDescriptions = ():void => {
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/deployment/deployment-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/deployment/deployment-view-model.ts
index 76be6c1141..feda7fe17f 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/deployment/deployment-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/deployment/deployment-view-model.ts
@@ -86,7 +86,6 @@ export class DeploymentViewModel {
this.$scope.setValidState(true);
this.initScope();
this.initGraphData();
- this.$scope.updateSelectedMenuItem();
}
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/distribution/distribution-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/distribution/distribution-view-model.ts
index 1852b6a83e..663361cd85 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/distribution/distribution-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/distribution/distribution-view-model.ts
@@ -48,7 +48,6 @@ export class DistributionViewModel {
private ModalsHandler:ModalsHandler) {
this.initScope();
this.$scope.setValidState(true);
- this.$scope.updateSelectedMenuItem();
}
private initScope = ():void => {
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
index 1dc326a7c0..98539d6a3b 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
@@ -118,7 +118,6 @@ export class GeneralViewModel {
this.initScopeValidation();
this.initScopeMethods();
this.initScope();
- this.$scope.updateSelectedMenuItem();
}
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/information-artifacts/information-artifacts-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/information-artifacts/information-artifacts-view-model.ts
index ceaba3c187..b2fd4d68c0 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/information-artifacts/information-artifacts-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/information-artifacts/information-artifacts-view-model.ts
@@ -65,7 +65,6 @@ export class InformationArtifactsViewModel {
private ModalsHandler:ModalsHandler,
private ComponentServiceNg2: ComponentServiceNg2) {
this.initInformationalArtifacts();
- this.$scope.updateSelectedMenuItem();
}
private initInformationalArtifacts = ():void => {
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model.ts
index 78865ac873..2e871a5f8d 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model.ts
@@ -45,7 +45,6 @@ export class ResourceInputsViewModel {
constructor(private $scope:IInputsViewModelScope, private $q:ng.IQService, private ModalsHandler:ModalsHandler) {
this.initScope();
- this.$scope.updateSelectedMenuItem();
}
private initScope = ():void => {
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs-view-model.ts
index 013a0023f9..00f3347b74 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs-view-model.ts
@@ -62,7 +62,6 @@ export class ServiceInputsViewModel {
private ModalsHandler:ModalsHandler,
private DataTypesService:DataTypesService) {
this.initScope();
- this.$scope.updateSelectedMenuItem();
this.$scope.isViewOnly = this.$scope.isViewMode();
}
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view-model.ts
index f8b29c4a9c..e44ed12c2a 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view-model.ts
@@ -18,130 +18,137 @@
* ============LICENSE_END=========================================================
*/
- 'use strict';
- import {ArtifactType} from "app/utils";
- import {ArtifactGroupModel} from "app/models";
- import {participant} from "app/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model";
- import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model";
- import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response";
- import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service";
+'use strict';
+import {ArtifactType} from "app/utils";
+import {ArtifactGroupModel} from "app/models";
+import {participant} from "app/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model";
+import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model";
+import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response";
+import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service";
+declare var PunchOutRegistry;
- export interface IManagementWorkflowViewModelScope extends IWorkspaceViewModelScope {
- vendorModel:VendorModel;
- }
+export interface IManagementWorkflowViewModelScope extends IWorkspaceViewModelScope {
+ vendorModel:VendorModel;
+ isLoading: boolean;
+}
- export class VendorModel {
- artifacts: ArtifactGroupModel;
- serviceID: string;
- readonly: boolean;
- sessionID: string;
- requestID: string;
- diagramType: string;
- participants:Array<participant>;
+export class VendorModel {
+ artifacts:ArtifactGroupModel;
+ serviceID:string;
+ readonly:boolean;
+ sessionID:string;
+ requestID:string;
+ diagramType:string;
+ participants:Array<participant>;
- constructor(artifacts: ArtifactGroupModel, serviceID:string, readonly:boolean, sessionID:string,
- requestID:string, diagramType:string, participants:Array<participant>){
- this.artifacts = artifacts;
- this.serviceID = serviceID;
- this.readonly = readonly;
- this.sessionID = sessionID;
- this.requestID = requestID;
- this.diagramType = diagramType;
- this.participants = participants;
- }
+ constructor(artifacts:ArtifactGroupModel, serviceID:string, readonly:boolean, sessionID:string,
+ requestID:string, diagramType:string, participants:Array<participant>) {
+ this.artifacts = artifacts;
+ this.serviceID = serviceID;
+ this.readonly = readonly;
+ this.sessionID = sessionID;
+ this.requestID = requestID;
+ this.diagramType = diagramType;
+ this.participants = participants;
}
+}
+
+export class ManagementWorkflowViewModel {
- export class ManagementWorkflowViewModel {
+ static '$inject' = [
+ '$scope',
+ 'uuid4',
+ 'ComponentServiceNg2'
+ ];
- static '$inject' = [
- '$scope',
- 'uuid4',
- 'ComponentServiceNg2'
- ];
+ constructor(private $scope:IManagementWorkflowViewModelScope,
+ private uuid4:any,
+ private ComponentServiceNg2:ComponentServiceNg2) {
- constructor(private $scope:IManagementWorkflowViewModelScope,
- private uuid4:any,
- private ComponentServiceNg2: ComponentServiceNg2) {
+ this.$scope.isLoading = true;
+ PunchOutRegistry.loadOnBoarding(()=> {
+ this.$scope.isLoading = false;
this.initInformationalArtifacts();
- this.$scope.updateSelectedMenuItem();
- }
+ });
+ }
- private initInformationalArtifacts = ():void => {
- if(!this.$scope.component.artifacts) {
- this.$scope.isLoading = true;
- this.ComponentServiceNg2.getComponentInformationalArtifacts(this.$scope.component).subscribe((response:ComponentGenericResponse) => {
- this.$scope.component.artifacts = response.artifacts;
- this.initScope();
- this.$scope.isLoading = false;
- });
- } else {
+ private initInformationalArtifacts = ():void => {
+ if (!this.$scope.component.artifacts) {
+ this.$scope.isLoading = true;
+ this.ComponentServiceNg2.getComponentInformationalArtifacts(this.$scope.component).subscribe((response:ComponentGenericResponse) => {
+ this.$scope.component.artifacts = response.artifacts;
this.initScope();
- }
+ this.$scope.isLoading = false;
+ });
+ } else {
+ this.initScope();
}
+ }
- private static getParticipants():Array<participant> {
- return [
- {
- "id": "1",
- "name": "Customer"},
- {
- "id": "2",
- "name": "CCD"
- },
- {
- "id": "3",
- "name": "Infrastructure"
- },
- {
- "id": "4",
- "name": "MSO"
- },
- {
- "id": "5",
- "name": "SDN-C"
- },
- {
- "id": "6",
- "name": "A&AI"
- },
- {
- "id": "7",
- "name": "APP-C"
- },
- {
- "id": "8",
- "name": "Cloud"
- },
- {
- "id": "9",
- "name": "DCAE"
- },
- {
- "id": "10",
- "name": "ALTS"
- },
- {
- "id": "11",
- "name": "VF"
- }
- ]
- }
+ private static getParticipants():Array<participant> {
+ return [
+ {
+ "id": "1",
+ "name": "Customer"
+ },
+ {
+ "id": "2",
+ "name": "CCD"
+ },
+ {
+ "id": "3",
+ "name": "Infrastructure"
+ },
+ {
+ "id": "4",
+ "name": "MSO"
+ },
+ {
+ "id": "5",
+ "name": "SDN-C"
+ },
+ {
+ "id": "6",
+ "name": "A&AI"
+ },
+ {
+ "id": "7",
+ "name": "APP-C"
+ },
+ {
+ "id": "8",
+ "name": "Cloud"
+ },
+ {
+ "id": "9",
+ "name": "DCAE"
+ },
+ {
+ "id": "10",
+ "name": "ALTS"
+ },
+ {
+ "id": "11",
+ "name": "VF"
+ }
+ ]
+ }
- private initScope():void {
- this.$scope.vendorModel = new VendorModel(
- this.$scope.component.artifacts.filteredByType(ArtifactType.THIRD_PARTY_RESERVED_TYPES.WORKFLOW),
- this.$scope.component.uniqueId,
- this.$scope.isViewMode(),
- this.$scope.user.userId,
- this.uuid4.generate(),
- ArtifactType.THIRD_PARTY_RESERVED_TYPES.WORKFLOW,
- ManagementWorkflowViewModel.getParticipants()
- );
+ private initScope():void {
+ this.$scope.vendorModel = new VendorModel(
+ this.$scope.component.artifacts.filteredByType(ArtifactType.THIRD_PARTY_RESERVED_TYPES.WORKFLOW),
+ this.$scope.component.uniqueId,
+ this.$scope.isViewMode(),
+ this.$scope.user.userId,
+ this.uuid4.generate(),
+ ArtifactType.THIRD_PARTY_RESERVED_TYPES.WORKFLOW,
+ ManagementWorkflowViewModel.getParticipants()
+ );
- this.$scope.thirdParty = true;
- this.$scope.setValidState(true);
- }
+ this.$scope.thirdParty = true;
+ this.$scope.setValidState(true);
}
+}
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view.html b/catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view.html
index bd196daec8..df570ccdca 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view.html
+++ b/catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view.html
@@ -1,3 +1,4 @@
-<div class="workspace-management-workflow">
- <punch-out name="'sequence-diagram'" data="vendorModel" user="user" on-event="onVendorEvent"></punch-out>
+<loader data-display="isLoading"></loader>
+<div class="workspace-management-workflow" ng-if="vendorModel">
+ <punch-out name="'sequence-diagram'" data="vendorModel" user="user" on-event="onVendorEvent"></punch-out>
</div>
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model.ts
index 6c7666d28c..488e4c774d 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model.ts
@@ -25,9 +25,11 @@ import {ResourceType, ArtifactType} from "app/utils";
import {ComponentInstance} from "app/models";
import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response";
import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service";
+declare var PunchOutRegistry;
export interface INetworkCallFlowViewModelScope extends IWorkspaceViewModelScope {
vendorMessageModel:VendorModel;
+ isLoading: boolean;
}
export class participant {
@@ -53,8 +55,12 @@ export class NetworkCallFlowViewModel {
private uuid4:any,
private ComponentServiceNg2: ComponentServiceNg2) {
- this.initComponentInstancesAndInformationalArtifacts();
- this.$scope.updateSelectedMenuItem();
+ this.$scope.isLoading = true;
+
+ PunchOutRegistry.loadOnBoarding(()=> {
+ this.$scope.isLoading = false;
+ this.initComponentInstancesAndInformationalArtifacts();
+ });
}
private getVFParticipantsFromInstances(instances:Array<ComponentInstance>):Array<participant> {
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view.html b/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view.html
index 6ce3e8e2b7..bc2d0643e0 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view.html
+++ b/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view.html
@@ -1,3 +1,4 @@
-<div class="workspace-network-call-flow">
+<loader data-display="isLoading"></loader>
+<div ng-if="vendorMessageModel" class="workspace-network-call-flow">
<punch-out name="'sequence-diagram'" data="vendorMessageModel" user="user" on-event="onVendorEvent"></punch-out>
</div>
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view-model.ts
index c9f2d0725f..3c9c7e9e4b 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view-model.ts
@@ -52,7 +52,6 @@ export class PropertiesViewModel {
private ModalsHandler:ModalsHandler,
private ComponentServiceNg2:ComponentServiceNg2) {
this.initComponentProperties();
- this.$scope.updateSelectedMenuItem();
}
private initComponentProperties = ():void => {
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model.ts
index c02900a413..b6cbf65cf0 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model.ts
@@ -67,7 +67,6 @@ export class ReqAndCapabilitiesViewModel {
private ComponentServiceNg2: ComponentServiceNg2) {
this.initCapabilitiesAndRequirements();
- this.$scope.updateSelectedMenuItem();
}
private initCapabilitiesAndRequirements = (): void => {
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model.ts
index 5f724c48fd..77b5ab74eb 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model.ts
@@ -50,7 +50,6 @@ export class ToscaArtifactsViewModel {
private $filter:ng.IFilterService,
private ComponentServiceNg2:ComponentServiceNg2) {
this.initToscaArtifacts();
- this.$scope.updateSelectedMenuItem();
}
private initToscaArtifacts = (): void => {
diff --git a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
index f529e79fa7..97a58402de 100644
--- a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
@@ -87,7 +87,7 @@ export interface IWorkspaceViewModelScope extends ng.IScope {
getLatestVersion():void;
getStatus():string;
showLifecycleIcon():boolean;
- updateSelectedMenuItem():void;
+ updateSelectedMenuItem(state:string):void;
uploadFileChangedInGeneralTab():void;
updateMenuComponentName(ComponentName:string):void;
getTabTitle():string;
@@ -136,6 +136,7 @@ export class WorkspaceViewModel {
this.initScope();
this.initAfterScope();
+ this.$scope.updateSelectedMenuItem(this.$state.current.name);
}
private role:string;
@@ -216,6 +217,7 @@ export class WorkspaceViewModel {
this.$scope.onMenuItemPressed = (state:string):ng.IPromise<boolean> => {
let deferred = this.$q.defer();
let goToState = ():void => {
+ this.$scope.updateSelectedMenuItem(state);
this.$state.go(state, {
id: this.$scope.component.uniqueId,
type: this.$scope.component.componentType.toLowerCase(),
@@ -613,9 +615,9 @@ export class WorkspaceViewModel {
return result;
};
- this.$scope.updateSelectedMenuItem = ():void => {
+ this.$scope.updateSelectedMenuItem = (state:string):void => {
let selectedItem:MenuItem = _.find(this.$scope.leftBarTabs.menuItems, (item:MenuItem) => {
- return item.state === this.$state.current.name;
+ return item.state === state;
});
this.$scope.leftBarTabs.selectedIndex = selectedItem ? this.$scope.leftBarTabs.menuItems.indexOf(selectedItem) : 0;
};
diff --git a/catalog-ui/src/assets/styles/app.less b/catalog-ui/src/assets/styles/app.less
index fde4cc8888..c19ace5823 100644
--- a/catalog-ui/src/assets/styles/app.less
+++ b/catalog-ui/src/assets/styles/app.less
@@ -8,6 +8,7 @@
@import 'mixins.less';
@import 'mixins_old.less';
@import 'global.less';
+@import '../../../node_modules/sdc-ui/css/style.css';
@import 'sprite-old.less';
@import 'sprite.less';
@@ -33,7 +34,6 @@
@import 'tooltips.less';
@import 'welcome-sprite.less';
@import 'welcome-style.less';
-@import 'sdc-ui.css';
@import 'notification-template.less';
// Less insides specific files.
diff --git a/catalog-ui/src/assets/styles/sdc-ui.css b/catalog-ui/src/assets/styles/sdc-ui.css
deleted file mode 100644
index ad96e7762a..0000000000
--- a/catalog-ui/src/assets/styles/sdc-ui.css
+++ /dev/null
@@ -1,361 +0,0 @@
-@charset "UTF-8";
-/* Colors */
-.sdc-bc-blue {
- background-color: #009fdb; }
-
-.sdc-bc-dark-blue {
- background-color: #0568ae; }
-
-.sdc-bc-light-blue {
- background-color: #71c5e8; }
-
-.sdc-bc-green {
- background-color: #4ca90c; }
-
-.sdc-bc-dark-green {
- background-color: #007a3e; }
-
-.sdc-bc-light-green {
- background-color: #b5bd00; }
-
-.sdc-bc-orange {
- background-color: #ea7400; }
-
-.sdc-bc-yellow {
- background-color: #ffb81c; }
-
-.sdc-bc-dark-purple {
- background-color: #702f8a; }
-
-.sdc-bc-purple {
- background-color: #9063cd; }
-
-.sdc-bc-light-purple {
- background-color: #caa2dd; }
-
-.sdc-bc-black {
- background-color: #000000; }
-
-.sdc-bc-dark-gray {
- background-color: #5a5a5a; }
-
-.sdc-bc-gray {
- background-color: #959595; }
-
-.sdc-bc-light-gray {
- background-color: #d2d2d2; }
-
-.sdc-bc-white {
- background-color: #ffffff; }
-
-/* Prefix */
-/* Value Prefix*/
-/* Box sizing */
-/* Borders & Shadows */
-/* Opacity */
-/* Ellipsis */
-/* Vertical placement of multuple lines of text */
-/* transform-rotate */
-/* transform-translate */
-/* transform-scale */
-/**/
-/**/
-/*body {*/
- /*-webkit-touch-callout: none;*/
- /*-webkit-user-select: none;*/
- /*-moz-user-select: none;*/
- /*-ms-user-select: none;*/
- /*user-select: none; }*/
-
-html {
- font-size: 100%;
- height: 100%; }
-
-body {
- /* scrollbar styling for Internet Explorer */
- scrollbar-face-color: #191919;
- scrollbar-track-color: #191919;
- height: 100%; }
-
-/* scrollbar styling for Google Chrome | Safari | Opera */
-::-webkit-scrollbar {
- width: 8px;
- height: 8px; }
-
-::-webkit-scrollbar-track {
- background-color: transparent;
- border-radius: 10px; }
-
-::-webkit-scrollbar-thumb {
- border-radius: 10px;
- background-color: #d2d2d2;
- border-right: 2px solid #ffffff; }
-
-/* Mozilla Firefox currently doesn't support scrollbar styling */
-ul {
- list-style: none; }
-
-h1, h2, h3, h4, h5, h6, ul {
- margin: 0;
- padding: 0; }
-
-.disabled {
- opacity: 0.7 !important; }
-
-fieldset {
- border: none; }
-
-fieldset label {
- display: inline-block; }
-
-.nav-tabs > li > a:focus,
-.btn:focus,
-.btn:active:focus,
-.btn.active:focus {
- outline: none; }
-
-/* Fonts */
-.text-lowercase {
- text-transform: lowercase; }
-
-.text-uppercase, .heading-3-light, .heading-3, .heading-3-medium {
- text-transform: uppercase; }
-
-.text-capitalize {
- text-transform: capitalize; }
-
-.heading-1 {
- font-weight: 300;
- font-size: 36px; }
-
-.heading-2 {
- font-weight: 300;
- font-size: 24px; }
-
-.heading-3-light {
- font-weight: 300;
- font-size: 20px; }
-
-.heading-3 {
- font-weight: 400;
- font-size: 20px; }
-
-.heading-3-medium {
- font-weight: 600;
- font-size: 20px; }
-
-.heading-4 {
- font-weight: 400;
- font-size: 18px; }
-
-.heading-4-medium {
- font-weight: 600;
- font-size: 18px; }
-
-.heading-5 {
- font-weight: 400;
- font-size: 16px; }
-
-.heading-5-medium, .catalog-tile .catalog-tile-top .catalog-tile-item-name, .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info .sdc-tile-content-info-item-name {
- font-weight: 400;
- line-height: 16px;
- font-size: 14px; }
-
-.body-1 {
- font-weight: 400;
- font-size: 14px; }
-
-.body-1-medium {
- font-weight: 600;
- font-size: 14px; }
-
-.body-1-light {
- font-weight: 300;
- font-size: 14px; }
-
-.body-2, .catalog-tile .catalog-tile-top .catalog-tile-entity-details .catalog-tile-version-info .catalog-tile-item-version, .catalog-tile .catalog-tile-content .catalog-tile-locking-user-name, .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info .sdc-tile-content-info-version-info .sdc-tile-content-info-version-info-text, .sdc-tile-catalog .sdc-tile-footer .sdc-tile-footer-text {
- font-weight: 400;
- font-size: 12px; }
-
-.body-2-medium, .catalog-tile .catalog-tile-content {
- font-weight: 600;
- font-size: 13px; }
-
-.body-3 {
- font-weight: 400;
- font-size: 12px; }
-
-.body-3-medium, .catalog-tile .catalog-tile-top .catalog-tile-entity-details .catalog-tile-vendor-name, .catalog-tile.vendor-type .catalog-tile-top .catalog-tile-vsp-count, .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info .sdc-tile-content-info-vendor-name {
- font-weight: 600;
- font-size: 12px; }
-
-.body-3-light {
- font-weight: 300;
- font-size: 12px; }
-
-.circle-icon-text {
- font-weight: 600;
- font-size: 14px; }
-
-.sdc-icon {
- display: inline-block;
- text-rendering: auto;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- width: 16px;
- height: 16px; }
-
-.sdc-icon-locked {
- background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='15' viewBox='0 0 11 15' id='locked_icon'> <metadata><?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?><x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Adobe XMP Core 5.6-c138 79.159824, 2016/09/14-01:09:01 '> <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <rdf:Description rdf:about=''/> </rdf:RDF></x:xmpmeta><?xpacket end='w'?></metadata><defs> <style> .cls-1 { fill: #959595; fill-rule: evenodd; } </style> </defs> <path id='Shape_77_copy_10' data-name='Shape 77 copy 10' class='cls-1' d='M445,359a16.71,16.71,0,0,0-2.1-.009c-1.945.045-3.195,0.049-3.9,0.009v-5a1.743,1.743,0,0,1,2-2h1a1.743,1.743,0,0,1,2,2v5c0.474,0.063.343-.073,1,0,0.266,0.029,0,.279,0,0v-5a2.726,2.726,0,0,0-3-3h-1.142c-1.72-.125-2.715,1.562-2.858,3,0.088,0.009,0,7.338,0,5h0a1.891,1.891,0,0,0-2,1.689v3.461A1.823,1.823,0,0,0,437.775,366h7.448A1.823,1.823,0,0,0,447,364.15v-3.461A2.018,2.018,0,0,0,445,359Z' transform='translate(-436 -351)'/></svg>");
- background-repeat: no-repeat; }
-
-.sdc-icon-plus {
- background-image: url("data:image/svg+xml;utf8,<?xml version='1.0' encoding='utf-8'?><!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --><svg version='1.1' id='plus_icon' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 19 19' style='enable-background:new 0 0 19 19;' xml:space='preserve'><g><rect y='8' width='19' height='3'/><path id='Rectangle_2139_copy' d='M8,19V0h3v19H8z'/></g></svg>");
- background-repeat: no-repeat; }
-
-.sdc-icon-unlocked {
- background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='18' viewBox='0 0 11 18' id='unlocked_icon'> <metadata><?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?><x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Adobe XMP Core 5.6-c138 79.159824, 2016/09/14-01:09:01 '> <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <rdf:Description rdf:about=''/> </rdf:RDF></x:xmpmeta><?xpacket end='w'?></metadata><defs> <style> .cls-1 { fill: #959595; fill-rule: evenodd; } </style> </defs> <path id='Shape_77_copy_16' data-name='Shape 77 copy 16' class='cls-1' d='M663,358a16.723,16.723,0,0,0-2.1-.009c-1.944.045-3.194,0.049-3.9,0.009v-7a1.743,1.743,0,0,1,2-2h1a1.743,1.743,0,0,1,2,2v2c0.474,0.064.343-.073,1,0,0.266,0.029,0,.279,0,0v-2a2.726,2.726,0,0,0-3-3h-1.142c-1.72-.125-2.715,1.562-2.858,3,0.088,0.009,0,9.338,0,7h0a1.891,1.891,0,0,0-2,1.689v4.461a1.823,1.823,0,0,0,1.775,1.85h7.448A1.823,1.823,0,0,0,665,364.15v-4.461A2.018,2.018,0,0,0,663,358Zm1.05,6.15a0.827,0.827,0,0,1-.8.836H655.8a0.827,0.827,0,0,1-.8-0.836l0-4.15a1.164,1.164,0,0,1,.8-1.147h7.448A1.129,1.129,0,0,1,664,360Z' transform='translate(-654 -348)'/></svg>");
- background-repeat: no-repeat; }
-
-.sdc-icon-vendor {
- background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 53 47' id='vendor_icon'><title>vendor</title><g id='Layer_2' data-name='Layer 2'><g id='vlm_icon' data-name='vlm icon'><path d='M49,7,38.5,7V5.92A5.92,5.92,0,0,0,32.58,0H20.42A5.92,5.92,0,0,0,14.5,5.92V7.15L4,7.2a3.8,3.8,0,0,0-4,3.5V43.5C0,45.4,2,47,4.2,47L49,46.8a3.8,3.8,0,0,0,4-3.5V10.5A3.8,3.8,0,0,0,49,7ZM16.5,5.92A3.92,3.92,0,0,1,20.42,2H32.58A3.92,3.92,0,0,1,36.5,5.92V7.06l-20,.09ZM2,10.8A1.9,1.9,0,0,1,4,9l45-.2a1.9,1.9,0,0,1,2,1.8v8.87L32.94,24.18a6.49,6.49,0,0,0-12.89,0L2,19.51V10.8ZM31,25a4.5,4.5,0,1,1-4.5-4.5A4.5,4.5,0,0,1,31,25ZM49,45,4,45.2A1.9,1.9,0,0,1,2,43.4V21.57l18.13,4.73a6.5,6.5,0,0,0,12.74,0L51,21.53V43.21A1.9,1.9,0,0,1,49,45Z'/></g></g></svg>");
- background-repeat: no-repeat; }
-
-.sdc-icon-vlm {
- background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 45 53'><title>vlm_new_icon</title><g id='Layer_2' data-name='Layer 2'><g id='vlm_icon' data-name='vlm icon'><path d='M41,2a2,2,0,0,1,2,2l.19,45a2,2,0,0,1-2,2H4a2,2,0,0,1-2-2L1.81,4a2,2,0,0,1,2-2H41m-.15-2H4A4.2,4.2,0,0,0,0,4.24L.19,49a4,4,0,0,0,4,4H41a4,4,0,0,0,4-4L44.81,4a4,4,0,0,0-4-4Z'/><rect x='14' y='11' width='17' height='2'/><rect x='14' y='18' width='10' height='2'/><polygon points='20.56 38.85 13.87 33.14 15.16 31.62 20.39 36.08 29.08 26.63 30.55 27.98 20.56 38.85'/></g></g></svg>");
- background-repeat: no-repeat; }
-
-.sdc-icon-vsp {
- background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 59.5 40' id='vsp_icon'><title>vsp_new_icon</title><g id='Layer_2' data-name='Layer 2'><g id='vlm_icon' data-name='vlm icon'><path d='M58.28,30.74c-1.49-1.82-3-2.7-4.67-2.74a8.5,8.5,0,0,0-16.22-2.44,6.93,6.93,0,0,0-4.06.66A7.23,7.23,0,0,0,36.42,40H53.5a6,6,0,0,0,6-6A5.18,5.18,0,0,0,58.28,30.74ZM53.5,38H36.42a5.25,5.25,0,0,1-5.21-5.91,5.32,5.32,0,0,1,3-4.06,5,5,0,0,1,2.21-.53,5.25,5.25,0,0,1,1.35.18l.92.24L39,27A6.5,6.5,0,0,1,51.67,29v1.3l1.17-.2c1-.17,2.17-.17,3.91,2a3.18,3.18,0,0,1,.76,2A4,4,0,0,1,53.5,38Z'/><path d='M49,0,4,.17A3.79,3.79,0,0,0,0,3.69V7.94H0v2H0V36.31C0,38.35,2,40,4.25,40l20.84-.08a1,1,0,0,0,0-1.92L4,38.08a1.89,1.89,0,0,1-2-1.76V10H51v7a1,1,0,0,0,2,0V3.53A3.79,3.79,0,0,0,49,0ZM2,8V3.76A1.89,1.89,0,0,1,4,2l45-.16a1.89,1.89,0,0,1,2,1.76V8Z'/></g></g></svg>");
- background-repeat: no-repeat; }
-
-.svg-icon.purple {
- fill: #9063cd; }
-
-.svg-icon.purple-hover {
- fill: #9063cd; }
- .svg-icon.purple-hover:hover {
- fill: #caa2dd; }
-
-.svg-icon.blue {
- fill: #009fdb; }
-
-.svg-icon.blue-hover {
- fill: #009fdb; }
- .svg-icon.blue-hover:hover {
- fill: #71c5e8; }
-
-.svg-icon.gray {
- fill: #959595; }
-
-.svg-icon.gray-hover {
- fill: #000000; }
- .svg-icon.gray-hover:hover {
- fill: #d2d2d2; }
-
-.svg-icon.black {
- fill: #000000; }
-
-.svg-icon.black-hover {
- fill: #000000; }
- .svg-icon.black-hover:hover {
- fill: #d2d2d2; }
-
-.sdc-tile, .sdc-tile-catalog {
- box-sizing: border-box;
- background-color: #ffffff;
- display: flex;
- flex-direction: column;
- padding: 10px;
- cursor: pointer;
- border: 1px solid #eaeaea;
- -webkit-box-shadow: 0.5px 0.8px 4px 0 rgba(24, 24, 25, 0.05);
- -moz-box-shadow: 0.5px 0.8px 4px 0 rgba(24, 24, 25, 0.05);
- box-shadow: 0.5px 0.8px 4px 0 rgba(24, 24, 25, 0.05); }
- .sdc-tile:active, .sdc-tile-catalog:active {
- border: 1px solid #71c5e8; }
- .sdc-tile:hover, .sdc-tile-catalog:hover {
- box-shadow: 0.3px 5px 12.8px 1.3px rgba(24, 24, 25, 0.15);
- border: 1px solid #d2d2d2; }
- .sdc-tile .sdc-tile-header, .sdc-tile-catalog .sdc-tile-header {
- position: relative;
- flex-shrink: 0;
- display: flex;
- align-items: flex-start;
- flex-direction: column; }
- .sdc-tile .sdc-tile-content, .sdc-tile-catalog .sdc-tile-content {
- position: relative;
- flex: 1;
- display: flex;
- align-items: flex-start;
- flex-direction: column;
- overflow: auto;
- justify-content: space-between; }
- .sdc-tile .sdc-tile-footer, .sdc-tile-catalog .sdc-tile-footer {
- position: relative;
- flex-shrink: 0;
- display: flex;
- align-items: flex-start;
- flex-direction: column; }
-
-.sdc-tile-catalog {
- width: 204px;
- height: 200px; }
- .sdc-tile-catalog .sdc-tile-header {
- line-height: 16px; }
- .sdc-tile-catalog .sdc-tile-header .sdc-tile-header-type {
- font-size: 14px;
- text-transform: uppercase; }
- .sdc-tile-catalog .sdc-tile-header .sdc-tile-header-type.purple {
- color: #9063cd; }
- .sdc-tile-catalog .sdc-tile-header .sdc-tile-header-type.blue {
- color: #009fdb; }
- .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-icon {
- align-items: center;
- display: flex;
- flex-direction: column;
- width: 100%;
- padding-top: 25px; }
- .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-icon svg {
- width: 60px;
- height: 40px; }
- .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info {
- padding-bottom: 4px;
- width: 180px;
- overflow: hidden;
- text-overflow: ellipsis;
- width: auto;
- white-space: nowrap;
- display: inline-block;
- max-width: 178px; }
- .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info .sdc-tile-content-info-vendor-name {
- color: #959595;
- line-height: 12px; }
- .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info .sdc-tile-content-info-item-name {
- color: #191919; }
- .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info .sdc-tile-content-info-version-info {
- display: flex;
- justify-content: space-between; }
- .sdc-tile-catalog .sdc-tile-footer {
- display: flex;
- flex-direction: row;
- border-top: 1px solid #eaeaea;
- padding: 0;
- width: 180px;
- height: 20px; }
- .sdc-tile-catalog .sdc-tile-footer .sdc-tile-footer-text {
- flex: 1;
- padding-top: 5px;
- overflow: hidden;
- text-overflow: ellipsis;
- width: auto;
- white-space: nowrap;
- display: inline-block;
- max-width: 164px; }
- .sdc-tile-catalog .sdc-tile-footer .sdc-tile-footer-icon {
- flex-shrink: 1;
- overflow: hidden;
- padding-top: 5px; }
- .sdc-tile-catalog .sdc-tile-footer .sdc-tile-footer-icon svg {
- width: 16px;
- height: 20px; }
diff --git a/catalog-ui/src/index.html b/catalog-ui/src/index.html
index 3a66d4da45..044eb374a6 100644
--- a/catalog-ui/src/index.html
+++ b/catalog-ui/src/index.html
@@ -19,7 +19,7 @@
<script src="/sdc1/scripts/inline.bundle.js"></script>
<script src="/sdc1/scripts/polyfills.bundle.js"></script>
<script src="/sdc1/scripts/vendor.bundle.js"></script>
-<script src="/dcae/dcae-bundle.js" async></script>
+<script src="/dcae/dcae-bundle.js"></script>
<script id="main-bundle" src="/sdc1/scripts/main.bundle.js"></script>
<script src="/sdc1/scripts/styles.bundle.js"></script>
diff --git a/catalog-ui/src/third-party/PunchOutRegistry.js b/catalog-ui/src/third-party/PunchOutRegistry.js
index db8e6875d6..506a785c79 100644
--- a/catalog-ui/src/third-party/PunchOutRegistry.js
+++ b/catalog-ui/src/third-party/PunchOutRegistry.js
@@ -18,7 +18,9 @@
* ============LICENSE_END=========================================================
*/
-(function(window) {
+
+
+(function (window) {
"use strict";
if (window.PunchOutRegistry) {
@@ -29,9 +31,20 @@
var factoryPromises = new Map();
var instancePromises = new Map();
+ function loadOnBoarding(callback) {
+
+ if (factoryPromises.has("onboarding/vendor") && !queuedFactoryRequests.has("onboarding/vendor")) {
+ callback();
+ }
+ else {
+ console.log("Load OnBoarding");
+ $.getScript("/onboarding/punch-outs_en.js").then(callback);
+ }
+ }
+
function registerFactory(name, factory) {
if (factoryPromises.has(name) && !queuedFactoryRequests.has(name)) {
- console.error("PunchOut \"" + name + "\" has been already registered");
+ // console.error("PunchOut \"" + name + "\" has been already registered");
return;
}
if (queuedFactoryRequests.has(name)) {
@@ -58,7 +71,7 @@
var factoryPromise;
var instancePromise = instancePromises.get(element);
if (!instancePromise) {
- instancePromise = getFactoryPromise(name).then(function(factory) {
+ instancePromise = getFactoryPromise(name).then(function (factory) {
return factory();
});
instancePromises.set(element, instancePromise);
@@ -69,7 +82,8 @@
function renderPunchOut(params, element) {
var name = params.name;
var options = params.options || {};
- var onEvent = params.onEvent || function () {};
+ var onEvent = params.onEvent || function () {
+ };
getInstancePromise(name, element).then(function (punchOut) {
punchOut.render({options: options, onEvent: onEvent}, element);
@@ -81,7 +95,7 @@
console.error("There is no PunchOut in element", element);
return;
}
- instancePromises.get(element).then(function(punchOut) {
+ instancePromises.get(element).then(function (punchOut) {
punchOut.unmount(element);
});
instancePromises.delete(element);
@@ -90,7 +104,8 @@
var PunchOutRegistry = Object.freeze({
register: registerFactory,
render: renderPunchOut,
- unmount: unmountPunchOut
+ unmount: unmountPunchOut,
+ loadOnBoarding: loadOnBoarding
});
window.PunchOutRegistry = PunchOutRegistry;
diff --git a/catalog-ui/src/third-party/cytoscape.js-edge-editation/CytoscapeEdgeEditation.js b/catalog-ui/src/third-party/cytoscape.js-edge-editation/CytoscapeEdgeEditation.js
index 5731019ff0..0e6ca8b3c2 100644
--- a/catalog-ui/src/third-party/cytoscape.js-edge-editation/CytoscapeEdgeEditation.js
+++ b/catalog-ui/src/third-party/cytoscape.js-edge-editation/CytoscapeEdgeEditation.js
@@ -459,7 +459,8 @@
var handle = handles[i];
var position = this._getHandlePosition(handle, this._hover);
- if (VectorMath.distance(position, mousePoisition) < this.HANDLE_SIZE) {
+ var renderedHandleSize = this.HANDLE_SIZE * this._cy.zoom(); //actual number of pixels that handle uses.
+ if (VectorMath.distance(position, mousePoisition) < renderedHandleSize) {
return {
handle: handle,
position: position
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java
index 30d70cd019..367b806104 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.common.util;
import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
public class JsonUtils {
@@ -42,4 +43,16 @@ public class JsonUtils {
}
+ public static boolean containsEntry(JsonObject json, String key) {
+ return json.get(key) != null;
+ }
+
+ public static boolean isEmptyJson(JsonObject json) {
+ return json.entrySet().isEmpty();
+ }
+
+ public static boolean isEmptyJson(JsonElement json) {
+ return json.isJsonPrimitive() ? false : JsonUtils.isEmptyJson(json.getAsJsonObject());
+ }
+
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java
index 45c6b18b59..bbd05c893e 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/AndreyTest.java
@@ -55,7 +55,7 @@ public class AndreyTest {
// File path = new File("C:/Data/D2.0/TOSCA_Ex/resource-Vl11Vl10-template.yml");
// File path = new File("C:/Data/D2.0/TOSCA_Ex/service-Servicepxtc-template US822998.yml");
// File path = new File("C:/Data/FileToParse/Definitions/service-Ciservice513e6fa67d07-template.yml");
- toscaDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File("C:/Data/FileToParse/LDSA/LDSA_amdocs.csar"));
+ toscaDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File("C:/Data/FileToParse/LDSA/service-LdsaService-csar.csar"));
// File path = new File("C:/Data/FileToParse/Definitions/resource-Civfonboarded2016006VvmVvm301607E2100a9b04-template.yml");
// File csarPath = new File("C:/Data/D2.0/TOSCA_Ex/Nested.csar");
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java
index f4d9fe3f35..12f7ea327a 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/validation/AuditValidationUtils.java
@@ -659,8 +659,7 @@ public class AuditValidationUtils {
public static void compareElements(Object expectedValue, Object foundValue) {
if (expectedValue instanceof String) {
assertTrue("Actual value " + foundValue + " is not string", foundValue instanceof String);
- assertTrue("Expected " + expectedValue + " not equal to actual " + foundValue,
- foundValue.equals(expectedValue));
+ assertTrue("Expected " + "[" + expectedValue +"]" + " not equal to actual [" + foundValue + "]", foundValue.equals(expectedValue));
}
/*
* else if( expectedValue instanceof Number){ assertTrue(foundValue
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java
index 127ae54784..668508751b 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/CRUDExternalAPI.java
@@ -89,6 +89,7 @@ import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.config.EcompErrorName;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
import org.openecomp.sdc.common.util.GeneralUtility;
+import org.openecomp.sdc.common.util.ValidationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
@@ -2098,7 +2099,7 @@ public class CRUDExternalAPI extends ComponentBaseTest {
ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_LOGICAL_NAME_CANNOT_BE_CHANGED.name());
List<String> variables = asList();
- artifactReqDetails.setArtifactLabel("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
+ artifactReqDetails.setArtifactLabel("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
if(componentInstance != null) {
updateArtifactOfAssetIncludingValiditionOfAuditAndResponseCode(component, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
@@ -2166,8 +2167,8 @@ public class CRUDExternalAPI extends ComponentBaseTest {
}
}
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_LOGICAL_NAME_CANNOT_BE_CHANGED.name());
- List<String> variables = asList();
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.EXCEEDS_LIMIT.name());
+ List<String> variables = asList("artifact description", ValidationUtils.ARTIFACT_DESCRIPTION_MAX_LENGTH.toString());
artifactReqDetails.setDescription("invalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeinvalGGfdsiofhdsouhfoidshfoidshoifhsdoifhdsouihfdsofhiufdsghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidTypeghiufghodhfioudsgafodsgaiofudsghifudsiugfhiufawsouipfhgawseiupfsadiughdfsoiuhgfaighfpasdghfdsaqgfdsgdfgidType");
if(componentInstance != null) {
@@ -2202,7 +2203,8 @@ public class CRUDExternalAPI extends ComponentBaseTest {
}
- ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_LOGICAL_NAME_CANNOT_BE_CHANGED.name());
+// ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.ARTIFACT_LOGICAL_NAME_CANNOT_BE_CHANGED.name());
+ ErrorInfo errorInfo = ErrorValidationUtils.parseErrorConfigYaml(ActionStatus.MISSING_DATA.name());
List<String> variables = asList("artifact description");
artifactReqDetails.setDescription("");
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java
index 6e212d3155..a97c8e7336 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/VFCMTExternalAPI.java
@@ -216,10 +216,6 @@ public class VFCMTExternalAPI extends ComponentBaseTest {
// Various failure flows
@Test(dataProvider="createVfcmtVariousFailureFlows")
public void createVfcmtVariousFailureFlows(String flow) throws Exception {
- //TODO: check what happens now, test will prbably fail
- if(flow.equals("resource_type_missing") || flow.equals("resource_type_invalid")) {
- throw new SkipException("TC require repairs");
- }
User defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
ResourceExternalReqDetails defaultResource = ElementFactory.getDefaultResourceByType("ci", ResourceCategoryEnum.TEMPLATE_MONITORING_TEMPLATE, defaultUser.getUserId(), ResourceTypeEnum.VFCMT.toString());
diff --git a/test-apis-ci/src/main/resources/ci/scripts/copyToStorage.sh b/test-apis-ci/src/main/resources/ci/scripts/copyToStorage.sh
index 30094fe235..b7b8c09715 100644
--- a/test-apis-ci/src/main/resources/ci/scripts/copyToStorage.sh
+++ b/test-apis-ci/src/main/resources/ci/scripts/copyToStorage.sh
@@ -3,7 +3,6 @@
REPORT_NAME=$1
VERSION=$2
ENV=$3
-IP=$4
if [ -z "$REPORT_NAME" ]
then
@@ -19,6 +18,12 @@ if [ -z "$REPORT_NAME" ]
fi
fi
+
+source conf/attInternal.info
+IP=$automationResutlsRepo
+PASS=$automationResutlsRepoPass
+
+echo ${IP}
/usr/bin/expect << EOF
spawn ssh admin@${IP} mkdir -p -m 775 /home/admin/reports/${ENV}/${VERSION}/APIs/
@@ -29,7 +34,7 @@ expect {
exp_continue
}
-re ".*sword.*" {
- exp_send "Aa123456\r"
+ exp_send ${PASS}\r
}
}
@@ -43,7 +48,7 @@ expect {
exp_continue
}
-re ".*sword.*" {
- exp_send "Aa123456\r"
+ exp_send ${PASS}\r
}
}
@@ -57,7 +62,7 @@ expect {
exp_continue
}
-re ".*sword.*" {
- exp_send "Aa123456\r"
+ exp_send ${PASS}\r
}
}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTest.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTest.java
index 519f1e1a76..f0bc6f7505 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTest.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CatalogLeftPanelTest.java
@@ -22,7 +22,6 @@ package org.openecomp.sdc.ci.tests.execute.sanity;
import static org.testng.AssertJUnit.assertTrue;
-import java.io.File;
import java.util.Arrays;
import java.util.List;
@@ -58,15 +57,7 @@ public class CatalogLeftPanelTest extends SetupCDTest{
private String filePath;
@BeforeMethod
public void beforeTest(){
- filePath = System.getProperty("filepath");
-
- if (filePath == null && System.getProperty("os.name").contains("Windows")) {
- filePath = FileHandling.getResourcesFilesPath();
- }
-
- else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){
- filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator;
- }
+ filePath = FileHandling.getFilePath("");
}
public static String[] resourceTypes = Arrays.stream(ResourceTypeEnum.class.getEnumConstants()).
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CustomizationUUID.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CustomizationUUID.java
index 2c2b09af22..b8b7bd752e 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CustomizationUUID.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/CustomizationUUID.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.sanity;
-import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -71,15 +70,7 @@ public class CustomizationUUID extends SetupCDTest {
@BeforeMethod
public void beforeTest(){
- filePath = System.getProperty("filepath");
-
- if (filePath == null && System.getProperty("os.name").contains("Windows")) {
- filePath = FileHandling.getResourcesFilesPath();
- }
-
- else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){
- filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator;
- }
+ filePath = FileHandling.getFilePath("");
}
@Test
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java
index 2e25eddd2c..1af68d9364 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/DeploymentViewTests.java
@@ -20,10 +20,8 @@
package org.openecomp.sdc.ci.tests.execute.sanity;
-import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
-import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -56,15 +54,7 @@ public class DeploymentViewTests extends SetupCDTest {
@BeforeMethod
public void beforeTest(){
- filePath = System.getProperty("filepath");
-
- if (filePath == null && System.getProperty("os.name").contains("Windows")) {
- filePath = FileHandling.getResourcesFilesPath();
- }
-
- else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){
- filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator;
- }
+ filePath = FileHandling.getFilePath("");
}
@DataProvider(name = "CSAR_VF_Files", parallel = false)
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java
index 6a80dfe854..5204c808c4 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportDCAE.java
@@ -22,7 +22,6 @@ package org.openecomp.sdc.ci.tests.execute.sanity;
import static org.testng.AssertJUnit.assertTrue;
-import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -36,11 +35,11 @@ import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo;
import org.openecomp.sdc.ci.tests.datatypes.CanvasElement;
import org.openecomp.sdc.ci.tests.datatypes.CanvasManager;
import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
-import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum;
-import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.InformationalArtifactsPlaceholders;
import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems;
import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ResourceMetadataEnum;
+import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum;
+import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
@@ -50,7 +49,6 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
import org.openecomp.sdc.ci.tests.pages.CompositionPage;
import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
-import org.openecomp.sdc.ci.tests.pages.DeploymentPage;
import org.openecomp.sdc.ci.tests.pages.GeneralPageElements;
import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage;
import org.openecomp.sdc.ci.tests.pages.InputsPage;
@@ -81,18 +79,12 @@ import com.aventstack.extentreports.Status;
public class ImportDCAE extends SetupCDTest {
+ private static final String SERVICE_INPUT_TEST_VF2_CSAR = "service_input_test_VF2.csar";
private String filePath;
+
@BeforeMethod
public void beforeTest(){
- filePath = System.getProperty("filepath");
-
- if (filePath == null && System.getProperty("os.name").contains("Windows")) {
- filePath = FileHandling.getResourcesFilesPath();
- }
-
- else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){
- filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator;
- }
+ filePath = FileHandling.getFilePath("");
}
@Test
@@ -159,8 +151,8 @@ public class ImportDCAE extends SetupCDTest {
ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
List<ArtifactInfo> deploymentArtifactList = new ArrayList<ArtifactInfo>();
- deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"));
- deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML"));
+ deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType()));
+ deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", ArtifactTypeEnum.YANG_XML.getType()));
for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
DeploymentArtifactPage.clickAddNewArtifact();
ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact);
@@ -186,7 +178,7 @@ public class ImportDCAE extends SetupCDTest {
createDCAEAsset();
ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
- ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
+ ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType());
InformationalArtifactPage.clickAddNewArtifact();
ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
@@ -436,7 +428,7 @@ public class ImportDCAE extends SetupCDTest {
ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
- ArtifactInfo artifact = new ArtifactInfo(filePath, "Heat-File.yaml", "kuku", "artifact3","OTHER");
+ ArtifactInfo artifact = new ArtifactInfo(filePath, "Heat-File.yaml", "kuku", "artifact3",ArtifactTypeEnum.OTHER.getType());
CompositionPage.showDeploymentArtifactTab();
CompositionPage.clickAddArtifactButton();
ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup());
@@ -463,11 +455,16 @@ public class ImportDCAE extends SetupCDTest {
@Test
public void addDeploymentArtifactAndVerifyInCompositionScreenDCAEAssetTest() throws Exception{
+
+ if(true){
+ throw new SkipException("Open bug 320081");
+ }
+
createDCAEAsset();
ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
- ArtifactInfo deploymentArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
+ ArtifactInfo deploymentArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType());
DeploymentArtifactPage.clickAddNewArtifact();
ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact);
assertTrue(DeploymentArtifactPage.checkElementsCountInTable(1));
@@ -588,7 +585,7 @@ public class ImportDCAE extends SetupCDTest {
@Test
public void removeFileFromGeneralPageDCAEAssetTest() throws Exception{
- String fileName2 = "service_input_test_VF2.csar";
+ String fileName2 = SERVICE_INPUT_TEST_VF2_CSAR;
ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
ResourceUIUtils.importVfFromCsarNoCreate(resourceMetaData, filePath, fileName2, getUser());
GeneralPageElements.clickDeleteFile();
@@ -608,7 +605,7 @@ public class ImportDCAE extends SetupCDTest {
ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
- ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
+ ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType());
InformationalArtifactPage.clickAddNewArtifact();
ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
@@ -655,15 +652,13 @@ public class ImportDCAE extends SetupCDTest {
@Test
public void validContactAfterCreateDCAEAssetTest() throws Exception{
- String fileName2 = "service_input_test_VF2.csar";
- ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
- ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser());
+ ResourceReqDetails resourceMetaData = createDCAEAsset();
SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating that userID equal to user that was logged in..."));
- assertTrue("wrong userId", resourceMetaData.getContactId().equals(ResourceGeneralPage.getContactIdText()));
+ assertTrue("Wrong userId", resourceMetaData.getContactId().equals(ResourceGeneralPage.getContactIdText()));
}
public ResourceReqDetails createDCAEAsset() throws Exception{
- String fileName2 = "service_input_test_VF2.csar";
+ String fileName2 = SERVICE_INPUT_TEST_VF2_CSAR;
ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser());
resourceMetaData.setVersion("0.1");
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java
index c129636291..fca568794b 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/ImportVFCAsset.java
@@ -22,7 +22,6 @@ package org.openecomp.sdc.ci.tests.execute.sanity;
import static org.testng.AssertJUnit.assertTrue;
-import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -59,12 +58,9 @@ import org.openecomp.sdc.ci.tests.verificator.VfVerificator;
import org.testng.Assert;
import org.testng.SkipException;
import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import com.aventstack.extentreports.Status;
-
public class ImportVFCAsset extends SetupCDTest {
private ResourceReqDetails atomicResourceMetaData;
@@ -72,13 +68,7 @@ public class ImportVFCAsset extends SetupCDTest {
private String filePath;
@BeforeClass
public void beforeClass(){
- filePath = System.getProperty("filepath");
- if (filePath == null && System.getProperty("os.name").contains("Windows")) {
- filePath = FileHandling.getResourcesFilesPath();
- }
- else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){
- filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator + "";
- }
+ filePath = FileHandling.getFilePath("");
}
@DataProvider(name = "assetFiles", parallel = false)
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Onboard.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Onboard.java
index 2db818948a..66ab0b3cef 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Onboard.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Onboard.java
@@ -25,6 +25,7 @@ import static org.testng.AssertJUnit.assertTrue;
import java.awt.AWTException;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -150,17 +151,7 @@ public class Onboard extends SetupCDTest {
public void runOnboardToDistributionFlow(String filepath, String vnfFile) throws Exception, AWTException {
- Pair<String,Map<String,String>> onboardAndValidate = OnboardingUtils.onboardAndValidate(filepath, vnfFile, getUser());
- String vspName = onboardAndValidate.left;
-
- DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen();
- ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFile ,"The topology template for " + vnfFile + " is as follows : ");
-
- DeploymentArtifactPage.clickSubmitForTestingButton(vspName);
-
- reloginWithNewRole(UserRoleEnum.TESTER);
- GeneralUIUtils.findComponentAndClick(vspName);
- TesterOperationPage.certifyComponent(vspName);
+ String vspName = onboardAndCertify(filepath, vnfFile);
reloginWithNewRole(UserRoleEnum.DESIGNER);
// create service
@@ -207,6 +198,24 @@ public class Onboard extends SetupCDTest {
getExtendTest().log(Status.INFO, String.format("The onboarding %s test is passed ! ", vnfFile));
}
+ public String onboardAndCertify(String filepath, String vnfFile) throws Exception, IOException {
+ Pair<String,Map<String,String>> onboardAndValidate = OnboardingUtils.onboardAndValidate(filepath, vnfFile, getUser());
+ String vspName = onboardAndValidate.left;
+
+ DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen();
+ ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFile ,"The topology template for " + vnfFile + " is as follows : ");
+
+ DeploymentArtifactPage.clickSubmitForTestingButton(vspName);
+
+ reloginWithNewRole(UserRoleEnum.TESTER);
+ GeneralUIUtils.findComponentAndClick(vspName);
+ TesterOperationPage.certifyComponent(vspName);
+ return vspName;
+ }
+
+
+
+
// protected synchronized void validateInputArtsVSouput(String serviceName) {
//
//
@@ -225,12 +234,19 @@ public class Onboard extends SetupCDTest {
System.out.println("printttttttttttttt - >" + makeDistributionValue);
runOnboardToDistributionFlow(filepath, vnfFile);
}
+
+ @Test(dataProvider = "VNF_List")
+ public void onboardVNFShotFlow(String filepath, String vnfFile) throws Exception, Throwable {
+ setLog(vnfFile);
+ System.out.println("printttttttttttttt - >" + makeDistributionValue);
+ onboardAndCertify(filepath, vnfFile);
+ }
@Test(dataProvider = "randomVNF_List")
public void onboardRandomVNFsTest(String filepath, String vnfFile) throws Exception, Throwable {
setLog(vnfFile);
System.out.println("printttttttttttttt - >" + makeDistributionValue);
- System.out.println("vnf File name is: " + vnfFile);
+ System.out.println("Vnf File name is: " + vnfFile);
runOnboardToDistributionFlow(filepath, vnfFile);
}
@@ -309,7 +325,7 @@ public class Onboard extends SetupCDTest {
OpsOperationPage.waitUntilArtifactsDistributed(0);
- getExtendTest().log(Status.INFO, String.format("onboarding %s test is passed ! ", vnfFile));
+ getExtendTest().log(Status.INFO, String.format("Onboarding %s test is passed ! ", vnfFile));
}
@@ -325,15 +341,15 @@ public class Onboard extends SetupCDTest {
Map<String, String> vspNames = new HashMap<String, String>();
for (String vnfFile : vmmscList){
- getExtendTest().log(Status.INFO, String.format("going to onboard the VNF %s......", vnfFile));
- System.out.println(String.format("going to onboard the VNF %s......", vnfFile));
+ getExtendTest().log(Status.INFO, String.format("Going to onboard the VNF %s......", vnfFile));
+ System.out.println(String.format("Going to onboard the VNF %s......", vnfFile));
AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(getUser());
Pair<String,Map<String,String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(vnfFile, filepath, getUser(), amdocsLicenseMembers);
- getExtendTest().log(Status.INFO, String.format("searching for onboarded %s", vnfFile));
+ getExtendTest().log(Status.INFO, String.format("Searching for onboarded %s", vnfFile));
HomePage.showVspRepository();
- getExtendTest().log(Status.INFO,String.format("going to import %s......", vnfFile.substring(0, vnfFile.indexOf("."))));
+ getExtendTest().log(Status.INFO,String.format("Going to import %s......", vnfFile.substring(0, vnfFile.indexOf("."))));
OnboardingUtils.importVSP(createVendorSoftwareProduct);
ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
@@ -391,19 +407,6 @@ public class Onboard extends SetupCDTest {
}
-
-
-
-
-
-
-
-
-
-
-
-
-
@Override
protected UserRoleEnum getRole() {
return UserRoleEnum.DESIGNER;
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Product.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Product.java
index e0e13b7036..c12a8f220a 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Product.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Product.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.ci.tests.execute.sanity;
-import java.io.File;
-
import org.openecomp.sdc.ci.tests.datatypes.CanvasElement;
import org.openecomp.sdc.ci.tests.datatypes.CanvasManager;
import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
@@ -32,12 +30,10 @@ import org.openecomp.sdc.ci.tests.pages.CompositionPage;
import org.openecomp.sdc.ci.tests.pages.GeneralPageElements;
import org.openecomp.sdc.ci.tests.pages.ProductGeneralPage;
import org.openecomp.sdc.ci.tests.pages.TesterOperationPage;
-import org.openecomp.sdc.ci.tests.utilities.FileHandling;
import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
import org.openecomp.sdc.ci.tests.utilities.ProductUIUtils;
import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@@ -47,21 +43,7 @@ import org.testng.annotations.Test;
public class Product extends SetupCDTest {
- private String filePath;
- @BeforeMethod
- public void beforeTest(){
- filePath = System.getProperty("filepath");
-
- if (filePath == null && System.getProperty("os.name").contains("Windows")) {
- filePath = FileHandling.getResourcesFilesPath();
- }
-
- else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){
- filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator;
- }
- }
-
@Test
public void createProductAndAddCertifiedServiceInstance() throws Exception {
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java
index f8ad51ca14..9eee0e9096 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VFCArtifacts.java
@@ -22,7 +22,6 @@ package org.openecomp.sdc.ci.tests.execute.sanity;
import static org.testng.Assert.assertTrue;
-import java.io.File;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -66,16 +65,9 @@ public class VFCArtifacts extends SetupCDTest {
private static final String ARTIFACTS = "artifacts";
private static final String DEPLOYMENT_ARTIFACTS = "deploymentArtifacts";
private String filePath;
- private Object object;
@BeforeClass
public void beforeClass(){
- filePath = System.getProperty("filepath");
- if (filePath == null && System.getProperty("os.name").contains("Windows")) {
- filePath = FileHandling.getResourcesFilesPath() + "VFCArtifacts"+ File.separator;
- }
- else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){
- filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator + "VFCArtifacts"+ File.separator;
- }
+ filePath = FileHandling.getFilePath("");
}
@Test
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java
index ef7a534ee9..17d1fa2906 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java
@@ -92,13 +92,7 @@ public class Vf extends SetupCDTest {
private String filePath;
@BeforeClass
public void beforeClass(){
- filePath = System.getProperty("filepath");
- if (filePath == null && System.getProperty("os.name").contains("Windows")) {
- filePath = FileHandling.getResourcesFilesPath();
- }
- else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){
- filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator;
- }
+ filePath = FileHandling.getFilePath("");
}
@BeforeMethod
@@ -520,6 +514,11 @@ public class Vf extends SetupCDTest {
@Test
public void addDeploymentArtifactAndVerifyInCompositionScreen() throws Exception{
+
+ if(true){
+ throw new SkipException("Open bug 320081");
+ }
+
ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
ResourceUIUtils.createResource(vfMetaData, getUser());
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java
index 22396ec9c7..f7e7945227 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/VfDeploymentInformationalArtifacts.java
@@ -58,14 +58,17 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
// TC1434241 - Import VF Artifacts - Deployment Artifacts - One Artifact, One Type
@Test
public void importVfArtifactsDeploymentArtifactsOneArtifactOneType() throws Exception {
+
+ if(true){
+ throw new SkipException("Open bug 320081");
+ }
String fileName = "TC1434241.csar";
String folder ="US825779";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
-
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null);
}
@@ -74,19 +77,23 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
// TC1434245 - Import VF Artifacts - Deployment Artifacts - Multiple Artifacts, Multiple Types
@Test
public void importVfArtifactsDeploymentArtifactsMultipleArtifactsMultipleTypes() throws Exception {
+
+ if(true){
+ throw new SkipException("Open bug 320081");
+ }
String fileName = "TC1434245.csar";
String folder ="US825779";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName3.yaml", null, "HeatVolArtifactName3", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName3.yaml", null, "HeatVolArtifactName3", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName,folder, deploymentArtifacts, null);
}
@@ -104,11 +111,11 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
String folder ="US825779";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
- informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts);
}
@@ -126,13 +133,13 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
String folder ="US825779";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
- informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
- informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1"));
- informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts);
}
@@ -150,18 +157,18 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
String folder ="US825779";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName3.yaml", null, "HeatVolArtifactName3", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName3.yaml", null, "HeatVolArtifactName3", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
- informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
- informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1"));
- informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts);
}
@@ -181,9 +188,9 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
String folder ="US825779";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "ArtifactName.yaml", null, "ArtifactName", ArtifactTypeEnum.OTHER.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "ArtifactName.yaml", null, "ArtifactName", ArtifactTypeEnum.OTHER.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null);
}
@@ -201,11 +208,11 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
String folder ="US825779";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
- informationalArtifacts.add(new ArtifactInfo(null, "ArtifactName.yaml", null, "ArtifactName", ArtifactTypeEnum.OTHER.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "ArtifactName.yaml", null, "ArtifactName", ArtifactTypeEnum.OTHER.getType(), "1"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts);
}
@@ -266,15 +273,15 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "4"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "4"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null);
GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
fileName = "UpdateTC1443736.csar";
- deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, null, null, null);
}
@@ -289,9 +296,9 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "4"));
- ArtifactInfo artifactInfo = new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1");
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "4"));
+ ArtifactInfo artifactInfo = new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1");
deploymentArtifacts.add(artifactInfo);
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null);
@@ -316,9 +323,9 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "4"));
- ArtifactInfo artifactInfo = new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1");
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "4"));
+ ArtifactInfo artifactInfo = new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1");
deploymentArtifacts.add(artifactInfo);
@@ -345,8 +352,8 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
String folder ="US825779";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null);
@@ -355,7 +362,7 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
fileName = "UpdateTC1443887.csar";
List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
- informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, informationalArtifacts, null, null);
}
@@ -373,11 +380,11 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
String fileName = "ImportTC1443888.csar";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
- ArtifactInfo artifactInfo = new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1");
+ ArtifactInfo artifactInfo = new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1");
informationalArtifacts.add(artifactInfo);
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts);
@@ -407,11 +414,11 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
String fileName = "ImportTC1443890.csar";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
- ArtifactInfo artifactInfo = new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1");
+ ArtifactInfo artifactInfo = new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1");
informationalArtifacts.add(artifactInfo);
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts);
@@ -437,18 +444,18 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
String fileName = "ImportUpdateTC1443893.csar";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
- deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName3.yaml", null, "HeatVolArtifactName3", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName3.yaml", null, "HeatVolArtifactName3", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
- informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
- informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1"));
- informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts);
@@ -471,12 +478,12 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
String folder ="US825779";
String fileName = "ImportTC1443954.csar";
- ArtifactInfo deploymentHeat1 = new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1");
- ArtifactInfo deploymentHeat2 = new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1");
- ArtifactInfo deploymentHeat3 = new ArtifactInfo(null, "heatartifactname3.yaml", null, "heatartifactname3", ArtifactTypeEnum.HEAT.getType(), "1");
+ ArtifactInfo deploymentHeat1 = new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1");
+ ArtifactInfo deploymentHeat2 = new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1");
+ ArtifactInfo deploymentHeat3 = new ArtifactInfo(null, "heatartifactname3.yaml", null, "heatartifactname3", ArtifactTypeEnum.HEAT.getType(), "1");
- ArtifactInfo deploymentHeatVol1 = new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1");
- ArtifactInfo deploymentHeatVol2 = new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1");
+ ArtifactInfo deploymentHeatVol1 = new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1");
+ ArtifactInfo deploymentHeatVol2 = new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1");
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
deploymentArtifacts.add(deploymentHeat1);
@@ -485,12 +492,12 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
deploymentArtifacts.add(deploymentHeatVol1);
deploymentArtifacts.add(deploymentHeatVol2);
- ArtifactInfo infoGuide1 = new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1");
- ArtifactInfo infoGuide2 = new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1");
+ ArtifactInfo infoGuide1 = new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1");
+ ArtifactInfo infoGuide2 = new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1");
- ArtifactInfo infoOther1 = new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1");
- ArtifactInfo infoOther2 = new ArtifactInfo(null, "artifactname2.txt", null, "artifactname2", ArtifactTypeEnum.OTHER.getType(), "1");
- ArtifactInfo infoOther3 = new ArtifactInfo(null, "artifactname3.txt", null, "artifactname3", ArtifactTypeEnum.OTHER.getType(), "1");
+ ArtifactInfo infoOther1 = new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1");
+ ArtifactInfo infoOther2 = new ArtifactInfo(null, "artifactname2.txt", null, "artifactname2", ArtifactTypeEnum.OTHER.getType(), "1");
+ ArtifactInfo infoOther3 = new ArtifactInfo(null, "artifactname3.txt", null, "artifactname3", ArtifactTypeEnum.OTHER.getType(), "1");
List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
informationalArtifacts.add(infoGuide1);
@@ -513,8 +520,8 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
deploymentArtifactsNotExist.add(deploymentHeat2);
deploymentArtifacts.remove(deploymentHeat1);
deploymentArtifacts.remove(deploymentHeat2);
- deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname4.yaml", null, "heatartifactname4", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname5.yaml", null, "heatartifactname5", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname4.yaml", null, "heatartifactname4", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname5.yaml", null, "heatartifactname5", ArtifactTypeEnum.HEAT.getType(), "1"));
deploymentHeatVol1.setArtifactVersion("2");
deploymentHeatVol2.setArtifactVersion("2");
@@ -525,8 +532,8 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
informationalArtifactsNotExist.add(infoOther2);
informationalArtifacts.remove(infoGuide2);
informationalArtifacts.remove(infoOther2);
- informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact3.yml", null, "GuideInfoArtifact3", ArtifactTypeEnum.GUIDE.getType(), "1"));
- informationalArtifacts.add(new ArtifactInfo(null, "artifactname4.txt", null, "artifactname4", ArtifactTypeEnum.OTHER.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact3.yml", null, "GuideInfoArtifact3", ArtifactTypeEnum.GUIDE.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "artifactname4.txt", null, "artifactname4", ArtifactTypeEnum.OTHER.getType(), "1"));
updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, informationalArtifacts, deploymentArtifactsNotExist, informationalArtifactsNotExist);
}
@@ -538,11 +545,13 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
public void updateWithExistedDeploymentArtifactByArtifactWithDifferentType() throws Exception {
String folder ="US825779";
String fileName = "ImportTC1444206.csar";
-
+ if(true){
+ throw new SkipException("Open bug 320081");
+ }
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
- deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null);
@@ -571,11 +580,11 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
String fileName = "ImportTC1444207.csar";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
- informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts);
@@ -596,13 +605,17 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
// TC1444208 - Update With Existed Informational Artifact By Deployment Artifact With Different Type
@Test
public void updateWithExistedInformationalArtifactByDeploymentArtifactWithDifferentType() throws Exception {
+
+ if(true){
+ throw new SkipException("Open bug 320081");
+ }
String folder ="US825779";
String fileName = "ImportTC1444208.csar";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
- deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null);
@@ -679,15 +692,15 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null);
GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
fileName = "UpdateTC1444530.csar";
- deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, null, null, null);
}
@@ -712,7 +725,7 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
fileName = "UpdateTC1444531.csar";
List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
- informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
+ informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, null, informationalArtifacts, null, null);
}
@@ -720,29 +733,38 @@ public class VfDeploymentInformationalArtifacts extends SetupCDTest {
@Test
public void importValidInformationalArtifactInInvalidFolerTest_TC1438313() throws Exception{
+
+ if(true){
+ throw new SkipException("Open bug 320081");
+ }
String fileName = "ValidArtifactNameInInvalidFolder.csar";
String folder = "US824719";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null);
}
@Test
public void updateValidInformationalArtifactInInvalidFolerTest_TC1444533() throws Exception{
+ if(true){
+ throw new SkipException("Open bug 320081");
+ }
+
String fileName = "ImportTC1444533.csar";
String folder = "US824719";
String filePath = FileHandling.getFilePath(folder);
+
ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser());
String updatedCsarFileName = "UpdateTC1444533.csar";
List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
- deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
- deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "4"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
+ deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "4"));
updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, updatedCsarFileName, deploymentArtifacts, null, null, null);
}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java
index 705f0decaf..fd53249ac2 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java
@@ -37,6 +37,8 @@ import org.openecomp.sdc.ci.tests.utilities.FileHandling;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
+import org.testng.ITestContext;
+import org.testng.ITestResult;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
@@ -96,7 +98,7 @@ public class DriverFactory {
webDriverThread.quitDriver();
}
-// MobProxy.removeAllProxyServers();
+ MobProxy.removeAllProxyServers();
deleteDownloadDirs();
}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java
index 820c6997f5..10ae6cba7a 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java
@@ -238,7 +238,7 @@ public abstract class SetupCDTest extends DriverFactory {
}
}
- public void generateReport4Jenkins(ITestResult result, ITestContext context) {
+ public void generateReport4Jenkins(ITestContext context) {
String suiteName = ExtentManager.getSuiteName(context);
// String outputDirectory = context.getOutputDirectory();
JSONObject obj = new JSONObject();
@@ -269,16 +269,17 @@ public abstract class SetupCDTest extends DriverFactory {
@AfterSuite(alwaysRun = true)
- public void afterSuite(ITestResult result, ITestContext context) throws Exception {
-
- if (getConfig().getUseBrowserMobProxy()){
- MobProxy.getPoxyServer().stop();
- }
+
+ public void afterSuite2() throws Exception {
+// public void afterSuite() throws Exception {
csvReport.closeFile();
- generateReport4Jenkins(result, context);
+ generateReport4Jenkins(myContext);
RestCDUtils.deleteOnDemand();
+ if (getConfig().getUseBrowserMobProxy()){
+ MobProxy.getPoxyServer().stop();
+ }
}
protected static String setUrl() {
@@ -299,7 +300,7 @@ public abstract class SetupCDTest extends DriverFactory {
}
File credentialsFileRemote = new File(FileHandling.getBasePath() + File.separator + "conf" + File.separator + CREDENTIALS_FILE);
// File credentialsFileLocal = new File(FileHandling.getConfFilesPath() + CREDENTIALS_FILE);
- File credentialsFileLocal = new File(FileHandling.getSdcVncPath() + File.separator + "conf"
+ File credentialsFileLocal = new File(FileHandling.getSdcVnfsPath() + File.separator + "conf"
+ File.separator + CREDENTIALS_FILE);
File[] credentialFiles = {credentialsFileRemote, credentialsFileLocal};
for (File credentialsFile : credentialFiles){
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java
index a83e26d980..fdcb3f372d 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/FileHandling.java
@@ -109,12 +109,10 @@ public class FileHandling {
return System.getProperty("user.dir") + File.separator;
}
- public static String getSdcVncPath() {
- return Paths.get(System.getProperty("user.dir"), "..", "..", "sdc-vnfs").toString();
+ public static String getSdcVnfsPath() {
+ return getBasePath() + Paths.get("..", "..", "sdc-vnfs").toString();
}
-
-
public static String getDriversPath() {
return getBasePath() + "src" + File.separator + "main" + File.separator + "resources"
+ File.separator + "ci" + File.separator + "drivers" + File.separator;
@@ -124,8 +122,7 @@ public class FileHandling {
// return getBasePath() + "src" + File.separator + "main" + File.separator + "resources"
// + File.separator + "Files" + File.separator;
- return getSdcVncPath()+ File.separator + "ui-tests"
- + File.separator + "Files" + File.separator;
+ return getSdcVnfsPath()+ File.separator + "ui-tests" + File.separator + "Files" + File.separator;
}
public static String getResourcesEnvFilesPath() {
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/GeneralUIUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/GeneralUIUtils.java
index 19c2242550..44ff08938a 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/GeneralUIUtils.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/GeneralUIUtils.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.ci.tests.utilities;
-import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java
index 33b9f4a77e..eed4f765c5 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUtils.java
@@ -399,6 +399,7 @@ public class OnboardingUtils {
jObject.put("name", "xyz");
jObject.put("description", "new vendor license feature groups");
jObject.put("partNumber", "123abc456");
+ jObject.put("manufacturerReferenceNumber", "5");
jObject.put("addedLicenseKeyGroupsIds", Arrays.asList(licenseKeyGroupId).toArray());
jObject.put("addedEntitlementPoolsIds", Arrays.asList(entitlementPoolId).toArray());
@@ -514,7 +515,7 @@ public class OnboardingUtils {
return new Pair<RestResponse, Map<String, String>>(response, vspMetadta);
}
- public static RestResponse getVendorSoftwareProduct(Map vspObject, User user) throws Exception {
+/* public static RestResponse getVendorSoftwareProduct(Map vspObject, User user) throws Exception {
Config config = Utils.getConfig();
String url = String.format("http://%s:%s/onboarding-api/v1.0/vendor-software-products/" + vspObject.get("vspId"),
config.getCatalogBeHost(), config.getCatalogBePort());
@@ -527,7 +528,7 @@ public class OnboardingUtils {
RestResponse response = http.httpsSendGet(url, headersMap);
return response;
- }
+ }*/
public static RestResponse validateUpload(String vspid, User user) throws Exception {
Config config = Utils.getConfig();
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java
index e4c4840450..2689849b19 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java
@@ -81,7 +81,7 @@ public class ServiceVerificator {
}
JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag);
int size = ((JSONArray) jsonResource.get("componentInstances")).size();
- assertTrue(size == numOfVFC);
+ assertTrue(size == numOfVFC, "Expected number of componenet instances is " + numOfVFC + ", but actual is " + size);
ExtentTestActions.log(Status.INFO, "The number of components on the canvas was verified.");
}
diff --git a/ui-ci/src/main/resources/ci/conf/attsdc.yaml b/ui-ci/src/main/resources/ci/conf/attsdc.yaml
index 1ab581cada..4dd7e75abd 100644
--- a/ui-ci/src/main/resources/ci/conf/attsdc.yaml
+++ b/ui-ci/src/main/resources/ci/conf/attsdc.yaml
@@ -1,7 +1,12 @@
outputFolder: target
reportName: index.html
-catalogBeHost: 127.0.0.1
-catalogFeHost: fehost
+#catalogBeHost: 127.0.0.1
+#Automate
+#catalogBeHost: 135.63.125.67
+#catalogFeHost: 135.63.125.63
+#IFT
+catalogBeHost: 135.21.143.248
+catalogFeHost: 135.21.125.96
esHost: eshost
disributionClientHost: disClient
catalogFePort: 8181
@@ -12,7 +17,9 @@ neoHost: neoHost
neoPort: 7474
neoDBusername: neo4j
neoDBpassword: 123456
-url: http://localhost:8285/sdc1
+#url: http://localhost:8285/sdc1
+#url: https://www.e-access.att.com/QA-AUTOMATE1/sdc1/portal
+url: https://www.e-access.att.com/AA-IFT-testing/sdc1/portal
remoteTestingMachineIP: 0.0.0.0
remoteTestingMachinePort: 5566
remoteTesting: false
diff --git a/ui-ci/src/main/resources/ci/scripts/copyToStorage.sh b/ui-ci/src/main/resources/ci/scripts/copyToStorage.sh
index 396c1aa0ac..a113c54e60 100644
--- a/ui-ci/src/main/resources/ci/scripts/copyToStorage.sh
+++ b/ui-ci/src/main/resources/ci/scripts/copyToStorage.sh
@@ -3,7 +3,7 @@
REPORT_NAME=$1
VERSION=$2
ENV=$3
-IP=$3
+
if [ -z "$REPORT_NAME" ]
then
@@ -20,6 +20,10 @@ if [ -z "$REPORT_NAME" ]
fi
+source conf/attInternal.info
+IP=$automationResutlsRepo
+PASS=$automationResutlsRepoPass
+
/usr/bin/expect << EOF
spawn ssh admin@${IP} mkdir -p -m 775 /home/admin/reports/${ENV}/${VERSION}/UI/
@@ -29,13 +33,13 @@ expect {
exp_continue
}
-re ".*sword.*" {
- exp_send "Aa123456\r"
+ exp_send ${PASS}\r
}
}
expect eof
-spawn scp -pr ExtentReport admin@{IP}:/home/admin/reports/${ENV}/${VERSION}/UI/${REPORT_NAME}/
+spawn scp -pr ExtentReport admin@${IP}:/home/admin/reports/${ENV}/${VERSION}/UI/${REPORT_NAME}/
expect {
-re ".*es.*o.*" {
@@ -43,7 +47,7 @@ expect {
exp_continue
}
-re ".*sword.*" {
- exp_send "Aa123456\r"
+ exp_send ${PASS}\r
}
}
diff --git a/ui-ci/src/main/resources/ci/testSuites/extendedSanity.xml b/ui-ci/src/main/resources/ci/testSuites/extendedSanity.xml
index da2bc98ebc..36993e382c 100644
--- a/ui-ci/src/main/resources/ci/testSuites/extendedSanity.xml
+++ b/ui-ci/src/main/resources/ci/testSuites/extendedSanity.xml
@@ -9,6 +9,8 @@
<class name="org.openecomp.sdc.ci.tests.execute.sanity.Onboard">
<methods>
<exclude name="onboardVNFTestSanity"/>
+ <exclude name="onboardVNFShotFlow"/>
+ <exclude name="onboardRandomVNFsTest"/>
</methods>
</class>
<class name="org.openecomp.sdc.ci.tests.execute.sanity.CatalogLeftPanelTest"/>
diff --git a/ui-ci/src/main/resources/ci/testSuites/onboardingVNFs.xml b/ui-ci/src/main/resources/ci/testSuites/onboardingVNFs.xml
index a49c8a751c..c55da4274c 100644
--- a/ui-ci/src/main/resources/ci/testSuites/onboardingVNFs.xml
+++ b/ui-ci/src/main/resources/ci/testSuites/onboardingVNFs.xml
@@ -1,16 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="uitests" configfailurepolicy="continue" parallel="methods" thread-count="2" data-provider-thread-count="2">
-<parameter name="makeDistribution" value="true"/>
- <test name="Onboarding">
+ <parameter name="makeDistribution" value="true"/>
+
+ <test name="uiSanity">
<classes>
<class name="org.openecomp.sdc.ci.tests.execute.sanity.Onboard">
<methods>
- <include name="onboardVNFTest"/>
+ <exclude name="onboardVNFTestSanity"/>
+ <exclude name="onboardVNFShotFlow"/>
+ <exclude name="onboardRandomVNFsTest"/>
</methods>
</class>
+
</classes>
</test> <!-- uitests -->
</suite> <!-- uisuite --> \ No newline at end of file
diff --git a/ui-ci/src/main/resources/ci/testSuites/onboardingVNFsShortFlow.xml b/ui-ci/src/main/resources/ci/testSuites/onboardingVNFsShortFlow.xml
new file mode 100644
index 0000000000..4a4628a9ed
--- /dev/null
+++ b/ui-ci/src/main/resources/ci/testSuites/onboardingVNFsShortFlow.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="uitests" configfailurepolicy="continue" parallel="methods" thread-count="2" data-provider-thread-count="2">
+ <parameter name="makeDistribution" value="true"/>
+
+ <test name="uiSanity">
+ <classes>
+
+ <class name="org.openecomp.sdc.ci.tests.execute.sanity.Onboard">
+ <methods>
+ <include name="onboardVNFShotFlow"/>
+ </methods>
+ </class>
+
+
+ </classes>
+ </test> <!-- uitests -->
+</suite> <!-- uisuite --> \ No newline at end of file