aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-01-10 12:42:59 +0000
committerGerrit Code Review <gerrit@onap.org>2019-01-10 12:42:59 +0000
commit659874df80409170e57b6dd6197eb3a81eb3468e (patch)
tree08e79fd57aa0ed299586fd88f69f87a5a2f5ded1
parent143784a849ece4fc35cc290e33f829b72bf1fc79 (diff)
parent6ad41e3ccd398a2721f41ad61c80b7bb03f7d127 (diff)
Merge "Merge from ECOMP's repository"
-rwxr-xr-xepsdk-app-onap/pom.xml4
-rw-r--r--epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java42
-rw-r--r--epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppInitializer.java6
-rw-r--r--pom.xml498
-rw-r--r--vid-app-common/TestNg-BE-UnitTest.xml11
-rwxr-xr-xvid-app-common/pom.xml177
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/RelatedTo.java39
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java425
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java27
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java43
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseTranslator.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseWithRequestInfo.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ExceptionWithRequestInfo.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java39
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java23
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstance.java12
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstances.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstancesSearchResults.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscription.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptions.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/Services.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/SubscriberWithFilter.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/AicZones.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/Zone.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/CloudRegion.java55
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Network.java16
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/ServiceInstance.java42
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Vlan.java41
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Vnf.java84
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentList.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfResponse.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfs/Pnf.java32
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPortMirroringSourcePorts.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/Service.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetTenatns/GetTenantsResponse.java23
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiRelationResponse.java16
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/CustomQuerySimpleResult.java18
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/GetServiceModelsByDistributionStatusResponse.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/LogicalLinkResponse.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/Model.java20
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVer.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVers.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntity.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntityResponse.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/Permissions.kt6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/PnfProperties.java47
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/PnfResult.java40
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/PortDetailsTranslator.java42
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/Project.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ProjectResponse.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/Properties.java77
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedTo.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedToProperty.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/Relationship.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipData.java42
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ResourceType.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/Result.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceProperties.java25
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceRelationships.java62
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/SimpleResult.java32
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java34
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/interfaces/AaiModelWithRelationships.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java108
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeConverter.java89
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/CacheConfig.kt52
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/CacheProvider.java37
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/CacheProviderWithLoadingCache.java100
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsAuthClient.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsComponentsClient.java117
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/JettyObfuscationConversionCommandLineUtil.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/ServiceInstanceStandardQuery.java93
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/SystemPropertyHelper.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java1
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/SecureServices.java1
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Input.java17
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/InputProperties.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/NodeTemplate.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Property.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/SubstitutionMappings.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/TopologyTemplate.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaCsar.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaMeta.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java60
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/parser/ServiceModelInflator.kt43
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaNamingPolicy.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java449
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java130
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/ChangeManagementRequest.java21
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/CloudConfiguration.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/LeanCloudConfiguration.java9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfo.java13
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfoOfRelatedInstance.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestDetails.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestInfo.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetails.java1
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetailsWithWorkflows.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowsDetail.java1
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/client/HttpBasicClient.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/client/HttpsBasicClient.java111
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/AaiController.java)144
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AaiController2.java98
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryController.java173
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AsyncControllerForTests.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/AsyncControllerForTests.java)10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/AsyncInstantiationController.java)38
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ChangeManagementController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/ChangeManagementController.java)46
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/ControllersUtils.java)8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/FeatureTogglingController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/FeatureTogglingController.java)6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java)2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/HealthStatus.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/HealthStatus.java)2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/LoggerController.java)4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/MaintenanceController.java)16
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/MsoConfig.java)28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/MsoController.java)246
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/OperationalEnvironmentController.java)8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/ProbeController.java)23
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/PropertyController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/PropertyController.java)26
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/RoleGeneratorController.java)6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/VersionController.java63
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/VidController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/VidController.java)6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/VidRestrictedBaseController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/VidRestrictedBaseController.java)7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ViewLogController.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/ViewLogController.java)4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java (renamed from vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java)103
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/filter/ClientCredentialsFilter.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java17
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/test/TestAaiController.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/test/TestAsdcController.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/test/TestMsoController.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controllers/PolicyController.java84
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/Job.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/JobAdapter.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/JobCommand.java9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/JobException.java16
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/JobType.java24
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/JobsBrokerService.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceCommand.kt122
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceInstantiationCommand.java21
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/BaseInProgressStatusCommand.java95
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/BaseInstantiationCommand.java18
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/BaseRootCommand.java41
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/BaseWatchingCommand.java70
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/CommandBase.java27
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/CommandParentData.java80
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java46
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ExpiryChecker.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/HttpCallCommand.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusCommand.java137
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusService.java87
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupCommand.kt59
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupInstantiationCommand.java47
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/JobCommandFactory.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/MacroServiceInstantiationCommand.java26
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/MsoResult.kt9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/MsoResultHandlerService.kt66
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/NetworkInstantiationCommand.java41
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt324
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ResourceInProgressStatusCommand.java32
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ResourceInstantiationCommand.java87
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ResourceWithChildrenInProgressCommand.java65
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInProgressStatusCommand.java100
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ServiceInstantiationCommand.java146
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleInstantiationCommand.java44
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VnfInProgressStatusCommand.java87
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VnfInstantiationCommand.java50
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupInProgressStatusCommand.java65
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VolumeGroupInstantiationCommand.java83
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt61
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/WatchingCommand.java33
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/WatchingCommandBaseModule.java93
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobAdapterImpl.java55
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobDaoImpl.java40
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobData.java54
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobSchedulerInitializer.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobSharedData.java84
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobWorker.java35
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobsBrokerServiceInDatabaseImpl.java75
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Action.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/CR.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/CommandProperty.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Group.java21
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/GroupProperties.java9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java75
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/MinimalNode.kt8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ModelConstants.java12
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/NameCounter.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/NewNetwork.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/NewNode.java18
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/NewServiceModel.java91
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/NewVNF.java41
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Node.java44
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/PortMirroringConfig.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Resource.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ResourceGroup.kt13
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Service.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java75
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java41
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ServiceProxy.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/SoftDeleteRequest.java42
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Subscriber.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/SubscriberList.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/VNF.java29
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/VfModule.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt34
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java178
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java53
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/FailureAAITreeNode.java31
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java20
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java139
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java52
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java193
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java41
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java54
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.java52
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/probes/ExternalComponentStatus.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java61
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java115
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java22
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java74
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java90
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java60
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java81
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java18
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java148
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java41
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java30
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper2.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapperInterface.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java40
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java237
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/RestObject.java17
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/RestObjectWithRequestInfo.java (renamed from vid-app-common/src/test/java/org/onap/fusionapp/controller/NetMapTest.java)58
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/BaseResourceInstantiationRequestDetails.java142
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/CloudConfiguration.java173
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/InstanceGroupInstantiationRequestDetails.java48
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/ModelInfo.java279
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/NetworkInstantiationRequestDetails.java86
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfo.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/RequestInfo.java376
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/RequestParameters.java123
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/RequestReferences.java121
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceDeletionRequestDetails.kt15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/ServiceInstantiationRequestDetails.java84
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/UserParam.java98
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/UserParamTypes.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleInstantiationRequestDetails.java111
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/VfModuleMacro.java71
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/VnfInstantiationRequestDetails.java87
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/VolumeGroupRequestDetails.java18
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java27
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatusList.java17
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/InstanceIds.java202
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java186
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedInstance.java84
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedModel.java125
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/Request.java231
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java41
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestList.java23
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestStatus.java208
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java25
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/SubscriberInfo.java144
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/policy/PolicyProperties.java26
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/policy/PolicyResponseWrapper.java56
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInt.java66
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInterface.java230
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInterfaceFactory.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInterfaceIfc.java58
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/policy/PolicyUtil.java71
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/policy/RestObject.java68
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/policy/rest/RequestDetails.java107
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/properties/Features.java27
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/properties/FeaturesTogglingConfiguration.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/properties/VidProperties.java34
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java61
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/RestObject.java44
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/RestObjects/RestObject.java39
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java62
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterfaceIfc.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerService.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerServiceImpl.java43
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AAIServiceTree.java247
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AAITreeNodeBuilder.java281
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AaiService.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java138
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogic.java39
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java767
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AuditService.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AuditServiceImpl.java127
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/BulkInstantiationService.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/BulkInstantiationServiceImpl.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java61
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerService.java12
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java76
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/CsvService.java1
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java16
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/WorkflowService.java1
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/KotlinUtils.kt10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Logging.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Multival.java54
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Streams.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/TimeUtils.java21
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Tree.kt44
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Unchecked.java23
-rw-r--r--vid-app-common/src/main/resources/1712_ADIOD.zipbin89316 -> 89573 bytes
-rw-r--r--vid-app-common/src/main/resources/2f80c596.zipbin87214 -> 87488 bytes
-rw-r--r--vid-app-common/src/main/resources/adiod.zipbin79510 -> 79927 bytes
-rw-r--r--vid-app-common/src/main/resources/cacheConfig.json17
-rw-r--r--vid-app-common/src/main/resources/csar317927061915233480.zipbin61779 -> 62196 bytes
-rw-r--r--vid-app-common/src/main/resources/csar3933948645405128424.zipbin102261 -> 102599 bytes
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/cloudConfiguration19
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/instanceIds29
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/modelInfo42
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/relatedInstance16
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/relatedModel15
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/request32
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/requestDetails13
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/requestError27
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/requestInfo52
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/requestParameters23
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/requestReferences18
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/requestStatus32
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/response13
-rwxr-xr-xvid-app-common/src/main/resources/json/mso/subscriberInfo19
-rw-r--r--vid-app-common/src/main/resources/pnf.zipbin33299 -> 33397 bytes
-rw-r--r--vid-app-common/src/main/resources/sdcservices.json42
-rw-r--r--vid-app-common/src/main/resources/service-AmpPhSvc-csar.zipbin67244 -> 67661 bytes
-rw-r--r--vid-app-common/src/main/resources/service-vf-csar.zipbin57116 -> 57455 bytes
-rw-r--r--vid-app-common/src/main/resources/service-vf-with-annotations.zipbin117760 -> 118031 bytes
-rw-r--r--vid-app-common/src/main/resources/service-vl-csar.zipbin34490 -> 34965 bytes
-rw-r--r--vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties28
-rw-r--r--vid-app-common/src/main/webapp/WEB-INF/conf/features.properties40
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js21
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js5
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/constants/vidConfiguration.js5
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js131
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js13
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceProxyConfigController.js21
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/VidApp.js2
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js132
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js2
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitModalController.js9
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js2
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js6
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js6
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js16
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js138
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.css62
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html78
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js77
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/asdcService.js59
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js6
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js12
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js6
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/msoService.js38
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/propertyService.js9
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/view-models/aaiGetSubs.htm3
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/view-models/change-management.html6
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/view-models/instantiate.htm40
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/view-models/serviceModels.htm6
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/view-models/serviceProxyConfig.htm4
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/test/testMso.js1
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/test/testViewEdit.js1
-rwxr-xr-xvid-app-common/src/main/webapp/test.jsp29
-rw-r--r--vid-app-common/src/test/java/org/onap/ecomp/vid/selenium/FirstClass.java606
-rw-r--r--vid-app-common/src/test/java/org/onap/ecomp/vid/selenium/LogOutLeftPane.java242
-rw-r--r--vid-app-common/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java177
-rw-r--r--vid-app-common/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java75
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/RelatedToTest.java37
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java531
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java72
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientTest.java12
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java18
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java5
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetPnfResponseTest.java10
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/model/PnfPropertiesTest.java4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/model/PnfResultTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/CacheConfigTest.java32
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/CacheProviderTest.java41
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/CacheProviderWithLoadingCacheTest.java313
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java41
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/NonCachingCacheProvider.java14
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/ServiceInstanceStandardQueryTest.java405
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/SingleAAIRestInterfaceTest.java75
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/PropertyTest.java112
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java281
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserInflatorTest.java120
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/parser/VidNotionsBuilderTest.java290
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/bl/AaiServiceTest.java2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/client/HttpsBasicClientTest.java17
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/config/DataSourceConfig.java7
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/config/JobCommandsConfigWithMockedMso.java207
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java12
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryControllerTest.java120
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/ChangeManagementControllerTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/controllers/ChangeManagementControllerTest.java)63
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/ClientCredentialsFilterTest.java1
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/HealthCheckControllerTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/controllers/HealthCheckControllerTest.java)2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java23
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/LoggerControllerTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/controllers/LoggerControllerTest.java)11
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/MaintenanceControllerTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/controllers/MaintenanceControllerTest.java)4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerNewTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/controllers/MsoControllerNewTest.java)15
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java17
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/PropertyControllerTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/controllers/PropertyControllerTest.java)7
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/RoleGeneratorControllerTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/controllers/RoleGeneratorControllerTest.java)2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/ServicePermissionsTest.java48
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/ToscaParserMockHelper.java37
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/VersionControllerTest.java31
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/VidControllerTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/controllers/VidControllerTest.java)4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/ViewEditSubControllerTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/controllers/ViewEditSubControllerTest.java)2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controllers/AaiControllerTest.java440
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controllers/LocalWebConfig.java70
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controllers/MsoControllerTest.java109
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controllers/PolicyControllerTest.java30
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controllers/PromiseEcompRequestIdFilterTest.java169
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controllers/ToscaParserMockHelper.java42
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/CommandUtilsTest.java88
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/InProgressStatusCommandTest.java143
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/InProgressStatusServiceTest.java83
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/InstanceGroupCommandTest.java85
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/JobCommandFactoryTest.java36
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java303
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/ResourceInProgressStatusCommandTest.java40
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInProgressStatusCommandTest.java208
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/ServiceInstantiationCommandTest.java157
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/WatchChildrenJobsBLTest.java98
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/WatchingCommandTest.java77
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java925
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/JobAdapterImplTest.java110
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/JobAdapterTest.java100
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/JobSchedulerInitializerTest.java121
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/JobWorkerTest.java9
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/model/JobAuditStatusTest.java40
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/model/RequestReferencesContainerTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java22
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java14
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/RequestDetailsTest.java63
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java108
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/AsyncRequestStatusTest.java2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java14
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java14
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestIdTest.java)104
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedModelTest.java93
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java8
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestTest.java2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/policy/PolicyResponseWrapperTest.java70
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/policy/PolicyRestIntTest.java22
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/policy/PolicyRestInterfaceFactoryTest.java18
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/policy/PolicyRestInterfaceTest.java32
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/policy/PolicyUtilTest.java51
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/policy/RestObjectTest.java48
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/policy/rest/RequestDetailsTest.java33
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java14
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjectTest.java20
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/scheduler/RestObjects/RestObjectTest.java1
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/scheduler/SchedulerRestInterfaceTest.java9
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/selenium/FirstClass.java605
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/selenium/LogOutLeftPane.java242
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AAIServiceTreeTest.java160
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AAITreeConverterTest.java222
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AAITreeNodeBuilderTest.java131
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AaiResponseTranslatorTest.java5
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java220
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java877
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AuditServiceImplTest.java36
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/BulkInstantiationServiceImplTest.java36
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java20
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceTest.java29
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java9
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/CloudOwnerServiceTest.java125
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/CsvServiceTest.java162
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java1287
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/PortDetailsTranslatorTest.java261
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/SchedulerServiceImplTest.java179
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java58
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/utils/LoggingTest.java10
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/utils/LoggingUtilsTest.java10
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/utils/TimeUtilsTest.java67
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/utils/TreeTest.java63
-rw-r--r--vid-app-common/src/test/resources/WEB-INF/fusion/conf/fusion.properties39
-rw-r--r--vid-app-common/src/test/resources/WEB-INF/fusion/defs/definitions.xml25
-rw-r--r--vid-app-common/src/test/resources/WEB-INF/fusion/orm/RNoteBookIntegration.hbm.xml34
-rw-r--r--vid-app-common/src/test/resources/cacheConfig.json13
-rw-r--r--vid-app-common/src/test/resources/cr-csar.JSON6
-rw-r--r--vid-app-common/src/test/resources/csv_files/csv_to_json.csv2
-rw-r--r--vid-app-common/src/test/resources/fabric-configuration.json52
-rw-r--r--vid-app-common/src/test/resources/fabric-real-sriov-configuration.json51
-rw-r--r--vid-app-common/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker1
-rw-r--r--vid-app-common/src/test/resources/orchestrationRequestsByServiceInstanceId.json200
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_deletion_request.json19
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_request.json34
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_alacarte_service_request_naming_false.json32
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_macro_service_request.json (renamed from vid-app-common/src/test/resources/payload_jsons/bulk_service_request.json)2
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_service_request_ecomp_naming.json9
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_service_request_no_vfmodule_ecomp_naming.json1
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_service_request_unique_names.json21
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request.json48
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request_without_cloud_owner.json47
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/bulk_vnf_request_without_instance_name.json47
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/instance_group_instantiation_request.json36
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/network_instantiation_request.json48
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/network_instantiation_request_without_instance_name.json47
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/scaleOutVfModulePayload.json17
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/scaleOutVfModulePayloadToMso.json16
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfModuleDeactivateAndCloudDelete.json17
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request.json69
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_instance_name.json59
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_volume_group.json60
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/volumegroup_instantiation_request.json56
-rw-r--r--vid-app-common/src/test/resources/policy-configuration-by-policy-false.JSON9
-rw-r--r--vid-app-common/src/test/resources/policy-configuration-csar.JSON33
-rw-r--r--vid-app-common/src/test/resources/responses/aai/getCloudRegionAndTenantByVnfId.json119
-rw-r--r--vid-app-common/src/test/resources/responses/mso/orchestrationRequestsMockedMinimalResponse.json11
-rw-r--r--vid-app-common/src/test/resources/responses/mso/orchestrationRequestsServiceInstance.json19
-rw-r--r--vid-app-common/src/test/resources/responses/mso/orchestrationRequestsVnf.json68
-rw-r--r--vid-app-common/src/test/resources/vf-csar.JSON12
-rw-r--r--vid-app-common/src/test/resources/vf-with-annotation-csar.json102
-rw-r--r--vid-app-common/src/test/resources/vf-with-vfcInstanceGroups.json9
-rw-r--r--vid-app-common/src/test/resources/vl-csar.JSON9
-rw-r--r--vid-app-common/src/test/resources/vlan-tagging.json222
-rw-r--r--vid-app-common/src/test/resources/vnf-grouping-csar.json145
-rw-r--r--vid-app-common/src/test/resources/vnfConfigUpdatePayload.json2
-rw-r--r--vid-automation/TestNg-ApiTest.xml2
-rw-r--r--vid-automation/TestNg-UI-half.xml15
-rw-r--r--vid-automation/TestNg-dev.xml (renamed from vid-automation/TestNg.xml)14
-rw-r--r--vid-automation/conf/services2
-rw-r--r--vid-automation/conf/users4
-rw-r--r--vid-automation/pom.xml11
-rw-r--r--vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOServiceInstanceGen2WithNames.java2
-rw-r--r--vid-automation/src/main/java/vid/automation/test/services/UsersService.java2
-rw-r--r--vid-automation/src/main/java/vid/automation/test/test/VidBaseTestCase.java19
-rw-r--r--vid-automation/src/main/java/vid/automation/test/test/ViewEditServiceInstanceTest.java3
-rw-r--r--vid-automation/src/main/java/vid/automation/test/utils/DB_CONFIG.java2
-rw-r--r--vid-automation/src/main/resources/META-INF/aop-ajc.xml16
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationApiTest.java11
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/BaseApiAaiTest.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/BaseApiTest.java9
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/BaseMsoApiTest.java4
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/ChangeManagementApiTest.java4
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/OperationalEnvironmentControllerApiTest.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/ProbeApiTest.java7
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/SampleApiTest.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/model/probe/ExternalComponentStatus.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java2
-rw-r--r--vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java4
-rw-r--r--vid-automation/src/test/resources/test_config.properties4
-rw-r--r--vid-ext-services-simulator/pom.xml6
558 files changed, 22078 insertions, 11192 deletions
diff --git a/epsdk-app-onap/pom.xml b/epsdk-app-onap/pom.xml
index fb80e24..f2441b3 100755
--- a/epsdk-app-onap/pom.xml
+++ b/epsdk-app-onap/pom.xml
@@ -127,7 +127,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.19.1</version>
+ <version>2.22.1</version>
<configuration>
<includes>
<include>**/Test*.java</include>
@@ -205,7 +205,7 @@
</dependencies>
</plugin>
<plugin>
- <groupId>org.sonarsource.scanner.maven</groupId>
+ <groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.3.0.603</version>
</plugin>
diff --git a/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java b/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
index 0c6fba9..3fa0839 100644
--- a/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
+++ b/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
@@ -37,11 +37,6 @@
*/
package org.onap.portalapp.conf;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.sql.DataSource;
-
import org.onap.portalapp.login.LoginStrategyImpl;
import org.onap.portalapp.scheduler.RegistryAdapter;
import org.onap.portalsdk.core.auth.LoginStrategy;
@@ -54,13 +49,11 @@ import org.onap.portalsdk.core.util.CacheManager;
import org.onap.portalsdk.core.util.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.DependsOn;
-import org.springframework.context.annotation.Import;
-import org.springframework.context.annotation.Profile;
-import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.annotation.*;
+import org.springframework.core.io.Resource;
+import org.springframework.jdbc.datasource.init.DataSourceInitializer;
+import org.springframework.jdbc.datasource.init.DatabasePopulator;
+import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
@@ -70,10 +63,10 @@ import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
-import org.springframework.core.io.Resource;
-import org.springframework.jdbc.datasource.init.DataSourceInitializer;
-import org.springframework.jdbc.datasource.init.DatabasePopulator;
-import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
+
+import javax.sql.DataSource;
+import java.util.ArrayList;
+import java.util.List;
/**
* ONAP Portal SDK sample application. Extends core AppConfig class to
@@ -86,6 +79,7 @@ import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
@Profile("src")
@EnableAsync
@EnableScheduling
+@EnableAspectJAutoProxy(proxyTargetClass=true)
public class ExternalAppConfig extends AppConfig implements Configurable {
private RegistryAdapter schedulerRegistryAdapter;
@@ -177,18 +171,12 @@ public class ExternalAppConfig extends AppConfig implements Configurable {
* populates it with triggers.
*
* @return New instance of {@link SchedulerFactoryBean}
- * @throws Exception
*/
- @Bean // ANNOTATION COMMENTED OUT
- // APPLICATIONS REQUIRING QUARTZ SHOULD RESTORE ANNOTATION
- @DependsOn("dataSourceInitializer")
- public SchedulerFactoryBean schedulerFactoryBean() throws Exception {
- SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
- scheduler.setTriggers(schedulerRegistryAdapter.getTriggers());
- scheduler.setConfigLocation(appApplicationContext.getResource("WEB-INF/conf/quartz.properties"));
- scheduler.setDataSource(dataSource());
- scheduler.setJobFactory(new SpringBeanJobFactory());
- return scheduler;
+ @Bean
+ public SchedulerFactoryBean schedulerFactoryBean() {
+ SchedulerFactoryBean schedulerFactory = new SchedulerFactoryBean();
+ schedulerFactory.setJobFactory(new SpringBeanJobFactory());
+ return schedulerFactory;
}
diff --git a/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppInitializer.java b/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppInitializer.java
index 93e867d..dc6973f 100644
--- a/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppInitializer.java
+++ b/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppInitializer.java
@@ -37,12 +37,8 @@
*/
package org.onap.portalapp.conf;
-import org.onap.vid.controllers.ChangeManagementController;
-import org.onap.vid.controllers.MaintenanceController;
-import org.onap.vid.controllers.RoleGeneratorController;
import org.onap.portalsdk.core.conf.AppInitializer;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
+
import java.util.TimeZone;
public class ExternalAppInitializer extends AppInitializer {
diff --git a/pom.xml b/pom.xml
index 70a7ac7..eff3649 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,249 +1,249 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.onap.vid</groupId>
- <artifactId>vid-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>vid</name>
-
- <profiles>
- <!-- DO NOT CHANGE THE *ORDER* IN WHICH THESE PROFILES ARE DEFINED! -->
-
- <profile>
- <id>onap</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <modules>
- <module>vid-app-common</module>
- <module>vid-webpack-master</module>
- <module>epsdk-app-onap</module>
- </modules>
-
- <repositories>
- <repository>
- <id>ecomp-releases</id>
- <name>VID Release Repository</name>
- <url>${nexusproxy}/${releaseNexusPath}</url>
- </repository>
- <repository>
- <id>ecomp-snapshots</id>
- <name>VID Snapshot Repository</name>
- <url>${nexusproxy}/${snapshotNexusPath}</url>
- </repository>
- <repository>
- <id>ecomp-staging</id>
- <name>VID Staging Repository</name>
- <url>${nexusproxy}/${stagingNexusPath}</url>
- </repository>
- <repository>
- <!-- Snapshots repository has ECOMP snapshot artifacts -->
- <id>oss-snapshots</id>
- <name>oss Central - Snapshots</name>
- <url>https://oss.sonatype.org/service/local/repositories/releases/content/</url>
- </repository>
- </repositories>
-
- <distributionManagement>
- <repository>
- <id>ecomp-releases</id>
- <name>VID Release Repository</name>
- <url>${nexusproxy}/${releaseNexusPath}</url>
- </repository>
- <snapshotRepository>
- <id>ecomp-snapshots</id>
- <name>VID Snapshot Repository</name>
- <url>${nexusproxy}/${snapshotNexusPath}</url>
- </snapshotRepository>
- <!-- added for javadoc -->
- <site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
- </site>
- </distributionManagement>
-
- </profile>
-
- <profile>
- <id>docker</id>
- <modules>
- <module>vid-app-common</module>
- <module>vid-webpack-master</module>
- <module>epsdk-app-onap</module>
- <module>deliveries</module>
- </modules>
- </profile>
- </profiles>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <build.version>4.0.0-SNAPSHOT</build.version>
- <nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
- <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
- <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
- <sitePath>/content/sites/site/org/onap/vid/${project.version}</sitePath>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>versions-maven-plugin</artifactId>
- <version>1.3.1</version>
- </plugin>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.7</version>
- <extensions>true</extensions>
- <configuration>
- <nexusUrl>${nexusproxy}</nexusUrl>
- <stagingProfileId>176c31dfe190a</stagingProfileId>
- <serverId>ecomp-staging</serverId>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.6</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-webdav-jackrabbit</artifactId>
- <version>2.10</version>
- </dependency>
- </dependencies>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <version>2.8</version>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.17</version>
- <configuration>
- <useSystemClassLoader>false</useSystemClassLoader>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
-
- <configuration>
- <debug>true</debug>
- <compilerArgument>-Xlint</compilerArgument>
- <verbose>true</verbose>
- <showDeprecation>true</showDeprecation>
- <showWarnings>true</showWarnings>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.sonarsource.scanner.maven</groupId>
- <artifactId>sonar-maven-plugin</artifactId>
- <version>3.3.0.603</version>
- </plugin>
- <plugin>
- <groupId>com.blackducksoftware.integration</groupId>
- <artifactId>hub-maven-plugin</artifactId>
- <version>1.4.0</version>
- <inherited>false</inherited>
- <configuration>
- <hubProjectName>${project.name}</hubProjectName>
- <outputDirectory>${project.basedir}</outputDirectory>
- </configuration>
- <executions>
- <execution>
- <id>create-bdio-file</id>
- <phase>package</phase>
- <goals>
- <goal>createHubOutput</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <!-- added for javadoc -->
- <pluginRepositories>
- <!-- Black Duck plugin dependencies -->
- <pluginRepository>
- <id>JCenter</id>
- <name>JCenter Repository</name>
- <url>http://jcenter.bintray.com</url>
- </pluginRepository>
-
- <pluginRepository>
- <id>Restlet</id>
- <name>Restlet Repository</name>
- <url>http://maven.restlet.com</url>
- </pluginRepository>
- </pluginRepositories>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
- <configuration>
- <failOnError>false</failOnError>
- <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
- <docletArtifact>
- <groupId>org.umlgraph</groupId>
- <artifactId>umlgraph</artifactId>
- <version>5.6</version>
- </docletArtifact>
- <additionalparam>-views</additionalparam>
- <useStandardDocletOptions>true</useStandardDocletOptions>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
-
- <!--Overide versions for latest security fixes-->
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>1.2.3</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>1.2.3</version>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.poi</groupId>
- <artifactId>poi</artifactId>
- <version>3.17</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.5.3</version>
- </dependency>
- </dependencies>
-</project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.onap.vid</groupId>
+ <artifactId>vid-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>vid</name>
+
+ <profiles>
+ <!-- DO NOT CHANGE THE *ORDER* IN WHICH THESE PROFILES ARE DEFINED! -->
+
+ <profile>
+ <id>onap</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>vid-app-common</module>
+ <module>vid-webpack-master</module>
+ <module>epsdk-app-onap</module>
+ </modules>
+
+ <repositories>
+ <repository>
+ <id>ecomp-releases</id>
+ <name>VID Release Repository</name>
+ <url>${nexusproxy}/${releaseNexusPath}</url>
+ </repository>
+ <repository>
+ <id>ecomp-snapshots</id>
+ <name>VID Snapshot Repository</name>
+ <url>${nexusproxy}/${snapshotNexusPath}</url>
+ </repository>
+ <repository>
+ <id>ecomp-staging</id>
+ <name>VID Staging Repository</name>
+ <url>${nexusproxy}/${stagingNexusPath}</url>
+ </repository>
+ <repository>
+ <!-- Snapshots repository has ECOMP snapshot artifacts -->
+ <id>oss-snapshots</id>
+ <name>oss Central - Snapshots</name>
+ <url>https://oss.sonatype.org/service/local/repositories/releases/content/</url>
+ </repository>
+ </repositories>
+
+ <distributionManagement>
+ <repository>
+ <id>ecomp-releases</id>
+ <name>VID Release Repository</name>
+ <url>${nexusproxy}/${releaseNexusPath}</url>
+ </repository>
+ <snapshotRepository>
+ <id>ecomp-snapshots</id>
+ <name>VID Snapshot Repository</name>
+ <url>${nexusproxy}/${snapshotNexusPath}</url>
+ </snapshotRepository>
+ <!-- added for javadoc -->
+ <site>
+ <id>ecomp-site</id>
+ <url>dav:${nexusproxy}${sitePath}</url>
+ </site>
+ </distributionManagement>
+
+ </profile>
+
+ <profile>
+ <id>docker</id>
+ <modules>
+ <module>vid-app-common</module>
+ <module>vid-webpack-master</module>
+ <module>epsdk-app-onap</module>
+ <module>deliveries</module>
+ </modules>
+ </profile>
+ </profiles>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <build.version>4.0.0-SNAPSHOT</build.version>
+ <nexusproxy>https://nexus.onap.org</nexusproxy>
+ <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
+ <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
+ <stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
+ <sitePath>/content/sites/site/org/onap/vid/${project.version}</sitePath>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>versions-maven-plugin</artifactId>
+ <version>1.3.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.sonatype.plugins</groupId>
+ <artifactId>nexus-staging-maven-plugin</artifactId>
+ <version>1.6.7</version>
+ <extensions>true</extensions>
+ <configuration>
+ <nexusUrl>${nexusproxy}</nexusUrl>
+ <stagingProfileId>176c31dfe190a</stagingProfileId>
+ <serverId>ecomp-staging</serverId>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.6</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav-jackrabbit</artifactId>
+ <version>2.10</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.8</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.22.1</version>
+ <configuration>
+ <useSystemClassLoader>false</useSystemClassLoader>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+
+ <configuration>
+ <debug>true</debug>
+ <compilerArgument>-Xlint</compilerArgument>
+ <verbose>true</verbose>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.sonarsource.scanner.maven</groupId>
+ <artifactId>sonar-maven-plugin</artifactId>
+ <version>3.3.0.603</version>
+ </plugin>
+ <plugin>
+ <groupId>com.blackducksoftware.integration</groupId>
+ <artifactId>hub-maven-plugin</artifactId>
+ <version>1.4.0</version>
+ <inherited>false</inherited>
+ <configuration>
+ <hubProjectName>${project.name}</hubProjectName>
+ <outputDirectory>${project.basedir}</outputDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <id>create-bdio-file</id>
+ <phase>package</phase>
+ <goals>
+ <goal>createHubOutput</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- added for javadoc -->
+ <pluginRepositories>
+ <!-- Black Duck plugin dependencies -->
+ <pluginRepository>
+ <id>JCenter</id>
+ <name>JCenter Repository</name>
+ <url>http://jcenter.bintray.com</url>
+ </pluginRepository>
+
+ <pluginRepository>
+ <id>Restlet</id>
+ <name>Restlet Repository</name>
+ <url>http://maven.restlet.com</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.4</version>
+ <configuration>
+ <failOnError>false</failOnError>
+ <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
+ <docletArtifact>
+ <groupId>org.umlgraph</groupId>
+ <artifactId>umlgraph</artifactId>
+ <version>5.6</version>
+ </docletArtifact>
+ <additionalparam>-views</additionalparam>
+ <useStandardDocletOptions>true</useStandardDocletOptions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--Overide versions for latest security fixes-->
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>1.2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi</artifactId>
+ <version>3.17</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.3</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/vid-app-common/TestNg-BE-UnitTest.xml b/vid-app-common/TestNg-BE-UnitTest.xml
new file mode 100644
index 0000000..b4b05bd
--- /dev/null
+++ b/vid-app-common/TestNg-BE-UnitTest.xml
@@ -0,0 +1,11 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+
+<suite verbose="1" name="VID BE Unit Tests" annotations="JDK">
+
+ <test name="VID BE Unit Tests">
+ <packages>
+ <package name="org.onap.vid.*"/>
+ <package name="org.opencomp.vid.*"/>
+ </packages>
+ </test>
+</suite> \ No newline at end of file
diff --git a/vid-app-common/pom.xml b/vid-app-common/pom.xml
index 9a01c6c..7cd30a2 100755
--- a/vid-app-common/pom.xml
+++ b/vid-app-common/pom.xml
@@ -21,6 +21,10 @@
<epsdk.version>2.4.0</epsdk.version>
<springframework.version>4.2.9.RELEASE</springframework.version>
<hibernate.version>4.3.11.Final</hibernate.version>
+ <jackson.version>2.9.7</jackson.version>
+ <jersey.version>2.27</jersey.version>
+ <surefire.version>2.22.1</surefire.version>
+
<!-- Skip assembling the zip by default -->
<skipassembly>true</skipassembly>
<nexusproxy>https://nexus.onap.org</nexusproxy>
@@ -28,6 +32,11 @@
<releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
<stagingNexusPath>/content/repositories/staging/</stagingNexusPath>
<sitePath>/content/sites/site/org/onap/vid/${project.version}</sitePath>
+
+ <aspectj.version>1.8.9</aspectj.version>
+ <kotlin.version>1.3.11</kotlin.version>
+ <kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
+
</properties>
@@ -80,6 +89,33 @@
<finalName>vid-common</finalName>
<plugins>
+
+ <plugin>
+ <artifactId>kotlin-maven-plugin</artifactId>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <version>${kotlin.version}</version>
+ <executions>
+ <execution>
+ <id>compile</id>
+ <goals> <goal>compile</goal> </goals>
+ <configuration>
+ <sourceDirs>
+ <sourceDir>${project.basedir}/src/main/java</sourceDir>
+ </sourceDirs>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-compile</id>
+ <goals> <goal>test-compile</goal> </goals>
+ <configuration>
+ <sourceDirs>
+ <sourceDir>${project.basedir}/src/test/java</sourceDir>
+ </sourceDirs>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
@@ -121,39 +157,44 @@
<version>2.2</version>
</plugin>
- <!-- Generate POJOs from MSO json schema -->
<plugin>
- <groupId>org.jsonschema2pojo</groupId>
- <artifactId>jsonschema2pojo-maven-plugin</artifactId>
- <version>0.4.23</version>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.5.1</version>
<configuration>
- <sourceDirectory>${basedir}/src/main/resources/json/mso</sourceDirectory>
- <targetPackage>org.onap.vid.domain.mso</targetPackage>
- <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
+ <source>1.8</source>
+ <target>1.8</target>
</configuration>
+
<executions>
+ <!-- Replacing default-compile as it is treated specially by maven -->
<execution>
- <goals>
- <goal>generate</goal>
- </goals>
+ <id>default-compile</id>
+ <phase>none</phase>
+ </execution>
+ <!-- Replacing default-testCompile as it is treated specially by maven -->
+ <execution>
+ <id>default-testCompile</id>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>java-compile</id>
+ <phase>compile</phase>
+ <goals> <goal>compile</goal> </goals>
+ </execution>
+ <execution>
+ <id>java-test-compile</id>
+ <phase>test-compile</phase>
+ <goals> <goal>testCompile</goal> </goals>
</execution>
</executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.19.1</version>
+ <version>${surefire.version}</version>
<configuration>
<includes>
<include>**/Test*.java</include>
@@ -171,7 +212,29 @@
<container.classpath>classpath:</container.classpath>
</systemPropertyVariables>
<useSystemClassLoader>false</useSystemClassLoader>
+ <properties>
+ <property>
+ <!-- avoid running JUnit tests within surefire-testng provider -->
+ <name>junit</name>
+ <value>false</value>
+ </property>
+ </properties>
+ <threadCount>1</threadCount>
</configuration>
+ <dependencies>
+ <!-- Running TestNG and JUnit Tests -->
+ <!-- https://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html -->
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit47</artifactId>
+ <version>${surefire.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-testng</artifactId>
+ <version>${surefire.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
<plugin>
@@ -234,8 +297,7 @@
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
<dateFormatTimeZone>${user.timezone}</dateFormatTimeZone>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
- <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
- </generateGitPropertiesFilename>
+ <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<includeOnlyProperties>
<includeOnlyProperty>^git.commit.id$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.message.short$</includeOnlyProperty>
@@ -285,7 +347,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>4.3.6</version>
+ <version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
@@ -368,26 +430,32 @@
<version>1.2.3</version>
</dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib-jdk8</artifactId>
+ <version>${kotlin.version}</version>
+ </dependency>
+
<!-- Mapper -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
- <version>2.6.3</version>
+ <version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
- <version>2.8.6</version>
+ <version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>2.6.7.1</version>
+ <version>${jackson.version}</version>
</dependency>
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>1.9.13</version>
+ <groupId>com.fasterxml.jackson.module</groupId>
+ <artifactId>jackson-module-kotlin</artifactId>
+ <version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
@@ -415,6 +483,7 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
@@ -490,17 +559,23 @@
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
- <version>2.23.1</version>
+ <version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jetty-connector</artifactId>
- <version>2.23.1</version>
+ <version>${jersey.version}</version>
+ </dependency>
+ <!--https://stackoverflow.com/questions/44088493/jersey-stopped-working-with-injectionmanagerfactory-not-found-->
+ <dependency>
+ <groupId>org.glassfish.jersey.inject</groupId>
+ <artifactId>jersey-hk2</artifactId>
+ <version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
- <version>2.6.3</version>
+ <version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
@@ -527,7 +602,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>6.8</version>
+ <version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -555,11 +630,12 @@
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<version>1.5.0</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.onap.sdc.sdc-tosca</groupId>
<artifactId>sdc-tosca</artifactId>
- <version>1.4.1</version>
+ <version>1.4.7</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -569,11 +645,27 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-json-jackson</artifactId>
+ <version>${jersey.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.6</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.1</version>
</dependency>
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-proxy</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
<groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId>
<version>2.0.0.0</version>
@@ -585,10 +677,27 @@
<version>2.5.0.Final</version>
</dependency>
<dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.4.196</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.2.11</version>
+ </dependency>
+
+ <dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.10.0</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>23.0</version>
+ </dependency>
</dependencies>
</project>
diff --git a/vid-app-common/src/main/java/org/onap/vid/RelatedTo.java b/vid-app-common/src/main/java/org/onap/vid/RelatedTo.java
deleted file mode 100644
index 08e0281..0000000
--- a/vid-app-common/src/main/java/org/onap/vid/RelatedTo.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.onap.vid;
-
-import com.fasterxml.jackson.annotation.*;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-import java.util.HashMap;
-import java.util.Map;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
- "id",
- "node-type",
- "relationship-label",
- "url"
-})
-public class RelatedTo {
-
- @JsonProperty("id")
- public String id;
- @JsonProperty("node-type")
- public String nodeType;
- @JsonProperty("relationship-label")
- public String relationshipLabel;
- @JsonProperty("url")
- public String url;
- @JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<>();
-
- @JsonAnyGetter
- public Map<String, Object> getAdditionalProperties() {
- return this.additionalProperties;
- }
-
- @JsonAnySetter
- public void setAdditionalProperty(String name, Object value) {
- this.additionalProperties.put(name, value);
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
index baf92b8..e1a1e70 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
@@ -1,25 +1,25 @@
package org.onap.vid.aai;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.ObjectMapper;
+import org.jetbrains.annotations.NotNull;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.aai.exceptions.InvalidAAIResponseException;
import org.onap.vid.aai.model.AaiGetAicZone.AicZones;
import org.onap.vid.aai.model.*;
import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.*;
import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
import org.onap.vid.aai.model.AaiGetServicesRequestModel.GetServicesAAIRespone;
-import org.onap.vid.aai.model.Relationship;
-import org.onap.vid.aai.model.RelationshipData;
-import org.onap.vid.aai.model.RelationshipList;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
import org.onap.vid.aai.util.AAIRestInterface;
+import org.onap.vid.aai.util.CacheProvider;
import org.onap.vid.aai.util.VidObjectMapperType;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.SubscriberList;
@@ -27,6 +27,8 @@ import org.onap.vid.model.probes.ErrorMetadata;
import org.onap.vid.model.probes.ExternalComponentStatus;
import org.onap.vid.model.probes.HttpRequestMetadata;
import org.onap.vid.utils.Logging;
+import org.onap.vid.utils.Unchecked;
+import org.springframework.http.HttpMethod;
import org.springframework.web.util.UriUtils;
import javax.inject.Inject;
@@ -34,15 +36,16 @@ import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import java.net.URI;
import java.net.URLEncoder;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.UUID;
+import java.util.function.Function;
import static java.util.Collections.emptyList;
+import static java.util.stream.Collectors.toMap;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
/**
@@ -52,13 +55,13 @@ import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
public class AaiClient implements AaiClientInterface {
- public static final String QUERY_FORMAT_RESOURCE = "query?format=resource";
- public static final String SERVICE_SUBSCRIPTIONS_PATH = "/service-subscriptions/service-subscription/";
- public static final String MODEL_INVARIANT_ID = "&model-invariant-id=";
- public static final String QUERY_FORMAT_SIMPLE = "query?format=simple";
- public static final String BUSINESS_CUSTOMER = "/business/customers/customer/";
- public static final String SERVICE_INSTANCE = "/service-instances/service-instance/";
- public static final String BUSINESS_CUSTOMERS_CUSTOMER = "business/customers/customer/";
+ private static final String QUERY_FORMAT_RESOURCE = "query?format=resource";
+ private static final String SERVICE_SUBSCRIPTIONS_PATH = "/service-subscriptions/service-subscription/";
+ private static final String MODEL_INVARIANT_ID = "&model-invariant-id=";
+ private static final String QUERY_FORMAT_SIMPLE = "query?format=simple";
+ private static final String BUSINESS_CUSTOMER = "/business/customers/customer/";
+ private static final String SERVICE_INSTANCE = "/service-instances/service-instance/";
+ private static final String BUSINESS_CUSTOMERS_CUSTOMER = "business/customers/customer/";
protected String fromAppId = "VidAaiController";
@@ -66,22 +69,22 @@ public class AaiClient implements AaiClientInterface {
private final AAIRestInterface restController;
+ private final CacheProvider cacheProvider;
+
+ ObjectMapper objectMapper = new ObjectMapper();
+
/**
* The logger
*/
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AaiClient.class);
- /**
- * The Constant dateFormat.
- */
- static final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
-
- static final String GET_SERVICE_MODELS_RESPONSE_BODY = "{\"start\" : \"service-design-and-creation/models/\", \"query\" : \"query/serviceModels-byDistributionStatus?distributionStatus=DISTRIBUTION_COMPLETE_OK\"}";
+ private static final String GET_SERVICE_MODELS_RESPONSE_BODY = "{\"start\" : \"service-design-and-creation/models/\", \"query\" : \"query/serviceModels-byDistributionStatus?distributionStatus=DISTRIBUTION_COMPLETE_OK\"}";
@Inject
- public AaiClient(AAIRestInterface restController, PortDetailsTranslator portDetailsTranslator) {
+ public AaiClient(AAIRestInterface restController, PortDetailsTranslator portDetailsTranslator, CacheProvider cacheProvider) {
this.restController = restController;
this.portDetailsTranslator = portDetailsTranslator;
+ this.cacheProvider = cacheProvider;
}
@@ -107,8 +110,14 @@ public class AaiClient implements AaiClientInterface {
@Override
public AaiResponse getServiceModelsByDistributionStatus() {
- Response resp = doAaiPut(QUERY_FORMAT_RESOURCE, GET_SERVICE_MODELS_RESPONSE_BODY, false);
- return processAaiResponse(resp, GetServiceModelsByDistributionStatusResponse.class, null);
+ return getFromCache("getServiceModelsByDistributionStatus", this::getServiceModelsByDistributionStatusNonCached,
+ true, "Failed to get service models by distribution status");
+ }
+
+ private AaiResponse getServiceModelsByDistributionStatusNonCached(boolean propagateExceptions) {
+ GetServiceModelsByDistributionStatusResponse response = typedAaiRest(QUERY_FORMAT_RESOURCE, GetServiceModelsByDistributionStatusResponse.class,
+ GET_SERVICE_MODELS_RESPONSE_BODY, HttpMethod.PUT, propagateExceptions);
+ return new AaiResponse(response, "", HttpStatus.SC_OK);
}
@Override
@@ -121,14 +130,14 @@ public class AaiClient implements AaiClientInterface {
@Override
public AaiResponse getInstanceGroupsByCloudRegion(String cloudOwner, String cloudRegionId, String networkFunction) {
Response resp = doAaiPut(QUERY_FORMAT_RESOURCE,
- "{\"start\": [\"cloud-infrastructure/cloud-regions/cloud-region/" + cloudOwner + "/" + cloudRegionId + "\"]," +
- "\"query\": \"query/instance-group-byCloudRegion?type=L3-NETWORK&role=SUB-INTERFACE&function=" + networkFunction + "\"}\n", false);
+ "{\"start\": [\"cloud-infrastructure/cloud-regions/cloud-region/" + encodePathSegment(cloudOwner) + "/" + encodePathSegment(cloudRegionId) + "\"]," +
+ "\"query\": \"query/instance-groups-byCloudRegion?type=L3-NETWORK&role=SUB-INTERFACE&function=" + encodePathSegment(networkFunction) + "\"}\n", false);
return processAaiResponse(resp, AaiGetInstanceGroupsByCloudRegion.class, null, VidObjectMapperType.FASTERXML);
}
private AaiResponse getNetworkCollectionDetailsResponse(AaiResponse<AaiGetNetworkCollectionDetailsHelper> aaiResponse){
if(aaiResponse.getHttpCode() == 200) {
- com.fasterxml.jackson.databind.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper();
+ ObjectMapper om = objectMapper;
AaiGetNetworkCollectionDetails aaiGetNetworkCollectionDetails = new AaiGetNetworkCollectionDetails();
try {
for (int i = 0; i < aaiResponse.getT().getResults().size(); i++) {
@@ -145,7 +154,8 @@ public class AaiClient implements AaiClientInterface {
return new AaiResponse(aaiGetNetworkCollectionDetails, null, HttpStatus.SC_OK);
}
catch (com.fasterxml.jackson.databind.JsonMappingException e) {
- return new AaiResponse(e.getCause(), "AAI response parsing Error" , aaiResponse.getHttpCode());
+ logger.error(EELFLoggerDelegate.errorLogger, "AAI response parsing Error", e);
+ return new AaiResponse(e.getCause(), "AAI response parsing Error" , HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
catch (Exception e) {
return new AaiResponse(e.getCause(), "Got " + aaiResponse.getHttpCode() + " from a&ai" , aaiResponse.getHttpCode());
@@ -183,7 +193,7 @@ public class AaiClient implements AaiClientInterface {
Response resp = doAaiPut(QUERY_FORMAT_SIMPLE, payload, false);
resp.bufferEntity(); // avoid later "Entity input stream has already been closed" problems
String rawPayload = resp.readEntity(String.class);
- AaiResponse<AaiGetPortMirroringSourcePorts> aaiResponse = processAaiResponse(resp, AaiGetPortMirroringSourcePorts.class, rawPayload);
+ AaiResponse<CustomQuerySimpleResult> aaiResponse = processAaiResponse(resp, CustomQuerySimpleResult.class, rawPayload);
return portDetailsTranslator.extractPortDetails(aaiResponse, rawPayload);
}
@@ -202,21 +212,80 @@ public class AaiClient implements AaiClientInterface {
}
@Override
- public AaiResponse<AaiNodeQueryResponse> searchNodeTypeByName(String name, ResourceType type) {
- String path = String.format(
- "search/nodes-query?search-node-type=%s&filter=%s:EQUALS:%s",
+ public boolean isNodeTypeExistsByName(String name, ResourceType type) {
+ if (StringUtils.isEmpty(name)) {
+ throw new GenericUncheckedException("Empty resource-name provided to searchNodeTypeByName; request is rejected as this will cause full resources listing");
+ }
+
+ URI path = Unchecked.toURI(String.format( // e.g. GET /aai/v$/nodes/vf-modules?vf-module-name={vf-module-name}
+ "nodes/%s?%s=%s",
type.getAaiFormat(),
type.getNameFilter(),
- name
- );
- return typedAaiGet(path, AaiNodeQueryResponse.class);
+ encodePathSegment(name)
+ ));
+ final ResponseWithRequestInfo responseWithRequestInfo = restController.RestGet(fromAppId, UUID.randomUUID().toString(), path, false, true);
+
+ return isResourceExistByStatusCode(responseWithRequestInfo);
+ }
+
+ public Map<String, Properties> getCloudRegionAndTenantByVnfId(String vnfId) {
+ String start = "/network/generic-vnfs/generic-vnf/" + vnfId;
+ String query = "/query/cloud-region-fromVnf";
+
+ String payload = "{\"start\":[\"" + start + "\"],\"query\":\"" + query + "\"}";
+ CustomQuerySimpleResult result = typedAaiRest(QUERY_FORMAT_SIMPLE, CustomQuerySimpleResult.class, payload, HttpMethod.PUT, false);
+
+ return result.getResults().stream()
+ .filter(res -> StringUtils.equals(res.getNodeType(), "tenant") ||
+ StringUtils.equals(res.getNodeType(), "cloud-region"))
+ .collect(toMap(SimpleResult::getNodeType, SimpleResult::getProperties));
+ }
+
+ private boolean isResourceExistByStatusCode(ResponseWithRequestInfo responseWithRequestInfo) {
+ // 200 - is found
+ // 404 - resource not found
+ Response.Status statusInfo = responseWithRequestInfo.getResponse().getStatusInfo().toEnum();
+ switch (statusInfo) {
+ case OK:
+ return true;
+ case NOT_FOUND:
+ return false;
+ default:
+ throw new GenericUncheckedException("Unexpected response-code (only OK and NOT_FOUND are expected): " +
+ responseWithRequestInfo.getResponse().getStatusInfo());
+ }
}
- private <T> AaiResponse<T> typedAaiGet(String path, Class<T> clz) {
- Response resp = doAaiGet(path , false);
- return processAaiResponse(resp, clz, null, VidObjectMapperType.FASTERXML);
+ @Override
+ public <T> T typedAaiGet(URI uri, Class<T> clz) {
+ return typedAaiRest(uri, clz, null, HttpMethod.GET, false);
}
+ public <T> T typedAaiRest(String path, Class<T> clz, String payload, HttpMethod method, boolean propagateExceptions) {
+ return typedAaiRest(Unchecked.toURI(path), clz, payload, method, propagateExceptions);
+ }
+
+
+ public <T> T typedAaiRest(URI path, Class<T> clz, String payload, HttpMethod method, boolean propagateExceptions) {
+ ResponseWithRequestInfo responseWithRequestInfo;
+ try {
+ responseWithRequestInfo = restController.doRest(fromAppId, UUID.randomUUID().toString(), path, payload, method, false, propagateExceptions);
+ } catch (Exception e) {
+ responseWithRequestInfo = handleExceptionFromRestCall(propagateExceptions, "doAai"+method.name(), e);
+ }
+
+ final AaiResponseWithRequestInfo<T> aaiResponse = processAaiResponse(responseWithRequestInfo, clz, VidObjectMapperType.FASTERXML, true);
+
+ if (aaiResponse.getAaiResponse().getHttpCode() > 399 || aaiResponse.getAaiResponse().getT() == null) {
+ throw new ExceptionWithRequestInfo(aaiResponse.getHttpMethod(),
+ aaiResponse.getRequestedUrl(),
+ aaiResponse.getRawData(),
+ responseWithRequestInfo.getResponse().getStatus(),
+ new InvalidAAIResponseException(aaiResponse.getAaiResponse()));
+ }
+
+ return aaiResponse.getAaiResponse().getT();
+ }
private String getUrlFromLIst(String url, String paramKey, List<String> params){
@@ -229,8 +298,8 @@ public class AaiClient implements AaiClientInterface {
encodedParam= URLEncoder.encode(param, "UTF-8");
} catch (UnsupportedEncodingException e) {
String methodName = "getUrlFromList";
- logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.error(EELFLoggerDelegate.errorLogger, methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + e.toString());
}
url = url.concat(encodedParam);
if(i != params.size()){
@@ -241,9 +310,34 @@ public class AaiClient implements AaiClientInterface {
}
+
@Override
public AaiResponse<SubscriberList> getAllSubscribers() {
- return getAllSubscribers(false).getAaiResponse();
+ return getFromCache("getAllSubscribers", this::getAllSubscribersNonCached, true, "Failed to get all subscribers");
+ }
+
+ private <K> AaiResponse getFromCache(String cacheName, Function<K, AaiResponse> function, K argument, String errorMessage) {
+ try {
+ return cacheProvider
+ .aaiClientCacheFor(cacheName, function)
+ .get(argument);
+ } catch (ExceptionWithRequestInfo exception) {
+ logger.error(errorMessage, exception);
+ return new AaiResponse(null, exception.getRawData(), exception.getHttpCode());
+ }
+ catch (Exception exception) {
+ logger.error(errorMessage, exception);
+ return new AaiResponse(null, exception.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ private AaiResponse<SubscriberList> getAllSubscribersNonCached(boolean propagateExceptions) {
+ AaiResponse<SubscriberList> aaiResponse = getAllSubscribers(propagateExceptions).getAaiResponse();
+ if (propagateExceptions && (aaiResponse.getT() == null || aaiResponse.getT().customer == null || aaiResponse.getT().customer.isEmpty())) {
+ throw new GenericUncheckedException("Failed to get Subscribers data. The data is null or empty.");
+ } else {
+ return aaiResponse;
+ }
}
AaiResponseWithRequestInfo<SubscriberList> getAllSubscribers(boolean propagateExceptions){
@@ -262,33 +356,12 @@ public class AaiClient implements AaiClientInterface {
return processAaiResponse(resp, AicZones.class, null);
}
-
- @Override
- public AaiResponse<String> getAicZoneForPnf(String globalCustomerId , String serviceType , String serviceId) {
- String aicZonePath = BUSINESS_CUSTOMERS_CUSTOMER + globalCustomerId + SERVICE_SUBSCRIPTIONS_PATH + serviceType + SERVICE_INSTANCE + serviceId;
- Response resp = doAaiGet(aicZonePath , false);
- AaiResponse<ServiceRelationships> aaiResponse = processAaiResponse(resp , ServiceRelationships.class , null);
- ServiceRelationships serviceRelationships = aaiResponse.getT();
- RelationshipList relationshipList = serviceRelationships.getRelationshipList();
- Relationship relationship = relationshipList.getRelationship().get(0);
- RelationshipData relationshipData= relationship.getRelationDataList().get(0);
- String aicZone = relationshipData.getRelationshipValue();
- return new AaiResponse(aicZone , null ,HttpStatus.SC_OK);
- }
-
-
@Override
- public AaiResponse getVNFData() {
- String payload = "{\"start\": [\"/business/customers/customer/e433710f-9217-458d-a79d-1c7aff376d89/service-subscriptions/service-subscription/VIRTUAL%20USP/service-instances/service-instance/3f93c7cb-2fd0-4557-9514-e189b7b04f9d\"], \"query\": \"query/vnf-topology-fromServiceInstance\"}";
- Response resp = doAaiPut(QUERY_FORMAT_SIMPLE, payload, false);
- return processAaiResponse(resp, AaiGetVnfResponse.class, null);
- }
-
- @Override
- public Response getVNFData(String globalSubscriberId, String serviceType) {
+ public AaiResponse getVNFData(String globalSubscriberId, String serviceType) {
String payload = "{\"start\": [\"business/customers/customer/" + globalSubscriberId + SERVICE_SUBSCRIPTIONS_PATH + encodePathSegment(serviceType) +"/service-instances\"]," +
"\"query\": \"query/vnf-topology-fromServiceInstance\"}";
- return doAaiPut(QUERY_FORMAT_SIMPLE, payload, false);
+ Response resp = doAaiPut(QUERY_FORMAT_SIMPLE, payload, false);
+ return processAaiResponse(resp, AaiGetVnfResponse.class, null);
}
@Override
@@ -343,22 +416,17 @@ public class AaiClient implements AaiClientInterface {
@Override
public AaiResponse getTenants(String globalCustomerId, String serviceType) {
- AaiResponse aaiResponse;
-
if ((globalCustomerId == null || globalCustomerId.isEmpty()) || ((serviceType == null) || (serviceType.isEmpty())) ){
- aaiResponse = new AaiResponse<>(null, "{\"statusText\":\" Failed to retrieve LCP Region & Tenants from A&AI, Subscriber ID or Service Type is missing.\"}", HttpStatus.SC_INTERNAL_SERVER_ERROR);
- return aaiResponse;
+ return buildAaiResponseForGetTenantsFailure(" Failed to retrieve LCP Region & Tenants from A&AI, Subscriber ID or Service Type is missing.");
}
-
- String url = BUSINESS_CUSTOMERS_CUSTOMER + globalCustomerId + SERVICE_SUBSCRIPTIONS_PATH + serviceType;
-
- Response resp = doAaiGet(url, false);
- String responseAsString = parseForTenantsByServiceSubscription(resp.readEntity(String.class));
- if (responseAsString.equals("")){
- return new AaiResponse<>(null, String.format("{\"statusText\":\" A&AI has no LCP Region & Tenants associated to subscriber '%s' and service type '%s'\"}", globalCustomerId, serviceType), HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ try {
+ return cacheProvider
+ .aaiClientCacheFor("getTenants", this::getTenantsByKey)
+ .get(CacheProvider.compileKey(globalCustomerId, serviceType));
}
- else {
- return processAaiResponse(resp, GetTenantsResponse[].class, responseAsString);
+ catch (ParsingGetTenantsResponseFailure exception) {
+ logger.error("Failed to get tenants ", exception);
+ return buildAaiResponseForGetTenantsFailure(exception.getMessage());
}
}
@@ -389,13 +457,17 @@ public class AaiClient implements AaiClientInterface {
}
private <T> AaiResponseWithRequestInfo<T> processAaiResponse(ResponseWithRequestInfo responseWithRequestInfo, Class<? extends T> classType, boolean propagateExceptions) {
+ return processAaiResponse(responseWithRequestInfo, classType, VidObjectMapperType.CODEHAUS, propagateExceptions);
+ }
+
+ private <T> AaiResponseWithRequestInfo<T> processAaiResponse(ResponseWithRequestInfo responseWithRequestInfo, Class<? extends T> classType, VidObjectMapperType omType, boolean propagateExceptions) {
String responseBody = null;
Integer responseHttpCode = null;
try {
Response response = responseWithRequestInfo.getResponse();
responseHttpCode = (response != null) ? response.getStatus() : null;
responseBody = (response != null) ? response.readEntity(String.class) : null;
- AaiResponse<T> processedAaiResponse = processAaiResponse(response, classType, responseBody, VidObjectMapperType.CODEHAUS, propagateExceptions);
+ AaiResponse<T> processedAaiResponse = processAaiResponse(response, classType, responseBody, omType, propagateExceptions);
return new AaiResponseWithRequestInfo<>(responseWithRequestInfo.getRequestHttpMethod(), responseWithRequestInfo.getRequestUrl(), processedAaiResponse,
responseBody);
} catch (Exception e) {
@@ -408,17 +480,17 @@ public class AaiClient implements AaiClientInterface {
return processAaiResponse(resp, classType, responseBody, VidObjectMapperType.CODEHAUS);
}
- private AaiResponse processAaiResponse(Response resp, Class classType, String responseBody, VidObjectMapperType omType) {
+ private <T> AaiResponse<T> processAaiResponse(Response resp, Class<? extends T> classType, String responseBody, VidObjectMapperType omType) {
return processAaiResponse(resp, classType, responseBody, omType, false);
}
- private AaiResponse processAaiResponse(Response resp, Class classType, String responseBody, VidObjectMapperType omType, boolean propagateExceptions) {
- AaiResponse subscriberDataResponse;
+ private <T> AaiResponse<T> processAaiResponse(Response resp, Class<? extends T> classType, String responseBody, VidObjectMapperType omType, boolean propagateExceptions) {
+ AaiResponse<T> subscriberDataResponse;
if (resp == null) {
subscriberDataResponse = new AaiResponse<>(null, null, HttpStatus.SC_INTERNAL_SERVER_ERROR);
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "Invalid response from AAI");
+ logger.debug(EELFLoggerDelegate.debugLogger, "Invalid response from AAI");
} else {
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getSubscribers() resp=" + resp.getStatusInfo().toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, "getSubscribers() resp=" + resp.getStatusInfo().toString());
if (resp.getStatus() != HttpStatus.SC_OK) {
subscriberDataResponse = processFailureResponse(resp,responseBody);
} else {
@@ -429,7 +501,7 @@ public class AaiClient implements AaiClientInterface {
}
private AaiResponse processFailureResponse(Response resp, String responseBody) {
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "Invalid response from AAI");
+ logger.debug(EELFLoggerDelegate.debugLogger, "Invalid response from AAI");
String rawData;
if (responseBody != null) {
rawData = responseBody;
@@ -439,8 +511,8 @@ public class AaiClient implements AaiClientInterface {
return new AaiResponse<>(null, rawData, resp.getStatus());
}
- private AaiResponse processOkResponse(Response resp, Class classType, String responseBody, VidObjectMapperType omType, boolean propagateExceptions) {
- AaiResponse subscriberDataResponse;
+ private <T> AaiResponse<T> processOkResponse(Response resp, Class<? extends T> classType, String responseBody, VidObjectMapperType omType, boolean propagateExceptions) {
+ AaiResponse<T> subscriberDataResponse;
String finalResponse = null;
try {
if (responseBody != null) {
@@ -465,50 +537,59 @@ public class AaiClient implements AaiClientInterface {
return subscriberDataResponse;
}
- private AaiResponse parseFasterXmlObject(Class classType, String finalResponse) throws IOException {
- com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
+ private <T> AaiResponse<T> parseFasterXmlObject(Class<? extends T> classType, String finalResponse) throws IOException {
return new AaiResponse<>((objectMapper.readValue(finalResponse, classType)), null, HttpStatus.SC_OK);
}
- private AaiResponse parseCodeHausObject(Class classType, String finalResponse) throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
+ private <T> AaiResponse<T> parseCodeHausObject(Class<? extends T> classType, String finalResponse) throws IOException {
return new AaiResponse<>((objectMapper.readValue(finalResponse, classType)), null, HttpStatus.SC_OK);
}
+ @Override
public Response doAaiGet(String uri, boolean xml) {
return doAaiGet(uri, xml, false).getResponse();
}
public ResponseWithRequestInfo doAaiGet(String uri, boolean xml, boolean propagateExceptions) {
+ return doAaiGet(Unchecked.toURI(uri), xml, propagateExceptions);
+ }
+
+ public ResponseWithRequestInfo doAaiGet(URI uri, boolean xml, boolean propagateExceptions) {
String methodName = "doAaiGet";
- String transId = UUID.randomUUID().toString();
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + " start");
ResponseWithRequestInfo resp;
try {
- resp = restController.RestGet(fromAppId, transId, uri, xml, propagateExceptions);
+ resp = restController.RestGet(fromAppId, UUID.randomUUID().toString(), uri, xml, propagateExceptions);
} catch (Exception e) {
- if (propagateExceptions) {
- throw (e instanceof RuntimeException) ? (RuntimeException)e : new GenericUncheckedException(e);
- } else {
- final Exception actual =
- e instanceof ExceptionWithRequestInfo ? (Exception) e.getCause() : e;
+ resp = handleExceptionFromRestCall(propagateExceptions, methodName, e);
+ }
+ return resp;
+ }
- final String message =
- actual instanceof WebApplicationException ? ((WebApplicationException) actual).getResponse().readEntity(String.class) : e.toString();
+ @NotNull
+ protected ResponseWithRequestInfo handleExceptionFromRestCall(boolean propagateExceptions, String methodName, Exception e) {
+ ResponseWithRequestInfo resp;
+ if (propagateExceptions) {
+ throw (e instanceof RuntimeException) ? (RuntimeException)e : new GenericUncheckedException(e);
+ } else {
+ final Exception actual =
+ e instanceof ExceptionWithRequestInfo ? (Exception) e.getCause() : e;
- //ToDo: change parameter of requestUrl to real url from RestGet function
- resp = new ResponseWithRequestInfo(null, null, org.springframework.http.HttpMethod.GET);
- logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + message);
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + message);
- }
+ final String message =
+ actual instanceof WebApplicationException ? ((WebApplicationException) actual).getResponse().readEntity(String.class) : e.toString();
+
+ //ToDo: change parameter of requestUrl to real url from doRest function
+ resp = new ResponseWithRequestInfo(null, null, org.springframework.http.HttpMethod.GET);
+ logger.info(EELFLoggerDelegate.errorLogger, methodName + message);
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + message);
}
return resp;
}
- private String parseForTenantsByServiceSubscription(String resp) {
+ private String parseForTenantsByServiceSubscription(String relatedToKey, String resp) {
String tenantList = "";
try {
@@ -516,7 +597,7 @@ public class AaiClient implements AaiClientInterface {
JSONObject jsonObject = (JSONObject) jsonParser.parse(resp);
- return parseServiceSubscriptionObjectForTenants(jsonObject);
+ return parseServiceSubscriptionObjectForTenants(relatedToKey, jsonObject);
} catch (Exception ex) {
logger.debug(EELFLoggerDelegate.debugLogger, "parseForTenantsByServiceSubscription error while parsing tenants by service subscription", ex);
}
@@ -524,24 +605,26 @@ public class AaiClient implements AaiClientInterface {
}
protected Response doAaiPut(String uri, String payload, boolean xml) {
+ return doAaiPut(uri, payload, xml, false).getResponse();
+ }
+
+ protected ResponseWithRequestInfo doAaiPut(String uri, String payload, boolean xml, boolean propagateExceptions) {
String methodName = "doAaiPut";
- String transId = UUID.randomUUID().toString();
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + " start");
- Response resp = null;
+ ResponseWithRequestInfo resp;
try {
- resp = restController.RestPut(fromAppId, uri, payload, xml);
+ resp = restController.RestPut(fromAppId, uri, payload, xml, propagateExceptions);
} catch (Exception e) {
- logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ resp = handleExceptionFromRestCall(propagateExceptions, methodName, e);
}
return resp;
}
- private String parseServiceSubscriptionObjectForTenants(JSONObject jsonObject) {
+ private String parseServiceSubscriptionObjectForTenants(String relatedToKey, JSONObject jsonObject) {
JSONArray tenantArray = new JSONArray();
boolean bconvert = false;
try {
@@ -550,7 +633,7 @@ public class AaiClient implements AaiClientInterface {
JSONArray rShipArray = (JSONArray) relationShipListsObj.get("relationship");
for (Object innerObj : defaultIfNull(rShipArray, emptyList())) {
if (innerObj != null) {
- bconvert = parseTenant(tenantArray, bconvert, (JSONObject) innerObj);
+ bconvert = parseTenant(relatedToKey, tenantArray, bconvert, (JSONObject) innerObj);
}
}
}
@@ -565,9 +648,9 @@ public class AaiClient implements AaiClientInterface {
}
- private static boolean parseTenant(JSONArray tenantArray, boolean bconvert, JSONObject inner1Obj) {
+ private static boolean parseTenant(String relatedToKey, JSONArray tenantArray, boolean bconvert, JSONObject inner1Obj) {
String relatedTo = checkForNull((String) inner1Obj.get("related-to"));
- if (relatedTo.equalsIgnoreCase("tenant")) {
+ if (relatedTo.equalsIgnoreCase(relatedToKey)) {
JSONObject tenantNewObj = new JSONObject();
String relatedLink = checkForNull((String) inner1Obj.get("related-link"));
@@ -609,9 +692,7 @@ public class AaiClient implements AaiClientInterface {
tenantNewObj.put("cloudOwner", rShipVal);
} else if (rShipKey.equalsIgnoreCase("cloud-region.cloud-region-id")) {
tenantNewObj.put("cloudRegionID", rShipVal);
- }
-
- if (rShipKey.equalsIgnoreCase("tenant.tenant-id")) {
+ } else if (rShipKey.equalsIgnoreCase("tenant.tenant-id")) {
tenantNewObj.put("tenantID", rShipVal);
}
}
@@ -639,7 +720,7 @@ public class AaiClient implements AaiClientInterface {
responseWithRequestInfo.getHttpMethod(),
(aaiResponse != null) ? aaiResponse.getHttpCode() : 0,
responseWithRequestInfo.getRequestedUrl(),
- StringUtils.substring(responseWithRequestInfo.getRawData(), 0, 500),
+ responseWithRequestInfo.getRawData(),
isAvailable ? "OK" : "No subscriber received",
duration
);
@@ -648,16 +729,104 @@ public class AaiClient implements AaiClientInterface {
} catch (ExceptionWithRequestInfo e) {
long duration = System.currentTimeMillis() - startTime;
return new ExternalComponentStatus(ExternalComponentStatus.Component.AAI, false,
- new HttpRequestMetadata(
- e.getHttpMethod(),
- defaultIfNull(e.getHttpCode(), 0),
- e.getRequestedUrl(),
- e.getRawData(),
- Logging.exceptionToDescription(e.getCause()), duration));
+ new HttpRequestMetadata(e, duration));
} catch (Exception e) {
long duration = System.currentTimeMillis() - startTime;
return new ExternalComponentStatus(ExternalComponentStatus.Component.AAI, false,
new ErrorMetadata(Logging.exceptionToDescription(e), duration));
}
}
+
+ @Override
+ public String getCloudOwnerByCloudRegionId(String cloudRegionId) {
+ return cacheProvider
+ .aaiClientCacheFor("getCloudOwnerByCloudRegionId", this::getCloudOwnerByCloudRegionIdNonCached)
+ .get(cloudRegionId);
+ }
+
+
+ @Override
+ public GetTenantsResponse getHomingDataByVfModule(String vnfInstanceId, String vfModuleId) {
+
+ if (StringUtils.isEmpty(vnfInstanceId)||StringUtils.isEmpty(vfModuleId)){
+ throw new GenericUncheckedException("Failed to retrieve homing data associated to vfModule from A&AI, VNF InstanceId or VF Module Id is missing.");
+ }
+ Response resp = doAaiGet("network/generic-vnfs/generic-vnf/" + vnfInstanceId +"/vf-modules/vf-module/"+ vfModuleId, false);
+ String responseAsString = parseForTenantsByServiceSubscription("vserver",resp.readEntity(String.class));
+ if (responseAsString.equals("")){
+ throw new GenericUncheckedException( String.format("A&AI has no homing data associated to vfModule '%s' of vnf '%s'", vfModuleId, vnfInstanceId));
+ }
+ else {
+ AaiResponse aaiResponse = processAaiResponse(resp, GetTenantsResponse[].class, responseAsString);
+ return ((GetTenantsResponse[])aaiResponse.getT())[0];
+ }
+ }
+
+ @Override
+ public void resetCache(String cacheName) {
+ cacheProvider.resetCache(cacheName);
+ }
+
+ String getCloudOwnerByCloudRegionIdNonCached(String cloudRegionId) {
+ String uri = "cloud-infrastructure/cloud-regions?cloud-region-id=" + encodePathSegment(cloudRegionId);
+
+ final CloudRegion.Collection cloudRegionCollection =
+ typedAaiGet(Unchecked.toURI(uri), CloudRegion.Collection.class);
+
+ return cloudRegionCollection
+ .getCloudRegions().stream()
+ .map(CloudRegion::getCloudOwner)
+ // from here we assure that the cloud owner is given, and not null
+ // and non-empty, and that if more than one cloud-owner is given -
+ // it is only a single value.
+ // exception is thrown if none or more than a single values are
+ // given.
+ .filter(StringUtils::isNotEmpty)
+ .distinct()
+ .reduce((a, b) -> {
+ // will be invoked only if distinct() leaves more than a single element
+ throw new GenericUncheckedException("Conflicting cloud-owner found for " + cloudRegionId + ": '" + a + "' / '" + b + "'");
+ })
+ .orElseThrow(() -> new GenericUncheckedException("No cloud-owner found for " + cloudRegionId));
+ }
+
+ private AaiResponse getTenantsByKey(String key) {
+ String[] args = CacheProvider.decompileKey(key);
+ String globalCustomerId = safeGetFromArray(args, 0);
+ String serviceType = safeGetFromArray(args, 1);
+ return getTenantsNonCached(globalCustomerId, serviceType);
+ }
+
+ AaiResponse getTenantsNonCached(String globalCustomerId, String serviceType) {
+ String url = BUSINESS_CUSTOMERS_CUSTOMER + globalCustomerId + SERVICE_SUBSCRIPTIONS_PATH + serviceType;
+
+ Response resp = doAaiGet(url, false);
+ String responseAsString = parseForTenantsByServiceSubscription("tenant",resp.readEntity(String.class));
+ if (StringUtils.isEmpty(responseAsString)){
+ throw new ParsingGetTenantsResponseFailure(String.format("A&AI has no LCP Region & Tenants associated to subscriber '%s' and service type '%s'", globalCustomerId, serviceType));
+ }
+ else {
+ return processAaiResponse(resp, GetTenantsResponse[].class, responseAsString);
+ }
+ }
+
+ public static class ParsingGetTenantsResponseFailure extends GenericUncheckedException {
+
+ public ParsingGetTenantsResponseFailure(String message) {
+ super(message);
+ }
+ }
+
+ @NotNull
+ private AaiResponse<String> buildAaiResponseForGetTenantsFailure(String errorText) {
+ return new AaiResponse<>(null, String.format("{\"statusText\":\"%s\"}", errorText), HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ }
+
+ private static String safeGetFromArray(String[] array, int i) {
+ if (i < 0 || i >= array.length) {
+ return null;
+ } else {
+ return array[i];
+ }
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
index 901591a..bf97e59 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
@@ -1,24 +1,29 @@
package org.onap.vid.aai;
-import org.codehaus.jackson.JsonNode;
+import com.fasterxml.jackson.databind.JsonNode;
import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
-import org.onap.vid.aai.model.AaiNodeQueryResponse;
+import org.onap.vid.aai.model.CustomQuerySimpleResult;
import org.onap.vid.aai.model.PortDetailsTranslator;
+import org.onap.vid.aai.model.Properties;
import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.model.SubscriberList;
import org.onap.vid.model.probes.ExternalComponentStatus;
import javax.ws.rs.core.Response;
+import java.net.URI;
import java.util.List;
+import java.util.Map;
/**
* Created by Oren on 7/4/17.
*/
public interface AaiClientInterface {
- AaiResponse<AaiNodeQueryResponse> searchNodeTypeByName(String name, ResourceType type);
+ boolean isNodeTypeExistsByName(String name, ResourceType type);
+
+ <T> T typedAaiGet(URI path, Class<T> clz);
AaiResponse<SubscriberList> getAllSubscribers();
@@ -34,15 +39,11 @@ public interface AaiClientInterface {
AaiResponse getAllAicZones();
- AaiResponse getAicZoneForPnf(String globalCustomerId , String serviceType , String serviceId);
-
- AaiResponse getVNFData();
-
AaiResponse getNetworkCollectionDetails(String serviceInstanceId);
AaiResponse getInstanceGroupsByCloudRegion(String cloudOwner, String cloudRegionId, String networkFunction);
- Response getVNFData(String globalSubscriberId, String serviceType);
+ AaiResponse getVNFData(String globalSubscriberId, String serviceType);
AaiResponse getVNFData(String globalSubscriberId, String serviceType, String serviceInstanceId);
@@ -69,4 +70,14 @@ public interface AaiClientInterface {
AaiResponse getInstanceGroupsByVnfInstanceId(String vnfInstanceId);
ExternalComponentStatus probeAaiGetAllSubscribers();
+
+ Response doAaiGet(String uri, boolean xml);
+
+ String getCloudOwnerByCloudRegionId(String cloudRegionId);
+
+ GetTenantsResponse getHomingDataByVfModule(String vnfInstanceId, String vfModuleId);
+
+ void resetCache(String cacheName);
+
+ Map<String, Properties> getCloudRegionAndTenantByVnfId(String vnfId);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java
index 0858520..479bd13 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java
@@ -1,8 +1,7 @@
package org.onap.vid.aai;
-import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.*;
import com.google.common.base.MoreObjects;
-import org.codehaus.jackson.annotate.*;
import org.onap.vid.aai.model.VnfResult;
import java.util.HashMap;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java
index 6e25e27..fe62f02 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClient.java
@@ -20,26 +20,25 @@
package org.onap.vid.aai;
-import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.ACCEPT;
-import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.CONTENT_TYPE;
-import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.FROM_APP_ID_HEADER;
-import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.REQUEST_ID;
-import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.TRANSACTION_ID_HEADER;
-
import io.joshworks.restclient.http.HttpResponse;
+import io.joshworks.restclient.http.JsonNode;
import io.vavr.collection.HashMap;
-import java.nio.charset.StandardCharsets;
-import java.util.Base64;
-import java.util.Collections;
-import java.util.Map;
-import javax.ws.rs.core.MediaType;
+import org.apache.commons.lang3.StringUtils;
import org.onap.portalsdk.core.util.SystemProperties;
-import org.onap.vid.aai.model.AaiNodeQueryResponse;
import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.aai.util.AAIProperties;
import org.onap.vid.client.SyncRestClientInterface;
+import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.SubscriberList;
+import javax.ws.rs.core.MediaType;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.Collections;
+import java.util.Map;
+
+import static org.onap.vid.aai.AaiOverTLSClientInterface.HEADERS.*;
+
public class AaiOverTLSClient implements AaiOverTLSClientInterface {
private final AaiOverTLSPropertySupplier propertySupplier;
@@ -64,9 +63,23 @@ public class AaiOverTLSClient implements AaiOverTLSClientInterface {
}
@Override
- public HttpResponse<AaiNodeQueryResponse> searchNodeTypeByName(String name, ResourceType type) {
- String uri = urlBase + String.format(URIS.NODE_TYPE_BY_NAME, type.getAaiFormat(), type.getNameFilter(), name);
- return syncRestClient.get(uri, getRequestHeaders(), Collections.emptyMap(), AaiNodeQueryResponse.class);
+ public boolean isNodeTypeExistsByName(String name, ResourceType type) {
+
+ if (StringUtils.isEmpty(name)) {
+ throw new GenericUncheckedException("Empty resource-name provided to isNodeTypeExistsByName; request is rejected as this will cause full resources listing");
+ }
+
+ String path = String.format( // e.g. GET /aai/v$/nodes/vf-modules?vf-module-name={vf-module-name}
+ "nodes/%s?%s=%s",
+ type.getAaiFormat(),
+ type.getNameFilter(),
+ name
+ );
+
+ String uri = urlBase + path;
+ final HttpResponse<JsonNode> response = syncRestClient.get(uri, getRequestHeaders(), Collections.emptyMap());
+
+ return response.isSuccessful();
}
@Override
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java
index ad43746..57ec519 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiOverTLSClientInterface.java
@@ -22,7 +22,6 @@ package org.onap.vid.aai;
import io.joshworks.restclient.http.HttpResponse;
import org.onap.portalsdk.core.util.SystemProperties;
-import org.onap.vid.aai.model.AaiNodeQueryResponse;
import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.model.SubscriberList;
@@ -44,7 +43,7 @@ public interface AaiOverTLSClientInterface {
void setUseClientCert(boolean useClientCert);
- HttpResponse<AaiNodeQueryResponse> searchNodeTypeByName(String name, ResourceType type);
+ boolean isNodeTypeExistsByName(String name, ResourceType type);
HttpResponse<SubscriberList> getAllSubscribers();
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseTranslator.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseTranslator.java
index c7a98a8..a0a8a30 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseTranslator.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseTranslator.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai;
+import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.lang3.StringUtils;
-import org.codehaus.jackson.JsonNode;
import org.springframework.stereotype.Component;
import java.util.Optional;
@@ -26,7 +26,7 @@ public class AaiResponseTranslator {
for (JsonNode resultNode : results) {
final JsonNode nodeType = resultNode.path("node-type");
- if (nodeType.isTextual() && "cloud-region".equals(nodeType.getTextValue())) {
+ if (nodeType.isTextual() && "cloud-region".equals(nodeType.textValue())) {
return getPortMirroringConfigData(payload, resultNode);
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseWithRequestInfo.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseWithRequestInfo.java
index cd1f904..a1806f0 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseWithRequestInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponseWithRequestInfo.java
@@ -3,9 +3,8 @@ package org.onap.vid.aai;
import org.springframework.http.HttpMethod;
-import java.io.Serializable;
-public class AaiResponseWithRequestInfo<T> implements Serializable {
+public class AaiResponseWithRequestInfo<T> {
private AaiResponse<T> aaiResponse;
private String requestedUrl;
private String rawData;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/ExceptionWithRequestInfo.java b/vid-app-common/src/main/java/org/onap/vid/aai/ExceptionWithRequestInfo.java
index dcca3ec..388c381 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/ExceptionWithRequestInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ExceptionWithRequestInfo.java
@@ -42,13 +42,13 @@ public class ExceptionWithRequestInfo extends RuntimeException {
private static String toMessage(HttpMethod httpMethod, String requestedUrl, Throwable cause) {
if (StringUtils.isEmpty(requestedUrl)) {
- return cause.toString();
+ return String.valueOf(cause);
} else {
return "" +
"Exception while handling " +
defaultIfNull(httpMethod, "request").toString() +
" " + requestedUrl +
- ": " + cause.toString();
+ ": " + (cause == null ? "null" : cause.toString());
}
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java b/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java
index 10ad4e9..4b4a496 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java
@@ -1,12 +1,9 @@
package org.onap.vid.aai;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.onap.vid.aai.model.Relationship;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import org.onap.vid.aai.model.RelationshipList;
-import java.util.List;
-
@JsonIgnoreProperties(ignoreUnknown = true)
public class OperationalEnvironment {
@@ -33,75 +30,75 @@ public class OperationalEnvironment {
this.relationshipList = relationshipList;
}
- @JsonProperty("operational-environment-id")
public String getOperationalEnvironmentId() {
return operationalEnvironmentId;
}
- public void setOperationalEnvironmentId(String operationalEnvironmentId) {
+ @JsonProperty("operational-environment-id")
+ public void setJsonOperationalEnvironmentId(String operationalEnvironmentId) {
this.operationalEnvironmentId = operationalEnvironmentId;
}
- @JsonProperty("operational-environment-name")
public String getOperationalEnvironmentName() {
return operationalEnvironmentName;
}
- public void setOperationalEnvironmentName(String operationalEnvironmentName) {
+ @JsonProperty("operational-environment-name")
+ public void setJsonOperationalEnvironmentName(String operationalEnvironmentName) {
this.operationalEnvironmentName = operationalEnvironmentName;
}
- @JsonProperty("operational-environment-type")
public String getOperationalEnvironmentType() {
return operationalEnvironmentType;
}
- public void setOperationalEnvironmentType(String operationalEnvironmentType) {
+ @JsonProperty("operational-environment-type")
+ public void setJsonOperationalEnvironmentType(String operationalEnvironmentType) {
this.operationalEnvironmentType = operationalEnvironmentType;
}
- @JsonProperty("operational-environment-status")
public String getOperationalEnvironmentStatus() {
return operationalEnvironmentStatus;
}
- public void setOperationalEnvironmentStatus(String operationalEnvironmentStatus) {
+ @JsonProperty("operational-environment-status")
+ public void setJsonOperationalEnvironmentStatus(String operationalEnvironmentStatus) {
this.operationalEnvironmentStatus = operationalEnvironmentStatus;
}
- @JsonProperty("tenant-context")
public String getTenantContext() {
return tenantContext;
}
- public void setTenantContext(String tenantContext) {
+ @JsonProperty("tenant-context")
+ public void setJsonTenantContext(String tenantContext) {
this.tenantContext = tenantContext;
}
- @JsonProperty("workload-context")
public String getWorkloadContext() {
return workloadContext;
}
- public void setWorkloadContext(String workloadContext) {
+ @JsonProperty("workload-context")
+ public void setJsonWorkloadContext(String workloadContext) {
this.workloadContext = workloadContext;
}
- @JsonProperty("resource-version")
public String getResourceVersion() {
return resourceVersion;
}
- public void setResourceVersion(String resourceVersion) {
+ @JsonProperty("resource-version")
+ public void setJsonResourceVersion(String resourceVersion) {
this.resourceVersion = resourceVersion;
}
- @JsonProperty("relationship-list")
public RelationshipList getRelationshipList() {
return relationshipList;
}
- public void setRelationshipList(RelationshipList relationshipList) {
+ @JsonProperty("relationship-list")
+ public void setJsonRelationshipList(RelationshipList relationshipList) {
this.relationshipList = relationshipList;
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java b/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java
index 28b6f54..000628d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/PombaClientImpl.java
@@ -1,21 +1,15 @@
package org.onap.vid.aai;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.onap.vid.model.PombaInstance.PombaRequest;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.model.PombaInstance.PombaRequest;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.ServletContext;
-import javax.ws.rs.core.Response;
-import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
public class PombaClientImpl implements PombaClientInterface {
- final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
protected String fromAppId = "VidAaiController";
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AaiClient.class);
@@ -29,22 +23,15 @@ public class PombaClientImpl implements PombaClientInterface {
@Override
public void verify(PombaRequest request) {
String methodName = "doAaiPost";
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + " start");
String uri = SystemProperties.getProperty("pomba.server.url");
try {
- Response response = pombaRestInterface.RestPost(fromAppId, uri, new ObjectMapper().writeValueAsString(request));
+ pombaRestInterface.RestPost(fromAppId, uri, new ObjectMapper().writeValueAsString(request));
} catch (Exception e) {
- logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.info(EELFLoggerDelegate.errorLogger, methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + e.toString());
}
}
-
-
- private File getCertificatesFile() {
- if (servletContext != null)
- return new File(servletContext.getRealPath("/WEB-INF/cert/"));
- return null;
- }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java
index c4bc852..6376237 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/PombaRestInterface.java
@@ -42,11 +42,12 @@ public class PombaRestInterface extends AAIRestInterface {
private Client client = null;
- private void initRestClient()
+ @Override
+ protected void initRestClient()
{
if (client == null) {
try {
- client = httpsAuthClientFactory.getClient(HttpClientMode.UNSECURE);
+ client = httpsAuthClientFactory.getClient(HttpClientMode.WITH_KEYSTORE);
}
catch (Exception e) {
logger.info(EELFLoggerDelegate.errorLogger, "Exception in REST call to DB in initRestClient" + e.toString());
@@ -78,6 +79,7 @@ public class PombaRestInterface extends AAIRestInterface {
} else {
logger.debug(EELFLoggerDelegate.debugLogger, getInvalidResponseLogMessage(url, methodName, cres));
}
+ return cres;
} catch (Exception e) {
logger.debug(EELFLoggerDelegate.debugLogger, getFailedResponseLogMessage(url, methodName, e));
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstance.java b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstance.java
index 26f4a21..59f3673 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstance.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstance.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class ServiceInstance {
@@ -11,16 +11,16 @@ public class ServiceInstance {
@JsonProperty("service-instance-name")
public String serviceInstanceName;
-
+
@JsonProperty("persona-model-id")
public String personaModelId;
-
+
@JsonProperty("persona-model-version")
public String personaModelVersion;
-
+
@JsonProperty("resource-version")
public String resourceVersion;
-
+
@JsonProperty("orchestration-status")
public String orchestrationStatus;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstances.java b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstances.java
index c92a47a..fb5f18b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstances.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstances.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstancesSearchResults.java b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstancesSearchResults.java
index b32a83a..79d9098 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstancesSearchResults.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstancesSearchResults.java
@@ -1,10 +1,9 @@
package org.onap.vid.aai;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import org.onap.vid.model.ServiceInstanceSearchResult;
-import java.util.ArrayList;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscription.java b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscription.java
index 5dc9d52..8057801 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscription.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscription.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class ServiceSubscription {
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptions.java b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptions.java
index 686dc7d..8938f2c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptions.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptions.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/Services.java b/vid-app-common/src/main/java/org/onap/vid/aai/Services.java
index fe70de5..2a7fc40 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/Services.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/Services.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class Services {
@@ -16,7 +16,7 @@ public class Services {
@JsonProperty("resource-version")
public String resourceVersion;
-
+
@JsonProperty("service-subscriptions")
public ServiceSubscriptions serviceSubscriptions;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberWithFilter.java b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberWithFilter.java
index aaaa144..a91e33e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberWithFilter.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberWithFilter.java
@@ -1,6 +1,6 @@
package org.onap.vid.aai;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import org.onap.vid.model.Subscriber;
/**
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/AicZones.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/AicZones.java
index c30aaeb..f91797a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/AicZones.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/AicZones.java
@@ -1,8 +1,8 @@
package org.onap.vid.aai.model.AaiGetAicZone;
-import java.util.List;
+import com.fasterxml.jackson.annotation.JsonProperty;
-import org.codehaus.jackson.annotate.JsonProperty;
+import java.util.List;
public class AicZones {
@JsonProperty("zone")
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/Zone.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/Zone.java
index 89400f2..13e2684 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/Zone.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/Zone.java
@@ -1,13 +1,13 @@
package org.onap.vid.aai.model.AaiGetAicZone;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class Zone {
@JsonProperty("zone-id")
public String zoneId;
-
+
@JsonProperty("zone-name")
public String zoneName;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/CloudRegion.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/CloudRegion.java
new file mode 100644
index 0000000..38dd2b1
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/CloudRegion.java
@@ -0,0 +1,55 @@
+package org.onap.vid.aai.model.AaiGetNetworkCollectionDetails;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang3.ObjectUtils;
+
+import java.util.List;
+
+import static java.util.Collections.emptyList;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CloudRegion {
+
+ private final String cloudOwner;
+ private final String cloudRegionId;
+
+ public CloudRegion(
+ @JsonProperty("cloud-owner") String cloudOwner,
+ @JsonProperty("cloud-region-id") String cloudRegionId
+ ) {
+ this.cloudOwner = cloudOwner;
+ this.cloudRegionId = cloudRegionId;
+ }
+
+ public String getCloudOwner() {
+ return cloudOwner;
+ }
+
+ public String getCloudRegionId() {
+ return cloudRegionId;
+ }
+
+ /*
+ This will handle container like:
+ {
+ "cloud-region": [{
+ "cloud-owner": "alfi",
+ "cloud-region-id": "foo",
+ . . .
+ }, {
+ "cloud-owner": "alba",
+ "cloud-region-id": "bar",
+ */
+ public static class Collection {
+ private final List<CloudRegion> cloudRegions;
+
+ public Collection(@JsonProperty("cloud-region") List<CloudRegion> cloudRegions) {
+ this.cloudRegions = ObjectUtils.defaultIfNull(cloudRegions, emptyList());
+ }
+
+ public List<CloudRegion> getCloudRegions() {
+ return cloudRegions;
+ }
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Network.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Network.java
index 29450a8..41b720a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Network.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Network.java
@@ -2,9 +2,10 @@ package org.onap.vid.aai.model.AaiGetNetworkCollectionDetails;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.vid.aai.model.interfaces.AaiModelWithRelationships;
@JsonIgnoreProperties(ignoreUnknown = true)
-public class Network {
+public class Network implements AaiModelWithRelationships {
@JsonProperty("network-id")
private String networkId;
@JsonProperty("network-name")
@@ -19,6 +20,8 @@ public class Network {
private Boolean isBoundToVpn;
@JsonProperty("resource-version")
private String resourceVersion;
+ @JsonProperty("orchestration-status")
+ private String orchestrationStatus;
@JsonProperty("is-provider-network")
private Boolean isProviderNetwork;
@JsonProperty("is-shared-network")
@@ -99,6 +102,16 @@ public class Network {
this.resourceVersion = resourceVersion;
}
+ @JsonProperty("orchestration-status")
+ public String getOrchestrationStatus() {
+ return orchestrationStatus;
+ }
+
+ @JsonProperty("orchestration-status")
+ public void setOrchestrationStatus(String orchestrationStatus) {
+ this.orchestrationStatus = orchestrationStatus;
+ }
+
@JsonProperty("is-provider-network")
public Boolean getIsProviderNetwork() {
return isProviderNetwork;
@@ -129,6 +142,7 @@ public class Network {
this.isExternalNetwork = isExternalNetwork;
}
+ @Override
@JsonProperty("relationship-list")
public RelationshipList getRelationshipList() {
return relationshipList;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/ServiceInstance.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/ServiceInstance.java
index c366402..49b8536 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/ServiceInstance.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/ServiceInstance.java
@@ -1,17 +1,51 @@
package org.onap.vid.aai.model.AaiGetNetworkCollectionDetails;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.vid.aai.model.interfaces.AaiModelWithRelationships;
+
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
@JsonIgnoreProperties(ignoreUnknown = true)
-public class ServiceInstance {
+public class ServiceInstance implements AaiModelWithRelationships {
+
+ private final String serviceInstanceId;
+ private final String serviceInstanceName;
+ private final String resourceVersion;
+ private final RelationshipList relationshipList;
+
+ public ServiceInstance(
+ @JsonProperty("service-instance-id") String serviceInstanceId,
+ @JsonProperty("service-instance-name") String serviceInstanceName,
+ @JsonProperty("resource-version") String resourceVersion,
+ @JsonProperty("relationship-list") RelationshipList relationshipList
+ ) {
+ this.serviceInstanceId = serviceInstanceId;
+ this.serviceInstanceName = serviceInstanceName;
+ this.resourceVersion = resourceVersion;
+ this.relationshipList = relationshipList;
+ }
@JsonProperty("service-instance-id")
- public String serviceInstanceId;
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ @JsonProperty("service-instance-name")
+ @JsonInclude(NON_NULL)
+ public String getServiceInstanceName() {
+ return serviceInstanceName;
+ }
@JsonProperty("resource-version")
- public String resourceVersion;
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+ @Override
@JsonProperty("relationship-list")
- public RelationshipList relationshipList;
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Vlan.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Vlan.java
new file mode 100644
index 0000000..a184648
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Vlan.java
@@ -0,0 +1,41 @@
+package org.onap.vid.aai.model.AaiGetNetworkCollectionDetails;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.vid.aai.model.interfaces.AaiModelWithRelationships;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Vlan implements AaiModelWithRelationships {
+
+ public Vlan(
+ @JsonProperty("vlan-interface") String vlanInterface,
+ @JsonProperty("vlan-id-inner") String vlanIdInner,
+ @JsonProperty("relationship-list") RelationshipList relationshipList) {
+ this.vlanInterface = vlanInterface;
+ this.vlanIdInner = vlanIdInner;
+ this.relationshipList = relationshipList;
+ }
+
+ @JsonProperty("vlan-interface")
+ private final String vlanInterface;
+
+ @JsonProperty("vlan-id-inner")
+ private final String vlanIdInner;
+
+ @JsonProperty("relationship-list")
+ public final RelationshipList relationshipList;
+
+ public String getVlanInterface() {
+ return vlanInterface;
+ }
+
+ public String getVlanIdInner() {
+ return vlanIdInner;
+ }
+
+ @Override
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Vnf.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Vnf.java
new file mode 100644
index 0000000..5dc6e4d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetNetworkCollectionDetails/Vnf.java
@@ -0,0 +1,84 @@
+package org.onap.vid.aai.model.AaiGetNetworkCollectionDetails;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.vid.aai.model.interfaces.AaiModelWithRelationships;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Vnf implements AaiModelWithRelationships {
+ @JsonProperty("vnf-id")
+ private String vnfId;
+ @JsonProperty("vnf-name")
+ private String vnfName;
+ @JsonProperty("vnf-type")
+ private String vnfType;
+ @JsonProperty("resource-version")
+ private String resourceVersion;
+ @JsonProperty("orchestration-status")
+ private String orchestrationStatus;
+ @JsonProperty("relationship-list")
+ private RelationshipList relationshipList;
+
+
+ @JsonProperty("vnf-id")
+ public String getVnfId() {
+ return vnfId;
+ }
+
+ @JsonProperty("vnf-id")
+ public void setVnfId(String vnfId) {
+ this.vnfId = vnfId;
+ }
+
+ @JsonProperty("vnf-name")
+ public String getVnfName() {
+ return vnfName;
+ }
+
+ @JsonProperty("vnf-name")
+ public void setVnfName(String vnfName) {
+ this.vnfName = vnfName;
+ }
+
+ @JsonProperty("vnf-type")
+ public String getVnfType() {
+ return vnfType;
+ }
+
+ @JsonProperty("vnf-type")
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+
+ @JsonProperty("resource-version")
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ @JsonProperty("resource-version")
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @JsonProperty("orchestration-status")
+ public String getOrchestrationStatus() {
+ return orchestrationStatus;
+ }
+
+ @JsonProperty("orchestration-status")
+ public void setOrchestrationStatus(String orchestrationStatus) {
+ this.orchestrationStatus = orchestrationStatus;
+ }
+
+ @Override
+ @JsonProperty("relationship-list")
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ @JsonProperty("relationship-list")
+ public void setRelationshipList(RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentList.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentList.java
index 1f31cfa..254d5ed 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentList.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentList.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai.model.AaiGetOperationalEnvironments;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.onap.vid.aai.OperationalEnvironment;
import java.util.List;
@@ -9,12 +9,11 @@ import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
public class OperationalEnvironmentList {
- @JsonProperty("operational-environment")
public List<OperationalEnvironment> getOperationalEnvironment() {
return operationalEnvironment;
}
- @JsonProperty("operational-environment")
+ @JsonAlias("operational-environment")
public void setOperationalEnvironment(List<OperationalEnvironment> operationalEnvironment) {
this.operationalEnvironment = operationalEnvironment;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfResponse.java
index fa9fe93..93c12c8 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfResponse.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfResponse.java
@@ -1,12 +1,7 @@
package org.onap.vid.aai.model;
-import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.*;
import com.google.common.base.MoreObjects;
-import org.codehaus.jackson.annotate.JsonAnyGetter;
-import org.codehaus.jackson.annotate.JsonAnySetter;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.codehaus.jackson.annotate.JsonPropertyOrder;
import java.util.HashMap;
import java.util.List;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfs/Pnf.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfs/Pnf.java
index 00a731a..d359474 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfs/Pnf.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfs/Pnf.java
@@ -1,31 +1,25 @@
package org.onap.vid.aai.model.AaiGetPnfs;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.onap.vid.aai.model.AaiRelationResponse;
@JsonIgnoreProperties(ignoreUnknown = true)
public class Pnf extends AaiRelationResponse {
- @JsonProperty("pnf-name")
- public String pnfName;
- @JsonProperty("pnf-name2")
- public String pnfName2;
- @JsonProperty("pnf-name2-source")
- public String pnfName2Source;
- @JsonProperty("pnf-id")
- public String pnfId;
- @JsonProperty("equip-type")
- public String equipType;
- @JsonProperty("equip-vendor")
- public String equipVendor;
- @JsonProperty("equip-model")
- public String equipModel;
+ private String pnfName;
+ private String pnfName2;
+ private String pnfName2Source;
+ private String pnfId;
+ private String equipType;
+ private String equipVendor;
+ private String equipModel;
public String getPnfName() {
return pnfName;
}
+ @JsonAlias("pnf-name")
public void setPnfName(String pnfName) {
this.pnfName = pnfName;
}
@@ -34,6 +28,7 @@ public class Pnf extends AaiRelationResponse {
return equipType;
}
+ @JsonAlias("equip-type")
public void setEquipType(String equipType) {
this.equipType = equipType;
}
@@ -42,6 +37,7 @@ public class Pnf extends AaiRelationResponse {
return equipVendor;
}
+ @JsonAlias("equip-vendor")
public void setEquipVendor(String equipVendor) {
this.equipVendor = equipVendor;
}
@@ -50,6 +46,7 @@ public class Pnf extends AaiRelationResponse {
return pnfName2;
}
+ @JsonAlias("pnf-name2")
public void setPnfName2(String pnfName2) {
this.pnfName2 = pnfName2;
}
@@ -58,6 +55,7 @@ public class Pnf extends AaiRelationResponse {
return pnfId;
}
+ @JsonAlias("pnf-id")
public void setPnfId(String pnfId) {
this.pnfId = pnfId;
}
@@ -66,12 +64,14 @@ public class Pnf extends AaiRelationResponse {
return equipModel;
}
+ @JsonAlias("equip-model")
public void setEquipModel(String equipModel) {
this.equipModel = equipModel;
}
public String getPnfName2Source() { return pnfName2Source; }
+ @JsonAlias("pnf-name2-source")
public void setPnfName2Source(String pnfName2Source) { this.pnfName2Source = pnfName2Source; }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPortMirroringSourcePorts.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPortMirroringSourcePorts.java
index 47a57da..b629d90 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPortMirroringSourcePorts.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPortMirroringSourcePorts.java
@@ -1,6 +1,6 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java
index d3dd7d2..d5858de 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java
@@ -1,7 +1,6 @@
package org.onap.vid.aai.model.AaiGetServicesRequestModel;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/Service.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/Service.java
index 367287e..36b5a51 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/Service.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/Service.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai.model.AaiGetServicesRequestModel;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Created by Oren on 7/17/17.
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetTenatns/GetTenantsResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetTenatns/GetTenantsResponse.java
index 1d0e849..c799c8f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetTenatns/GetTenantsResponse.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetTenatns/GetTenantsResponse.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai.model.AaiGetTenatns;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Created by Oren on 7/18/17.
@@ -9,26 +9,29 @@ import org.codehaus.jackson.annotate.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class GetTenantsResponse {
- @JsonProperty("cloudRegionID")
- public String cloudRegionId;
+ public String cloudRegionID;
- @JsonProperty("cloudOwner")
public String cloudOwner;
-
- @JsonProperty("tenantName")
+
public String tenantName;
- @JsonProperty("tenantID")
public String tenantID;
- @JsonProperty("is-permitted")
public boolean isPermitted;
+ @JsonProperty("is-permitted")
+ public boolean getJsonIsPermitted() {
+ // this is a special case to *duplicate* the permission field
+ // as it might be that both -- camelCase and hyphen faces --
+ // are in use
+ return isPermitted;
+ }
+
public GetTenantsResponse() {
}
public GetTenantsResponse(String cloudRegionId, String cloudOwner, String tenantName, String tenantID, boolean isPermitted) {
- this.cloudRegionId = cloudRegionId;
+ this.cloudRegionID = cloudRegionId;
this.cloudOwner = cloudOwner;
this.tenantName = tenantName;
this.tenantID = tenantID;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiRelationResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiRelationResponse.java
index 7bc2e7a..981f856 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiRelationResponse.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiRelationResponse.java
@@ -1,9 +1,8 @@
package org.onap.vid.aai.model;
-
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.HashMap;
import java.util.Map;
@@ -13,30 +12,27 @@ import java.util.Map;
*/
public class AaiRelationResponse {
- @JsonProperty("resource-version")
private String resourceVersion;
- @JsonProperty("relationship-list")
private RelationshipList relationshipList;
+
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private Map<String, Object> additionalProperties = new HashMap<>();
- @JsonProperty("resource-version")
public String getResourceVersion() {
return resourceVersion;
}
- @JsonProperty("resource-version")
+ @JsonAlias("resource-version")
public void setResourceVersion(String resourceVersion) {
this.resourceVersion = resourceVersion;
}
- @JsonProperty("relationship-list")
public RelationshipList getRelationshipList() {
return relationshipList;
}
- @JsonProperty("relationship-list")
+ @JsonAlias("relationship-list")
public void setRelationshipList(RelationshipList relationshipList) {
this.relationshipList = relationshipList;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/CustomQuerySimpleResult.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/CustomQuerySimpleResult.java
new file mode 100644
index 0000000..4f91b75
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/CustomQuerySimpleResult.java
@@ -0,0 +1,18 @@
+package org.onap.vid.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+public class CustomQuerySimpleResult {
+
+ private final List<SimpleResult> results;
+
+ public CustomQuerySimpleResult(@JsonProperty("results") List<SimpleResult> results) {
+ this.results = results;
+ }
+
+ public List<SimpleResult> getResults() {
+ return results;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/GetServiceModelsByDistributionStatusResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/GetServiceModelsByDistributionStatusResponse.java
index 5a6924d..c17f930 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/GetServiceModelsByDistributionStatusResponse.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/GetServiceModelsByDistributionStatusResponse.java
@@ -1,8 +1,8 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/LogicalLinkResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/LogicalLinkResponse.java
index 6625957..4d815bc 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/LogicalLinkResponse.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/LogicalLinkResponse.java
@@ -1,31 +1,26 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
public class LogicalLinkResponse {
- @JsonProperty("link-name")
public String linkName;
- @JsonProperty("in-maint")
public Boolean inMaint;
- @JsonProperty("link-type")
public String linkType;
- @JsonProperty("resource-version")
public String resourceVersion;
- @JsonProperty("purpose")
public String purpose;
- @JsonProperty("relationship-list")
public RelationshipList relationshipList;
public String getLinkName() {
return linkName;
}
+ @JsonAlias("link-name")
public void setLinkName(String linkName) {
this.linkName = linkName;
}
@@ -34,6 +29,7 @@ public class LogicalLinkResponse {
return inMaint;
}
+ @JsonAlias("in-maint")
public void setInMaint(Boolean inMaint) {
this.inMaint = inMaint;
}
@@ -42,6 +38,7 @@ public class LogicalLinkResponse {
return linkType;
}
+ @JsonAlias("link-type")
public void setLinkType(String linkType) {
this.linkType = linkType;
}
@@ -50,6 +47,7 @@ public class LogicalLinkResponse {
return resourceVersion;
}
+ @JsonAlias("resource-version")
public void setResourceVersion(String resourceVersion) {
this.resourceVersion = resourceVersion;
}
@@ -58,6 +56,7 @@ public class LogicalLinkResponse {
return purpose;
}
+ @JsonAlias("purpose")
public void setPurpose(String purpose) {
this.purpose = purpose;
}
@@ -66,6 +65,7 @@ public class LogicalLinkResponse {
return relationshipList;
}
+ @JsonAlias("relationship-list")
public void setRelationshipList(RelationshipList relationshipList) {
this.relationshipList = relationshipList;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/Model.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/Model.java
index 5f422f6..7a771e4 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/Model.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/Model.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/**
* Created by moriya1 on 15/10/2017.
@@ -9,51 +9,43 @@ import org.codehaus.jackson.annotate.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class Model {
- @JsonProperty("model-invariant-id")
private String modelInvariantId;
- @JsonProperty("model-type")
private String modelType;
- @JsonProperty("resource-version")
private String resourceVersion;
- @JsonProperty("model-vers")
private ModelVers modelVers;
- @JsonProperty("model-invariant-id")
public String getModelInvariantId() {
return modelInvariantId;
}
- @JsonProperty("model-invariant-id")
+ @JsonAlias("model-invariant-id")
public void setModelInvariantId(String modelInvariantId) {
this.modelInvariantId = modelInvariantId;
}
- @JsonProperty("model-type")
public String getModelType() {
return modelType;
}
- @JsonProperty("model-type")
+ @JsonAlias("model-type")
public void setModelType(String modelType) {
this.modelType = modelType;
}
- @JsonProperty("resource-version")
public String getResourceVersion() {
return resourceVersion;
}
- @JsonProperty("resource-version")
+ @JsonAlias("resource-version")
public void setResourceVersion(String resourceVersion) {
this.resourceVersion = resourceVersion;
}
- @JsonProperty("model-vers")
public ModelVers getModelVers() {
return modelVers;
}
- @JsonProperty("model-vers")
+ @JsonAlias("model-vers")
public void setModelVers(ModelVers modelVers) {
this.modelVers = modelVers;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVer.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVer.java
index f02bbac..6908feb 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVer.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVer.java
@@ -1,82 +1,70 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class ModelVer {
- @JsonProperty("model-version-id")
private String modelVersionId;
- @JsonProperty("model-name")
private String modelName;
- @JsonProperty("model-version")
private String modelVersion;
- @JsonProperty("distribution-status")
private String distributionStatus;
- @JsonProperty("resource-version")
private String resourceVersion;
- @JsonProperty("model-description")
private String modelDescription;
- @JsonProperty("model-version-id")
public String getModelVersionId() {
return modelVersionId;
}
- @JsonProperty("model-version-id")
+ @JsonAlias("model-version-id")
public void setModelVersionId(String modelVersionId) {
this.modelVersionId = modelVersionId;
}
- @JsonProperty("model-name")
public String getModelName() {
return modelName;
}
- @JsonProperty("model-name")
+ @JsonAlias("model-name")
public void setModelName(String modelName) {
this.modelName = modelName;
}
- @JsonProperty("model-version")
public String getModelVersion() {
return modelVersion;
}
- @JsonProperty("model-version")
+ @JsonAlias("model-version")
public void setModelVersion(String modelVersion) {
this.modelVersion = modelVersion;
}
- @JsonProperty("distribution-status")
public String getDistributionStatus() {
return distributionStatus;
}
- @JsonProperty("distribution-status")
+ @JsonAlias("distribution-status")
public void setDistributionStatus(String distributionStatus) {
this.distributionStatus = distributionStatus;
}
- @JsonProperty("resource-version")
public String getResourceVersion() {
return resourceVersion;
}
- @JsonProperty("resource-version")
+ @JsonAlias("resource-version")
public void setResourceVersion(String resourceVersion) {
this.resourceVersion = resourceVersion;
}
- @JsonProperty("model-description")
public String getModelDescription() {
return modelDescription;
}
- @JsonProperty("model-description")
+ @JsonAlias("model-description")
public void setModelDescription(String modelDescription) {
this.modelDescription = modelDescription;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVers.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVers.java
index f352158..eed40fc 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVers.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVers.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List;
@@ -11,15 +11,13 @@ import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
public class ModelVers {
- @JsonProperty("model-ver")
private List<ModelVer> modelVer;
- @JsonProperty("model-ver")
public List<ModelVer> getModelVer() {
return modelVer;
}
- @JsonProperty("model-ver")
+ @JsonAlias("model-ver")
public void setModelVer(List<ModelVer> modelVer) {
this.modelVer = modelVer;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntity.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntity.java
index edf5242..366a108 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntity.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntity.java
@@ -1,33 +1,29 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
/**
* Created by moriya1 on 08/10/2017.
*/
public class OwningEntity extends AaiRelationResponse {
- @JsonProperty("owning-entity-id")
private String owningEntityId;
- @JsonProperty("owning-entity-name")
private String owningEntityName;
- @JsonProperty("owning-entity-id")
public String getOwningEntityId() {
return owningEntityId;
}
- @JsonProperty("owning-entity-id")
+ @JsonAlias("owning-entity-id")
public void setOwningEntityId(String owningEntityId) {
this.owningEntityId = owningEntityId;
}
- @JsonProperty("owning-entity-name")
public String getOwningEntityName() {
return owningEntityName;
}
- @JsonProperty("owning-entity-name")
+ @JsonAlias("owning-entity-name")
public void setOwningEntityName(String owningEntityName) {
this.owningEntityName = owningEntityName;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntityResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntityResponse.java
index 3a571ea..1d9bd83 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntityResponse.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntityResponse.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
@@ -10,17 +10,15 @@ import java.util.List;
*/
public class OwningEntityResponse {
- @JsonProperty("owning-entity")
private List<OwningEntity> owningEntity;
- @JsonProperty("owning-entity")
public List<OwningEntity> getOwningEntity() {
return owningEntity;
}
@JsonProperty("owning-entity")
- public void setOwningEntity(List<OwningEntity> owningEntity) {
+ public void setJsonOwningEntity(List<OwningEntity> owningEntity) {
this.owningEntity = owningEntity;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/Permissions.kt b/vid-app-common/src/main/java/org/onap/vid/aai/model/Permissions.kt
new file mode 100644
index 0000000..472da8d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/Permissions.kt
@@ -0,0 +1,6 @@
+package org.onap.vid.aai.model
+
+import com.fasterxml.jackson.annotation.JsonProperty
+
+
+data class Permissions(@get:JsonProperty("isEditPermitted") val isEditPermitted: Boolean) \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/PnfProperties.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/PnfProperties.java
index 3481d26..032714b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/PnfProperties.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/PnfProperties.java
@@ -1,12 +1,6 @@
package org.onap.vid.aai.model;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.*;
import java.util.HashMap;
import java.util.Map;
@@ -23,20 +17,15 @@ import java.util.Map;
})
public class PnfProperties {
- @JsonProperty("pnf-name")
public String pnfName;
- @JsonProperty("equip-type")
public String equipType;
- @JsonProperty("equip-vendor")
public String equipVendor;
- @JsonProperty("equip-model")
public String equipModel;
- @JsonProperty("in-maint")
public Boolean inMaint;
- @JsonProperty("resource-version")
public String resourceVersion;
+
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private Map<String, Object> additionalProperties = new HashMap<>();
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
@@ -48,4 +37,34 @@ public class PnfProperties {
this.additionalProperties.put(name, value);
}
+ @JsonProperty("pnf-name")
+ public void setJsonPnfName(String pnfName) {
+ this.pnfName = pnfName;
+ }
+
+ @JsonProperty("equip-type")
+ public void setJsonEquipType(String equipType) {
+ this.equipType = equipType;
+ }
+
+ @JsonProperty("equip-vendor")
+ public void setJsonEquipVendor(String equipVendor) {
+ this.equipVendor = equipVendor;
+ }
+
+ @JsonProperty("equip-model")
+ public void setJsonEquipModel(String equipModel) {
+ this.equipModel = equipModel;
+ }
+
+ @JsonProperty("in-maint")
+ public void setJsonInMaint(Boolean inMaint) {
+ this.inMaint = inMaint;
+ }
+
+ @JsonProperty("resource-version")
+ public void setJsonResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/PnfResult.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/PnfResult.java
index a727d8f..a2c3d3b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/PnfResult.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/PnfResult.java
@@ -1,12 +1,6 @@
package org.onap.vid.aai.model;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.onap.vid.RelatedTo;
+import com.fasterxml.jackson.annotation.*;
import java.util.HashMap;
import java.util.List;
@@ -23,19 +17,39 @@ import java.util.Map;
})
public class PnfResult {
- @JsonProperty("id")
public String id;
- @JsonProperty("node-type")
public String nodeType;
- @JsonProperty("url")
public String url;
- @JsonProperty("properties")
public PnfProperties properties;
- @JsonProperty("related-to")
public List<RelatedTo> relatedTo;
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private Map<String, Object> additionalProperties = new HashMap<>();
+
+ @JsonProperty("id")
+ public void setJsonId(String id) {
+ this.id = id;
+ }
+
+ @JsonProperty("node-type")
+ public void setJsonNodeType(String nodeType) {
+ this.nodeType = nodeType;
+ }
+
+ @JsonProperty("url")
+ public void setJsonUrl(String url) {
+ this.url = url;
+ }
+
+ @JsonProperty("properties")
+ public void setJsonProperties(PnfProperties properties) {
+ this.properties = properties;
+ }
+
+ @JsonProperty("related-to")
+ public void setJsonRelatedTo(List<RelatedTo> relatedTo) {
+ this.relatedTo = relatedTo;
+ }
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/PortDetailsTranslator.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/PortDetailsTranslator.java
index f898045..ae74af6 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/PortDetailsTranslator.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/PortDetailsTranslator.java
@@ -3,10 +3,7 @@ package org.onap.vid.aai.model;
import com.google.common.collect.ImmutableList;
import org.onap.vid.aai.AaiResponse;
-import org.onap.vid.properties.Features;
-import org.togglz.core.manager.FeatureManager;
-import javax.inject.Inject;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
@@ -15,10 +12,7 @@ import java.util.stream.Collectors;
public class PortDetailsTranslator {
- @Inject
- FeatureManager featureManager;
-
- public static class PortDetailsOk extends PortDetails {
+ public static class PortDetailsOk implements PortDetails {
private final String interfaceId;
private final String interfaceName;
@@ -43,16 +37,16 @@ public class PortDetailsTranslator {
}
}
- public abstract static class PortDetails {
+ public interface PortDetails {
}
- public static class PortDetailsError extends PortDetails {
+ public static class PortDetailsError implements PortDetails {
private final String errorDescription;
private final String rawAaiResponse;
- public PortDetailsError(String errorDescription, String rawAaiResponse){
- this.errorDescription = errorDescription;
- this.rawAaiResponse = rawAaiResponse;
+ public PortDetailsError(String errorDescription, String rawAaiResponse) {
+ this.errorDescription = errorDescription;
+ this.rawAaiResponse = rawAaiResponse;
}
public String getErrorDescription() {
@@ -64,13 +58,13 @@ public class PortDetailsTranslator {
}
}
- public static PortDetails extractPortDetailsFromProperties(Properties properties, String rawPayload){
+ public static PortDetails extractPortDetailsFromProperties(Properties properties, String rawPayload) {
List<String> errorDescriptions = new LinkedList<>();
describeIfNullOrEmpty("interface-id", properties.getInterfaceId(), errorDescriptions);
describeIfNullOrEmpty("interface-name", properties.getInterfaceName(), errorDescriptions);
describeIfNullOrEmpty("is-port-mirrored", properties.getIsPortMirrored(), errorDescriptions);
- if(errorDescriptions.isEmpty()){
+ if (errorDescriptions.isEmpty()) {
return new PortDetailsOk(properties.getInterfaceId(), properties.getInterfaceName(), properties.getIsPortMirrored());
} else {
return new PortDetailsError(String.join(" ", errorDescriptions), rawPayload);
@@ -90,14 +84,14 @@ public class PortDetailsTranslator {
final String errorMessage = aaiResponse.getErrorMessage();
return Optional.of(ImmutableList.of(new PortDetailsError(
"Got " + aaiResponse.getHttpCode() + " from aai",
- errorMessage != null ? errorMessage.toString() : rawPayload)
+ errorMessage != null ? errorMessage : rawPayload)
));
} else {
return Optional.empty();
}
}
- public List<PortDetails> extractPortDetailsInternal(AaiGetPortMirroringSourcePorts aaiGetPortsResponse, String rawPayload){
+ public List<PortDetails> extractPortDetailsInternal(CustomQuerySimpleResult aaiGetPortsResponse, String rawPayload) {
List<SimpleResult> filteredResult = getFilteredPortList(aaiGetPortsResponse.getResults());
return filteredResult.stream()
@@ -107,7 +101,7 @@ public class PortDetailsTranslator {
}
public List<SimpleResult> getFilteredPortList(List<SimpleResult> results) {
- String LINTERFACE = "l-interface";
+ final String LINTERFACE = "l-interface";
final Predicate<SimpleResult> ifIsPort = (SimpleResult r) -> LINTERFACE.equals(r.getNodeType());
Predicate<SimpleResult> ifIsSource = getIsSourcePredicate();
@@ -119,18 +113,12 @@ public class PortDetailsTranslator {
}
private Predicate<SimpleResult> getIsSourcePredicate() {
- boolean FLAG_ADVANCED_PORTS_FILTER = featureManager.isActive(Features.FLAG_ADVANCED_PORTS_FILTER);
-
- if (FLAG_ADVANCED_PORTS_FILTER) {
- String PORT_LABEL = "org.onap.relationships.inventory.Source";
- return (SimpleResult r) -> r.getRelatedTo().stream()
- .anyMatch(relatedTo -> PORT_LABEL.equalsIgnoreCase(relatedTo.getRelationshipLabel()));
- } else {
- return (SimpleResult r) -> true;
- }
+ final String PORT_LABEL = "org.onap.relationships.inventory.Source";
+ return (SimpleResult r) -> r.getRelatedTo().stream()
+ .anyMatch(relatedTo -> PORT_LABEL.equalsIgnoreCase(relatedTo.getRelationshipLabel()));
}
- public List<PortDetails> extractPortDetails(AaiResponse<AaiGetPortMirroringSourcePorts> aaiGetPortsResponse, String rawPayload){
+ public List<PortDetails> extractPortDetails(AaiResponse<CustomQuerySimpleResult> aaiGetPortsResponse, String rawPayload) {
return extractErrorResponseIfHttpError(aaiGetPortsResponse, rawPayload).orElseGet(() -> extractPortDetailsInternal(aaiGetPortsResponse.getT(), rawPayload));
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/Project.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/Project.java
index 5931bb9..4e9f945 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/Project.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/Project.java
@@ -1,20 +1,18 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
/**
* Created by moriya1 on 08/10/2017.
*/
public class Project extends AaiRelationResponse {
- @JsonProperty("project-name")
private String projectName;
- @JsonProperty("project-name")
public String getProjectName() { return projectName; }
- @JsonProperty("project-name")
+ @JsonAlias("project-name")
public void setProjectName(String projectName) { this.projectName = projectName; }
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ProjectResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ProjectResponse.java
index 0ca35b0..125e106 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/ProjectResponse.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ProjectResponse.java
@@ -1,8 +1,6 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonProperty;
-
import java.util.List;
/**
@@ -10,16 +8,13 @@ import java.util.List;
*/
public class ProjectResponse {
- @JsonProperty("project")
private List<Project> project;
- @JsonProperty("project")
public List<Project> getProject() {
return project;
}
- @JsonProperty("project")
public void setProject(List<Project> project) {
this.project = project;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/Properties.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/Properties.java
index 6fecbed..dec632e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/Properties.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/Properties.java
@@ -1,23 +1,38 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.HashMap;
+import java.util.Map;
-@JsonIgnoreProperties(ignoreUnknown = true)
public class Properties {
- private final String interfaceName;
- private final String interfaceId;
- private final Boolean isPortMirrored;
+ //properties for l-interface node-type
+ @JsonProperty("interface-name")
+ private String interfaceName;
- public Properties(
- @JsonProperty("interface-name") String interfaceName,
- @JsonProperty("interface-id") String interfaceId,
- @JsonProperty("is-port-mirrored") Boolean isPortMirrored) {
- this.interfaceName = interfaceName;
- this.interfaceId = interfaceId;
- this.isPortMirrored = isPortMirrored;
- }
+ @JsonProperty("interface-id")
+ private String interfaceId;
+
+ @JsonProperty("is-port-mirrored")
+ private Boolean isPortMirrored;
+
+ //properties for tenant node-type
+ @JsonProperty("tenant-id")
+ private String tenantId;
+
+ @JsonProperty("tenant-name")
+ private String tenantName;
+
+ //properties for cloud-region node-type
+ @JsonProperty("cloud-region-id")
+ private String cloudRegionId;
+
+ private Map<String, String> additionalProperties = new HashMap<>();
+
+ public Properties(){}
public String getInterfaceName() {
return interfaceName;
@@ -30,4 +45,38 @@ public class Properties {
public Boolean getIsPortMirrored() {
return isPortMirrored;
}
+
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantName() {
+ return tenantName;
+ }
+
+ public void setTenantName(String tenantName) {
+ this.tenantName = tenantName;
+ }
+
+ public String getCloudRegionId() {
+ return cloudRegionId;
+ }
+
+ public void setCloudRegionId(String cloudRegionId) {
+ this.cloudRegionId = cloudRegionId;
+ }
+
+ @JsonAnyGetter
+ public Map<String, String> getAdditionalProperties() {
+ return additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperties(String name, String value) {
+ additionalProperties.put(name, value);
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedTo.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedTo.java
index f14a445..fa0351e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedTo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedTo.java
@@ -1,9 +1,11 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
public class RelatedTo {
private final String id;
private final String relationshipLabel;
@@ -20,19 +22,19 @@ public class RelatedTo {
this.nodeType = nodeType;
this.url = url;
}
-
+ @JsonProperty("id")
public String getId() {
return id;
}
-
+ @JsonProperty("relationship-label")
public String getRelationshipLabel() {
return relationshipLabel;
}
-
+ @JsonProperty("node-type")
public String getNodeType() {
return nodeType;
}
-
+ @JsonProperty("url")
public String getUrl() {
return url;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedToProperty.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedToProperty.java
index a2a98fc..9227e87 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedToProperty.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedToProperty.java
@@ -1,8 +1,8 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class RelatedToProperty {
@@ -12,6 +12,7 @@ public class RelatedToProperty {
}
+ @JsonAlias("property-key")
public void setPropertyKey(String propertyKey) {
this.propertyKey = propertyKey;
}
@@ -22,16 +23,15 @@ public class RelatedToProperty {
}
+ @JsonAlias("property-value")
public void setPropertyValue(String propertyValue) {
this.propertyValue = propertyValue;
}
- @JsonProperty("property-key")
public String propertyKey;
- @JsonProperty("property-value")
public String propertyValue;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/Relationship.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/Relationship.java
index 6bf63c4..d6ba8d8 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/Relationship.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/Relationship.java
@@ -1,7 +1,8 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
import java.util.List;
@@ -9,19 +10,14 @@ import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
public class Relationship {
- @JsonProperty("related-to")
public String relatedTo;
- @JsonProperty("related-link")
public String relatedLink;
- @JsonProperty("relationship-label")
public String relationshipLabel;
- @JsonProperty("relationship-data")
public List<RelationshipData> relationshipData;
- @JsonProperty("related-to-property")
public List<RelatedToProperty> relatedToProperty;
@@ -29,6 +25,7 @@ public class Relationship {
return relatedTo;
}
+ @JsonAlias("related-to")
public void setRelatedTo(String relatedTo) {
this.relatedTo = relatedTo;
}
@@ -37,6 +34,7 @@ public class Relationship {
return relatedLink;
}
+ @JsonAlias("related-link")
public void setRelatedLink(String relatedLink) {
this.relatedLink = relatedLink;
}
@@ -45,6 +43,7 @@ public class Relationship {
return relationshipData;
}
+ @JsonAlias("relationship-data")
public void setRelationDataList(List<RelationshipData> relationDataList) {
this.relationshipData = relationDataList;
}
@@ -53,6 +52,7 @@ public class Relationship {
return relatedToProperty;
}
+ @JsonAlias("related-to-property")
public void setRelatedToPropertyList(List<RelatedToProperty> relatedToPropertyList) {
this.relatedToProperty = relatedToPropertyList;
}
@@ -61,6 +61,7 @@ public class Relationship {
return relationshipLabel;
}
+ @JsonAlias("relationship-label")
public void setRelationshipLabel(String relationshipLabel) {
this.relationshipLabel = relationshipLabel;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipData.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipData.java
index 4153665..55a0b77 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipData.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipData.java
@@ -1,29 +1,29 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class RelationshipData {
- @JsonProperty("relationship-key")
- public String getRelationshipKey() {
- return relationshipKey;
- }
- @JsonProperty("relationship-key")
- public void setRelationshipKey(String relationshipKey) {
- this.relationshipKey = relationshipKey;
- }
- @JsonProperty("relationship-value")
- public String getRelationshipValue() {
- return relationshipValue;
- }
- @JsonProperty("relationship-value")
- public void setRelationshipValue(String relationshipValue) {
- this.relationshipValue = relationshipValue;
- }
+ public String relationshipKey;
+ public String relationshipValue;
- public String relationshipKey;
-
- public String relationshipValue;
+ public String getRelationshipKey() {
+ return relationshipKey;
+ }
+
+ @JsonAlias("relationship-key")
+ public void setRelationshipKey(String relationshipKey) {
+ this.relationshipKey = relationshipKey;
+ }
+
+ public String getRelationshipValue() {
+ return relationshipValue;
+ }
+
+ @JsonAlias("relationship-value")
+ public void setRelationshipValue(String relationshipValue) {
+ this.relationshipValue = relationshipValue;
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java
index b16ddd0..f51fb9d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ResourceType.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ResourceType.java
index 736a1aa..79f5272 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/ResourceType.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ResourceType.java
@@ -10,10 +10,12 @@ import java.util.stream.Stream;
public enum ResourceType {
- SERVICE_INSTANCE("service-instance", "service-instance-name"),
- GENERIC_VNF("generic-vnf", "vnf-name"),
- VF_MODULE("vf-module", "vf-module-name"),
- VOLUME_GROUP("volume-group", "volume-group-name");
+ SERVICE_INSTANCE("service-instances", "service-instance-name"),
+ GENERIC_VNF("generic-vnfs", "vnf-name"),
+ L3_NETWORK("l3-networks", "network-name"),
+ VF_MODULE("vf-modules", "vf-module-name"),
+ INSTANCE_GROUP("instance-groups", "instance-group-name"),
+ VOLUME_GROUP("volume-groups", "volume-group-name");
private static Map<String, ResourceType> AAI_FORMAT_MAP = Stream
.of(ResourceType.values())
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/Result.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/Result.java
index 1eb46be..cb4dc86 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/Result.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/Result.java
@@ -1,7 +1,7 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Created by moriya1 on 15/10/2017.
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceProperties.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceProperties.java
index a76bcf8..a1962cc 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceProperties.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceProperties.java
@@ -1,8 +1,6 @@
package org.onap.vid.aai.model;
import com.fasterxml.jackson.annotation.*;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
import java.util.HashMap;
import java.util.Map;
@@ -35,70 +33,49 @@ import java.util.Map;
public class ServiceProperties {
@JsonProperty("service-instance-id")
- @com.fasterxml.jackson.annotation.JsonProperty("service-instance-id")
public String serviceInstanceId;
@JsonProperty("service-instance-name")
- @com.fasterxml.jackson.annotation.JsonProperty("service-instance-name")
public String serviceInstanceName;
@JsonProperty("model-invariant-id")
- @com.fasterxml.jackson.annotation.JsonProperty("model-invariant-id")
public String modelInvariantId;
@JsonProperty("model-version-id")
- @com.fasterxml.jackson.annotation.JsonProperty("model-version-id")
public String modelVersionId;
@JsonProperty("resource-version")
- @com.fasterxml.jackson.annotation.JsonProperty("resource-version")
public String resourceVersion;
@JsonProperty("orchestration-status")
- @com.fasterxml.jackson.annotation.JsonProperty("orchestration-status")
public String orchestrationStatus;
@JsonProperty("global-customer-id")
- @com.fasterxml.jackson.annotation.JsonProperty("global-customer-id")
public String globalCustomerId;
@JsonProperty("subscriber-name")
- @com.fasterxml.jackson.annotation.JsonProperty("subscriber-name")
public String subscriberName;
@JsonProperty("subscriber-type")
- @com.fasterxml.jackson.annotation.JsonProperty("subscriber-type")
public String subscriberType;
@JsonProperty("vnf-id")
- @com.fasterxml.jackson.annotation.JsonProperty("vnf-id")
public String vnfId;
@JsonProperty("vnf-name")
- @com.fasterxml.jackson.annotation.JsonProperty("vnf-name")
public String vnfName;
@JsonProperty("vnf-type")
- @com.fasterxml.jackson.annotation.JsonProperty("vnf-type")
public String vnfType;
@JsonProperty("service-id")
- @com.fasterxml.jackson.annotation.JsonProperty("service-id")
public String serviceId;
@JsonProperty("prov-status")
- @com.fasterxml.jackson.annotation.JsonProperty("prov-status")
public String provStatus;
@JsonProperty("in-maint")
- @com.fasterxml.jackson.annotation.JsonProperty("in-maint")
public Boolean inMaint;
@JsonProperty("is-closed-loop-disabled")
- @com.fasterxml.jackson.annotation.JsonProperty("is-closed-loop-disabled")
public Boolean isClosedLoopDisabled;
@JsonProperty("model-customization-id")
- @com.fasterxml.jackson.annotation.JsonProperty("model-customization-id")
public String modelCustomizationId;
@JsonProperty("nf-type")
- @com.fasterxml.jackson.annotation.JsonProperty("nf-type")
public String nfType;
@JsonProperty("nf-function")
- @com.fasterxml.jackson.annotation.JsonProperty("nf-function")
public String nfFunction;
@JsonProperty("nf-role")
- @com.fasterxml.jackson.annotation.JsonProperty("nf-role")
public String nfRole;
@JsonProperty("nf-naming-code")
- @com.fasterxml.jackson.annotation.JsonProperty("nf-naming-code")
public String nfNamingCode;
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private Map<String, Object> additionalProperties = new HashMap<>();
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceRelationships.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceRelationships.java
index b8abc84..eba0035 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceRelationships.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceRelationships.java
@@ -1,40 +1,31 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+@JsonIgnoreProperties(ignoreUnknown = true)
public class ServiceRelationships {
- @JsonProperty("service-instance-id")
public String serviceInstanceId;
- @JsonProperty("service-instance-name")
public String serviceInstanceName;
- @JsonProperty("service-type")
public String serviceType;
- @JsonProperty("service-role")
public String serviceRole;
- @JsonProperty("environment-context")
public String environmentContext;
- @JsonProperty("workload-context")
public String workloadContext;
- @JsonProperty("model-invariant-id")
public String modelInvariantId;
-
- @JsonProperty("model-version-id")
+
public String modelVersionId;
- @JsonProperty("resource-version")
public String resourceVersion;
-
- @JsonProperty("orchestration-status")
+
public String orchestrationStatus;
- @JsonProperty("relationship-list")
public RelationshipList relationshipList;
@@ -42,6 +33,7 @@ public class ServiceRelationships {
return serviceInstanceId;
}
+ @JsonAlias("service-instance-id")
public void setServiceInstanceId(String serviceInstanceId) {
this.serviceInstanceId = serviceInstanceId;
}
@@ -50,6 +42,7 @@ public class ServiceRelationships {
return serviceInstanceName;
}
+ @JsonAlias("service-instance-name")
public void setServiceInstanceName(String serviceInstanceName) {
this.serviceInstanceName = serviceInstanceName;
}
@@ -58,6 +51,43 @@ public class ServiceRelationships {
return modelInvariantId;
}
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ @JsonAlias("service-type")
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public String getServiceRole() {
+ return serviceRole;
+ }
+
+ @JsonAlias("service-role")
+ public void setServiceRole(String serviceRole) {
+ this.serviceRole = serviceRole;
+ }
+
+ public String getEnvironmentContext() {
+ return environmentContext;
+ }
+
+ @JsonAlias("environment-context")
+ public void setEnvironmentContext(String environmentContext) {
+ this.environmentContext = environmentContext;
+ }
+
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ @JsonAlias("workload-context")
+ public void setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+
+ @JsonAlias("model-invariant-id")
public void setModelInvariantId(String modelInvariantId) {
this.modelInvariantId = modelInvariantId;
}
@@ -66,6 +96,7 @@ public class ServiceRelationships {
return modelVersionId;
}
+ @JsonAlias("model-version-id")
public void setModelVersionId(String modelVersionId) {
this.modelVersionId = modelVersionId;
}
@@ -74,6 +105,7 @@ public class ServiceRelationships {
return resourceVersion;
}
+ @JsonAlias("resource-version")
public void setResourceVersion(String resourceVersion) {
this.resourceVersion = resourceVersion;
}
@@ -82,6 +114,7 @@ public class ServiceRelationships {
return orchestrationStatus;
}
+ @JsonAlias("orchestration-status")
public void setOrchestrationStatus(String orchestrationStatus) {
this.orchestrationStatus = orchestrationStatus;
}
@@ -90,6 +123,7 @@ public class ServiceRelationships {
return relationshipList;
}
+ @JsonAlias("relationship-list")
public void setRelationshipList(RelationshipList relationshipList) {
this.relationshipList = relationshipList;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/SimpleResult.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/SimpleResult.java
index b2edfc1..554449b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/SimpleResult.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/SimpleResult.java
@@ -1,85 +1,73 @@
package org.onap.vid.aai.model;
-import org.codehaus.jackson.annotate.JsonAnyGetter;
-import org.codehaus.jackson.annotate.JsonAnySetter;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SimpleResult {
- @JsonProperty("id")
private String id;
- @JsonProperty("node-type")
private String nodeType;
- @JsonProperty("url")
private String url;
- @JsonProperty("properties")
private Properties properties;
- @JsonProperty("related-to")
private List<RelatedTo> relatedTo = null;
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private Map<String, Object> additionalProperties = new HashMap<>();
- @JsonProperty("id")
public String getId() {
return id;
}
@JsonProperty("id")
- public void setId(String id) {
+ public void setJsonId(String id) {
this.id = id;
}
- @JsonProperty("node-type")
public String getNodeType() {
return nodeType;
}
@JsonProperty("node-type")
- public void setNodeType(String nodeType) {
+ public void setJsonNodeType(String nodeType) {
this.nodeType = nodeType;
}
- @JsonProperty("url")
public String getUrl() {
return url;
}
@JsonProperty("url")
- public void setUrl(String url) {
+ public void setJsonUrl(String url) {
this.url = url;
}
- @JsonProperty("properties")
public Properties getProperties() {
return properties;
}
@JsonProperty("properties")
- public void setProperties(Properties properties) {
+ public void setJsonProperties(Properties properties) {
this.properties = properties;
}
- @JsonProperty("related-to")
public List<RelatedTo> getRelatedTo() {
return relatedTo;
}
@JsonProperty("related-to")
- public void setRelatedTo(List<RelatedTo> relatedTo) {
+ public void setJsonRelatedTo(List<RelatedTo> relatedTo) {
this.relatedTo = relatedTo;
}
- @JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonAnySetter
- public void setAdditionalProperty(String name, Object value) {
+ public void setJsonAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java
index e4f2284..b404a02 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java
@@ -1,8 +1,6 @@
package org.onap.vid.aai.model;
import com.fasterxml.jackson.annotation.*;
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.onap.vid.RelatedTo;
import java.util.HashMap;
import java.util.List;
@@ -18,10 +16,8 @@ import java.util.Map;
"related-to"
})
public class VnfResult {
-
@JsonProperty("id")
public String id;
- @com.fasterxml.jackson.annotation.JsonProperty("node-type")
@JsonProperty("node-type")
public String nodeType;
@JsonProperty("url")
@@ -29,10 +25,34 @@ public class VnfResult {
@JsonProperty("properties")
public ServiceProperties properties;
@JsonProperty("related-to")
- @com.fasterxml.jackson.annotation.JsonProperty("related-to")
public List<RelatedTo> relatedTo = null;
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private Map<String, Object> additionalProperties = new HashMap<>();
+
+ @JsonProperty("id")
+ public void setJsonId(String id) {
+ this.id = id;
+ }
+
+ @JsonProperty("node-type")
+ public void setJsonNodeType(String nodeType) {
+ this.nodeType = nodeType;
+ }
+
+ @JsonProperty("url")
+ public void setJsonUrl(String url) {
+ this.url = url;
+ }
+
+ @JsonProperty("properties")
+ public void setJsonProperties(ServiceProperties properties) {
+ this.properties = properties;
+ }
+
+ @JsonProperty("related-to")
+ public void setJsonRelatedTo(List<RelatedTo> relatedTo) {
+ this.relatedTo = relatedTo;
+ }
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
@@ -40,7 +60,7 @@ public class VnfResult {
}
@JsonAnySetter
- public void setAdditionalProperty(String name, Object value) {
+ public void setJsonAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/interfaces/AaiModelWithRelationships.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/interfaces/AaiModelWithRelationships.java
new file mode 100644
index 0000000..77fe4ce
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/interfaces/AaiModelWithRelationships.java
@@ -0,0 +1,7 @@
+package org.onap.vid.aai.model.interfaces;
+
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList;
+
+public interface AaiModelWithRelationships {
+ RelationshipList getRelationshipList();
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java
index f5625ce..f4401ab 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java
@@ -22,12 +22,14 @@ package org.onap.vid.aai.util;
import com.att.eelf.configuration.EELFLogger;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.aai.ExceptionWithRequestInfo;
import org.onap.vid.aai.ResponseWithRequestInfo;
import org.onap.vid.aai.exceptions.InvalidPropertyException;
import org.onap.vid.utils.Logging;
+import org.onap.vid.utils.Unchecked;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
@@ -37,6 +39,7 @@ import javax.ws.rs.client.Invocation;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
+import java.net.URI;
import java.net.URLEncoder;
import java.util.Optional;
import java.util.UUID;
@@ -55,7 +58,6 @@ public class AAIRestInterface {
protected final EELFLogger outgoingRequestsLogger = Logging.getRequestsLogger("aai");
-
/** The client. */
private Client client = null;
@@ -105,9 +107,9 @@ public class AAIRestInterface {
return URLEncoder.encode(nodeKey, "UTF-8").replaceAll("\\+", "%20");
}
- private void initRestClient() {
- initRestClient(false);
- }
+ protected void initRestClient() {
+ initRestClient(false);
+ }
private void initRestClient(boolean propagateExceptions) {
@@ -160,47 +162,61 @@ public class AAIRestInterface {
* @param xml the xml
* @return the string
*/
- public ResponseWithRequestInfo RestGet(String fromAppId, String transId, String requestUri, boolean xml) {
+ public ResponseWithRequestInfo RestGet(String fromAppId, String transId, URI requestUri, boolean xml) {
return RestGet(fromAppId, transId, requestUri, xml, false);
}
- public ResponseWithRequestInfo RestGet(String fromAppId, String transId, String requestUri, boolean xml, boolean propagateExceptions) {
- String methodName = "RestGet";
- String url = systemPropertyHelper.getFullServicePath(requestUri);
+ public ResponseWithRequestInfo RestGet(String fromAppId, String transId, URI requestUri, boolean xml, boolean propagateExceptions) {
+ return doRest(fromAppId, transId, requestUri, null, HttpMethod.GET, xml, propagateExceptions);
+ }
+
+ public ResponseWithRequestInfo doRest(String fromAppId, String transId, URI requestUri, String payload, HttpMethod method, boolean xml, boolean propagateExceptions) {
+ String url = null;
+ String methodName = "Rest"+method.name();
try {
+
+ url = systemPropertyHelper.getFullServicePath(requestUri);
+
initRestClient(propagateExceptions);
logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_STRING);
logger.debug(EELFLoggerDelegate.debugLogger, url + " for the get REST API");
- Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
+ Logging.logRequest(outgoingRequestsLogger, method, url, payload);
final Response response;
- Invocation.Builder requestBuilder = client.target(url)
- .request()
- .accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON)
- .header(TRANSACTION_ID_HEADER, transId)
- .header(FROM_APP_ID_HEADER, fromAppId)
- .header("Content-Type", MediaType.APPLICATION_JSON)
- .header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId());
- response = systemPropertyHelper.isClientCertEnabled() ?
- requestBuilder.get() : authenticateRequest(requestBuilder).get();
- Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, response);
-
- if (response.getStatusInfo().equals(Response.Status.OK)) {
+ Invocation.Builder requestBuilder = client.target(url)
+ .request()
+ .accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON)
+ .header(TRANSACTION_ID_HEADER, transId)
+ .header(FROM_APP_ID_HEADER, fromAppId)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId());
+
+ requestBuilder = systemPropertyHelper.isClientCertEnabled() ?
+ requestBuilder : authenticateRequest(requestBuilder);
+
+ Invocation restInvocation = StringUtils.isEmpty(payload) ?
+ requestBuilder.build(method.name()) :
+ requestBuilder.build(method.name(), Entity.entity(payload, MediaType.APPLICATION_JSON));
+
+ response = restInvocation.invoke();
+ Logging.logResponse(outgoingRequestsLogger, method, url, response);
+
+ if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) {
logger.debug(EELFLoggerDelegate.debugLogger, methodName + SUCCESSFUL_API_MESSAGE);
logger.info(EELFLoggerDelegate.errorLogger, methodName + SUCCESSFUL_API_MESSAGE);
} else {
logger.debug(EELFLoggerDelegate.debugLogger, getInvalidResponseLogMessage(url, methodName, response));
}
- return new ResponseWithRequestInfo(response, url, HttpMethod.GET);
+ return new ResponseWithRequestInfo(response, url, method);
} catch (Exception e) {
logger.debug(EELFLoggerDelegate.debugLogger, getFailedResponseLogMessage(url, methodName, e));
if (propagateExceptions) {
- throw new ExceptionWithRequestInfo(HttpMethod.GET, defaultIfNull(url, requestUri), e);
- } else {
- return new ResponseWithRequestInfo(null, url, HttpMethod.GET);
- }
+ throw new ExceptionWithRequestInfo(method, defaultIfNull(url, requestUri.toASCIIString()), e);
+ } else {
+ return new ResponseWithRequestInfo(null, url, method);
+ }
}
}
@@ -222,7 +238,7 @@ public class AAIRestInterface {
transId += ":" + UUID.randomUUID().toString();
logger.debug(methodName + START_STRING);
Boolean response = false;
- String url = systemPropertyHelper.getFullServicePath(path);;
+ String url = systemPropertyHelper.getFullServicePath(path);
try {
initRestClient();
@@ -263,37 +279,11 @@ public class AAIRestInterface {
* @param path the path
* @param payload the payload
* @param xml the xml
+ * @param propagateExceptions
* @return the string
*/
- public Response RestPut(String fromAppId, String path, String payload, boolean xml) {
- String methodName = "RestPut";
- String url=systemPropertyHelper.getFullServicePath(path);
- String transId = UUID.randomUUID().toString();
- logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_STRING);
-
- Response response = null;
- try {
- initRestClient();
- Logging.logRequest(outgoingRequestsLogger, HttpMethod.PUT, url, payload);
- response = authenticateRequest(client.target(url)
- .request()
- .accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON)
- .header(TRANSACTION_ID_HEADER, transId)
- .header(FROM_APP_ID_HEADER, fromAppId))
- .header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId())
- .put(Entity.entity(payload, MediaType.APPLICATION_JSON));
- Logging.logResponse(outgoingRequestsLogger, HttpMethod.PUT, url, response);
-
- if (response.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL)) {
- logger.info(EELFLoggerDelegate.errorLogger, getValidResponseLogMessage(methodName));
- logger.debug(EELFLoggerDelegate.debugLogger, getValidResponseLogMessage(methodName));
- } else {
- logger.debug(EELFLoggerDelegate.debugLogger, getInvalidResponseLogMessage(url, methodName, response));
- }
- } catch (Exception e) {
- logger.debug(EELFLoggerDelegate.debugLogger, getFailedResponseLogMessage(url, methodName, e));
- }
- return response;
+ public ResponseWithRequestInfo RestPut(String fromAppId, String path, String payload, boolean xml, boolean propagateExceptions) {
+ return doRest(fromAppId, UUID.randomUUID().toString(), Unchecked.toURI(path), payload, HttpMethod.PUT, xml, propagateExceptions);
}
@@ -313,13 +303,13 @@ public class AAIRestInterface {
String transId = UUID.randomUUID().toString();
logger.debug(EELFLoggerDelegate.debugLogger, methodName + START_STRING);
- Response response = null;
+ Response response = null;
try {
initRestClient();
Logging.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, payload);
- response = authenticateRequest(client.target(systemPropertyHelper.getServiceBasePath(path))
+ response = authenticateRequest(client.target(url)
.request()
- .accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON)
+ .accept(xml ? MediaType.APPLICATION_XML : MediaType.APPLICATION_JSON)
.header(TRANSACTION_ID_HEADER, transId)
.header(FROM_APP_ID_HEADER, fromAppId))
.header(REQUEST_ID_HEADER_KEY, extractOrGenerateRequestId())
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeConverter.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeConverter.java
new file mode 100644
index 0000000..8fa6f6c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAITreeConverter.java
@@ -0,0 +1,89 @@
+package org.onap.vid.aai.util;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.vid.model.aaiTree.*;
+import org.onap.vid.mso.model.ModelInfo;
+import org.onap.vid.services.AAITreeNodeBuilder;
+import org.springframework.stereotype.Component;
+
+import java.util.Objects;
+
+import static java.util.function.Function.identity;
+import static java.util.stream.Collectors.counting;
+import static java.util.stream.Collectors.groupingBy;
+import static org.onap.vid.asdc.parser.ToscaParserImpl2.Constants.A_LA_CARTE;
+
+@Component
+public class AAITreeConverter {
+
+ public static final String VNF_TYPE = "vnf-type";
+ public static final String NETWORK_TYPE = "network-type";
+
+ public static final String IS_BASE_VF_MODULE = "is-base-vf-module";
+
+ public enum ModelType {
+ service,
+ vnf,
+ network,
+ instanceGroup,
+ vfModule
+ }
+
+ public ServiceInstance convertTreeToUIModel(AAITreeNode rootNode, String globalCustomerId, String serviceType, String instantiationType) {
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setInstanceId(rootNode.getId());
+ serviceInstance.setInstanceName(rootNode.getName());
+ serviceInstance.setOrchStatus(rootNode.getOrchestrationStatus());
+ serviceInstance.setGlobalSubscriberId(globalCustomerId);
+ serviceInstance.setSubscriptionServiceType(serviceType);
+ serviceInstance.setIsALaCarte(StringUtils.equals(instantiationType, A_LA_CARTE));
+
+ serviceInstance.setModelInfo(createModelInfo(rootNode, ModelType.service));
+
+ //set children: vnf, network,group
+ rootNode.getChildren().forEach(child -> {
+ if (child.getType().equals(AAITreeNodeBuilder.GENERIC_VNF)) {
+ serviceInstance.getVnfs().put(child.getUniqueNodeKey(), Vnf.from(child));
+ } else if (child.getType().equals(AAITreeNodeBuilder.NETWORK)) {
+ serviceInstance.getNetworks().put(child.getUniqueNodeKey(), Network.from(child));
+ } else if (child.getType().equals(AAITreeNodeBuilder.INSTANCE_GROUP)) {
+ serviceInstance.getVnfGroups().put(child.getUniqueNodeKey(), VnfGroup.from(child));
+ }
+ });
+
+ serviceInstance.setExistingVNFCounterMap(
+ serviceInstance.getVnfs().entrySet().stream()
+ .map(k -> k.getValue().getModelInfo().getModelVersionId())
+ .collect(groupingBy(identity(), counting()))
+ );
+
+ serviceInstance.setExistingNetworksCounterMap(
+ serviceInstance.getNetworks().entrySet().stream()
+ .map(k -> k.getValue().getModelInfo().getModelVersionId())
+ .filter(Objects::nonNull)
+ .collect(groupingBy(identity(), counting()))
+ );
+
+
+ serviceInstance.setExistingVnfGroupCounterMap(
+ serviceInstance.getVnfGroups().entrySet().stream()
+ .map(k -> k.getValue().getModelInfo().getModelVersionId())
+ .filter(Objects::nonNull)
+ .collect(groupingBy(identity(), counting()))
+ );
+
+ return serviceInstance;
+ }
+
+ private static ModelInfo createModelInfo(AAITreeNode aaiNode, ModelType modelType) {
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelType(modelType.name());
+ modelInfo.setModelName(aaiNode.getModelName());
+ modelInfo.setModelVersion(aaiNode.getModelVersion());
+ modelInfo.setModelVersionId(aaiNode.getModelVersionId());
+ modelInfo.setModelInvariantId(aaiNode.getModelInvariantId());
+ modelInfo.setModelCustomizationId(aaiNode.getModelCustomizationId());
+
+ return modelInfo;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/CacheConfig.kt b/vid-app-common/src/main/java/org/onap/vid/aai/util/CacheConfig.kt
new file mode 100644
index 0000000..0ff6041
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/CacheConfig.kt
@@ -0,0 +1,52 @@
+package org.onap.vid.aai.util
+
+import com.fasterxml.jackson.core.type.TypeReference
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.module.kotlin.KotlinModule
+import com.google.common.collect.ImmutableMap
+import org.springframework.stereotype.Component
+
+//I use a regular kotlin class because I want that when jackson read
+//a json with null values (or missing fields) they would get default values.
+//for other cases it's better to use data class for POJO class
+//for more information you can read here :
+//https://github.com/FasterXML/jackson-module-kotlin/issues/130
+class CacheConfig constructor(
+ isActive: Boolean?,
+ expireAfterWriteHours: Long?,
+ refreshAfterWriteSeconds: Long?) {
+ val isActive: Boolean = isActive ?: true
+ val expireAfterWriteHours: Long = expireAfterWriteHours ?: 24L
+ val refreshAfterWriteSeconds: Long = refreshAfterWriteSeconds ?: 10L
+
+ companion object {
+ val defaultCacheConfig = CacheConfig(null, null, null)
+ }
+
+}
+
+
+interface CacheConfigProvider {
+ fun getCacheConfig(cacheName:String): CacheConfig
+}
+
+@Component
+class CacheConfigProviderImpl() : CacheConfigProvider {
+ private val mapper = ObjectMapper().apply { registerModule(KotlinModule()) }
+
+ private fun readMapOfCacheConfig(): Map<String, CacheConfig> {
+ val configInputStream = CacheConfigProviderImpl::class.java.classLoader.getResourceAsStream("cacheConfig.json")
+
+ return if (configInputStream == null) {
+ ImmutableMap.of()
+ } else {
+ mapper.readValue(configInputStream, object : TypeReference<Map<String, CacheConfig>>() {})
+ }
+ }
+
+ override fun getCacheConfig(cacheName: String): CacheConfig {
+ return readMapOfCacheConfig()[cacheName] ?: CacheConfig.defaultCacheConfig
+ }
+}
+
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/CacheProvider.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/CacheProvider.java
new file mode 100644
index 0000000..63615f4
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/CacheProvider.java
@@ -0,0 +1,37 @@
+package org.onap.vid.aai.util;
+
+import java.util.List;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+
+public interface CacheProvider {
+ String KEY_DELIMITER = "!@#'";
+ /*
+ Returns the cache associated with given name; creates one if wasn't any
+ */
+ <K, V> Cache<K, V> aaiClientCacheFor(String name, Function<K, V> loader);
+
+ /*
+ reset cache if exist. Otherwise do nothing
+ */
+ void resetCache(String name);
+
+ interface Cache<K, V> {
+ V get(K key);
+ }
+
+ static String compileKey(List<String> args) {
+ return compileKey(args.toArray(new String[0]));
+ }
+
+ static String compileKey(String... args) {
+ return Stream.of(args).map(arg->defaultIfNull(arg, "")).collect( Collectors.joining( KEY_DELIMITER ) );
+ }
+
+ static String[] decompileKey(String key) {
+ return key.split(KEY_DELIMITER);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/CacheProviderWithLoadingCache.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/CacheProviderWithLoadingCache.java
new file mode 100644
index 0000000..26a3ebf
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/CacheProviderWithLoadingCache.java
@@ -0,0 +1,100 @@
+package org.onap.vid.aai.util;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.util.concurrent.UncheckedExecutionException;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.jetbrains.annotations.NotNull;
+import org.onap.vid.properties.Features;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.togglz.core.manager.FeatureManager;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+
+@Component
+public class CacheProviderWithLoadingCache implements CacheProvider {
+
+ private final ExecutorService cacheReloadPool;
+ private final FeatureManager featureManager;
+ private final CacheConfigProvider cacheConfigProvider;
+ private final ConcurrentHashMap<String, Cache> caches;
+
+
+ @Autowired
+ public CacheProviderWithLoadingCache(FeatureManager featureManager, CacheConfigProvider cacheConfigProvider) {
+ this.featureManager = featureManager;
+ this.cacheConfigProvider = cacheConfigProvider;
+ this.cacheReloadPool = Executors.newFixedThreadPool(3);
+ this.caches = new ConcurrentHashMap<>();
+ }
+
+ /*
+ Returns the cache associated with given name; creates one if wasn't any
+ */
+ @Override
+ public <K, V> Cache<K, V> aaiClientCacheFor(String name, Function<K, V> loader) {
+ return (Cache<K, V>) caches.computeIfAbsent(name, s -> buildAaiClientCacheFrom(loader, name));
+ }
+
+ @Override
+ public void resetCache(String name) {
+ caches.remove(name);
+ }
+
+ /*
+ Creates and returns a Cache that use provided `loader` to fetch values for
+ search keys, and stores the result for reuse over a certain time.
+ The cache will not use any stored key if FLAG_1810_AAI_LOCAL_CACHE is turned off.
+ In that case, `loader` will be invoked for any `get()` request from the cache. The
+ cache adheres the flag in real-time; so no restart is required.
+ */
+ protected <K, V> Cache<K, V> buildAaiClientCacheFrom(Function<K, V> loader, String name) {
+ final LoadingCache<K, V> activeCache = buildAaiClientActiveCacheFrom(loader, name);
+
+ // this works because Cache interface has only a single method: "get()"
+ // can be replaced with new anonimous class; e.g.:
+ // return new Cache() { ... }
+ return key -> {
+ if (featureManager.isActive(Features.FLAG_1810_AAI_LOCAL_CACHE) &&
+ defaultIfNull(cacheConfigProvider.getCacheConfig(name).isActive(), true)) {
+ try {
+ return activeCache.getUnchecked(key);
+ }
+ catch (UncheckedExecutionException exception) {
+ return ExceptionUtils.rethrow(exception.getCause());
+ }
+ } else {
+ activeCache.invalidateAll();
+ activeCache.cleanUp();
+ return loader.apply(key);
+ }
+ };
+ }
+
+ private <K, V> LoadingCache<K, V> buildAaiClientActiveCacheFrom(Function<K, V> loader, String name) {
+ return createCacheBuilder(name).build(createAsyncReloadingCacheLoaderFrom(loader));
+
+ }
+
+ @NotNull
+ protected CacheBuilder<Object, Object> createCacheBuilder(String name) {
+ CacheConfig cacheConfig = cacheConfigProvider.getCacheConfig(name);
+ return CacheBuilder.newBuilder()
+ .maximumSize(1000)
+ .expireAfterWrite(cacheConfig.getExpireAfterWriteHours(), TimeUnit.HOURS)
+ .refreshAfterWrite(cacheConfig.getRefreshAfterWriteSeconds(), TimeUnit.SECONDS);
+ }
+
+ private <K, V> CacheLoader<K, V> createAsyncReloadingCacheLoaderFrom(Function<K, V> loader) {
+ return CacheLoader.asyncReloading(CacheLoader.from(loader::apply), cacheReloadPool);
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsAuthClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsAuthClient.java
index 15f8143..489d2f1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsAuthClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsAuthClient.java
@@ -22,11 +22,16 @@
package org.onap.vid.aai.util;
+import org.apache.http.conn.ssl.DefaultHostnameVerifier;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.aai.exceptions.HttpClientBuilderException;
+import org.onap.vid.properties.Features;
+import org.togglz.core.manager.FeatureManager;
+import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -47,16 +52,19 @@ public class HttpsAuthClient {
private final SystemPropertyHelper systemPropertyHelper;
private final SSLContextProvider sslContextProvider;
- public HttpsAuthClient(String certFilePath, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider) {
+ public HttpsAuthClient(String certFilePath, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider, FeatureManager featureManager) {
this.certFilePath = certFilePath;
this.systemPropertyHelper = systemPropertyHelper;
this.sslContextProvider = sslContextProvider;
+ this.featureManager = featureManager;
}
private final String certFilePath;
+ FeatureManager featureManager;
+
/** The logger. */
- static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HttpsAuthClient.class);
+ static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(org.onap.vid.aai.util.HttpsAuthClient.class);
/**
@@ -70,7 +78,7 @@ public class HttpsAuthClient {
try {
setSystemProperties();
- ignoreHostname();
+ optionallyVerifyHostname();
return systemPropertyHelper.isClientCertEnabled() ?
getTrustedClient(config, getKeystorePath(), systemPropertyHelper.getDecryptedKeystorePassword(), mode)
@@ -83,8 +91,8 @@ public class HttpsAuthClient {
}
- private void ignoreHostname() {
- HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> true);
+ private void optionallyVerifyHostname() {
+ HttpsURLConnection.setDefaultHostnameVerifier(getHostnameVerifier());
}
private Client getUntrustedClient(ClientConfig config) {
@@ -94,12 +102,20 @@ public class HttpsAuthClient {
private Client getTrustedClient(ClientConfig config, String keystorePath, String keystorePassword, HttpClientMode httpClientMode) throws HttpClientBuilderException {
return ClientBuilder.newBuilder()
.sslContext(sslContextProvider.getSslContext(keystorePath, keystorePassword, httpClientMode))
- .hostnameVerifier((s, sslSession) -> true)
+ .hostnameVerifier(getHostnameVerifier())
.withConfig(config)
.build()
.register(CustomJacksonJaxBJsonProvider.class);
}
+ protected HostnameVerifier getHostnameVerifier() {
+ if(featureManager.isActive(Features.FLAG_EXP_USE_DEFAULT_HOST_NAME_VERIFIER)){
+ return new DefaultHostnameVerifier();
+ }
+
+ return new NoopHostnameVerifier();
+ }
+
private String getKeystorePath() {
return getCertificatesPath() + FileSystems.getDefault().getSeparator() + systemPropertyHelper.getAAIKeystoreFilename();
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsComponentsClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsComponentsClient.java
deleted file mode 100644
index d1f1cfc..0000000
--- a/vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsComponentsClient.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * 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.onap.vid.aai.util;
-
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLContextBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.eclipse.jetty.util.security.Password;
-import org.onap.vid.exceptions.GenericUncheckedException;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.portalsdk.core.util.SystemProperties;
-
-import javax.net.ssl.SSLContext;
-import java.io.FileInputStream;
-import java.security.GeneralSecurityException;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-
-
-/**
- * The Class HttpsComponentsClient.
- */
-public class HttpsComponentsClient{
-
- static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HttpsComponentsClient.class);
-
- /**
- * Gets the client.
- *
- * @param certFilePath the cert file path
- * @return the client
- * @throws KeyManagementException the key management exception
- */
- public static CloseableHttpClient getClient(String certFilePath) {
- CloseableHttpClient httpclient = null;
- try {
-
- String truststore_path = certFilePath + AAIProperties.FILESEPARTOR + SystemProperties.getProperty(AAIProperties.AAI_TRUSTSTORE_FILENAME);
- String truststore_password = SystemProperties.getProperty(AAIProperties.AAI_TRUSTSTORE_PASSWD_X);
- String decrypted_truststore_password = Password.deobfuscate(truststore_password);
- String keystore_path = certFilePath + AAIProperties.FILESEPARTOR + SystemProperties.getProperty(AAIProperties.AAI_KEYSTORE_FILENAME);
- String keystore_password = SystemProperties.getProperty(AAIProperties.AAI_KEYSTORE_PASSWD_X);
- String decrypted_keystore_password = Password.deobfuscate(keystore_password);
-
- SSLContextBuilder sslContextB = new SSLContextBuilder();
-
- KeyStore ks = KeyStore.getInstance("PKCS12");
- char[] pwd = decrypted_keystore_password.toCharArray();
-
- try(FileInputStream fin = new FileInputStream(keystore_path)) {
- ks.load(fin, pwd);
- }
- catch (Exception e) {
- logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up keystore");
- logger.error(EELFLoggerDelegate.errorLogger, "Error loading keystore materials: (keystore path: {}, obfuascated keystore password: {})", keystore_path, keystore_password);
- throw new GenericUncheckedException(e);
- }
-
- sslContextB.loadKeyMaterial(ks, pwd);
-
- KeyStore ts = KeyStore.getInstance("JKS");
- char[] pwd1 = decrypted_truststore_password.toCharArray();
-
- try(FileInputStream fin1 = new FileInputStream(truststore_path)) {
- ts.load(fin1, pwd1);
- }
- catch (Exception e) {
- logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up truststore");
- logger.error(EELFLoggerDelegate.errorLogger, "Error loading truststore materials: (truststore path: {}, obfuascated truststore password: {})", truststore_path, truststore_password);
- throw new GenericUncheckedException(e);
- }
-
- sslContextB.loadTrustMaterial(ts);
- sslContextB.loadKeyMaterial(ks, pwd);
- sslContextB.useTLS();
-
- SSLContext sslcontext = sslContextB.build();
-
- SSLConnectionSocketFactory sslFactory = new SSLConnectionSocketFactory(
- sslcontext,
- new String[] { "TLSv1.1", "TLSv1.2" },
- null,
- SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER );
-
- httpclient = HttpClients.custom()
- .setSSLSocketFactory(sslFactory)
- .build();
-
-
- } catch (GeneralSecurityException e) {
- throw new GenericUncheckedException(e);
- }
- return httpclient;
- }
-
-
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/JettyObfuscationConversionCommandLineUtil.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/JettyObfuscationConversionCommandLineUtil.java
index cfc56d1..b39c203 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/util/JettyObfuscationConversionCommandLineUtil.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/JettyObfuscationConversionCommandLineUtil.java
@@ -48,8 +48,8 @@ public class JettyObfuscationConversionCommandLineUtil {
System.out.println(encoded);
} else if (cmd.hasOption("d")) {
toProcess = cmd.getOptionValue("d");
- String decoded_str = Password.deobfuscate(toProcess);
- System.out.println(decoded_str);
+ String decodedStr = Password.deobfuscate(toProcess);
+ System.out.println(decodedStr);
} else {
usage();
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/ServiceInstanceStandardQuery.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/ServiceInstanceStandardQuery.java
new file mode 100644
index 0000000..22743bb
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/ServiceInstanceStandardQuery.java
@@ -0,0 +1,93 @@
+package org.onap.vid.aai.util;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.commons.text.StrSubstitutor;
+import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.*;
+import org.onap.vid.aai.model.interfaces.AaiModelWithRelationships;
+import org.onap.vid.utils.Multival;
+import org.onap.vid.utils.Unchecked;
+
+import javax.inject.Inject;
+import java.net.URI;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+
+import static java.util.stream.Collectors.toSet;
+
+public class ServiceInstanceStandardQuery {
+
+ private static final String SERVICE_INSTANCE_URI_TEMPLATE = "" +
+ "business/customers/customer/${global-customer-id}" +
+ "/service-subscriptions/service-subscription/${service-type}" +
+ "/service-instances/service-instance/${service-instance-id}";
+
+ private final AaiClientInterface aaiClient;
+
+ @Inject
+ public ServiceInstanceStandardQuery(AaiClientInterface aaiClient) {
+ this.aaiClient = aaiClient;
+ }
+
+ public ServiceInstance fetchServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId) {
+ final String serviceInstanceUri = getServiceInstanceUri(globalCustomerId, serviceType, serviceInstanceId);
+
+ return fetchServiceInstance(Unchecked.toURI(serviceInstanceUri));
+ }
+
+ ServiceInstance fetchServiceInstance(URI serviceInstanceUri) {
+ return objectByUri(ServiceInstance.class, serviceInstanceUri);
+ }
+
+ protected <T> T objectByUri(Class<T> clazz, URI aaiResourceUri) {
+ return aaiClient.typedAaiGet(aaiResourceUri, clazz);
+ }
+
+ public Multival<ServiceInstance, Vnf> fetchRelatedVnfs(ServiceInstance serviceInstance) {
+ return fetchRelated("service", serviceInstance, "generic-vnf", Vnf.class);
+ }
+
+ public <K extends AaiModelWithRelationships> Multival<K, Network> fetchRelatedL3Networks(String sourceType, K source) {
+ return fetchRelated(sourceType, source, "l3-network", Network.class);
+ }
+
+ public Multival<Network, Vlan> fetchRelatedVlanTags(Network network) {
+ return fetchRelated("network", network, "vlan-tag", Vlan.class);
+ }
+
+ private String getServiceInstanceUri(String globalCustomerId, String serviceType, String serviceInstanceId) {
+ return new StrSubstitutor(ImmutableMap.of(
+ "global-customer-id", globalCustomerId,
+ "service-type", serviceType,
+ "service-instance-id", serviceInstanceId
+ )).replace(SERVICE_INSTANCE_URI_TEMPLATE);
+ }
+
+ private <K extends AaiModelWithRelationships, V> Multival<K, V> fetchRelated(String sourceType, K source, String destType, Class<V> destClass) {
+ return Multival.of(
+ sourceType,
+ source,
+ destType,
+ fetchRelatedInner(source, destType, destClass)
+ );
+ }
+
+ private <K extends AaiModelWithRelationships, V> Set<V> fetchRelatedInner(K source, String destType, Class<V> destClass) {
+ return getURIsOf(source, relationship -> relatedTo(relationship, destType))
+ .map(destUri -> objectByUri(destClass, destUri))
+ .collect(toSet());
+ }
+
+ protected Stream<URI> getURIsOf(AaiModelWithRelationships aaiModel, Predicate<Relationship> predicate) {
+ return aaiModel.getRelationshipList().getRelationship().stream()
+ .filter(predicate)
+ .map(r -> r.relatedLink)
+ .map(Unchecked::toURI);
+ }
+
+ protected static boolean relatedTo(Relationship r, String relationshipName) {
+ return relationshipName.equals(r.getRelatedTo());
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/SystemPropertyHelper.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/SystemPropertyHelper.java
index 4d43d3b..939bfe5 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/util/SystemPropertyHelper.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/SystemPropertyHelper.java
@@ -23,8 +23,10 @@ package org.onap.vid.aai.util;
import org.eclipse.jetty.util.security.Password;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.aai.exceptions.InvalidPropertyException;
+import org.onap.vid.utils.Unchecked;
import java.io.UnsupportedEncodingException;
+import java.net.URI;
import java.util.Base64;
import java.util.Optional;
@@ -74,6 +76,15 @@ public class SystemPropertyHelper {
return getAAIServerUrl().orElse("") + path;
}
+ public String getFullServicePath(URI requestUri) {
+ // resolve() will merge two paths, handling the restiveness:
+ // Especially if requestUri starts with a '/' -- result will be
+ // AAI_SERVER_URL host, post, etc., and the path will be just
+ // requestUri.
+ return Unchecked.toURI(getAAIServerUrl().orElse(""))
+ .resolve(requestUri).toASCIIString();
+ }
+
public String getServiceBasePath(String path) {
return getAAIServerBaseUrl().orElse("") + path;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
index fdbf2c2..d26a1b2 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
@@ -50,4 +50,5 @@ public interface AsdcClient {
* @throws AsdcCatalogException the asdc catalog exception
*/
Path getServiceToscaModel(UUID uuid) throws AsdcCatalogException;
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/SecureServices.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/SecureServices.java
index a6aa3de..6eaf37b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/SecureServices.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/SecureServices.java
@@ -1,7 +1,6 @@
package org.onap.vid.asdc.beans;
import java.util.Collection;
-import java.util.List;
/**
* Created by Oren on 6/27/17.
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Input.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Input.java
index 5902849..d66591c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Input.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Input.java
@@ -20,10 +20,11 @@
package org.onap.vid.asdc.beans.tosca;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.onap.sdc.toscaparser.api.Property;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
// TODO: Auto-generated Javadoc
/**
@@ -36,6 +37,7 @@ public class Input {
this.description = input.getDescription();
this._default = input.getDefault();
this.inputProperties = new InputProperties(properties);
+ this.fromInputName = input.getName();
}
/** The type. */
@@ -51,7 +53,9 @@ public class Input {
private Input entry_schema;
private InputProperties inputProperties;
-
+
+ private String fromInputName;
+
/** The constraints */
private List<org.onap.sdc.toscaparser.api.elements.constraints.Constraint> constraints;
@@ -63,12 +67,12 @@ public class Input {
private String templateUUID;
private String templateInvariantUUID;
private String templateCustomizationUUID;
-
+
/**
* Instantiates a new input.
*/
public Input() {
- constraints = new ArrayList<org.onap.sdc.toscaparser.api.elements.constraints.Constraint>();
+ constraints = new ArrayList<>();
}
/**
@@ -160,6 +164,11 @@ public class Input {
return inputProperties;
}
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public String getFromInputName() {
+ return fromInputName;
+ }
+
public void setInputProperties(InputProperties inputProperties) {
this.inputProperties = inputProperties;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/InputProperties.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/InputProperties.java
index bc2513e..c5fe8b9 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/InputProperties.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/InputProperties.java
@@ -17,13 +17,10 @@ public class InputProperties {
for(Property property: properties) {
if (property.getName().equals("source_type")) {
this.sourceType = (String)property.getValue();
- continue;
} else if (property.getName().equals("param_name")) {
this.paramName = (String)property.getValue();
- continue;
} else if (property.getName().equals("vf_module_label")) {
this.vfModuleLabel = getPropertyValueAsString(property);
- continue;
}
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/NodeTemplate.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/NodeTemplate.java
index 28210b2..23c0a10 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/NodeTemplate.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/NodeTemplate.java
@@ -20,8 +20,8 @@
package org.onap.vid.asdc.beans.tosca;
-import java.util.Map;
import java.util.HashMap;
+import java.util.Map;
/**
* The Class NodeTemplate.
@@ -41,7 +41,7 @@ public class NodeTemplate {
private Object requirements;
public NodeTemplate () {
- properties = new HashMap<String,Object>();
+ properties = new HashMap<>();
}
/**
* Gets the type.
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Property.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Property.java
index 74b00bd..a15c55f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Property.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Property.java
@@ -43,7 +43,7 @@ public class Property {
/**
* Instantiates a new property.
*/
- Property() {}
+ private Property() {}
/**
* Gets the type.
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/SubstitutionMappings.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/SubstitutionMappings.java
index 70779c5..4ce3023 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/SubstitutionMappings.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/SubstitutionMappings.java
@@ -41,8 +41,8 @@ public class SubstitutionMappings {
* Instantiates a new substitution mappings.
*/
public SubstitutionMappings() {
- capabilities = new HashMap<String, Object> ();
- requirements = new HashMap<String, Object> ();
+ capabilities = new HashMap<> ();
+ requirements = new HashMap<> ();
}
/**
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/TopologyTemplate.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/TopologyTemplate.java
index 7083071..b24627d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/TopologyTemplate.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/TopologyTemplate.java
@@ -45,9 +45,9 @@ public class TopologyTemplate {
*/
public TopologyTemplate() {
substitution_mappings = new SubstitutionMappings();
- inputs = new HashMap<String, Input> ();
- node_templates = new HashMap<String, NodeTemplate> ();
- groups = new HashMap<String, Group> ();
+ inputs = new HashMap<> ();
+ node_templates = new HashMap<> ();
+ groups = new HashMap<> ();
}
/**
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaCsar.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaCsar.java
index 6785835..4cf2f79 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaCsar.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaCsar.java
@@ -43,7 +43,7 @@ public class ToscaCsar {
private final ToscaModel parent;
/** The children. */
- private Collection<ToscaModel> children = new LinkedList<ToscaModel> ();
+ private Collection<ToscaModel> children = new LinkedList<> ();
/**
* Instantiates a new builder.
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaMeta.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaMeta.java
index a7a6c62..ad88340 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaMeta.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaMeta.java
@@ -20,6 +20,8 @@
package org.onap.vid.asdc.beans.tosca;
+import org.onap.vid.asdc.AsdcCatalogException;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -27,8 +29,6 @@ import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
-import org.onap.vid.asdc.AsdcCatalogException;
-
/**
* The Class ToscaMeta.
*/
@@ -45,7 +45,7 @@ public class ToscaMeta {
* @throws AsdcCatalogException the asdc catalog exception
*/
private ToscaMeta(Builder builder) throws IOException, AsdcCatalogException {
- metadata = new HashMap<String, String> ();
+ metadata = new HashMap<> ();
read(builder.inputStream);
}
@@ -113,10 +113,7 @@ public class ToscaMeta {
metadata.put(entry[0], entry[1].substring(1));
}
}
- } catch (IOException e) {
- metadata.clear();
- throw e;
- } catch (AsdcCatalogException e) {
+ } catch (IOException | AsdcCatalogException e) {
metadata.clear();
throw e;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
index 108d9c0..bcb201d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
@@ -1,31 +1,22 @@
package org.onap.vid.asdc.local;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.ObjectMapper;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.JSONArray;
import org.json.JSONObject;
import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.asdc.AsdcClient;
import org.onap.vid.asdc.beans.Service;
-import org.onap.vid.asdc.beans.tosca.ToscaCsar;
-import org.onap.vid.asdc.beans.tosca.ToscaMeta;
-import org.onap.vid.asdc.beans.tosca.ToscaModel;
import org.onap.vid.exceptions.GenericUncheckedException;
-import org.yaml.snakeyaml.Yaml;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
-import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.Map;
import java.util.UUID;
-import java.util.zip.ZipFile;
/**
* The Class LocalAsdcClient.
@@ -117,7 +108,7 @@ public class LocalAsdcClient implements AsdcClient {
/* (non-Javadoc)
* @see org.onap.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)
*/
- public Path getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {
+ public Path getServiceToscaModel(UUID serviceUuid) {
String toscaModelURL = null;
@@ -146,49 +137,6 @@ public class LocalAsdcClient implements AsdcClient {
}
/**
- * Gets the tosca model.
- *
- * @param csarInputStream the csar input stream
- * @return the tosca model
- * @throws AsdcCatalogException the asdc catalog exception
- */
- private ToscaCsar getToscaModel(InputStream csarInputStream) throws AsdcCatalogException {
- final Path csarFile;
-
- try {
- csarFile = Files.createTempFile("csar", ".zip");
- Files.copy(csarInputStream, csarFile, StandardCopyOption.REPLACE_EXISTING);
- } catch (IOException e) {
- throw new AsdcCatalogException("Caught IOException while creating CSAR", e);
- }
-
- try (final ZipFile csar = new ZipFile(csarFile.toFile())) {
-
- final InputStream toscaMetaStream = csar.getInputStream(csar.getEntry("TOSCA-Metadata/TOSCA.meta"));
- final ToscaMeta toscaMeta = new ToscaMeta.Builder(toscaMetaStream).build();
- final String entryDefinitions = toscaMeta.get("Entry-Definitions");
- final InputStream toscaParentEntryYamlStream = csar.getInputStream(csar.getEntry(entryDefinitions));
-
- final Yaml yaml = new Yaml();
- final ToscaModel parentModel = yaml.loadAs(toscaParentEntryYamlStream, ToscaModel.class);
-
- final ToscaCsar.Builder csarBuilder = new ToscaCsar.Builder(parentModel);
-
- for (Map<String, Map<String, String>> imports : parentModel.getImports()) {
- for (Map.Entry<String, Map<String, String>> entry : imports.entrySet()) {
- final InputStream toscaChildEntryYamlStream = csar.getInputStream(csar.getEntry("Definitions/" + entry.getValue().get("file")));
- final ToscaModel childModel = yaml.loadAs(toscaChildEntryYamlStream, ToscaModel.class);
- csarBuilder.addVnf(childModel);
- }
- }
-
- return csarBuilder.build();
- } catch (IOException e) {
- throw new AsdcCatalogException("Caught IOException while processing CSAR", e);
- }
- }
-
- /**
* The Class Builder.
*/
public static class Builder {
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ServiceModelInflator.kt b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ServiceModelInflator.kt
new file mode 100644
index 0000000..79ab045
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ServiceModelInflator.kt
@@ -0,0 +1,43 @@
+package org.onap.vid.asdc.parser
+
+import org.onap.vid.model.*
+import org.springframework.stereotype.Component
+
+@Component
+class ServiceModelInflator {
+
+ data class Names (val modelCustomizationName: String?, val modelKey: String?)
+
+ fun toNamesByVersionId(model: ServiceModel): Map<String, Names> {
+ return emptyMap<String, Names>()
+ .plus(inflate(model.networks))
+ .plus(inflate(model.vnfs))
+ .plus(inflate(model.vnfGroups))
+ }
+
+ private fun inflate(instances: Map<String, *>): Map<String, Names> {
+ return instances.entries.map { inflate(it.key, it.value) }.fold(emptyMap()) { acc, it -> acc.plus(it) }
+ }
+
+ private fun inflate(modelKey: String, vnf: VNF): Map<String, Names> {
+ return mapOf(vnf.uuid to Names(vnf.modelCustomizationName, modelKey))
+ .plus(inflate(vnf.vfModules))
+ .plus(inflate(vnf.volumeGroups))
+ }
+
+ private fun inflate(modelKey: String, instance: Any?): Map<String, Names> {
+ return when (instance) {
+ is Network -> mapOf(instance.uuid to Names(instance.modelCustomizationName, modelKey))
+ is VfModule -> mapOf(instance.uuid to Names(instance.modelCustomizationName, modelKey))
+ is VolumeGroup -> mapOf(instance.uuid to Names(instance.modelCustomizationName, modelKey))
+ is ResourceGroup -> mapOf(instance.uuid to Names(instance.modelCustomizationName, modelKey))
+ is VNF -> inflate(modelKey, instance)
+
+ else -> {
+ // sink
+ emptyMap()
+ }
+ }
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaNamingPolicy.java b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaNamingPolicy.java
new file mode 100644
index 0000000..ca26010
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaNamingPolicy.java
@@ -0,0 +1,28 @@
+package org.onap.vid.asdc.parser;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Property;
+
+import java.util.Map;
+
+public class ToscaNamingPolicy {
+
+ public static String isUserProvidingServiceNameOptional(ISdcCsarHelper csarHelper){
+ return csarHelper.getServiceMetadata().getValue(ToscaParserImpl2.Constants.ECOMP_GENERATED_NAMING);
+ }
+
+ private static Object isPropertyContainsEcompGeneratedNaming(Property property) {
+ return ((Map) (property.getValue())).get(ToscaParserImpl2.Constants.ECOMP_GENERATED_NAMING_PROPERTY);
+ }
+
+ public static String getEcompNamingValueForNode(NodeTemplate node, String parentProperty) {
+ return node.getPropertiesObjects().stream()
+ .filter(property -> StringUtils.equals(property.getName(), parentProperty))
+ .findFirst()
+ .map(ToscaNamingPolicy::isPropertyContainsEcompGeneratedNaming)
+ .map(Object::toString)
+ .orElse("false");
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl.java b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl.java
index 27445c0..ef57ccb 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl.java
@@ -16,6 +16,7 @@ import org.yaml.snakeyaml.error.YAMLException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -92,7 +93,7 @@ public class ToscaParserImpl implements ToscaParser {
final ToscaModel asdcServiceToscaModel = toscaCsar.getParent();
serviceModel.setService(ServiceModel.extractService(asdcServiceToscaModel, service));
-
+ serviceModel.setFabricConfigurations(Collections.emptyMap());
populateVnfsAndNetwork(methodName, isNewFlow, vnfs, networks, asdcServiceToscaModel, serviceModel);
@@ -180,8 +181,6 @@ public class ToscaParserImpl implements ToscaParser {
}
private ServiceModel getCustomizedServices(ToscaModel asdcServiceToscaModel, ServiceModel serviceModel) {
- String methodName = "asdcServiceToscaModel";
-
// asdcServiceToscaModel should have vf modules and vol groups populated
// at this point but
// they are not associated with the VNFs
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java
index 57d80ce..53ec403 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java
@@ -1,11 +1,12 @@
package org.onap.vid.asdc.parser;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.enums.FilterType;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
-import org.onap.sdc.tosca.parser.impl.FilterType;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
-import org.onap.sdc.tosca.parser.impl.SdcTypes;
import org.onap.sdc.toscaparser.api.Group;
import org.onap.sdc.toscaparser.api.*;
import org.onap.sdc.toscaparser.api.elements.Metadata;
@@ -15,87 +16,112 @@ import org.onap.vid.model.*;
import java.nio.file.Path;
import java.util.*;
-import java.util.stream.Collectors;
+import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static org.onap.vid.asdc.parser.ToscaParserImpl2.Constants.VF_MODULE_LABEL;
public class ToscaParserImpl2 {
-
- public class Constants {
- public final static String UUID = "UUID";
- public final static String DESCRIPTION = "description";
- public final static String SERVICE_TYPE = "serviceType";
- public final static String SERVICE_ROLE = "serviceRole";
- public final static String ECOMP_GENERATED_NAMING = "ecompGeneratedNaming";
-
- public final static String CUSTOMIZATION_UUID = "customizationUUID";
- public final static String VF_MODULE_MODEL_VERSION = "vfModuleModelVersion";
- public final static String VF_MODULE_MODEL_CUSTOMIZATION_UUID = "vfModuleModelCustomizationUUID";
- public final static String VOLUME_GROUP = "volume_group";
- public final static String VF_MODULE_MODEL_INVARIANT_UUID = "vfModuleModelInvariantUUID";
- public final static String VF_MODULE_MODEL_UUID = "vfModuleModelUUID";
- public final static String INVARIANT_UUID = "invariantUUID";
- public final static String VERSION = "version";
- public final static String NAME = "name";
- public final static String CATEGORY = "category";
- public final static String VF_MODULE_MODEL_NAME = "vfModuleModelName";
- public final static String GET_INPUT = "get_input";
- public final static String TYPE = "type";
-
- public final static String INSTANTIATION_TYPE = "instantiationType";
+
+ private final VidNotionsBuilder vidNotionsBuilder;
+
+ public class Constants {
+ public static final String UUID = "UUID";
+ public static final String DESCRIPTION = "description";
+ public static final String SERVICE_TYPE = "serviceType";
+ public static final String SERVICE_ROLE = "serviceRole";
+ public static final String ECOMP_GENERATED_NAMING = "ecompGeneratedNaming";
+
+ public static final String CUSTOMIZATION_UUID = "customizationUUID";
+ public static final String VF_MODULE_MODEL_VERSION = "vfModuleModelVersion";
+ public static final String VF_MODULE_MODEL_CUSTOMIZATION_UUID = "vfModuleModelCustomizationUUID";
+ public static final String VOLUME_GROUP = "volume_group";
+ public static final String VF_MODULE_MODEL_INVARIANT_UUID = "vfModuleModelInvariantUUID";
+ public static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUID";
+ public static final String INVARIANT_UUID = "invariantUUID";
+ public static final String VERSION = "version";
+ public static final String NAME = "name";
+ public static final String CATEGORY = "category";
+ public static final String VF_MODULE_MODEL_NAME = "vfModuleModelName";
+ public static final String GET_INPUT = "get_input";
+ public static final String TYPE = "type";
+
+ public static final String INSTANTIATION_TYPE = "instantiationType";
//instantiation type
- public final static String BOTH = "Both";
- public final static String MACRO = "Macro";
- public final static String A_LA_CARTE = "A-La-Carte";
- public final static String CLIENT_CONFIG = "ClientConfig";
+ public static final String BOTH = "Both";
+ public static final String MACRO = "Macro";
+ public static final String A_LA_CARTE = "A-La-Carte";
+ public static final String CLIENT_CONFIG = "ClientConfig";
+
+ //service role
+ public static final String GROUPING = "GROUPING";
//group properties
- public final static String MIN_VF_MODULE_INSTANCES = "min_vf_module_instances";
- public final static String MAX_VF_MODULE_INSTANCES = "max_vf_module_instances";
- public final static String INITIAL_COUNT = "initial_count";
- public final static String VF_MODULE_LABEL = "vf_module_label";
+ public static final String MIN_VF_MODULE_INSTANCES = "min_vf_module_instances";
+ public static final String MAX_VF_MODULE_INSTANCES = "max_vf_module_instances";
+ public static final String INITIAL_COUNT = "initial_count";
+ public static final String VF_MODULE_LABEL = "vf_module_label";
+ public static final String VF_MODULE_TYPE = "vf_module_type";
//collection resource properties
- public final static String SUBCATEGORY = "subcategory";
- public final static String RESOURCE_VENDOR = "resourceVendor";
- public final static String RESOURCE_VENDOR_RELEASE = "resourceVendorRelease";
- public final static String RESOURCE_VENDOR_MODEL_NUMBER = "resourceVendorModelNumber";
- public final static String ORG_OPENECOMP_GROUPS_NETWORK_COLLECTION = "org.openecomp.groups.NetworkCollection";
- public final static String NETWORK_COLLECTION_FUNCTION = "network_collection_function";
- public final static String NETWORK_COLLECTION_DESCRIPTION = "network_collection_description";
+ public static final String SUBCATEGORY = "subcategory";
+ public static final String RESOURCE_VENDOR = "resourceVendor";
+ public static final String RESOURCE_VENDOR_RELEASE = "resourceVendorRelease";
+ public static final String RESOURCE_VENDOR_MODEL_NUMBER = "resourceVendorModelNumber";
+ public static final String ORG_OPENECOMP_GROUPS_NETWORK_COLLECTION = "org.openecomp.groups.NetworkCollection";
+ public static final String NETWORK_COLLECTION_FUNCTION = "network_collection_function";
+ public static final String NETWORK_COLLECTION_DESCRIPTION = "network_collection_description";
//vfc instance group properties
- public final static String VFC_INSTANCE_GROUP_TYPE = "org.openecomp.groups.VfcInstanceGroup";
- public final static String VFC_PARENT_PORT_ROLE = "vfc_parent_port_role";
- public final static String SUBINTERFACE_ROLE = "subinterface_role";
- public final static String VFC_INSTANCE_GROUP_FUNCTION = "vfc_instance_group_function";
+ public static final String VFC_INSTANCE_GROUP_TYPE = "org.openecomp.groups.VfcInstanceGroup";
+ public static final String VFC_PARENT_PORT_ROLE = "vfc_parent_port_role";
+ public static final String SUBINTERFACE_ROLE = "subinterface_role";
+ public static final String VFC_INSTANCE_GROUP_FUNCTION = "vfc_instance_group_function";
+
+ public static final String FABRIC_CONFIGURATION_TYPE = "org.openecomp.nodes.FabricConfiguration";
+
+ public static final String RESOURCE_GROUP_TYPE = "org.openecomp.groups.ResourceInstanceGroup";
+ public static final String RESOURCE_GROUP_CONTAINED_TYPE = "contained_resource_type";
+
+ public static final String VNF_GROUP = "VnfGroup";
+
+ public static final String NAMING_POLICY_TYPE = "org.openecomp.policies.External";
+
+ public static final String ECOMP_GENERATED_NAMING_PROPERTY = "ecomp_generated_naming";
}
-
- public ToscaParserImpl2() {}
- public ServiceModel makeServiceModel(Path path, Service asdcServiceMetadata) throws SdcToscaParserException {
+ public ToscaParserImpl2(VidNotionsBuilder vidNotionsBuilder) {
+ this.vidNotionsBuilder = vidNotionsBuilder;
+ }
+
+ public ServiceModel makeServiceModel(Path path, Service asdcServiceMetadata) throws SdcToscaParserException {
ServiceModel serviceModel = new ServiceModel();
- SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
- ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(path.toFile().getAbsolutePath(),false);
+ ISdcCsarHelper sdcCsarHelper = getSdcCsarHelper(path);
+ List<String> policiesTargets = extractNamingPoliciesTargets(sdcCsarHelper);
serviceModel.setService(extractServiceFromCsar(asdcServiceMetadata, sdcCsarHelper));
serviceModel.setVolumeGroups(extractVolumeGroups(sdcCsarHelper));
serviceModel.setVfModules(extractVfModuleFromCsar(sdcCsarHelper));
- serviceModel.setVnfs(extractVnfsFromCsar(sdcCsarHelper));
- serviceModel.setConfigurations(extractPortMirroringConfigFromCsar(sdcCsarHelper));
- serviceModel.setServiceProxies(extractServiceProxyFromCsar(sdcCsarHelper));
- serviceModel.setNetworks(extractNetworksFromCsar(sdcCsarHelper));
- serviceModel.setPnfs(extractPnfsFromCsar(sdcCsarHelper));
- serviceModel.setCollectionResource(extractCRFromCsar(sdcCsarHelper));
+ serviceModel.setVnfs(extractVnfsFromCsar(sdcCsarHelper, policiesTargets));
+ serviceModel.setConfigurations(extractPortMirroringConfigFromCsar(sdcCsarHelper, policiesTargets));
+ serviceModel.setServiceProxies(extractServiceProxyFromCsar(sdcCsarHelper, policiesTargets));
+ serviceModel.setNetworks(extractNetworksFromCsar(sdcCsarHelper, policiesTargets));
+ serviceModel.setPnfs(extractPnfsFromCsar(sdcCsarHelper, policiesTargets));
+ serviceModel.setCollectionResource(extractCRFromCsar(sdcCsarHelper, policiesTargets));
+ serviceModel.setFabricConfigurations(extractFabricConfigFromCsar(sdcCsarHelper, policiesTargets));
+ serviceModel.setVnfGroups(extractVnfGroupsFromCsar(sdcCsarHelper, policiesTargets));
+ serviceModel.getService().setVidNotions(vidNotionsBuilder.buildVidNotions(sdcCsarHelper, serviceModel));
return serviceModel;
}
+ public ISdcCsarHelper getSdcCsarHelper(Path path) throws SdcToscaParserException {
+ SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
+ return factory.getSdcCsarHelper(path.toFile().getAbsolutePath(), false);
+ }
-
- private org.onap.vid.model.Service extractServiceFromCsar(Service asdcServiceMetadata, ISdcCsarHelper csarHelper) throws SdcToscaParserException {
- org.onap.vid.model.Service service = new org.onap.vid.model.Service();
+ private org.onap.vid.model.Service extractServiceFromCsar(Service asdcServiceMetadata, ISdcCsarHelper csarHelper) {
+ org.onap.vid.model.Service service = new org.onap.vid.model.Service();
service.setName(csarHelper.getServiceMetadata().getValue(Constants.NAME));
service.setCategory(csarHelper.getServiceMetadata().getValue(Constants.CATEGORY));
@@ -104,21 +130,25 @@ public class ToscaParserImpl2 {
service.setVersion(asdcServiceMetadata.getVersion());
service.setDescription(csarHelper.getServiceMetadata().getValue(Constants.DESCRIPTION));
service.setInputs(inputsListToInputsMap(csarHelper.getInputsWithAnnotations()));
- service.setServiceEcompNaming(csarHelper.getServiceMetadata().getValue(Constants.ECOMP_GENERATED_NAMING));
+ service.setServiceEcompNaming(isUserProvidingServiceNameOptional(csarHelper));
service.setServiceType(csarHelper.getServiceMetadata().getValue(Constants.SERVICE_TYPE));
service.setServiceRole(csarHelper.getServiceMetadata().getValue(Constants.SERVICE_ROLE));
service.setInstantiationType(validateInstantiationType(csarHelper));
return service;
}
- private Map<String,CR> extractCRFromCsar(ISdcCsarHelper sdcCsarHelper) {
- List<NodeTemplate> nodeTemplates = sdcCsarHelper.getServiceNodeTemplates();
- Map<String, CR> collectionResourceMap = new HashMap<>();
+ private String isUserProvidingServiceNameOptional(ISdcCsarHelper csarHelper) {
+ return ToscaNamingPolicy.isUserProvidingServiceNameOptional(csarHelper);
+ }
+
+ private Map<String, CR> extractCRFromCsar(ISdcCsarHelper sdcCsarHelper, List<String> policiesTargets) {
+ List<NodeTemplate> nodeTemplates = sdcCsarHelper.getServiceNodeTemplates();
+ Map<String, CR> collectionResourceMap = new HashMap<>();
- for(NodeTemplate nodeTemplate: nodeTemplates){
- if(nodeTemplate.getMetaData().getValue(Constants.TYPE).equals(SdcTypes.CR.getValue())) {
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ if ( nodeTemplate.getMetaData().getValue(Constants.TYPE).equals(SdcTypes.CR.getValue()) ) {
CR cr = new CR();
- populateCrFromNodeTemplate(nodeTemplate, sdcCsarHelper, cr);
+ populateCrFromNodeTemplate(nodeTemplate, sdcCsarHelper, cr, policiesTargets);
collectionResourceMap.put(nodeTemplate.getName(), cr);
}
}
@@ -126,21 +156,39 @@ public class ToscaParserImpl2 {
return collectionResourceMap;
}
- private void populateCrFromNodeTemplate(NodeTemplate nodeTemplate, ISdcCsarHelper sdcCsarHelper, CR cr) {
- populateNodeFromNodeTemplate(nodeTemplate, sdcCsarHelper, cr);
+ private Map<String, Node> extractFabricConfigFromCsar(ISdcCsarHelper sdcCsarHelper, List<String> policiesTargets) {
+ List<NodeTemplate> nodeTemplates = sdcCsarHelper.getServiceNodeTemplates();
+ Map<String, Node> fabricConfiguration = new HashMap<>();
+
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ List<NodeTemplate> nodeTemplateChildren = sdcCsarHelper.getNodeTemplateChildren(nodeTemplate);
+ for (NodeTemplate nodeTemplateChild : nodeTemplateChildren) {
+ if ( nodeTemplateChild.getType().equals(Constants.FABRIC_CONFIGURATION_TYPE) ) {
+ Node node = new Node();
+ fabricConfiguration.put(nodeTemplateChild.getName(), populateNodeFromNodeTemplate(nodeTemplateChild, sdcCsarHelper, node, policiesTargets));
+ }
+ }
+
+ }
+ return fabricConfiguration;
+ }
+
+
+ private void populateCrFromNodeTemplate(NodeTemplate nodeTemplate, ISdcCsarHelper sdcCsarHelper, CR cr, List<String> policiesTargets) {
+ populateNodeFromNodeTemplate(nodeTemplate, sdcCsarHelper, cr, policiesTargets);
cr.setCustomizationUUID(nodeTemplate.getMetaData().getValue(Constants.CUSTOMIZATION_UUID));
cr.setCategory(nodeTemplate.getMetaData().getValue(Constants.CATEGORY));
- cr.setSubcategory(nodeTemplate.getMetaData().getValue(Constants.SUBCATEGORY));
- cr.setResourceVendor(nodeTemplate.getMetaData().getValue(Constants.RESOURCE_VENDOR));
- cr.setResourceVendorRelease(nodeTemplate.getMetaData().getValue(Constants.RESOURCE_VENDOR_RELEASE));
- cr.setResourceVendorModelNumber(nodeTemplate.getMetaData().getValue(Constants.RESOURCE_VENDOR_MODEL_NUMBER));
- cr.setNetworksCollection(getNetworksCollectionMapFromGroupsList(sdcCsarHelper, nodeTemplate));
+ cr.setSubcategory(nodeTemplate.getMetaData().getValue(Constants.SUBCATEGORY));
+ cr.setResourceVendor(nodeTemplate.getMetaData().getValue(Constants.RESOURCE_VENDOR));
+ cr.setResourceVendorRelease(nodeTemplate.getMetaData().getValue(Constants.RESOURCE_VENDOR_RELEASE));
+ cr.setResourceVendorModelNumber(nodeTemplate.getMetaData().getValue(Constants.RESOURCE_VENDOR_MODEL_NUMBER));
+ cr.setNetworksCollection(getNetworksCollectionMapFromGroupsList(sdcCsarHelper, nodeTemplate));
}
private Map<String, NetworkCollection> getNetworksCollectionMapFromGroupsList(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate) {
List<Group> groups = sdcCsarHelper.getGroupsOfOriginOfNodeTemplateByToscaGroupType(nodeTemplate, Constants.ORG_OPENECOMP_GROUPS_NETWORK_COLLECTION);
- Map<String, NetworkCollection> networksCollectionMap = new HashMap<String, NetworkCollection>();
- for(Group group: groups){
+ Map<String, NetworkCollection> networksCollectionMap = new HashMap<>();
+ for (Group group : groups) {
networksCollectionMap.put(group.getName(), populateCollectionNetworkFromGroup(group, nodeTemplate));
}
return networksCollectionMap;
@@ -161,44 +209,46 @@ public class ToscaParserImpl2 {
LinkedHashMap<String, Property> properties = group.getProperties();
Map<String, Property> nodeTemplateProperties = nodeTemplate.getProperties();
- String networkCollectionFunction = (String)((Map)(properties.get(Constants.NETWORK_COLLECTION_FUNCTION).getValue())).get(Constants.GET_INPUT);
- String networkCollectionDescription = (String)((Map)(properties.get(Constants.NETWORK_COLLECTION_DESCRIPTION).getValue())).get(Constants.GET_INPUT);
+ String networkCollectionFunction = (String) ((Map) (properties.get(Constants.NETWORK_COLLECTION_FUNCTION).getValue())).get(Constants.GET_INPUT);
+ String networkCollectionDescription = (String) ((Map) (properties.get(Constants.NETWORK_COLLECTION_DESCRIPTION).getValue())).get(Constants.GET_INPUT);
- networkCollection.getNetworkCollectionProperties().setNetworkCollectionDescription((String)nodeTemplateProperties.get(networkCollectionDescription).getValue());
- networkCollection.getNetworkCollectionProperties().setNetworkCollectionFunction((String)nodeTemplateProperties.get(networkCollectionFunction).getValue());
+ networkCollection.getNetworkCollectionProperties().setNetworkCollectionDescription((String) nodeTemplateProperties.get(networkCollectionDescription).getValue());
+ networkCollection.getNetworkCollectionProperties().setNetworkCollectionFunction((String) nodeTemplateProperties.get(networkCollectionFunction).getValue());
}
- private Map<String, VNF> extractVnfsFromCsar(ISdcCsarHelper csarHelper) {
+ private Map<String, VNF> extractVnfsFromCsar(ISdcCsarHelper csarHelper, List<String> policiesTargets) {
List<NodeTemplate> nodeTemplates = csarHelper.getServiceVfList();
- Map<String, VNF> vnfsMaps = new HashMap<String, VNF>();
+ Map<String, VNF> vnfsMaps = new HashMap<>();
for (NodeTemplate nodeTemplate : nodeTemplates) {
VNF vnf = new VNF();
- populateNodeFromNodeTemplate(nodeTemplate, csarHelper, vnf);
+ populateNodeFromNodeTemplate(nodeTemplate, csarHelper, vnf, policiesTargets);
vnf.setModelCustomizationName(nodeTemplate.getName());
vnf.setVfModules(getVfModulesFromVF(csarHelper, vnf.getCustomizationUuid()));
vnf.setVolumeGroups(getVolumeGroupsFromVF(csarHelper, vnf.getCustomizationUuid()));
vnf.setVfcInstanceGroups(getVfcInstanceGroup(csarHelper, nodeTemplate));
-
+ if (ToscaNamingPolicy.getEcompNamingValueForNode(nodeTemplate, "nf_naming").equals("true")) {
+ setEcompNamingProperty(vnf.getProperties(), "true");
+ }
vnfsMaps.put(nodeTemplate.getName(), vnf);
}
return vnfsMaps;
}
- private Map<String,VfcInstanceGroup> getVfcInstanceGroup(ISdcCsarHelper csarHelper, NodeTemplate nodeTemplate) {
- List<Group> vfcList = csarHelper.getGroupsOfOriginOfNodeTemplateByToscaGroupType(nodeTemplate, Constants.VFC_INSTANCE_GROUP_TYPE);
+ private Map<String, VfcInstanceGroup> getVfcInstanceGroup(ISdcCsarHelper csarHelper, NodeTemplate nodeTemplate) {
+ List<Group> vfcList = csarHelper.getGroupsOfOriginOfNodeTemplateByToscaGroupType(nodeTemplate, Constants.VFC_INSTANCE_GROUP_TYPE);
return vfcList.stream()
- .collect(toMap(Group::getName, group -> populateVfcInstanceGroupFromGroup(group, csarHelper, nodeTemplate)));
+ .collect(toMap(Group::getName, group -> populateVfcInstanceGroupFromGroup(group, nodeTemplate)));
}
- private VfcInstanceGroup populateVfcInstanceGroupFromGroup(Group group, ISdcCsarHelper csarHelper, NodeTemplate nodeTemplate) {
- VfcInstanceGroup vfcInstanceGroup = new VfcInstanceGroup();
- vfcInstanceGroup.setUuid(group.getMetadata().getValue(Constants.UUID));
- vfcInstanceGroup.setInvariantUuid(group.getMetadata().getValue(Constants.INVARIANT_UUID));
- vfcInstanceGroup.setVersion(group.getMetadata().getValue(Constants.VERSION));
- vfcInstanceGroup.setName(group.getMetadata().getValue(Constants.NAME));
- vfcInstanceGroup.setVfcInstanceGroupProperties(getVfcPropertiesFromGroup(nodeTemplate, group));
+ private VfcInstanceGroup populateVfcInstanceGroupFromGroup(Group group, NodeTemplate nodeTemplate) {
+ VfcInstanceGroup vfcInstanceGroup = new VfcInstanceGroup();
+ vfcInstanceGroup.setUuid(group.getMetadata().getValue(Constants.UUID));
+ vfcInstanceGroup.setInvariantUuid(group.getMetadata().getValue(Constants.INVARIANT_UUID));
+ vfcInstanceGroup.setVersion(group.getMetadata().getValue(Constants.VERSION));
+ vfcInstanceGroup.setName(group.getMetadata().getValue(Constants.NAME));
+ vfcInstanceGroup.setVfcInstanceGroupProperties(getVfcPropertiesFromGroup(nodeTemplate, group));
return vfcInstanceGroup;
@@ -209,24 +259,24 @@ public class ToscaParserImpl2 {
vfcInstanceGroupProperties.setVfcParentPortRole((String) group.getProperties().get(Constants.VFC_PARENT_PORT_ROLE).getValue());
vfcInstanceGroupProperties.setSubinterfaceRole((String) group.getProperties().get(Constants.SUBINTERFACE_ROLE).getValue());
- String networkCollectionFunction = (String)((Map)(group.getProperties().get(Constants.NETWORK_COLLECTION_FUNCTION).getValue())).get(Constants.GET_INPUT);
- String vfcInstanceGroupFunction = (String)((Map)(group.getProperties().get(Constants.VFC_INSTANCE_GROUP_FUNCTION).getValue())).get(Constants.GET_INPUT);
+ String networkCollectionFunction = (String) ((Map) (group.getProperties().get(Constants.NETWORK_COLLECTION_FUNCTION).getValue())).get(Constants.GET_INPUT);
+ String vfcInstanceGroupFunction = (String) ((Map) (group.getProperties().get(Constants.VFC_INSTANCE_GROUP_FUNCTION).getValue())).get(Constants.GET_INPUT);
- if(nodeTemplate.getProperties().get(networkCollectionFunction) != null)
+ if ( nodeTemplate.getProperties().get(networkCollectionFunction) != null )
vfcInstanceGroupProperties.setNetworkCollectionFunction((String) nodeTemplate.getProperties().get(networkCollectionFunction).getValue());
- if(nodeTemplate.getProperties().get(vfcInstanceGroupFunction) != null)
+ if ( nodeTemplate.getProperties().get(vfcInstanceGroupFunction) != null )
vfcInstanceGroupProperties.setVfcInstanceGroupFunction((String) nodeTemplate.getProperties().get(vfcInstanceGroupFunction).getValue());
return vfcInstanceGroupProperties;
}
- private Map<String, PortMirroringConfig> extractPortMirroringConfigFromCsar(ISdcCsarHelper csarHelper) {
- List<NodeTemplate> nodeTemplates = csarHelper.getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
+ private Map<String, PortMirroringConfig> extractPortMirroringConfigFromCsar(ISdcCsarHelper csarHelper, List<String> policiesTargets) {
+ List<NodeTemplate> nodeTemplates = csarHelper.getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);//TODO change to
Map<String, PortMirroringConfig> configMaps = new HashMap<>();
for (NodeTemplate nodeTemplate : nodeTemplates) {
PortMirroringConfig pmConfig = new PortMirroringConfig();
- populateNodeFromNodeTemplate(nodeTemplate, csarHelper, pmConfig);
+ populateNodeFromNodeTemplate(nodeTemplate, csarHelper, pmConfig, policiesTargets);
pmConfig.setModelCustomizationName(nodeTemplate.getName());
pmConfig.setRequirementAssignments(nodeTemplate.getRequirements());
@@ -236,38 +286,38 @@ public class ToscaParserImpl2 {
}
return configMaps;
- }
+ }
- private Map<String, ServiceProxy> extractServiceProxyFromCsar(ISdcCsarHelper csarHelper) {
+ private Map<String, ServiceProxy> extractServiceProxyFromCsar(ISdcCsarHelper csarHelper, List<String> policiesTargets) {
List<NodeTemplate> nodeTemplates = csarHelper.getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
- Map<String, ServiceProxy> serviceProxies = new HashMap<>();
- for (NodeTemplate nodeTemplate: nodeTemplates) {
- ServiceProxy serviceProxy = new ServiceProxy();
- populateNodeFromNodeTemplate(nodeTemplate, csarHelper, serviceProxy);
+ return nodeTemplates.stream()
+ .collect(toMap(NodeTemplate::getName, node -> getServiceProxyFromNodeTemplate(node, csarHelper, policiesTargets)));
+ }
- Map<String, String> metadata = nodeTemplate.getMetaData().getAllProperties();
- serviceProxy.setSourceModelUuid(metadata.get("sourceModelUuid"));
- serviceProxy.setSourceModelInvariant(metadata.get("sourceModelInvariant"));
- serviceProxy.setSourceModelName(metadata.get("sourceModelName"));
+ private ServiceProxy getServiceProxyFromNodeTemplate(NodeTemplate nodeTemplate, ISdcCsarHelper csarHelper, List<String> policiesTargets) {
+ ServiceProxy serviceProxy = new ServiceProxy();
+ populateNodeFromNodeTemplate(nodeTemplate, csarHelper, serviceProxy, policiesTargets);
- serviceProxies.put(nodeTemplate.getName(), serviceProxy);
- }
+ Map<String, String> metadata = nodeTemplate.getMetaData().getAllProperties();
+ serviceProxy.setSourceModelUuid(metadata.get("sourceModelUuid"));
+ serviceProxy.setSourceModelInvariant(metadata.get("sourceModelInvariant"));
+ serviceProxy.setSourceModelName(metadata.get("sourceModelName"));
- return serviceProxies;
+ return serviceProxy;
}
- private void setSourceAndCollectorProxyNodes(ISdcCsarHelper csarHelper, PortMirroringConfig portMirroringConfig, NodeTemplate nodeTemplate) {
- RequirementAssignments requirementAssignments = nodeTemplate.getRequirements();
+ private void setSourceAndCollectorProxyNodes(ISdcCsarHelper csarHelper, PortMirroringConfig portMirroringConfig, NodeTemplate nodeTemplate) {
+ RequirementAssignments requirementAssignments = nodeTemplate.getRequirements();
List<String> sourceNodes = getRequirementsNodesNames(requirementAssignments.getRequirementsByName("source").getAll());
portMirroringConfig.setSourceNodes(sourceNodes);
List<String> collectorNodes = getRequirementsNodesNames(requirementAssignments.getRequirementsByName("collector").getAll());
- if (!collectorNodes.isEmpty()) { // vprobe
+ if ( !collectorNodes.isEmpty() ) { // vprobe
portMirroringConfig.setCollectorNodes(collectorNodes);
} else { // pprobe - configuration by policy
String collectorNodeName = csarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "collector_node");
- if (collectorNodeName != null) {
+ if ( collectorNodeName != null ) {
portMirroringConfig.setCollectorNodes(Arrays.asList(collectorNodeName));
portMirroringConfig.setConfigurationByPolicy(true);
}
@@ -277,8 +327,8 @@ public class ToscaParserImpl2 {
private List<String> getRequirementsNodesNames(List<RequirementAssignment> requirements) {
List<String> requirementsNodes = new ArrayList<>();
- if (requirements != null && requirements.size() > 0) {
- requirementsNodes = requirements.stream().map(RequirementAssignment::getNodeTemplateName).collect(Collectors.toList());
+ if ( !CollectionUtils.isEmpty(requirements) ) {
+ requirementsNodes = requirements.stream().map(RequirementAssignment::getNodeTemplateName).collect(toList());
}
return requirementsNodes;
@@ -301,26 +351,29 @@ public class ToscaParserImpl2 {
return Boolean.valueOf(group.getPropertyValue(Constants.VOLUME_GROUP).toString());
}
- private Map<String, Network> extractNetworksFromCsar(ISdcCsarHelper csarHelper) {
+ private Map<String, Network> extractNetworksFromCsar(ISdcCsarHelper csarHelper, List<String> policiesTargets) {
List<NodeTemplate> nodeTemplates = csarHelper.getServiceVlList();
- Map<String, Network> networksMap = new HashMap<String, Network>();
+ Map<String, Network> networksMap = new HashMap<>();
for (NodeTemplate nodeTemplate : nodeTemplates) {
Network newNetwork = new Network();
- populateNodeFromNodeTemplate(nodeTemplate, csarHelper, newNetwork);
+ populateNodeFromNodeTemplate(nodeTemplate, csarHelper, newNetwork, policiesTargets);
newNetwork.setModelCustomizationName(nodeTemplate.getName());
+ if (ToscaNamingPolicy.getEcompNamingValueForNode(nodeTemplate, "exVL_naming").equals("true")) {
+ setEcompNamingProperty(newNetwork.getProperties(), "true");
+ }
networksMap.put(nodeTemplate.getName(), newNetwork);
}
return networksMap;
- }
+ }
- private Map<String,Node> extractPnfsFromCsar(ISdcCsarHelper csarHelper) {
+ private Map<String, Node> extractPnfsFromCsar(ISdcCsarHelper csarHelper, List<String> policiesTargets) {
List<NodeTemplate> nodeTemplates = csarHelper.getServiceNodeTemplateBySdcType(SdcTypes.PNF);
HashMap<String, Node> pnfHashMap = new HashMap<>();
for (NodeTemplate nodeTemplate : nodeTemplates) {
Node pnf = new Node();
- populateNodeFromNodeTemplate(nodeTemplate, csarHelper, pnf);
+ populateNodeFromNodeTemplate(nodeTemplate, csarHelper, pnf, policiesTargets);
pnfHashMap.put(nodeTemplate.getName(), pnf);
}
return pnfHashMap;
@@ -352,13 +405,13 @@ public class ToscaParserImpl2 {
Map<String, org.onap.vid.asdc.beans.tosca.Input> inputs = new HashMap<>();
for (org.onap.sdc.toscaparser.api.parameters.Input input : inputList) {
//Set only inputs without annotation to the service level
- if(input.getAnnotations() == null)
+ if ( input.getAnnotations() == null )
inputs.put(input.getName(), convertInput(input, new org.onap.vid.asdc.beans.tosca.Input(), null));
}
return inputs;
}
- private Node populateNodeFromNodeTemplate(NodeTemplate nodeTemplate, ISdcCsarHelper csarHelper, Node newNode) {
+ private Node populateNodeFromNodeTemplate(NodeTemplate nodeTemplate, ISdcCsarHelper csarHelper, Node newNode, List<String> policiesTargets) {
newNode.setCustomizationUuid(csarHelper.getNodeTemplateCustomizationUuid(nodeTemplate));
newNode.setDescription(nodeTemplate.getMetaData().getValue(Constants.DESCRIPTION));
newNode.setInvariantUuid(nodeTemplate.getMetaData().getValue(Constants.INVARIANT_UUID));
@@ -367,19 +420,21 @@ public class ToscaParserImpl2 {
newNode.setVersion(nodeTemplate.getMetaData().getValue(Constants.VERSION));
newNode.setInputs(extractInputsAndCommandsForNodeTemplate(nodeTemplate, csarHelper, newNode));
newNode.setType(nodeTemplate.getMetaData().getValue(Constants.TYPE));
- Map<String, String> propertiesMap = setPropertiesOfVnf(nodeTemplate.getPropertiesObjects());
+ Map<String, String> propertiesMap = nodeTemplate.getPropertiesObjects().stream()
+ .collect(toMap(Property::getName, p -> p.getValue().toString()));
+ setEcompNamingProperty(propertiesMap, String.valueOf(policiesTargets.contains(nodeTemplate.getName())));
newNode.setProperties(propertiesMap);
return newNode;
}
- private VfModule populateVfModuleFromGroup(Group group, ISdcCsarHelper csarHelper){
+ private VfModule populateVfModuleFromGroup(Group group, ISdcCsarHelper csarHelper) {
VfModule vfModule = new VfModule();
extractBasicPropertiesForGroup(vfModule, group, csarHelper);
vfModule.setVolumeGroupAllowed(isVolumeGroup(group));
return vfModule;
}
- private VolumeGroup populateVolumeGroupFromGroup(Group group, ISdcCsarHelper csarHelper){
+ private VolumeGroup populateVolumeGroupFromGroup(Group group, ISdcCsarHelper csarHelper) {
VolumeGroup volumeGroup = new VolumeGroup();
extractBasicPropertiesForGroup(volumeGroup, group, csarHelper);
return volumeGroup;
@@ -398,30 +453,39 @@ public class ToscaParserImpl2 {
}
- private Map<String,org.onap.vid.asdc.beans.tosca.Input> extractVfInputsFromCsarByAnnotation(ISdcCsarHelper csarHelper, org.onap.vid.model.Group group) {
+ private Map<String, org.onap.vid.asdc.beans.tosca.Input> extractVfInputsFromCsarByAnnotation(ISdcCsarHelper csarHelper, org.onap.vid.model.Group group) {
Map<String, org.onap.vid.asdc.beans.tosca.Input> inputMap = new HashMap<>();
- if(group.getProperties().getVfModuleLabel() != null){
+ if ( group.getProperties().getVfModuleLabel() != null ) {
List<Input> inputsList = csarHelper.getInputsWithAnnotations();
- for(Input input: inputsList){
- if(input.getAnnotations() != null){
- List<Property> annotationProperties = input.getAnnotations().get("source").getProperties();
- if(isInputMatchesToGroup(annotationProperties, group)){
- inputMap.put(input.getName(), new org.onap.vid.asdc.beans.tosca.Input(input ,annotationProperties));
- }
- }
+ for (Input input : inputsList) {
+ extractVfModuleInput(group, inputMap, input);
}
}
return inputMap;
}
+ private void extractVfModuleInput(org.onap.vid.model.Group group, Map<String, org.onap.vid.asdc.beans.tosca.Input> inputMap, Input input) {
+ if ( input.getAnnotations() != null ) {
+ List<Property> annotationProperties = input.getAnnotations().get("source").getProperties();
+ if ( isInputMatchesToGroup(annotationProperties, group) ) {
+ final org.onap.vid.asdc.beans.tosca.Input vfModuleInput = new org.onap.vid.asdc.beans.tosca.Input(input, annotationProperties);
+ if ( vfModuleInput.getInputProperties() != null && vfModuleInput.getInputProperties().getParamName() != null ) {
+ inputMap.put(vfModuleInput.getInputProperties().getParamName(), vfModuleInput);
+ } else {
+ inputMap.put(input.getName(), vfModuleInput);
+ }
+ }
+ }
+ }
+
- private boolean isInputMatchesToGroup(List<Property> annotationProperties, org.onap.vid.model.Group group){
- for(Property property: annotationProperties){
- if(property.getName().equals(VF_MODULE_LABEL)){
+ private boolean isInputMatchesToGroup(List<Property> annotationProperties, org.onap.vid.model.Group group) {
+ for (Property property : annotationProperties) {
+ if ( property.getName().equals(VF_MODULE_LABEL) ) {
final Object values = property.getValue();
final String vfModuleLabel = group.getProperties().getVfModuleLabel();
- if (values instanceof List) {
- if (listContainsAsString((List) values, vfModuleLabel)) return true;
+ if ( values instanceof List ) {
+ if ( listContainsAsString((List) values, vfModuleLabel) ) return true;
} else {
return getPropertyValueAsString(property).equals(vfModuleLabel);
}
@@ -432,7 +496,7 @@ public class ToscaParserImpl2 {
private boolean listContainsAsString(List list, String value) {
for (Object v : list) {
- if (StringUtils.equals(v.toString(), value)) {
+ if ( StringUtils.equals(v.toString(), value) ) {
return true;
}
}
@@ -443,37 +507,45 @@ public class ToscaParserImpl2 {
return removeSquareBrackets(property.getValue().toString());
}
- private String removeSquareBrackets(String stringWithSquareBrackets){
+ private String removeSquareBrackets(String stringWithSquareBrackets) {
return stringWithSquareBrackets.replaceAll("(^\\[|\\]$)", "");
}
- private GroupProperties extractVfModuleProperties(Group group, ISdcCsarHelper csarHelper){
+ private GroupProperties extractVfModuleProperties(Group group, ISdcCsarHelper csarHelper) {
GroupProperties vfModuleProperties = new GroupProperties();
- if(csarHelper.getGroupPropertyAsObject(group, Constants.MIN_VF_MODULE_INSTANCES) != null)
- vfModuleProperties.setMinCountInstances((Integer)csarHelper.getGroupPropertyAsObject(group, Constants.MIN_VF_MODULE_INSTANCES));
- if(csarHelper.getGroupPropertyAsObject(group, Constants.MAX_VF_MODULE_INSTANCES) != null)
- vfModuleProperties.setMaxCountInstances((Integer)csarHelper.getGroupPropertyAsObject(group, Constants.MAX_VF_MODULE_INSTANCES));
- if(csarHelper.getGroupPropertyAsObject(group, Constants.INITIAL_COUNT) != null)
- vfModuleProperties.setInitialCount((Integer)csarHelper.getGroupPropertyAsObject(group, Constants.INITIAL_COUNT));
- if(csarHelper.getGroupPropertyAsObject(group, VF_MODULE_LABEL) != null)
+ if ( csarHelper.getGroupPropertyAsObject(group, Constants.MIN_VF_MODULE_INSTANCES) != null )
+ vfModuleProperties.setMinCountInstances((Integer) csarHelper.getGroupPropertyAsObject(group, Constants.MIN_VF_MODULE_INSTANCES));
+ if ( csarHelper.getGroupPropertyAsObject(group, Constants.MAX_VF_MODULE_INSTANCES) != null )
+ vfModuleProperties.setMaxCountInstances((Integer) csarHelper.getGroupPropertyAsObject(group, Constants.MAX_VF_MODULE_INSTANCES));
+ if ( csarHelper.getGroupPropertyAsObject(group, Constants.INITIAL_COUNT) != null )
+ vfModuleProperties.setInitialCount((Integer) csarHelper.getGroupPropertyAsObject(group, Constants.INITIAL_COUNT));
+ if ( csarHelper.getGroupPropertyAsObject(group, VF_MODULE_LABEL) != null )
vfModuleProperties.setVfModuleLabel((String) csarHelper.getGroupPropertyAsObject(group, VF_MODULE_LABEL));
+ vfModuleProperties.setBaseModule(isModuleTypeIsBaseObjectSafe(csarHelper.getGroupPropertyAsObject(group, Constants.VF_MODULE_TYPE)));
return vfModuleProperties;
}
+ public static boolean isModuleTypeIsBaseObjectSafe(Object vfModuleTypeValue) {
+ return (vfModuleTypeValue instanceof String) && (isModuleTypeIsBase((String) vfModuleTypeValue));
+ }
+
+ protected static boolean isModuleTypeIsBase(String vfModuleTypeValue) {
+ return "Base".equalsIgnoreCase(vfModuleTypeValue);
+ }
- private Map<String, org.onap.vid.asdc.beans.tosca.Input> extractInputsAndCommandsForNodeTemplate(NodeTemplate nodeTemplate, ISdcCsarHelper csarHelper, Node newNode){
+ private Map<String, org.onap.vid.asdc.beans.tosca.Input> extractInputsAndCommandsForNodeTemplate(NodeTemplate nodeTemplate, ISdcCsarHelper csarHelper, Node newNode) {
Map<String, org.onap.vid.asdc.beans.tosca.Input> inputMap = new HashMap<>();
Map<String, CommandProperty> commandPropertyMap = new HashMap<>();
List<Input> inputs = csarHelper.getServiceInputs();
- Map<String, String> properties = csarHelper.filterNodeTemplatePropertiesByValue(nodeTemplate, FilterType.CONTAINS, Constants.GET_INPUT);
+ Map<String, String> properties = csarHelper.filterNodeTemplatePropertiesByValue(nodeTemplate, FilterType.CONTAINS, Constants.GET_INPUT);
for (Map.Entry<String, String> property : properties.entrySet()) {
String inputKey = property.getValue();
String key = extractInputValue(inputKey);
- for (Input input: inputs){
- if(input.getName().equals(key)){
+ for (Input input : inputs) {
+ if ( input.getName().equals(key) ) {
org.onap.vid.asdc.beans.tosca.Input localInput = new org.onap.vid.asdc.beans.tosca.Input();
localInput = convertInput(input, localInput, nodeTemplate);
String name = property.getKey();
@@ -487,7 +559,7 @@ public class ToscaParserImpl2 {
}
private String extractInputValue(String inputKey) {
- return inputKey.substring(inputKey.indexOf(":") + 1);
+ return inputKey.substring(inputKey.indexOf(':') + 1);
}
private org.onap.vid.asdc.beans.tosca.Input convertInput(Input parserInput, org.onap.vid.asdc.beans.tosca.Input localInput, NodeTemplate nodeTemplate){
@@ -497,7 +569,7 @@ public class ToscaParserImpl2 {
localInput.setType(parserInput.getType());
localInput.setConstraints(parserInput.getConstraints());
// localInput.setentry_schema()
-
+
//if inputs of inner nodeTemplate - tell its details
if(nodeTemplate != null) {
Metadata metadata = nodeTemplate.getMetaData();
@@ -506,11 +578,11 @@ public class ToscaParserImpl2 {
localInput.setTemplateInvariantUUID(metadata.getValue("invariantUUID"));
localInput.setTemplateCustomizationUUID(metadata.getValue("customizationUUID"));
}
-
+
return localInput;
}
- private CommandProperty extractCommands(String displayName, String inputName){
+ private CommandProperty extractCommands(String displayName, String inputName) {
CommandProperty commandProperty = new CommandProperty();
commandProperty.setDisplayName(displayName);
commandProperty.setCommand(Constants.GET_INPUT);
@@ -518,19 +590,8 @@ public class ToscaParserImpl2 {
return commandProperty;
}
- private Map<String, String> setPropertiesOfVnf(List<Property> properties) {
- Map<String, String> propertiesMap = new HashMap<String, String>();
- for (Property property : properties) {
- //special handling to necessary sub-property "ecomp_generated_naming"
- if(property.getName().equals("nf_naming")){
- final Object ecompGeneratedNaming = ((Map) (property.getValue())).get("ecomp_generated_naming");
- if (ecompGeneratedNaming != null) {
- propertiesMap.put("ecomp_generated_naming", ecompGeneratedNaming.toString());
- }
- }
- propertiesMap.put(property.getName(), property.getValue().toString());
- }
- return propertiesMap;
+ private void setEcompNamingProperty(Map<String, String> propertiesMap, String isUserProvidingVnfNameOptional) {
+ propertiesMap.put(Constants.ECOMP_GENERATED_NAMING_PROPERTY, isUserProvidingVnfNameOptional);
}
private String validateInstantiationType(ISdcCsarHelper csarHelper){
@@ -545,5 +606,43 @@ public class ToscaParserImpl2 {
return validatedInstantiationType;
}
+ private Map<String, ResourceGroup> extractVnfGroupsFromCsar(ISdcCsarHelper csarHelper, List<String> policiesTargets) {
+ List<Group> resourceGroups = csarHelper.getGroupsOfTopologyTemplateByToscaGroupType(Constants.RESOURCE_GROUP_TYPE);
+
+ return resourceGroups.stream()
+ .filter(group -> group.getProperties().get(Constants.RESOURCE_GROUP_CONTAINED_TYPE).getValue().equals("VF"))
+ .collect(toMap(Group::getName, group -> parseResourceGroup(group, csarHelper, policiesTargets)));
+ }
+
+ private ResourceGroup parseResourceGroup(Group group, ISdcCsarHelper csarHelper, List<String> policiesTargets) {
+ return new ResourceGroup(
+ Constants.VNF_GROUP,
+ group.getMetadata().getValue(Constants.INVARIANT_UUID),
+ group.getMetadata().getValue(Constants.UUID),
+ group.getMetadata().getValue(Constants.VERSION),
+ group.getMetadata().getValue(Constants.NAME),
+ group.getMetadata().getValue(Constants.NAME),
+ getPropertiesOfResourceGroup(group.getProperties(), policiesTargets.contains(group.getName())),
+ csarHelper.getGroupMembersFromTopologyTemplate(group.getName()).stream()
+ .collect(toMap(NodeTemplate::getName, node -> getServiceProxyFromNodeTemplate(node, csarHelper, policiesTargets)))
+ );
+ }
+
+ private Map<String, Object> getPropertiesOfResourceGroup(Map<String, Property> properties, boolean hasPolicyTarget) {
+ Map<String, Object> propertiesMap = properties.entrySet().stream()
+ .collect(toMap(Map.Entry::getKey, e -> e.getValue().getValue()));
+ propertiesMap.put(Constants.ECOMP_GENERATED_NAMING_PROPERTY, String.valueOf(hasPolicyTarget));
+ return propertiesMap;
+ }
+
+ public List<String> extractNamingPoliciesTargets(ISdcCsarHelper csarHelper) {
+ List<Policy> policies = csarHelper.getPoliciesOfTopologyTemplateByToscaPolicyType(Constants.NAMING_POLICY_TYPE);
+ return policies.stream()
+ .filter(policy -> policy.getProperties().get(Constants.TYPE) != null &&
+ policy.getProperties().get(Constants.TYPE).getValue() != null &&
+ StringUtils.equalsIgnoreCase(policy.getProperties().get(Constants.TYPE).getValue().toString(), "naming"))
+ .flatMap(policy -> policy.getTargets().stream())
+ .collect(toList());
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
new file mode 100644
index 0000000..ca0607b
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java
@@ -0,0 +1,130 @@
+package org.onap.vid.asdc.parser;
+
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.vid.model.ServiceModel;
+import org.onap.vid.model.VidNotions;
+import org.onap.vid.properties.Features;
+import org.togglz.core.manager.FeatureManager;
+
+import static org.apache.commons.lang3.StringUtils.equalsAnyIgnoreCase;
+import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
+
+public class VidNotionsBuilder {
+
+ private final FeatureManager featureManager;
+
+ public VidNotionsBuilder(FeatureManager featureManager) {
+ this.featureManager = featureManager;
+ }
+
+ public VidNotions buildVidNotions(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
+ final VidNotions.InstantiationUI instantiationUI = suggestInstantiationUI(csarHelper);
+
+ return new VidNotions(instantiationUI, suggestModelCategory(csarHelper), suggestViewEditUI(csarHelper, serviceModel));
+ }
+
+ //UI route a-la-carte services to old UI only if InstantiationUI is LEGACY
+ //So any other value for InstantiationUI other than LEGACY make UI to route
+ //a-la-carte services to new UI
+ VidNotions.InstantiationUI suggestInstantiationUI(ISdcCsarHelper csarHelper) {
+ if(featureManager.isActive(Features.FLAG_EXP_ANY_ALACARTE_NEW_INSTANTIATION_UI) && isALaCarte(csarHelper)) {
+ return VidNotions.InstantiationUI.ANY_ALACARTE_NEW_UI;
+ }
+ if (featureManager.isActive(Features.FLAG_1902_VNF_GROUPING) && isGrouping(csarHelper)) {
+ return VidNotions.InstantiationUI.SERVICE_WITH_VNF_GROUPING;
+ }
+ if (featureManager.isActive(Features.FLAG_5G_IN_NEW_INSTANTIATION_UI)) {
+ if (isUuidExactlyHardCoded1ffce89fef3f(csarHelper)) {
+ return VidNotions.InstantiationUI.SERVICE_UUID_IS_1ffce89f_ef3f_4cbb_8b37_82134590c5de;
+ } else if (isALaCarte(csarHelper) && hasAnyNetworkWithPropertyNetworkTechnologyEqualsStandardSriovOrOvs(csarHelper)) {
+ return VidNotions.InstantiationUI.NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS;
+ } else if (isALaCarte(csarHelper) && hasFabricConfiguration(csarHelper)) {
+ return VidNotions.InstantiationUI.SERVICE_WITH_FABRIC_CONFIGURATION;
+ }
+ }
+
+ return VidNotions.InstantiationUI.LEGACY;
+
+ }
+
+ VidNotions.ModelCategory suggestModelCategory(ISdcCsarHelper csarHelper) {
+ if (isALaCarte(csarHelper) && hasAnyNetworkWithPropertyNetworkTechnologyEqualsStandardSriovOrOvs(csarHelper)){
+ return VidNotions.ModelCategory.IS_5G_PROVIDER_NETWORK_MODEL;
+ } else if(isALaCarte(csarHelper) && hasFabricConfiguration(csarHelper)) {
+ return VidNotions.ModelCategory.IS_5G_FABRIC_CONFIGURATION_MODEL;
+ } else {
+ return VidNotions.ModelCategory.OTHER;
+ }
+ }
+
+ VidNotions.InstantiationUI suggestViewEditUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel) {
+ if (!featureManager.isActive(Features.FLAG_ASYNC_INSTANTIATION)){
+ return VidNotions.InstantiationUI.LEGACY;
+ }
+ if (featureManager.isActive(Features.FLAG_1902_VNF_GROUPING) && isGrouping(csarHelper)) {
+ return VidNotions.InstantiationUI.SERVICE_WITH_VNF_GROUPING;
+ }
+
+ if (featureManager.isActive(Features.FLAG_1902_NEW_VIEW_EDIT)) {
+ if (isMacro(serviceModel) && !isMacroExcludedFromAsyncFlow(serviceModel)) {
+ return VidNotions.InstantiationUI.MACRO_SERVICE;
+ }
+ VidNotions.InstantiationUI instantiationUISuggestion = suggestInstantiationUI(csarHelper);
+ if (instantiationUISuggestion!=VidNotions.InstantiationUI.LEGACY) {
+ return instantiationUISuggestion;
+ }
+ }
+
+ return VidNotions.InstantiationUI.LEGACY;
+ }
+
+ private boolean isMacro(ServiceModel serviceModel) {
+ return ToscaParserImpl2.Constants.MACRO.equals(serviceModel.getService().getInstantiationType());
+ }
+
+ private boolean isUuidExactlyHardCoded1ffce89fef3f(ISdcCsarHelper csarHelper) {
+ return equalsIgnoreCase(
+ csarHelper.getServiceMetadata().getValue(ToscaParserImpl2.Constants.UUID), "95eb2c44-bff2-4e8b-ad5d-8266870b7717");
+ }
+
+ private boolean hasAnyNetworkWithPropertyNetworkTechnologyEqualsStandardSriovOrOvs(ISdcCsarHelper csarHelper) {
+ return hasAnyNetworkWithPropertyEqualsToAnyOf(csarHelper, "network_technology","Standard-SR-IOV","OVS") ;
+ }
+
+ boolean hasFabricConfiguration(ISdcCsarHelper csarHelper) {
+ return csarHelper.getServiceNodeTemplates().stream()
+ .flatMap(nodeTemplate -> csarHelper.getNodeTemplateChildren(nodeTemplate).stream())
+ .anyMatch(child -> child.getType().equals(ToscaParserImpl2.Constants.FABRIC_CONFIGURATION_TYPE));
+ }
+
+ boolean hasAnyNetworkWithPropertyEqualsToAnyOf(ISdcCsarHelper csarHelper, String propertyName, String... propertyValues) {
+ return csarHelper
+ .getServiceVlList().stream()
+ .map(NodeTemplate::getProperties)
+ .flatMap(props -> props.entrySet().stream())
+ .filter(prop -> equalsIgnoreCase(prop.getKey(), propertyName))
+ // getValue().getValue() because value is Entry, where it's inner value is what we're looking for
+ .anyMatch(prop -> equalsAnyIgnoreCase(prop.getValue().getValue().toString(), propertyValues));
+ }
+
+ boolean isALaCarte(ISdcCsarHelper csarHelper) {
+ final String instantiationType = csarHelper.getServiceMetadata().getValue(ToscaParserImpl2.Constants.INSTANTIATION_TYPE);
+ return StringUtils.equalsIgnoreCase(instantiationType, ToscaParserImpl2.Constants.A_LA_CARTE);
+ }
+
+ boolean isMacroExcludedFromAsyncFlow(ServiceModel serviceModel) {
+ return (MapUtils.isNotEmpty(serviceModel.getPnfs()) ||
+ MapUtils.isNotEmpty(serviceModel.getCollectionResource()) ||
+ (MapUtils.isNotEmpty(serviceModel.getNetworks()) && !featureManager.isActive(Features.FLAG_NETWORK_TO_ASYNC_INSTANTIATION)));
+
+
+ }
+
+ private boolean isGrouping(ISdcCsarHelper csarHelper) {
+ final String serviceRole = csarHelper.getServiceMetadata().getValue(ToscaParserImpl2.Constants.SERVICE_ROLE);
+ return StringUtils.equalsIgnoreCase(serviceRole, ToscaParserImpl2.Constants.GROUPING);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/ChangeManagementRequest.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/ChangeManagementRequest.java
index 1d866ee..abfcd6f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/ChangeManagementRequest.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/ChangeManagementRequest.java
@@ -1,13 +1,10 @@
package org.onap.vid.changeManagement;
-import java.util.List;
+import com.fasterxml.jackson.annotation.*;
+
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonPropertyOrder({
"requestDetails",
@@ -17,17 +14,17 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
public class ChangeManagementRequest {
public static class MsoChangeManagementRequest {
- public final static String SOFTWARE_UPDATE = "inPlaceSoftwareUpdate";
+ public static final String SOFTWARE_UPDATE = "inPlaceSoftwareUpdate";
public static final String REPLACE = "replace";
- public final static String CONFIG_UPDATE = "applyUpdatedConfig";
+ public static final String CONFIG_UPDATE = "applyUpdatedConfig";
}
- public final static String VNF_IN_PLACE_SOFTWARE_UPDATE = "vnf in place software update";
+ public static final String VNF_IN_PLACE_SOFTWARE_UPDATE = "vnf in place software update";
public static final String UPDATE = "update";
public static final String REPLACE = "replace";
- public final static String CONFIG_UPDATE = "vnf config update";
- public final static String SCALE_OUT = "vnf scale out";
+ public static final String CONFIG_UPDATE = "vnf config update";
+ public static final String SCALE_OUT = "vnf scale out";
@JsonProperty("requestDetails")
private List<RequestDetails> requestDetails;
@@ -36,7 +33,7 @@ public class ChangeManagementRequest {
private String requestType;
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private Map<String, Object> additionalProperties = new HashMap<>();
@JsonProperty("requestDetails")
public List<RequestDetails> getRequestDetails() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/CloudConfiguration.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/CloudConfiguration.java
index 43d6a6a..b743579 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/CloudConfiguration.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/CloudConfiguration.java
@@ -1,13 +1,9 @@
package org.onap.vid.changeManagement;
+import com.fasterxml.jackson.annotation.*;
+
import java.util.HashMap;
import java.util.Map;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
@@ -20,7 +16,7 @@ public class CloudConfiguration {
@JsonProperty("tenantId")
private String tenantId;
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private Map<String, Object> additionalProperties = new HashMap<>();
@JsonProperty("lcpCloudRegionId")
public String getLcpCloudRegionId() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/LeanCloudConfiguration.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/LeanCloudConfiguration.java
index 6011c7e..480ef12 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/LeanCloudConfiguration.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/LeanCloudConfiguration.java
@@ -1,20 +1,27 @@
package org.onap.vid.changeManagement;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.onap.vid.mso.model.CloudConfiguration;
+
/**
* Created by Oren on 9/5/17.
*/
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class LeanCloudConfiguration {
public LeanCloudConfiguration() {
}
- public LeanCloudConfiguration(org.onap.vid.domain.mso.CloudConfiguration cloudConfiguration) {
+ public LeanCloudConfiguration(CloudConfiguration cloudConfiguration) {
this.tenantId = cloudConfiguration.getTenantId();
this.lcpCloudRegionId = cloudConfiguration.getLcpCloudRegionId();
+ this.cloudOwner = cloudConfiguration.getCloudOwner();
}
public String lcpCloudRegionId;
public String tenantId;
+ public String cloudOwner;
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfo.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfo.java
index 8f44a4b..ebb0ba3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfo.java
@@ -1,12 +1,9 @@
package org.onap.vid.changeManagement;
+
+import com.fasterxml.jackson.annotation.*;
+
import java.util.HashMap;
import java.util.Map;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
@@ -24,7 +21,7 @@ public class ModelInfo {
}
- public ModelInfo(org.onap.vid.domain.mso.ModelInfo modelInfo){
+ public ModelInfo(org.onap.vid.mso.model.ModelInfo modelInfo){
this.setModelType(modelInfo.getModelType().toString());
this.setModelInvariantId(modelInfo.getModelInvariantId());
this.setModelVersionId(modelInfo.getModelNameVersionId());
@@ -50,7 +47,7 @@ public class ModelInfo {
@JsonProperty("modelCustomizationId")
private String modelCustomizationId;
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private Map<String, Object> additionalProperties = new HashMap<>();
@JsonProperty("modelType")
public String getModelType() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfoOfRelatedInstance.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfoOfRelatedInstance.java
index 7e87609..7c9b709 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfoOfRelatedInstance.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfoOfRelatedInstance.java
@@ -1,13 +1,9 @@
package org.onap.vid.changeManagement;
+import com.fasterxml.jackson.annotation.*;
+
import java.util.HashMap;
import java.util.Map;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
@@ -37,7 +33,7 @@ public class ModelInfoOfRelatedInstance {
@JsonProperty("modelCustomizationId")
private String modelCustomizationId;
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private Map<String, Object> additionalProperties = new HashMap<>();
@JsonProperty("modelType")
public String getModelType() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestDetails.java
index 8e1a408..25951f2 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestDetails.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestDetails.java
@@ -57,4 +57,9 @@ public class RequestDetails extends org.onap.vid.mso.rest.RequestDetails{
public boolean equals(Object other) {
return super.equals(other);
}
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestInfo.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestInfo.java
index 4aa3724..8ecb39e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestInfo.java
@@ -1,13 +1,9 @@
package org.onap.vid.changeManagement;
+import com.fasterxml.jackson.annotation.*;
+
import java.util.HashMap;
import java.util.Map;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
@@ -23,7 +19,7 @@ public class RequestInfo {
@JsonProperty("requestorId")
private String requestorId;
@JsonIgnore
- private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+ private Map<String, Object> additionalProperties = new HashMap<>();
@JsonProperty("source")
public String getSource() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java
index 024e9c3..394c8ff 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java
@@ -1,6 +1,6 @@
package org.onap.vid.changeManagement;
-import org.onap.vid.domain.mso.*;
+import org.onap.vid.mso.model.RequestInfo;
/**
* Created by Oren on 9/5/17.
@@ -11,7 +11,7 @@ public class UpdateRequestInfo {
}
- public UpdateRequestInfo(org.onap.vid.domain.mso.RequestInfo requestInfo) {
+ public UpdateRequestInfo(RequestInfo requestInfo) {
this.requestorId = requestInfo.getRequestorId();
this.suppressRollback = requestInfo.getSuppressRollback();
this.source = requestInfo.getSource();
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetails.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetails.java
index 5cc2f4d..c5a0671 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetails.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetails.java
@@ -1,7 +1,6 @@
package org.onap.vid.changeManagement;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.MoreObjects;
public class VnfDetails {
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetailsWithWorkflows.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetailsWithWorkflows.java
index 4e172a1..9971df9 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetailsWithWorkflows.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetailsWithWorkflows.java
@@ -33,7 +33,13 @@ public class VnfDetailsWithWorkflows extends VnfDetails {
this.workflows = workflows;
}
- public boolean equals(VnfDetailsWithWorkflows vnfDetailsWithWorkflows){
- return this.workflows.equals(vnfDetailsWithWorkflows.getWorkflows());
+ @Override
+ public boolean equals(Object o) {
+ return super.equals(o);
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowsDetail.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowsDetail.java
index e833ecb..0883411 100644
--- a/vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowsDetail.java
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowsDetail.java
@@ -1,7 +1,6 @@
package org.onap.vid.changeManagement;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.MoreObjects;
public class WorkflowsDetail {
diff --git a/vid-app-common/src/main/java/org/onap/vid/client/HttpBasicClient.java b/vid-app-common/src/main/java/org/onap/vid/client/HttpBasicClient.java
index 8f0d59f..b9b2c8b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/client/HttpBasicClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/client/HttpBasicClient.java
@@ -29,8 +29,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.ServletContext;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
/**
* General HTTP client.
@@ -45,9 +43,6 @@ public class HttpBasicClient{
/** The logger. */
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HttpBasicClient.class);
- /** The Constant dateFormat. */
- final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
-
/**
* Obtain a basic HTTP client .
*
diff --git a/vid-app-common/src/main/java/org/onap/vid/client/HttpsBasicClient.java b/vid-app-common/src/main/java/org/onap/vid/client/HttpsBasicClient.java
deleted file mode 100644
index 5afa035..0000000
--- a/vid-app-common/src/main/java/org/onap/vid/client/HttpsBasicClient.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * 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.onap.vid.client;
-
-import org.eclipse.jetty.util.security.Password;
-import org.glassfish.jersey.client.ClientConfig;
-import org.glassfish.jersey.client.ClientProperties;
-import org.onap.vid.properties.VidProperties;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.portalsdk.core.util.SystemProperties;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
- /**
- * General SSL client using the VID tomcat keystore. It doesn't use client certificates.
- */
-
-public class HttpsBasicClient{
-
- /** The logger. */
- static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HttpsBasicClient.class);
-
- /** The Constant dateFormat. */
- final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
-
- /**
- * Retrieve an SSL client.
- *
- * @return Client The SSL client
- * @throws Exception the exception
- */
- public static Client getClient() {
- String methodName = "getClient";
- ClientConfig config = new ClientConfig();
-
- SSLContext ctx = null;
-
- try {
-
- config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
-
- String truststore_path = SystemProperties.getProperty(VidProperties.VID_TRUSTSTORE_FILENAME);
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + " " + methodName + " truststore_path=" + truststore_path);
- String truststore_password = SystemProperties.getProperty(VidProperties.VID_TRUSTSTORE_PASSWD_X);
-
-
- String decrypted_truststore_password = Password.deobfuscate(truststore_password);
- //logger.debug(dateFormat.format(new Date()) + " " + methodName + " decrypted_truststore_password=" + decrypted_truststore_password);
-
- File tr = new File (truststore_path);
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + " " + methodName + " absolute truststore path=" + tr.getAbsolutePath());
-
- System.setProperty("javax.net.ssl.trustStore", truststore_path);
- System.setProperty("javax.net.ssl.trustStorePassword", decrypted_truststore_password);
- HttpsURLConnection.setDefaultHostnameVerifier( new HostnameVerifier(){
- public boolean verify(String string,SSLSession ssls) {
- return true;
- }
- });
-
- //May need to make the algorithm a parameter. MSO requires TLSv1.1 or TLSv1.2
- ctx = SSLContext.getInstance("TLSv1.2");
-
- ctx.init(null, null, null);
- //config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
- // new HTTPSProperties( , ctx));
-
- return ClientBuilder.newBuilder()
- .sslContext(ctx)
- .hostnameVerifier(new HostnameVerifier() {
- @Override
- public boolean verify( String s, SSLSession sslSession ) {
- return true;
- }
- }).withConfig(config)
- .build()
- .register(org.onap.vid.aai.util.CustomJacksonJaxBJsonProvider.class);
-
- } catch (Exception e) {
- logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up config: exiting", e);
- return null;
- }
- }
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java
index 9e50c44..ed1401c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/client/SyncRestClient.java
@@ -42,11 +42,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
+import java.security.*;
import java.security.cert.CertificateException;
import java.util.Map;
@@ -170,7 +166,7 @@ public class SyncRestClient implements SyncRestClientInterface {
}
private ObjectMapper defaultObjectMapper() {
- org.codehaus.jackson.map.ObjectMapper objectMapper = new org.codehaus.jackson.map.ObjectMapper();
+ com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
return new ObjectMapper() {
@Override
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/AaiController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
index 1a426ed..c099db8 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/AaiController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
@@ -18,15 +18,18 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
-import org.codehaus.jackson.map.ObjectMapper;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.aai.AaiGetVnfResponse;
import org.onap.vid.aai.AaiResponse;
import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigData;
import org.onap.vid.aai.ServiceInstancesSearchResults;
-import org.onap.vid.aai.SubscriberData;
import org.onap.vid.aai.SubscriberFilteredResults;
import org.onap.vid.aai.model.AaiGetInstanceGroupsByCloudRegion;
import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
@@ -38,9 +41,7 @@ import org.onap.vid.roles.Role;
import org.onap.vid.roles.RoleProvider;
import org.onap.vid.roles.RoleValidator;
import org.onap.vid.services.AaiService;
-import org.onap.portalsdk.core.controller.RestrictedBaseController;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.utils.Unchecked;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -56,9 +57,10 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
import java.util.stream.Collectors;
import static org.onap.vid.utils.Logging.getMethodName;
@@ -69,14 +71,11 @@ import static org.onap.vid.utils.Logging.getMethodName;
@RestController
public class AaiController extends RestrictedBaseController {
- /**
- * The Constant dateFormat.
- */
- final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
/**
* The from app id.
*/
- protected String fromAppId = "VidAaiController";
+ private String fromAppId = "VidAaiController";
/**
* The logger.
*/
@@ -84,7 +83,7 @@ public class AaiController extends RestrictedBaseController {
/**
* The model.
*/
- private Map<String, Object> model = new HashMap<String, Object>();
+ private Map<String, Object> model = new HashMap<>();
/**
* The servlet context.
*/
@@ -109,20 +108,20 @@ public class AaiController extends RestrictedBaseController {
*/
@RequestMapping(value = {"/subscriberSearch"}, method = RequestMethod.GET)
public ModelAndView welcome(HttpServletRequest request) {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== AaiController welcome start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== AaiController welcome start");
return new ModelAndView(getViewName());
}
@RequestMapping(value = {"/aai_get_aic_zones"}, method = RequestMethod.GET)
public ResponseEntity<String> getAicZones(HttpServletRequest request) throws IOException {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== getAicZones controller start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== getAicZones controller start");
AaiResponse response = aaiService.getAaiZones();
return aaiResponseToResponseEntity(response);
}
@RequestMapping(value = {"/aai_get_aic_zone_for_pnf/{globalCustomerId}/{serviceType}/{serviceId}"}, method = RequestMethod.GET)
public ResponseEntity<String> getAicZoneForPnf(@PathVariable("globalCustomerId") String globalCustomerId ,@PathVariable("serviceType") String serviceType , @PathVariable("serviceId") String serviceId ,HttpServletRequest request) throws IOException {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== getAicZoneForPnf controller start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== getAicZoneForPnf controller start");
AaiResponse response = aaiService.getAicZoneForPnf(globalCustomerId , serviceType , serviceId);
return aaiResponseToResponseEntity(response);
}
@@ -143,7 +142,7 @@ public class AaiController extends RestrictedBaseController {
String userId = ControllersUtils.extractUserId(request);
- return new ResponseEntity<String>(userId, HttpStatus.OK);
+ return new ResponseEntity<>(userId, HttpStatus.OK);
}
/**
@@ -157,20 +156,15 @@ public class AaiController extends RestrictedBaseController {
RoleValidator roleValidator = new RoleValidator(roleProvider.getUserRoles(request));
AaiResponse subscriberList = aaiService.getServices(roleValidator);
- ResponseEntity<String> responseEntity = aaiResponseToResponseEntity(subscriberList);
-
- return responseEntity;
+ return aaiResponseToResponseEntity(subscriberList);
}
@RequestMapping(value = {"/aai_get_version_by_invariant_id"}, method = RequestMethod.POST)
public ResponseEntity<String> getVersionByInvariantId(HttpServletRequest request, @RequestBody VersionByInvariantIdsRequest versions) {
- ResponseEntity<String> responseEntity;
- ObjectMapper objectMapper = new ObjectMapper();
-
Response result = aaiService.getVersionByInvariantId(versions.versions);
- return new ResponseEntity<String>(result.readEntity(String.class), HttpStatus.OK);
+ return new ResponseEntity<>(result.readEntity(String.class), HttpStatus.OK);
}
@@ -179,9 +173,9 @@ public class AaiController extends RestrictedBaseController {
ResponseEntity<String> responseEntity;
ObjectMapper objectMapper = new ObjectMapper();
if (aaiResponseData.getHttpCode() == 200) {
- responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(aaiResponseData.getT()), HttpStatus.OK);
+ responseEntity = new ResponseEntity<>(objectMapper.writeValueAsString(aaiResponseData.getT()), HttpStatus.OK);
} else {
- responseEntity = new ResponseEntity<String>(aaiResponseData.getErrorMessage(), HttpStatus.valueOf(aaiResponseData.getHttpCode()));
+ responseEntity = new ResponseEntity<>(aaiResponseData.getErrorMessage(), HttpStatus.valueOf(aaiResponseData.getHttpCode()));
}
return responseEntity;
}
@@ -209,7 +203,7 @@ public class AaiController extends RestrictedBaseController {
return convertResponseToResponseEntity(resp);
}
- /**
+ /**
* Get services from a&ai.
*
* @param globalCustomerId the global customer id
@@ -246,7 +240,7 @@ public class AaiController extends RestrictedBaseController {
@RequestMapping(value = "/get_system_prop_vnf_prov_status", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> getTargetProvStatus() {
String p = SystemProperties.getProperty("aai.vnf.provstatus");
- return new ResponseEntity<String>(p, HttpStatus.OK);
+ return new ResponseEntity<>(p, HttpStatus.OK);
}
@@ -264,7 +258,7 @@ public class AaiController extends RestrictedBaseController {
if (response.getHttpCode() != 200) {
String errorMessage = getAaiErrorMessage(response.getErrorMessage());
if(errorMessage != null) {
- response = new AaiResponse<OperationalEnvironmentList>(response.getT(), errorMessage, response.getHttpCode());
+ response = new AaiResponse<>(response.getT(), errorMessage, response.getHttpCode());
}
}
@@ -286,9 +280,9 @@ public class AaiController extends RestrictedBaseController {
RoleValidator roleValidator = new RoleValidator(roleProvider.getUserRoles(request));
SubscriberFilteredResults subscriberList = aaiService.getFullSubscriberList(roleValidator);
if (subscriberList.getHttpCode() == 200) {
- responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(subscriberList.getSubscriberList()), HttpStatus.OK);
+ responseEntity = new ResponseEntity<>(objectMapper.writeValueAsString(subscriberList.getSubscriberList()), HttpStatus.OK);
} else {
- responseEntity = new ResponseEntity<String>(subscriberList.getErrorMessage(), HttpStatus.valueOf(subscriberList.getHttpCode()));
+ responseEntity = new ResponseEntity<>(subscriberList.getErrorMessage(), HttpStatus.valueOf(subscriberList.getHttpCode()));
}
@@ -301,10 +295,10 @@ public class AaiController extends RestrictedBaseController {
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> getVnfDataByGlobalIdAndServiceType(HttpServletRequest request,
@PathVariable("globalCustomerId") String globalCustomerId,
- @PathVariable("serviceType") String serviceType) {
+ @PathVariable("serviceType") String serviceType) throws IOException {
- Response resp = aaiService.getVNFData(globalCustomerId, serviceType);
- return convertResponseToResponseEntity(resp);
+ AaiResponse<AaiGetVnfResponse> resp = aaiService.getVNFData(globalCustomerId, serviceType);
+ return aaiResponseToResponseEntity(resp);
}
@@ -316,8 +310,7 @@ public class AaiController extends RestrictedBaseController {
*/
@RequestMapping(value = "/aai_refresh_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> doRefreshSubscriberList() {
- Response resp = getSubscribers(false);
- return convertResponseToResponseEntity(resp);
+ return refreshSubscriberList();
}
/**
@@ -328,7 +321,11 @@ public class AaiController extends RestrictedBaseController {
*/
@RequestMapping(value = "/aai_refresh_full_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> doRefreshFullSubscriberList() {
- Response resp = getSubscribers(false);
+ return refreshSubscriberList();
+ }
+
+ protected ResponseEntity<String> refreshSubscriberList() {
+ Response resp = getSubscribers();
return convertResponseToResponseEntity(resp);
}
@@ -344,7 +341,7 @@ public class AaiController extends RestrictedBaseController {
ResponseEntity responseEntity;
List<Role> roles = roleProvider.getUserRoles(request);
RoleValidator roleValidator = new RoleValidator(roles);
- AaiResponse<SubscriberData> subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator);
+ AaiResponse subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator);
String httpMessage = subscriberData.getT() != null ?
objectMapper.writeValueAsString(subscriberData.getT()) :
subscriberData.getErrorMessage();
@@ -381,7 +378,7 @@ public class AaiController extends RestrictedBaseController {
searchResult.getErrorMessage();
- if(searchResult.getT().serviceInstances.size() == 0){
+ if(searchResult.getT().serviceInstances.isEmpty()){
responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.NOT_FOUND);
} else {
@@ -415,17 +412,6 @@ public class AaiController extends RestrictedBaseController {
return convertResponseToResponseEntity(resp);
}
- @RequestMapping(value = "/aai_get_vnf_data/{globalCustomerId}/{serviceType}/{serviceInstanceId}", method = RequestMethod.GET)
- public AaiResponse<String> getVnfData(
- @PathVariable("globalCustomerId") String globalCustomerId,
- @PathVariable("serviceType") String serviceType,
- @PathVariable("serviceInstanceId") String serviceInstanceId) {
-
- return aaiService.getVNFData(globalCustomerId, serviceType, serviceInstanceId);
-
- }
-
-
/**
* Issue a named query to a&ai.
*
@@ -455,7 +441,7 @@ public class AaiController extends RestrictedBaseController {
@PathVariable("cloudRegion") String cloudRegion) {
AaiResponse<String> resp = aaiService.getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion);
- return new ResponseEntity<String>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
+ return new ResponseEntity<>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
}
@RequestMapping(value = "/aai_get_network_collection_details/{serviceInstanceId}", method = RequestMethod.GET)
@@ -466,7 +452,7 @@ public class AaiController extends RestrictedBaseController {
String httpMessage = resp.getT() != null ?
objectMapper.writeValueAsString(resp.getT()) :
resp.getErrorMessage();
- return new ResponseEntity<String>(httpMessage, HttpStatus.valueOf(resp.getHttpCode()));
+ return new ResponseEntity<>(httpMessage, HttpStatus.valueOf(resp.getHttpCode()));
}
@RequestMapping(value = "/aai_get_instance_groups_by_cloudregion/{cloudOwner}/{cloudRegionId}/{networkFunction}", method = RequestMethod.GET)
@@ -479,7 +465,7 @@ public class AaiController extends RestrictedBaseController {
String httpMessage = resp.getT() != null ?
objectMapper.writeValueAsString(resp.getT()) :
resp.getErrorMessage();
- return new ResponseEntity<String>(httpMessage, HttpStatus.valueOf(resp.getHttpCode()));
+ return new ResponseEntity<>(httpMessage, HttpStatus.valueOf(resp.getHttpCode()));
}
@RequestMapping(value = "/aai_get_by_uri/**", method = RequestMethod.GET)
@@ -518,16 +504,14 @@ public class AaiController extends RestrictedBaseController {
*/
@RequestMapping(value = "/aai_get_pnfs/pnf/{pnf_id}", method = RequestMethod.GET)
public ResponseEntity getSpecificPnf(@PathVariable("pnf_id") String pnfId) {
- //logger.trace(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), pnfId);
AaiResponse<Pnf> resp;
ResponseEntity<Pnf> re;
try {
resp = aaiService.getSpecificPnf(pnfId);
- re = new ResponseEntity<Pnf>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
+ re = new ResponseEntity<>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
} catch (Exception e){
return new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
- //logger.trace(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), resp.getHttpCode());
return re;
}
@@ -571,7 +555,7 @@ public class AaiController extends RestrictedBaseController {
@PathVariable("equipModel") String equipModel) {
AaiResponse<String> resp = aaiService.getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, equipModel);
- return new ResponseEntity<String>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
+ return new ResponseEntity<>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
}
@RequestMapping(value = "/aai_getPortMirroringConfigsData", method = RequestMethod.GET)
@@ -594,11 +578,10 @@ public class AaiController extends RestrictedBaseController {
private ResponseEntity<String> convertResponseToResponseEntity(Response resp) {
ResponseEntity<String> respEnt;
- ObjectMapper objectMapper = new ObjectMapper();
if (resp == null) {
- respEnt = new ResponseEntity<String>("Failed to fetch data from A&AI, check server logs for details.", HttpStatus.INTERNAL_SERVER_ERROR);
+ respEnt = new ResponseEntity<>("Failed to fetch data from A&AI, check server logs for details.", HttpStatus.INTERNAL_SERVER_ERROR);
} else {
- respEnt = new ResponseEntity<String>(resp.readEntity(String.class), HttpStatus.valueOf(resp.getStatus()));
+ respEnt = new ResponseEntity<>(resp.readEntity(String.class), HttpStatus.valueOf(resp.getStatus()));
}
return respEnt;
}
@@ -606,34 +589,20 @@ public class AaiController extends RestrictedBaseController {
/**
* Gets the subscribers.
*
- * @param isFullSet the is full set
* @return the subscribers
*/
- private Response getSubscribers(boolean isFullSet) {
+ private Response getSubscribers() {
String depth = "0";
Response resp = doAaiGet("business/customers?subscriber-type=INFRA&depth=" + depth, false);
if (resp != null) {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getSubscribers() resp=" + resp.getStatusInfo().toString());
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== getSubscribers() resp=" + resp.getStatusInfo().toString());
}
return resp;
}
/**
- * Gets the subscriber details.
- *
- * @param subscriberId the subscriber id
- * @return the subscriber details
- */
- private Response getSubscriberDetails(String subscriberId) {
- Response resp = doAaiGet("business/customers/customer/" + subscriberId + "?depth=2", false);
- //String resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers/customer/" + subscriberId, false);
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getSubscriberDetails() resp=" + resp.getStatusInfo().toString());
- return resp;
- }
-
- /**
* Send a GET request to a&ai.
*
* @param uri the uri
@@ -643,21 +612,21 @@ public class AaiController extends RestrictedBaseController {
protected Response doAaiGet(String uri, boolean xml) {
String methodName = "getSubscriberList";
String transId = UUID.randomUUID().toString();
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + " start");
Response resp = null;
try {
- resp = aaiRestInterface.RestGet(fromAppId, transId, uri, xml).getResponse();
+ resp = aaiRestInterface.RestGet(fromAppId, transId, Unchecked.toURI(uri), xml).getResponse();
} catch (WebApplicationException e) {
final String message = e.getResponse().readEntity(String.class);
- LOGGER.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + message);
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + message);
+ LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + "." + methodName + message);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + "." + methodName + message);
} catch (Exception e) {
- LOGGER.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + "." + methodName + e.toString());
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + "." + methodName + e.toString());
}
return resp;
@@ -673,8 +642,7 @@ public class AaiController extends RestrictedBaseController {
*/
protected Response doAaiPost(String uri, String payload, boolean xml) {
String methodName = "getSubscriberList";
- String transId = UUID.randomUUID().toString();
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + " start");
Response resp = null;
try {
@@ -682,8 +650,8 @@ public class AaiController extends RestrictedBaseController {
resp = aaiRestInterface.RestPost(fromAppId, uri, payload, xml);
} catch (Exception e) {
- LOGGER.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + "." + methodName + e.toString());
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + "." + methodName + e.toString());
}
return resp;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController2.java b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController2.java
new file mode 100644
index 0000000..ee28770
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController2.java
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * 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.onap.vid.controller;
+
+import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.vid.aai.model.Permissions;
+import org.onap.vid.model.aaiTree.RelatedVnf;
+import org.onap.vid.roles.RoleProvider;
+import org.onap.vid.services.AaiService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+/**
+ * Controller to handle a&ai new requests.
+ */
+
+@RestController
+public class AaiController2 extends VidRestrictedBaseController {
+
+ private final AaiService aaiService;
+ private final RoleProvider roleProvider;
+ private final AaiClientInterface aaiClient;
+
+ @Autowired
+ public AaiController2(AaiService aaiService, RoleProvider roleProvider, AaiClientInterface aaiClient) {
+ this.aaiService = aaiService;
+ this.roleProvider = roleProvider;
+ this.aaiClient = aaiClient;
+ }
+
+ @RequestMapping(value = "/aai_get_homing_by_vfmodule/{vnfInstanceId}/{vfModuleId}", method = RequestMethod.GET)
+ public GetTenantsResponse getHomingDataByVfModule(@PathVariable("vnfInstanceId") String vnfInstanceId,
+ @PathVariable("vfModuleId") String vfModuleId){
+ return aaiService.getHomingDataByVfModule(vnfInstanceId, vfModuleId);
+ }
+
+ @RequestMapping(value = "/aai_get_service_instance_topology/{subscriberId}/{serviceType}/{serviceInstanceId}",
+ method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public String getServiceInstanceTree(@PathVariable("subscriberId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceInstanceType,
+ @PathVariable("serviceInstanceId") String serviceInstanceId) {
+ return aaiService.getAAIServiceTree(globalCustomerId, serviceInstanceType, serviceInstanceId);
+ }
+
+ @RequestMapping(value = "/aai_reset_cache/{cacheName}", method = RequestMethod.DELETE)
+ @ResponseStatus(HttpStatus.ACCEPTED)
+ public void resetCache(@PathVariable("cacheName") String cacheName) {
+ aaiClient.resetCache(cacheName);
+ }
+
+ @RequestMapping(value = "/roles/service_permissions", method = RequestMethod.GET)
+ public Permissions servicePermissions(HttpServletRequest request,
+ @RequestParam(value = "subscriberId") String subscriberId,
+ @RequestParam(value = "serviceType") String serviceType) {
+
+ final boolean isEditPermitted = roleProvider
+ .getUserRolesValidator(request)
+ .isServicePermitted(subscriberId, serviceType);
+
+ return new Permissions(isEditPermitted);
+ }
+
+ @RequestMapping(value = "/aai_search_group_members",
+ method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public List<RelatedVnf> searchGroupMembers(@RequestParam("subscriberId") String globalCustomerId,
+ @RequestParam("serviceType") String serviceType,
+ @RequestParam("serviceInvariantId") String invariantId,
+ @RequestParam("groupType") String groupType,
+ @RequestParam("groupRole") String groupRole) {
+ return aaiService.searchGroupMembers(globalCustomerId, serviceType, invariantId, groupType, groupRole);
+ }
+
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryController.java
new file mode 100644
index 0000000..974ac98
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AaiServiceInstanceStandardQueryController.java
@@ -0,0 +1,173 @@
+package org.onap.vid.controller;
+
+
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Network;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.ServiceInstance;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Vlan;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Vnf;
+import org.onap.vid.aai.util.ServiceInstanceStandardQuery;
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.exceptions.GenericUncheckedException;
+import org.onap.vid.model.ServiceModel;
+import org.onap.vid.model.VidNotions;
+import org.onap.vid.properties.Features;
+import org.onap.vid.services.VidService;
+import org.onap.vid.utils.Multival;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.togglz.core.manager.FeatureManager;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.UUID;
+
+import static java.util.stream.Collectors.toList;
+
+
+@RestController
+@RequestMapping(AaiServiceInstanceStandardQueryController.AAI_STANDARD_QUERY)
+public class AaiServiceInstanceStandardQueryController extends VidRestrictedBaseController {
+
+ public static final String AAI_STANDARD_QUERY = "aai/standardQuery";
+
+ private final ServiceInstanceStandardQuery serviceInstanceStandardQuery;
+ private final FeatureManager featureManager;
+ private final VidService sdcService;
+
+ @Autowired
+ public AaiServiceInstanceStandardQueryController(FeatureManager featureManager, ServiceInstanceStandardQuery serviceInstanceStandardQuery, VidService sdcService) {
+ this.featureManager = featureManager;
+ this.serviceInstanceStandardQuery = serviceInstanceStandardQuery;
+ this.sdcService = sdcService;
+ }
+
+ @RequestMapping(value = "vlansByNetworks", method = RequestMethod.GET)
+ public VlansByNetworksHierarchy getNetworksToVlansByServiceInstance(HttpServletRequest request,
+ @RequestParam("sdcModelUuid") UUID sdcModelUuid,
+ @RequestParam("globalCustomerId") String globalCustomerId,
+ @RequestParam("serviceType") String serviceType,
+ @RequestParam("serviceInstanceId") String serviceInstanceId
+ ) throws AsdcCatalogException {
+ if (!featureManager.isActive(Features.FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS)) {
+ return new VlansByNetworksHierarchy();
+ }
+
+ if (!isModelOf5g(sdcModelUuid)) {
+ return new VlansByNetworksHierarchy();
+ }
+
+ final ServiceInstance serviceInstance =
+ serviceInstanceStandardQuery.fetchServiceInstance(globalCustomerId, serviceType, serviceInstanceId);
+
+ Multival<ServiceInstance, Multival<Vnf, Multival<Network, Vlan>>> l3NetworksWithVlansForVnfForService = fetchVnfsForService(serviceInstance);
+ Multival<ServiceInstance, Multival<Network, Vlan>> l3NetworksWithVlansForService = fetchNetworksForService(serviceInstance);
+
+ // translate to response's format
+ return new VlansByNetworksHierarchy(
+ l3NetworksWithVlansForService.getValues().stream().map(this::translateNetworksFormat
+ ).collect(toList()),
+
+ l3NetworksWithVlansForVnfForService.getValues().stream().map(vnfWithNetworks ->
+ new VnfVlansByNetworks(vnfWithNetworks.getKey().getVnfId(),
+ vnfWithNetworks.getValues().stream().map(this::translateNetworksFormat
+ ).collect(toList())
+ )
+ ).collect(toList())
+ );
+ }
+
+ private Multival<ServiceInstance, Multival<Vnf, Multival<Network, Vlan>>> fetchVnfsForService(ServiceInstance serviceInstance) {
+ final Multival<ServiceInstance, Vnf> vnfsForService =
+ serviceInstanceStandardQuery.fetchRelatedVnfs(serviceInstance);
+
+ final Multival<ServiceInstance, Multival<Vnf, Network>> vnfsWithL3NetworksForService =
+ vnfsForService.mapEachVal(vnf -> serviceInstanceStandardQuery.fetchRelatedL3Networks("vnf", vnf));
+
+ return vnfsWithL3NetworksForService.mapEachVal(vnfMulti->
+ vnfMulti.mapEachVal(serviceInstanceStandardQuery::fetchRelatedVlanTags)
+ );
+
+ }
+
+ private Multival<ServiceInstance, Multival<Network, Vlan>> fetchNetworksForService(ServiceInstance serviceInstance) {
+ final Multival<ServiceInstance, Network> l3NetworksForService =
+ serviceInstanceStandardQuery.fetchRelatedL3Networks("service", serviceInstance);
+
+ return l3NetworksForService.mapEachVal(serviceInstanceStandardQuery::fetchRelatedVlanTags);
+ }
+
+ private NetworksToVlans translateNetworksFormat(Multival<Network, Vlan> networkWithVlan) {
+ return new NetworksToVlans(
+ networkWithVlan.getKey().getNetworkId(),
+ networkWithVlan.getKey().getNetworkName(),
+ networkWithVlan.getKey().getNetworkType(),
+ networkWithVlan.getKey().getOrchestrationStatus(),
+ networkWithVlan.getValues().stream().map(
+ vlan -> new NetworksToVlans.Vlan(vlan.getVlanIdInner())
+ ).collect(toList())
+ );
+ }
+
+ protected boolean isModelOf5g(UUID sdcModelUuid) throws AsdcCatalogException {
+ final ServiceModel serviceModel = sdcService.getService(sdcModelUuid.toString());
+ if (serviceModel == null) {
+ throw new GenericUncheckedException("Internal error while fetching Service Model: " + sdcModelUuid);
+ }
+ VidNotions.ModelCategory serviceModelCategory = serviceModel.getService().getVidNotions().getModelCategory();
+ return serviceModelCategory.equals(VidNotions.ModelCategory.IS_5G_PROVIDER_NETWORK_MODEL) ||
+ serviceModelCategory.equals(VidNotions.ModelCategory.IS_5G_FABRIC_CONFIGURATION_MODEL);
+ }
+
+ protected static class VlansByNetworksHierarchy {
+ public final Collection<NetworksToVlans> serviceNetworks;
+ public final Collection<VnfVlansByNetworks> vnfNetworks;
+
+ public VlansByNetworksHierarchy() {
+ this(Collections.emptySet(), Collections.emptySet());
+ }
+
+ public VlansByNetworksHierarchy(Collection<NetworksToVlans> serviceNetworks, Collection<VnfVlansByNetworks> vnfNetworks) {
+ this.serviceNetworks = serviceNetworks;
+ this.vnfNetworks = vnfNetworks;
+ }
+ }
+
+ protected static class VnfVlansByNetworks {
+ public final String vnfId;
+ public final Collection<NetworksToVlans> networks;
+
+ public VnfVlansByNetworks(String vnfId, Collection<NetworksToVlans> networks) {
+ this.vnfId = vnfId;
+ this.networks = networks;
+ }
+ }
+
+ protected static class NetworksToVlans {
+ public final String networkId;
+ public final String name;
+ public final String nodeType;
+ public final String nodeStatus;
+ public final Collection<Vlan> vlans;
+
+ private NetworksToVlans(String networkId, String name, String nodeType, String nodeStatus, Collection<Vlan> vlans) {
+ this.networkId = networkId;
+ this.name = name;
+ this.nodeType = nodeType;
+ this.nodeStatus = nodeStatus;
+ this.vlans = vlans;
+ }
+
+ private static class Vlan {
+ public final String vlanIdInner;
+
+ private Vlan(String vlanIdInner) {
+ this.vlanIdInner = vlanIdInner;
+ }
+ }
+
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/AsyncControllerForTests.java b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncControllerForTests.java
index c4d8293..a67686a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/AsyncControllerForTests.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncControllerForTests.java
@@ -1,17 +1,14 @@
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.ExceptionResponse;
-import org.onap.vid.model.JobBulk;
import org.onap.vid.model.JobModel;
import org.onap.vid.services.BulkInstantiationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
-import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import javax.ws.rs.WebApplicationException;
-import java.util.Map;
import java.util.UUID;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
@@ -27,11 +24,6 @@ public class AsyncControllerForTests extends VidRestrictedBaseController {
this.bulkInstantiationService = bulkInstantiationService;
}
- @RequestMapping(method = RequestMethod.POST)
- public JobBulk createAsyncJob(@RequestBody Map<String, Object> body) {
- return bulkInstantiationService.saveBulk(body);
- }
-
@RequestMapping(value = "/job/{uuid}", method = RequestMethod.GET)
public JobModel getJob(@PathVariable UUID uuid) {
return bulkInstantiationService.getJob(uuid);
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/AsyncInstantiationController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
index c5621a3..dcfc13b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/AsyncInstantiationController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
@@ -1,22 +1,23 @@
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.exceptions.OperationNotAllowedException;
import org.onap.vid.model.ExceptionResponse;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.exception.ExceptionUtils;
-
import org.onap.vid.model.JobAuditStatus;
import org.onap.vid.model.ServiceInfo;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
import org.onap.vid.mso.MsoResponseWrapper2;
import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+import org.onap.vid.services.AuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.UUID;
+
import static org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED;
@@ -28,6 +29,11 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
protected final AsyncInstantiationBusinessLogic asyncInstantiationBL;
+ protected ObjectMapper objectMapper = new ObjectMapper();
+
+ @Autowired
+ protected AuditService auditService;
+
@Autowired
public AsyncInstantiationController(AsyncInstantiationBusinessLogic asyncInstantiationBL) {
this.asyncInstantiationBL = asyncInstantiationBL;
@@ -52,7 +58,12 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
@RequestMapping(value = "bulk", method = RequestMethod.POST)
public MsoResponseWrapper2<List<String>> createBulkOfServices(@RequestBody ServiceInstantiation request, HttpServletRequest httpServletRequest) {
//Push to DB according the model
-
+ try {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "incoming ServiceInstantiation request: "+ objectMapper.writeValueAsString(request));
+ }
+ catch (Exception e) {
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "failed to log incoming ServiceInstantiation request ", e);
+ }
String userId = ControllersUtils.extractUserId(httpServletRequest);
List<UUID> uuids = asyncInstantiationBL.pushBulkJob(request, userId);
@@ -74,5 +85,20 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
return asyncInstantiationBL.getAuditStatuses(jobId, source);
}
+ @RequestMapping(value = "auditStatus/{jobId}/mso", method = RequestMethod.GET)
+ public List<JobAuditStatus> getJobMsoAuditStatusForAlaCarte(HttpServletRequest request,
+ @PathVariable(value="jobId") UUID jobId,
+ @RequestParam(value="requestId", required = false) UUID requestId,
+ @RequestParam(value="serviceInstanceId", required = false) UUID serviceInstanceId){
+ if (serviceInstanceId != null) {
+ return auditService.getAuditStatusFromMsoByServiceInstanceId(jobId, serviceInstanceId);
+ }
+ if (requestId != null){
+ return auditService.getAuditStatusFromMsoByRequestId(jobId, requestId);
+ }
+ return auditService.getAuditStatusFromMsoByJobId(jobId);
+
+ }
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/ChangeManagementController.java b/vid-app-common/src/main/java/org/onap/vid/controller/ChangeManagementController.java
index 88875b5..90a175f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/ChangeManagementController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/ChangeManagementController.java
@@ -20,29 +20,15 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.controllers;
-
-import static org.onap.vid.utils.Logging.getMethodName;
-import static org.springframework.http.HttpStatus.BAD_REQUEST;
-import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
-import static org.springframework.http.HttpStatus.OK;
+package org.onap.vid.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
-import java.util.Collection;
-import java.util.Collections;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.WebApplicationException;
+import com.fasterxml.jackson.databind.node.ArrayNode;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.commons.lang3.tuple.Pair;
-import org.json.simple.JSONArray;
import org.onap.portalsdk.core.controller.UnRestrictedBaseController;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.changeManagement.ChangeManagementRequest;
-import org.onap.vid.changeManagement.GetVnfWorkflowRelationRequest;
-import org.onap.vid.changeManagement.GetWorkflowsResponse;
-import org.onap.vid.changeManagement.VnfWorkflowRelationAllResponse;
-import org.onap.vid.changeManagement.VnfWorkflowRelationRequest;
-import org.onap.vid.changeManagement.VnfWorkflowRelationResponse;
+import org.onap.vid.changeManagement.*;
import org.onap.vid.exceptions.NotFoundException;
import org.onap.vid.model.ExceptionResponse;
import org.onap.vid.model.MsoExceptionResponse;
@@ -54,18 +40,17 @@ import org.onap.vid.services.WorkflowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RequestPart;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.WebApplicationException;
+import java.util.Collection;
+import java.util.Collections;
+
+import static org.onap.vid.utils.Logging.getMethodName;
+import static org.springframework.http.HttpStatus.*;
+
/**
* Controller to handle ChangeManagement feature requests.
*/
@@ -105,7 +90,8 @@ public class ChangeManagementController extends UnRestrictedBaseController {
}
@RequestMapping(value = "/workflow/{vnfName}", method = RequestMethod.POST)
- public ResponseEntity<String> changeManagement(HttpServletRequest request, @PathVariable("vnfName") String vnfName,
+ public ResponseEntity<String> changeManagement(HttpServletRequest request,
+ @PathVariable("vnfName") String vnfName,
@RequestBody ChangeManagementRequest changeManagmentRequest)
throws Exception {
return this.changeManagementService.doChangeManagement(changeManagmentRequest, vnfName);
@@ -128,8 +114,8 @@ public class ChangeManagementController extends UnRestrictedBaseController {
@RequestMapping(value = {"/scheduler"}, method = RequestMethod.GET)
- public ResponseEntity<JSONArray> getSchedulerChangeManagements() {
- JSONArray result = this.changeManagementService.getSchedulerChangeManagements();
+ public ResponseEntity<ArrayNode> getSchedulerChangeManagements() {
+ ArrayNode result = this.changeManagementService.getSchedulerChangeManagements();
return new ResponseEntity<>(result, OK);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/ControllersUtils.java b/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java
index 1abe300..9be6ad5 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/ControllersUtils.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java
@@ -1,19 +1,17 @@
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.onap.portalsdk.core.domain.User;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.model.ExceptionResponse;
-import org.slf4j.MDC;
import org.springframework.http.ResponseEntity;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.WebApplicationException;
-import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
-import static org.onap.vid.utils.Logging.getMethodName;
+import static org.onap.vid.utils.Logging.getMethodCallerName;
public class ControllersUtils {
@@ -34,7 +32,7 @@ public class ControllersUtils {
}
public static ExceptionResponse handleException(Exception e, EELFLoggerDelegate logger) {
- logger.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodName(), ExceptionUtils.getMessage(e), e);
+ logger.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodCallerName(), ExceptionUtils.getMessage(e), e);
ExceptionResponse exceptionResponse = new ExceptionResponse(e);
return exceptionResponse;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/FeatureTogglingController.java b/vid-app-common/src/main/java/org/onap/vid/controller/FeatureTogglingController.java
index 36dfdaa..a90e71d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/FeatureTogglingController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/FeatureTogglingController.java
@@ -1,7 +1,7 @@
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
-import org.onap.vid.properties.Features;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.vid.properties.Features;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -18,7 +18,7 @@ public class FeatureTogglingController extends RestrictedBaseController {
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Map<String,Boolean> getFeatureToggles()
{
- HashMap<String,Boolean> flags = new HashMap <String, Boolean>();
+ HashMap<String,Boolean> flags = new HashMap <>();
for(Features flag : Features.values()){
flags.put(flag.name(), flag.isActive());
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java b/vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java
index 86e832b..2c42da2 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthCheckController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
import org.onap.portalsdk.core.controller.UnRestrictedBaseController;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthStatus.java b/vid-app-common/src/main/java/org/onap/vid/controller/HealthStatus.java
index 6056c28..14372b5 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/HealthStatus.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/HealthStatus.java
@@ -1,4 +1,4 @@
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
import org.springframework.http.HttpStatus;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/LoggerController.java b/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java
index 14d0272..698ea54 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/LoggerController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java
@@ -1,4 +1,4 @@
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.Appender;
@@ -109,7 +109,7 @@ public class LoggerController extends RestrictedBaseController {
@ExceptionHandler({ IOException.class, InternalServerErrorException.class })
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ExceptionResponse ioExceptionHandler(Exception e) {
- return org.onap.vid.controllers.ControllersUtils.handleException(e, LOGGER);
+ return ControllersUtils.handleException(e, LOGGER);
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/MaintenanceController.java b/vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java
index 1a3eb42..40b7834 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/MaintenanceController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java
@@ -1,4 +1,4 @@
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
/*-
* ============LICENSE_START=======================================================
@@ -22,9 +22,6 @@ package org.onap.vid.controllers;
* ============LICENSE_END=========================================================
*/
-import static org.onap.vid.utils.Logging.getMethodCallerName;
-
-import javax.ws.rs.ForbiddenException;
import org.onap.portalsdk.core.controller.UnRestrictedBaseController;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.category.AddCategoryOptionResponse;
@@ -38,12 +35,11 @@ import org.onap.vid.services.CategoryParameterServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.ws.rs.ForbiddenException;
+
+import static org.onap.vid.utils.Logging.getMethodCallerName;
/**
* Controler for APIs that are used only by vid operators
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/MsoConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
index 020018a..7f90d6a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/MsoConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
@@ -18,11 +18,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import io.joshworks.restclient.http.mapper.ObjectMapper;
import org.onap.portalsdk.core.util.SystemProperties;
-
+import org.onap.vid.aai.AaiClientInterface;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.factories.MsoRequestFactory;
import org.onap.vid.mso.MsoBusinessLogic;
@@ -30,6 +30,8 @@ import org.onap.vid.mso.MsoBusinessLogicImpl;
import org.onap.vid.mso.MsoInterface;
import org.onap.vid.mso.MsoProperties;
import org.onap.vid.mso.rest.MsoRestClientNew;
+import org.onap.vid.services.CloudOwnerService;
+import org.onap.vid.services.CloudOwnerServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.togglz.core.manager.FeatureManager;
@@ -38,24 +40,15 @@ import org.togglz.core.manager.FeatureManager;
@Configuration
public class MsoConfig {
- /**
- * Gets the object mapper.
- *
- * @return the object mapper
- */
- @Bean
- public ObjectMapper getObjectMapper() {
- return new ObjectMapper();
- }
-
@Bean
public MsoRequestFactory createRequestDetailsFactory(){
return new MsoRequestFactory();
}
@Bean
- public MsoInterface getMsoClient(){
- return new MsoRestClientNew(new SyncRestClient(MsoInterface.objectMapper()), SystemProperties.getProperty(
+ public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper){
+ // Satisfy both interfaces -- MsoInterface and RestMsoImplementation
+ return new MsoRestClientNew(new SyncRestClient(unirestObjectMapper), SystemProperties.getProperty(
MsoProperties.MSO_SERVER_URL));
}
@@ -64,5 +57,10 @@ public class MsoConfig {
return new MsoBusinessLogicImpl(msoClient, featureManager);
}
+ @Bean
+ public CloudOwnerService cloudOwnerService(AaiClientInterface aaiClient, FeatureManager featureManager) {
+ return new CloudOwnerServiceImpl(aaiClient, featureManager);
+ }
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/MsoController.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
index 62c64b7..716267a 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/MsoController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,19 +18,22 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.model.ExceptionResponse;
+import org.onap.vid.model.SoftDeleteRequest;
import org.onap.vid.mso.MsoBusinessLogic;
import org.onap.vid.mso.MsoResponseWrapper;
+import org.onap.vid.mso.MsoResponseWrapper2;
import org.onap.vid.mso.rest.Request;
import org.onap.vid.mso.rest.RequestDetails;
import org.onap.vid.mso.rest.RequestDetailsWrapper;
import org.onap.vid.mso.rest.Task;
-import org.onap.portalsdk.core.controller.RestrictedBaseController;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.services.CloudOwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -39,20 +42,11 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import static org.onap.vid.utils.Logging.getMethodName;
-//import java.util.UUID;
-//import org.springframework.http.ResponseEntity;
-//import org.springframework.http.RequestEntity;
-
/**
* The Class MsoController.
*/
@@ -66,31 +60,29 @@ public class MsoController extends RestrictedBaseController {
private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MsoController.class);
/**
- * The Constant dateFormat.
- */
- private final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
-
- /**
* The Constant SVC_INSTANCE_ID.
*/
- public final static String SVC_INSTANCE_ID = "<service_instance_id>";
- public final static String REQUEST_TYPE = "<request_type>";
+ public static final String SVC_INSTANCE_ID = "<service_instance_id>";
+ public static final String REQUEST_TYPE = "<request_type>";
/**
* The Constant CONFIGURATION_ID
*/
- public final static String CONFIGURATION_ID = "<configuration_id>";
+ public static final String CONFIGURATION_ID = "<configuration_id>";
/**
* The Constant VNF_INSTANCE_ID.
*/
- public final static String VNF_INSTANCE_ID = "<vnf_instance_id>";
+ public static final String VNF_INSTANCE_ID = "<vnf_instance_id>";
+ public static final String START_LOG = " start";
private final MsoBusinessLogic msoBusinessLogic;
+ private final CloudOwnerService cloudOwnerService;
@Autowired
- public MsoController(MsoBusinessLogic msoBusinessLogic) {
+ public MsoController(MsoBusinessLogic msoBusinessLogic, CloudOwnerService cloudOwnerService) {
this.msoBusinessLogic = msoBusinessLogic;
+ this.cloudOwnerService = cloudOwnerService;
}
/**
@@ -101,19 +93,20 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
- public ResponseEntity<String> createSvcInstance(HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ public ResponseEntity<String> createSvcInstance(HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
String methodName = "createSvcInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
// always return OK, the MSO status code is embedded in the body
- MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(mso_request);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(msoRequest);
return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
}
-
+
/**
* Creates the e2e svc instance.
*
@@ -122,14 +115,15 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_create_e2e_svc_instance", method = RequestMethod.POST)
- public ResponseEntity<String> createE2eSvcInstance(HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> mso_request) {
+ public ResponseEntity<String> createE2eSvcInstance(HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> msoRequest) {
String methodName = "createE2eSvcInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
// always return OK, the MSO status code is embedded in the body
- MsoResponseWrapper w = msoBusinessLogic.createE2eSvcInstance(mso_request.get("requestDetails"));
+ //cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.createE2eSvcInstance(msoRequest.get("requestDetails"));
return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
@@ -144,9 +138,10 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_create_vnf_instance/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
- MsoResponseWrapper w = msoBusinessLogic.createVnf(mso_request, serviceInstanceId);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.createVnf(msoRequest, serviceInstanceId);
// always return OK, the MSO status code is embedded in the body
@@ -163,11 +158,12 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_create_nw_instance/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
String methodName = "createNwInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
- MsoResponseWrapper w = msoBusinessLogic.createNwInstance(mso_request, serviceInstanceId);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.createNwInstance(msoRequest, serviceInstanceId);
return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
@@ -184,11 +180,12 @@ public class MsoController extends RestrictedBaseController {
*/
@RequestMapping(value = "/mso_create_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
public ResponseEntity<String> createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
- HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
String methodName = "createVolumeGroupInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
- MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId);
// always return OK, the MSO status code is embedded in the body
return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
@@ -205,12 +202,13 @@ public class MsoController extends RestrictedBaseController {
*/
@RequestMapping(value = "/mso_create_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
public ResponseEntity<String> createVfModuleInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
String methodName = "createVfModuleInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
- MsoResponseWrapper w = msoBusinessLogic.createVfModuleInstance(mso_request, serviceInstanceId, vnfInstanceId);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.createVfModuleInstance(msoRequest, serviceInstanceId, vnfInstanceId);
// always return OK, the MSO status code is embedded in the body
@@ -227,11 +225,12 @@ public class MsoController extends RestrictedBaseController {
*/
@RequestMapping(value = "/mso_create_configuration_instance/{serviceInstanceId}/configurations/", method = RequestMethod.POST)
public ResponseEntity<String> createConfigurationInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- HttpServletRequest request, @RequestBody RequestDetailsWrapper mso_request) {
+ HttpServletRequest request, @RequestBody RequestDetailsWrapper msoRequest) {
String methodName = "createConfigurationInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
- MsoResponseWrapper w = msoBusinessLogic.createConfigurationInstance(mso_request, serviceInstanceId);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest.getRequestDetails());
+ MsoResponseWrapper w = msoBusinessLogic.createConfigurationInstance(msoRequest, serviceInstanceId);
// always return OK, the MSO status code is embedded in the body
@@ -248,20 +247,16 @@ public class MsoController extends RestrictedBaseController {
*/
@RequestMapping(value = "/mso_delete_e2e_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
public ResponseEntity<String> deleteE2eSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> mso_request) {
-
- String methodName = "deleteE2eSvcInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), mso_request);
+ HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> msoRequest) {
- MsoResponseWrapper w = msoBusinessLogic.deleteE2eSvcInstance(mso_request.get("requestDetails"), serviceInstanceId);
-
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.deleteE2eSvcInstance(msoRequest.get("requestDetails"), serviceInstanceId);
// always return OK, the MSO status code is embedded in the body
return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
}
-
+
/**
* Delete svc instance.
*
@@ -273,12 +268,11 @@ public class MsoController extends RestrictedBaseController {
@RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
public String deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- HttpServletRequest request, @RequestBody RequestDetails mso_request,
- @RequestParam(value = "serviceStatus") String serviceStatus) {
+ HttpServletRequest request, @RequestBody RequestDetails msoRequest,
+ @RequestParam(value = "serviceStatus") String serviceStatus) {
- String methodName = "deleteSvcInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), mso_request);
- MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(mso_request, serviceInstanceId, serviceStatus);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(msoRequest, serviceInstanceId, serviceStatus);
// always return OK, the MSO status code is embedded in the body
return w.getResponse();
@@ -296,12 +290,12 @@ public class MsoController extends RestrictedBaseController {
@RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
- HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
String methodName = "deleteVnf";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
-
- MsoResponseWrapper w = msoBusinessLogic.deleteVnf(mso_request, serviceInstanceId, vnfInstanceId);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.deleteVnf(msoRequest, serviceInstanceId, vnfInstanceId);
// always return OK, the MSO status code is embedded in the body
return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
@@ -312,7 +306,7 @@ public class MsoController extends RestrictedBaseController {
* Delete configuration instance
* @param serviceInstanceId the service instance id
* @param configurationId the configuration id
- * @param mso_request the request
+ * @param msoRequest the request
* @return the response entity
* @throws Exception the exception
*/
@@ -321,13 +315,14 @@ public class MsoController extends RestrictedBaseController {
public ResponseEntity<String> deleteConfiguration(
@PathVariable("serviceInstanceId") String serviceInstanceId,
@PathVariable ("configurationId") String configurationId,
- @RequestBody RequestDetailsWrapper mso_request) {
+ @RequestBody RequestDetailsWrapper msoRequest) {
String methodName = "deleteConfiguration";
LOGGER.debug(EELFLoggerDelegate.debugLogger,
- dateFormat.format(new Date()) + "<== " + methodName + " start");
+ "<== " + methodName + START_LOG);
- MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(mso_request, serviceInstanceId, configurationId);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest.getRequestDetails());
+ MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(msoRequest, serviceInstanceId, configurationId);
// always return OK, the MSO status code is embedded in the body
return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
@@ -337,7 +332,7 @@ public class MsoController extends RestrictedBaseController {
* Activate configuration instance
* @param serviceInstanceId the service instace id
* @param configurationId the configuration id
- * @param mso_request the request
+ * @param msoRequest the request
* @return the response entity
* @throws Exception the exception
*/
@@ -346,9 +341,10 @@ public class MsoController extends RestrictedBaseController {
public ResponseEntity<String> activateConfiguration(
@PathVariable("serviceInstanceId") String serviceInstanceId,
@PathVariable("configurationId") String configurationId,
- @RequestBody RequestDetails mso_request) {
+ @RequestBody RequestDetails msoRequest) {
- MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, true);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, true);
// always return OK, the MSO status code is embedded in the body
return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
@@ -358,7 +354,7 @@ public class MsoController extends RestrictedBaseController {
* Deactivate configuration instance
* @param serviceInstanceId the service instace id
* @param configurationId the configuration id
- * @param mso_request the request
+ * @param msoRequest the request
* @return the response entity
* @throws Exception the exception
*/
@@ -367,9 +363,10 @@ public class MsoController extends RestrictedBaseController {
public ResponseEntity<String> deactivateConfiguration(
@PathVariable("serviceInstanceId") String serviceInstanceId,
@PathVariable("configurationId") String configurationId,
- @RequestBody RequestDetails mso_request) {
+ @RequestBody RequestDetails msoRequest) {
- MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, false);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, false);
// always return OK, the MSO status code is embedded in the body
return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
@@ -379,7 +376,7 @@ public class MsoController extends RestrictedBaseController {
* Disable port on configuration instance
* @param serviceInstanceId the service instance id
* @param configurationId the configuration instance id
- * @param mso_request the request
+ * @param msoRequest the request
* @return the response entity
* @throws Exception the exception
*/
@@ -388,9 +385,10 @@ public class MsoController extends RestrictedBaseController {
public ResponseEntity<String> disablePortOnConfiguration(
@PathVariable("serviceInstanceId") String serviceInstanceId,
@PathVariable("configurationId") String configurationId,
- @RequestBody RequestDetails mso_request) {
+ @RequestBody RequestDetails msoRequest) {
- MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, false);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, false);
// always return OK, the MSO status code is embedded in the body
return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
@@ -400,7 +398,7 @@ public class MsoController extends RestrictedBaseController {
* Enable port on configuration instance
* @param serviceInstanceId the service instance id
* @param configurationId the configuration instance id
- * @param mso_request the request
+ * @param msoRequest the request
* @return the response entity
* @throws Exception the exception
*/
@@ -409,9 +407,10 @@ public class MsoController extends RestrictedBaseController {
public ResponseEntity<String> enablePortOnConfiguration(
@PathVariable("serviceInstanceId") String serviceInstanceId,
@PathVariable("configurationId") String configurationId,
- @RequestBody RequestDetails mso_request) {
+ @RequestBody RequestDetails msoRequest) {
- MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, true);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, true);
// always return OK, the MSO status code is embedded in the body
return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
@@ -431,12 +430,13 @@ public class MsoController extends RestrictedBaseController {
@RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
public ResponseEntity<String> deleteVfModule(
@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
- @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
String methodName = "deleteVfModule";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
- MsoResponseWrapper w = msoBusinessLogic.deleteVfModule(mso_request, serviceInstanceId, vnfInstanceId, vfModuleId);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.deleteVfModule(msoRequest, serviceInstanceId, vnfInstanceId, vfModuleId);
// always return OK, the MSO status code is embedded in the body
return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
@@ -455,11 +455,12 @@ public class MsoController extends RestrictedBaseController {
@RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
public ResponseEntity<String> deleteVolumeGroupInstance(
@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
- HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
String methodName = "deleteVolumeGroupInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
- MsoResponseWrapper w = msoBusinessLogic.deleteVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId, volumeGroupId);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.deleteVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId, volumeGroupId);
// always return OK, the MSO status code is embedded in the body
return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
@@ -476,11 +477,12 @@ public class MsoController extends RestrictedBaseController {
*/
@RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request, @RequestBody RequestDetails mso_request) {
+ @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
String methodName = "deleteNwInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
- MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(mso_request, serviceInstanceId, networkInstanceId);
+ cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
+ MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(msoRequest, serviceInstanceId, networkInstanceId);
// always return OK, the MSO status code is embedded in the body
return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
@@ -499,7 +501,7 @@ public class MsoController extends RestrictedBaseController {
HttpServletRequest request) {
String methodName = "getOrchestrationRequest";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
@@ -521,7 +523,7 @@ public class MsoController extends RestrictedBaseController {
HttpServletRequest request) {
String methodName = "getOrchestrationRequests";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
@@ -541,7 +543,7 @@ public class MsoController extends RestrictedBaseController {
@RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) {
String methodName = "activateServiceInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
@@ -558,7 +560,7 @@ public class MsoController extends RestrictedBaseController {
@RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) {
String methodName = "deactivateServiceInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
@@ -574,7 +576,7 @@ public class MsoController extends RestrictedBaseController {
public List<Request> getOrchestrationRequestsForDashboard() {
String methodName = "getOrchestrationRequestsForDashboard";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
return msoBusinessLogic.getOrchestrationRequestsForDashboard();
@@ -591,7 +593,7 @@ public class MsoController extends RestrictedBaseController {
public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) {
String methodName = "getManualTasksByRequestId";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
}
@@ -608,10 +610,10 @@ public class MsoController extends RestrictedBaseController {
public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId , @RequestBody RequestDetails requestDetails) {
String methodName = "manualTaskComplete";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
- return new ResponseEntity<String>(w.getResponse(), HttpStatus.OK);
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
@RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
@@ -619,7 +621,7 @@ public class MsoController extends RestrictedBaseController {
@RequestBody RequestDetails requestDetails) {
String methodName = "removeRelationshipFromServiceInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
MsoResponseWrapper w;
try {
@@ -633,10 +635,10 @@ public class MsoController extends RestrictedBaseController {
@RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
public ResponseEntity<String> addRelationshipToServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
- @RequestBody RequestDetails requestDetails) {
+ @RequestBody RequestDetails requestDetails) {
String methodName = "addRelationshipToServiceInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
MsoResponseWrapper w;
try {
@@ -648,6 +650,34 @@ public class MsoController extends RestrictedBaseController {
return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
+ @RequestMapping(value = "/mso_activate_fabric_configuration/{serviceInstanceId}", method = RequestMethod.POST)
+ public MsoResponseWrapper2 activateFabricConfiguration(
+ @PathVariable("serviceInstanceId") String serviceInstanceId ,
+ @RequestBody RequestDetails requestDetails) {
+
+ String methodName = "activateFabricConfiguration";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
+
+ return msoBusinessLogic.activateFabricConfiguration(serviceInstanceId, requestDetails);
+ }
+
+ @RequestMapping(value = "/mso_vfmodule_soft_delete/{serviceInstanceId}/{vnfInstanceId}/{vfModuleInstanceId}", method = RequestMethod.POST)
+ public MsoResponseWrapper2 deactivateAndCloudDelete(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("vnfInstanceId") String vnfInstanceId,
+ @PathVariable("vfModuleInstanceId") String vfModuleInstanceId,
+ @RequestBody SoftDeleteRequest softDeleteRequest) {
+
+ String methodName = "deactivateAndCloudDelete";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
+
+ RequestDetails requestDetails = msoBusinessLogic.buildRequestDetailsForSoftDelete(softDeleteRequest);
+
+ cloudOwnerService.enrichRequestWithCloudOwner(requestDetails);
+ return msoBusinessLogic.deactivateAndCloudDelete(serviceInstanceId, vnfInstanceId, vfModuleInstanceId, requestDetails);
+ }
+
+
/**
* Exception handler.
*
@@ -658,25 +688,7 @@ public class MsoController extends RestrictedBaseController {
@ExceptionHandler(Exception.class)
private void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
- /*
- * The following "logger.error" lines "should" be sufficient for logging the exception.
- * However, the console output in my Eclipse environment is NOT showing ANY of the
- * logger statements in this class. Thus the temporary "e.printStackTrace" statement
- * is also included.
- */
-
- String methodName = "exceptionHandler";
- LOGGER.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- LOGGER.error(EELFLoggerDelegate.errorLogger, sw.toString());
-
- /*
- * Temporary - IF the above mentioned "logger.error" glitch is resolved ...
- * this statement could be removed since it would then likely result in duplicate
- * trace output.
- */
- e.printStackTrace(System.err);
+ ControllersUtils.handleException(e, LOGGER);
response.setContentType("application/json; charset=UTF-8");
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/OperationalEnvironmentController.java b/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java
index 6a4527c..21aef68 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/OperationalEnvironmentController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java
@@ -18,15 +18,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import io.joshworks.restclient.http.HttpResponse;
-import java.util.HashMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.model.ExceptionResponse;
import org.onap.vid.model.RequestReferencesContainer;
@@ -37,13 +37,13 @@ import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails;
import org.onap.vid.mso.rest.RequestDetails;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
@@ -61,7 +61,7 @@ public class OperationalEnvironmentController extends VidRestrictedBaseControlle
private final MsoInterface restMso;
private final MsoBusinessLogic msoBusinessLogic;
- private static final Pattern RECOVERY_ACTION_MESSAGE_PATTERN = Pattern.compile("String value \'(.*)\': value not");
+ private static final Pattern RECOVERY_ACTION_MESSAGE_PATTERN = Pattern.compile("from String \"(.*)\": value not");
@Autowired
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/ProbeController.java b/vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.java
index a2145de..1324ebb 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/ProbeController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/ProbeController.java
@@ -1,8 +1,11 @@
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.vid.aai.AaiClient;
import org.onap.vid.model.probes.ExternalComponentStatus;
-import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.vid.mso.MsoBusinessLogic;
+import org.onap.vid.scheduler.SchedulerService;
+import org.onap.vid.services.VidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -14,13 +17,25 @@ import java.util.List;
@RestController
@RequestMapping("probe")
public class ProbeController extends RestrictedBaseController {
+
+ private final AaiClient aaiClient;
+ private final VidService vidService;
+ private final MsoBusinessLogic msoBusinessLogic;
+ private final SchedulerService schedulerService;
+
@Autowired
- private AaiClient aaiClient;
+ public ProbeController(AaiClient aaiClient, VidService vidService, MsoBusinessLogic msoBusinessLogic, SchedulerService schedulerService) {
+ this.aaiClient = aaiClient;
+ this.vidService = vidService;
+ this.msoBusinessLogic = msoBusinessLogic;
+ this.schedulerService = schedulerService;
+ }
@RequestMapping(method= RequestMethod.GET)
- public List<ExternalComponentStatus> getProbe(){
+ public List<ExternalComponentStatus> getProbe() {
List<ExternalComponentStatus> componentStatuses = new ArrayList<>();
componentStatuses.add(aaiClient.probeAaiGetAllSubscribers());
+ componentStatuses.add(schedulerService.probeGetSchedulerChangeManagements());
return componentStatuses;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/PropertyController.java b/vid-app-common/src/main/java/org/onap/vid/controller/PropertyController.java
index 2c82386..2f8d6e2 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/PropertyController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/PropertyController.java
@@ -18,14 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
-import org.onap.vid.category.CategoryParametersResponse;
-import org.onap.vid.model.CategoryParameter.Family;
-import org.onap.vid.services.CategoryParameterService;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.category.CategoryParametersResponse;
+import org.onap.vid.model.CategoryParameter.Family;
+import org.onap.vid.services.CategoryParameterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -33,9 +33,6 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
import static org.onap.vid.utils.Logging.getMethodName;
@@ -48,9 +45,6 @@ public class PropertyController extends RestrictedBaseController{
/** The logger. */
private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(PropertyController.class);
-
- /** The Constant dateFormat. */
- final protected static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
@Autowired
protected CategoryParameterService categoryParameterService;
@@ -64,7 +58,7 @@ public class PropertyController extends RestrictedBaseController{
*/
@RequestMapping(value = {"/propertyhome" }, method = RequestMethod.GET)
public ModelAndView welcome(HttpServletRequest request) {
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== PropertyController welcome start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== PropertyController welcome start");
return new ModelAndView(getViewName());
}
@@ -84,7 +78,7 @@ public class PropertyController extends RestrictedBaseController{
String methodName = "getProperty";
ResponseEntity<String> resp = null;
String pvalue = null;
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + " start");
try {
// convert "_" to "." in the property name
@@ -97,14 +91,14 @@ public class PropertyController extends RestrictedBaseController{
if ( ( pvalue == null ) || ( pvalue.length() == 0 ) ) {
pvalue = defaultvalue;
}
- resp = new ResponseEntity<String>(pvalue, HttpStatus.OK);
+ resp = new ResponseEntity<>(pvalue, HttpStatus.OK);
}
catch (Exception e) {
- LOGGER.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ LOGGER.info(EELFLoggerDelegate.errorLogger, "<== " + "." + methodName + e.toString());
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + "." + methodName + e.toString());
throw e;
}
- LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " returning " + pvalue);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + " returning " + pvalue);
return ( resp );
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/RoleGeneratorController.java b/vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java
index dd6388d..78f1e37 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/RoleGeneratorController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java
@@ -1,7 +1,7 @@
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
-import org.onap.vid.services.RoleGeneratorService;
import org.onap.portalsdk.core.controller.UnRestrictedBaseController;
+import org.onap.vid.services.RoleGeneratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -19,7 +19,7 @@ public class RoleGeneratorController extends UnRestrictedBaseController {
public ResponseEntity<String> generateRoleScript (@PathVariable("firstRun") boolean firstRun) {
ResponseEntity<String> response = null;
String query = roleGeneratorService.generateRoleScript(firstRun);
- response = new ResponseEntity<String>(query, HttpStatus.OK);
+ response = new ResponseEntity<>(query, HttpStatus.OK);
return response;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/VersionController.java b/vid-app-common/src/main/java/org/onap/vid/controller/VersionController.java
new file mode 100644
index 0000000..ba879ed
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/VersionController.java
@@ -0,0 +1,63 @@
+package org.onap.vid.controller;
+
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableMap;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.portalsdk.core.controller.UnRestrictedBaseController;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.inject.Inject;
+import javax.servlet.ServletContext;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static org.apache.commons.lang3.StringUtils.substringAfterLast;
+
+@RestController
+@RequestMapping("version")
+public class VersionController extends UnRestrictedBaseController {
+
+ private final ServletContext servletContext;
+
+ @Inject
+ public VersionController(ServletContext servletContext) {
+ this.servletContext = servletContext;
+ }
+
+ @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public Map<String,String> getVersionAndFeatures()
+ {
+ String features = SystemProperties.getProperty("features.set.filename");
+ String version;
+ try {
+ final URL resource = servletContext.getResource("/app/vid/scripts/constants/version.json");
+ HashMap<String,String> versionFile = new HashMap <>();
+ ObjectMapper mapper = new ObjectMapper();
+ versionFile.putAll(mapper.readValue(resource, new TypeReference<HashMap<String, String>>() {}));
+ version = versionFile.get("Version");
+ } catch (IOException e) {
+ version = "Error retrieving build number";
+ }
+ String majorVersion = getDisplayVersion(features, version);
+ return ImmutableMap.of("Features", features, "Build", version, "DisplayVersion", majorVersion);
+ }
+
+ String getDisplayVersion(String features, String build) {
+ Matcher matcher = Pattern.compile("([^/]+?)(\\.features|$)").matcher(features);
+ final String majorByFeatures = matcher.find() ? matcher.group(1) : features;
+
+ final String buildByVersion = StringUtils.defaultIfBlank(substringAfterLast(build, "."), build);
+
+ return StringUtils.join(majorByFeatures, ".", buildByVersion);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/VidController.java b/vid-app-common/src/main/java/org/onap/vid/controller/VidController.java
index b9d67b6..40d0f46 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/VidController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/VidController.java
@@ -20,8 +20,10 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.asdc.beans.SecureServices;
import org.onap.vid.exceptions.VidServiceUnavailableException;
@@ -32,8 +34,6 @@ import org.onap.vid.roles.RoleProvider;
import org.onap.vid.services.AaiService;
import org.onap.vid.services.PombaService;
import org.onap.vid.services.VidService;
-import org.onap.portalsdk.core.controller.RestrictedBaseController;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/VidRestrictedBaseController.java b/vid-app-common/src/main/java/org/onap/vid/controller/VidRestrictedBaseController.java
index b520bc0..e13cf45 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/VidRestrictedBaseController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/VidRestrictedBaseController.java
@@ -1,10 +1,10 @@
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
-import org.onap.vid.model.ExceptionResponse;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.model.ExceptionResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
@@ -31,8 +31,7 @@ public abstract class VidRestrictedBaseController extends RestrictedBaseControll
else {
message = "The parameter " + e.getName() + " must be of type " + type.getTypeName();
}
- ResponseEntity response = new ResponseEntity<String>(message, HttpStatus.BAD_REQUEST);
- return response;
+ return new ResponseEntity<String>(message, HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(Exception.class)
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/ViewLogController.java b/vid-app-common/src/main/java/org/onap/vid/controller/ViewLogController.java
index a95f0ad..4956c5b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/ViewLogController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/ViewLogController.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
@@ -44,7 +44,7 @@ public class ViewLogController extends RestrictedBaseController{
private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(ViewLogController.class);
/** The Constant dateFormat. */
- final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+ static final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
/** The servlet context. */
private @Autowired ServletContext servletContext;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
index 56dce9a..68d5b71 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/WebConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
@@ -19,40 +19,23 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.vid.controllers;
+package org.onap.vid.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.joshworks.restclient.http.mapper.ObjectMapper;
-import java.io.IOException;
-import org.onap.vid.aai.AaiClient;
-import org.onap.vid.aai.AaiClientInterface;
-import org.onap.vid.aai.AaiOverTLSClient;
-import org.onap.vid.aai.AaiOverTLSClientInterface;
-import org.onap.vid.aai.AaiOverTLSPropertySupplier;
-import org.onap.vid.aai.AaiResponseTranslator;
-import org.onap.vid.aai.PombaClientImpl;
-import org.onap.vid.aai.PombaClientInterface;
-import org.onap.vid.aai.PombaRestInterface;
+import org.onap.vid.aai.*;
import org.onap.vid.aai.model.PortDetailsTranslator;
-import org.onap.vid.aai.util.AAIRestInterface;
-import org.onap.vid.aai.util.HttpsAuthClient;
-import org.onap.vid.aai.util.SSLContextProvider;
-import org.onap.vid.aai.util.ServletRequestHelper;
-import org.onap.vid.aai.util.SystemPropertyHelper;
+import org.onap.vid.aai.util.*;
import org.onap.vid.asdc.AsdcClient;
import org.onap.vid.asdc.parser.ToscaParserImpl2;
+import org.onap.vid.asdc.parser.VidNotionsBuilder;
import org.onap.vid.asdc.rest.SdcRestClient;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.client.SyncRestClientInterface;
import org.onap.vid.properties.AsdcClientConfiguration;
-import org.onap.vid.services.AaiService;
-import org.onap.vid.services.AaiServiceImpl;
-import org.onap.vid.services.PombaService;
-import org.onap.vid.services.PombaServiceImpl;
-import org.onap.vid.services.VidService;
-import org.onap.vid.services.VidServiceImpl;
-import org.onap.vid.scheduler.SchedulerRestInterface;
-import org.onap.vid.scheduler.SchedulerRestInterfaceIfc;
+import org.onap.vid.scheduler.SchedulerService;
+import org.onap.vid.scheduler.SchedulerServiceImpl;
+import org.onap.vid.services.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -60,6 +43,7 @@ import org.togglz.core.manager.FeatureManager;
import javax.servlet.ServletContext;
import java.io.File;
+import java.io.IOException;
@Configuration
public class WebConfig {
@@ -81,6 +65,11 @@ public class WebConfig {
}
@Bean
+ public SchedulerService schedulerService(ChangeManagementService changeManagementService) {
+ return new SchedulerServiceImpl(changeManagementService);
+ }
+
+ @Bean
public AaiService getAaiService() {
return new AaiServiceImpl();
}
@@ -96,8 +85,8 @@ public class WebConfig {
}
@Bean
- public AaiClientInterface getAaiRestInterface(@Qualifier("aaiRestInterface") AAIRestInterface restController, PortDetailsTranslator portsDetailsTranslator) {
- return new AaiClient(restController, portsDetailsTranslator);
+ public AaiClientInterface getAaiRestInterface(@Qualifier("aaiRestInterface") AAIRestInterface restController, PortDetailsTranslator portsDetailsTranslator, CacheProvider cacheProvider) {
+ return new AaiClient(restController, portsDetailsTranslator, cacheProvider);
}
@Bean(name = "aaiRestInterface")
@@ -126,9 +115,9 @@ public class WebConfig {
}
@Bean
- public HttpsAuthClient httpsAuthClientFactory(ServletContext servletContext, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider) {
+ public HttpsAuthClient httpsAuthClientFactory(ServletContext servletContext, SystemPropertyHelper systemPropertyHelper, SSLContextProvider sslContextProvider ,FeatureManager featureManager) {
final String certFilePath = new File(servletContext.getRealPath("/WEB-INF/cert/")).getAbsolutePath();
- return new HttpsAuthClient(certFilePath, systemPropertyHelper, sslContextProvider);
+ return new HttpsAuthClient(certFilePath, systemPropertyHelper, sslContextProvider, featureManager);
}
@Bean
@@ -147,8 +136,13 @@ public class WebConfig {
}
@Bean
- public ToscaParserImpl2 getToscaParser() {
- return new ToscaParserImpl2();
+ public VidNotionsBuilder vidNotionsBuilder(FeatureManager featureManager) {
+ return new VidNotionsBuilder(featureManager);
+ }
+
+ @Bean
+ public ToscaParserImpl2 getToscaParser(VidNotionsBuilder vidNotionsBuilder) {
+ return new ToscaParserImpl2(vidNotionsBuilder);
}
@Bean
@@ -162,20 +156,23 @@ public class WebConfig {
}
@Bean
- public SchedulerRestInterfaceIfc getSchedulerRestInterface(){
- return new SchedulerRestInterface();
+ public ServiceInstanceStandardQuery serviceInstanceStandardQuery(AaiClientInterface aaiClient) {
+ return new ServiceInstanceStandardQuery(aaiClient);
}
- @Bean(name = "aaiClientForFasterXmlMapping")
- public AaiOverTLSClientInterface getAaiClientForFasterXmlMapping(){
- ObjectMapper objectMapper = new ObjectMapper() {
+ @Bean
+ public AaiOverTLSClientInterface aaiOverTLSClient(ObjectMapper unirestObjectMapper){
+ return new AaiOverTLSClient(new SyncRestClient(unirestObjectMapper), new AaiOverTLSPropertySupplier());
+ }
- com.fasterxml.jackson.databind.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper();
+ @Bean
+ public ObjectMapper unirestFasterxmlObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) {
+ return new ObjectMapper() {
@Override
public <T> T readValue(String s, Class<T> aClass) {
try {
- return om.readValue(s, aClass);
+ return objectMapper.readValue(s, aClass);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -184,43 +181,13 @@ public class WebConfig {
@Override
public String writeValue(Object o) {
try {
- return om.writeValueAsString(o);
+ return objectMapper.writeValueAsString(o);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
};
- return new AaiOverTLSClient(new SyncRestClient(objectMapper), new AaiOverTLSPropertySupplier());
}
-
- @Bean(name = "aaiClientForCodehausMapping")
- public AaiOverTLSClientInterface getAaiClientForCodehausMapping() {
-
- ObjectMapper objectMapper = new ObjectMapper() {
-
- org.codehaus.jackson.map.ObjectMapper om = new org.codehaus.jackson.map.ObjectMapper();
-
- @Override
- public <T> T readValue(String s, Class<T> aClass) {
- try {
- return om.readValue(s, aClass);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public String writeValue(Object o) {
- try {
- return om.writeValueAsString(o);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- };
-
- return new AaiOverTLSClient(new SyncRestClient(objectMapper), new AaiOverTLSPropertySupplier());
- }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/filter/ClientCredentialsFilter.java b/vid-app-common/src/main/java/org/onap/vid/controller/filter/ClientCredentialsFilter.java
index d4c7e3c..cba36a7 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/filter/ClientCredentialsFilter.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/filter/ClientCredentialsFilter.java
@@ -20,7 +20,7 @@ import java.io.IOException;
@WebFilter(urlPatterns = "/change-management/workflow/*")
public class ClientCredentialsFilter extends GenericFilterBean {
- private final static EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(ClientCredentialsFilter.class);
+ private static final EELFLoggerDelegate filterLogger = EELFLoggerDelegate.getLogger(ClientCredentialsFilter.class);
@Override
@@ -33,12 +33,12 @@ public class ClientCredentialsFilter extends GenericFilterBean {
String actualAuthorization = ((HttpServletRequest)request).getHeader("Authorization");
if (verifyClientCredentials(actualAuthorization, expectedAuthorization)) {
- LOGGER.warn(EELFLoggerDelegate.debugLogger,"Client credentials authenticated.");
+ filterLogger.warn(EELFLoggerDelegate.debugLogger,"Client credentials authenticated.");
chain.doFilter(request, response);
return;
}
- LOGGER.warn(EELFLoggerDelegate.debugLogger,"Client did not provide the expected credentials.");
+ filterLogger.warn(EELFLoggerDelegate.debugLogger,"Client did not provide the expected credentials.");
((HttpServletResponse) response).sendError(401);
}
@@ -46,13 +46,13 @@ public class ClientCredentialsFilter extends GenericFilterBean {
{
if (StringUtils.isEmpty(expectedAuthorization))
{
- LOGGER.warn(EELFLoggerDelegate.debugLogger,String.format("Expected Authorization is not configured (key: %s)", SchedulerProperties.SCHEDULER_BASIC_AUTH));
+ filterLogger.warn(EELFLoggerDelegate.debugLogger,String.format("Expected Authorization is not configured (key: %s)", SchedulerProperties.SCHEDULER_BASIC_AUTH));
return true;
}
if (StringUtils.isEmpty(actualAuthorization))
{
- LOGGER.warn(EELFLoggerDelegate.debugLogger,"Authorization header is missing.");
+ filterLogger.warn(EELFLoggerDelegate.debugLogger,"Authorization header is missing.");
return false;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java b/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java
index 7501b10..9c1cb46 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java
@@ -3,7 +3,6 @@ package org.onap.vid.controller.filter;
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.StringUtils;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.springframework.web.filter.GenericFilterBean;
import javax.servlet.FilterChain;
@@ -24,8 +23,7 @@ import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID;
@WebFilter(urlPatterns = "/*")
public class PromiseEcompRequestIdFilter extends GenericFilterBean {
- private final static EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(PromiseEcompRequestIdFilter.class);
- private final static String REQUEST_ID_RESPONSE_HEADER = ECOMP_REQUEST_ID + "-echo";
+ private static final String REQUEST_ID_RESPONSE_HEADER = ECOMP_REQUEST_ID + "-echo";
@Override
@@ -48,13 +46,19 @@ public class PromiseEcompRequestIdFilter extends GenericFilterBean {
final HttpServletRequest httpRequest = (HttpServletRequest) request;
final String originalRequestId = httpRequest.getHeader(ECOMP_REQUEST_ID);
- if (StringUtils.isEmpty(originalRequestId)) {
+ if (StringUtils.isEmpty(originalRequestId) || !verifyAndValidateUuid(originalRequestId)) {
request = new PromiseEcompRequestIdRequestWrapper(httpRequest);
}
return request;
}
+ public static boolean verifyAndValidateUuid(String value)
+ {
+ String uuidRegex = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
+ return value.matches(uuidRegex);
+ }
+
private static class PromiseEcompRequestIdRequestWrapper extends HttpServletRequestWrapper {
private final UUID requestId;
@@ -81,12 +85,17 @@ public class PromiseEcompRequestIdFilter extends GenericFilterBean {
@Override
public Enumeration<String> getHeaderNames() {
+
+ if (null == super.getHeader(ECOMP_REQUEST_ID)) {
return Collections.enumeration(ImmutableList.<String>builder()
.add(ECOMP_REQUEST_ID)
.addAll(Collections.list(super.getHeaderNames()))
.build());
}
+ return super.getHeaderNames();
+ }
+
private boolean isRequestIdHeaderName(String name) {
return ECOMP_REQUEST_ID.equalsIgnoreCase(name);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAaiController.java b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAaiController.java
index c57d93c..511e863 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAaiController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAaiController.java
@@ -20,7 +20,7 @@
package org.onap.vid.controller.test;
-import org.codehaus.jackson.map.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.vid.model.ExceptionResponse;
import org.springframework.web.bind.annotation.*;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAsdcController.java b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAsdcController.java
index ae63964..da79ef9 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAsdcController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAsdcController.java
@@ -20,7 +20,7 @@
package org.onap.vid.controller.test;
-import org.codehaus.jackson.map.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.vid.model.ExceptionResponse;
import org.springframework.web.bind.annotation.*;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestMsoController.java b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestMsoController.java
index ba4476f..4cb0d6c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestMsoController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestMsoController.java
@@ -20,7 +20,7 @@
package org.onap.vid.controller.test;
-import org.codehaus.jackson.map.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.vid.model.ExceptionResponse;
import org.springframework.http.HttpStatus;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controllers/PolicyController.java b/vid-app-common/src/main/java/org/onap/vid/controllers/PolicyController.java
deleted file mode 100644
index 80b4739..0000000
--- a/vid-app-common/src/main/java/org/onap/vid/controllers/PolicyController.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * 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.onap.vid.controllers;
-
-import org.json.simple.JSONObject;
-import org.onap.vid.policy.*;
-import org.onap.portalsdk.core.controller.RestrictedBaseController;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.UUID;
-
-/**
- * Controller to handle Policy requests.
- */
-
-@RestController
-public class PolicyController extends RestrictedBaseController{
-
- /** The logger. */
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(PolicyController.class);
-
- @RequestMapping(value="/get_policy",method = RequestMethod.POST)
- public ResponseEntity<String> getPolicyInfo( HttpServletRequest request, @RequestBody JSONObject policy_request) {
-
- LOGGER.debug("#####################POLICY API CALL STARTED ###############"+ PolicyProperties.POLICY_GET_CONFIG_VAL);
- LOGGER.debug("#####################Policy Request ###############"+policy_request.toString());
-
- String path = PolicyProperties.getProperty(PolicyProperties.POLICY_GET_CONFIG_VAL);
- PolicyResponseWrapper policyResWrapper = getPolicyConfig(policy_request,path);
-
- LOGGER.debug("$$$$$$$$$$$$$$$$$$$$$$ " + new ResponseEntity<String>(policyResWrapper.getResponse(), HttpStatus.OK).toString());
-
- return ( new ResponseEntity<String>(policyResWrapper.getResponse(), HttpStatus.valueOf(policyResWrapper.getStatus())) );
- }
-
- protected static PolicyResponseWrapper getPolicyConfig(JSONObject request, String path) {
- String methodName = "getPolicyConfig";
- String uuid = UUID.randomUUID().toString();
- LOGGER.debug( "starting getPolicyConfig ");
-
- try {
- //STARTING REST API CALL AS AN FACTORY INSTACE
- PolicyRestInterfaceIfc restController = PolicyRestInterfaceFactory.getInstance();
-
- RestObject<String> restObjStr = new RestObject<String>();
- String str = new String();
- restObjStr.set(str);
- restController.<String>Post(str, request, uuid, path, restObjStr );
- PolicyResponseWrapper policyRespWrapper = PolicyUtil.wrapResponse (restObjStr);
-
- LOGGER.debug( "<== " + methodName + " w=" + policyRespWrapper.getResponse());
- return policyRespWrapper;
- } catch (Exception e) {
- LOGGER.debug( "EXCEPTION in getPolicyConfig <== " + "." + methodName + e.toString());
- throw e;
- }
- }
-}
-
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/Job.java b/vid-app-common/src/main/java/org/onap/vid/job/Job.java
index 77f348d..144c96c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/Job.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/Job.java
@@ -1,6 +1,7 @@
package org.onap.vid.job;
import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.onap.vid.job.impl.JobSharedData;
import java.util.Map;
import java.util.UUID;
@@ -18,30 +19,49 @@ public interface Job {
@JsonIgnore
Map<String, Object> getData();
+ JobSharedData getSharedData();
+
void setTypeAndData(JobType jobType, Map<String, Object> data);
UUID getTemplateId();
void setTemplateId(UUID templateId);
+ Integer getIndexInBulk();
+
void setIndexInBulk(Integer indexInBulk);
JobType getType();
enum JobStatus {
- COMPLETED(true),
- FAILED(true),
+ COMPLETED(true, false),
+ FAILED(true, true),
IN_PROGRESS(false),
+ RESOURCE_IN_PROGRESS(false),
PAUSE(false),
PENDING(false),
- STOPPED(true);
+ STOPPED(true, true),
+ COMPLETED_WITH_ERRORS(true, true),
+ COMPLETED_WITH_NO_ACTION(true, false),
+ CREATING(false);
private final Boolean finalStatus;
public Boolean isFinal(){return finalStatus;}
+ private final Boolean failure;
+ public Boolean isFailure() {
+ return failure;
+ }
+
JobStatus(Boolean finalStatus)
{
- this.finalStatus = finalStatus ;
+ this(finalStatus, false);
}
+
+ JobStatus(Boolean finalStatus, boolean failure) {
+ this.finalStatus = finalStatus;
+ this.failure = failure;
+ }
+
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/JobAdapter.java b/vid-app-common/src/main/java/org/onap/vid/job/JobAdapter.java
index 1701092..f281f98 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/JobAdapter.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/JobAdapter.java
@@ -1,9 +1,8 @@
package org.onap.vid.job;
-import org.onap.vid.model.JobBulk;
+import org.onap.vid.job.impl.JobSharedData;
import org.onap.vid.model.JobModel;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -13,14 +12,12 @@ import java.util.UUID;
public interface JobAdapter {
JobModel toModel(Job job);
- JobBulk toModelBulk(List<Job> jobList);
+ Job createServiceInstantiationJob(JobType jobType, AsyncJobRequest request, UUID templateId, String userId, String optimisticUniqueServiceInstanceName, Integer indexInBulk);
- List<Job> createBulkOfJobs(Map<String, Object> bulkRequest);
-
- Job createJob(JobType jobType, AsyncJobRequest request, UUID templateId, String userId, Integer indexInBulk);
+ Job createChildJob(JobType jobType, Job.JobStatus jobStatus, AsyncJobRequest request, JobSharedData parentSharedData, Map<String, Object> jobData);
// Marks types that are an AsyncJob payload
- public interface AsyncJobRequest {
+ interface AsyncJobRequest {
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/JobCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/JobCommand.java
index c32645c..7f62bca 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/JobCommand.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/JobCommand.java
@@ -1,7 +1,8 @@
package org.onap.vid.job;
+import org.onap.vid.job.impl.JobSharedData;
+
import java.util.Map;
-import java.util.UUID;
/**
@@ -13,11 +14,11 @@ public interface JobCommand {
/**
* Initialize the command state
- * @param jobUuid Parent job's uuid
- * @param data An input to be set into the command. Each implementation may expect different keys in the map.
+ * @param sharedData shared data cross all job commands
+ * @param commandData An input to be set into the command. Each implementation may expect different keys in the map.
* @return Returns itself
*/
- default JobCommand init(UUID jobUuid, Map<String, Object> data) {
+ default JobCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
return this;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/JobException.java b/vid-app-common/src/main/java/org/onap/vid/job/JobException.java
new file mode 100644
index 0000000..ca389b0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/JobException.java
@@ -0,0 +1,16 @@
+package org.onap.vid.job;
+
+import java.util.UUID;
+
+public class JobException extends RuntimeException {
+ private final UUID jobUuid;
+
+ public JobException(String message, UUID jobUuid, Throwable cause) {
+ super(message, cause);
+ this.jobUuid = jobUuid;
+ }
+
+ public UUID getJobUuid() {
+ return jobUuid;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/JobType.java b/vid-app-common/src/main/java/org/onap/vid/job/JobType.java
index 9846d27..e856ba0 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/JobType.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/JobType.java
@@ -6,15 +6,33 @@ import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import static org.onap.vid.utils.Streams.not;
+
public enum JobType {
HttpCall(HttpCallCommand.class),
AggregateState(AggregateStateCommand.class),
- ServiceInstantiation(ServiceInstantiationCommand.class),
- InProgressStatus(InProgressStatusCommand.class),
+ ServiceInstantiation(MacroServiceInstantiationCommand.class),
+ MacroServiceInstantiation(MacroServiceInstantiationCommand.class),
+ ALaCarteServiceInstantiation(ALaCarteServiceInstantiationCommand.class),
+ ALaCarteService(ALaCarteServiceCommand.class),
+ VnfInstantiation(VnfInstantiationCommand.class),
+ VfmoduleInstantiation(VfmoduleInstantiationCommand.class),
+ VolumeGroupInstantiation(VolumeGroupInstantiationCommand.class),
+ VolumeGroupInProgressStatus(VolumeGroupInProgressStatusCommand.class),
+ NetworkInstantiation(NetworkInstantiationCommand.class),
+ InstanceGroupInstantiation(InstanceGroupInstantiationCommand.class),
+ InstanceGroup(InstanceGroupCommand.class),
+ InProgressStatus(ServiceInProgressStatusCommand.class),
+ ResourceInProgressStatus(ResourceInProgressStatusCommand.class),
+ VnfInProgressStatus(VnfInProgressStatusCommand.class),
+ Watching(WatchingCommand.class),
+ WatchingBaseModule(WatchingCommandBaseModule.class),
NoOp(NoOpCommand.class);
- private static final Map<Class, JobType> REVERSE_MAP = Stream.of(values()).collect(Collectors.toMap(t -> t.getCommandClass(), t -> t));
+ private static final Map<Class, JobType> REVERSE_MAP = Stream.of(values())
+ .filter(not(jobType -> jobType.equals(ServiceInstantiation)))
+ .collect(Collectors.toMap(t -> t.getCommandClass(), t -> t));
private final Class commandClass;
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/JobsBrokerService.java b/vid-app-common/src/main/java/org/onap/vid/job/JobsBrokerService.java
index 856f50b..98925d0 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/JobsBrokerService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/JobsBrokerService.java
@@ -18,4 +18,6 @@ public interface JobsBrokerService {
void delete(UUID jobId);
+ boolean mute(UUID jobId);
+
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceCommand.kt
new file mode 100644
index 0000000..f88e9d6
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceCommand.kt
@@ -0,0 +1,122 @@
+package org.onap.vid.job.command
+
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
+import org.onap.vid.changeManagement.RequestDetailsWrapper
+import org.onap.vid.job.*
+import org.onap.vid.model.Action
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation
+import org.onap.vid.mso.RestMsoImplementation
+import org.onap.vid.mso.model.ServiceDeletionRequestDetails
+import org.onap.vid.properties.VidProperties
+import org.onap.vid.services.AsyncInstantiationBusinessLogic
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.http.HttpMethod
+import org.springframework.stereotype.Component
+import java.time.ZonedDateTime
+import java.time.temporal.ChronoUnit
+import java.util.*
+
+class ServiceExpiryChecker : ExpiryChecker {
+
+ override fun isExpired(jobStartTime: ZonedDateTime?): Boolean {
+ val now = ZonedDateTime.now()
+ val maxHoursInProgress = VidProperties.getLongProperty(VidProperties.VID_JOB_MAX_HOURS_IN_PROGRESS)
+ val hoursBetween = ChronoUnit.HOURS.between(jobStartTime, now)
+ return maxHoursInProgress in 1..hoursBetween
+ }
+}
+
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class ALaCarteServiceCommand @Autowired constructor(
+ inProgressStatusService: InProgressStatusService,
+ watchChildrenJobsBL: WatchChildrenJobsBL,
+ private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
+ private val jobsBrokerService: JobsBrokerService,
+ msoResultHandlerService: MsoResultHandlerService,
+ private val jobAdapter: JobAdapter,
+ restMso: RestMsoImplementation
+) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService, watchChildrenJobsBL), JobCommand {
+
+ override fun getExpiryChecker(): ExpiryChecker {
+ return ServiceExpiryChecker();
+ }
+
+ companion object {
+ private val LOGGER = EELFLoggerDelegate.getLogger(ALaCarteServiceCommand::class.java)
+ }
+
+ override fun getRequest(): ServiceInstantiation {
+ return msoResultHandlerService.getRequest(sharedData)
+ }
+
+ override fun createChildren(): Job.JobStatus {
+ val dataForChild = buildDataForChild(getRequest())//.plus(ACTION_PHASE to actionPhase)
+
+ val childJobType = when (actionPhase) {
+ Action.Create -> JobType.InstanceGroupInstantiation
+ Action.Delete -> JobType.InstanceGroup
+ else -> return Job.JobStatus.COMPLETED
+ }
+
+ childJobs = getRequest().vnfGroups
+ .map { jobAdapter.createChildJob(childJobType, Job.JobStatus.CREATING, it.value, sharedData, dataForChild) }
+ .map { jobsBrokerService.add(it) }
+ .map { it.toString() }
+
+ return Job.JobStatus.COMPLETED_WITH_NO_ACTION
+ }
+
+ private fun buildDataForChild(request: ServiceInstantiation): Map<String, Any> {
+ val commandParentData = CommandParentData()
+ commandParentData.addInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID, request.instanceId)
+ commandParentData.addModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO, request.modelInfo)
+ return commandParentData.parentData
+ }
+
+ override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
+ TODO("not implemented")
+ }
+
+ override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
+ val requestDetailsWrapper = generateServiceDeletionRequest()
+ val path = asyncInstantiationBL.getServiceDeletionPath(getRequest().instanceId)
+ return MsoRestCallPlan(HttpMethod.DELETE, path, Optional.of(requestDetailsWrapper), Optional.empty(),
+ "delete instance with id ${getRequest().instanceId}")
+
+ }
+
+ override fun handleInProgressStatus(jobStatus: Job.JobStatus): Job.JobStatus {
+ if (jobStatus==Job.JobStatus.FAILED) {
+ asyncInstantiationBL.handleFailedInstantiation(sharedData.jobUuid)
+ return jobStatus
+ }
+
+ asyncInstantiationBL.updateServiceInfoAndAuditStatus(sharedData.jobUuid, jobStatus)
+ return if (jobStatus == Job.JobStatus.PAUSE) Job.JobStatus.IN_PROGRESS else jobStatus
+ }
+
+
+ private fun generateServiceDeletionRequest(): RequestDetailsWrapper<ServiceDeletionRequestDetails> {
+ return asyncInstantiationBL.generateALaCarteServiceDeletionRequest(
+ sharedData.jobUuid, getRequest(), sharedData.userId
+ )
+ }
+
+ override fun getExternalInProgressStatus() = Job.JobStatus.IN_PROGRESS
+
+ override fun isServiceCommand(): Boolean = true
+
+ override fun onFinal(jobStatus: Job.JobStatus) {
+ asyncInstantiationBL.updateServiceInfoAndAuditStatus(sharedData.jobUuid, jobStatus)
+ }
+
+ override fun onInitial(phase: Action) {
+ if (phase== Action.Delete) {
+ asyncInstantiationBL.updateServiceInfoAndAuditStatus(sharedData.jobUuid, Job.JobStatus.IN_PROGRESS)
+ }
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceInstantiationCommand.java
new file mode 100644
index 0000000..8a1346d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/ALaCarteServiceInstantiationCommand.java
@@ -0,0 +1,21 @@
+package org.onap.vid.job.command;
+
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.job.JobCommand;
+import org.onap.vid.mso.model.ServiceInstantiationRequestDetails;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class ALaCarteServiceInstantiationCommand extends ServiceInstantiationCommand implements JobCommand {
+
+ @Override
+ protected RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateServiceInstantiationRequest() {
+ return asyncInstantiationBL.generateALaCarteServiceInstantiationRequest(
+ getSharedData().getJobUuid(), getRequest(), optimisticUniqueServiceInstanceName, getSharedData().getUserId()
+ );
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/BaseInProgressStatusCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/BaseInProgressStatusCommand.java
new file mode 100644
index 0000000..a035708
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/BaseInProgressStatusCommand.java
@@ -0,0 +1,95 @@
+package org.onap.vid.job.command;
+
+import com.google.common.collect.ImmutableMap;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.job.*;
+import org.onap.vid.job.impl.JobSharedData;
+import org.onap.vid.mso.RestMsoImplementation;
+import org.onap.vid.mso.RestObject;
+import org.onap.vid.mso.rest.AsyncRequestStatus;
+import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+import org.togglz.core.manager.FeatureManager;
+
+import javax.inject.Inject;
+import java.util.Map;
+
+public abstract class BaseInProgressStatusCommand extends BaseInstantiationCommand implements JobCommand {
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(BaseInProgressStatusCommand.class);
+
+ @Inject
+ protected AsyncInstantiationBusinessLogic asyncInstantiationBL;
+
+ @Inject
+ protected JobsBrokerService jobsBrokerService;
+
+ @Inject
+ protected JobAdapter jobAdapter;
+
+ @Inject
+ protected RestMsoImplementation restMso;
+
+ @Inject
+ protected FeatureManager featureManager;
+
+ @Inject
+ protected InProgressStatusService inProgressStatusService;
+
+
+ protected String requestId;
+
+ protected String instanceId;
+
+
+ @Override
+ public NextCommand call() {
+
+ try {
+ Job.JobStatus jobStatus = inProgressStatusService.call(getExpiryChecker(), getSharedData(), requestId);
+ return processJobStatus(jobStatus);
+ } catch (javax.ws.rs.ProcessingException e) {
+ // Retry when we can't connect MSO during getStatus
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, will retry: {}", requestId, e, e);
+ return new NextCommand(Job.JobStatus.IN_PROGRESS, this);
+ } catch (InProgressStatusService.BadResponseFromMso e) {
+ return handleFailedMsoResponse(e.getMsoResponse());
+ }
+ catch (RuntimeException e) {
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, stopping: {}", requestId, e, e);
+ return new NextCommand(Job.JobStatus.STOPPED, this);
+ }
+ }
+
+ protected abstract ExpiryChecker getExpiryChecker();
+
+ abstract NextCommand processJobStatus(Job.JobStatus jobStatus);
+
+ private NextCommand handleFailedMsoResponse(RestObject<AsyncRequestStatus> msoResponse) {
+ inProgressStatusService.handleFailedMsoResponse(getSharedData().getJobUuid(), requestId, msoResponse);
+ return new NextCommand(Job.JobStatus.IN_PROGRESS, this);
+ }
+
+ @Override
+ public BaseInProgressStatusCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
+ return init(sharedData, (String) commandData.get("requestId"), (String) commandData.get("instanceId"));
+ }
+
+
+ protected BaseInProgressStatusCommand init(JobSharedData sharedData,
+ String requestId,
+ String instanceId) {
+ init(sharedData);
+ this.requestId = requestId;
+ this.instanceId = instanceId;
+ return this;
+ }
+
+ @Override
+ public Map<String, Object> getData() {
+ return ImmutableMap.of(
+ "requestId", requestId,
+ "instanceId", instanceId
+ );
+ }
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/BaseInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/BaseInstantiationCommand.java
new file mode 100644
index 0000000..6f78eaf
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/BaseInstantiationCommand.java
@@ -0,0 +1,18 @@
+package org.onap.vid.job.command;
+
+import org.onap.vid.job.impl.JobSharedData;
+
+import java.util.Map;
+
+
+public abstract class BaseInstantiationCommand extends CommandBase{
+
+
+ protected CommandParentData commandParentData = new CommandParentData();
+
+ protected BaseInstantiationCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
+ super.init(sharedData);
+ commandParentData.initParentData(commandData);
+ return this;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/BaseRootCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/BaseRootCommand.java
new file mode 100644
index 0000000..4930c94
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/BaseRootCommand.java
@@ -0,0 +1,41 @@
+package org.onap.vid.job.command;
+
+import org.onap.vid.job.NextCommand;
+import org.onap.vid.job.impl.JobSharedData;
+import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
+import org.onap.vid.mso.RestObject;
+
+import javax.inject.Inject;
+
+
+public abstract class BaseRootCommand extends CommandBase{
+
+ @Inject
+ private MsoResultHandlerService msoResultHandlerService;
+
+ @Override
+ protected CommandBase init(JobSharedData sharedData) {
+ super.init(sharedData);
+ return this;
+ }
+
+ protected ServiceInstantiation getRequest() {
+ return msoResultHandlerService.getRequest(getSharedData());
+ }
+
+ protected NextCommand handleRootResponse(RestObject<RequestReferencesContainer> msoResponse){
+ MsoResult msoResult = msoResultHandlerService.handleRootResponse(getSharedData().getJobUuid(), msoResponse);
+ return new NextCommand(msoResult.getJobStatus(),
+ (msoResult.getMsoResourceIds()!=null) ?
+ new ServiceInProgressStatusCommand(getSharedData(), msoResult.getMsoResourceIds()) :
+ null
+ );
+
+ }
+
+ protected NextCommand handleCommandFailed() {
+ return new NextCommand(msoResultHandlerService.handleRootCommandFailed(getSharedData().getJobUuid()).getJobStatus());
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/BaseWatchingCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/BaseWatchingCommand.java
new file mode 100644
index 0000000..b619edd
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/BaseWatchingCommand.java
@@ -0,0 +1,70 @@
+package org.onap.vid.job.command;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.job.Job;
+import org.onap.vid.job.JobCommand;
+import org.onap.vid.job.NextCommand;
+import org.onap.vid.job.impl.JobSharedData;
+import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public abstract class BaseWatchingCommand extends BaseInstantiationCommand implements JobCommand {
+
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(BaseWatchingCommand.class);
+
+ @Inject
+ protected AsyncInstantiationBusinessLogic asyncInstantiationBL;
+
+ @Inject
+ private WatchChildrenJobsBL watchChildrenJobsBL;
+
+ private List<String> childrenJobsIds;
+
+ protected boolean isService;
+
+ public BaseWatchingCommand() {}
+
+ public BaseWatchingCommand(JobSharedData sharedData, List<String> childrenJobsIds, boolean isService) {
+ init(sharedData, childrenJobsIds, isService);
+ }
+
+ @Override
+ public NextCommand call() {
+ Job.JobStatus cumulativeJobsStatus = watchChildrenJobsBL.cumulateJobStatus(
+ watchChildrenJobsBL.retrieveChildrenJobsStatus(childrenJobsIds),
+ Job.JobStatus.COMPLETED);
+ return getNextCommand(cumulativeJobsStatus);
+ }
+
+ protected abstract NextCommand getNextCommand(Job.JobStatus cumulativeJobsStatus);
+
+ @Override
+ public BaseWatchingCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
+ return init(
+ sharedData,
+ (List<String>) commandData.get("childrenJobs"),
+ (boolean) commandData.get("isService")
+ );
+ }
+
+ protected BaseWatchingCommand init(JobSharedData sharedData, List<String> childrenJobsIds, boolean isService) {
+ super.init(sharedData);
+ this.childrenJobsIds = ObjectUtils.defaultIfNull(childrenJobsIds, new ArrayList<>());
+ this.isService = isService;
+ return this;
+ }
+
+ @Override
+ public Map<String, Object> getData() {
+ Map<String, Object> data = new HashMap<>();
+ data.put("childrenJobs", childrenJobsIds);
+ data.put("isService", isService);
+ return data;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandBase.java b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandBase.java
new file mode 100644
index 0000000..163106c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandBase.java
@@ -0,0 +1,27 @@
+package org.onap.vid.job.command;
+
+import org.onap.vid.job.impl.JobSharedData;
+
+import javax.inject.Inject;
+
+
+public abstract class CommandBase {
+
+ @Inject
+ protected CommandUtils commandUtils;
+
+ private JobSharedData sharedData;
+
+ protected CommandBase init(JobSharedData sharedData) {
+ this.setSharedData(sharedData);
+ return this;
+ }
+
+ public JobSharedData getSharedData() {
+ return sharedData;
+ }
+
+ private void setSharedData(JobSharedData sharedData) {
+ this.sharedData = sharedData;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandParentData.java b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandParentData.java
new file mode 100644
index 0000000..25c1972
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandParentData.java
@@ -0,0 +1,80 @@
+package org.onap.vid.job.command;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.vid.mso.model.ModelInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CommandParentData {
+
+
+ public enum CommandDataKey{
+ SERVICE_MODEL_INFO,
+ SERVICE_INSTANCE_ID,
+ VNF_INSTANCE_ID,
+ VNF_MODEL_INFO,
+ VG_INSTANCE_ID,
+ ;
+ }
+
+ private static final String RESOURCE_INSTANCE_IDS = "resourceInstancesIds";
+ private static final String RESOURCE_MODEL_INFOS = "resourceModelInfos";
+
+ private final TypeReference<Map<CommandDataKey, String>> mapCommandKeyToString =
+ new TypeReference<Map<CommandDataKey, String>> () {};
+
+ private final TypeReference<Map<CommandDataKey, ModelInfo>> mapCommandKeyToModelInfo =
+ new TypeReference<Map<CommandDataKey, ModelInfo>> () {};
+
+
+ private ObjectMapper objectMapper = new ObjectMapper();
+
+ private Map<CommandDataKey,ModelInfo> getModelInfosByCommandData(Map<String, Object> commandData) {
+ Object object = commandData.get(RESOURCE_MODEL_INFOS);
+ if (object != null) {
+ return objectMapper.convertValue(object, mapCommandKeyToModelInfo);
+ }
+ return null;
+ }
+
+ private Map<CommandDataKey,String> getInstanceIdsByCommandData(Map<String, Object> commandData) {
+ Object object = commandData.get(RESOURCE_INSTANCE_IDS);
+ if (object != null) {
+ return objectMapper.convertValue(object, mapCommandKeyToString);
+ }
+ return null;
+ }
+
+ public Map<String, Object> getParentData() {
+ Map<String, Object> data = new HashMap<>();
+ data.put(RESOURCE_INSTANCE_IDS, resourceInstancesIds);
+ data.put(RESOURCE_MODEL_INFOS, resourceModelInfos);
+ return data;
+ }
+ private Map<CommandDataKey, String> resourceInstancesIds = new HashMap<>();
+ private Map<CommandDataKey, ModelInfo> resourceModelInfos = new HashMap<>();
+
+ public void addModelInfo(CommandDataKey modelInfoKey, ModelInfo modelInfo) {
+ resourceModelInfos.put(modelInfoKey, modelInfo);
+ }
+
+ public void addInstanceId(CommandDataKey instanceIdKey, String instanceId) {
+ resourceInstancesIds.put(instanceIdKey, instanceId);
+ }
+ public ModelInfo getModelInfo(CommandDataKey modelInfoKey) {
+ return resourceModelInfos.get(modelInfoKey);
+ }
+
+ public String getInstanceId(CommandDataKey instanceIdKey) {
+ return resourceInstancesIds.get(instanceIdKey);
+ }
+
+ public CommandParentData initParentData(Map<String, Object> commandData) {
+ resourceModelInfos = getModelInfosByCommandData(commandData);
+ resourceInstancesIds = getInstanceIdsByCommandData(commandData);
+ return this;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
new file mode 100644
index 0000000..497eafd
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
@@ -0,0 +1,46 @@
+package org.onap.vid.job.command;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.model.ServiceModel;
+import org.onap.vid.services.VidService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CommandUtils {
+
+ private final VidService vidService;
+
+ @Autowired
+ public CommandUtils(VidService vidService) {
+ this.vidService = vidService;
+ }
+
+ public boolean isVfModuleBaseModule(String serviceModelUuid, String vfModuleModelUUID) throws AsdcCatalogException{
+ ServiceModel serviceModel = vidService.getService(serviceModelUuid);
+
+ if (serviceModel==null) {
+ throw new AsdcCatalogException("Failed to retrieve model with uuid "+serviceModelUuid +" from SDC");
+ }
+
+ if (serviceModel.getVfModules() == null) {
+ throw createAsdcCatalogVfModuleModelUUIDNotFoundException(serviceModelUuid, vfModuleModelUUID);
+ }
+
+ return serviceModel.getVfModules()
+ .values()
+ .stream()
+ .filter(vfModule -> StringUtils.equals(vfModule.getUuid(), vfModuleModelUUID))
+ .findFirst()
+ .orElseThrow(() -> createAsdcCatalogVfModuleModelUUIDNotFoundException(serviceModelUuid, vfModuleModelUUID))
+ .getProperties()
+ .getBaseModule();
+ }
+
+ private AsdcCatalogException createAsdcCatalogVfModuleModelUUIDNotFoundException(String serviceModelUuid, String vfModuleModelUUID) {
+ return new AsdcCatalogException("Failed to find vfModuleModelUUID: " + vfModuleModelUUID +
+ "in model with uuid: " + serviceModelUuid);
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ExpiryChecker.java b/vid-app-common/src/main/java/org/onap/vid/job/command/ExpiryChecker.java
new file mode 100644
index 0000000..1ae5d21
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/ExpiryChecker.java
@@ -0,0 +1,8 @@
+package org.onap.vid.job.command;
+
+import java.time.ZonedDateTime;
+
+public interface ExpiryChecker {
+
+ boolean isExpired(ZonedDateTime jobStartTime);
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/HttpCallCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/HttpCallCommand.java
index 5951d7c..7ee48a8 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/HttpCallCommand.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/HttpCallCommand.java
@@ -4,13 +4,13 @@ import com.google.common.collect.ImmutableMap;
import org.onap.vid.job.Job;
import org.onap.vid.job.JobCommand;
import org.onap.vid.job.NextCommand;
+import org.onap.vid.job.impl.JobSharedData;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Response;
import java.util.Map;
import java.util.UUID;
@@ -30,13 +30,13 @@ public class HttpCallCommand implements JobCommand {
@Override
public NextCommand call() {
- final Response response = ClientBuilder.newClient().target(url).request().post(Entity.text(uuid.toString()));
+ ClientBuilder.newClient().target(url).request().post(Entity.text(uuid.toString()));
return new NextCommand(Job.JobStatus.COMPLETED);
}
@Override
- public HttpCallCommand init(UUID jobUuid, Map<String, Object> data) {
- return init((String) data.get("url"), jobUuid);
+ public HttpCallCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
+ return init((String) commandData.get("url"), sharedData.getJobUuid());
}
private HttpCallCommand init(String url, UUID jobUuid) {
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusCommand.java
deleted file mode 100644
index 6685a63..0000000
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusCommand.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2018 Nokia. 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.onap.vid.job.command;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.ImmutableMap;
-import io.joshworks.restclient.http.HttpResponse;
-import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.job.Job.JobStatus;
-import org.onap.vid.job.JobCommand;
-import org.onap.vid.job.NextCommand;
-import org.onap.vid.mso.MsoInterface;
-import org.onap.vid.mso.rest.AsyncRequestStatus;
-import org.onap.vid.services.AsyncInstantiationBusinessLogic;
-import org.onap.vid.services.AuditService;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import javax.inject.Inject;
-import java.util.Map;
-import java.util.Objects;
-import java.util.UUID;
-
-
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class InProgressStatusCommand implements JobCommand {
-
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-
- private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(InProgressStatusCommand.class);
-
- @Inject
- private AsyncInstantiationBusinessLogic asyncInstantiationBL;
-
- @Inject
- private MsoInterface restMso;
-
- @Inject
- private AuditService auditService;
-
- private String requestId;
-
- private UUID jobUuid;
-
- public InProgressStatusCommand() {
- }
-
- InProgressStatusCommand(UUID jobUuid, String requestId) {
- init(jobUuid, requestId);
- }
-
- InProgressStatusCommand(AsyncInstantiationBusinessLogic asyncInstantiationBusinessLogic, MsoInterface msoInterface, AuditService auditService, UUID jobUuid, String requestId) {
- this(jobUuid, requestId);
- this.asyncInstantiationBL = asyncInstantiationBusinessLogic;
- this.restMso = msoInterface;
- this.auditService = auditService;
- }
-
- @Override
- public NextCommand call() {
-
- try {
- String path = asyncInstantiationBL.getOrchestrationRequestsPath() + "/" + requestId;
- HttpResponse<AsyncRequestStatus> msoResponse = restMso.get(path, AsyncRequestStatus.class);
-
-
- JobStatus jobStatus;
- if (msoResponse.getStatus() >= 400 || msoResponse.getBody() == null) {
- auditService.setFailedAuditStatusFromMso(jobUuid, requestId, msoResponse.getStatus(), Objects.toString(msoResponse.getBody()));
- LOGGER.error(EELFLoggerDelegate.errorLogger,
- "Failed to get orchestration status for {}. Status code: {}, Body: {}",
- requestId, msoResponse.getStatus(), Objects.toString(msoResponse.getRawBody()));
- return new NextCommand(JobStatus.IN_PROGRESS, this);
- } else {
- jobStatus = asyncInstantiationBL.calcStatus(msoResponse.getBody());
- }
-
- asyncInstantiationBL.auditMsoStatus(jobUuid, msoResponse.getBody().request);
-
-
- if (jobStatus == JobStatus.FAILED) {
- asyncInstantiationBL.handleFailedInstantiation(jobUuid);
- } else {
- asyncInstantiationBL.updateServiceInfoAndAuditStatus(jobUuid, jobStatus);
- }
- //in case of JobStatus.PAUSE we leave the job itself as IN_PROGRESS, for keep tracking job progress
- if (jobStatus == JobStatus.PAUSE) {
- return new NextCommand(JobStatus.IN_PROGRESS, this);
- }
- return new NextCommand(jobStatus, this);
- } catch (javax.ws.rs.ProcessingException e) {
- // Retry when we can't connect MSO during getStatus
- LOGGER.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, will retry: {}", requestId, e, e);
- return new NextCommand(JobStatus.IN_PROGRESS, this);
- } catch (RuntimeException e) {
- LOGGER.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, stopping: {}", requestId, e, e);
- return new NextCommand(JobStatus.STOPPED, this);
- }
- }
-
- @Override
- public InProgressStatusCommand init(UUID jobUuid, Map<String, Object> data) {
- return init(jobUuid, (String) data.get("requestId"));
- }
-
- private InProgressStatusCommand init(UUID jobUuid, String requestId) {
- this.requestId = requestId;
- this.jobUuid = jobUuid;
- return this;
- }
-
- @Override
- public Map<String, Object> getData() {
- return ImmutableMap.of("requestId", requestId);
- }
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusService.java b/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusService.java
new file mode 100644
index 0000000..4799f00
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/InProgressStatusService.java
@@ -0,0 +1,87 @@
+package org.onap.vid.job.command;
+
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.job.Job;
+import org.onap.vid.job.impl.JobSharedData;
+import org.onap.vid.mso.RestMsoImplementation;
+import org.onap.vid.mso.RestObject;
+import org.onap.vid.mso.rest.AsyncRequestStatus;
+import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+import org.onap.vid.services.AuditService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeParseException;
+import java.util.UUID;
+
+import static org.onap.vid.utils.TimeUtils.parseZonedDateTime;
+
+@Service
+public class InProgressStatusService {
+
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(InProgressStatusService.class);
+
+ private final AsyncInstantiationBusinessLogic asyncInstantiationBL;
+
+ private final RestMsoImplementation restMso;
+
+ private final AuditService auditService;
+
+ @Autowired
+ public InProgressStatusService(AsyncInstantiationBusinessLogic asyncInstantiationBL, RestMsoImplementation restMso, AuditService auditService) {
+ this.asyncInstantiationBL = asyncInstantiationBL;
+ this.restMso = restMso;
+ this.auditService = auditService;
+ }
+
+
+ public Job.JobStatus call(ExpiryChecker expiryChecker, JobSharedData sharedData, String requestId) {
+
+ RestObject<AsyncRequestStatus> asyncRequestStatus = getAsyncRequestStatus(requestId);
+ asyncInstantiationBL.auditMsoStatus(sharedData.getRootJobId(), asyncRequestStatus.get().request);
+ Job.JobStatus jobStatus = asyncInstantiationBL.calcStatus(asyncRequestStatus.get());
+ ZonedDateTime jobStartTime = getZonedDateTime(asyncRequestStatus, requestId);
+ jobStatus = expiryChecker.isExpired(jobStartTime) ? Job.JobStatus.FAILED : jobStatus;
+ return jobStatus;
+ }
+
+ private RestObject<AsyncRequestStatus> getAsyncRequestStatus(String requestId) {
+ String path = asyncInstantiationBL.getOrchestrationRequestsPath()+"/"+requestId;
+ RestObject<AsyncRequestStatus> msoResponse = restMso.GetForObject(path, AsyncRequestStatus.class);
+ if (msoResponse.getStatusCode() >= 400 || msoResponse.get() == null) {
+ throw new BadResponseFromMso(msoResponse);
+ }
+ return msoResponse;
+ }
+
+ public void handleFailedMsoResponse(UUID jobUUID, String requestId, RestObject<AsyncRequestStatus> msoResponse) {
+ auditService.setFailedAuditStatusFromMso(jobUUID, requestId, msoResponse.getStatusCode(), msoResponse.getRaw());
+ LOGGER.error(EELFLoggerDelegate.errorLogger,
+ "Failed to get orchestration status for {}. Status code: {}, Body: {}",
+ requestId, msoResponse.getStatusCode(), msoResponse.getRaw());
+ }
+
+ public static class BadResponseFromMso extends RuntimeException {
+ private final RestObject<AsyncRequestStatus> msoResponse;
+
+ public BadResponseFromMso(RestObject<AsyncRequestStatus> msoResponse) {
+ this.msoResponse = msoResponse;
+ }
+
+ public RestObject<AsyncRequestStatus> getMsoResponse() {
+ return msoResponse;
+ }
+ }
+
+ private ZonedDateTime getZonedDateTime(RestObject<AsyncRequestStatus> asyncRequestStatusResponse, String requestId) {
+ ZonedDateTime jobStartTime;
+ try {
+ jobStartTime = parseZonedDateTime(asyncRequestStatusResponse.get().request.startTime);
+ } catch (DateTimeParseException | NullPointerException e) {
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to parse start time for {}, body: {}. Current time will be used", requestId, asyncRequestStatusResponse.getRaw(), e);
+ jobStartTime = ZonedDateTime.now();
+ }
+ return jobStartTime;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupCommand.kt
new file mode 100644
index 0000000..36da508
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupCommand.kt
@@ -0,0 +1,59 @@
+package org.onap.vid.job.command
+
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
+import org.onap.vid.job.Job
+import org.onap.vid.job.JobAdapter
+import org.onap.vid.job.JobCommand
+import org.onap.vid.model.serviceInstantiation.InstanceGroup
+import org.onap.vid.mso.RestMsoImplementation
+import org.onap.vid.services.AsyncInstantiationBusinessLogic
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.http.HttpMethod
+import org.springframework.stereotype.Component
+import java.util.*
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class InstanceGroupCommand @Autowired constructor(
+ private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
+ restMso: RestMsoImplementation,
+ msoResultHandlerService: MsoResultHandlerService,
+ inProgressStatusService:InProgressStatusService,
+ watchChildrenJobsBL: WatchChildrenJobsBL
+) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService, watchChildrenJobsBL), JobCommand {
+
+ companion object {
+ private val LOGGER = EELFLoggerDelegate.getLogger(InstanceGroupCommand::class.java)
+ }
+
+ override fun createChildren(): Job.JobStatus {
+ return Job.JobStatus.COMPLETED_WITH_NO_ACTION
+ }
+
+ override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
+ val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
+ val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
+
+ val instantiatePath = asyncInstantiationBL.getInstanceGroupInstantiationPath()
+
+ val requestDetailsWrapper = asyncInstantiationBL.generateInstanceGroupInstantiationRequest(
+ request as InstanceGroup,
+ serviceModelInfo, serviceInstanceId,
+ userId
+ )
+
+ val actionDescription = "create instance group in $serviceInstanceId"
+
+ return MsoRestCallPlan(HttpMethod.POST, instantiatePath, Optional.of(requestDetailsWrapper), Optional.empty(), actionDescription)
+ }
+
+ override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
+ val path = asyncInstantiationBL.getInstanceGroupDeletePath(getRequest().instanceId)
+ return MsoRestCallPlan(HttpMethod.DELETE, path, Optional.empty(), Optional.of(userId),
+ "delete instance group with id ${getRequest().instanceId}")
+
+ }
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupInstantiationCommand.java
new file mode 100644
index 0000000..17b3f35
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/InstanceGroupInstantiationCommand.java
@@ -0,0 +1,47 @@
+package org.onap.vid.job.command;//package org.onap.vid.job.command;
+
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.command.CommandParentData.CommandDataKey;
+import org.onap.vid.model.Action;
+import org.onap.vid.model.serviceInstantiation.InstanceGroup;
+import org.onap.vid.mso.model.InstanceGroupInstantiationRequestDetails;
+import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+
+@Component
+@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class InstanceGroupInstantiationCommand extends ResourceInstantiationCommand {
+
+ @Inject
+ private AsyncInstantiationBusinessLogic asyncInstantiationBL;
+
+ @Override
+ protected String getRequestPath() {
+ return asyncInstantiationBL.getInstanceGroupInstantiationPath();
+ }
+
+ @Override
+ protected RequestDetailsWrapper<InstanceGroupInstantiationRequestDetails> generateMSORequest(JobAdapter.AsyncJobRequest request, String userId) {
+ return asyncInstantiationBL.generateInstanceGroupInstantiationRequest(
+ (InstanceGroup) getSharedData().getRequest(),
+ commandParentData.getModelInfo(CommandDataKey.SERVICE_MODEL_INFO),
+ commandParentData.getInstanceId(CommandDataKey.SERVICE_INSTANCE_ID),
+ getSharedData().getUserId()
+ );
+ }
+
+ @Override
+ protected String getJobAuditMSOStatus() {
+ return "INSTANCE_GROUP_REQUESTED";
+ }
+
+ @Override
+ protected boolean shouldInstantiateMyself() {
+ return Action.Create == ((InstanceGroup) getSharedData().getRequest()).getAction();
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/JobCommandFactory.java b/vid-app-common/src/main/java/org/onap/vid/job/command/JobCommandFactory.java
index 1e613c5..5661663 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/JobCommandFactory.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/JobCommandFactory.java
@@ -34,7 +34,7 @@ public class JobCommandFactory {
public JobCommand toCommand(Job job) {
final JobCommand command = jobFactory.apply(job.getType().getCommandClass());
- command.init(job.getUuid(), job.getData());
+ command.init(job.getSharedData(), job.getData());
return command;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/MacroServiceInstantiationCommand.java b/vid-app-common/src/main/java/org/onap/vid/job/command/MacroServiceInstantiationCommand.java
new file mode 100644
index 0000000..e03f9b8
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/MacroServiceInstantiationCommand.java
@@ -0,0 +1,26 @@