aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid
diff options
context:
space:
mode:
authorOfir Sonsino <os0695@att.com>2018-01-31 17:19:00 +0200
committerOfir Sonsino <os0695@att.com>2018-01-31 17:19:00 +0200
commit1cfb08779ea0e00be69e072a940b3063e049fe6b (patch)
tree6602a900387c8393ed0dcd81c0539381632903c6 /vid-app-common/src/main/java/org/onap/vid
parent2f20b001b9243e0f8b44aecc768ec265fd538732 (diff)
org.onap migration
Change-Id: I52f0b2851f2c765752b6d21f49b32136d7d72a3d Issue-ID: VID-86 Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid')
-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.java489
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java58
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java39
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiResponse.java34
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java107
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstance.java33
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstances.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstancesSearchResults.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscription.java20
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptions.java17
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/Services.java24
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/SubscriberAaiResponse.java24
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/SubscriberData.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/SubscriberFilteredResults.java29
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java31
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/SubscriberWithFilter.java21
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/exceptions/InvalidAAIResponseException.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/exceptions/RoleParsingException.java7
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/AicZones.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/Zone.java13
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentList.java30
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfResponse.java42
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfs/Pnf.java77
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/Service.java21
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetTenatns/GetTenantsResponse.java33
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/AaiRelationResponse.java45
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/GetServiceModelsByDistributionStatusResponse.java29
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/LogicalLinkResponse.java72
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/Model.java61
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVer.java84
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVers.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntity.java36
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntityResponse.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/PnfProperties.java51
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/PnfResult.java49
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/Project.java21
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ProjectResponse.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedToProperty.java35
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/Relationship.java67
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipData.java30
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java26
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/Result.java26
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstance.java26
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstances.java12
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceProperties.java113
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceRelationships.java102
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceSubscription.java17
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/Services.java24
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java46
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/AAIProperties.java68
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java373
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/CustomJacksonJaxBJsonProvider.java73
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsAuthClient.java140
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsComponentsClient.java99
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/util/JettyObfuscationConversionCommandLineUtil.java78
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/AsdcCatalogException.java58
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java129
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/Artifact.java314
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/Resource.java429
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/SecureService.java9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/SecureServices.java30
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java354
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/SubResource.java175
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Capability.java140
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Constraint.java199
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Group.java135
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Import.java48
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Input.java168
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/NodeTemplate.java117
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Property.java157
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Requirement.java120
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Schema.java53
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/SubstitutionMappings.java101
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/TopologyTemplate.java124
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaCsar.java101
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaMeta.java124
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaMetadata.java461
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaModel.java166
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java394
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/memory/InMemoryAsdcClient.java372
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParser.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl.java226
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java354
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/asdc/rest/RestfulAsdcClient.java480
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionResponse.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionsRequest.java13
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/category/CategoryParameterOptionRep.java31
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/category/CategoryParametersResponse.java27
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/ChangeManagementRequest.java73
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/ChangeManagementResponse.java19
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/CloudConfiguration.java55
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/CmResponse.java17
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/GetVnfWorkflowRelationRequest.java28
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/GetWorkflowsResponse.java24
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/LeanCloudConfiguration.java20
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfo.java138
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfoOfRelatedInstance.java122
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/MsoRequestDetails.java32
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/RelatedInstance.java29
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/RelatedInstanceList.java23
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestDetails.java56
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestDetailsWrapper.java16
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestInfo.java69
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java26
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetails.java67
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetailsWithWorkflows.java36
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfWorkflowRelationAllResponse.java23
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfWorkflowRelationRequest.java31
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfWorkflowRelationResponse.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowsDetail.java44
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/client/FakeHttpSession.java224
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/client/HttpBasicClient.java67
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/client/HttpsBasicClient.java143
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java750
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ChangeManagementController.java193
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java40
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java192
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java115
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java135
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java42
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java655
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java354
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/PolicyController.java84
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/PropertyController.java132
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java31
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/VidController.java149
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/ViewLogController.java65
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java123
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java94
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/filter/TempFilterForCORS.java48
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/test/TestAaiController.java87
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/test/TestAsdcController.java106
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/test/TestMsoController.java723
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/test/TestPageController.java55
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java112
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/dao/ProfileDao.java45
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/exceptions/NotFoundException.java12
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/exceptions/VidServiceUnavailableException.java69
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/factories/MsoRequestFactory.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/logging/VidLoggerAspect.java85
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/CategoryParameter.java120
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java139
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/CommandProperty.java93
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ExceptionResponse.java91
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ExceptionTranslator.java39
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ListOfErrorsResponse.java24
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ModelConstants.java44
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ModelUtil.java45
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/MsoExceptionResponse.java32
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Network.java62
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/NewNetwork.java56
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/NewNode.java209
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/NewService.java252
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/NewServiceModel.java288
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/NewVNF.java123
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Node.java322
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/PortMirroringConfig.java77
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ProxyResponse.java30
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java42
-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/Result.java58
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Service.java283
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ServiceInstanceSearchResult.java139
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java330
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ServiceProxy.java46
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Subscriber.java26
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/SubscriberList.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/VNF.java165
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/VNFDao.java105
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/VersionByInvariantIdsRequest.java11
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/VfModule.java308
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/VidWorkflow.java83
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/VolumeGroup.java196
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Workflow.java47
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java99
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java800
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java85
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java119
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper.java129
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper2.java60
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapperInterface.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java126
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java380
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/RestObject.java131
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfo.java33
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfo.java29
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java123
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java435
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/OperationalEnvironment/OperationEnvironmentRequestDetails.java120
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedInstance.java125
-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.java146
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java235
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestList.java137
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestWrapper.java35
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/Response.java54
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java68
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java119
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/TaskList.java16
-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.java233
-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/AsdcClientConfiguration.java124
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/properties/MsoClientConfiguration.java9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/properties/VidProperties.java93
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/roles/EcompRole.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/roles/Role.java48
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java138
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java57
-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/SchedulerProperties.java19
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java214
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterfaceFactory.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterfaceIfc.java23
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AaiService.java63
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java435
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterService.java18
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java144
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java32
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java303
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/CsvService.java15
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java250
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java164
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/RoleGeneratorService.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/VidService.java17
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java79
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/WorkflowService.java9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/WorkflowServiceImpl.java40
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Intersection.java31
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Logging.java105
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Streams.java47
240 files changed, 25641 insertions, 0 deletions
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
new file mode 100644
index 000000000..738f62036
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/RelatedTo.java
@@ -0,0 +1,39 @@
+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<String, Object>();
+
+ @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
new file mode 100644
index 000000000..2b8cf3a0e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
@@ -0,0 +1,489 @@
+package org.onap.vid.aai;
+
+import org.apache.http.HttpStatus;
+import org.apache.http.client.utils.URIBuilder;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.onap.vid.aai.util.AAIRestInterface;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.aai.model.AaiGetAicZone.AicZones;
+import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.vid.aai.model.*;
+import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
+import org.onap.vid.aai.model.AaiGetServicesRequestModel.GetServicesAAIRespone;
+import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.vid.model.SubscriberList;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.util.UriUtils;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
+
+/**
+
+ * Created by Oren on 7/4/17.
+ */
+public class AaiClient implements AaiClientInterface {
+
+ /**
+ * The Constant dateFormat.
+ */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+ protected String fromAppId = "VidAaiController";
+ @Autowired
+ ServletContext servletContext;
+ /**
+ * The logger
+ */
+
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AaiClient.class);
+ private final String getServiceModelsResponseBody = "{\"start\" : \"service-design-and-creation/models/\", \"query\" : \"query/serviceModels-byDistributionStatus?distributionStatus=DISTRIBUTION_COMPLETE_OK\"}";
+
+ public AaiClient() {
+ // certiPath = getCertificatesFile().getAbsolutePath();
+ // depth = "0";
+ }
+
+ public AaiClient(ServletContext context) {
+ servletContext = context;
+ }
+
+
+ private static String checkForNull(String local) {
+ if (local != null)
+ return local;
+ else
+ return "";
+
+ }
+
+ @Override
+ public AaiResponse getServicesByOwningEntityId(List<String> owningEntityIds){
+ File certiPath = getCertificatesFile();
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), getUrlFromLIst("business/owning-entities?", "owning-entity-id=", owningEntityIds), false);
+ AaiResponse aaiResponse = proccessAaiResponse(resp, OwningEntityResponse.class, null);
+
+ return aaiResponse;
+ }
+
+ @Override
+ public AaiResponse getServicesByProjectNames(List<String> projectNames){
+ File certiPath = getCertificatesFile();
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), getUrlFromLIst("business/projects?", "project-name=", projectNames), false);
+ AaiResponse aaiResponse = proccessAaiResponse(resp, ProjectResponse.class, null);
+
+ return aaiResponse;
+ }
+
+ @Override
+ public AaiResponse getServiceModelsByDistributionStatus() {
+ File certiPath = getCertificatesFile();
+ Response resp = doAaiPut(certiPath.getAbsolutePath(), "query?format=resource", getServiceModelsResponseBody, false);
+ AaiResponse aaiResponse = proccessAaiResponse(resp, GetServiceModelsByDistributionStatusResponse.class, null);
+
+ return aaiResponse;
+ }
+
+ @Override
+ public AaiResponse getPNFData(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion, String equipVendor, String equipModel) {
+ String certiPath = getCertificatesFile().getAbsolutePath();
+ String siQuery = "/business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + encodePathSegment(serviceType) + "/service-instances?model-version-id=" + modelVersionId + "&model-invariant-id=" + modelInvariantId;
+ String pnfQuery = "query/pnf-fromModel-byRegion?cloudRegionId=" + encodePathSegment(cloudRegion) + "&equipVendor=" + encodePathSegment(equipVendor) + "&equipModel=" + encodePathSegment(equipModel);
+ String payload = "{\"start\":\"" + siQuery + "\",\"query\":\"" + pnfQuery + "\"}";
+ Response resp = doAaiPut(certiPath, "query?format=simple", payload, false);
+ return proccessAaiResponse(resp, AaiGetPnfResponse.class, null);
+ }
+
+
+ @Override
+ public AaiResponse<Pnf> getSpecificPnf(String pnfId) {
+ File certiPath = getCertificatesFile();
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), "network/pnfs/pnf/"+pnfId, false);
+ AaiResponse aaiResponse = proccessAaiResponse(resp, Pnf.class, null);
+
+ return aaiResponse;
+ }
+
+ public AaiResponse getServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId) {
+ String certiPath = getCertificatesFile().getAbsolutePath();
+ String getServiceInstancePath = "business/customers/customer/"+globalCustomerId+"/service-subscriptions/service-subscription/"+serviceType+"/service-instances/service-instance/"+serviceInstanceId;
+ Response resp = doAaiGet(certiPath , getServiceInstancePath , false);
+ return proccessAaiResponse(resp, ServiceRelationships.class, null);
+ }
+
+ @Override
+ public AaiResponse getLogicalLink(String link) {
+ String certiPath = getCertificatesFile().getAbsolutePath();
+ Response resp = doAaiGet(certiPath , "network/logical-links/logical-link/" + link , false);
+ return proccessAaiResponse(resp, LogicalLinkResponse.class, null);
+ }
+
+ private String getUrlFromLIst(String url, String paramKey, List<String> params){
+ url.concat(paramKey);
+ int i = 0;
+ for(String param: params){
+ i ++;
+ url = url.concat(paramKey);
+ String encodedParam= param;
+ try {
+ 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());
+ }
+ url = url.concat(encodedParam);
+ if(i != params.size()){
+ url = url.concat("&");
+ }
+ }
+ return url;
+ }
+
+
+ @Override
+ public AaiResponse<SubscriberList> getAllSubscribers() {
+ String certiPath = getCertificatesFile().getAbsolutePath();
+ String depth = "0";
+ Response resp = doAaiGet(certiPath, "business/customers?subscriber-type=INFRA&depth=" + depth, false);
+ return proccessAaiResponse(resp, SubscriberList.class, null);
+ }
+
+
+ @Override
+ public AaiResponse getAllAicZones() {
+ String certiPath = getCertificatesFile().getAbsolutePath();
+ Response resp = doAaiGet(certiPath, "network/zones", false);
+ AaiResponse aaiAicZones = proccessAaiResponse(resp, AicZones.class, null);
+ return aaiAicZones;
+ }
+
+
+ @Override
+ public AaiResponse<String> getAicZoneForPnf(String globalCustomerId , String serviceType , String serviceId) {
+ String certiPath = getCertificatesFile().getAbsolutePath();
+ String aicZonePath = "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances/service-instance/" + serviceId;
+ Response resp = doAaiGet(certiPath , aicZonePath , false);
+ AaiResponse<ServiceRelationships> aaiResponse = proccessAaiResponse(resp , ServiceRelationships.class , null);
+ ServiceRelationships serviceRelationships = (ServiceRelationships)aaiResponse.getT();
+ RelationshipList relationshipList = serviceRelationships.getRelationshipList();
+ Relationship relationship = relationshipList.getRelationship().get(0);
+ RelationshipData relationshipData= relationship.getRelationDataList().get(0);
+ String aicZone = relationshipData.getRelationshipValue();
+ AaiResponse<String> aaiAicZonaForPnfResponse = new AaiResponse(aicZone , null ,HttpStatus.SC_OK);
+ return aaiAicZonaForPnfResponse;
+ }
+
+
+ @Override
+ public AaiResponse getVNFData() {
+ String certiPath = getCertificatesFile().getAbsolutePath();
+ 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(certiPath, "query?format=simple", payload, false);
+ return proccessAaiResponse(resp, AaiGetVnfResponse.class, null);
+
+ }
+
+ @Override
+ public Response getVNFData(String globalSubscriberId, String serviceType) {
+ String certiPath = getCertificatesFile().getAbsolutePath();
+ String payload = "{\"start\": [\"business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/"+ encodePathSegment(serviceType) +"/service-instances\"]," +
+ "\"query\": \"query/vnf-topology-fromServiceInstance\"}";
+ return doAaiPut(certiPath, "query?format=simple", payload, false);
+
+ }
+
+ @Override
+ public AaiResponse getVNFData(String globalSubscriberId, String serviceType, String serviceInstanceId) {
+ String certiPath = getCertificatesFile().getAbsolutePath();
+ String payload = "{\"start\": [\"/business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/" + encodePathSegment(serviceType) + "/service-instances/service-instance/" + serviceInstanceId + "\"], \"query\": \"query/vnf-topology-fromServiceInstance\"}";
+ Response resp = doAaiPut(certiPath, "query?format=simple", payload, false);
+ return proccessAaiResponse(resp, AaiGetVnfResponse.class, null);
+ }
+
+ @Override
+ public Response getVersionByInvariantId(List<String> modelInvariantId) {
+ File certiPath = getCertificatesFile();
+ StringBuilder sb = new StringBuilder();
+ for (String id : modelInvariantId){
+ sb.append("&model-invariant-id=");
+ sb.append(id);
+
+ }
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), "service-design-and-creation/models?depth=2"+ sb.toString(), false);
+ return resp;
+ }
+
+ @Override
+ public AaiResponse getSubscriberData(String subscriberId) {
+ File certiPath = getCertificatesFile();
+ String depth = "2";
+ AaiResponse subscriberDataResponse;
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers/customer/" + subscriberId + "?depth=" + depth, false);
+ subscriberDataResponse = proccessAaiResponse(resp, Services.class, null);
+ return subscriberDataResponse;
+ }
+
+ @Override
+ public AaiResponse getServices() {
+ File certiPath = getCertificatesFile();
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), "service-design-and-creation/services", false);
+ AaiResponse<GetServicesAAIRespone> getServicesResponse = proccessAaiResponse(resp, GetServicesAAIRespone.class, null);
+
+ return getServicesResponse;
+ }
+
+ @Override
+ public AaiResponse getOperationalEnvironments(String operationalEnvironmentType, String operationalEnvironmentStatus) {
+ File certiPath = getCertificatesFile();
+ String url = "cloud-infrastructure/operational-environments";
+ URIBuilder urlBuilder = new URIBuilder();
+ if (operationalEnvironmentType != null)
+ urlBuilder.addParameter("operational-environment-type", operationalEnvironmentType);
+ if (operationalEnvironmentStatus != null)
+ urlBuilder.addParameter("operational-environment-status", operationalEnvironmentStatus);
+ url += urlBuilder.toString();
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), url, false);
+ AaiResponse<OperationalEnvironmentList> getOperationalEnvironmentsResponse = proccessAaiResponse(resp, OperationalEnvironmentList.class, null);
+ return getOperationalEnvironmentsResponse;
+
+ }
+
+ @Override
+ public AaiResponse getTenants(String globalCustomerId, String serviceType) {
+ File certiPath = getCertificatesFile();
+ String url = "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + serviceType;
+
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), url, false);
+ String responseAsString = parseForTenantsByServiceSubscription(resp.readEntity(String.class));
+ if (responseAsString.equals("")){
+ AaiResponse aaiResponse = 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);
+ return aaiResponse;
+ }
+ else {
+ AaiResponse<GetTenantsResponse[]> getTenantsResponse = proccessAaiResponse(resp, GetTenantsResponse[].class, responseAsString);
+ return getTenantsResponse;
+ }
+
+ }
+
+ @Override
+ public AaiResponse getNodeTemplateInstances(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion) {
+
+ String certiPath = getCertificatesFile().getAbsolutePath();
+
+ String siQuery = "/business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + encodePathSegment(serviceType) + "/service-instances?model-version-id=" + modelVersionId + "&model-invariant-id=" + modelInvariantId;
+ String vnfQuery = "query/queryvnfFromModelbyRegion?cloudRegionId=" + encodePathSegment(cloudRegion);
+ String payload1 = "{\"start\":\"" + siQuery + "\",\"query\":\"" + vnfQuery + "\"}";
+
+ Response resp1 = doAaiPut(certiPath, "query?format=simple", payload1, false);
+ AaiResponse aaiResponse1 = proccessAaiResponse(resp1, AaiGetVnfResponse.class, null);
+ logger.debug(EELFLoggerDelegate.debugLogger, "getNodeTemplateInstances AAI's response: {}", aaiResponse1);
+ return aaiResponse1;
+ }
+
+ private AaiResponse proccessAaiResponse(Response resp, Class classType, String responseBody) {
+ AaiResponse subscriberDataResponse = null;
+ 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");
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "getSubscribers() resp=" + resp.getStatusInfo().toString());
+ if (resp.getStatus() != HttpStatus.SC_OK) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "Invalid response from AAI");
+ subscriberDataResponse = new AaiResponse<>(null, resp.readEntity(String.class), resp.getStatus());
+ } else {
+ String finalResponse = null;
+ try {
+ if (responseBody != null) {
+ finalResponse = responseBody;
+ } else {
+ finalResponse = resp.readEntity(String.class);
+ }
+
+ subscriberDataResponse = new AaiResponse<>((new ObjectMapper().readValue(finalResponse, classType)), null, HttpStatus.SC_OK);
+
+ } catch(Exception e){
+ subscriberDataResponse = new AaiResponse<>(null, null, HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ logger.error("Failed to parse aai response: \"{}\" to class {}", finalResponse, classType, e);
+ }
+ }
+ }
+ return subscriberDataResponse;
+ }
+
+ private File getCertificatesFile() {
+ if (servletContext != null)
+ return new File(servletContext.getRealPath("/WEB-INF/cert/"));
+ return null;
+ }
+
+ @SuppressWarnings("all")
+ public Response doAaiGet(String certiPath, String uri, boolean xml) {
+ String methodName = "doAaiGet";
+ String transId = UUID.randomUUID().toString();
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ Response resp = null;
+ try {
+
+ AAIRestInterface restContrller = new AAIRestInterface(certiPath);
+ resp = restContrller.RestGet(fromAppId, transId, uri, xml);
+
+ } catch (WebApplicationException e) {
+ final String message = ((BadRequestException) 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);
+ } 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());
+ }
+
+ return resp;
+ }
+
+ private String parseForTenantsByServiceSubscription(String resp) {
+ String tenantList = "";
+
+ try {
+ JSONParser jsonParser = new JSONParser();
+
+ JSONObject jsonObject = (JSONObject) jsonParser.parse(resp);
+
+ return parseServiceSubscriptionObjectForTenants(jsonObject);
+ } catch (Exception ex) {
+
+ }
+
+ return tenantList;
+ }
+
+ protected Response doAaiPut(String certiPath, String uri, String payload, boolean xml) {
+ String methodName = "doAaiPut";
+ String transId = UUID.randomUUID().toString();
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ Response resp = null;
+ try {
+
+ AAIRestInterface restContrller = new AAIRestInterface(certiPath);
+ resp = restContrller.RestPut(fromAppId, transId, 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());
+ }
+
+ return resp;
+ }
+
+
+ public static String parseServiceSubscriptionObjectForTenants(JSONObject jsonObject) {
+
+ JSONArray tenantArray = new JSONArray();
+ boolean bconvert = false;
+
+ try {
+ JSONObject relationShipListsObj = (JSONObject) jsonObject.get("relationship-list");
+ if (relationShipListsObj != null) {
+ JSONArray rShipArray = (JSONArray) relationShipListsObj.get("relationship");
+ if (rShipArray != null) {
+ Iterator i1 = rShipArray.iterator();
+
+ while (i1.hasNext()) {
+
+ JSONObject inner1Obj = (JSONObject) i1.next();
+
+ if (inner1Obj == null)
+ continue;
+
+ String relatedTo = checkForNull((String) inner1Obj.get("related-to"));
+ if (relatedTo.equalsIgnoreCase("tenant")) {
+ JSONObject tenantNewObj = new JSONObject();
+
+ String relatedLink = checkForNull((String) inner1Obj.get("related-link"));
+ tenantNewObj.put("link", relatedLink);
+
+ JSONArray rDataArray = (JSONArray) inner1Obj.get("relationship-data");
+ if (rDataArray != null) {
+ Iterator i2 = rDataArray.iterator();
+
+ while (i2.hasNext()) {
+ JSONObject inner2Obj = (JSONObject) i2.next();
+
+ if (inner2Obj == null)
+ continue;
+
+ String rShipKey = checkForNull((String) inner2Obj.get("relationship-key"));
+ String rShipVal = checkForNull((String) inner2Obj.get("relationship-value"));
+ if (rShipKey.equalsIgnoreCase("cloud-region.cloud-owner")) {
+ tenantNewObj.put("cloudOwner", rShipVal);
+ } else if (rShipKey.equalsIgnoreCase("cloud-region.cloud-region-id")) {
+ tenantNewObj.put("cloudRegionID", rShipVal);
+ }
+
+ if (rShipKey.equalsIgnoreCase("tenant.tenant-id")) {
+ tenantNewObj.put("tenantID", rShipVal);
+ }
+ }
+ }
+
+ JSONArray relatedTPropArray = (JSONArray) inner1Obj.get("related-to-property");
+ if (relatedTPropArray != null) {
+ Iterator i3 = relatedTPropArray.iterator();
+
+ while (i3.hasNext()) {
+ JSONObject inner3Obj = (JSONObject) i3.next();
+
+ if (inner3Obj == null)
+ continue;
+
+ String propKey = checkForNull((String) inner3Obj.get("property-key"));
+ String propVal = checkForNull((String) inner3Obj.get("property-value"));
+ if (propKey.equalsIgnoreCase("tenant.tenant-name")) {
+ tenantNewObj.put("tenantName", propVal);
+ }
+ }
+ }
+ bconvert = true;
+ tenantArray.add(tenantNewObj);
+ }
+ }
+
+ }
+ }
+ } catch (NullPointerException ex) {
+
+
+ }
+
+ if (bconvert)
+ return tenantArray.toJSONString();
+ else
+ return "";
+
+ }
+
+ private static String encodePathSegment(String segmentToEncode) {
+ try {
+ return UriUtils.encodePathSegment(segmentToEncode, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException("URI encoding failed unexpectedly", e);
+ }
+ }
+
+} \ 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
new file mode 100644
index 000000000..5095f48b5
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
@@ -0,0 +1,58 @@
+package org.onap.vid.aai;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
+import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.vid.aai.model.AaiGetServicesRequestModel.GetServicesAAIRespone;
+import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.vid.model.SubscriberList;
+
+import javax.ws.rs.core.Response;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Created by Oren on 7/4/17.
+ */
+public interface AaiClientInterface {
+
+ AaiResponse<SubscriberList> getAllSubscribers();
+
+ AaiResponse getSubscriberData(String subscriberId);
+
+ AaiResponse getServices();
+
+ AaiResponse getServicesByOwningEntityId(List<String> owningEntityIds);
+
+ AaiResponse<GetTenantsResponse[]> getTenants(String globalCustomerId, String serviceType);
+
+ AaiResponse<OperationalEnvironmentList> getOperationalEnvironments(String operationalEnvironmentType, String operationalEnvironmentStatus);
+
+ AaiResponse getAllAicZones();
+
+ AaiResponse getAicZoneForPnf(String globalCustomerId , String serviceType , String serviceId);
+
+ AaiResponse getVNFData();
+
+ Response getVNFData(String globalSubscriberId, String serviceType);
+
+ AaiResponse getVNFData(String globalSubscriberId, String serviceType, String serviceInstanceId);
+
+ AaiResponse getNodeTemplateInstances(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion);
+
+ Response getVersionByInvariantId(List<String> modelInvariantId);
+
+ AaiResponse getServicesByProjectNames(List<String> projectNames);
+
+ AaiResponse getServiceModelsByDistributionStatus();
+
+ AaiResponse getPNFData(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion, String equipVendor, String equipModel);
+
+ AaiResponse<Pnf> getSpecificPnf(String pnfId);
+
+ AaiResponse getServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId);
+
+ AaiResponse getLogicalLink(String link);
+}
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
new file mode 100644
index 000000000..14e8e5dcf
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiGetVnfResponse.java
@@ -0,0 +1,39 @@
+package org.onap.vid.aai;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.google.common.base.MoreObjects;
+import org.codehaus.jackson.annotate.*;
+import org.onap.vid.aai.model.VnfResult;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "results"
+})
+public class AaiGetVnfResponse {
+ @JsonProperty("results")
+ public List<VnfResult> results = null;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("results", results)
+ .add("additionalProperties", additionalProperties)
+ .toString();
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponse.java
new file mode 100644
index 000000000..c4b19b134
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiResponse.java
@@ -0,0 +1,34 @@
+package org.onap.vid.aai;
+
+import com.google.common.base.MoreObjects;
+import org.onap.vid.model.ProxyResponse;
+
+/**
+ * Created by Oren on 7/10/17.
+ */
+public class AaiResponse<T> extends ProxyResponse{
+
+ T t;
+
+ public AaiResponse() {
+ }
+
+ public AaiResponse(T t, String errorMessage, int aaiHttpCode) {
+ this.t = t;
+ this.errorMessage = errorMessage;
+ this.httpCode = aaiHttpCode;
+ }
+
+ public T getT() {
+ return t;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("httpCode", httpCode)
+ .add("errorMessage", errorMessage)
+ .add("t", t)
+ .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
new file mode 100644
index 000000000..10ad4e963
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/OperationalEnvironment.java
@@ -0,0 +1,107 @@
+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 org.onap.vid.aai.model.RelationshipList;
+
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class OperationalEnvironment {
+
+ private String operationalEnvironmentId;
+ private String operationalEnvironmentName;
+ private String operationalEnvironmentType;
+ private String operationalEnvironmentStatus;
+ private String tenantContext;
+ private String workloadContext;
+ private String resourceVersion;
+ private RelationshipList relationshipList;
+
+ public OperationalEnvironment() {
+ }
+
+ public OperationalEnvironment(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, String operationalEnvironmentStatus, String tenantContext, String workloadContext, String resourceVersion, RelationshipList relationshipList) {
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ this.operationalEnvironmentName = operationalEnvironmentName;
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ this.operationalEnvironmentStatus = operationalEnvironmentStatus;
+ this.tenantContext = tenantContext;
+ this.workloadContext = workloadContext;
+ this.resourceVersion = resourceVersion;
+ this.relationshipList = relationshipList;
+ }
+
+ @JsonProperty("operational-environment-id")
+ public String getOperationalEnvironmentId() {
+ return operationalEnvironmentId;
+ }
+
+ public void setOperationalEnvironmentId(String operationalEnvironmentId) {
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ }
+
+ @JsonProperty("operational-environment-name")
+ public String getOperationalEnvironmentName() {
+ return operationalEnvironmentName;
+ }
+
+ public void setOperationalEnvironmentName(String operationalEnvironmentName) {
+ this.operationalEnvironmentName = operationalEnvironmentName;
+ }
+
+ @JsonProperty("operational-environment-type")
+ public String getOperationalEnvironmentType() {
+ return operationalEnvironmentType;
+ }
+
+ public void setOperationalEnvironmentType(String operationalEnvironmentType) {
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ }
+
+ @JsonProperty("operational-environment-status")
+ public String getOperationalEnvironmentStatus() {
+ return operationalEnvironmentStatus;
+ }
+
+ public void setOperationalEnvironmentStatus(String operationalEnvironmentStatus) {
+ this.operationalEnvironmentStatus = operationalEnvironmentStatus;
+ }
+
+ @JsonProperty("tenant-context")
+ public String getTenantContext() {
+ return tenantContext;
+ }
+
+ public void setTenantContext(String tenantContext) {
+ this.tenantContext = tenantContext;
+ }
+
+ @JsonProperty("workload-context")
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ public void setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+
+ @JsonProperty("resource-version")
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @JsonProperty("relationship-list")
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ public void setRelationshipList(RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ }
+}
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
new file mode 100644
index 000000000..26f4a21e7
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstance.java
@@ -0,0 +1,33 @@
+package org.onap.vid.aai;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceInstance {
+
+ @JsonProperty("service-instance-id")
+ public String serviceInstanceId;
+
+ @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;
+
+ @JsonProperty("model-invariant-id")
+ public String modelInvariantId;
+
+ @JsonProperty("model-version-id")
+ public String modelVersionId;
+
+}
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
new file mode 100644
index 000000000..c92a47a36
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstances.java
@@ -0,0 +1,14 @@
+package org.onap.vid.aai;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceInstances {
+
+ @JsonProperty("service-instance")
+ public List<ServiceInstance> serviceInstance;
+
+}
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
new file mode 100644
index 000000000..b32a83a13
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceInstancesSearchResults.java
@@ -0,0 +1,14 @@
+package org.onap.vid.aai;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.onap.vid.model.ServiceInstanceSearchResult;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceInstancesSearchResults {
+ @JsonProperty("service-instances")
+ public List<ServiceInstanceSearchResult> serviceInstances;
+}
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
new file mode 100644
index 000000000..5dc9d526b
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscription.java
@@ -0,0 +1,20 @@
+package org.onap.vid.aai;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceSubscription {
+
+ @JsonProperty("service-type")
+ public String serviceType;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("service-instances")
+ public ServiceInstances serviceInstances;
+
+ @JsonProperty("is-permitted")
+ public boolean isPermitted =false;
+}
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
new file mode 100644
index 000000000..686dc7d60
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/ServiceSubscriptions.java
@@ -0,0 +1,17 @@
+package org.onap.vid.aai;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.List;
+
+/**
+ * Created by Oren on 7/9/17.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+
+public class ServiceSubscriptions {
+
+ @JsonProperty("service-subscription")
+ public List<ServiceSubscription> serviceSubscription;
+}
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
new file mode 100644
index 000000000..fe70de5af
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/Services.java
@@ -0,0 +1,24 @@
+package org.onap.vid.aai;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Services {
+ @JsonProperty("global-customer-id")
+ public String globalCustomerId;
+
+ @JsonProperty("subscriber-name")
+ public String subscriberName;
+
+ @JsonProperty("subscriber-type")
+ public String subscriberType;
+
+ @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/SubscriberAaiResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberAaiResponse.java
new file mode 100644
index 000000000..2dad75fdf
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberAaiResponse.java
@@ -0,0 +1,24 @@
+package org.onap.vid.aai;
+
+import org.onap.vid.model.ProxyResponse;
+import org.onap.vid.model.SubscriberList;
+
+/**
+ * Created by Oren on 7/5/17.
+ */
+public class SubscriberAaiResponse extends ProxyResponse {
+
+
+ private SubscriberList subscriberList;
+
+ public SubscriberAaiResponse(SubscriberList subscriberList, String errorMessage, int aaiHttpCode) {
+ this.subscriberList = subscriberList;
+ this.errorMessage = errorMessage;
+ this.httpCode = aaiHttpCode;
+ }
+
+
+ public SubscriberList getSubscriberList() {
+ return subscriberList;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberData.java b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberData.java
new file mode 100644
index 000000000..1c93d97e2
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberData.java
@@ -0,0 +1,7 @@
+package org.onap.vid.aai;
+
+/**
+ * Created by Oren on 7/10/17.
+ */
+public class SubscriberData {
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberFilteredResults.java b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberFilteredResults.java
new file mode 100644
index 000000000..2db981999
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberFilteredResults.java
@@ -0,0 +1,29 @@
+package org.onap.vid.aai;
+
+import org.onap.vid.model.ProxyResponse;
+import org.onap.vid.model.SubscriberList;
+import org.onap.vid.roles.RoleValidator;
+
+/**
+ * Created by Oren on 7/5/17.
+ */
+
+public class SubscriberFilteredResults extends ProxyResponse {
+
+ private SubscriberListWithFilterData subscriberList;
+
+ public SubscriberFilteredResults(RoleValidator roleValidator,SubscriberList subscribers, String errorMessage, int aaiHttpCode) {
+ this.subscriberList = new SubscriberListWithFilterData(subscribers,roleValidator);
+ this.errorMessage = errorMessage;
+ this.httpCode = aaiHttpCode;
+ }
+
+
+ public SubscriberListWithFilterData getSubscriberList() {
+ return subscriberList;
+ }
+
+ public void setSubscriberList(SubscriberListWithFilterData subscriberList) {
+ this.subscriberList = subscriberList;
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java
new file mode 100644
index 000000000..0d4b4b7b3
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberListWithFilterData.java
@@ -0,0 +1,31 @@
+package org.onap.vid.aai;
+
+import org.onap.vid.model.Subscriber;
+import org.onap.vid.model.SubscriberList;
+import org.onap.vid.roles.RoleValidator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by Oren on 7/5/17.
+ */
+public class SubscriberListWithFilterData {
+
+ public SubscriberListWithFilterData(SubscriberList subscriberList, RoleValidator roleValidator){
+ List<Subscriber> subscribers = subscriberList.customer;
+ List<SubscriberWithFilter> subscribersWithFilter = new ArrayList<>();
+ for (Subscriber subscriber :subscribers){
+ SubscriberWithFilter subscriberWithFilter = new SubscriberWithFilter();
+ subscriberWithFilter.setIsPermitted(roleValidator.isSubscriberPermitted(subscriber.globalCustomerId));
+ subscriberWithFilter.subscriberType = subscriber.subscriberType;
+ subscriberWithFilter.resourceVersion = subscriber.resourceVersion;
+ subscriberWithFilter.subscriberName = subscriber.subscriberName;
+ subscriberWithFilter.globalCustomerId = subscriber.globalCustomerId;
+ subscribersWithFilter.add(subscriberWithFilter);
+ }
+ this.customer = subscribersWithFilter;
+ }
+
+ public List<SubscriberWithFilter> customer;
+}
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
new file mode 100644
index 000000000..aaaa14455
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/SubscriberWithFilter.java
@@ -0,0 +1,21 @@
+package org.onap.vid.aai;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.onap.vid.model.Subscriber;
+
+/**
+ * Created by Oren on 7/5/17.
+ */
+public class SubscriberWithFilter extends Subscriber{
+
+ @JsonProperty("is-permitted")
+ private boolean isPermitted;
+
+ public boolean getIsPermitted() {
+ return isPermitted;
+ }
+
+ public void setIsPermitted(boolean isPermitted) {
+ this.isPermitted = isPermitted;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/exceptions/InvalidAAIResponseException.java b/vid-app-common/src/main/java/org/onap/vid/aai/exceptions/InvalidAAIResponseException.java
new file mode 100644
index 000000000..e6296488e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/exceptions/InvalidAAIResponseException.java
@@ -0,0 +1,7 @@
+package org.onap.vid.aai.exceptions;
+
+/**
+ * Created by Oren on 7/4/17.
+ */
+public class InvalidAAIResponseException extends Exception {
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/exceptions/RoleParsingException.java b/vid-app-common/src/main/java/org/onap/vid/aai/exceptions/RoleParsingException.java
new file mode 100644
index 000000000..1d838a1c0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/exceptions/RoleParsingException.java
@@ -0,0 +1,7 @@
+package org.onap.vid.aai.exceptions;
+
+/**
+ * Created by Oren on 12/16/17.
+ */
+public class RoleParsingException extends Exception {
+}
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
new file mode 100644
index 000000000..c30aaeb8f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/AicZones.java
@@ -0,0 +1,10 @@
+package org.onap.vid.aai.model.AaiGetAicZone;
+
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class AicZones {
+ @JsonProperty("zone")
+ public List<Zone> zones;
+}
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
new file mode 100644
index 000000000..89400f20e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetAicZone/Zone.java
@@ -0,0 +1,13 @@
+package org.onap.vid.aai.model.AaiGetAicZone;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.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/AaiGetOperationalEnvironments/OperationalEnvironmentList.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentList.java
new file mode 100644
index 000000000..1f31cfaa9
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentList.java
@@ -0,0 +1,30 @@
+package org.onap.vid.aai.model.AaiGetOperationalEnvironments;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.onap.vid.aai.OperationalEnvironment;
+
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class OperationalEnvironmentList {
+
+ @JsonProperty("operational-environment")
+ public List<OperationalEnvironment> getOperationalEnvironment() {
+ return operationalEnvironment;
+ }
+
+ @JsonProperty("operational-environment")
+ public void setOperationalEnvironment(List<OperationalEnvironment> operationalEnvironment) {
+ this.operationalEnvironment = operationalEnvironment;
+ }
+
+ public OperationalEnvironmentList() {
+ }
+
+ public OperationalEnvironmentList(List<OperationalEnvironment> operationalEnvironment) {
+ this.operationalEnvironment = operationalEnvironment;
+ }
+
+ private List<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
new file mode 100644
index 000000000..cd8cca8f2
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfResponse.java
@@ -0,0 +1,42 @@
+package org.onap.vid.aai.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+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;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "results"
+})
+public class AaiGetPnfResponse {
+ @JsonProperty("results")
+ public List<PnfResult> results = null;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("results", results)
+ .add("additionalProperties", additionalProperties)
+ .toString();
+ }
+}
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
new file mode 100644
index 000000000..00a731a70
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetPnfs/Pnf.java
@@ -0,0 +1,77 @@
+package org.onap.vid.aai.model.AaiGetPnfs;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+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;
+
+ public String getPnfName() {
+ return pnfName;
+ }
+
+ public void setPnfName(String pnfName) {
+ this.pnfName = pnfName;
+ }
+
+ public String getEquipType() {
+ return equipType;
+ }
+
+ public void setEquipType(String equipType) {
+ this.equipType = equipType;
+ }
+
+ public String getEquipVendor() {
+ return equipVendor;
+ }
+
+ public void setEquipVendor(String equipVendor) {
+ this.equipVendor = equipVendor;
+ }
+
+ public String getPnfName2() {
+ return pnfName2;
+ }
+
+ public void setPnfName2(String pnfName2) {
+ this.pnfName2 = pnfName2;
+ }
+
+ public String getPnfId() {
+ return pnfId;
+ }
+
+ public void setPnfId(String pnfId) {
+ this.pnfId = pnfId;
+ }
+
+ public String getEquipModel() {
+ return equipModel;
+ }
+
+ public void setEquipModel(String equipModel) {
+ this.equipModel = equipModel;
+ }
+
+ public String getPnfName2Source() { return pnfName2Source; }
+
+ public void setPnfName2Source(String pnfName2Source) { this.pnfName2Source = pnfName2Source; }
+}
+
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
new file mode 100644
index 000000000..d3dd7d26c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/GetServicesAAIRespone.java
@@ -0,0 +1,11 @@
+package org.onap.vid.aai.model.AaiGetServicesRequestModel;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.List;
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class GetServicesAAIRespone {
+
+ public List<Service> service;
+}
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
new file mode 100644
index 000000000..367287e1d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetServicesRequestModel/Service.java
@@ -0,0 +1,21 @@
+package org.onap.vid.aai.model.AaiGetServicesRequestModel;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * Created by Oren on 7/17/17.
+ */
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Service {
+ @JsonProperty("service-id")
+ public String serviceId;
+ @JsonProperty("service-description")
+ public String serviceDescription;
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+ @JsonProperty("is-permitted")
+ public boolean isPermitted;
+
+}
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
new file mode 100644
index 000000000..bee92440d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiGetTenatns/GetTenantsResponse.java
@@ -0,0 +1,33 @@
+package org.onap.vid.aai.model.AaiGetTenatns;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * Created by Oren on 7/18/17.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class GetTenantsResponse {
+
+ @JsonProperty("cloudRegionID")
+ public String cloudRegionId;
+
+ @JsonProperty("tenantName")
+ public String tenantName;
+
+ @JsonProperty("tenantID")
+ public String tenantID;
+
+ @JsonProperty("is-permitted")
+ public boolean isPermitted;
+
+ public GetTenantsResponse() {
+ }
+
+ public GetTenantsResponse(String cloudRegionId, String tenantName, String tenantID, boolean isPermitted) {
+ this.cloudRegionId = cloudRegionId;
+ this.tenantName = tenantName;
+ this.tenantID = tenantID;
+ this.isPermitted = isPermitted;
+ }
+} \ No newline at end of file
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
new file mode 100644
index 000000000..7bc2e7a2e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/AaiRelationResponse.java
@@ -0,0 +1,45 @@
+package org.onap.vid.aai.model;
+
+
+
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by moriya1 on 08/10/2017.
+ */
+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>();
+
+
+ @JsonProperty("resource-version")
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ @JsonProperty("resource-version")
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @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/GetServiceModelsByDistributionStatusResponse.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/GetServiceModelsByDistributionStatusResponse.java
new file mode 100644
index 000000000..5a6924dcb
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/GetServiceModelsByDistributionStatusResponse.java
@@ -0,0 +1,29 @@
+package org.onap.vid.aai.model;
+
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.List;
+
+/**
+ * Created by moriya1 on 15/10/2017.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class GetServiceModelsByDistributionStatusResponse {
+ @JsonProperty("results")
+ private List<Result> results;
+
+
+ @JsonProperty("results")
+ public List<Result> getResults() {
+ return results;
+ }
+
+ @JsonProperty("results")
+ public void setResults(List<Result> results) {
+ this.results = results;
+ }
+
+
+}
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
new file mode 100644
index 000000000..6625957ec
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/LogicalLinkResponse.java
@@ -0,0 +1,72 @@
+package org.onap.vid.aai.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+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;
+ }
+
+ public void setLinkName(String linkName) {
+ this.linkName = linkName;
+ }
+
+ public Boolean getInMaint() {
+ return inMaint;
+ }
+
+ public void setInMaint(Boolean inMaint) {
+ this.inMaint = inMaint;
+ }
+
+ public String getLinkType() {
+ return linkType;
+ }
+
+ public void setLinkType(String linkType) {
+ this.linkType = linkType;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public String getPurpose() {
+ return purpose;
+ }
+
+ public void setPurpose(String purpose) {
+ this.purpose = purpose;
+ }
+
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ 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
new file mode 100644
index 000000000..5f422f68a
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/Model.java
@@ -0,0 +1,61 @@
+package org.onap.vid.aai.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * Created by moriya1 on 15/10/2017.
+ */
+@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")
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ @JsonProperty("model-type")
+ public String getModelType() {
+ return modelType;
+ }
+
+ @JsonProperty("model-type")
+ public void setModelType(String modelType) {
+ this.modelType = modelType;
+ }
+
+ @JsonProperty("resource-version")
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ @JsonProperty("resource-version")
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @JsonProperty("model-vers")
+ public ModelVers getModelVers() {
+ return modelVers;
+ }
+
+ @JsonProperty("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
new file mode 100644
index 000000000..f02bbacfe
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVer.java
@@ -0,0 +1,84 @@
+package org.onap.vid.aai.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@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")
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ @JsonProperty("model-name")
+ public String getModelName() {
+ return modelName;
+ }
+
+ @JsonProperty("model-name")
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ @JsonProperty("model-version")
+ public String getModelVersion() {
+ return modelVersion;
+ }
+
+ @JsonProperty("model-version")
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ @JsonProperty("distribution-status")
+ public String getDistributionStatus() {
+ return distributionStatus;
+ }
+
+ @JsonProperty("distribution-status")
+ public void setDistributionStatus(String distributionStatus) {
+ this.distributionStatus = distributionStatus;
+ }
+
+ @JsonProperty("resource-version")
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ @JsonProperty("resource-version")
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @JsonProperty("model-description")
+ public String getModelDescription() {
+ return modelDescription;
+ }
+
+ @JsonProperty("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
new file mode 100644
index 000000000..f352158f2
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ModelVers.java
@@ -0,0 +1,28 @@
+package org.onap.vid.aai.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.List;
+
+/**
+ * Created by moriya1 on 15/10/2017.
+ */
+@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")
+ 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
new file mode 100644
index 000000000..edf5242d6
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntity.java
@@ -0,0 +1,36 @@
+package org.onap.vid.aai.model;
+
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * 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")
+ public void setOwningEntityId(String owningEntityId) {
+ this.owningEntityId = owningEntityId;
+ }
+
+ @JsonProperty("owning-entity-name")
+ public String getOwningEntityName() {
+ return owningEntityName;
+ }
+
+ @JsonProperty("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
new file mode 100644
index 000000000..3a571ea14
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/OwningEntityResponse.java
@@ -0,0 +1,28 @@
+package org.onap.vid.aai.model;
+
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.List;
+
+/**
+ * Created by moriya1 on 08/10/2017.
+ */
+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) {
+ this.owningEntity = owningEntity;
+ }
+
+
+}
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
new file mode 100644
index 000000000..3481d263e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/PnfProperties.java
@@ -0,0 +1,51 @@
+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 java.util.HashMap;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonPropertyOrder({
+ "pnf-name",
+ "equip-type",
+ "equip-vendor",
+ "equip-model",
+ "in-maint",
+ "resource-version"
+})
+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>();
+
+ @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/model/PnfResult.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/PnfResult.java
new file mode 100644
index 000000000..a727d8f3c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/PnfResult.java
@@ -0,0 +1,49 @@
+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 java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "id",
+ "node-type",
+ "url",
+ "properties",
+ "related-to"
+})
+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>();
+
+ @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/model/Project.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/Project.java
new file mode 100644
index 000000000..5931bb97a
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/Project.java
@@ -0,0 +1,21 @@
+package org.onap.vid.aai.model;
+
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * 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")
+ 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
new file mode 100644
index 000000000..0ca35b0a9
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ProjectResponse.java
@@ -0,0 +1,28 @@
+package org.onap.vid.aai.model;
+
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.List;
+
+/**
+ * Created by moriya1 on 08/10/2017.
+ */
+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/RelatedToProperty.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedToProperty.java
new file mode 100644
index 000000000..38003aec2
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelatedToProperty.java
@@ -0,0 +1,35 @@
+package org.onap.vid.aai.model;
+
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class RelatedToProperty {
+
+ public String getPropertyKey() {
+ return propertyKey;
+ }
+
+
+ public void setPropertyKey(String propertyKey) {
+ this.propertyKey = propertyKey;
+ }
+
+
+ public String getPropertyValue() {
+ return propertyValue;
+ }
+
+
+ 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
new file mode 100644
index 000000000..c80d5b6be
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/Relationship.java
@@ -0,0 +1,67 @@
+package org.onap.vid.aai.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.List;
+
+
+
+
+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;
+
+
+ public String getRelatedTo() {
+ return relatedTo;
+ }
+
+ public void setRelatedTo(String relatedTo) {
+ this.relatedTo = relatedTo;
+ }
+
+ public String getRelatedLink() {
+ return relatedLink;
+ }
+
+ public void setRelatedLink(String relatedLink) {
+ this.relatedLink = relatedLink;
+ }
+
+ public List<RelationshipData> getRelationDataList() {
+ return relationshipData;
+ }
+
+ public void setRelationDataList(List<RelationshipData> relationDataList) {
+ this.relationshipData = relationDataList;
+ }
+
+ public List<RelatedToProperty> getRelatedToPropertyList() {
+ return relatedToProperty;
+ }
+
+ public void setRelatedToPropertyList(List<RelatedToProperty> relatedToPropertyList) {
+ this.relatedToProperty = relatedToPropertyList;
+ }
+
+ public String getRelationshipLabel() {
+ return relationshipLabel;
+ }
+
+ 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
new file mode 100644
index 000000000..5d2d4091d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipData.java
@@ -0,0 +1,30 @@
+package org.onap.vid.aai.model;
+
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+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;
+ }
+
+ @JsonProperty("relationship-key")
+ public String relationshipKey;
+
+ @JsonProperty("relationship-value")
+ public String 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
new file mode 100644
index 000000000..43194fc7c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/RelationshipList.java
@@ -0,0 +1,26 @@
+package org.onap.vid.aai.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.List;
+
+
+public class RelationshipList {
+
+ @JsonProperty("relationship")
+ public List<Relationship> getRelationship() {
+ return relationship;
+ }
+
+ @JsonProperty("relationship")
+ public void setRelationship(List<Relationship> relationship) {
+ this.relationship = relationship;
+ }
+
+ @JsonProperty("relationship")
+ public List<Relationship> relationship;
+
+
+
+
+}
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
new file mode 100644
index 000000000..1eb46be75
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/Result.java
@@ -0,0 +1,26 @@
+package org.onap.vid.aai.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * Created by moriya1 on 15/10/2017.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Result {
+ @JsonProperty("model")
+ private Model model;
+
+ @JsonProperty("model")
+ public Model getModel() {
+ return model;
+ }
+
+ @JsonProperty("model")
+ public void setModel(Model model) {
+ this.model = model;
+ }
+
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstance.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstance.java
new file mode 100644
index 000000000..381f9bc25
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstance.java
@@ -0,0 +1,26 @@
+package org.onap.vid.aai.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class ServiceInstance {
+
+ @JsonProperty("service-instance-id")
+ public String serviceInstanceId;
+
+ @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/model/ServiceInstances.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstances.java
new file mode 100644
index 000000000..0fced4c57
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceInstances.java
@@ -0,0 +1,12 @@
+package org.onap.vid.aai.model;
+
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class ServiceInstances {
+
+ @JsonProperty("service-instance")
+ public List<ServiceInstance> serviceInstance;
+
+}
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
new file mode 100644
index 000000000..a76bcf8a1
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceProperties.java
@@ -0,0 +1,113 @@
+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;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonPropertyOrder({
+ "service-instance-id",
+ "service-instance-name",
+ "model-invariant-id",
+ "model-version-id",
+ "resource-version",
+ "orchestration-status",
+ "global-customer-id",
+ "subscriber-name",
+ "subscriber-type",
+ "vnf-id",
+ "vnf-name",
+ "vnf-type",
+ "service-id",
+ "prov-status",
+ "in-maint",
+ "is-closed-loop-disabled",
+ "model-customization-id",
+ "nf-type",
+ "nf-function",
+ "nf-role",
+ "nf-naming-code"
+})
+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>();
+
+ @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/model/ServiceRelationships.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceRelationships.java
new file mode 100644
index 000000000..b8abc8494
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceRelationships.java
@@ -0,0 +1,102 @@
+package org.onap.vid.aai.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+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;
+
+
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public String getServiceInstanceName() {
+ return serviceInstanceName;
+ }
+
+ public void setServiceInstanceName(String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ }
+
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public String getOrchestrationStatus() {
+ return orchestrationStatus;
+ }
+
+ public void setOrchestrationStatus(String orchestrationStatus) {
+ this.orchestrationStatus = orchestrationStatus;
+ }
+
+ public RelationshipList getRelationshipList() {
+ return relationshipList;
+ }
+
+ public void setRelationshipList(RelationshipList relationshipList) {
+ this.relationshipList = relationshipList;
+ }
+
+
+
+
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceSubscription.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceSubscription.java
new file mode 100644
index 000000000..91582e816
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/ServiceSubscription.java
@@ -0,0 +1,17 @@
+package org.onap.vid.aai.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class ServiceSubscription {
+
+ @JsonProperty("service-type")
+ public String serviceType;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("service-instances")
+ public ServiceInstances serviceInstances;
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/Services.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/Services.java
new file mode 100644
index 000000000..3ba4b22d0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/Services.java
@@ -0,0 +1,24 @@
+package org.onap.vid.aai.model;
+
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class Services {
+ @JsonProperty("global-customer-id")
+ public String globalCustomerId;
+
+ @JsonProperty("subscriber-name")
+ public String subscriberName;
+
+ @JsonProperty("subscriber-type")
+ public String subscriberType;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+ @JsonProperty("service-subscriptions")
+ public List<ServiceSubscription> serviceSubscriptions;
+
+
+}
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
new file mode 100644
index 000000000..e4f22849d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/VnfResult.java
@@ -0,0 +1,46 @@
+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;
+import java.util.Map;
+
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "id",
+ "node-type",
+ "url",
+ "properties",
+ "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")
+ public String url;
+ @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>();
+
+ @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/util/AAIProperties.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIProperties.java
new file mode 100644
index 000000000..254584ca1
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIProperties.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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.openecomp.portalsdk.core.util.SystemProperties;
+
+/**
+ * The Class AAIProperties.
+ */
+public class AAIProperties extends SystemProperties {
+
+ /** The Constant AAI_SERVER_URL_BASE. */
+ //VID Specific
+ public static final String AAI_SERVER_URL_BASE = "aai.server.url.base";
+
+ /** The Constant AAI_SERVER_URL. */
+ public static final String AAI_SERVER_URL = "aai.server.url";
+
+ /** The Constant AAI_OLDSERVER_URL_BASE. */
+ public static final String AAI_OLDSERVER_URL_BASE = "aai.oldserver.url.base";
+
+ /** The Constant AAI_OLDSERVER_URL. */
+ public static final String AAI_OLDSERVER_URL = "aai.oldserver.url";
+
+ /** The Constant AAI_TRUSTSTORE_FILENAME. */
+ public static final String AAI_TRUSTSTORE_FILENAME = "aai.truststore.filename";
+
+ /** The Constant AAI_TRUSTSTORE_PASSWD_X. */
+ public static final String AAI_TRUSTSTORE_PASSWD_X = "aai.truststore.passwd.x";
+
+ /** The Constant AAI_KEYSTORE_FILENAME. */
+ public static final String AAI_KEYSTORE_FILENAME = "aai.keystore.filename";
+
+ /** The Constant AAI_KEYSTORE_PASSWD_X. */
+ public static final String AAI_KEYSTORE_PASSWD_X = "aai.keystore.passwd.x";
+
+ /** The Constant AAI_VID_USERNAME. */
+ public static final String AAI_VID_USERNAME = "aai.vid.username";
+
+ /** The Constant AAI_VID_PASSWD_X. */
+ public static final String AAI_VID_PASSWD_X = "aai.vid.passwd.x";
+
+ /** The Constant FILESEPARTOR. */
+ public static final String FILESEPARTOR = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
+
+ /** The Constant AAI_USE_CLIENT_CERT */
+ public static final String AAI_USE_CLIENT_CERT = "aai.use.client.cert";
+
+}
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
new file mode 100644
index 000000000..13b7d30b0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java
@@ -0,0 +1,373 @@
+/*-
+ * ============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 java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.security.KeyManagementException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Base64;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import com.att.eelf.configuration.EELFLogger;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.eclipse.jetty.util.security.Password;
+import org.onap.vid.utils.Logging;
+import org.springframework.http.HttpMethod;
+import static org.onap.vid.utils.Logging.getHttpServletRequest;
+import static org.onap.vid.utils.Logging.requestIdHeaderKey;
+
+
+/**
+ * The Class AAIRestInterface.
+ */
+public class AAIRestInterface {
+
+ /** The logger. */
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AAIRestInterface.class);
+
+ final private EELFLogger outgoingRequestsLogger = Logging.getRequestsLogger("aai");
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The client. */
+ private static Client client = null;
+
+ /** The rest srvr base URL. */
+ private String restSrvrBaseURL;
+
+ /** The certificate path. */
+ public String certificatePath = "";
+
+ private String START_STRING = " start";
+
+ private String TRANSACTION_ID_HEADER = "X-TransactionId";
+ private String FROM_APP_ID_HEADER = "X-FromAppId";
+ private String SUCCESSFUL_API_MESSAGE=" REST api POST was successful!";
+ private String URL_DECLERATION = ", url=";
+
+
+
+
+
+
+ /**
+ * Instantiates a new AAI rest interface.
+ *
+ * @param certPath the cert path
+ */
+ public AAIRestInterface(String certPath)
+ {
+ certificatePath = certPath;
+ }
+
+ /**
+ * Encode URL.
+ *
+ * @param nodeKey the node key
+ * @return the string
+ * @throws UnsupportedEncodingException the unsupported encoding exception
+ */
+ public String encodeURL (String nodeKey) throws UnsupportedEncodingException {
+ return URLEncoder.encode(nodeKey, "UTF-8").replaceAll("\\+", "%20");
+ }
+
+ /**
+ * Inits the rest client.
+ */
+ private void initRestClient()
+ {
+ String methodName = "initRestClient";
+
+ if (client == null) {
+ try {
+ client = HttpsAuthClient.getClient(certificatePath);
+ }
+ catch (KeyManagementException e){
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== KeyManagementException in " + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== KeyManagementException in " + methodName + e.toString());
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== Exception in REST call to DB in initRestClient" + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== Exception in REST call to DB : " + e.toString());
+ }
+ }
+ }
+
+ /**
+ * Sets the rest srvr base URL.
+ *
+ * @param baseURL the base URL
+ */
+ public void SetRestSrvrBaseURL(String baseURL)
+ {
+ if (baseURL == null)
+ {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== REST Server base URL cannot be null.");
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== REST Server base URL cannot be null.");
+ }
+
+ restSrvrBaseURL = baseURL;
+ }
+
+ /**
+ * Gets the rest srvr base URL.
+ *
+ * @return the rest srvr base URL
+ */
+ public String getRestSrvrBaseURL()
+ {
+ return restSrvrBaseURL;
+ }
+
+
+ /**
+ * Rest get.
+ *
+ * @param fromAppId the from app id
+ * @param transId the trans id
+ * @param requestUri the request uri
+ * @param xml the xml
+ * @return the string
+ * @throws UnsupportedEncodingException
+ */
+ public Response RestGet(String fromAppId, String transId, String requestUri, boolean xml) throws UnsupportedEncodingException {
+ String methodName = "RestGet";
+
+ String responseType = MediaType.APPLICATION_JSON;
+ if (xml)
+ responseType = MediaType.APPLICATION_XML;
+
+ initRestClient();
+
+ String clientCert = SystemProperties.getProperty(AAIProperties.AAI_USE_CLIENT_CERT);
+
+ boolean useClientCert = false;
+ if (clientCert != null &&
+ SystemProperties.getProperty(AAIProperties.AAI_USE_CLIENT_CERT).equalsIgnoreCase("true")) {
+ useClientCert = true;
+ }
+ String url = "";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START_STRING);
+
+ url = SystemProperties.getProperty(AAIProperties.AAI_SERVER_URL) + requestUri;
+
+
+ logger.debug(dateFormat.format(new Date()) + "<== " + url + " for the get REST API");
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
+
+ final Response cres;
+ if (useClientCert == true) {
+ cres = client.target(url)
+ .request()
+ .accept(responseType)
+ .header(TRANSACTION_ID_HEADER, transId)
+ .header(FROM_APP_ID_HEADER, fromAppId)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get();
+ } else {
+
+ String vidUsername = SystemProperties.getProperty(AAIProperties.AAI_VID_USERNAME);
+ String vidPassword = Password.deobfuscate(SystemProperties.getProperty(AAIProperties.AAI_VID_PASSWD_X));
+ String encodeThis = vidUsername + ":" + vidPassword;
+
+ cres = client.target(url)
+ .request()
+ .accept(responseType)
+ .header(TRANSACTION_ID_HEADER, transId)
+ .header(FROM_APP_ID_HEADER, fromAppId)
+ .header("Content-Type", "application/json")
+ .header("Authorization", "Basic " + Base64.getEncoder().encodeToString(encodeThis.getBytes("utf-8")))
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get();
+ }
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, cres);
+// String r = cres.readEntity(String.class);
+ if (cres.getStatus() == 200) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + SUCCESSFUL_API_MESSAGE);
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + SUCCESSFUL_API_MESSAGE);
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName +" with status="+cres.getStatus()+URL_DECLERATION+url);
+ }
+ return cres;
+// logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName +" resp=" + r );
+// return r;
+ }
+
+
+ /**
+ * Delete.
+ *
+ * @param sourceID the source ID
+ * @param transId the trans id
+ * @param path the path
+ * @return true, if successful
+ */
+ public boolean Delete(String sourceID, String transId, String path) {
+ String methodName = "Delete";
+ String url="";
+ transId += ":" + UUID.randomUUID().toString();
+ logger.debug(dateFormat.format(new Date()) + "<== " + methodName + START_STRING);
+
+ initRestClient();
+ String request = "{}";
+ url = SystemProperties.getProperty(AAIProperties.AAI_SERVER_URL) + path;
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url);
+ final Response cres = client.target(url)
+ .request()
+ .accept(MediaType.APPLICATION_JSON)
+ .header(TRANSACTION_ID_HEADER, transId)
+ .header(FROM_APP_ID_HEADER, sourceID)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ //.entity(request)
+ .delete();
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres);
+ if (cres.getStatus() == 404) { // resource not found
+ String msg = "Resource does not exist...: " + cres.getStatus()
+ + ":" + cres.readEntity(String.class);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + msg);
+ return false;
+ } else if (cres.getStatus() == 200 || cres.getStatus() == 204){
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "Resource " + url + " deleted");
+ return true;
+ } else {
+ String msg = "Deleting Resource failed: " + cres.getStatus()
+ + ":" + cres.readEntity(String.class);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + msg);
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Rest put.
+ *
+ * @param fromAppId the from app id
+ * @param transId the trans id
+ * @param path the path
+ * @param payload the payload
+ * @param xml the xml
+ * @return the string
+ */
+ public Response RestPut(String fromAppId, String transId, String path, String payload, boolean xml) {
+ String methodName = "RestPut";
+ String url="";
+ transId = UUID.randomUUID().toString();
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START_STRING);
+
+ try {
+
+ String responseType = MediaType.APPLICATION_JSON;
+ if (xml)
+ responseType = "application/xml";
+
+ initRestClient();
+
+ url = SystemProperties.getProperty(AAIProperties.AAI_SERVER_URL) + path;
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.PUT, url, payload);
+ final Response cres = client.target(url)
+ .request()
+ .accept(responseType)
+ .header(TRANSACTION_ID_HEADER, transId)
+ .header(FROM_APP_ID_HEADER, fromAppId)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .put(Entity.entity(payload, MediaType.APPLICATION_JSON));
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.PUT, url, cres);
+
+ if (cres.getStatus() == 200 && cres.getStatus() <= 299) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + URL_DECLERATION);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + URL_DECLERATION);
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName +" with status="+cres.getStatus()+URL_DECLERATION+url);
+ }
+ return cres;
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + URL_DECLERATION+url+ ", Exception: " + e.toString());
+ }
+ return null;
+ }
+
+
+
+ /**
+ * Rest post.
+ *
+ * @param fromAppId the from app id
+ * @param transId the trans id
+ * @param path the path
+ * @param payload the payload
+ * @param xml the xml
+ * @return the string
+ */
+ public Response RestPost(String fromAppId, String transId, String path, String payload, boolean xml) {
+ String methodName = "RestPost";
+ String url="";
+ transId = UUID.randomUUID().toString();
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + START_STRING);
+
+ try {
+
+ String responseType = MediaType.APPLICATION_JSON;
+ if (xml)
+ responseType = "application/xml";
+
+ initRestClient();
+
+ url = SystemProperties.getProperty(AAIProperties.AAI_SERVER_URL_BASE) + path;
+ String vidUsername = SystemProperties.getProperty(AAIProperties.AAI_VID_USERNAME);
+ String vidPassword = Password.deobfuscate(SystemProperties.getProperty(AAIProperties.AAI_VID_PASSWD_X));
+ String encodeThis = vidUsername + ":" + vidPassword;
+
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, payload);
+ final Response cres = client.target(url)
+ .request()
+ .accept(responseType)
+ .header(TRANSACTION_ID_HEADER, transId)
+ .header(FROM_APP_ID_HEADER, fromAppId)
+ .header("Authorization", "Basic " + Base64.getEncoder().encodeToString(encodeThis.getBytes("utf-8")))
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .post(Entity.entity(payload, MediaType.APPLICATION_JSON));
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.POST, url, cres);
+
+ if (cres.getStatus() == 200 && cres.getStatus() <= 299) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + URL_DECLERATION);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + URL_DECLERATION);
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " with status="+cres.getStatus()+URL_DECLERATION+url);
+ }
+ return cres;
+ } catch (Exception e) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + URL_DECLERATION+url+ ", Exception: " + e.toString());
+ }
+ return null;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/CustomJacksonJaxBJsonProvider.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/CustomJacksonJaxBJsonProvider.java
new file mode 100644
index 000000000..996341a9c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/CustomJacksonJaxBJsonProvider.java
@@ -0,0 +1,73 @@
+/*-
+ * ============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 javax.ws.rs.ext.Provider;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
+import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
+
+/**
+ * The Class CustomJacksonJaxBJsonProvider.
+ */
+@Provider
+public class CustomJacksonJaxBJsonProvider extends JacksonJaxbJsonProvider {
+
+ /** The common mapper. */
+ private static ObjectMapper commonMapper = null;
+
+ /**
+ * Instantiates a new custom jackson jax B json provider.
+ */
+ public CustomJacksonJaxBJsonProvider() {
+ if (commonMapper == null) {
+ ObjectMapper mapper = new ObjectMapper();
+
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+ mapper.configure(SerializationFeature.INDENT_OUTPUT, false);
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
+
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
+
+ mapper.registerModule(new JaxbAnnotationModule());
+
+ commonMapper = mapper;
+ }
+ super.setMapper(commonMapper);
+ }
+
+ /**
+ * Gets the mapper.
+ *
+ * @return the mapper
+ */
+ public ObjectMapper getMapper() {
+ return commonMapper;
+ }
+}
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
new file mode 100644
index 000000000..0cf32cd42
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsAuthClient.java
@@ -0,0 +1,140 @@
+/*-
+ * ============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 java.io.FileInputStream;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+
+import org.eclipse.jetty.util.security.Password;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.HttpUrlConnectorProvider;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+/**
+ * The Class HttpsAuthClient.
+ */
+public class HttpsAuthClient{
+ /** The logger. */
+ static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HttpsAuthClient.class);
+
+ /**
+ * Gets the client.
+ *
+ * @param certFilePath the cert file path
+ * @return the client
+ * @throws KeyManagementException the key management exception
+ */
+ public static Client getClient(String certFilePath) throws KeyManagementException {
+
+ ClientConfig config = new ClientConfig();
+ //config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
+ //config.getClasses().add(org.openecomp.aai.util.CustomJacksonJaxBJsonProvider.class);
+
+ try {
+
+ config.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, Boolean.TRUE );
+
+ config.connectorProvider(new HttpUrlConnectorProvider().useSetMethodWorkaround());
+ String truststore_path = certFilePath + org.onap.vid.aai.util.AAIProperties.FILESEPARTOR + SystemProperties.getProperty(org.onap.vid.aai.util.AAIProperties.AAI_TRUSTSTORE_FILENAME);
+ String truststore_password = SystemProperties.getProperty(org.onap.vid.aai.util.AAIProperties.AAI_TRUSTSTORE_PASSWD_X);
+ String decrypted_truststore_password = Password.deobfuscate(truststore_password);
+
+ boolean useClientCert = false;
+
+ String keystore_path = certFilePath + org.onap.vid.aai.util.AAIProperties.FILESEPARTOR + SystemProperties.getProperty(org.onap.vid.aai.util.AAIProperties.AAI_KEYSTORE_FILENAME);
+ String keystore_password = SystemProperties.getProperty(org.onap.vid.aai.util.AAIProperties.AAI_KEYSTORE_PASSWD_X);
+ String decrypted_keystore_password = Password.deobfuscate(keystore_password);
+
+ String clientCert = SystemProperties.getProperty(org.onap.vid.aai.util.AAIProperties.AAI_USE_CLIENT_CERT);
+
+ if (clientCert != null &&
+ SystemProperties.getProperty(org.onap.vid.aai.util.AAIProperties.AAI_USE_CLIENT_CERT).equalsIgnoreCase("true")) {
+ useClientCert = true;
+ }
+
+ 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;
+ }
+ });
+
+ final SSLContext ctx = SSLContext.getInstance("TLS");
+
+ KeyManagerFactory kmf = null;
+ if (useClientCert) {
+
+ try {
+ kmf = KeyManagerFactory.getInstance("SunX509");
+ FileInputStream fin = new FileInputStream(keystore_path);
+ KeyStore ks = KeyStore.getInstance("PKCS12");
+ char[] pwd = decrypted_keystore_password.toCharArray();
+ ks.load(fin, pwd);
+ kmf.init(ks, pwd);
+ } catch (Exception e) {
+ //System.out.println("Error setting up kmf: exiting");
+ logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up kmf: exiting");
+ e.printStackTrace();
+ return null;
+ }
+ ctx.init(kmf.getKeyManagers(), null, null);
+
+ 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);
+ } else {
+ return ClientBuilder.newBuilder()
+ .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");
+ //System.out.println("Error setting up config: exiting");
+ e.printStackTrace();
+ System.exit(1);
+ return null;
+ }
+ }
+}
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
new file mode 100644
index 000000000..54d7f4684
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/HttpsComponentsClient.java
@@ -0,0 +1,99 @@
+/*-
+ * ============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 java.io.FileInputStream;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+
+import javax.net.ssl.SSLContext;
+
+import org.apache.http.conn.ssl.SSLContextBuilder;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.impl.client.HttpClients;
+import org.eclipse.jetty.util.security.Password;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+
+
+/**
+ * The Class HttpsComponentsClient.
+ */
+public class HttpsComponentsClient{
+
+ /**
+ * Gets the client.
+ *
+ * @param certFilePath the cert file path
+ * @return the client
+ * @throws KeyManagementException the key management exception
+ */
+ public static CloseableHttpClient getClient(String certFilePath) throws Exception {
+ 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");
+ FileInputStream fin = new FileInputStream(keystore_path);
+ char[] pwd = decrypted_keystore_password.toCharArray();
+ ks.load(fin, pwd);
+
+ sslContextB.loadKeyMaterial(ks, pwd);
+
+ KeyStore ts = KeyStore.getInstance("JKS");
+ FileInputStream fin1 = new FileInputStream(truststore_path);
+ char[] pwd1 = decrypted_truststore_password.toCharArray();
+ ts.load(fin1, pwd1);
+
+ 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 (Exception e) {
+ throw 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
new file mode 100644
index 000000000..8a3ba88ff
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/JettyObfuscationConversionCommandLineUtil.java
@@ -0,0 +1,78 @@
+/*-
+ * ============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.commons.cli.BasicParser;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.eclipse.jetty.util.security.Password;
+
+
+public class JettyObfuscationConversionCommandLineUtil {
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(String[] args){
+ Options options = new Options();
+ options.addOption("e", true, "obfuscate the given string");
+ options.addOption("d", true, "deobfuscate the given string");
+
+ CommandLineParser parser = new BasicParser();
+
+ try {
+ CommandLine cmd = parser.parse(options, args);
+ String toProcess = null;
+
+ if (cmd.hasOption("e")){
+ toProcess = cmd.getOptionValue("e");
+ String encoded = Password.obfuscate(toProcess);
+ System.out.println(encoded);
+ } else if (cmd.hasOption("d")) {
+ toProcess = cmd.getOptionValue("d");
+ String decoded_str = Password.deobfuscate(toProcess);
+ System.out.println(decoded_str);
+ } else {
+ usage();
+ }
+ } catch (ParseException e) {
+ System.out.println("failed to parse input");
+ System.out.println(e.toString());
+ usage();
+ } catch (Exception e) {
+ System.out.println("exception:" + e.toString());
+ }
+ }
+
+ /**
+ * Usage.
+ */
+ private static void usage(){
+ System.out.println("usage:");;
+ System.out.println("-e [string] to obfuscate");
+ System.out.println("-d [string] to deobfuscate");
+ System.out.println("-h help");
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcCatalogException.java b/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcCatalogException.java
new file mode 100644
index 000000000..01883d50e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcCatalogException.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.asdc;
+
+/**
+ * The Class AsdcCatalogException.
+ */
+public class AsdcCatalogException extends Exception {
+
+ /** The Constant serialVersionUID. */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Instantiates a new sdc catalog exception.
+ *
+ * @param msg the msg
+ */
+ public AsdcCatalogException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Instantiates a new sdc catalog exception.
+ *
+ * @param cause the cause
+ */
+ public AsdcCatalogException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Instantiates a new sdc catalog exception.
+ *
+ * @param msg the msg
+ * @param t the t
+ */
+ public AsdcCatalogException(String msg, Throwable t) {
+ super(msg, t);
+ }
+}
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
new file mode 100644
index 000000000..970ec954f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/AsdcClient.java
@@ -0,0 +1,129 @@
+/*-
+ * ============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.asdc;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.Map;
+import java.util.UUID;
+
+import org.onap.vid.asdc.beans.Artifact;
+import org.onap.vid.asdc.beans.Resource;
+import org.onap.vid.asdc.beans.Service;
+
+/**
+ * The Interface AsdcClient.
+ */
+public interface AsdcClient {
+
+ /**
+ * Gets the resource.
+ *
+ * @param uuid the uuid
+ * @return the resource
+ * @throws AsdcCatalogException the sdc catalog exception
+ */
+ public Resource getResource(UUID uuid) throws AsdcCatalogException;
+
+ /**
+ * Gets the resources.
+ *
+ * @return the resources
+ * @throws AsdcCatalogException the sdc catalog exception
+ */
+ public Collection<Resource> getResources() throws AsdcCatalogException;
+
+ /**
+ * Gets the resources.
+ *
+ * @param filter the filter
+ * @return the resources
+ * @throws AsdcCatalogException the sdc catalog exception
+ */
+ public Collection<Resource> getResources(Map<String, String[]> filter) throws AsdcCatalogException;
+
+ /**
+ * Gets the resource artifact.
+ *
+ * @param resourceUuid the resource uuid
+ * @param artifactUuid the artifact uuid
+ * @return the resource artifact
+ * @throws AsdcCatalogException the sdc catalog exception
+ */
+ public Artifact getResourceArtifact(UUID resourceUuid, UUID artifactUuid) throws AsdcCatalogException;
+
+ /**
+ * Gets the resource tosca model.
+ *
+ * @param uuid the uuid
+ * @return the resource tosca model
+ * @throws AsdcCatalogException the sdc catalog exception
+ */
+ public Path getResourceToscaModel(UUID uuid) throws AsdcCatalogException;
+
+ /**
+ * Gets the service.
+ *
+ * @param uuid the uuid
+ * @return the service
+ * @throws AsdcCatalogException the sdc catalog exception
+ */
+ public Service getService(UUID uuid) throws AsdcCatalogException;
+
+ /**
+ * Gets the services.
+ *
+ * @return the services
+ * @throws AsdcCatalogException the sdc catalog exception
+ */
+ public Collection<Service> getServices() throws AsdcCatalogException;
+
+ /**
+ * Gets the services.
+ *
+ * @param filter the filter
+ * @return the services
+ * @throws AsdcCatalogException the asdc catalog exception
+ */
+ public Collection<Service> getServices(Map<String, String[]> filter) throws AsdcCatalogException;
+
+ /**
+ * Gets the service artifact.
+ *
+ * @param serviceUuid the service uuid
+ * @param artifactUuid the artifact uuid
+ * @return the service artifact
+ * @throws AsdcCatalogException the asdc catalog exception
+ */
+ public Artifact getServiceArtifact(UUID serviceUuid, UUID artifactUuid) throws AsdcCatalogException;
+
+ /**
+ * Gets the service tosca model.
+ *
+ * @param uuid the uuid
+ * @return the service tosca model
+ * @throws AsdcCatalogException the asdc catalog exception
+ */
+ public Path getServiceToscaModel(UUID uuid) throws AsdcCatalogException;
+
+ //TODO: Collect TOSCA information from CSAR
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Artifact.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Artifact.java
new file mode 100644
index 000000000..c7e093ffb
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Artifact.java
@@ -0,0 +1,314 @@
+/*-
+ * ============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.asdc.beans;
+
+import java.util.UUID;
+
+/**
+ * The Class Artifact.
+ */
+public class Artifact {
+
+/*
+ * SDC has widened this to a String type for 1610.
+ public enum Type {
+ HEAT,
+ HEAT_ENV,
+ HEAT_VOL,
+ HEAT_NET,
+ HEAT_NESTED,
+ HEAT_ARTIFACT,
+ YANG_XML,
+ VNF_CATALOG,
+ VF_LICENSE,
+ VENDOR_LICENSE,
+ ASSET_INVENTORY_PROFILE,
+ ASSET_QUERY_SPEC,
+ APPC_CONFIG,
+ VF_MODULES_METADATA,
+ DCAE_TOSCA,
+ DCAE_JSON,
+ DCAE_EMF,
+ DCAE_DOC,
+ DCAE_BLUEPRINT,
+ DCAE_EVENT,
+ DCAE_INVENTORY_TOSCA,
+ DCAE_INVENTORY_JSON,
+ DCAE_INVENTORY_EMF,
+ DCAE_INVENTORY_DOC,
+ DCAE_INVENTORY_BLUEPRINT,
+ DCAE_INVENTORY_EVENT,
+ OTHER,
+ AAI_SERVICE_MODEL //HEY! READ ME! YES, YOU! I AM A TEMPORARY FIX, PLEASE REMOVE ME BECAUSE I AM A FRAUD. I DON'T BELONG HERE.
+ //Warm Regards,
+ // *The* Artifact.Type.AAI_SERVICE_MODEL Constant
+ }
+ */
+
+ /** The artifact name. */
+ private String artifactName;
+
+ /** The artifact label. */
+ private String artifactLabel;
+
+ /** The artifact group type. */
+ private String artifactGroupType;
+
+ /** The artifact type. */
+ private String artifactType;
+
+ /** The artifact URL. */
+ private String artifactURL;
+
+ /** The artifact description. */
+ private String artifactDescription;
+
+ /** The artifact timeout. */
+ private int artifactTimeout;
+
+ /** The artifact checksum. */
+ private String artifactChecksum;
+
+ /** The artifact UUID. */
+ private String artifactUUID;
+
+ /** The artifact version. */
+ private String artifactVersion;
+
+ /** The generated from UUID. */
+ private String generatedFromUUID;
+
+ /**
+ * Gets the artifact name.
+ *
+ * @return the artifact name
+ */
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ /**
+ * Gets the artifact type.
+ *
+ * @return the artifact type
+ */
+ public String getArtifactType() {
+ return artifactType;
+ }
+ /**
+ * Gets the artifact group type.
+ *
+ * @return the artifact group type
+ */
+ public String getArtifactGroupType() {
+ return artifactGroupType;
+ }
+
+ /**
+ * Gets the artifact label.
+ *
+ * @return the artifact label
+ */
+ public String getArtifactLabel() {
+ return artifactLabel;
+ }
+ /**
+ * Gets the artifact URL.
+ *
+ * @return the artifact URL
+ */
+ public String getArtifactURL() {
+ return artifactURL;
+ }
+
+ /**
+ * Gets the artifact description.
+ *
+ * @return the artifact description
+ */
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ /**
+ * Gets the artifact timeout.
+ *
+ * @return the artifact timeout
+ */
+ public int getArtifactTimeout() {
+ return artifactTimeout;
+ }
+
+ /**
+ * Gets the artifact checksum.
+ *
+ * @return the artifact checksum
+ */
+ public String getArtifactChecksum() {
+ return artifactChecksum;
+ }
+
+ /**
+ * Gets the artifact UUID.
+ *
+ * @return the artifact UUID
+ */
+ public String getArtifactUUID() {
+ return artifactUUID;
+ }
+
+ /**
+ * Gets the artifact version.
+ *
+ * @return the artifact version
+ */
+ public String getArtifactVersion() {
+ return artifactVersion;
+ }
+
+ /**
+ * Gets the generated from UUID.
+ *
+ * @return the generated from UUID
+ */
+ public String getGeneratedFromUUID() {
+ return generatedFromUUID;
+ }
+
+ /**
+ * Sets the artifact name.
+ *
+ * @param artifactName the new artifact name
+ */
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ /**
+ * Sets the artifact type.
+ *
+ * @param artifactType the new artifact type
+ */
+ public void setArtifactType(String artifactType) {
+ this.artifactType = artifactType;
+ }
+ /**
+ * Sets the artifact group type.
+ *
+ * @param artifactGroupType the new artifact group type
+ */
+ public void setArtifactGroupType(String artifactGroupType) {
+ this.artifactGroupType = artifactGroupType;
+ }
+ /**
+ * Sets the artifact label.
+ *
+ * @param artifactGroupType the new artifact label
+ */
+ public void setArtifactLabel(String artifactLabel) {
+ this.artifactLabel = artifactLabel;
+ }
+ /**
+ * Sets the artifact URL.
+ *
+ * @param artifactURL the new artifact URL
+ */
+ public void setArtifactURL(String artifactURL) {
+ this.artifactURL = artifactURL;
+ }
+
+ /**
+ * Sets the artifact description.
+ *
+ * @param artifactDescription the new artifact description
+ */
+ public void setArtifactDescription(String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ }
+
+ /**
+ * Sets the artifact timeout.
+ *
+ * @param artifactTimeout the new artifact timeout
+ */
+ public void setArtifactTimeout(int artifactTimeout) {
+ this.artifactTimeout = artifactTimeout;
+ }
+
+ /**
+ * Sets the artifact checksum.
+ *
+ * @param artifactChecksum the new artifact checksum
+ */
+ public void setArtifactChecksum(String artifactChecksum) {
+ this.artifactChecksum = artifactChecksum;
+ }
+
+ /**
+ * Sets the artifact UUID.
+ *
+ * @param artifactUUID the new artifact UUID
+ */
+ public void setArtifactUUID(String artifactUUID) {
+ this.artifactUUID = artifactUUID;
+ }
+
+ /**
+ * Sets the artifact version.
+ *
+ * @param artifactVersion the new artifact version
+ */
+ public void setArtifactVersion(String artifactVersion) {
+ this.artifactVersion = artifactVersion;
+ }
+
+ /**
+ * Sets the generated from UUID.
+ *
+ * @param generatedFromUUID the new generated from UUID
+ */
+ public void setGeneratedFromUUID(String generatedFromUUID) {
+ this.generatedFromUUID = generatedFromUUID;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final UUID uuid = UUID.fromString(getArtifactUUID());
+
+ return uuid.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if (!(o instanceof Artifact)) return false;
+
+ final Artifact artifact = (Artifact) o;
+
+ return (artifact.getArtifactUUID().equals(getArtifactUUID()));
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Resource.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Resource.java
new file mode 100644
index 000000000..6b5aa5320
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Resource.java
@@ -0,0 +1,429 @@
+/*-
+ * ============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.asdc.beans;
+
+import java.util.Collection;
+import java.util.UUID;
+
+/**
+ * The Class Resource.
+ */
+public class Resource {
+
+ /**
+ * The Enum Type.
+ */
+ public enum Type {
+
+ /** The vf. */
+ VF,
+
+ /** The vfc. */
+ VFC,
+
+ /** The cp. */
+ CP,
+
+ /** The vl. */
+ VL,
+
+ /** The vfcmt. */
+ VFCMT
+ }
+
+ /**
+ * The Enum LifecycleState.
+ */
+ public enum LifecycleState {
+
+ /** The not certified checkout. */
+ NOT_CERTIFIED_CHECKOUT,
+
+ /** The not certified checkin. */
+ NOT_CERTIFIED_CHECKIN,
+
+ /** The ready for certification. */
+ READY_FOR_CERTIFICATION,
+
+ /** The certification in progress. */
+ CERTIFICATION_IN_PROGRESS,
+
+ /** The certified. */
+ CERTIFIED
+ }
+
+ /** The uuid. */
+ private String uuid;
+
+ /** The invariant UUID. */
+ private String invariantUUID;
+
+ /** The name. */
+ private String name;
+
+ /** The description. */
+ private String description;
+
+ /** The version. */
+ private String version;
+
+ /** The tosca model URL. */
+ private String toscaModelURL;
+
+ /** The category. */
+ private String category;
+
+ /** The sub category. */
+ private String subCategory;
+
+ /** The resource type. */
+ private Resource.Type resourceType;
+
+ /** The lifecycle state. */
+ private Resource.LifecycleState lifecycleState;
+
+ /** The last updater user ID. */
+ private String lastUpdaterUserId;
+
+ /** The last updater full name. */
+ private String lastUpdaterFullName;
+
+ /** The tosca model. */
+ private String toscaModel;
+
+ /** The tosca resource name. */
+ private String toscaResourceName;
+
+ /** The artifacts. */
+ private Collection<Artifact> artifacts;
+
+ /** The resources. */
+ private Collection<SubResource> resources;
+
+ /**
+ * Gets the uuid.
+ *
+ * @return the uuid
+ */
+ public String getUuid() {
+ return uuid;
+ }
+
+ /**
+ * Gets the invariant UUID.
+ *
+ * @return the invariant UUID
+ */
+ public String getInvariantUUID() {
+ return invariantUUID;
+ }
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Gets the version.
+ *
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Gets the tosca model URL.
+ *
+ * @return the tosca model URL
+ */
+ public String getToscaModelURL() {
+ return toscaModelURL;
+ }
+
+ /**
+ * Gets the category.
+ *
+ * @return the category
+ */
+ public String getCategory() {
+ return category;
+ }
+
+ /**
+ * Gets the sub category.
+ *
+ * @return the sub category
+ */
+ public String getSubCategory() {
+ return subCategory;
+ }
+
+ /**
+ * Gets the resource type.
+ *
+ * @return the resource type
+ */
+ public Resource.Type getResourceType() {
+ return resourceType;
+ }
+
+ /**
+ * Gets the lifecycle state.
+ *
+ * @return the lifecycle state
+ */
+ public Resource.LifecycleState getLifecycleState() {
+ return lifecycleState;
+ }
+
+ /**
+ * Gets the last updater user ID.
+ *
+ * @return the last updater user ID
+ */
+ public String getLastUpdaterUserId() {
+ return lastUpdaterUserId;
+ }
+
+ /**
+ * Gets the last updater full name.
+ *
+ * @return the last updater full name
+ */
+ public String getLastUpdaterFullName() {
+ return lastUpdaterFullName;
+ }
+
+ /**
+ * Gets the tosca model.
+ *
+ * @return the tosca model
+ */
+ public String getToscaModel() {
+ return toscaModel;
+ }
+
+ /**
+ * Gets the tosca resource name.
+ *
+ * @return the tosca resource name
+ */
+ public String getToscaResourceName() {
+ return toscaResourceName;
+ }
+
+ /**
+ * Gets the artifacts.
+ *
+ * @return the artifacts
+ */
+ public Collection<Artifact> getArtifacts() {
+ return artifacts;
+ }
+
+ /**
+ * Gets the resources.
+ *
+ * @return the resources
+ */
+ public Collection<SubResource> getResources() {
+ return resources;
+ }
+
+ /**
+ * Sets the uuid.
+ *
+ * @param uuid the new uuid
+ */
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ /**
+ * Sets the invariant UUID.
+ *
+ * @param invariantUUID the new invariant UUID
+ */
+ public void setInvariantUUID(String invariantUUID) {
+ this.invariantUUID = invariantUUID;
+ }
+
+ /**
+ * Sets the name.
+ *
+ * @param name the new name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * Sets the description.
+ *
+ * @param name the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ /**
+ * Sets the version.
+ *
+ * @param version the new version
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ /**
+ * Sets the tosca model URL.
+ *
+ * @param toscaModelURL the new tosca model URL
+ */
+ public void setToscaModelURL(String toscaModelURL) {
+ this.toscaModelURL = toscaModelURL;
+ }
+
+ /**
+ * Sets the category.
+ *
+ * @param category the new category
+ */
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ /**
+ * Sets the sub category.
+ *
+ * @param subCategory the new sub category
+ */
+ public void setSubCategory(String subCategory) {
+ this.subCategory = subCategory;
+ }
+
+ /**
+ * Sets the resource type.
+ *
+ * @param resourceType the new resource type
+ */
+ public void setResourceType(Resource.Type resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ /**
+ * Sets the lifecycle state.
+ *
+ * @param lifecycleState the new lifecycle state
+ */
+ public void setLifecycleState(Resource.LifecycleState lifecycleState) {
+ this.lifecycleState = lifecycleState;
+ }
+
+ /**
+ * Sets the last updater user ID.
+ *
+ * @param lastUpdaterUserId the new last updater user ID
+ */
+ public void setLastUpdaterUserId(String lastUpdaterUserId) {
+ this.lastUpdaterUserId = lastUpdaterUserId;
+ }
+
+ /**
+ * Sets the last updater full name.
+ *
+ * @param lastUpdaterFullName the new last updater full name
+ */
+ public void setLastUpdaterFullName(String lastUpdaterFullName) {
+ this.lastUpdaterFullName = lastUpdaterFullName;
+ }
+
+ /**
+ * Sets the tosca model.
+ *
+ * @param toscaModel the new tosca model
+ */
+ public void setToscaModel(String toscaModel) {
+ this.toscaModel = toscaModel;
+ }
+
+ /**
+ * Sets the tosca resource name.
+ *
+ * @param toscaResourceName the new tosca resource name
+ */
+ public void setToscaResourceName(String toscaResourceName) {
+ this.toscaResourceName = toscaResourceName;
+ }
+
+ /**
+ * Sets the artifacts.
+ *
+ * @param artifacts the new artifacts
+ */
+ public void setArtifacts(Collection<Artifact> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ /**
+ * Sets the resources.
+ *
+ * @param resources the new resources
+ */
+ public void setResources(Collection<SubResource> resources) {
+ this.resources = resources;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final UUID uuid = UUID.fromString(getUuid());
+
+ return uuid.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if (!(o instanceof Resource)) return false;
+
+ final Resource resource = (Resource) o;
+
+ return (resource.getUuid().equals(getUuid()));
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/SecureService.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/SecureService.java
new file mode 100644
index 000000000..b81a43893
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/SecureService.java
@@ -0,0 +1,9 @@
+package org.onap.vid.asdc.beans;
+
+/**
+ * Created by Oren on 6/27/17.
+ */
+public class SecureService extends Service{
+
+ public boolean isPermmited = true;
+}
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
new file mode 100644
index 000000000..a6aa3de6f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/SecureServices.java
@@ -0,0 +1,30 @@
+package org.onap.vid.asdc.beans;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Created by Oren on 6/27/17.
+ */
+public class SecureServices {
+
+ private Collection<Service> services;
+ private boolean isReadOnly = true;
+
+ public void setServices(Collection<Service> services) {
+ this.services = services;
+ }
+
+ public Collection<Service> getServices() {
+
+ return services;
+ }
+ public boolean isReadOnly() {
+ return isReadOnly;
+ }
+
+ public void setReadOnly(boolean readOnly) {
+ isReadOnly = readOnly;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java
new file mode 100644
index 000000000..5f59b89e8
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java
@@ -0,0 +1,354 @@
+/*-
+ * ============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.asdc.beans;
+
+import java.util.Collection;
+import java.util.UUID;
+/**
+ * The Class Service.
+ */
+public class Service {
+
+ /**
+ * The Enum DistributionStatus.
+ */
+ public enum DistributionStatus {
+
+ /** The distribution not approved. */
+ DISTRIBUTION_NOT_APPROVED,
+
+ /** The distribution approved. */
+ DISTRIBUTION_APPROVED,
+
+ /** The distributed. */
+ DISTRIBUTED,
+
+ /** The distribution rejected. */
+ DISTRIBUTION_REJECTED,
+
+ /** The destributed for tenant isolation. */
+ DISTRIBUTION_COMPLETE_OK
+ }
+
+ /**
+ * The Enum LifecycleState.
+ */
+ public enum LifecycleState {
+
+ /** The not certified checkout. */
+ NOT_CERTIFIED_CHECKOUT,
+
+ /** The not certified checkin. */
+ NOT_CERTIFIED_CHECKIN,
+
+ /** The ready for certification. */
+ READY_FOR_CERTIFICATION,
+
+ /** The certification in progress. */
+ CERTIFICATION_IN_PROGRESS,
+
+ /** The certified. */
+ CERTIFIED
+ }
+
+ /** The uuid. */
+ private String uuid;
+
+ /** The invariant UUID. */
+ private String invariantUUID;
+
+ /** The name. */
+ private String name;
+
+ /** The version. */
+ private String version;
+
+ /** The tosca model URL. */
+ private String toscaModelURL;
+
+ /** The category. */
+ private String category;
+
+ /** The lifecycle state. */
+ private Service.LifecycleState lifecycleState;
+
+ /** The last updater user uid. */
+ private String lastUpdaterUserId;
+
+ /** The last updater full name. */
+ private String lastUpdaterFullName;
+
+ /** The distribution status. */
+ private Service.DistributionStatus distributionStatus;
+
+ /** The artifacts. */
+ private Collection<Artifact> artifacts;
+
+ /** The resources. */
+ private Collection<SubResource> resources;
+
+ /**
+ * Gets the uuid.
+ *
+ * @return the uuid
+ */
+ public String getUuid() {
+ return uuid;
+ }
+
+ /**
+ * Gets the invariant UUID.
+ *
+ * @return the invariant UUID
+ */
+ public String getInvariantUUID() {
+ return invariantUUID;
+ }
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the version.
+ *
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Gets the tosca model URL.
+ *
+ * @return the tosca model URL
+ */
+ public String getToscaModelURL() {
+ return toscaModelURL;
+ }
+
+ /**
+ * Gets the category.
+ *
+ * @return the category
+ */
+ public String getCategory() {
+ return category;
+ }
+
+ /**
+ * Gets the lifecycle state.
+ *
+ * @return the lifecycle state
+ */
+ public Service.LifecycleState getLifecycleState() {
+ return lifecycleState;
+ }
+
+ /**
+ * Gets the last updater user uid.
+ *
+ * @return the last updater user uid
+ */
+ public String getLastUpdaterUserId() {
+ return lastUpdaterUserId;
+ }
+
+ /**
+ * Gets the last updater full name.
+ *
+ * @return the last updater full name
+ */
+ public String getLastUpdaterFullName() {
+ return lastUpdaterFullName;
+ }
+
+ /**
+ * Gets the distribution status.
+ *
+ * @return the distribution status
+ */
+ public Service.DistributionStatus getDistributionStatus() {
+ return distributionStatus;
+ }
+
+ /**
+ * Gets the artifacts.
+ *
+ * @return the artifacts
+ */
+ public Collection<Artifact> getArtifacts() {
+ return artifacts;
+ }
+
+ /**
+ * Gets the resources.
+ *
+ * @return the resources
+ */
+ public Collection<SubResource> getResources() {
+ return resources;
+ }
+
+ /**
+ * Sets the uuid.
+ *
+ * @param uuid the new uuid
+ */
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ /**
+ * Sets the invariant UUID.
+ *
+ * @param invariantUUID the new invariant UUID
+ */
+ public void setInvariantUUID(String invariantUUID) {
+ this.invariantUUID = invariantUUID;
+ }
+
+ /**
+ * Sets the name.
+ *
+ * @param name the new name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the version.
+ *
+ * @param version the new version
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ /**
+ * Sets the tosca model URL.
+ *
+ * @param toscaModelURL the new tosca model URL
+ */
+ public void setToscaModelURL(String toscaModelURL) {
+ this.toscaModelURL = toscaModelURL;
+ }
+
+ /**
+ * Sets the category.
+ *
+ * @param category the new category
+ */
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ /**
+ * Sets the lifecycle state.
+ *
+ * @param lifecycleState the new lifecycle state
+ */
+ public void setLifecycleState(Service.LifecycleState lifecycleState) {
+ this.lifecycleState = lifecycleState;
+ }
+
+ /**
+ * Sets the last updater user uid.
+ *
+ * @param lastUpdaterUserId the new last updater user uid
+ */
+ public void set(String lastUpdaterUserId) {
+ this.lastUpdaterUserId = lastUpdaterUserId;
+ }
+
+ /**
+ * Sets the last updater full name.
+ *
+ * @param lastUpdaterFullName the new last updater full name
+ */
+ public void setLastUpdaterFullName(String lastUpdaterFullName) {
+ this.lastUpdaterFullName = lastUpdaterFullName;
+ }
+
+ /**
+ * Sets the distribution status.
+ *
+ * @param distributionStatus the new distribution status
+ */
+ public void setDistributionStatus(Service.DistributionStatus distributionStatus) {
+ this.distributionStatus = distributionStatus;
+ }
+
+ /**
+ * Sets the artifacts.
+ *
+ * @param artifacts the new artifacts
+ */
+ public void setArtifacts(Collection<Artifact> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ /**
+ * Sets the resources.
+ *
+ * @param resources the new resources
+ */
+ public void setResources(Collection<SubResource> resources) {
+ this.resources = resources;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return uuid;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final UUID uuid = UUID.fromString(getUuid());
+
+ return uuid.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if (!(o instanceof Service)) return false;
+
+ final Service service = (Service) o;
+
+ return (service.getUuid().equals(getUuid()));
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/SubResource.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/SubResource.java
new file mode 100644
index 000000000..5f7811d64
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/SubResource.java
@@ -0,0 +1,175 @@
+/*-
+ * ============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.asdc.beans;
+
+import java.util.Collection;
+/**
+ * The Class SubResource.
+ */
+public class SubResource {
+
+ /** The resource instance name. */
+ private String resourceInstanceName;
+
+ /** The resource name. */
+ private String resourceName;
+
+ /** The resource invariant UUID. */
+ private String resourceInvariantUUID;
+
+ /** The resource version. */
+ private String resourceVersion;
+
+ /** The resource type. */
+ private String resourceType;
+
+ /** The resource UUID. */
+ private String resourceUUID;
+
+ /** The artifacts. */
+ private Collection<Artifact> artifacts;
+
+ /**
+ * Gets the resource instance name.
+ *
+ * @return the resource instance name
+ */
+ public String getResourceInstanceName() {
+ return resourceInstanceName;
+ }
+
+ /**
+ * Gets the resource name.
+ *
+ * @return the resource name
+ */
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ /**
+ * Gets the resource invariant UUID.
+ *
+ * @return the resource invariant UUID
+ */
+ public String getResourceInvariantUUID() {
+ return resourceInvariantUUID;
+ }
+
+ /**
+ * Gets the resource version.
+ *
+ * @return the resource version
+ */
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ /**
+ * Gets the resoucre type.
+ *
+ * @return the resoucre type
+ */
+ public String getResoucreType() {
+ return resourceType;
+ }
+
+ /**
+ * Gets the resource UUID.
+ *
+ * @return the resource UUID
+ */
+ public String getResourceUUID() {
+ return resourceUUID;
+ }
+
+ /**
+ * Gets the artifacts.
+ *
+ * @return the artifacts
+ */
+ public Collection<Artifact> getArtifacts() {
+ return artifacts;
+ }
+
+ /**
+ * Sets the resource instance name.
+ *
+ * @param resourceInstanceName the new resource instance name
+ */
+ public void setResourceInstanceName(String resourceInstanceName) {
+ this.resourceInstanceName = resourceInstanceName;
+ }
+
+ /**
+ * Sets the resource name.
+ *
+ * @param resourceName the new resource name
+ */
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ /**
+ * Sets the resource invariant UUID.
+ *
+ * @param resourceInvariantUUID the new resource invariant UUID
+ */
+ public void setResourceInvariantUUID(String resourceInvariantUUID) {
+ this.resourceInvariantUUID = resourceInvariantUUID;
+ }
+
+ /**
+ * Sets the resource version.
+ *
+ * @param resourceVersion the new resource version
+ */
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ /**
+ * Sets the resoucre type.
+ *
+ * @param resourceType the new resoucre type
+ */
+ public void setResoucreType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ /**
+ * Sets the resource UUID.
+ *
+ * @param resourceUUID the new resource UUID
+ */
+ public void setResourceUUID(String resourceUUID) {
+ this.resourceUUID = resourceUUID;
+ }
+
+ /**
+ * Sets the artifacts.
+ *
+ * @param artifacts the new artifacts
+ */
+ public void setArtifacts(Collection<Artifact> artifacts) {
+ this.artifacts = artifacts;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Capability.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Capability.java
new file mode 100644
index 000000000..7aa13435d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Capability.java
@@ -0,0 +1,140 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * The Class Capability.
+ */
+public class Capability {
+
+ /** The type. */
+ private String type; //FIXME: Make an enumeration?
+
+ /** The description. */
+ private String description;
+
+ /** The occurrences. */
+ private Collection<String> occurrences; //FIXME: Make an enumeration?
+
+ /** The properties. */
+ private Map<String, Property> properties;
+
+ /** The valid source types. */
+ private Collection<String> valid_source_types; //FIXME: Make an enumeration?
+
+ /**
+ * Instantiates a new capability.
+ */
+ public Capability() {}
+
+ /**
+ * Gets the type.
+ *
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Gets the occurrences.
+ *
+ * @return the occurrences
+ */
+ public Collection<String> getOccurrences() {
+ return occurrences;
+ }
+
+ /**
+ * Gets the properties.
+ *
+ * @return the properties
+ */
+ public Map<String, Property> getProperties() {
+ return properties;
+ }
+
+ /**
+ * Gets the valid source types.
+ *
+ * @return the valid source types
+ */
+ public Collection<String> getValid_source_types() {
+ return valid_source_types;
+ }
+
+ /**
+ * Sets the type.
+ *
+ * @param type the new type
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Sets the occurrences.
+ *
+ * @param occurrences the new occurrences
+ */
+ public void setOccurrences(Collection<String> occurrences) {
+ this.occurrences = occurrences;
+ }
+
+ /**
+ * Sets the properties.
+ *
+ * @param properties the properties
+ */
+ public void setProperties(Map<String, Property> properties) {
+ this.properties = properties;
+ }
+
+ /**
+ * Sets the valid source types.
+ *
+ * @param valid_source_types the new valid source types
+ */
+ public void setValid_source_types(Collection<String> valid_source_types) {
+ this.valid_source_types = valid_source_types;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Constraint.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Constraint.java
new file mode 100644
index 000000000..118776cab
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Constraint.java
@@ -0,0 +1,199 @@
+/*-
+ * ============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.asdc.beans.tosca;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * The Class Constraint.
+ */
+
+public class Constraint {
+ private List<Object> valid_values;
+ private Object equal;
+ private Object greater_than;
+ private Object greater_or_equal;
+ private Object less_than;
+ private Object less_or_equal;
+ private List<Object> in_range;
+ private Object length;
+ private Object min_length;
+ private Object max_length;
+
+ /**
+ * Instantiates a new Constraint.
+ */
+ public Constraint() {
+ valid_values = new ArrayList<Object>();
+ in_range = new ArrayList<Object>();
+ }
+
+ /**
+ * Gets the valid_values.
+ *
+ * @return the valid_values
+ */
+ public List<Object> getvalid_values() {
+ return valid_values;
+ }
+ /**
+ * Gets equal.
+ *
+ * @return equal
+ */
+ public Object getEqual() {
+ return equal;
+ }
+ /**
+ * Gets greater_than.
+ *
+ * @return greater_than
+ */
+ public Object getGreater_than() {
+ return greater_than;
+ }
+ /**
+ * Gets greater_or_equal.
+ *
+ * @return greater_or_equal
+ */
+ public Object getGreater_or_equal() {
+ return greater_or_equal;
+ }
+ /**
+ * Gets less_than.
+ *
+ * @return less_than
+ */
+ public Object getLess_than() {
+ return less_than;
+ }
+ /**
+ * Gets less_or_equal.
+ *
+ * @return less_or_equal
+ */
+ public Object getLess_or_equal() {
+ return less_or_equal;
+ }
+ /**
+ * Gets in_range.
+ *
+ * @return in_range
+ */
+ public List<Object> getIn_range() {
+ return in_range;
+ }
+ /**
+ * Gets length.
+ *
+ * @return length
+ */
+ public Object getLength() {
+ return length;
+ }
+ /**
+ * Gets min_length.
+ *
+ * @return min_length
+ */
+ public Object getMin_length() {
+ return min_length;
+ }
+ /**
+ * Gets max_length.
+ *
+ * @return max_length
+ */
+ public Object getMax_length() {
+ return max_length;
+ }
+ /**
+ * Sets the valid_values.
+ *
+ * @param op the new valid_values
+ */
+ public void setvalid_values(List<Object> vlist) {
+ this.valid_values = vlist;
+ }
+ /**
+ * Sets equal.
+ *
+ * @param e the new equal
+ */
+ public void setEqual(Object e) {
+ this.equal = e;
+ }
+ /**
+ * Sets greater_than.
+ *
+ * @param e the new greater_than
+ */
+ public void setGreater_than(Object e) {
+ this.greater_than = e;
+ }
+ /**
+ * Sets less_than.
+ *
+ * @param e the new less_than
+ */
+ public void setLess_than(Object e) {
+ this.less_than = e;
+ }
+ /**
+ * Sets in_range.
+ *
+ * @param e the new in_range
+ */
+ public void setIn_range(List<Object> e) {
+ this.in_range = e;
+ }
+ /**
+ * Sets length.
+ *
+ * @param e the length
+ */
+ public void setLength(Object e) {
+ this.length = e;
+ }
+ /**
+ * Sets min_length.
+ *
+ * @param e the min_length
+ */
+ public void setMin_length(Object e) {
+ this.min_length = e;
+ }
+ /**
+ * Sets max_length.
+ *
+ * @param e the max_length
+ */
+ public void setMax_length(Object e) {
+ this.max_length = e;
+ }
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "valid_values=" + valid_values;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Group.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Group.java
new file mode 100644
index 000000000..2685b22b8
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Group.java
@@ -0,0 +1,135 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * The Class Group.
+ */
+public class Group {
+
+ /** The type. */
+ private String type;
+
+ /** The members. */
+ private Collection<String> members;
+
+ /** The metadata. */
+ private ToscaMetadata metadata;
+
+ /** The vf module type. */
+ private String vf_module_type;
+
+ /** The properties. */
+ private Map<String, Object> properties;
+
+ /**
+ * Gets the metadata.
+ *
+ * @return the metadata
+ */
+ public ToscaMetadata getMetadata() {
+ return metadata;
+ }
+
+ /**
+ * Sets the metadata.
+ *
+ * @param metadata the new metadata
+ */
+ public void setMetadata(ToscaMetadata metadata) {
+ this.metadata = metadata;
+ }
+
+ /**
+ * Gets the members.
+ *
+ * @return the members
+ */
+ public Collection<String> getMembers() {
+ return members;
+ }
+
+ /**
+ * Sets the members.
+ *
+ * @param members the new members
+ */
+ public void setMembers(Collection<String> members) {
+ this.members = members;
+ }
+
+ /**
+ * Gets the type.
+ *
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the type.
+ *
+ * @param type the new type
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Gets the vf module type.
+ *
+ * @return the vf module type
+ */
+ public String getvf_module_type() {
+ return vf_module_type;
+ }
+
+ /**
+ * Sets the vf module type.
+ *
+ * @param vf_module_type the new vf module type
+ */
+ public void setvf_module_type(String vf_module_type) {
+ this.vf_module_type = vf_module_type;
+ }
+
+ /**
+ * Gets the properties.
+ *
+ * @return the properties
+ */
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ /**
+ * Sets the properties.
+ *
+ * @param properties the properties
+ */
+ public void setProperties(Map<String, Object> properties) {
+ this.properties = properties;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Import.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Import.java
new file mode 100644
index 000000000..dcd66e605
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Import.java
@@ -0,0 +1,48 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+/**
+ * The Class Import.
+ */
+public class Import {
+
+ /** The file. */
+ private String file;
+
+ /**
+ * Gets the file.
+ *
+ * @return the file
+ */
+ public String getFile() {
+ return file;
+ }
+
+ /**
+ * Sets the file.
+ *
+ * @param file the new file
+ */
+ public void setFile(String file) {
+ this.file = file;
+ }
+}
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
new file mode 100644
index 000000000..e485a65e2
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Input.java
@@ -0,0 +1,168 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+import org.openecomp.sdc.toscaparser.api.elements.constraints.*;
+
+import java.util.List;
+import java.util.ArrayList;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class Input.
+ */
+public class Input {
+
+ /** The type. */
+ private String type;
+
+ /** The description. */
+ private String description;
+
+ /** The default. */
+ private Object _default;
+
+ /** The entry schema. */
+ private Input entry_schema;
+
+ /** The constraints */
+ private List<org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint> constraints;
+
+ /** The required field. If not set, the default is true */
+ private boolean required = true;
+
+ /**
+ * Instantiates a new input.
+ */
+ public Input() {
+ constraints = new ArrayList<org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint>();
+ }
+
+ /**
+ * Gets the type.
+ *
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the type.
+ *
+ * @param type the new type
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+ /**
+ * Gets the required field.
+ *
+ * @return the required field
+ */
+ public boolean getRequired() {
+ return required;
+ }
+ /**
+ * Sets the required value.
+ *
+ * @param required the new required value
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Gets the default.
+ *
+ * @return the default
+ */
+ public Object getDefault() {
+ return _default;
+ }
+
+ /**
+ * Sets the default.
+ *
+ * @param _default the new default
+ */
+ public void setDefault(Object _default) {
+ this._default = _default;
+ }
+
+ /**
+ * Gets the entry schema.
+ *
+ * @return the entry schema
+ */
+ public Input getentry_schema() {
+ return entry_schema;
+ }
+ /**
+ * Sets the entry schema.
+ *
+ * @param the entry schema
+ */
+ public void setentry_schema(Input s) {
+ this.entry_schema = s;
+ }
+ /**
+ * Sets the constraints.
+ *
+ * @param c the new constraints
+ */
+ public void setConstraints(List<org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint> c) {
+ this.constraints = c;
+ }
+ /**
+ * Gets the constraints
+ *
+ * @return the constraints
+ */
+ public List<org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint> getConstraints() {
+ return constraints;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "type=" + type + ",description=" + description + ",default=" + _default;
+ }
+}
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
new file mode 100644
index 000000000..28210b2ec
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/NodeTemplate.java
@@ -0,0 +1,117 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * The Class NodeTemplate.
+ */
+public class NodeTemplate {
+
+ /** The type. */
+ private String type;
+
+ /** The metadata. */
+ private ToscaMetadata metadata;
+
+ /** The properties. */
+ private Map<String, Object> properties; //HEAT?
+
+ /** The requirements. */
+ private Object requirements;
+
+ public NodeTemplate () {
+ properties = new HashMap<String,Object>();
+ }
+ /**
+ * Gets the type.
+ *
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the type.
+ *
+ * @param type the new type
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Gets the metadata.
+ *
+ * @return the metadata
+ */
+ public ToscaMetadata getMetadata() {
+ return metadata;
+ }
+
+ /**
+ * Sets the metadata.
+ *
+ * @param metadata the new metadata
+ */
+ public void setMetadata(ToscaMetadata metadata) {
+ this.metadata = metadata;
+ }
+
+ /**
+ * Gets the properties.
+ *
+ * @return the properties
+ */
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ /**
+ * Sets the properties.
+ *
+ * @param properties the properties
+ */
+ public void setProperties(Map<String, Object> properties) {
+ this.properties = properties;
+ }
+
+ /**
+ * Gets the requirements.
+ *
+ * @return the requirements
+ */
+ public Object getRequirements() {
+ return requirements;
+ }
+
+ /**
+ * Sets the requirements.
+ *
+ * @param requirements the new requirements
+ */
+ public void setRequirements(Object requirements) {
+ this.requirements = requirements;
+ }
+}
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
new file mode 100644
index 000000000..107f5c82f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Property.java
@@ -0,0 +1,157 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+/**
+ * The Class Property.
+ */
+public class Property {
+
+ /** The type. */
+ private String type;
+
+ /** The description. */
+ private String description;
+
+ /** The entry schema. */
+ private Schema entry_schema;
+
+ /** The default. */
+ private String _default;
+
+ /** The required. */
+ private boolean required;
+
+ /**
+ * Instantiates a new property.
+ */
+ private Property() {}
+
+ /**
+ * Gets the type.
+ *
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Gets the entry schema.
+ *
+ * @return the entry schema
+ */
+ public Schema getEntry_schema() {
+ return entry_schema;
+ }
+
+ /**
+ * Gets the default.
+ *
+ * @return the default
+ */
+ public String get_default() {
+ return _default;
+ }
+
+ /**
+ * Sets the type.
+ *
+ * @param type the new type
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Sets the entry schema.
+ *
+ * @param entry_schema the new entry schema
+ */
+ public void setEntry_schema(Schema entry_schema) {
+ this.entry_schema = entry_schema;
+ }
+
+ /**
+ * Sets the default.
+ *
+ * @param _default the new default
+ */
+ public void set_default(String _default) {
+ this._default = _default;
+ }
+
+ /**
+ * Gets the default.
+ *
+ * @return the default
+ */
+ public String getDefault() {
+ return _default;
+ }
+
+ /**
+ * Checks if is required.
+ *
+ * @return true, if is required
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * Sets the default.
+ *
+ * @param _default the new default
+ */
+ public void setDefault(String _default) {
+ this._default = _default;
+ }
+
+ /**
+ * Sets the required.
+ *
+ * @param required the new required
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Requirement.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Requirement.java
new file mode 100644
index 000000000..0c2f88493
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Requirement.java
@@ -0,0 +1,120 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+import java.util.Collection;
+
+/**
+ * The Class Requirement.
+ */
+public class Requirement {
+
+ /** The occurrences. */
+ private Collection<String> occurrences;
+
+ /** The capability. */
+ private String capability;
+
+ /** The node. */
+ private String node;
+
+ /** The relationship. */
+ private String relationship;
+
+ /**
+ * Instantiates a new requirement.
+ */
+ private Requirement() {}
+
+ /**
+ * Gets the occurrences.
+ *
+ * @return the occurrences
+ */
+ public Collection<String> getOccurrences() {
+ return occurrences;
+ }
+
+ /**
+ * Gets the capability.
+ *
+ * @return the capability
+ */
+ public String getCapability() {
+ return capability;
+ }
+
+ /**
+ * Gets the node.
+ *
+ * @return the node
+ */
+ public String getNode() {
+ return node;
+ }
+
+ /**
+ * Gets the relationship.
+ *
+ * @return the relationship
+ */
+ public String getRelationship() {
+ return relationship;
+ }
+
+ /**
+ * Sets the occurrences.
+ *
+ * @param occurrences the new occurrences
+ */
+ public void setOccurrences(Collection<String> occurrences) {
+ this.occurrences = occurrences;
+ }
+
+ /**
+ * Sets the capability.
+ *
+ * @param capability the new capability
+ */
+ public void setCapability(String capability) {
+ this.capability = capability;
+ }
+
+ /**
+ * Sets the node.
+ *
+ * @param node the new node
+ */
+ public void setNode(String node) {
+ this.node = node;
+ }
+
+ /**
+ * Sets the relationship.
+ *
+ * @param relationship the new relationship
+ */
+ public void setRelationship(String relationship) {
+ this.relationship = relationship;
+ }
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Schema.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Schema.java
new file mode 100644
index 000000000..7bf347708
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/Schema.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+/**
+ * The Class Schema.
+ */
+public class Schema {
+
+ /** The type. */
+ public String type;
+
+ /**
+ * Instantiates a new schema.
+ */
+ public Schema() {}
+
+ /**
+ * Gets the type.
+ *
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the type.
+ *
+ * @param type the new type
+ */
+ public void setType(String type) {
+ this.type = 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
new file mode 100644
index 000000000..70779c5f2
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/SubstitutionMappings.java
@@ -0,0 +1,101 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The Class SubstitutionMappings.
+ */
+public class SubstitutionMappings {
+
+ /** The node type. */
+ private String node_type;
+
+ /** The capabilities. */
+ private Map<String, Object> capabilities;
+
+ /** The requirements. */
+ private Map<String, Object> requirements;
+
+ /**
+ * Instantiates a new substitution mappings.
+ */
+ public SubstitutionMappings() {
+ capabilities = new HashMap<String, Object> ();
+ requirements = new HashMap<String, Object> ();
+ }
+
+ /**
+ * Gets the node type.
+ *
+ * @return the node type
+ */
+ public String getnode_type() {
+ return node_type;
+ }
+
+ /**
+ * Sets the node type.
+ *
+ * @param node_type the new node type
+ */
+ public void setnode_type(String node_type) {
+ this.node_type = node_type;
+ }
+
+ /**
+ * Gets the capabilities.
+ *
+ * @return the capabilities
+ */
+ public Map<String, Object> getCapabilities() {
+ return capabilities;
+ }
+
+ /**
+ * Sets the capabilities.
+ *
+ * @param capabilities the capabilities
+ */
+ public void setCapabilities(Map<String, Object> capabilities) {
+ this.capabilities = capabilities;
+ }
+
+ /**
+ * Gets the requirements.
+ *
+ * @return the requirements
+ */
+ public Map<String, Object> getRequirements() {
+ return requirements;
+ }
+
+ /**
+ * Sets the requirements.
+ *
+ * @param requirements the requirements
+ */
+ public void setRequirements(Map<String, Object> requirements) {
+ this.requirements = requirements;
+ }
+}
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
new file mode 100644
index 000000000..70830715e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/TopologyTemplate.java
@@ -0,0 +1,124 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The Class TopologyTemplate.
+ */
+public class TopologyTemplate {
+
+ /** The substitution mappings. */
+ private SubstitutionMappings substitution_mappings;
+
+ /** The inputs. */
+ private Map<String, Input> inputs;
+
+ /** The node templates. */
+ private Map<String, NodeTemplate> node_templates;
+
+ /** The groups. */
+ private Map<String, Group> groups;
+
+ /**
+ * Instantiates a new topology template.
+ */
+ public TopologyTemplate() {
+ substitution_mappings = new SubstitutionMappings();
+ inputs = new HashMap<String, Input> ();
+ node_templates = new HashMap<String, NodeTemplate> ();
+ groups = new HashMap<String, Group> ();
+ }
+
+ /**
+ * Gets the substitution mappings.
+ *
+ * @return the substitution mappings
+ */
+ public SubstitutionMappings getsubstitution_mappings() {
+ return this.substitution_mappings;
+ }
+
+ /**
+ * Sets the substitution mappings.
+ *
+ * @param substitution_mappings the new substitution mappings
+ */
+ public void setsubstitution_mappings(SubstitutionMappings substitution_mappings) {
+ this.substitution_mappings = substitution_mappings;
+ }
+
+ /**
+ * Gets the inputs.
+ *
+ * @return the inputs
+ */
+ public Map<String, Input> getInputs() {
+ return inputs;
+ }
+
+ /**
+ * Sets the inputs.
+ *
+ * @param inputs the inputs
+ */
+ public void setInputs(Map<String, Input> inputs) {
+ this.inputs = inputs;
+ }
+
+ /**
+ * Gets the node templates.
+ *
+ * @return the node templates
+ */
+ public Map<String, NodeTemplate> getnode_templates() {
+ return node_templates;
+ }
+
+ /**
+ * Setnode templates.
+ *
+ * @param node_templates the node templates
+ */
+ public void setnode_templates(Map<String, NodeTemplate> node_templates) {
+ this.node_templates = node_templates;
+ }
+
+ /**
+ * Gets the groups.
+ *
+ * @return the groups
+ */
+ public Map<String, Group> getGroups() {
+ return groups;
+ }
+
+ /**
+ * Sets the groups.
+ *
+ * @param groups the groups
+ */
+ public void setGroups(Map<String, Group> groups) {
+ this.groups = groups;
+ }
+}
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
new file mode 100644
index 000000000..678583573
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaCsar.java
@@ -0,0 +1,101 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+/**
+ * The Class ToscaCsar.
+ */
+public class ToscaCsar {
+
+ /** The parent. */
+ private final ToscaModel parent;
+
+ /** The children. */
+ private final Collection<ToscaModel> children;
+
+ /**
+ * The Class Builder.
+ */
+ public static class Builder {
+
+ /** The parent. */
+ private final ToscaModel parent;
+
+ /** The children. */
+ private Collection<ToscaModel> children = new LinkedList<ToscaModel> ();
+
+ /**
+ * Instantiates a new builder.
+ *
+ * @param parent the parent
+ */
+ public Builder(ToscaModel parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * Adds the vnf.
+ *
+ * @param child the child
+ * @return the builder
+ */
+ public Builder addVnf(ToscaModel child) {
+ children.add(child);
+ return this;
+ }
+
+ /**
+ * Builds the.
+ *
+ * @return the tosca csar
+ */
+ public ToscaCsar build() {
+ return new ToscaCsar(this);
+ }
+ }
+
+ /**
+ * Instantiates a new tosca csar.
+ *
+ * @param builder the builder
+ */
+ public ToscaCsar(Builder builder) {
+ this.parent = builder.parent;
+ this.children = builder.children;
+ }
+
+ /**
+ * Gets the parent.
+ *
+ * @return the parent
+ */
+ public ToscaModel getParent() { return parent; }
+
+ /**
+ * Gets the children.
+ *
+ * @return the children
+ */
+ public Collection<ToscaModel> getChildren() { return children; }
+}
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
new file mode 100644
index 000000000..a7a6c6296
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaMeta.java
@@ -0,0 +1,124 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.onap.vid.asdc.AsdcCatalogException;
+
+/**
+ * The Class ToscaMeta.
+ */
+public class ToscaMeta {
+
+ /** The metadata. */
+ private final Map<String, String> metadata;
+
+ /**
+ * Instantiates a new tosca meta.
+ *
+ * @param builder the builder
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws AsdcCatalogException the asdc catalog exception
+ */
+ private ToscaMeta(Builder builder) throws IOException, AsdcCatalogException {
+ metadata = new HashMap<String, String> ();
+
+ read(builder.inputStream);
+ }
+
+ /**
+ * The Class Builder.
+ */
+ public static class Builder {
+
+ /** The input stream. */
+ private final InputStream inputStream;
+
+ /**
+ * Instantiates a new builder.
+ *
+ * @param inputStream the input stream
+ */
+ public Builder(InputStream inputStream) {
+ this.inputStream = inputStream;
+ }
+
+ /**
+ * Builds the.
+ *
+ * @return the tosca meta
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws AsdcCatalogException the asdc catalog exception
+ */
+ public ToscaMeta build() throws IOException, AsdcCatalogException {
+ return new ToscaMeta(this);
+ }
+ }
+
+ /**
+ * Gets the.
+ *
+ * @param property the property
+ * @return the string
+ */
+ public String get(String property) {
+ return metadata.get(property);
+ }
+
+ /**
+ * Read.
+ *
+ * @param inputStream the input stream
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws AsdcCatalogException the asdc catalog exception
+ */
+ private void read(InputStream inputStream) throws IOException, AsdcCatalogException {
+
+ final BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
+
+ String line;
+
+ try {
+ while ((line = br.readLine()) != null) {
+ if ( line.length() > 0 ) {
+ final String[] entry = line.split(":");
+
+ if (entry.length != 2) throw new AsdcCatalogException("TOSCA.meta file cannot be parsed (more than 1 colon found on a single line");
+ if (!entry[1].startsWith(" ")) throw new AsdcCatalogException("TOSCA.meta file cannot be parsed (: not immediately followed by ' ')");
+
+ metadata.put(entry[0], entry[1].substring(1));
+ }
+ }
+ } catch (IOException e) {
+ metadata.clear();
+ throw e;
+ } catch (AsdcCatalogException e) {
+ metadata.clear();
+ throw e;
+ }
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaMetadata.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaMetadata.java
new file mode 100644
index 000000000..32e9fbac6
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaMetadata.java
@@ -0,0 +1,461 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+/**
+ * The Class ToscaMetadata.
+ */
+public class ToscaMetadata {
+
+ /** The template name. */
+ private String template_name;
+
+ /** The invariant UUID. */
+ private String invariantUUID;
+
+ /** The customization UUID. */
+ private String customizationUUID;
+
+ /** The uuid. */
+ private String uuid;
+
+ /** The version. */
+ private String version;
+
+ /** The name. */
+ private String name;
+
+ /** The description. */
+ private String description;
+
+ /** The category. */
+ private String category;
+
+ /** The subcategory. */
+ private String subcategory;
+
+ /** The type. */
+ private String type;
+
+ /** The resource vendor. */
+ private String resourceVendor;
+
+ /** The resource vendor release. */
+ private String resourceVendorRelease;
+
+ /** The service ecomp naming. */
+ private String serviceEcompNaming;
+
+ /** The ecomp generated naming - duplicate for serviceEcompNaming */
+ private boolean ecompGeneratedNaming;
+
+ /** The naming policy */
+ private String namingPolicy;
+
+ /** The service homing. */
+ private boolean serviceHoming;
+
+ /** The vf module model name. */
+ //ToscaMetadata for VF Modules
+ private String vfModuleModelName;
+
+ /** The vf module model invariant UUID. */
+ private String vfModuleModelInvariantUUID;
+
+ /** The vf module model customization UUID. */
+ private String vfModuleModelCustomizationUUID;
+
+ /** The vf module model UUID. */
+ private String vfModuleModelUUID;
+
+ /** The vf module model version. */
+ private String vfModuleModelVersion;
+
+ /**
+ * Instantiates a new tosca metadata.
+ */
+ public ToscaMetadata() {}
+
+ /**
+ * Gets the type.
+ *
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Gets the invariant UUID.
+ *
+ * @return the invariant UUID
+ */
+ public String getInvariantUUID() {
+ return invariantUUID;
+ }
+ /**
+ * Gets the customization UUID.
+ *
+ * @return the customization UUID
+ */
+ public String getCustomizationUUID() {
+ return customizationUUID;
+ }
+ /**
+ * Gets the uuid.
+ *
+ * @return the uuid
+ */
+ public String getUUID() {
+ return uuid;
+ }
+
+ /**
+ * Gets the version.
+ *
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Gets the category.
+ *
+ * @return the category
+ */
+ public String getCategory() {
+ return category;
+ }
+
+ /**
+ * Gets the subcategory.
+ *
+ * @return the subcategory
+ */
+ public String getSubcategory() {
+ return subcategory;
+ }
+
+ /**
+ * Gets the resource vendor.
+ *
+ * @return the resource vendor
+ */
+ public String getResourceVendor() {
+ return resourceVendor;
+ }
+
+ /**
+ * Gets the resource vendor release.
+ *
+ * @return the resource vendor release
+ */
+ public String getResourceVendorRelease() {
+ return resourceVendorRelease;
+ }
+
+ /**
+ * Returns the value of service ecomp naming.
+ *
+ * @return serviceEcompNaming
+ */
+ public String getServiceEcompNaming() {
+ return serviceEcompNaming;
+ }
+ /**
+ * Returns the value of the naming policy.
+ *
+ * @return namingPolicy
+ */
+ public String getNamingPolicy() {
+ return namingPolicy;
+ }
+ /**
+ * Checks if is service homing.
+ *
+ * @return true, if is service homing
+ */
+ public boolean isServiceHoming() {
+ return serviceHoming;
+ }
+ /**
+ * Checks if is ecomp generated naming.
+ *
+ * @return true, if ecomp generated naming is true
+ */
+ public boolean isEcompGeneratedNaming() {
+ return ecompGeneratedNaming;
+ }
+ /**
+ * Sets the type.
+ *
+ * @param type the new type
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Sets the invariant UUID.
+ *
+ * @param invariantUUID the new invariant UUID
+ */
+ public void setInvariantUUID(String invariantUUID) {
+ this.invariantUUID = invariantUUID;
+ }
+ /**
+ * Sets the naming policy.
+ *
+ * @param namingPolicy the new naming policy
+ */
+ public void setNamingPolicy(String namingPolicy) {
+ this.namingPolicy = namingPolicy;
+ }
+ /**
+ * Sets the uuid.
+ *
+ * @param uuid the new uuid
+ */
+ public void setUUID(String uuid) {
+ this.uuid = uuid;
+ }
+ /**
+ * Sets the customization uuid.
+ *
+ * @param u the new customization uuid
+ */
+ public void setCustomizationUUID(String u) {
+ this.customizationUUID = u;
+ }
+ /**
+ * Sets the version.
+ *
+ * @param version the new version
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ /**
+ * Sets the name.
+ *
+ * @param name the new name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Sets the category.
+ *
+ * @param category the new category
+ */
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ /**
+ * Sets the service ecomp naming.
+ *
+ * @param serviceEcompNaming the new service ecomp naming
+ */
+ public void setServiceEcompNaming(String serviceEcompNaming) {
+ this.serviceEcompNaming = serviceEcompNaming;
+ }
+
+ /**
+ * Sets the service homing.
+ *
+ * @param serviceHoming the new service homing
+ */
+ public void setServiceHoming(boolean serviceHoming) {
+ this.serviceHoming = serviceHoming;
+ }
+ /**
+ * Sets the ecomp generated naming.
+ *
+ * @param ecompGeneratedNaming the new ecomp generated naming
+ */
+ public void setEcompGeneratedNaming(boolean ecompGeneratedNaming) {
+ this.ecompGeneratedNaming = ecompGeneratedNaming;
+ }
+ /**
+ * Gets the template name.
+ *
+ * @return the template name
+ */
+ public String gettemplate_name() {
+ return template_name;
+ }
+
+ /**
+ * Sets the template name.
+ *
+ * @param template_name the new template name
+ */
+ public void settemplate_name(String template_name) {
+ this.template_name = template_name;
+ }
+
+ /**
+ * Sets the subcategory.
+ *
+ * @param subcategory the new subcategory
+ */
+ public void setSubcategory(String subcategory) {
+ this.subcategory = subcategory;
+ }
+
+ /**
+ * Sets the resource vendor.
+ *
+ * @param resourceVendor the new resource vendor
+ */
+ public void setResourceVendor(String resourceVendor) {
+ this.resourceVendor = resourceVendor;
+ }
+
+ /**
+ * Sets the resource vendor release.
+ *
+ * @param resourceVendorRelease the new resource vendor release
+ */
+ public void setResourceVendorRelease(String resourceVendorRelease) {
+ this.resourceVendorRelease = resourceVendorRelease;
+ }
+
+ /**
+ * Gets the vf module model name.
+ *
+ * @return the vf module model name
+ */
+ public String getVfModuleModelName() {
+ return vfModuleModelName;
+ }
+
+ /**
+ * Sets the vf module model name.
+ *
+ * @param vfModuleModelName the new vf module model name
+ */
+ public void setVfModuleModelName(String vfModuleModelName) {
+ this.vfModuleModelName = vfModuleModelName;
+ }
+
+ /**
+ * Gets the vf module model invariant UUID.
+ *
+ * @return the vf module model invariant UUID
+ */
+ public String getVfModuleModelInvariantUUID() {
+ return vfModuleModelInvariantUUID;
+ }
+
+ /**
+ * Sets the vf module model invariant UUID.
+ *
+ * @param vfModuleModelInvariantUUID the new vf module model invariant UUID
+ */
+ public void setVfModuleModelInvariantUUID(String vfModuleModelInvariantUUID) {
+ this.vfModuleModelInvariantUUID = vfModuleModelInvariantUUID;
+ }
+
+ /**
+ * Gets the vf module model UUID.
+ *
+ * @return the vf module model UUID
+ */
+ public String getVfModuleModelUUID() {
+ return vfModuleModelUUID;
+ }
+
+ /**
+ * Sets the vf module model UUID.
+ *
+ * @param vfModuleModelUUID the new vf module model UUID
+ */
+ public void setVfModuleModelUUID(String vfModuleModelUUID) {
+ this.vfModuleModelUUID = vfModuleModelUUID;
+ }
+
+ /**
+ * Gets the vf module model version.
+ *
+ * @return the vf module model version
+ */
+ public String getVfModuleModelVersion() {
+ return vfModuleModelVersion;
+ }
+
+ /**
+ * Sets the vf module model version.
+ *
+ * @param vfModuleModelVersion the new vf module model version
+ */
+ public void setVfModuleModelVersion(String vfModuleModelVersion) {
+ this.vfModuleModelVersion = vfModuleModelVersion;
+ }
+ /**
+ * Sets the vf module customization uuid.
+ *
+ * @param u the new vf module model customization uuid
+ */
+ public void setVfModuleModelCustomizationUUID(String u) {
+ this.vfModuleModelCustomizationUUID = u;
+ }
+ /**
+ * Gets the vf module model customization uuid.
+ *
+ * @return the vf module model customization uuid
+ */
+ public String getVfModuleModelCustomizationUUID() {
+
+ return vfModuleModelCustomizationUUID;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaModel.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaModel.java
new file mode 100644
index 000000000..972d366cf
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/tosca/ToscaModel.java
@@ -0,0 +1,166 @@
+/*-
+ * ============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.asdc.beans.tosca;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Map;
+
+/**
+ * The Class ToscaModel.
+ */
+public class ToscaModel {
+
+ /** The tosca definitions version. */
+ private String tosca_definitions_version;
+
+ /** The description. */
+ private String description;
+
+ /** The metadata. */
+ private ToscaMetadata metadata;
+
+ /** The topology template. */
+ private TopologyTemplate topology_template;
+
+ /** The imports. */
+ private Collection<Map<String, Map<String, String>>> imports;
+
+ /** The node types. */
+ private Map<String, Object> node_types;
+
+ /**
+ * Instantiates a new tosca model.
+ */
+ public ToscaModel() {
+ metadata = new ToscaMetadata();
+ topology_template = new TopologyTemplate();
+ imports = new LinkedList<Map<String, Map<String, String>>> ();
+ }
+
+ /**
+ * Gets the metadata.
+ *
+ * @return the metadata
+ */
+ public ToscaMetadata getMetadata() {
+ return metadata;
+ }
+
+ /**
+ * Sets the metadata.
+ *
+ * @param metadata the new metadata
+ */
+ public void setMetadata(ToscaMetadata metadata) {
+ this.metadata = metadata;
+ }
+
+ /**
+ * Gets the tosca definitions version.
+ *
+ * @return the tosca definitions version
+ */
+ public String gettosca_definitions_version() {
+ return tosca_definitions_version;
+ }
+
+ /**
+ * Sets the tosca definitions version.
+ *
+ * @param tosca_definitions_version the new tosca definitions version
+ */
+ public void settosca_definitions_version(String tosca_definitions_version) {
+ this.tosca_definitions_version = tosca_definitions_version;
+ }
+
+ /**
+ * Gets the topology template.
+ *
+ * @return the topology template
+ */
+ public TopologyTemplate gettopology_template() {
+ return topology_template;
+ }
+
+ /**
+ * Sets the topology template.
+ *
+ * @param topology_template the new topology template
+ */
+ public void settopology_template(TopologyTemplate topology_template) {
+ this.topology_template = topology_template;
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Gets the imports.
+ *
+ * @return the imports
+ */
+ public Collection<Map<String, Map<String, String>>> getImports() {
+ return imports;
+ }
+
+ /**
+ * Sets the imports.
+ *
+ * @param imports the imports
+ */
+ public void setImports(Collection<Map<String, Map<String, String>>> imports) {
+ this.imports = imports;
+ }
+
+ /**
+ * Gets the node types.
+ *
+ * @return the node types
+ */
+ public Map<String, Object> getnode_types() {
+ return node_types;
+ }
+
+ /**
+ * Setnode types.
+ *
+ * @param node_types the node types
+ */
+ public void setnode_types(Map<String, Object> node_types) {
+ this.node_types = node_types;
+ }
+}
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
new file mode 100644
index 000000000..3c04e5ce8
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/local/LocalAsdcClient.java
@@ -0,0 +1,394 @@
+package org.onap.vid.asdc.local;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.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.Artifact;
+import org.onap.vid.asdc.beans.Resource;
+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.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.UUID;
+import java.util.zip.ZipFile;
+
+/**
+ * The Class LocalAsdcClient.
+ */
+public class LocalAsdcClient implements AsdcClient {
+
+
+ /**
+ * The catalog.
+ */
+ private final JSONObject catalog;
+
+ /**
+ * The mapper.
+ */
+ private final ObjectMapper mapper;
+
+ /**
+ * Instantiates a new in local sdc client.
+ *
+ * @param builder the builder
+ */
+ public LocalAsdcClient(org.onap.vid.asdc.local.LocalAsdcClient.Builder builder) {
+ catalog = builder.catalog;
+ mapper = builder.mapper;
+ }
+
+ /**
+ * Gets the catalog.
+ *
+ * @return the catalog
+ */
+ private JSONObject getCatalog() {
+ return catalog;
+ }
+
+ /**
+ * Gets the mapper.
+ *
+ * @return the mapper
+ */
+ private ObjectMapper getMapper() {
+ return mapper;
+ }
+
+ /**
+ * Convert.
+ *
+ * @param <T> the generic type
+ * @param json the json
+ * @param clazz the clazz
+ * @return the t
+ * @throws AsdcCatalogException the sdc catalog exception
+ */
+ private <T> T convert(JSONObject json, Class<T> clazz) throws AsdcCatalogException {
+ try {
+ return getMapper().readValue(json.toString(), clazz);
+ } catch (JsonParseException e) {
+ throw new AsdcCatalogException("Failed to parse SDC response (bad data)", e);
+ } catch (JsonMappingException e) {
+ throw new AsdcCatalogException("Failed to map SDC response to internal VID data structure(s)", e);
+ } catch (IOException e) {
+ throw new AsdcCatalogException("Failed to get a response from SDC", e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResource(java.util.UUID)
+ */
+ public Resource getResource(UUID uuid) throws AsdcCatalogException {
+ final JSONObject resource = getCatalog().getJSONObject("resources")
+ .getJSONObject(uuid.toString());
+ return convert(resource, Resource.class);
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResources()
+ */
+ public Collection<Resource> getResources() throws AsdcCatalogException {
+ final Collection<Resource> resources = new LinkedList<Resource>();
+
+ for (String key : getCatalog().getJSONObject("resources").keySet()) {
+ final JSONObject json = getCatalog().getJSONObject("resources").getJSONObject(key);
+ final Resource resource = convert(json, Resource.class);
+ resources.add(resource);
+ }
+
+ return resources;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResources(java.util.Map)
+ */
+ public Collection<Resource> getResources(Map<String, String[]> filter) throws AsdcCatalogException {
+ final Collection<Resource> resources = new LinkedList<Resource>();
+
+ for (String key : getCatalog().getJSONObject("resources").keySet()) {
+ final JSONObject json = getCatalog().getJSONObject("resources").getJSONObject(key);
+
+ boolean filterMatch = true;
+
+ for (Map.Entry<String, String[]> entry : filter.entrySet()) {
+ for (int i = 0; i < entry.getValue().length; i++) {
+ if (!json.getString(entry.getKey()).equals(entry.getValue()[i])) {
+ filterMatch = false;
+ break;
+ }
+ }
+ }
+
+ if (filterMatch) resources.add(convert(json, Resource.class));
+ }
+
+ return resources;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getService(java.util.UUID)
+ */
+ public Service getService(UUID uuid) throws AsdcCatalogException {
+
+ JSONObject serviceJsonObject = null;
+ final JSONArray categoryJsonArray = getCatalog().getJSONArray("services");
+
+ for (int i = 0; i < categoryJsonArray.length(); i++) {
+ JSONObject jsonServiceObject = categoryJsonArray.getJSONObject(i);
+ if (jsonServiceObject.get("uuid").equals(uuid.toString())) {
+ serviceJsonObject = jsonServiceObject;
+ break;
+ }
+ }
+
+ if (serviceJsonObject != null)
+ return convert(serviceJsonObject, Service.class);
+ else return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getServices()
+ */
+ public Collection<Service> getServices() throws AsdcCatalogException {
+ final Collection<Service> services = new LinkedList<Service>();
+
+ JSONArray servicesArr = getCatalog().getJSONArray("services");
+
+ for (Object objService : servicesArr) {
+ JSONObject jsonServiceItem = (JSONObject) objService;
+ final Service service = convert(jsonServiceItem, Service.class);
+ services.add(service);
+ }
+
+ return services;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecompt.vid.asdc.AsdcClient#getServices(java.util.Map)
+ */
+ public Collection<Service> getServices(Map<String, String[]> filter) throws AsdcCatalogException {
+ final Collection<Service> services = new LinkedList<Service>();
+
+ JSONArray catalogServices = catalog.getJSONArray("services");
+
+ for (int i = 0; i < catalogServices.length(); i++) {
+
+ JSONObject serviceJson = catalogServices.getJSONObject(i);
+
+ boolean filterMatch = true;
+
+ for (Map.Entry<String, String[]> entry : filter.entrySet()) {
+ for (int j = 0; j < entry.getValue().length; j++) {
+ if (!serviceJson.getString(entry.getKey()).equals(entry.getValue()[j])) {
+ filterMatch = false;
+ break;
+ }
+ }
+ }
+ if (filterMatch) services.add(convert(serviceJson, Service.class));
+ }
+ return services;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResourceArtifact(java.util.UUID, java.util.UUID)
+ */
+ public Artifact getResourceArtifact(UUID resourceUuid, UUID artifactUuid) throws AsdcCatalogException {
+ final JSONArray artifacts = getCatalog().getJSONObject("resources")
+ .getJSONObject(resourceUuid.toString())
+ .getJSONArray("artifacts");
+
+ for (int i = 0; i < artifacts.length(); i++) {
+ final JSONObject artifact = artifacts.getJSONObject(i);
+
+ if (artifact.getString("artifactUUID").equals(artifactUuid.toString())) {
+ return convert(artifact, Artifact.class);
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getServiceArtifact(java.util.UUID, java.util.UUID)
+ */
+ public Artifact getServiceArtifact(UUID serviceUuid, UUID artifactUuid) throws AsdcCatalogException {
+ final JSONArray artifacts = getCatalog().getJSONObject("services")
+ .getJSONObject(serviceUuid.toString())
+ .getJSONArray("artifacts");
+
+ for (int i = 0; i < artifacts.length(); i++) {
+ final JSONObject artifact = artifacts.getJSONObject(i);
+
+ if (artifact.getString("artifactUUID").equals(artifactUuid.toString())) {
+ return convert(artifact, Artifact.class);
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResourceToscaModel(java.util.UUID)
+ */
+ public Path getResourceToscaModel(UUID resourceUuid) throws AsdcCatalogException {
+ final String toscaModelURL = getCatalog().getJSONObject("resources")
+ .getJSONObject(resourceUuid.toString())
+ .getString("toscaModelURL");
+
+
+ final InputStream toscaModelStream = getClass().getClassLoader().getResourceAsStream(toscaModelURL);
+
+ if (toscaModelStream == null) return null;
+
+ return null;//getToscaModel(toscaModelStream);
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)
+ */
+ public Path getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {
+
+ String toscaModelURL = null;
+
+ final JSONArray categoryJsonArray = getCatalog().getJSONArray("services");
+
+ for (int i = 0; i < categoryJsonArray.length(); i++) {
+
+ JSONObject jsonServiceObject = categoryJsonArray.getJSONObject(i);
+ if (jsonServiceObject.get("uuid").equals(serviceUuid.toString())) {
+ toscaModelURL = jsonServiceObject.getString("toscaModelURL");
+ break;
+ }
+ }
+ if (toscaModelURL == null) {
+ return null;
+ }
+ final InputStream toscaModelStream = getClass().getClassLoader().getResourceAsStream(toscaModelURL);
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ File file = new File(classLoader.getResource(toscaModelURL).getFile());
+ Path path = Paths.get(file.getPath());
+
+ if (toscaModelStream == null) return null;
+
+ return path;
+ }
+
+ /**
+ * 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 {
+
+ /**
+ * The catalog.
+ */
+ private JSONObject catalog = new JSONObject()
+ .put("resources", new JSONObject())
+ .put("services", new JSONObject());
+
+ /**
+ * The mapper.
+ */
+ private ObjectMapper mapper = new ObjectMapper();
+
+ /**
+ * Instantiates a new builder.
+ */
+ public Builder() {
+ }
+
+ /**
+ * Catalog.
+ *
+ * @param catalog the catalog
+ * @return the builder
+ */
+ public org.onap.vid.asdc.local.LocalAsdcClient.Builder catalog(JSONObject catalog) {
+ this.catalog = catalog;
+ return this;
+ }
+
+ /**
+ * Mapper.
+ *
+ * @param mapper the mapper
+ * @return the builder
+ */
+ public org.onap.vid.asdc.local.LocalAsdcClient.Builder mapper(ObjectMapper mapper) {
+ this.mapper = mapper;
+ return this;
+ }
+
+ /**
+ * Builds the.
+ *
+ * @return the in local sdc client
+ */
+ public org.onap.vid.asdc.local.LocalAsdcClient build() {
+ return new org.onap.vid.asdc.local.LocalAsdcClient(this);
+ }
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/memory/InMemoryAsdcClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/memory/InMemoryAsdcClient.java
new file mode 100644
index 000000000..a7b934e99
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/memory/InMemoryAsdcClient.java
@@ -0,0 +1,372 @@
+/*-
+ * ============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.asdc.memory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.UUID;
+import java.util.zip.ZipFile;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.yaml.snakeyaml.Yaml;
+
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.asdc.AsdcClient;
+import org.onap.vid.asdc.beans.Artifact;
+import org.onap.vid.asdc.beans.Resource;
+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;
+
+/**
+ * The Class InMemoryAsdcClient.
+ */
+public class InMemoryAsdcClient implements AsdcClient {
+
+ /** The catalog. */
+ private final JSONObject catalog;
+
+ /** The mapper. */
+ private final ObjectMapper mapper;
+
+ /**
+ * The Class Builder.
+ */
+ public static class Builder {
+
+ /** The catalog. */
+ private JSONObject catalog = new JSONObject()
+ .put("resources", new JSONObject())
+ .put("services", new JSONObject());
+
+ /** The mapper. */
+ private ObjectMapper mapper = new ObjectMapper();
+
+ /**
+ * Instantiates a new builder.
+ */
+ public Builder() {}
+
+ /**
+ * Catalog.
+ *
+ * @param catalog the catalog
+ * @return the builder
+ */
+ public Builder catalog(JSONObject catalog) {
+ this.catalog = catalog;
+ return this;
+ }
+
+ /**
+ * Mapper.
+ *
+ * @param mapper the mapper
+ * @return the builder
+ */
+ public Builder mapper(ObjectMapper mapper) {
+ this.mapper = mapper;
+ return this;
+ }
+
+ /**
+ * Builds the.
+ *
+ * @return the in memory sdc client
+ */
+ public InMemoryAsdcClient build() {
+ return new InMemoryAsdcClient(this);
+ }
+ }
+
+ /**
+ * Instantiates a new in memory sdc client.
+ *
+ * @param builder the builder
+ */
+ private InMemoryAsdcClient(Builder builder) {
+ catalog = builder.catalog;
+ mapper = builder.mapper;
+ }
+
+ /**
+ * Gets the catalog.
+ *
+ * @return the catalog
+ */
+ private JSONObject getCatalog() {
+ return catalog;
+ }
+
+ /**
+ * Gets the mapper.
+ *
+ * @return the mapper
+ */
+ private ObjectMapper getMapper() {
+ return mapper;
+ }
+
+ /**
+ * Convert.
+ *
+ * @param <T> the generic type
+ * @param json the json
+ * @param clazz the clazz
+ * @return the t
+ * @throws AsdcCatalogException the sdc catalog exception
+ */
+ private <T> T convert(JSONObject json, Class<T> clazz) throws AsdcCatalogException {
+ try {
+ return getMapper().readValue(json.toString(), clazz);
+ } catch (JsonParseException e) {
+ throw new AsdcCatalogException("Failed to parse SDC response (bad data)", e);
+ } catch (JsonMappingException e) {
+ throw new AsdcCatalogException("Failed to map SDC response to internal VID data structure(s)", e);
+ } catch (IOException e) {
+ throw new AsdcCatalogException("Failed to get a response from SDC", e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResource(java.util.UUID)
+ */
+ public Resource getResource(UUID uuid) throws AsdcCatalogException {
+ final JSONObject resource = getCatalog().getJSONObject("resources")
+ .getJSONObject(uuid.toString());
+ return convert(resource, Resource.class);
+ }
+
+ /* (non-Javadoc)
+ */
+ public Collection<Resource> getResources() throws AsdcCatalogException {
+ final Collection<Resource> resources = new LinkedList<Resource> ();
+
+ for (String key : getCatalog().getJSONObject("resources").keySet()) {
+ final JSONObject json = getCatalog().getJSONObject("resources").getJSONObject(key);
+ final Resource resource = convert(json, Resource.class);
+ resources.add(resource);
+ }
+
+ return resources;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResources(java.util.Map)
+ */
+ public Collection<Resource> getResources(Map<String, String[]> filter) throws AsdcCatalogException {
+ final Collection<Resource> resources = new LinkedList<Resource> ();
+
+ for (String key : getCatalog().getJSONObject("resources").keySet()) {
+ final JSONObject json = getCatalog().getJSONObject("resources").getJSONObject(key);
+
+ boolean filterMatch = true;
+
+ for (Entry<String, String[]> entry : filter.entrySet()) {
+ for (int i = 0; i < entry.getValue().length; i++) {
+ if (!json.getString(entry.getKey()).equals(entry.getValue()[i])) {
+ filterMatch = false;
+ break;
+ }
+ }
+ }
+
+ if (filterMatch) resources.add(convert(json, Resource.class));
+ }
+
+ return resources;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getService(java.util.UUID)
+ */
+ public Service getService(UUID uuid) throws AsdcCatalogException {
+ final JSONObject service = getCatalog().getJSONObject("services")
+ .getJSONObject(uuid.toString());
+ return convert(service, Service.class);
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getServices()
+ */
+ public Collection<Service> getServices() throws AsdcCatalogException {
+ final Collection<Service> services = new LinkedList<Service> ();
+
+ for (String key : getCatalog().getJSONObject("services").keySet()) {
+ final JSONObject json = getCatalog().getJSONObject("services").getJSONObject(key);
+ final Service service = convert(json, Service.class);
+ services.add(service);
+ }
+
+ return services;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecompt.vid.asdc.AsdcClient#getServices(java.util.Map)
+ */
+ public Collection<Service> getServices(Map<String, String[]> filter) throws AsdcCatalogException {
+ final Collection<Service> services = new LinkedList<Service> ();
+
+ for (String key : getCatalog().getJSONObject("services").keySet()) {
+ final JSONObject json = getCatalog().getJSONObject("services").getJSONObject(key);
+
+ boolean filterMatch = true;
+
+ for (Entry<String, String[]> entry : filter.entrySet()) {
+ for (int i = 0; i < entry.getValue().length; i++) {
+ if (!json.getString(entry.getKey()).equals(entry.getValue()[i])) {
+ filterMatch = false;
+ break;
+ }
+ }
+ }
+
+ if (filterMatch) services.add(convert(json, Service.class));
+ }
+
+ return services;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResourceArtifact(java.util.UUID, java.util.UUID)
+ */
+ public Artifact getResourceArtifact(UUID resourceUuid, UUID artifactUuid) throws AsdcCatalogException {
+ final JSONArray artifacts = getCatalog().getJSONObject("resources")
+ .getJSONObject(resourceUuid.toString())
+ .getJSONArray("artifacts");
+
+ for (int i = 0; i < artifacts.length(); i++) {
+ final JSONObject artifact = artifacts.getJSONObject(i);
+
+ if (artifact.getString("artifactUUID").equals(artifactUuid.toString())) {
+ return convert(artifact, Artifact.class);
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getServiceArtifact(java.util.UUID, java.util.UUID)
+ */
+ public Artifact getServiceArtifact(UUID serviceUuid, UUID artifactUuid) throws AsdcCatalogException {
+ final JSONArray artifacts = getCatalog().getJSONObject("services")
+ .getJSONObject(serviceUuid.toString())
+ .getJSONArray("artifacts");
+
+ for (int i = 0; i < artifacts.length(); i++) {
+ final JSONObject artifact = artifacts.getJSONObject(i);
+
+ if (artifact.getString("artifactUUID").equals(artifactUuid.toString())) {
+ return convert(artifact, Artifact.class);
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResourceToscaModel(java.util.UUID)
+ */
+ public Path getResourceToscaModel(UUID resourceUuid) throws AsdcCatalogException {
+ final String toscaModelURL = getCatalog().getJSONObject("resources")
+ .getJSONObject(resourceUuid.toString())
+ .getString("toscaModelURL");
+
+
+ final InputStream toscaModelStream = getClass().getClassLoader().getResourceAsStream(toscaModelURL);
+
+ if (toscaModelStream == null) return null;
+
+ return null;//getToscaModel(toscaModelStream);
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)
+ */
+ public Path getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {
+ final String toscaModelURL = getCatalog().getJSONObject("services")
+ .getJSONObject(serviceUuid.toString())
+ .getString("toscaModelURL");
+
+ final InputStream toscaModelStream = getClass().getClassLoader().getResourceAsStream(toscaModelURL);
+
+ if (toscaModelStream == null) return null;
+
+ return null;//getToscaModel(toscaModelStream);
+ }
+
+ /**
+ * 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 (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);
+ }
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParser.java b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParser.java
new file mode 100644
index 000000000..890752afe
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParser.java
@@ -0,0 +1,15 @@
+package org.onap.vid.asdc.parser;
+
+import java.nio.file.Path;
+
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.asdc.beans.tosca.ToscaCsar;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.model.ServiceModel;
+
+public interface ToscaParser{
+ ToscaCsar parse(Path path) throws AsdcCatalogException;
+
+ ServiceModel makeServiceModel(String uuid,Path path,Service asdcServiceMetadata) throws Exception;
+} \ No newline at end of file
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
new file mode 100644
index 000000000..12881b64f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl.java
@@ -0,0 +1,226 @@
+package org.onap.vid.asdc.parser;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Path;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.Map.Entry;
+import java.util.zip.ZipFile;
+
+import org.apache.commons.lang3.mutable.MutableBoolean;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.asdc.beans.tosca.NodeTemplate;
+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.model.ModelConstants;
+import org.onap.vid.model.Network;
+import org.onap.vid.model.Node;
+import org.onap.vid.model.ServiceModel;
+import org.onap.vid.model.VNF;
+import org.onap.vid.properties.VidProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.error.YAMLException;
+
+public class ToscaParserImpl implements ToscaParser {
+ /** The Constant LOG. */
+ static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(ToscaParserImpl.class);
+
+ @Autowired
+ private final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+
+ private static final String asdcModelNamespace = VidProperties.getAsdcModelNamespace();
+ private static final String vnfTag = asdcModelNamespace + ModelConstants.VNF;
+ private static final String networkTag = asdcModelNamespace + ModelConstants.NETWORK;
+ private static final String vfModuleTag = asdcModelNamespace + ModelConstants.VF_MODULE;
+
+
+ @Override
+ public ToscaCsar parse(Path path) throws AsdcCatalogException {
+ return getToscaCsar(path);
+ }
+
+ private ToscaCsar getToscaCsar(final Path csarFile) throws AsdcCatalogException {
+ 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));
+
+ try {
+ 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()) {
+ LOG.debug("imports = " + imports.toString());
+ for (Entry<String, Map<String, String>> entry : imports.entrySet()) {
+ if (entry.getValue() != null) {
+ String fname = entry.getValue().get("file");
+ if ((fname != null) && (fname.startsWith("service") || fname.startsWith("resource"))) {
+ LOG.debug("fname = " + fname);
+ final InputStream toscaChildEntryYamlStream = csar
+ .getInputStream(csar.getEntry("Definitions/" + fname));
+
+ final ToscaModel childModel = yaml.loadAs(toscaChildEntryYamlStream, ToscaModel.class);
+ csarBuilder.addVnf(childModel);
+ }
+ }
+ }
+ }
+
+ return csarBuilder.build();
+ } catch (YAMLException e) {
+ throw new AsdcCatalogException("Caught exception while processing TOSCA YAML", e);
+ }
+ } catch (IOException e) {
+ throw new AsdcCatalogException("Caught IOException while processing CSAR", e);
+ }
+ }
+
+ public ServiceModel makeServiceModel(String uuid, final Path serviceCsar,Service service ) throws AsdcCatalogException, SdcToscaParserException {
+
+
+ final ServiceModel serviceModel = new ServiceModel();
+ ToscaCsar toscaCsar = getToscaCsar(serviceCsar);
+ String methodName = "getServices";
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " start");
+ MutableBoolean isNewFlow = new MutableBoolean(false);
+ final Map<String, VNF> vnfs = new HashMap<String, VNF>();
+ final Map<String, Network> networks = new HashMap<String, Network>();
+ final ToscaModel asdcServiceToscaModel = toscaCsar.getParent();
+ serviceModel.setService(ServiceModel.extractService(asdcServiceToscaModel, service));
+
+
+ populateVnfsAndNetwork(methodName, isNewFlow, vnfs, networks, asdcServiceToscaModel, serviceModel);
+
+ // If we see customization uuid under vnf or network, follow 1702 flow
+ if (isNewFlow.getValue()) {
+ return (getCustomizedServices(asdcServiceToscaModel, serviceModel));
+ } else {
+ VNF vnf = null;
+ for (ToscaModel vnfModel : toscaCsar.getChildren()) {
+ // using uuid to match should only be valid for 1610 models
+ final String vnfUuid = (vnfModel.getMetadata().getUUID());
+ // find the VNF with that uuid, uuid is not the key anymore
+ vnf = findVNFAccordingToUUID(vnfs, vnfUuid);
+ if (vnf == null) {
+ LOG.warn("Couldn't find VNF object " + vnfUuid + ". Problem with Tosca model?");
+ continue;
+ }
+ extractAndUpdateInputs(vnf, vnfModel);
+ ServiceModel.extractGroups(vnfModel, serviceModel);
+ }
+
+ serviceModel.setVnfs(vnfs);
+ serviceModel.setNetworks(networks);
+ return serviceModel;
+ }
+ }
+
+ private VNF findVNFAccordingToUUID(final Map<String, VNF> vnfs, final String vnfUuid) {
+ VNF vnf = null;
+ for (Entry<String, VNF> vnfComp : vnfs.entrySet()) {
+ if (((vnfComp.getValue().getUuid()).equalsIgnoreCase(vnfUuid))) {
+ // found the vnf
+ vnf = vnfComp.getValue();
+ }
+ }
+ return vnf;
+ }
+
+ private void extractAndUpdateInputs(VNF vnf, ToscaModel vnfModel) {
+ vnf.setInputs(vnfModel.gettopology_template().getInputs());
+ }
+
+ private static void populateVnfsAndNetwork(String methodName, MutableBoolean isNewFlow, final Map<String, VNF> vnfs,
+ final Map<String, Network> networks, final ToscaModel asdcServiceToscaModel, ServiceModel serviceModel)
+ throws AsdcCatalogException, SdcToscaParserException {
+ for (Entry<String, NodeTemplate> component : extractNodeTemplates(asdcServiceToscaModel)) {
+ final String modelCustomizationName = component.getKey();
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName
+ + " model customization name: " + modelCustomizationName);
+ final NodeTemplate nodeTemplate = component.getValue();
+ final String type = nodeTemplate.getType();
+
+ if (type.startsWith(vnfTag)) {
+ LOG.debug(EELFLoggerDelegate.debugLogger,
+ dateFormat.format(new Date()) + methodName + " found node template type: " + type);
+ final VNF vnf = new VNF();
+ vnf.extractVnf(modelCustomizationName, nodeTemplate);
+// populateNodeVersionIfMissing(nodeTemplate, vnf,service);
+ LOG.debug(EELFLoggerDelegate.debugLogger,
+ dateFormat.format(new Date()) + methodName + " VNF commands: " + vnf.getCommands());
+ vnfs.put(modelCustomizationName, vnf);
+ isNewFlow.setValue(isNewFlow(vnf));
+ }
+ // Networks
+ if (type.startsWith(networkTag)) {
+ LOG.debug(EELFLoggerDelegate.debugLogger,
+ dateFormat.format(new Date()) + methodName + " found node template type: " + type);
+ final Network network = new Network();
+ network.extractNetwork(modelCustomizationName, nodeTemplate);
+// populateNodeVersionIfMissing(nodeTemplate, network, service);
+ isNewFlow.setValue(isNewFlow(network));
+ networks.put(modelCustomizationName, network);
+
+ }
+ }
+ serviceModel.setVnfs(vnfs);
+ serviceModel.setNetworks(networks);
+
+ }
+
+ private static Set<Entry<String, NodeTemplate>> extractNodeTemplates(final ToscaModel asdcServiceToscaModel) {
+ return asdcServiceToscaModel.gettopology_template().getnode_templates().entrySet();
+ }
+
+ private static boolean isNewFlow(Node node) {
+ return (node.getCustomizationUuid() != null) && (node.getCustomizationUuid().length() > 0);
+ }
+
+ private static boolean isNodeVersionMissing(Node Node) {
+ return Node.getVersion() == null;
+ }
+
+ private static void populateNodeVersionIfMissing(final NodeTemplate nodeTemplate, final Node node, Service service)
+ throws AsdcCatalogException {
+ if (isNodeVersionMissing(node)) {
+ node.setVersion(service.getVersion());
+ }
+ }
+
+ private ServiceModel getCustomizedServices(ToscaModel asdcServiceToscaModel, ServiceModel serviceModel) {
+ String methodName = "asdcServiceToscaModel";
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " start");
+
+ // asdcServiceToscaModel should have vf modules and vol groups populated
+ // at this point but
+ // they are not associated with the VNFs
+ ServiceModel.extractGroups(asdcServiceToscaModel,serviceModel);
+ // Now put the vf modules and volume groups under the VNF they belong
+ // too
+ serviceModel.associateGroups();
+ return (serviceModel);
+ }
+
+
+ private UUID extractUUIDFromNodeTemplate(final NodeTemplate nodeTemplate) {
+ return UUID.fromString(nodeTemplate.getMetadata().getUUID());
+ }
+
+
+} \ No newline at end of file
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
new file mode 100644
index 000000000..4a5ab3af3
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java
@@ -0,0 +1,354 @@
+package org.onap.vid.asdc.parser;
+
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.model.*;
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.openecomp.sdc.tosca.parser.impl.FilterType;
+import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.openecomp.sdc.tosca.parser.impl.SdcTypes;
+import org.openecomp.sdc.toscaparser.api.*;
+import org.openecomp.sdc.toscaparser.api.parameters.Input;
+
+import java.nio.file.Path;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static java.util.stream.Collectors.toMap;
+
+public class ToscaParserImpl2 {
+
+
+ public class Constants {
+ public final static String uuid = "UUID";
+ public final static String description = "description";
+ public final static String serviceType = "serviceType";
+ public final static String serviceRole = "serviceRole";
+ public final static String ecompGeneratedNaming = "ecompGeneratedNaming";
+
+ public final static String customizationUUID = "customizationUUID";
+ public final static String vfModuleModelVersion = "vfModuleModelVersion";
+ public final static String vfModuleModelCustomizationUUID = "vfModuleModelCustomizationUUID";
+ public final static String volume_group = "volume_group";
+ public final static String vfModuleModelInvariantUUID = "vfModuleModelInvariantUUID";
+ public final static String vfModuleModelUUID = "vfModuleModelUUID";
+ public final static String invariantUUID = "invariantUUID";
+ public final static String version = "version";
+ public final static String name = "name";
+ public final static String category = "category";
+ public final static String vfModuleModelName = "vfModuleModelName";
+ public final static String getInput = "get_input";
+
+ public final static String instantiationType = "instantiationType";
+ //Instantiation Types
+ public final static String both = "Both";
+ public final static String macro = "Macro";
+ public final static String aLaCarte = "A-La-Carte";
+ public final static String clientConfig = "ClientConfig";
+
+
+ }
+
+ public ToscaParserImpl2() {
+
+ }
+
+ public ServiceModel makeServiceModel(Path path, Service asdcServiceMetadata) throws Exception {
+ ServiceModel serviceModel = new ServiceModel();
+ SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
+ ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(path.toFile().getAbsolutePath(),false);
+ serviceModel.setService(extractServiceFromCsar(asdcServiceMetadata, sdcCsarHelper));
+
+ serviceModel.setVolumeGroups(extractVolumeGroups(sdcCsarHelper));
+ serviceModel.setVfModules(extractVfModuleFromCsar(sdcCsarHelper));
+ serviceModel.setVnfs(extractVnfsFromCsar(serviceModel,sdcCsarHelper));
+ serviceModel.setConfigurations(extractPortMirroringConfigFromCsar(sdcCsarHelper));
+ serviceModel.setServiceProxies(extractServiceProxyFromCsar(sdcCsarHelper));
+ serviceModel.setNetworks(extractNetworksFromCsar(sdcCsarHelper));
+ serviceModel.setPnfs(extractPnfsFromCsar(sdcCsarHelper));
+ return serviceModel;
+ }
+
+ 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();
+
+ service.setName(csarHelper.getServiceMetadata().getValue(Constants.name));
+ service.setCategory(csarHelper.getServiceMetadata().getValue(Constants.category));
+ service.setInvariantUuid(csarHelper.getServiceMetadata().getValue(Constants.invariantUUID));
+ service.setUuid(csarHelper.getServiceMetadata().getValue(Constants.uuid));
+ service.setVersion(asdcServiceMetadata.getVersion());
+ service.setDescription(csarHelper.getServiceMetadata().getValue(Constants.description));
+ service.setInputs(inputsListToInputsMap(csarHelper.getServiceInputs()));
+ service.setServiceEcompNaming(csarHelper.getServiceMetadata().getValue(Constants.ecompGeneratedNaming));
+ service.setServiceType(csarHelper.getServiceMetadata().getValue(Constants.serviceType));
+ service.setServiceRole(csarHelper.getServiceMetadata().getValue(Constants.serviceRole));
+ service.setInstantiationType(validateInstantiationType(csarHelper));
+ return service;
+ }
+
+
+ private Map<String, VNF> extractVnfsFromCsar(ServiceModel serviceModel,ISdcCsarHelper csarHelper) {
+ List<NodeTemplate> nodeTemplates = csarHelper.getServiceVfList();
+ Map<String, VNF> vnfsMaps = new HashMap<String, VNF>();
+
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ VNF vnf = new VNF();
+ populateNodeFromNodeTemplate(nodeTemplate, csarHelper, vnf);
+
+ vnf.setModelCustomizationName(nodeTemplate.getName());
+ Map<String, VfModule> vfModuleHashMap = getVfModulesFromVF(csarHelper, vnf.getCustomizationUuid());
+ vnf.setVfModules(vfModuleHashMap);
+
+ Map<String, VolumeGroup> volumeGroupMap = getVolumeGroupsFromVF(csarHelper, vnf.getCustomizationUuid());
+ vnf.setVolumeGroups(volumeGroupMap);
+
+ vnfsMaps.put(nodeTemplate.getName(), vnf);
+ }
+ return vnfsMaps;
+ }
+
+ private Map<String, PortMirroringConfig> extractPortMirroringConfigFromCsar(ISdcCsarHelper csarHelper) {
+ List<NodeTemplate> nodeTemplates = csarHelper.getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
+ Map<String, PortMirroringConfig> configMaps = new HashMap<>();
+
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ PortMirroringConfig pmConfig = new PortMirroringConfig();
+ populateNodeFromNodeTemplate(nodeTemplate, csarHelper, pmConfig);
+
+ pmConfig.setModelCustomizationName(nodeTemplate.getName());
+ pmConfig.setRequirementAssignments(nodeTemplate.getRequirements());
+ setSourceAndCollectorProxyNodes(csarHelper, pmConfig, nodeTemplate);
+
+ configMaps.put(nodeTemplate.getName(), pmConfig);
+ }
+
+ return configMaps;
+ }
+
+ private Map<String, ServiceProxy> extractServiceProxyFromCsar(ISdcCsarHelper csarHelper) {
+ 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);
+
+ Map<String, String> metadata = nodeTemplate.getMetaData().getAllProperties();
+ serviceProxy.setSourceModelUuid(metadata.get("sourceModelUuid"));
+ serviceProxy.setSourceModelInvariant(metadata.get("sourceModelInvariant"));
+ serviceProxy.setSourceModelName(metadata.get("sourceModelName"));
+
+ serviceProxies.put(nodeTemplate.getName(), serviceProxy);
+ }
+
+ return serviceProxies;
+ }
+
+ 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
+ portMirroringConfig.setCollectorNodes(collectorNodes);
+ } else { // pprobe - configuration by policy
+ String collectorNodeName = csarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "collector_node");
+ if (collectorNodeName != null) {
+ portMirroringConfig.setCollectorNodes(Arrays.asList(collectorNodeName));
+ portMirroringConfig.setConfigurationByPolicy(true);
+ }
+ }
+ }
+
+ 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());
+ }
+
+ return requirementsNodes;
+ }
+
+ Map<String, VfModule> getVfModulesFromVF(ISdcCsarHelper csarHelper, String vfUuid) {
+ List<Group> vfModulesByVf = csarHelper.getVfModulesByVf(vfUuid);
+ return vfModulesByVf.stream()
+ .collect(toMap(Group::getName, this::populateVfModuleFromGroup));
+ }
+
+ Map<String, VolumeGroup> getVolumeGroupsFromVF(ISdcCsarHelper csarHelper, String vfCustomizationUuid) {
+ List<Group> vfModulesByVf = csarHelper.getVfModulesByVf(vfCustomizationUuid);
+ return vfModulesByVf.stream()
+ .filter((group -> isVolumeGroup(group)))
+ .collect(toMap(Group::getName, this::populateVolumeGroupFromGroup));
+ }
+
+ private static Boolean isVolumeGroup(Group group) {
+ return Boolean.valueOf(group.getPropertyValue(Constants.volume_group).toString());
+ }
+
+ private Map<String, Network> extractNetworksFromCsar(ISdcCsarHelper csarHelper) {
+ List<NodeTemplate> nodeTemplates = csarHelper.getServiceVlList();
+ Map<String, Network> networksMap = new HashMap<String, Network>();
+
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ Network newNetwork = new Network();
+ populateNodeFromNodeTemplate(nodeTemplate, csarHelper, newNetwork);
+ newNetwork.setModelCustomizationName(nodeTemplate.getName());
+ networksMap.put(nodeTemplate.getName(), newNetwork);
+ }
+ return networksMap;
+ }
+
+ private Map<String,Node> extractPnfsFromCsar(ISdcCsarHelper csarHelper) {
+ 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);
+ pnfHashMap.put(nodeTemplate.getName(), pnf);
+ }
+ return pnfHashMap;
+ }
+
+ private Map<String, VfModule> extractVfModuleFromCsar(ISdcCsarHelper csarHelper) {
+ List<NodeTemplate> serviceVfList = csarHelper.getServiceVfList();
+ HashMap<String, VfModule> vfModuleHashMap = new HashMap<>();
+
+ for (NodeTemplate nodeTemplate : serviceVfList) {
+ Map<String, VfModule> nodeTemplateVfModule =
+ getVfModulesFromVF(csarHelper, nodeTemplate.getMetaData().getValue(Constants.customizationUUID));
+ vfModuleHashMap.putAll(nodeTemplateVfModule);
+ }
+ return vfModuleHashMap;
+ }
+
+ private Map<String, VolumeGroup> extractVolumeGroups(ISdcCsarHelper csarHelper) {
+ HashMap<String, VolumeGroup> volumeGroupHashMap = new HashMap<>();
+ for (NodeTemplate nodeTemplate : csarHelper.getServiceVfList()) {
+ Map<String, VolumeGroup> nodeTemplateVolumeGroups =
+ getVolumeGroupsFromVF(csarHelper, csarHelper.getNodeTemplateCustomizationUuid(nodeTemplate));
+ volumeGroupHashMap.putAll(nodeTemplateVolumeGroups);
+ }
+ return volumeGroupHashMap;
+ }
+
+ private Map<String, org.onap.vid.asdc.beans.tosca.Input> inputsListToInputsMap(List<org.openecomp.sdc.toscaparser.api.parameters.Input> inputList) {
+ Map<String, org.onap.vid.asdc.beans.tosca.Input> inputs = new HashMap<>();
+ for (org.openecomp.sdc.toscaparser.api.parameters.Input input : inputList) {
+ inputs.put(input.getName(), convertInput(input, new org.onap.vid.asdc.beans.tosca.Input()));
+ }
+ return inputs;
+ }
+
+ private Node populateNodeFromNodeTemplate(NodeTemplate nodeTemplate, ISdcCsarHelper csarHelper, Node newNode) {
+ newNode.setCustomizationUuid(csarHelper.getNodeTemplateCustomizationUuid(nodeTemplate));
+ newNode.setDescription(nodeTemplate.getMetaData().getValue(Constants.description));
+ newNode.setInvariantUuid(nodeTemplate.getMetaData().getValue(Constants.invariantUUID));
+ newNode.setUuid(nodeTemplate.getMetaData().getValue(Constants.uuid));
+ newNode.setName(nodeTemplate.getMetaData().getValue(Constants.name));
+ newNode.setVersion(nodeTemplate.getMetaData().getValue(Constants.version));
+ newNode.setInputs(extractInputsAndCommandsForNodeTemplate(nodeTemplate, csarHelper, newNode));
+ newNode.setType(nodeTemplate.getMetaData().getValue("type"));
+ Map<String, String> propertiesMap = setPropertiesOfVnf(nodeTemplate.getPropertiesObjects());
+ newNode.setProperties(propertiesMap);
+ return newNode;
+ }
+
+ private VfModule populateVfModuleFromGroup(Group group){
+ VfModule vfModule = new VfModule();
+
+ vfModule.setVersion(group.getMetadata().getValue(Constants.vfModuleModelVersion));
+ vfModule.setCustomizationUuid(group.getMetadata().getValue(Constants.vfModuleModelCustomizationUUID));
+ vfModule.setModelCustomizationName(group.getMetadata().getValue(Constants.vfModuleModelName));
+ vfModule.setName(group.getMetadata().getValue(Constants.vfModuleModelName));
+ vfModule.setVolumeGroupAllowed(isVolumeGroup(group));
+ vfModule.setDescription(group.getDescription());
+ vfModule.setInvariantUuid(group.getMetadata().getValue(Constants.vfModuleModelInvariantUUID));
+ vfModule.setUuid(group.getMetadata().getValue(Constants.vfModuleModelUUID));
+ return vfModule;
+ }
+
+ private VolumeGroup populateVolumeGroupFromGroup(Group group){
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setDescription(group.getDescription());
+ volumeGroup.setInvariantUuid(group.getMetadata().getValue(Constants.vfModuleModelInvariantUUID));
+ volumeGroup.setName(group.getMetadata().getValue(Constants.vfModuleModelName));
+ volumeGroup.setModelCustomizationName(group.getMetadata().getValue(Constants.vfModuleModelName));
+ volumeGroup.setVersion(group.getMetadata().getValue(Constants.vfModuleModelVersion));
+ volumeGroup.setUuid(group.getMetadata().getValue(Constants.vfModuleModelUUID));
+ volumeGroup.setCustomizationUuid(group.getMetadata().getValue(Constants.vfModuleModelCustomizationUUID));
+
+ return volumeGroup;
+ }
+
+
+ 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.getInput);
+ 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)){
+ org.onap.vid.asdc.beans.tosca.Input localInput = new org.onap.vid.asdc.beans.tosca.Input();
+ localInput = convertInput(input, localInput);
+ String name = property.getKey();
+ commandPropertyMap.put(name, extractCommands(name, key));
+ inputMap.put(name, localInput);
+ }
+ }
+ }
+ newNode.setCommands(commandPropertyMap);
+ return inputMap;
+ }
+
+ private String extractInputValue(String inputKey) {
+ 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){
+ localInput.setDefault(parserInput.getDefault());
+ localInput.setDescription(parserInput.getDescription());
+ localInput.setRequired(parserInput.isRequired());
+ localInput.setType(parserInput.getType());
+ localInput.setConstraints(parserInput.getConstraints());
+// localInput.setentry_schema()
+ return localInput;
+ }
+
+ private CommandProperty extractCommands(String displayName, String inputName){
+ CommandProperty commandProperty = new CommandProperty();
+ commandProperty.setDisplayName(displayName);
+ commandProperty.setCommand(Constants.getInput);
+ commandProperty.setInputName(inputName);
+ return commandProperty;
+ }
+
+ private Map<String, String> setPropertiesOfVnf(List<Property> properties) {
+ Map<String, String> propertiesMap = new HashMap<String, String>();
+ for (Property property : properties) {
+ propertiesMap.put(property.getName(), property.getValue().toString());
+ }
+ return propertiesMap;
+ }
+
+ private String validateInstantiationType(ISdcCsarHelper csarHelper){
+ String instantiationType = csarHelper.getServiceMetadata().getValue(Constants.instantiationType);
+ String validatedInstantiationType = Constants.clientConfig;
+ if(instantiationType != null && !instantiationType.isEmpty()){
+ if(instantiationType.equalsIgnoreCase(Constants.macro) || instantiationType.equalsIgnoreCase(Constants.both))
+ validatedInstantiationType = Constants.macro;
+ else if(instantiationType.equalsIgnoreCase(Constants.aLaCarte))
+ validatedInstantiationType = Constants.aLaCarte;
+ }
+ return validatedInstantiationType;
+ }
+
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/RestfulAsdcClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/RestfulAsdcClient.java
new file mode 100644
index 000000000..a8dc28716
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/RestfulAsdcClient.java
@@ -0,0 +1,480 @@
+/*-
+ * ============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.asdc.rest;
+
+import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.asdc.AsdcClient;
+import org.onap.vid.asdc.beans.Artifact;
+import org.onap.vid.asdc.beans.Resource;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.asdc.parser.ToscaParserImpl;
+import org.onap.vid.model.ModelConstants;
+import org.onap.vid.properties.VidProperties;
+
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.ProcessingException;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.UUID;
+
+import static org.onap.vid.utils.Logging.getHttpServletRequest;
+import static org.onap.vid.utils.Logging.requestIdHeaderKey;
+/**
+ * The Class RestfulAsdcClient.
+ */
+@SuppressWarnings("Duplicates")
+public class RestfulAsdcClient implements AsdcClient {
+
+
+ /**
+ * The Class Builder.
+ */
+ public static class Builder {
+
+ /**
+ * The client.
+ */
+ private final Client client;
+
+ /**
+ * The uri.
+ */
+ private final URI uri;
+
+ /**
+ * The auth.
+ */
+ private String auth = null;
+
+ /**
+ * Instantiates a new builder.
+ *
+ * @param client the client
+ * @param uri the uri
+ */
+ public Builder(Client client, URI uri) {
+ this.client = client;
+ this.client.register(JacksonJsonProvider.class);
+ this.uri = uri;
+ }
+
+ /**
+ * Auth.
+ *
+ * @param auth the auth
+ * @return the builder
+ */
+ public Builder auth(String auth) {
+ this.auth = auth;
+ return this;
+ }
+
+ /**
+ * Builds the.
+ *
+ * @return the restful asdc client
+ */
+ public RestfulAsdcClient build() {
+ return new RestfulAsdcClient(this);
+ }
+ }
+
+ /**
+ * The Constant LOG.
+ */
+ static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(RestfulAsdcClient.class);
+
+ /**
+ * The Constant dateFormat.
+ */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /**
+ * The client.
+ */
+ private final Client client;
+
+ /**
+ * The uri.
+ */
+ private final URI uri;
+
+ /**
+ * The common headers.
+ */
+ private final MultivaluedHashMap<String, Object> commonHeaders;
+
+ /**
+ * The auth.
+ */
+ private final String auth;
+
+ ToscaParserImpl p = new ToscaParserImpl();
+
+ /**
+ * Instantiates a new restful asdc client.
+ *
+ * @param builder the builder
+ */
+ private RestfulAsdcClient(Builder builder) {
+ client = builder.client;
+ uri = builder.uri;
+ auth = builder.auth;
+
+ commonHeaders = new MultivaluedHashMap<String, Object>();
+ commonHeaders.put("Authorization", Collections.singletonList((Object) (auth)));
+ }
+
+ private Path createTmpFile(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);
+ }
+ return csarFile;
+ }
+
+ /**
+ * Gets the client.
+ *
+ * @return the client
+ */
+ private Client getClient() {
+ return client;
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.asdc.AsdcClient#getResource(java.util.UUID)
+ */
+ public Resource getResource(UUID uuid) throws AsdcCatalogException {
+
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
+ try {
+ return getClient()
+ .target(uri)
+ .path(path + "/" + uuid.toString() + "/metadata")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get(Resource.class);
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.asdc.AsdcClient#getResourceArtifact(java.util.UUID, java.util.UUID)
+ */
+ public Artifact getResourceArtifact(UUID resourceUuid, UUID artifactUuid) throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
+ try {
+ return getClient()
+ .target(uri)
+ .path(path + "/" + resourceUuid + "/artifacts/" + artifactUuid)
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get(Artifact.class);
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.asdc.AsdcClient#getResources()
+ */
+ public Collection<Resource> getResources() throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
+ try {
+ return getClient()
+ .target(uri)
+ .path(path)
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get(new GenericType<Collection<Resource>>() {
+ });
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.asdc.AsdcClient#getResources(java.util.Map)
+ */
+ public Collection<Resource> getResources(Map<String, String[]> filter) throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
+ WebTarget target = getClient()
+ .target(uri)
+ .path(path);
+
+ for (Entry<String, String[]> filterEntry : filter.entrySet()) {
+ target = target.queryParam(filterEntry.getKey(), (Object[]) filterEntry.getValue());
+ }
+
+ try {
+ return target.request()
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get(new GenericType<Collection<Resource>>() {
+ });
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (NotFoundException e) {
+ throw e;
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.asdc.AsdcClient#getResourceToscaModel(java.util.UUID)
+ */
+ public Path getResourceToscaModel(UUID resourceUuid) throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
+ try (final InputStream csarInputStream = (InputStream) getClient()
+ .target(uri)
+ .path(path + "/" + resourceUuid + "/toscaModel")
+ .request(MediaType.APPLICATION_OCTET_STREAM_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get(InputStream.class)) {
+
+ return getToscaCsar(csarInputStream);
+ } catch (IOException e) {
+ throw new AsdcCatalogException("Failed to retrieve resource TOSCA model from ASDC", e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.asdc.AsdcClient#getService(java.util.UUID)
+ */
+ public Service getService(UUID uuid) throws AsdcCatalogException {
+
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
+ try {
+ return getClient()
+ .target(uri)
+ .path(path + "/" + uuid.toString() + "/metadata")
+ .request(MediaType.APPLICATION_JSON)
+ .headers(commonHeaders)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get(Service.class);
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.asdc.AsdcClient#getServiceArtifact(java.util.UUID, java.util.UUID)
+ */
+ public Artifact getServiceArtifact(UUID serviceUuid, UUID artifactUuid) throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
+
+ try {
+ return getClient()
+ .target(uri)
+ .path(path + "/" + serviceUuid + "/artifacts/" + artifactUuid)
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get(Artifact.class);
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.asdc.AsdcClient#getServices()
+ */
+ public Collection<Service> getServices() throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
+ try {
+ return getClient()
+ .target(uri)
+ .path(path)
+ .request()
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get(new GenericType<Collection<Service>>() {
+ });
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.asdc.AsdcClient#getServices(java.util.Map)
+ */
+ public Collection<Service> getServices(Map<String, String[]> filter) throws AsdcCatalogException {
+
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
+ WebTarget target = getClient()
+ .target(uri)
+ .path(path);
+
+
+ for (Entry<String, String[]> filterEntry : filter.entrySet()) {
+ target = target.queryParam(filterEntry.getKey(), (Object[]) filterEntry.getValue());
+ }
+
+ try {
+ return target.request()
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get(new GenericType<Collection<Service>>() {
+ });
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (NotFoundException e) {
+ throw e;
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.onap.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)
+ */
+ public Path getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
+ try {
+ final InputStream csarInputStream = (InputStream) getClient()
+ .target(uri)
+ .path(path + "/" + serviceUuid + "/toscaModel")
+ .request(MediaType.APPLICATION_OCTET_STREAM_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get(InputStream.class);
+
+
+ return getToscaCsar(csarInputStream);
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+
+ /**
+ * Gets the tosca model.
+ *
+ * @param csarInputStream the csar input stream
+ * @return the tosca model
+ * @throws AsdcCatalogException the asdc catalog exception
+ */
+ private Path getToscaCsar(InputStream csarInputStream) throws AsdcCatalogException {
+ return createTmpFile(csarInputStream);
+ }
+}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionResponse.java b/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionResponse.java
new file mode 100644
index 000000000..89d3963ac
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionResponse.java
@@ -0,0 +1,15 @@
+package org.onap.vid.category;
+
+import org.onap.vid.model.ListOfErrorsResponse;
+
+import java.util.List;
+
+public class AddCategoryOptionResponse extends ListOfErrorsResponse {
+
+ public AddCategoryOptionResponse() {
+ }
+
+ public AddCategoryOptionResponse(List<String> errors) {
+ super(errors);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionsRequest.java b/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionsRequest.java
new file mode 100644
index 000000000..5db474627
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/category/AddCategoryOptionsRequest.java
@@ -0,0 +1,13 @@
+package org.onap.vid.category;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class AddCategoryOptionsRequest {
+
+ public List<String> options;
+
+ public AddCategoryOptionsRequest() {
+ options = new ArrayList<>();
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/category/CategoryParameterOptionRep.java b/vid-app-common/src/main/java/org/onap/vid/category/CategoryParameterOptionRep.java
new file mode 100644
index 000000000..355e54838
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/category/CategoryParameterOptionRep.java
@@ -0,0 +1,31 @@
+package org.onap.vid.category;
+
+public class CategoryParameterOptionRep {
+
+ private String id;
+ private String name;
+
+ public CategoryParameterOptionRep() {
+ }
+
+ public CategoryParameterOptionRep(String id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/category/CategoryParametersResponse.java b/vid-app-common/src/main/java/org/onap/vid/category/CategoryParametersResponse.java
new file mode 100644
index 000000000..be7886698
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/category/CategoryParametersResponse.java
@@ -0,0 +1,27 @@
+package org.onap.vid.category;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+import java.util.Map;
+
+public class CategoryParametersResponse {
+
+ private Map<String, List<CategoryParameterOptionRep>> categoryParameters;
+
+ public CategoryParametersResponse() {
+ }
+
+ public CategoryParametersResponse(Map<String, List<CategoryParameterOptionRep>> categoryParameters) {
+ this.categoryParameters = categoryParameters;
+ }
+
+ @JsonProperty("categoryParameters")
+ public Map<String, List<CategoryParameterOptionRep>> getCategoryParameters() {
+ return categoryParameters;
+ }
+
+ public void setCategoryParameters(Map<String, List<CategoryParameterOptionRep>> categoryParameters) {
+ this.categoryParameters = categoryParameters;
+ }
+}
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
new file mode 100644
index 000000000..ec375b621
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/ChangeManagementRequest.java
@@ -0,0 +1,73 @@
+package org.onap.vid.changeManagement;
+
+import java.util.List;
+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.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonPropertyOrder({
+ "requestDetails",
+ "requestType"
+})
+
+public class ChangeManagementRequest {
+
+ public static class MsoChangeManagementRequest {
+ public final static String SOFTWARE_UPDATE = "inPlaceSoftwareUpdate";
+ public static final String REPLACE = "replace";
+ public final static String CONFIG_UPDATE = "applyUpdatedConfig";
+
+ }
+
+ public final static 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";
+
+ @JsonProperty("requestDetails")
+ private List<RequestDetails> requestDetails;
+
+ @JsonProperty("requestType")
+ private String requestType;
+
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonProperty("requestDetails")
+ public List<RequestDetails> getRequestDetails() {
+ return requestDetails;
+ }
+
+ @JsonProperty("requestDetails")
+ public void setRequestDetails(List<RequestDetails> requestDetails) {
+ this.requestDetails = requestDetails;
+ }
+
+ @JsonProperty("requestType")
+ public String getRequestType() {
+ return requestType;
+ }
+
+ @JsonProperty("requestType")
+ public void setRequestType(String requestType) {
+ this.requestType = requestType;
+ }
+
+ @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/changeManagement/ChangeManagementResponse.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/ChangeManagementResponse.java
new file mode 100644
index 000000000..05d6e0496
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/ChangeManagementResponse.java
@@ -0,0 +1,19 @@
+package org.onap.vid.changeManagement;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ChangeManagementResponse {
+ public List<CmResponse> cmResponses = null;
+
+
+
+ public ChangeManagementResponse(String vnfName) {
+ List<CmResponse> cmResponses = new ArrayList<>();
+ cmResponses.add(new CmResponse(vnfName));
+ this.cmResponses = cmResponses;
+
+ }
+
+
+}
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
new file mode 100644
index 000000000..43d6a6a0a
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/CloudConfiguration.java
@@ -0,0 +1,55 @@
+package org.onap.vid.changeManagement;
+
+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({
+"lcpCloudRegionId",
+"tenantId"
+})
+public class CloudConfiguration {
+ @JsonProperty("lcpCloudRegionId")
+ private String lcpCloudRegionId;
+ @JsonProperty("tenantId")
+ private String tenantId;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonProperty("lcpCloudRegionId")
+ public String getLcpCloudRegionId() {
+ return lcpCloudRegionId;
+ }
+
+ @JsonProperty("lcpCloudRegionId")
+ public void setLcpCloudRegionId(String lcpCloudRegionId) {
+ this.lcpCloudRegionId = lcpCloudRegionId;
+ }
+
+ @JsonProperty("tenantId")
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ @JsonProperty("tenantId")
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ @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/changeManagement/CmResponse.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/CmResponse.java
new file mode 100644
index 000000000..8aba0124a
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/CmResponse.java
@@ -0,0 +1,17 @@
+package org.onap.vid.changeManagement;
+
+public class CmResponse {
+
+ public String orchestratorRequestId;
+ public String serviceInstanceId;
+ public String vnfInstanceId;
+ public String vnfName;
+
+ public CmResponse(String vnfName){
+ this.orchestratorRequestId = "Request Id";
+ this.serviceInstanceId = "Service instance Id";
+ this.vnfInstanceId = "Vnf instance Id";
+ this.vnfName = vnfName;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/GetVnfWorkflowRelationRequest.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/GetVnfWorkflowRelationRequest.java
new file mode 100644
index 000000000..0412204f9
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/GetVnfWorkflowRelationRequest.java
@@ -0,0 +1,28 @@
+package org.onap.vid.changeManagement;
+
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class GetVnfWorkflowRelationRequest {
+
+ public GetVnfWorkflowRelationRequest() {
+ }
+
+ public GetVnfWorkflowRelationRequest(List<VnfDetails> vnfsDetails) {
+ this.vnfsDetails = vnfsDetails;
+ }
+
+ @JsonProperty("vnfsDetails")
+ private List<VnfDetails> vnfsDetails;
+
+ @JsonProperty("vnfsDetails")
+ public List<VnfDetails> getVnfDetails() {
+ return vnfsDetails;
+ }
+
+ @JsonProperty("vnfsDetails")
+ public void setVnfDetails(List<VnfDetails> vnfDetails) {
+ this.vnfsDetails = vnfDetails;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/GetWorkflowsResponse.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/GetWorkflowsResponse.java
new file mode 100644
index 000000000..05295fbc6
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/GetWorkflowsResponse.java
@@ -0,0 +1,24 @@
+package org.onap.vid.changeManagement;
+
+import java.util.List;
+
+public class GetWorkflowsResponse {
+ private List<String> workflows;
+
+ public GetWorkflowsResponse() {
+ }
+
+ public GetWorkflowsResponse(List<String> workflows) {
+ this.workflows = workflows;
+ }
+
+ public List<String> getWorkflows() {
+ return workflows;
+ }
+
+ public void setWorkflows(List<String> workflows) {
+ this.workflows = workflows;
+ }
+
+
+}
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
new file mode 100644
index 000000000..6011c7ebb
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/LeanCloudConfiguration.java
@@ -0,0 +1,20 @@
+package org.onap.vid.changeManagement;
+
+/**
+ * Created by Oren on 9/5/17.
+ */
+public class LeanCloudConfiguration {
+
+ public LeanCloudConfiguration() {
+ }
+
+ public LeanCloudConfiguration(org.onap.vid.domain.mso.CloudConfiguration cloudConfiguration) {
+ this.tenantId = cloudConfiguration.getTenantId();
+ this.lcpCloudRegionId = cloudConfiguration.getLcpCloudRegionId();
+
+ }
+ public String lcpCloudRegionId;
+
+ public String tenantId;
+
+}
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
new file mode 100644
index 000000000..8f44a4bf6
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfo.java
@@ -0,0 +1,138 @@
+package org.onap.vid.changeManagement;
+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({
+"modelType",
+"modelInvariantId",
+"modelVersionId",
+"modelName",
+"modelVersion",
+"modelCustomizationName",
+"modelCustomizationId"
+})
+public class ModelInfo {
+
+ public ModelInfo(){
+
+ }
+
+ public ModelInfo(org.onap.vid.domain.mso.ModelInfo modelInfo){
+ this.setModelType(modelInfo.getModelType().toString());
+ this.setModelInvariantId(modelInfo.getModelInvariantId());
+ this.setModelVersionId(modelInfo.getModelNameVersionId());
+ this.setModelName(modelInfo.getModelName());
+ this.setModelVersion(modelInfo.getModelVersion());
+ this.setModelCustomizationId(modelInfo.getModelCustomizationId());
+ this.setModelVersionId(modelInfo.getModelVersionId());
+ }
+
+
+ @JsonProperty("modelType")
+ private String modelType;
+ @JsonProperty("modelInvariantId")
+ private String modelInvariantId;
+ @JsonProperty("modelVersionId")
+ private String modelVersionId;
+ @JsonProperty("modelName")
+ private String modelName;
+ @JsonProperty("modelVersion")
+ private String modelVersion;
+ @JsonProperty("modelCustomizationName")
+ private String modelCustomizationName;
+ @JsonProperty("modelCustomizationId")
+ private String modelCustomizationId;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonProperty("modelType")
+ public String getModelType() {
+ return modelType;
+ }
+
+ @JsonProperty("modelType")
+ public void setModelType(String modelType) {
+ this.modelType = modelType;
+ }
+
+ @JsonProperty("modelInvariantId")
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ @JsonProperty("modelInvariantId")
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ @JsonProperty("modelVersionId")
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ @JsonProperty("modelVersionId")
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ @JsonProperty("modelName")
+ public String getModelName() {
+ return modelName;
+ }
+
+ @JsonProperty("modelName")
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ @JsonProperty("modelVersion")
+ public String getModelVersion() {
+ return modelVersion;
+ }
+
+ @JsonProperty("modelVersion")
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ @JsonProperty("modelCustomizationName")
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+
+ @JsonProperty("modelCustomizationName")
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+
+ @JsonProperty("modelCustomizationId")
+ public String getModelCustomizationId() {
+ return modelCustomizationId;
+ }
+
+ @JsonProperty("modelCustomizationId")
+ public void setModelCustomizationId(String modelCustomizationId) {
+ this.modelCustomizationId = modelCustomizationId;
+ }
+
+ @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/changeManagement/ModelInfoOfRelatedInstance.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfoOfRelatedInstance.java
new file mode 100644
index 000000000..7e8760987
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/ModelInfoOfRelatedInstance.java
@@ -0,0 +1,122 @@
+package org.onap.vid.changeManagement;
+
+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({
+"modelType",
+"modelInvariantId",
+"modelVersionId",
+"modelName",
+"modelVersion",
+"modelCustomizationName",
+"modelCustomizationId"
+})
+
+public class ModelInfoOfRelatedInstance {
+
+ @JsonProperty("modelType")
+ private String modelType;
+ @JsonProperty("modelInvariantId")
+ private String modelInvariantId;
+ @JsonProperty("modelVersionId")
+ private String modelVersionId;
+ @JsonProperty("modelName")
+ private String modelName;
+ @JsonProperty("modelVersion")
+ private String modelVersion;
+ @JsonProperty("modelCustomizationName")
+ private String modelCustomizationName;
+ @JsonProperty("modelCustomizationId")
+ private String modelCustomizationId;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonProperty("modelType")
+ public String getModelType() {
+ return modelType;
+ }
+
+ @JsonProperty("modelType")
+ public void setModelType(String modelType) {
+ this.modelType = modelType;
+ }
+
+ @JsonProperty("modelInvariantId")
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ @JsonProperty("modelInvariantId")
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ @JsonProperty("modelVersionId")
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ @JsonProperty("modelVersionId")
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ @JsonProperty("modelName")
+ public String getModelName() {
+ return modelName;
+ }
+
+ @JsonProperty("modelName")
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ @JsonProperty("modelVersion")
+ public String getModelVersion() {
+ return modelVersion;
+ }
+
+ @JsonProperty("modelVersion")
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ @JsonProperty("modelCustomizationName")
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+
+ @JsonProperty("modelCustomizationName")
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+
+ @JsonProperty("modelCustomizationId")
+ public String getModelCustomizationId() {
+ return modelCustomizationId;
+ }
+
+ @JsonProperty("modelCustomizationId")
+ public void setModelCustomizationId(String modelCustomizationId) {
+ this.modelCustomizationId = modelCustomizationId;
+ }
+
+ @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/changeManagement/MsoRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/MsoRequestDetails.java
new file mode 100644
index 000000000..913fa0787
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/MsoRequestDetails.java
@@ -0,0 +1,32 @@
+package org.onap.vid.changeManagement;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by Oren on 9/5/17.
+ */
+public class MsoRequestDetails {
+
+ public ModelInfo modelInfo;
+
+ public LeanCloudConfiguration cloudConfiguration;
+
+ public UpdateRequestInfo requestInfo;
+
+ public List<RelatedInstanceList> relatedInstanceList;
+
+ public Object requestParameters;
+
+ public MsoRequestDetails(RequestDetails r) {
+ this.modelInfo = new ModelInfo(r.getModelInfo());
+ this.cloudConfiguration = new LeanCloudConfiguration(r.getCloudConfiguration());
+ this.requestInfo = new UpdateRequestInfo(r.getRequestInfo());
+ this.relatedInstanceList = new ArrayList<>();
+ this.requestParameters = r.getRequestParameters();
+ relatedInstanceList = r.getRelatedInstList();
+
+
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/RelatedInstance.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RelatedInstance.java
new file mode 100644
index 000000000..c29aee454
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RelatedInstance.java
@@ -0,0 +1,29 @@
+package org.onap.vid.changeManagement;
+
+import com.fasterxml.jackson.annotation.*;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "instanceId",
+ "modelInfo"
+})
+public class RelatedInstance {
+
+ @JsonProperty("instanceId")
+ public String instanceId;
+
+
+ @JsonProperty("modelInfo")
+ public ModelInfo modelInfo;
+
+ @JsonGetter
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ @JsonSetter
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/RelatedInstanceList.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RelatedInstanceList.java
new file mode 100644
index 000000000..b3e67a020
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RelatedInstanceList.java
@@ -0,0 +1,23 @@
+package org.onap.vid.changeManagement;
+
+import com.fasterxml.jackson.annotation.*;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "relatedInstance"
+})
+public class RelatedInstanceList {
+
+ @JsonProperty("relatedInstance")
+ public RelatedInstance relatedInstance;
+
+ @JsonSetter
+ public RelatedInstance getRelatedInstance() {
+ return relatedInstance;
+ }
+
+ @JsonSetter
+ public void setRelatedInstance(RelatedInstance relatedInstance) {
+ this.relatedInstance = relatedInstance;
+ }
+}
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
new file mode 100644
index 000000000..36452f67f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestDetails.java
@@ -0,0 +1,56 @@
+package org.onap.vid.changeManagement;
+
+import com.fasterxml.jackson.annotation.*;
+
+import java.util.List;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+"modelInfo",
+"cloudConfiguration",
+"requestInfo",
+"requestParameters",
+"vnfName",
+"vnfInstanceId"
+})
+public class RequestDetails extends org.onap.vid.mso.rest.RequestDetails{
+
+ @JsonProperty("vnfName")
+ private String vnfName;
+ @JsonProperty("vnfInstanceId")
+ private String vnfInstanceId;
+
+ /** The related model list. */
+ @JsonProperty("relatedInstanceList")
+ public List<RelatedInstanceList> relatedInstList;
+
+ @JsonProperty("vnfName")
+ public String getVnfName() {
+ return vnfName;
+ }
+
+ @JsonProperty("vnfName")
+ public void setVnfName(String vnfName) {
+ this.vnfName = vnfName;
+ }
+ @JsonProperty("vnfInstanceId")
+ public String getVnfInstanceId() {
+ return vnfInstanceId;
+ }
+
+ @JsonProperty("vnfInstanceId")
+ public void setVnfInstanceId(String vnfInstanceId) {
+ this.vnfInstanceId = vnfInstanceId;
+ }
+
+ @JsonGetter
+ public List<RelatedInstanceList> getRelatedInstList() {
+ return relatedInstList;
+ }
+
+ @JsonSetter
+ public void setRelatedInstList(List<RelatedInstanceList> relatedInstList) {
+ this.relatedInstList = relatedInstList;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestDetailsWrapper.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestDetailsWrapper.java
new file mode 100644
index 000000000..92fb57c2d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestDetailsWrapper.java
@@ -0,0 +1,16 @@
+package org.onap.vid.changeManagement;
+
+/**
+ * Created by Oren on 9/5/17.
+ */
+public class RequestDetailsWrapper<T> {
+
+ public RequestDetailsWrapper(T requestDetails) {
+ this.requestDetails = requestDetails;
+ }
+
+ public RequestDetailsWrapper() {
+ }
+
+ public T requestDetails;
+}
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
new file mode 100644
index 000000000..4aa3724af
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/RequestInfo.java
@@ -0,0 +1,69 @@
+package org.onap.vid.changeManagement;
+
+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({
+"source",
+"suppressRollback",
+"requestorId"
+})
+public class RequestInfo {
+ @JsonProperty("source")
+ private String source;
+ @JsonProperty("suppressRollback")
+ private Boolean suppressRollback;
+ @JsonProperty("requestorId")
+ private String requestorId;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonProperty("source")
+ public String getSource() {
+ return source;
+ }
+
+ @JsonProperty("source")
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ @JsonProperty("suppressRollback")
+ public Boolean getSuppressRollback() {
+ return suppressRollback;
+ }
+
+ @JsonProperty("suppressRollback")
+ public void setSuppressRollback(Boolean suppressRollback) {
+ this.suppressRollback = suppressRollback;
+ }
+
+ @JsonProperty("requestorId")
+ public String getRequestorId() {
+ return requestorId;
+ }
+
+ @JsonProperty("requestorId")
+ public void setRequestorId(String requestorId) {
+ this.requestorId = requestorId;
+ }
+
+ @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/changeManagement/UpdateRequestInfo.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java
new file mode 100644
index 000000000..024e9c3c1
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/UpdateRequestInfo.java
@@ -0,0 +1,26 @@
+package org.onap.vid.changeManagement;
+
+import org.onap.vid.domain.mso.*;
+
+/**
+ * Created by Oren on 9/5/17.
+ */
+public class UpdateRequestInfo {
+
+ public UpdateRequestInfo() {
+ }
+
+
+ public UpdateRequestInfo(org.onap.vid.domain.mso.RequestInfo requestInfo) {
+ this.requestorId = requestInfo.getRequestorId();
+ this.suppressRollback = requestInfo.getSuppressRollback();
+ this.source = requestInfo.getSource();
+ }
+ public String source;
+
+ public Boolean suppressRollback;
+
+ public String requestorId;
+
+
+}
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
new file mode 100644
index 000000000..5cc2f4d32
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetails.java
@@ -0,0 +1,67 @@
+package org.onap.vid.changeManagement;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.MoreObjects;
+
+public class VnfDetails {
+
+ public VnfDetails() {
+ }
+
+ public VnfDetails(String UUID, String invariantUUID) {
+ this.UUID = UUID;
+ this.invariantUUID = invariantUUID;
+ }
+
+ @JsonProperty("UUID")
+ private String UUID;
+
+ @JsonProperty("invariantUUID")
+ private String invariantUUID;
+
+ @JsonProperty("UUID")
+ public String getUUID() {
+ return UUID;
+ }
+
+ @JsonProperty("UUID")
+ public void setUUID(String uUID) {
+ UUID = uUID;
+ }
+
+ @JsonProperty("invariantUUID")
+ public String getInvariantUUID() {
+ return invariantUUID;
+ }
+
+ @JsonProperty("invariantUUID")
+ public void setInvariantUUID(String invariantUUID) {
+ this.invariantUUID = invariantUUID;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ VnfDetails that = (VnfDetails) o;
+
+ if (getUUID() != null ? !getUUID().equals(that.getUUID()) : that.getUUID() != null) return false;
+ return getInvariantUUID() != null ? getInvariantUUID().equals(that.getInvariantUUID()) : that.getInvariantUUID() == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = getUUID() != null ? getUUID().hashCode() : 0;
+ result = 31 * result + (getInvariantUUID() != null ? getInvariantUUID().hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "VnfDetails{" +
+ "UUID='" + UUID + '\'' +
+ ", invariantUUID='" + invariantUUID + '\'' +
+ '}';
+ }
+}
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
new file mode 100644
index 000000000..db162999f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfDetailsWithWorkflows.java
@@ -0,0 +1,36 @@
+package org.onap.vid.changeManagement;
+
+import org.onap.vid.model.VNFDao;
+import org.onap.vid.model.VidWorkflow;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class VnfDetailsWithWorkflows extends VnfDetails {
+
+ private List<String> workflows;
+
+ public VnfDetailsWithWorkflows() {
+ }
+
+
+ @SuppressWarnings("WeakerAccess")
+ public VnfDetailsWithWorkflows(String UUID, String invariantUUID, List<String> workflows) {
+ super(UUID, invariantUUID);
+ this.workflows = workflows;
+ }
+
+ public VnfDetailsWithWorkflows(VNFDao vnfDao) {
+ this(vnfDao.getVnfUUID(),
+ vnfDao.getVnfInvariantUUID(),
+ vnfDao.getWorkflows().stream().map(VidWorkflow::getWokflowName).collect(Collectors.toList()));
+ }
+
+ public List<String> getWorkflows() {
+ return workflows;
+ }
+
+ public void setWorkflows(List<String> workflows) {
+ this.workflows = workflows;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfWorkflowRelationAllResponse.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfWorkflowRelationAllResponse.java
new file mode 100644
index 000000000..5c9af661e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfWorkflowRelationAllResponse.java
@@ -0,0 +1,23 @@
+package org.onap.vid.changeManagement;
+
+import java.util.List;
+
+public class VnfWorkflowRelationAllResponse {
+
+ private List<VnfDetailsWithWorkflows> vnfs;
+
+ public VnfWorkflowRelationAllResponse() {
+ }
+
+ public VnfWorkflowRelationAllResponse(List<VnfDetailsWithWorkflows> vnfs) {
+ this.vnfs = vnfs;
+ }
+
+ public List<VnfDetailsWithWorkflows> getVnfs() {
+ return vnfs;
+ }
+
+ public void setVnfs(List<VnfDetailsWithWorkflows> vnfs) {
+ this.vnfs = vnfs;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfWorkflowRelationRequest.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfWorkflowRelationRequest.java
new file mode 100644
index 000000000..cc9abae27
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfWorkflowRelationRequest.java
@@ -0,0 +1,31 @@
+package org.onap.vid.changeManagement;
+
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class VnfWorkflowRelationRequest {
+
+ public VnfWorkflowRelationRequest() {
+ }
+
+ public VnfWorkflowRelationRequest(List<WorkflowsDetail> workflowsDetails) {
+ this.workflowsDetails = workflowsDetails;
+ }
+
+ @JsonProperty("workflowsDetails")
+ private List<WorkflowsDetail> workflowsDetails;
+
+ @JsonProperty("workflowsDetails")
+ public List<WorkflowsDetail> getWorkflowsDetails() {
+ return workflowsDetails;
+ }
+
+ @JsonProperty("workflowsDetails")
+ public void setWorkflowsDetails(List<WorkflowsDetail> workflowsDetails) {
+ this.workflowsDetails = workflowsDetails;
+ }
+
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfWorkflowRelationResponse.java b/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfWorkflowRelationResponse.java
new file mode 100644
index 000000000..98ebc89ea
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/VnfWorkflowRelationResponse.java
@@ -0,0 +1,15 @@
+package org.onap.vid.changeManagement;
+
+import org.onap.vid.model.ListOfErrorsResponse;
+
+import java.util.List;
+
+public class VnfWorkflowRelationResponse extends ListOfErrorsResponse {
+
+ public VnfWorkflowRelationResponse() {
+ }
+
+ public VnfWorkflowRelationResponse(List<String> errors) {
+ super(errors);
+ }
+}
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
new file mode 100644
index 000000000..e833ecb28
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/changeManagement/WorkflowsDetail.java
@@ -0,0 +1,44 @@
+package org.onap.vid.changeManagement;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.MoreObjects;
+
+public class WorkflowsDetail {
+
+ public WorkflowsDetail() {
+ }
+
+ public WorkflowsDetail(VnfDetails vnfDetails, String workflowName) {
+ this.vnfDetails = vnfDetails;
+ this.workflowName = workflowName;
+ }
+
+ @JsonProperty("vnfDetails")
+ private VnfDetails vnfDetails;
+
+ @JsonProperty("workflowName")
+ private String workflowName;
+
+ @JsonProperty("vnfDetails")
+ public VnfDetails getVnfDetails() {
+ return vnfDetails;
+ }
+ @JsonProperty("vnfDetails")
+ public void setVnfDetails(VnfDetails vnfDetails) {
+ this.vnfDetails = vnfDetails;
+ }
+ @JsonProperty("workflowName")
+ public String getWorkflowName() {
+ return workflowName;
+ }
+ @JsonProperty("workflowName")
+ public void setWorkflowName(String workflowName) {
+ this.workflowName = workflowName;
+ }
+
+ @Override
+ public String toString() {
+ return vnfDetails +
+ ", workflowName='" + workflowName;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/client/FakeHttpSession.java b/vid-app-common/src/main/java/org/onap/vid/client/FakeHttpSession.java
new file mode 100644
index 000000000..69ce11f4b
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/client/FakeHttpSession.java
@@ -0,0 +1,224 @@
+package org.onap.vid.client;
+
+import org.apache.commons.io.IOUtils;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by pickjonathan on 03/07/2017.
+ */
+public class FakeHttpSession implements HttpSession {
+
+ /**
+ * Setup the creation time
+ */
+ public FakeHttpSession() {
+ File file = new File("resources/roles.json");
+
+ String rolesInputStream = null;
+ try {
+ rolesInputStream = IOUtils.toString(FakeHttpSession.class.getClassLoader().getResourceAsStream("roles.json"),"UTF8");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ JSONTokener tokener = new JSONTokener(rolesInputStream);
+ JSONObject roles = new JSONObject(tokener);
+
+ JSONArray rolesArray = roles.getJSONArray("roles");
+
+ //set permissions to the roles from file.
+ this.setAttribute("role", rolesArray);
+
+ creationTime = System.currentTimeMillis();
+ }
+
+
+ /**
+ * Setup the creation time
+ * @param id The new session id
+ */
+ public FakeHttpSession(String id)
+ {
+ this.id = id;
+ creationTime = System.currentTimeMillis();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#getCreationTime()
+ */
+ public long getCreationTime()
+ {
+ return creationTime;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#getId()
+ */
+ public String getId()
+ {
+ if (id == null)
+ {
+ System.out.println("Inventing data in FakeHttpSession.getId() to remain plausible.");
+ id = "fake";
+ }
+
+ return id;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#getLastAccessedTime()
+ */
+ public long getLastAccessedTime()
+ {
+ return creationTime;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#getServletContext()
+ */
+ public ServletContext getServletContext()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#setMaxInactiveInterval(int)
+ */
+ public void setMaxInactiveInterval(int maxInactiveInterval)
+ {
+ this.maxInactiveInterval = maxInactiveInterval;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#getMaxInactiveInterval()
+ */
+ public int getMaxInactiveInterval()
+ {
+ return maxInactiveInterval;
+ }
+
+ /**
+ * @see javax.servlet.http.HttpSession#getSessionContext()
+ * @deprecated
+ */
+ @SuppressWarnings({"UnnecessaryFullyQualifiedName"})
+ @Deprecated
+ public javax.servlet.http.HttpSessionContext getSessionContext()
+ {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#getAttribute(java.lang.String)
+ */
+ public Object getAttribute(String name)
+ {
+ return attributes.get(name);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#getValue(java.lang.String)
+ */
+ @Deprecated
+ public Object getValue(String name)
+ {
+ return attributes.get(name);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#getAttributeNames()
+ */
+ public Enumeration<String> getAttributeNames()
+ {
+ return Collections.enumeration(attributes.keySet());
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#getValueNames()
+ */
+ @Deprecated
+ public String[] getValueNames()
+ {
+ return attributes.keySet().toArray(new String[attributes.keySet().size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#setAttribute(java.lang.String, java.lang.Object)
+ */
+ public void setAttribute(String name, Object value)
+ {
+ attributes.put(name, value);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#putValue(java.lang.String, java.lang.Object)
+ */
+ @Deprecated
+ public void putValue(String name, Object value)
+ {
+ attributes.put(name, value);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#removeAttribute(java.lang.String)
+ */
+ public void removeAttribute(String name)
+ {
+ attributes.remove(name);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#removeValue(java.lang.String)
+ */
+ @Deprecated
+ public void removeValue(String name)
+ {
+ attributes.remove(name);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#invalidate()
+ */
+ public void invalidate()
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpSession#isNew()
+ */
+ public boolean isNew()
+ {
+ return true;
+ }
+
+ /**
+ * The session id
+ */
+ private String id = null;
+
+ /**
+ * The list of attributes
+ */
+ private Map<String, Object> attributes = new HashMap<String, Object>();
+
+ /**
+ * When were we created
+ */
+ private long creationTime;
+
+ /**
+ * How long before we timeout?
+ */
+ private int maxInactiveInterval = 30 * 60 * 1000;
+}
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
new file mode 100644
index 000000000..d0a34ce38
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/client/HttpBasicClient.java
@@ -0,0 +1,67 @@
+/*-
+ * ============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 java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.ClientProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
+/**
+ * General HTTP client.
+ */
+
+public class HttpBasicClient{
+
+ /** The servlet context. */
+ @Autowired
+ private ServletContext servletContext;
+
+ /** 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 .
+ *
+ * @return Client client object
+ * @throws Exception the exception
+ */
+ public static Client getClient() throws Exception {
+
+ ClientConfig config = new ClientConfig();
+ config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
+
+ return ClientBuilder.newClient(config)
+ .register(org.onap.vid.aai.util.CustomJacksonJaxBJsonProvider.class);
+ }
+}
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
new file mode 100644
index 000000000..28a4d0f9f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/client/HttpsBasicClient.java
@@ -0,0 +1,143 @@
+/*-
+ * ============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 java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+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 org.eclipse.jetty.util.security.Password;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.ClientProperties;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.onap.vid.properties.VidProperties;
+
+ /**
+ * 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() throws Exception {
+ String methodName = "getClient";
+ ClientConfig config = new ClientConfig();
+ //config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
+ //config.getClasses().add(org.openecomp.aai.util.CustomJacksonJaxBJsonProvider.class);
+
+ 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());
+
+ //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 = EncryptedPropValue.decryptTriple(keystore_password);
+
+ 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");
+
+ /*
+ KeyManagerFactory kmf = null;
+ try {
+ kmf = KeyManagerFactory.getInstance("SunX509");
+ FileInputStream fin = new FileInputStream(keystore_path);
+ KeyStore ks = KeyStore.getInstance("PKCS12");
+ char[] pwd = decrypted_keystore_password.toCharArray();
+ ks.load(fin, pwd);
+ kmf.init(ks, pwd);
+ } catch (Exception e) {
+ System.out.println("Error setting up kmf: exiting");
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ ctx.init(kmf.getKeyManagers(), null, null);
+ */
+ 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");
+ //System.out.println("Error setting up config: exiting");
+ e.printStackTrace();
+ return null;
+ }
+
+ //Client client = ClientBuilder.newClient(config);
+ // uncomment this line to get more logging for the request/response
+ // client.addFilter(new LoggingFilter(System.out));
+
+ //return client;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
new file mode 100644
index 000000000..1719ff6d4
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AaiController.java
@@ -0,0 +1,750 @@
+/*-
+ * ============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.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.onap.vid.aai.AaiResponse;
+import org.onap.vid.aai.ServiceInstancesSearchResults;
+import org.onap.vid.aai.SubscriberData;
+import org.onap.vid.aai.SubscriberFilteredResults;
+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.util.AAIRestInterface;
+import org.onap.vid.model.VersionByInvariantIdsRequest;
+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.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.HandlerMapping;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import java.io.File;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import static org.onap.vid.utils.Logging.getMethodName;
+
+/**
+ * Controller to handle a&ai requests.
+ */
+
+@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";
+ /**
+ * The logger.
+ */
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(AaiController.class);
+ /**
+ * The model.
+ */
+ private Map<String, Object> model = new HashMap<String, Object>();
+ /**
+ * The servlet context.
+ */
+ @Autowired
+ private ServletContext servletContext;
+ /**
+ * aai service
+ */
+ @Autowired
+ private AaiService aaiService;
+ @Autowired
+ private RoleProvider roleProvider;
+
+ public AaiController() {
+
+ }
+
+ public AaiController(ServletContext servletContext) {
+ this.servletContext = servletContext;
+
+ }
+
+ /**
+ * Welcome method.
+ *
+ * @param request the request
+ * @return ModelAndView The view
+ */
+ @RequestMapping(value = {"/subscriberSearch"}, method = RequestMethod.GET)
+ public ModelAndView welcome(HttpServletRequest request) {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== AaiController welcome start");
+ return new ModelAndView(getViewName());
+ }
+
+ @RequestMapping(value = {"/aai_get_aic_zones"}, method = RequestMethod.GET)
+ public ResponseEntity<String> getAicZones(HttpServletRequest request) throws JsonGenerationException, JsonMappingException, IOException {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== 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 JsonGenerationException, JsonMappingException, IOException {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== getAicZoneForPnf controller start");
+ AaiResponse response = aaiService.getAicZoneForPnf(globalCustomerId , serviceType , serviceId);
+ return aaiResponseToResponseEntity(response);
+ }
+
+ /**
+ * Get services from a&ai.
+ *
+ * @return ResponseEntity<String> The response entity with the logged in user uuid.
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ */
+ @RequestMapping(value = {"/getuserID"}, method = RequestMethod.GET)
+ public ResponseEntity<String> getUserID(HttpServletRequest request) throws IOException, InterruptedException {
+
+ String userId = ControllersUtils.extractUserId(request);
+
+ return new ResponseEntity<String>(userId, HttpStatus.OK);
+ }
+
+ /**
+ * Get services from a&ai.
+ *
+ * @return ResponseEntity<String> The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ */
+ @RequestMapping(value = "/aai_get_services", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doGetServices(HttpServletRequest request) throws IOException, InterruptedException {
+ RoleValidator roleValidator = new RoleValidator(roleProvider.getUserRoles(request));
+
+ AaiResponse subscriberList = aaiService.getServices(roleValidator);
+ ResponseEntity<String> responseEntity = aaiResponseToResponseEntity(subscriberList);
+
+ return responseEntity;
+ }
+
+
+ @RequestMapping(value = {"/aai_get_version_by_invariant_id"}, method = RequestMethod.POST)
+ public ResponseEntity<String> getVersionByInvariantId(HttpServletRequest request, @RequestBody VersionByInvariantIdsRequest versions) throws IOException {
+ ResponseEntity<String> responseEntity;
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ Response result = aaiService.getVersionByInvariantId(versions.versions);
+
+ return new ResponseEntity<String>(result.readEntity(String.class), HttpStatus.OK);
+ }
+
+
+ private ResponseEntity<String> aaiResponseToResponseEntity(AaiResponse aaiResponseData)
+ throws IOException, JsonGenerationException, JsonMappingException {
+ ResponseEntity<String> responseEntity;
+ ObjectMapper objectMapper = new ObjectMapper();
+ if (aaiResponseData.getHttpCode() == 200) {
+ responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(aaiResponseData.getT()), HttpStatus.OK);
+ } else {
+ responseEntity = new ResponseEntity<String>(aaiResponseData.getErrorMessage(), HttpStatus.valueOf(aaiResponseData.getHttpCode()));
+ }
+ return responseEntity;
+ }
+
+ /**
+ * Lookup single service instance in a&ai. Get the service-subscription and customer, too, i guess?
+ *
+ * @param serviceInstanceId the service instance Id
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ */
+ @RequestMapping(value = "/aai_get_service_instance/{service-instance-id}/{service-instance-type}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doGetServiceInstance(@PathVariable("service-instance-id") String serviceInstanceId, @PathVariable("service-instance-type") String serviceInstanceType) throws IOException, InterruptedException {
+ File certiPath = GetCertificatesPath();
+ Response resp = null;
+
+ if (serviceInstanceType.equalsIgnoreCase("Service Instance Id")) {
+ resp = doAaiGet(certiPath.getAbsolutePath(),
+ "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:"
+ + serviceInstanceId, false);
+ } else {
+ resp = doAaiGet(certiPath.getAbsolutePath(),
+ "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:"
+ + serviceInstanceId, false);
+ }
+ return convertResponseToResponseEntity(resp);
+ }
+
+ /**
+ * Get services from a&ai.
+ *
+ * @param globalCustomerId the global customer id
+ * @param serviceSubscriptionId the service subscription id
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ */
+ @RequestMapping(value = "/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doGetServices(@PathVariable("global-customer-id") String globalCustomerId,
+ @PathVariable("service-subscription-id") String serviceSubscriptionId) throws IOException, InterruptedException {
+ File certiPath = GetCertificatesPath();
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers/customer/" + globalCustomerId
+ + "/service-subscriptions/service-subscription/" + serviceSubscriptionId + "?depth=0", false);
+ return convertResponseToResponseEntity(resp);
+ }
+
+ /**
+ * Obtain the subscriber list from a&ai.
+ *
+ * @param fullSet the full set
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ */
+ @RequestMapping(value = "/aai_get_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doGetSubscriberList(HttpServletRequest request, @DefaultValue("n") @QueryParam("fullSet") String fullSet) throws IOException, InterruptedException {
+ return getFullSubscriberList(request);
+ }
+
+ /**
+ * Obtain the Target Prov Status from the System.Properties file.
+ *
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ */
+ @RequestMapping(value = "/get_system_prop_vnf_prov_status", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> getTargetProvStatus() throws IOException, InterruptedException {
+ String p = SystemProperties.getProperty("aai.vnf.provstatus");
+ return new ResponseEntity<String>(p, HttpStatus.OK);
+ }
+
+
+ /**
+ * Obtain the Target Prov Status from the System.Properties file.
+ *
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ */
+ @RequestMapping(value = "/get_operational_environments", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public AaiResponse<OperationalEnvironmentList> getOperationalEnvironments(@RequestParam(value="operationalEnvironmentType", required = false) String operationalEnvironmentType,
+ @RequestParam(value="operationalEnvironmentStatus", required = false) String operationalEnvironmentStatus) throws IOException, InterruptedException {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({}, {})", getMethodName(), operationalEnvironmentType, operationalEnvironmentStatus);
+ AaiResponse<OperationalEnvironmentList> response = aaiService.getOperationalEnvironments(operationalEnvironmentType,operationalEnvironmentStatus);
+ if (response.getHttpCode() != 200) {
+ String errorMessage = getAaiErrorMessage(response.getErrorMessage());
+ if(errorMessage != null) {
+ response = new AaiResponse<OperationalEnvironmentList>(response.getT(), errorMessage, response.getHttpCode());
+ }
+ }
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), response);
+ return response;
+ }
+
+ /**
+ * Obtain the full subscriber list from a&ai.
+ * <p>
+ * g @return ResponseEntity The response entity
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ */
+ @RequestMapping(value = "/aai_get_full_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> getFullSubscriberList(HttpServletRequest request) throws IOException, InterruptedException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ ResponseEntity<String> responseEntity;
+ 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);
+ } else {
+ responseEntity = new ResponseEntity<String>(subscriberList.getErrorMessage(), HttpStatus.valueOf(subscriberList.getHttpCode()));
+ }
+
+
+ return responseEntity;
+ }
+
+
+ @RequestMapping(value = "/get_vnf_data_by_globalid_and_service_type/{globalCustomerId}/{serviceType}",
+ method = RequestMethod.GET,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> getVnfDataByGlobalIdAndServiceType(HttpServletRequest request,
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType) throws IOException {
+
+ Response resp = aaiService.getVNFData(globalCustomerId, serviceType);
+ return convertResponseToResponseEntity(resp);
+ }
+
+
+ /**
+ * Refresh the subscriber list from a&ai.
+ *
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = "/aai_refresh_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doRefreshSubscriberList() throws IOException {
+ Response resp = getSubscribers(false);
+ return convertResponseToResponseEntity(resp);
+ }
+
+ /**
+ * Refresh the full subscriber list from a&ai.
+ *
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @RequestMapping(value = "/aai_refresh_full_subscribers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity<String> doRefreshFullSubscriberList() throws IOException {
+ Response resp = getSubscribers(false);
+ return convertResponseToResponseEntity(resp);
+ }
+
+ /**
+ * Get subscriber details from a&ai.
+ *
+ * @param subscriberId the subscriber id
+ * @return ResponseEntity The response entity
+ */
+ @RequestMapping(value = "/aai_sub_details/{subscriberId}", method = RequestMethod.GET)
+ public ResponseEntity<String> GetSubscriberDetails(HttpServletRequest request, @PathVariable("subscriberId") String subscriberId) throws IOException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ ResponseEntity responseEntity;
+ List<Role> roles = roleProvider.getUserRoles(request);
+ RoleValidator roleValidator = new RoleValidator(roles);
+ AaiResponse<SubscriberData> subscriberData = aaiService.getSubscriberData(subscriberId, roleValidator);
+ String httpMessage = subscriberData.getT() != null ?
+ objectMapper.writeValueAsString(subscriberData.getT()) :
+ subscriberData.getErrorMessage();
+
+ responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.valueOf(subscriberData.getHttpCode()));
+ return responseEntity;
+ }
+
+ /**
+ * Get service instances that match the query from a&ai.
+ *
+ * @param subscriberId the subscriber id
+ * @param instanceIdentifier the service instance name or id.
+ * @param projects the projects that are related to the instance
+ * @param owningEntities the owningEntities that are related to the instance
+ * @return ResponseEntity The response entity
+ */
+ @RequestMapping(value = "/search_service_instances", method = RequestMethod.GET)
+ public ResponseEntity<String> SearchServiceInstances(HttpServletRequest request,
+ @RequestParam(value="subscriberId", required = false) String subscriberId,
+ @RequestParam(value="serviceInstanceIdentifier", required = false) String instanceIdentifier,
+ @RequestParam(value="project", required = false) List<String> projects,
+ @RequestParam(value="owningEntity", required = false) List<String> owningEntities) throws IOException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ ResponseEntity responseEntity;
+
+ List<Role> roles = roleProvider.getUserRoles(request);
+ RoleValidator roleValidator = new RoleValidator(roles);
+
+ AaiResponse<ServiceInstancesSearchResults> searchResult = aaiService.getServiceInstanceSearchResults(subscriberId, instanceIdentifier, roleValidator, owningEntities, projects);
+
+ String httpMessage = searchResult.getT() != null ?
+ objectMapper.writeValueAsString(searchResult.getT()) :
+ searchResult.getErrorMessage();
+
+
+ if(searchResult.getT().serviceInstances.size() == 0){
+ responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.NOT_FOUND);
+
+ } else {
+ responseEntity = new ResponseEntity<String>(httpMessage, HttpStatus.valueOf(searchResult.getHttpCode()));
+
+ }
+ return responseEntity;
+ }
+
+
+
+ /**
+ * Issue a named query to a&ai.
+ *
+ * @param namedQueryId the named query id
+ * @param globalCustomerId the global customer id
+ * @param serviceType the service type
+ * @param serviceInstance the service instance
+ * @return ResponseEntity The response entity
+ */
+ @RequestMapping(value = "/aai_sub_viewedit/{namedQueryId}/{globalCustomerId}/{serviceType}/{serviceInstance}", method = RequestMethod.GET)
+ public ResponseEntity<String> viewEditGetComponentList(
+ @PathVariable("namedQueryId") String namedQueryId,
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType,
+ @PathVariable("serviceInstance") String serviceInstance) {
+
+ String componentListPayload = getComponentListPutPayload(namedQueryId, globalCustomerId, serviceType, serviceInstance);
+ File certiPath = GetCertificatesPath();
+
+ Response resp = doAaiPost(certiPath.getAbsolutePath(), "search/named-query", componentListPayload, false);
+ 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.
+ *
+ * @param namedQueryId the named query id
+ * @param globalCustomerId the global customer id
+ * @param serviceType the service type
+ * @return ResponseEntity The response entity
+ */
+ @RequestMapping(value = "/aai_get_models_by_service_type/{namedQueryId}/{globalCustomerId}/{serviceType}", method = RequestMethod.GET)
+ public ResponseEntity<String> viewEditGetComponentList(
+ @PathVariable("namedQueryId") String namedQueryId,
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType) {
+
+ String componentListPayload = getModelsByServiceTypePayload(namedQueryId, globalCustomerId, serviceType);
+ File certiPath = GetCertificatesPath();
+
+ Response resp = doAaiPost(certiPath.getAbsolutePath(), "search/named-query", componentListPayload, false);
+ return convertResponseToResponseEntity(resp);
+ }
+
+ @RequestMapping(value = "/aai_get_vnf_instances/{globalCustomerId}/{serviceType}/{modelVersionId}/{modelInvariantId}/{cloudRegion}", method = RequestMethod.GET)
+ public ResponseEntity<String> getNodeTemplateInstances(
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType,
+ @PathVariable("modelVersionId") String modelVersionId,
+ @PathVariable("modelInvariantId") String modelInvariantId,
+ @PathVariable("cloudRegion") String cloudRegion) {
+
+ AaiResponse<String> resp = aaiService.getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion);
+ return new ResponseEntity<String>(resp.getT(), HttpStatus.valueOf(resp.getHttpCode()));
+ }
+
+ @RequestMapping(value = "/aai_get_by_uri/**", method = RequestMethod.GET)
+ public ResponseEntity<String> getByUri(HttpServletRequest request) {
+ File certiPath = GetCertificatesPath();
+
+ String restOfTheUrl = (String) request.getAttribute(
+ HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
+ String formattedUri = restOfTheUrl.replaceFirst("/aai_get_by_uri/", "").replaceFirst("^aai/v[\\d]+/", "");
+
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), formattedUri, false);
+
+ return convertResponseToResponseEntity(resp);
+ }
+
+ @RequestMapping(value = "/aai_get_configuration/{configuration_id}", method = RequestMethod.GET)
+ public ResponseEntity<String> getSpecificConfiguration(@PathVariable("configuration_id") String configurationId) {
+ File certiPath = GetCertificatesPath();
+
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), "network/configurations/configuration/"+configurationId, false);
+
+ return convertResponseToResponseEntity(resp);
+ }
+
+ @RequestMapping(value = "/aai_get_service_instance_pnfs/{globalCustomerId}/{serviceType}/{serviceInstanceId}", method = RequestMethod.GET)
+ public List<String> getServiceInstanceAssociatedPnfs(
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType,
+ @PathVariable("serviceInstanceId") String serviceInstanceId) {
+
+ return aaiService.getServiceInstanceAssociatedPnfs(globalCustomerId, serviceType, serviceInstanceId);
+ }
+
+ /**
+ * PNF section
+ */
+ @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()));
+ } catch (Exception e){
+ return new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ //logger.trace(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), resp.getHttpCode());
+ return re;
+ }
+
+
+ /**
+ * Obtain tenants for a given service type.
+ *
+ * @param globalCustomerId the global customer id
+ * @param serviceType the service type
+ * @return ResponseEntity The response entity
+ */
+ @RequestMapping(value = "/aai_get_tenants/{global-customer-id}/{service-type}", method = RequestMethod.GET)
+ public ResponseEntity<String> viewEditGetTenantsFromServiceType(HttpServletRequest request,
+ @PathVariable("global-customer-id") String globalCustomerId, @PathVariable("service-type") String serviceType) {
+
+ ResponseEntity responseEntity;
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ List<Role> roles = roleProvider.getUserRoles(request);
+ RoleValidator roleValidator = new RoleValidator(roles);
+ AaiResponse<GetTenantsResponse[]> response = aaiService.getTenants(globalCustomerId, serviceType, roleValidator);
+ if (response.getHttpCode() == 200) {
+ responseEntity = new ResponseEntity<String>(objectMapper.writeValueAsString(response.getT()), HttpStatus.OK);
+ } else {
+ responseEntity = new ResponseEntity<String>(response.getErrorMessage(), HttpStatus.valueOf(response.getHttpCode()));
+ }
+ } catch (Exception e) {
+ responseEntity = new ResponseEntity<String>("Unable to proccess getTenants reponse", HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ return responseEntity;
+ }
+
+ @RequestMapping(value = "/aai_get_pnf_instances/{globalCustomerId}/{serviceType}/{modelVersionId}/{modelInvariantId}/{cloudRegion}/{equipVendor}/{equipModel}", method = RequestMethod.GET)
+ public ResponseEntity<String> getPnfInstances(
+ @PathVariable("globalCustomerId") String globalCustomerId,
+ @PathVariable("serviceType") String serviceType,
+ @PathVariable("modelVersionId") String modelVersionId,
+ @PathVariable("modelInvariantId") String modelInvariantId,
+ @PathVariable("cloudRegion") String cloudRegion,
+ @PathVariable("equipVendor") String equipVendor,
+ @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()));
+ }
+
+ 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);
+ } else {
+ respEnt = new ResponseEntity<String>(resp.readEntity(String.class), HttpStatus.valueOf(resp.getStatus()));
+ }
+ return respEnt;
+ }
+
+ /**
+ * Gets the subscribers.
+ *
+ * @param isFullSet the is full set
+ * @return the subscribers
+ */
+ private Response getSubscribers(boolean isFullSet) {
+
+ File certiPath = GetCertificatesPath();
+ String depth = "0";
+
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), "business/customers?subscriber-type=INFRA&depth=" + depth, false);
+ if (resp != null) {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "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) {
+ File certiPath = GetCertificatesPath();
+ Response resp = doAaiGet(certiPath.getAbsolutePath(), "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;
+ }
+
+ /**
+ * Gets the certificates path.
+ *
+ * @return the file
+ */
+ private File GetCertificatesPath() {
+ if (servletContext != null)
+ return new File(servletContext.getRealPath("/WEB-INF/cert/"));
+ return null;
+ }
+
+ /**
+ * Send a GET request to a&ai.
+ *
+ * @param certiPath the certi path
+ * @param uri the uri
+ * @param xml the xml
+ * @return String The response
+ */
+ protected Response doAaiGet(String certiPath, String uri, boolean xml) {
+ String methodName = "getSubscriberList";
+ String transId = UUID.randomUUID().toString();
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ Response resp = null;
+ try {
+
+ AAIRestInterface restContrller = new AAIRestInterface(certiPath);
+ resp = restContrller.RestGet(fromAppId, transId, uri, xml);
+
+ } catch (WebApplicationException e) {
+ final String message = ((BadRequestException) 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);
+ } 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());
+ }
+
+ return resp;
+ }
+
+ /**
+ * Send a POST request to a&ai.
+ *
+ * @param certiPath the certi path
+ * @param uri the uri
+ * @param payload the payload
+ * @param xml the xml
+ * @return String The response
+ */
+ protected Response doAaiPost(String certiPath, String uri, String payload, boolean xml) {
+ String methodName = "getSubscriberList";
+ String transId = UUID.randomUUID().toString();
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ Response resp = null;
+ try {
+
+ AAIRestInterface restContrller = new AAIRestInterface(certiPath);
+ resp = restContrller.RestPost(fromAppId, transId, 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());
+ }
+
+ return resp;
+ }
+
+ /**
+ * Gets the component list put payload.
+ *
+ * @param namedQueryId the named query id
+ * @param globalCustomerId the global customer id
+ * @param serviceType the service type
+ * @param serviceInstance the service instance
+ * @return the component list put payload
+ */
+ private String getComponentListPutPayload(String namedQueryId, String globalCustomerId, String serviceType, String serviceInstance) {
+ return
+ " {" +
+ " \"instance-filters\": {" +
+ " \"instance-filter\": [" +
+ " {" +
+ " \"customer\": {" +
+ " \"global-customer-id\": \"" + globalCustomerId + "\"" +
+ " }," +
+ " \"service-instance\": {" +
+ " \"service-instance-id\": \"" + serviceInstance + "\"" +
+ " }," +
+ " \"service-subscription\": {" +
+ " \"service-type\": \"" + serviceType + "\"" +
+ " }" +
+ " }" +
+ " ]" +
+ " }," +
+ " \"query-parameters\": {" +
+ " \"named-query\": {" +
+ " \"named-query-uuid\": \"" + namedQueryId + "\"" +
+ " }" +
+ " }" +
+ "}";
+
+ }
+
+ private String getModelsByServiceTypePayload(String namedQueryId, String globalCustomerId, String serviceType) {
+ // TODO Auto-generated method stub
+ return " {" +
+ " \"instance-filters\": {" +
+ " \"instance-filter\": [" +
+ " {" +
+ " \"customer\": {" +
+ " \"global-customer-id\": \"" + globalCustomerId + "\"" +
+ " }," +
+ " \"service-subscription\": {" +
+ " \"service-type\": \"" + serviceType + "\"" +
+ " }" +
+ " }" +
+ " ]" +
+ " }," +
+ " \"query-parameters\": {" +
+ " \"named-query\": {" +
+ " \"named-query-uuid\": \"" + namedQueryId + "\"" +
+ " }" +
+ " }" +
+ "}";
+
+ }
+
+ private String getAaiErrorMessage(String message) {
+ try {
+ org.json.JSONObject json = new org.json.JSONObject(message);
+ json = json.getJSONObject("requestError").getJSONObject("serviceException");
+
+ return json.getString("messageId") + ": " + json.getString("text");
+
+ } catch (Exception e) {
+ return null;
+ }
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/ChangeManagementController.java b/vid-app-common/src/main/java/org/onap/vid/controller/ChangeManagementController.java
new file mode 100644
index 000000000..4f307ed96
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/ChangeManagementController.java
@@ -0,0 +1,193 @@
+package org.onap.vid.controller;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.json.simple.JSONArray;
+import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.changeManagement.*;
+import org.onap.vid.exceptions.NotFoundException;
+import org.onap.vid.model.ExceptionResponse;
+import org.onap.vid.model.MsoExceptionResponse;
+import org.onap.vid.mso.MsoResponseWrapper2;
+import org.onap.vid.mso.MsoResponseWrapperInterface;
+import org.onap.vid.mso.rest.Request;
+import org.onap.vid.services.ChangeManagementService;
+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.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.WebApplicationException;
+import java.io.IOException;
+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.
+ */
+@RestController
+@RequestMapping(ChangeManagementController.CHANGE_MANAGEMENT)
+public class ChangeManagementController extends UnRestrictedBaseController {
+ private static final String GetWorkflowsResponse = null;
+ public static final String VNF_WORKFLOW_RELATION = "vnf_workflow_relation";
+ public static final String CHANGE_MANAGEMENT = "change-management";
+ public static final String GET_VNF_WORKFLOW_RELATION = "get_vnf_workflow_relation";
+ public static final String SCHEDULER_BY_SCHEDULE_ID = "/scheduler/schedules/{scheduleId}";
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(ChangeManagementController.class);
+ private String fromAppId;
+ private final WorkflowService workflowService;
+ private final ChangeManagementService changeManagementService;
+ private final ObjectMapper objectMapper;
+
+
+ @Autowired
+ public ChangeManagementController(WorkflowService workflowService, ChangeManagementService changeManagementService, ObjectMapper objectMapper) {
+ this.fromAppId = "VidChangeManagementController";
+ this.workflowService = workflowService;
+ this.changeManagementService = changeManagementService;
+ this.objectMapper = objectMapper;
+ }
+
+ @RequestMapping(value = {"/workflow"}, method = RequestMethod.GET)
+ public ResponseEntity<Collection<String>> getWorkflow(@RequestParam("vnfs") Collection<String> vnfs) throws IOException, InterruptedException {
+ Collection<String> result = this.workflowService.getWorkflowsForVNFs(vnfs);
+ return new ResponseEntity<>(result, OK);
+ }
+
+ @RequestMapping(value = {"/mso"}, method = RequestMethod.GET)
+ public ResponseEntity<Collection<Request>> getMSOChangeManagements() throws Exception, IOException, InterruptedException {
+
+ Collection<Request> result = this.changeManagementService.getMSOChangeManagements();
+ return new ResponseEntity<>(result, OK);
+ }
+
+ @RequestMapping(value = "/workflow/{vnfName}", method = RequestMethod.POST)
+ public ResponseEntity<String> changeManagement(@PathVariable("vnfName") String vnfName,
+ HttpServletRequest request,
+ @RequestBody ChangeManagementRequest changeManagmentRequest)
+ throws Exception {
+ return this.changeManagementService.doChangeManagement(changeManagmentRequest, vnfName);
+ }
+
+ @RequestMapping(value = "/uploadConfigUpdateFile", method = RequestMethod.POST)
+ public @ResponseBody ResponseEntity uploadConfigUpdateFile(@RequestPart("file") MultipartFile file)
+ throws Exception {
+ try {
+ String jsonString = this.changeManagementService.uploadConfigUpdateFile(file);
+ return new ResponseEntity<>(jsonString, HttpStatus.OK);
+ }
+ catch(WebApplicationException e){
+ return new ResponseEntity<>(handleException(e), HttpStatus.valueOf(e.getResponse().getStatus()));
+ }
+ catch (Exception e) {
+ return new ResponseEntity<>(handleException(e), INTERNAL_SERVER_ERROR);
+ }
+ }
+
+
+ @RequestMapping(value = {"/scheduler"}, method = RequestMethod.GET)
+ public ResponseEntity<JSONArray> getSchedulerChangeManagements() throws IOException, InterruptedException {
+ JSONArray result = this.changeManagementService.getSchedulerChangeManagements();
+ return new ResponseEntity<>(result, OK);
+ }
+
+ @RequestMapping(value = {SCHEDULER_BY_SCHEDULE_ID}, method = RequestMethod.DELETE)
+ public ResponseEntity deleteSchedule(@PathVariable("scheduleId") String scheduleId) throws IOException, InterruptedException {
+ Pair<String, Integer> result = this.changeManagementService.deleteSchedule(scheduleId);
+ return ResponseEntity.status(result.getRight()).build();
+ }
+
+
+ @RequestMapping(value = {GET_VNF_WORKFLOW_RELATION}, method = RequestMethod.POST)
+ public ResponseEntity getWorkflows(@RequestBody GetVnfWorkflowRelationRequest getVnfWorkflowRelationRequest) throws IOException, InterruptedException {
+ try {
+ GetWorkflowsResponse response = new GetWorkflowsResponse(changeManagementService.getWorkflowsForVnf(getVnfWorkflowRelationRequest));
+ return ResponseEntity.status(OK).body(response);
+ }
+ catch (NotFoundException exception) {
+ LOGGER.error(exception.getMessage(), exception);
+ return new ResponseEntity<>(new VnfWorkflowRelationResponse(Collections.singletonList(exception.getMessage())),HttpStatus.NOT_FOUND);
+ }
+ catch (Exception exception) {
+ return handleException(exception, "Failed to get workflows for vnf");
+ }
+ }
+
+ @RequestMapping(value = {VNF_WORKFLOW_RELATION}, method = RequestMethod.POST)
+ public ResponseEntity createWorkflowRelation(@RequestBody VnfWorkflowRelationRequest vnfWorkflowRelationRequest) throws IOException, InterruptedException {
+ VnfWorkflowRelationResponse vnfWorkflowRelationResponse;
+ try {
+ vnfWorkflowRelationResponse = changeManagementService.addVnfWorkflowRelation(vnfWorkflowRelationRequest);
+ }
+ catch (Exception exception) {
+ return handleException(exception, "Failed to add vnf to workflow relation");
+ }
+
+ return new ResponseEntity<>(vnfWorkflowRelationResponse, OK);
+ }
+
+ @RequestMapping(value = {VNF_WORKFLOW_RELATION}, method = RequestMethod.GET)
+ public ResponseEntity getAllWorkflowRelation() throws IOException, InterruptedException {
+
+ try {
+ VnfWorkflowRelationAllResponse vnfWorkflowRelationAllResponse = changeManagementService.getAllVnfWorkflowRelations();
+ return new ResponseEntity<>(vnfWorkflowRelationAllResponse, OK);
+ }
+ catch (Exception exception) {
+ return handleException(exception, "Failed to get all vnf to workflow relations");
+ }
+ }
+
+ @RequestMapping(value = {VNF_WORKFLOW_RELATION}, method = RequestMethod.DELETE)
+ public ResponseEntity deleteWorkflowRelation(@RequestBody VnfWorkflowRelationRequest vnfWorkflowRelationRequest) throws IOException, InterruptedException {
+ VnfWorkflowRelationResponse vnfWorkflowRelationResponse;
+ try {
+ vnfWorkflowRelationResponse = changeManagementService.deleteVnfWorkflowRelation(vnfWorkflowRelationRequest);
+ }
+ catch (Exception exception) {
+ return handleException(exception, "Failed to delete vnf from workflow relation");
+ }
+
+ return new ResponseEntity<>(vnfWorkflowRelationResponse, OK);
+ }
+
+ private ResponseEntity handleException(Exception exception, String msg) {
+ LOGGER.error(msg, exception);
+ return new ResponseEntity<>(new VnfWorkflowRelationResponse(Collections.singletonList(msg)), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+
+ private ExceptionResponse handleException(Exception e) {
+ return ControllersUtils.handleException(e, LOGGER);
+ }
+
+ @ExceptionHandler(Exception.class)
+ @ResponseStatus(value=OK) //return 200 for Backwards compatibility with the previous responses to scheduler
+ private MsoResponseWrapperInterface exceptionHandler(Exception e) {
+ return exceptionHandler(e, INTERNAL_SERVER_ERROR);
+ }
+
+ @ExceptionHandler({
+ javax.ws.rs.BadRequestException.class,
+ })
+ @ResponseStatus(value = OK) //return 200 for Backwards compatibility with the previous responses to scheduler
+ public MsoResponseWrapperInterface clientDerivedExceptionAsBadRequest(Exception e) {
+ // same handler, different HTTP Code
+ return exceptionHandler(e, BAD_REQUEST);
+ }
+
+ private MsoResponseWrapperInterface exceptionHandler(Exception e, HttpStatus httpStatus) {
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodName(), ExceptionUtils.getMessage(e), e);
+ MsoResponseWrapper2<MsoExceptionResponse> responseWrapper2 = new MsoResponseWrapper2<>(httpStatus.value(), new MsoExceptionResponse(e));
+ return responseWrapper2;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java b/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java
new file mode 100644
index 000000000..1df4f42bc
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/ControllersUtils.java
@@ -0,0 +1,40 @@
+package org.onap.vid.controller;
+
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.openecomp.portalsdk.core.domain.User;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.onap.vid.model.ExceptionResponse;
+import org.slf4j.MDC;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
+import static org.onap.vid.utils.Logging.getMethodName;
+
+public class ControllersUtils {
+
+
+ public static String extractUserId(HttpServletRequest request) {
+ String userId = "";
+ HttpSession session = request.getSession();
+ if (session != null) {
+ User user = (User) session.getAttribute(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME));
+ if (user != null) {
+ //userId = user.getHrid();
+ userId = user.getLoginId();
+ if (userId == null)
+ userId = user.getOrgUserId();
+ }
+ }
+ return userId;
+ }
+
+ public static ExceptionResponse handleException(Exception e, EELFLoggerDelegate logger) {
+ logger.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodName(), ExceptionUtils.getMessage(e), e);
+
+ ExceptionResponse exceptionResponse = new ExceptionResponse(e);
+ return exceptionResponse;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java b/vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java
new file mode 100644
index 000000000..2368649a4
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java
@@ -0,0 +1,192 @@
+/*-
+ * ============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.openecomp.portalsdk.core.controller.UnRestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.onap.vid.dao.FnAppDoaImpl;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Controller for user profile view. The view is restricted to authenticated
+ * users. The view name resolves to page user_profile.jsp which uses Angular.
+ */
+
+@RestController
+@RequestMapping("/")
+public class HealthCheckController extends UnRestrictedBaseController {
+
+
+ /** The logger. */
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(HealthCheckController.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ private static final String HEALTH_CHECK_PATH = "/healthCheck";
+
+ /**
+ * Model for JSON response with health-check results.
+ */
+ public class HealthStatus {
+ // Either 200 or 500
+ public int statusCode;
+
+ // Additional detail in case of error, empty in case of success.
+ public String message;
+
+ public String date;
+
+ public HealthStatus(int code, String msg) {
+ this.statusCode = code;
+ this.message = msg;
+ }
+
+ public HealthStatus(int code,String date, String msg) {
+ this.statusCode = code;
+ this.message = msg;
+ this.date=date;
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ public void setStatusCode(int code) {
+ this.statusCode = code;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String msg) {
+ this.message = msg;
+ }
+
+ public String getDate() {
+ return date;
+ }
+
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public int getProfileCount(String driver, String URL, String username, String password) {
+ FnAppDoaImpl doa= new FnAppDoaImpl();
+ int count= doa.getProfileCount(driver,URL,username,password);
+ return count;
+ }
+
+
+
+ /**
+ * Obtain the HealthCheck Status from the System.Properties file.
+ * Used by IDNS for redundancy
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ */
+ @RequestMapping(value="/healthCheck",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public HealthStatus gethealthCheckStatusforIDNS() throws IOException, InterruptedException {
+
+ String driver = SystemProperties.getProperty("db.driver");
+ String URL = SystemProperties.getProperty("db.connectionURL");
+ String username = SystemProperties.getProperty("db.userName");
+ String password = SystemProperties.getProperty("db.password");
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "driver ::" + driver);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "URL::" + URL);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "username::" + username);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger,"password::" + password);
+
+
+ HealthStatus healthStatus = null;
+ try {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "Performing health check");
+ int count=getProfileCount(driver,URL,username,password);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger,"count:::"+count);
+ healthStatus = new HealthStatus(200, "health check succeeded");
+ } catch (Exception ex) {
+
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex);
+ healthStatus = new HealthStatus(500, "health check failed: " + ex.toString());
+ }
+ return healthStatus;
+ }
+
+ /**
+ * Obtain the HealthCheck Status from the System.Properties file.
+ *
+ * @return ResponseEntity The response entity
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws InterruptedException the interrupted exception
+ * Project :
+ */
+ @RequestMapping(value="rest/healthCheck/{User-Agent}/{X-ECOMP-RequestID}",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ public HealthStatus getHealthCheck(
+ @PathVariable("User-Agent") String UserAgent,
+ @PathVariable("X-ECOMP-RequestID") String ECOMPRequestID) throws IOException, InterruptedException {
+
+ String driver = SystemProperties.getProperty("db.driver");
+ String URL = SystemProperties.getProperty("db.connectionURL");
+ String username = SystemProperties.getProperty("db.userName");
+ String password = SystemProperties.getProperty("db.password");
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "driver ::" + driver);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "URL::" + URL);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "username::" + username);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger,"password::" + password);
+
+
+ HealthStatus healthStatus = null;
+ try {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "Performing health check");
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "User-Agent" + UserAgent);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "X-ECOMP-RequestID" + ECOMPRequestID);
+
+
+ int count=getProfileCount(driver,URL,username,password);
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger,"count:::"+count);
+ healthStatus = new HealthStatus(200,dateFormat.format(new Date()) ,"health check succeeded");
+ } catch (Exception ex) {
+
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex);
+ healthStatus = new HealthStatus(500,dateFormat.format(new Date()),"health check failed: " + ex.toString());
+ }
+ return healthStatus;
+ }
+}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java b/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java
new file mode 100644
index 000000000..e70c87115
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/LoggerController.java
@@ -0,0 +1,115 @@
+package org.onap.vid.controller;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.FileAppender;
+import ch.qos.logback.core.spi.AppenderAttachable;
+import org.apache.commons.io.input.ReversedLinesFileReader;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.model.ExceptionResponse;
+import org.onap.vid.roles.Role;
+import org.onap.vid.roles.RoleProvider;
+import org.onap.vid.utils.Streams;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.NotAuthorizedException;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static com.att.eelf.configuration.Configuration.GENERAL_LOGGER_NAME;
+
+
+@RestController
+@RequestMapping("logger")
+public class LoggerController extends RestrictedBaseController {
+
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(LoggerController.class);
+
+ @Autowired
+ RoleProvider roleProvider;
+
+ @RequestMapping(value = "/{loggerName:audit|error|metrics}", method = RequestMethod.GET)
+ public String getLog(@PathVariable String loggerName, HttpServletRequest request,
+ @RequestParam(value="limit", defaultValue = "5000") Integer limit) throws IOException {
+
+ List<Role> roles = roleProvider.getUserRoles(request);
+ boolean userPermitted = roleProvider.userPermissionIsReadLogs(roles);
+ if (!userPermitted) {
+ throw new NotAuthorizedException("User not authorized to get logs");
+ }
+
+ String logfilePath = getLogfilePath(loggerName);
+
+ try (final ReversedLinesFileReader reader = new ReversedLinesFileReader(new File(logfilePath))) {
+ Supplier<String> reverseLinesSupplier = () -> {
+ try {
+ return reader.readLine();
+ } catch (NullPointerException e) {
+ // EOF Reached
+ return null;
+ } catch (IOException e) {
+ throw new InternalServerErrorException("error while reading " + logfilePath, e);
+ }
+ };
+
+ return Streams.takeWhile(
+ Stream.generate(reverseLinesSupplier),
+ line -> !StringUtils.contains(line, "Logging is started"))
+ .limit(limit)
+ .limit(5_000)
+ .filter(Objects::nonNull)
+ .collect(Collectors.joining("\n"));
+ }
+ }
+
+ private String getLogfilePath(String loggerName) {
+ /*
+ Find the requested logger, and pull all of it's appenders.
+ Find the first of the appenders that is a FileAppender, and return it's
+ write-out filename.
+ */
+ LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
+ return context.getLoggerList().stream()
+ .filter(logger -> logger.getName().equals(GENERAL_LOGGER_NAME + "." + loggerName))
+ .flatMap(this::pullSubAppenders)
+ .flatMap(appender -> {
+ // Appender might be "attachable", if so - roll-up its sub-appenders
+ return (appender instanceof AppenderAttachable) ?
+ pullSubAppenders((AppenderAttachable<?>) appender) : Stream.of(appender);
+ })
+ .filter(appender -> appender instanceof FileAppender)
+ .map(appender -> (FileAppender<?>) appender)
+ .map(FileAppender::getFile)
+ .findFirst()
+ .orElseThrow(() -> new InternalServerErrorException("logfile for " + loggerName + " not found"));
+ }
+
+ private <T> Stream<Appender<T>> pullSubAppenders(AppenderAttachable<T> logger) {
+ return Streams.fromIterator(logger.iteratorForAppenders());
+ }
+
+ @ExceptionHandler({ NotAuthorizedException.class })
+ @ResponseStatus(HttpStatus.UNAUTHORIZED)
+ public String notAuthorizedHandler(NotAuthorizedException e) {
+ return "UNAUTHORIZED";
+ }
+
+ @ExceptionHandler({ IOException.class, InternalServerErrorException.class })
+ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
+ public ExceptionResponse ioExceptionHandler(Exception e) {
+ return org.onap.vid.controller.ControllersUtils.handleException(e, LOGGER);
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java b/vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java
new file mode 100644
index 000000000..df1e6e421
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java
@@ -0,0 +1,135 @@
+package org.onap.vid.controller;
+
+
+import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.category.AddCategoryOptionResponse;
+import org.onap.vid.category.AddCategoryOptionsRequest;
+import org.onap.vid.category.CategoryParameterOptionRep;
+import org.onap.vid.category.CategoryParametersResponse;
+import org.onap.vid.model.CategoryParameter.Family;
+import org.onap.vid.model.CategoryParameterOption;
+import org.onap.vid.services.CategoryParameterService;
+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.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.ForbiddenException;
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.onap.vid.utils.Logging.getMethodName;
+
+/**
+ * Controler for APIs that are used only by vid operators
+ */
+
+@RestController
+@RequestMapping(MaintenanceController.Maintenance)
+public class MaintenanceController extends UnRestrictedBaseController {
+
+ public static final String Maintenance = "maintenance";
+
+ @Autowired
+ protected CategoryParameterService categoryParameterService;
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MaintenanceController.class);
+
+ /**
+ * Add list of options to one category parameter
+ * @param request the request
+ * @return the new option
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/category_parameter/{categoryName}", method = RequestMethod.POST)
+ public ResponseEntity addCategoryOptions (
+ HttpServletRequest request, @PathVariable String categoryName, @RequestBody AddCategoryOptionsRequest option) throws Exception {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName());
+ try {
+ AddCategoryOptionResponse response = categoryParameterService.createCategoryParameterOptions(categoryName, option);
+ HttpStatus httpStatus = response.getErrors().size()>0 ? HttpStatus.MULTI_STATUS : HttpStatus.OK;
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), response);
+ return new ResponseEntity<>(response, httpStatus);
+ }
+ catch (CategoryParameterServiceImpl.UnfoundedCategoryException exception) {
+ return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.NOT_FOUND);
+ }
+ catch (Exception exception) {
+ LOGGER.error("failed to add option to parameter category " + categoryName, exception);
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ @RequestMapping(value = "/category_parameter/{categoryName}", method = RequestMethod.PUT)
+ public ResponseEntity updateNameForOption (
+ HttpServletRequest request, @PathVariable String categoryName, @RequestBody CategoryParameterOptionRep option) throws Exception {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName());
+ try {
+ AddCategoryOptionResponse response = categoryParameterService.updateCategoryParameterOption(categoryName, option);
+ HttpStatus httpStatus = response.getErrors().size()>0 ? HttpStatus.MULTI_STATUS : HttpStatus.OK;
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), response);
+ return new ResponseEntity<>(response, httpStatus);
+ }
+ catch (ForbiddenException exception) {
+ return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.FORBIDDEN);
+ }
+ catch (CategoryParameterServiceImpl.UnfoundedCategoryException|CategoryParameterServiceImpl.UnfoundedCategoryOptionException exception) {
+ return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.NOT_FOUND);
+ }
+ catch (CategoryParameterServiceImpl.AlreadyExistOptionNameException exception) {
+ return new ResponseEntity<>(new AddCategoryOptionResponse(Collections.singletonList(exception.getMessage())), HttpStatus.CONFLICT);
+ }
+ catch (Exception exception) {
+ LOGGER.error("failed to update option to parameter category " + categoryName, exception);
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ /**
+ * Gets the owning entity properties.
+ * @param request the request
+ * @return the property
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/category_parameter", method = RequestMethod.GET)
+ public ResponseEntity getCategoryParameter(HttpServletRequest request, @RequestParam(value="familyName", required = true) Family familyName) throws Exception {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName());
+ try {
+ CategoryParametersResponse response = categoryParameterService.getCategoryParameters(familyName);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), response);
+ return new ResponseEntity<>(response, HttpStatus.OK);
+ }
+ catch (Exception exception) {
+ LOGGER.error("failed to retrieve category parameter list from DB.", exception);
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+
+ /**
+ * Delete option of the category.
+ * @param request the request
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/delete_category_parameter/{categoryName}", method = RequestMethod.POST)
+ public ResponseEntity deleteCategoryOption (
+ HttpServletRequest request, @PathVariable String categoryName, @RequestBody CategoryParameterOption option) throws Exception {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName());
+
+ try {
+ categoryParameterService.deleteCategoryOption(categoryName, option);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), HttpStatus.OK);
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+ catch (CategoryParameterServiceImpl.UnfoundedCategoryException exception) {
+ return new ResponseEntity<>(new AddCategoryOptionResponse(Arrays.asList(exception.getMessage())), HttpStatus.NOT_FOUND);
+ }
+ catch (Exception exception) {
+ LOGGER.error("failed to add/update owning entity option", exception);
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
new file mode 100644
index 000000000..2aa52b858
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
@@ -0,0 +1,42 @@
+package org.onap.vid.controller;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.vid.factories.MsoRequestFactory;
+import org.onap.vid.mso.MsoBusinessLogic;
+import org.onap.vid.mso.MsoBusinessLogicImpl;
+import org.onap.vid.mso.MsoInterface;
+import org.onap.vid.mso.rest.MsoRestClientNew;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+
+@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();
+ }
+
+ @Bean
+ public MsoBusinessLogic getMsoBusinessLogic(){
+ return new MsoBusinessLogicImpl(getMsoClient());
+ }
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
new file mode 100644
index 000000000..1ce1d64c4
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
@@ -0,0 +1,655 @@
+/*-
+ * ============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 com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.vid.model.ExceptionResponse;
+import org.onap.vid.mso.MsoBusinessLogic;
+import org.onap.vid.mso.MsoResponseWrapper;
+import org.onap.vid.mso.rest.Request;
+import org.onap.vid.mso.rest.RequestDetails;
+import org.onap.vid.mso.rest.Task;
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+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.List;
+
+//import java.util.UUID;
+//import org.springframework.http.ResponseEntity;
+//import org.springframework.http.RequestEntity;
+
+/**
+ * The Class MsoController.
+ */
+@RestController
+@RequestMapping("mso")
+public class MsoController extends RestrictedBaseController {
+
+ /**
+ * The logger.
+ */
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(MsoController.class);
+
+ /**
+ * The Constant dateFormat.
+ */
+ 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>";
+
+ /**
+ * The Constant CONFIGURATION_ID
+ */
+ public final static String CONFIGURATION_ID = "<configuration_id>";
+
+ /**
+ * The Constant VNF_INSTANCE_ID.
+ */
+ public final static String VNF_INSTANCE_ID = "<vnf_instance_id>";
+
+ private final MsoBusinessLogic msoBusinessLogic;
+
+ @Autowired
+ public MsoController(MsoBusinessLogic msoBusinessLogic) {
+ this.msoBusinessLogic = msoBusinessLogic;
+ }
+
+ /**
+ * Creates the svc instance.
+ *
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
+ public ResponseEntity<String> createSvcInstance(HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
+ String methodName = "createSvcInstance";
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ // always return OK, the MSO status code is embedded in the body
+
+ MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(mso_request);
+
+ return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Creates the vnf.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param request the request
+ * @return the response entity
+ * @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) throws Exception {
+
+ MsoResponseWrapper w = msoBusinessLogic.createVnf(mso_request, serviceInstanceId);
+
+ // always return OK, the MSO status code is embedded in the body
+
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Creates the nw instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param request the request
+ * @return the response entity
+ * @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) throws Exception {
+ String methodName = "createNwInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
+
+ MsoResponseWrapper w = msoBusinessLogic.createNwInstance(mso_request, serviceInstanceId);
+
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Creates the volume group instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @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) throws Exception {
+ String methodName = "createVolumeGroupInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Creates the vf module instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @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) throws Exception {
+ String methodName = "createVfModuleInstance";
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.createVfModuleInstance(mso_request, serviceInstanceId, vnfInstanceId);
+
+ // always return OK, the MSO status code is embedded in the body
+
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Creates a configuration instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_create_configuration_instance/{serviceInstanceId}/configurations/", method = RequestMethod.POST)
+ public ResponseEntity<String> createConfigurationInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
+ String methodName = "createConfigurationInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.createConfigurationInstance(mso_request, serviceInstanceId);
+
+ // always return OK, the MSO status code is embedded in the body
+
+ return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Delete svc instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ HttpServletRequest request, @RequestBody RequestDetails mso_request) throws Exception {
+
+ String methodName = "deleteSvcInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(mso_request, serviceInstanceId);
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+ // always return OK, the MSO status code is embedded in the body
+
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Delete vnf.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @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) throws Exception {
+ String methodName = "deleteVnf";
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.deleteVnf(mso_request, serviceInstanceId, vnfInstanceId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Delete configuration instance
+ * @param serviceInstanceId the service instance id
+ * @param configurationId the configuration id
+ * @param mso_request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "mso_delete_configuration/{serviceInstanceId}/configurations/{configurationId}",
+ method = RequestMethod.POST)
+ public ResponseEntity<String> deleteConfiguration(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable ("configurationId") String configurationId,
+ @RequestBody RequestDetails mso_request) throws Exception {
+
+ String methodName = "deleteConfiguration";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger,
+ dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(mso_request, serviceInstanceId, configurationId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Activate configuration instance
+ * @param serviceInstanceId the service instace id
+ * @param configurationId the configuration id
+ * @param mso_request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "mso_activate_configuration/{serviceInstanceId}/configurations/{configurationId}",
+ method = RequestMethod.POST)
+ public ResponseEntity<String> activateConfiguration(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetails mso_request) throws Exception {
+
+ MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, true);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Deactivate configuration instance
+ * @param serviceInstanceId the service instace id
+ * @param configurationId the configuration id
+ * @param mso_request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "mso_deactivate_configuration/{serviceInstanceId}/configurations/{configurationId}",
+ method = RequestMethod.POST)
+ public ResponseEntity<String> deactivateConfiguration(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetails mso_request) throws Exception {
+
+ MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(mso_request, serviceInstanceId, configurationId, false);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Disable port on configuration instance
+ * @param serviceInstanceId the service instance id
+ * @param configurationId the configuration instance id
+ * @param mso_request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "mso_disable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
+ method = RequestMethod.POST)
+ public ResponseEntity<String> disablePortOnConfiguration(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetails mso_request) throws Exception {
+
+ MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, false);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Enable port on configuration instance
+ * @param serviceInstanceId the service instance id
+ * @param configurationId the configuration instance id
+ * @param mso_request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "mso_enable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
+ method = RequestMethod.POST)
+ public ResponseEntity<String> enablePortOnConfiguration(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetails mso_request) throws Exception {
+
+ MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(mso_request, serviceInstanceId, configurationId, true);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Delete vf module.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param vfModuleId the vf module id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ //mso_delete_vf_module/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/fe9000-0009-9999/vfmodules/abeeee-abeeee-abeeee
+ @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) throws Exception {
+
+ String methodName = "deleteVfModule";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.deleteVfModule(mso_request, serviceInstanceId, vnfInstanceId, vfModuleId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Delete volume group instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param volumeGroupId the volume group id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @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) throws Exception {
+ String methodName = "deleteVolumeGroupInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.deleteVolumeGroupInstance(mso_request, serviceInstanceId, vnfInstanceId, volumeGroupId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+ /**
+ * Delete nw instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param networkInstanceId the network instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @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) throws Exception {
+ String methodName = "deleteNwInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(mso_request, serviceInstanceId, networkInstanceId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+
+ }
+
+ /**
+ * Gets the orchestration request.
+ *
+ * @param requestId the request id
+ * @param request the request
+ * @return the orchestration request
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
+ public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
+ HttpServletRequest request) throws Exception {
+
+ String methodName = "getOrchestrationRequest";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+
+ MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+
+ /**
+ * Gets the orchestration requests.
+ *
+ * @param filterString the filter string
+ * @param request the request
+ * @return the orchestration requests
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
+ public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
+ HttpServletRequest request) throws Exception {
+
+ String methodName = "getOrchestrationRequests";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+
+ MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
+
+ // always return OK, the MSO status code is embedded in the body
+ return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ }
+
+
+ /**
+ * activate to a pnf instance.
+ *
+ * @param serviceInstanceId the id of the service.
+ * @param requestDetails the body of the request.
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) throws Exception {
+ String methodName = "activateServiceInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
+ }
+
+ /**
+ * deactivate a service instance.
+ *
+ * @param serviceInstanceId the id of the service.
+ * @param requestDetails the body of the request.
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) throws Exception {
+ String methodName = "deactivateServiceInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
+ }
+
+
+ /**
+ * Gets the orchestration requests for the dashboard.
+ * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
+ * @return the orchestration requests
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_get_orch_reqs/dashboard", method = RequestMethod.GET)
+ public List<Request> getOrchestrationRequestsForDashboard() throws Exception {
+
+ String methodName = "getOrchestrationRequestsForDashboard";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+
+ return msoBusinessLogic.getOrchestrationRequestsForDashboard();
+ }
+
+ /**
+ * Gets the Manual Tasks for the given request id.
+ *
+ * @param originalRequestId the id of the original request.
+ * @return the tasks
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_get_man_task/{originalRequestId}", method = RequestMethod.GET)
+ public List<Task> getManualTasksByRequestId(@PathVariable("originalRequestId") String originalRequestId) throws Exception {
+
+ String methodName = "getManualTasksByRequestId";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
+ }
+
+
+
+ /**
+ * Complete the manual task.
+ *
+ * @param taskId the id of the task to complete.
+ * @param requestDetails the body of the request.
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
+ public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId , @RequestBody RequestDetails requestDetails) throws Exception {
+
+ String methodName = "manualTaskComplete";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w = msoBusinessLogic.completeManualTask(requestDetails, taskId);
+ return new ResponseEntity<String>(w.getResponse(), HttpStatus.OK);
+ }
+
+ @RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> removeRelationshipFromServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
+ @RequestBody RequestDetails requestDetails) throws Exception {
+
+ String methodName = "removeRelationshipFromServiceInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w;
+ try {
+ w = msoBusinessLogic.removeRelationshipFromServiceInstance(requestDetails, serviceInstanceId);
+ } catch (Exception e){
+ LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
+ return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
+ }
+
+ @RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> addRelationshipToServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
+ @RequestBody RequestDetails requestDetails) throws Exception {
+
+ String methodName = "addRelationshipToServiceInstance";
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ MsoResponseWrapper w;
+ try {
+ w = msoBusinessLogic.addRelationshipToServiceInstance(requestDetails, serviceInstanceId);
+ } catch (Exception e){
+ LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
+ return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
+ }
+
+
+ /**
+ * Exception handler.
+ *
+ * @param e the e
+ * @param response the response
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @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);
+
+ response.setContentType("application/json; charset=UTF-8");
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+
+ ExceptionResponse exceptionResponse = new ExceptionResponse();
+ exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
+ exceptionResponse.setMessage(e.getMessage());
+
+ response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
+
+ response.flushBuffer();
+
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java b/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java
new file mode 100644
index 000000000..e57aab392
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/OperationalEnvironmentController.java
@@ -0,0 +1,354 @@
+package org.onap.vid.controller;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.MoreObjects;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.model.ExceptionResponse;
+import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.mso.MsoBusinessLogic;
+import org.onap.vid.mso.MsoResponseWrapper2;
+import org.onap.vid.mso.RestMsoImplementation;
+import org.onap.vid.mso.RestObject;
+import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
+import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
+import org.onap.vid.mso.rest.MsoRestClientNew;
+import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails;
+import org.onap.vid.mso.rest.RequestDetails;
+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;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.onap.vid.utils.Logging.getMethodCallerName;
+import static org.onap.vid.utils.Logging.getMethodName;
+import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
+
+@RestController
+@RequestMapping("operationalEnvironment")
+public class OperationalEnvironmentController extends RestrictedBaseController {
+
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(OperationalEnvironmentController.class);
+ private final RestMsoImplementation restMso;
+ private final MsoBusinessLogic msoBusinessLogic;
+
+ private static final Pattern RECOVERY_ACTION_MESSAGE_PATTERN = Pattern.compile("String value \'(.*)\': value not");
+
+
+ @Autowired
+ public OperationalEnvironmentController(MsoBusinessLogic msoBusinessLogic, MsoRestClientNew msoClientInterface) {
+ this.restMso = msoClientInterface;
+ this.msoBusinessLogic = msoBusinessLogic;
+ }
+
+ @RequestMapping(value = "/create", method = RequestMethod.POST)
+ public MsoResponseWrapper2 createOperationalEnvironment(HttpServletRequest request, @RequestBody OperationalEnvironmentCreateBody operationalEnvironment) throws Exception {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), operationalEnvironment);
+ String userId = ControllersUtils.extractUserId(request);
+ RequestDetailsWrapper<OperationEnvironmentRequestDetails> requestDetailsWrapper = msoBusinessLogic.convertParametersToRequestDetails(operationalEnvironment, userId);
+ String path = msoBusinessLogic.getOperationalEnvironmentCreationPath();
+ RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetailsWrapper, "",
+ path, RequestReferencesContainer.class);
+ debugEnd(msoResponse);
+ return new MsoResponseWrapper2<>(msoResponse);
+ }
+
+ @RequestMapping(value = "/activate", method = RequestMethod.POST)
+ public MsoResponseWrapper2 activate(HttpServletRequest request,
+ @RequestParam("operationalEnvironment") String operationalEnvironmentId,
+ @RequestBody OperationalEnvironmentActivateBody activateRequest) throws Exception {
+
+ verifyIsNotEmpty(operationalEnvironmentId, "operationalEnvironment");
+
+ //manifest is null in case of wrong manifest structure (deserialization failure of the manifest)
+ if (activateRequest.getManifest()==null || activateRequest.getManifest().getServiceModelList()==null) {
+ throw new BadManifestException("Manifest structure is wrong");
+ }
+
+ String userId = ControllersUtils.extractUserId(request);
+
+ OperationalEnvironmentActivateInfo activateInfo = new OperationalEnvironmentActivateInfo(activateRequest, userId, operationalEnvironmentId);
+ debugStart(activateInfo);
+
+ String path = msoBusinessLogic.getOperationalEnvironmentActivationPath(activateInfo);
+ RequestDetailsWrapper<RequestDetails> requestDetailsWrapper = msoBusinessLogic.createOperationalEnvironmentActivationRequestDetails(activateInfo);
+
+ RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetailsWrapper, "",
+ path, RequestReferencesContainer.class);
+
+ debugEnd(msoResponse);
+ return new MsoResponseWrapper2<>(msoResponse);
+ }
+
+ @RequestMapping(value = "/deactivate", method = RequestMethod.POST)
+ public MsoResponseWrapper2 deactivate(HttpServletRequest request,
+ @RequestParam("operationalEnvironment") String operationalEnvironmentId,
+ @RequestBody Map deactivationRequest) throws Exception {
+
+ verifyIsNotEmpty(operationalEnvironmentId, "operationalEnvironment");
+
+ String userId = ControllersUtils.extractUserId(request);
+
+ OperationalEnvironmentDeactivateInfo deactivateInfo = new OperationalEnvironmentDeactivateInfo(userId, operationalEnvironmentId);
+ debugStart(deactivateInfo);
+
+ String path = msoBusinessLogic.getOperationalEnvironmentDeactivationPath(deactivateInfo);
+ RequestDetailsWrapper<RequestDetails> requestDetailsWrapper = msoBusinessLogic.createOperationalEnvironmentDeactivationRequestDetails(deactivateInfo);
+
+ RestObject<RequestReferencesContainer> msoResponse = restMso.PostForObject(requestDetailsWrapper, "",
+ path, RequestReferencesContainer.class);
+
+ debugEnd(msoResponse);
+ return new MsoResponseWrapper2<>(msoResponse);
+ }
+
+ @RequestMapping(value = "/requestStatus", method = RequestMethod.GET)
+ public MsoResponseWrapper2 status(HttpServletRequest request, @RequestParam("requestId") String requestId) throws Exception {
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), requestId);
+
+ verifyIsNotEmpty(requestId, "requestId");
+ String path = msoBusinessLogic.getCloudResourcesRequestsStatusPath(requestId);
+
+ final RestObject<HashMap> msoResponse = restMso.GetForObject("", path, HashMap.class);
+
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), msoResponse);
+ return new MsoResponseWrapper2<>(msoResponse);
+ }
+
+ @ExceptionHandler(Exception.class)
+ @ResponseStatus(value=INTERNAL_SERVER_ERROR)
+ private ExceptionResponse exceptionHandler(Exception e) {
+ return ControllersUtils.handleException(e, LOGGER);
+ }
+
+ @ExceptionHandler({
+ org.springframework.web.bind.MissingServletRequestParameterException.class,
+ BadManifestException.class
+ })
+ @ResponseStatus(value = HttpStatus.BAD_REQUEST)
+ public ExceptionResponse clientDerivedExceptionAsBadRequest(Exception e) {
+ // same handler, different HTTP Code
+ return exceptionHandler(e);
+ }
+
+ @ExceptionHandler({
+ org.springframework.http.converter.HttpMessageNotReadableException.class,
+ })
+ @ResponseStatus(value = HttpStatus.BAD_REQUEST)
+ public ExceptionResponse handlingHttpMessageNotReadableException(Exception e) {
+ //in case of wrong value in manifest for RecoveryAction the message contains the class name.
+ //The wrong value is in also part of this messages
+ //within the pattern of: String value '<WRONG_VALUE>': value not
+ //so we use regex to find the wrong value
+ if (e.getMessage().contains(OperationalEnvironmentRecoveryAction.class.getName())) {
+ LOGGER.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodName(), ExceptionUtils.getMessage(e), e);
+ String message = "Wrong value for RecoveryAction in manifest. Allowed options are: "+OperationalEnvironmentRecoveryAction.options;
+
+ Matcher matcher = RECOVERY_ACTION_MESSAGE_PATTERN.matcher(e.getMessage());
+ if (matcher.find()) {
+ String wrongValue = matcher.group(1);
+ message = message+". Wrong value is: "+wrongValue;
+ }
+ return new ExceptionResponse(new BadManifestException(message));
+ }
+ return exceptionHandler(e);
+ }
+
+
+ public enum OperationalEnvironmentRecoveryAction {
+ abort,
+ retry,
+ skip;
+
+ public static final String options = Stream.of(OperationalEnvironmentRecoveryAction.values()).map(OperationalEnvironmentRecoveryAction::name).collect(Collectors.joining(", "));
+ }
+
+ public static class ActivateServiceModel {
+ private String serviceModelVersionId;
+ private OperationalEnvironmentRecoveryAction recoveryAction;
+
+ public ActivateServiceModel() {
+ }
+
+ public ActivateServiceModel(String serviceModelVersionId, OperationalEnvironmentRecoveryAction recoveryAction) {
+ this.serviceModelVersionId = serviceModelVersionId;
+ this.recoveryAction = recoveryAction;
+ }
+
+ public String getServiceModelVersionId() {
+ return serviceModelVersionId;
+ }
+
+ public void setServiceModelVersionId(String serviceModelVersionId) {
+ this.serviceModelVersionId = serviceModelVersionId;
+ }
+
+ public OperationalEnvironmentRecoveryAction getRecoveryAction() {
+ return recoveryAction;
+ }
+
+ public void setRecoveryAction(OperationalEnvironmentRecoveryAction recoveryAction) {
+ this.recoveryAction = recoveryAction;
+ }
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class OperationalEnvironmentManifest {
+
+
+ private List<ActivateServiceModel> serviceModelList;
+
+ public OperationalEnvironmentManifest() {
+ }
+
+ public OperationalEnvironmentManifest(List<ActivateServiceModel> serviceModelList) {
+ this.serviceModelList = serviceModelList;
+ }
+
+ public List<ActivateServiceModel> getServiceModelList() {
+ return serviceModelList;
+ }
+
+ public void setServiceModelList(List<ActivateServiceModel> serviceModelList) {
+ this.serviceModelList = serviceModelList;
+ }
+ }
+
+ public static class OperationalEnvironmentActivateBody {
+ private final String relatedInstanceId;
+ private final String relatedInstanceName;
+ private final String workloadContext;
+ private final OperationalEnvironmentManifest manifest;
+
+ public OperationalEnvironmentActivateBody(@JsonProperty(value = "relatedInstanceId", required = true) String relatedInstanceId,
+ @JsonProperty(value = "relatedInstanceName", required = true) String relatedInstanceName,
+ @JsonProperty(value = "workloadContext", required = true) String workloadContext,
+ @JsonProperty(value = "manifest", required = true) OperationalEnvironmentManifest manifest) {
+ this.relatedInstanceId = relatedInstanceId;
+ this.relatedInstanceName = relatedInstanceName;
+ this.workloadContext = workloadContext;
+ this.manifest = manifest;
+ }
+
+
+ public String getRelatedInstanceId() {
+ return relatedInstanceId;
+ }
+
+ public String getRelatedInstanceName() {
+ return relatedInstanceName;
+ }
+
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ public OperationalEnvironmentManifest getManifest() {
+ return manifest;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("relatedInstanceId", relatedInstanceId)
+ .add("relatedInstanceName", relatedInstanceName)
+ .add("workloadContext", workloadContext)
+ .add("manifest", manifest)
+ .toString();
+ }
+ }
+
+ public static class OperationalEnvironmentCreateBody {
+ private final String instanceName;
+ private final String ecompInstanceId;
+ private final String ecompInstanceName;
+ private final String operationalEnvironmentType;
+ private final String tenantContext;
+ private final String workloadContext;
+
+ public OperationalEnvironmentCreateBody(@JsonProperty(value = "instanceName", required = true) String instanceName,
+ @JsonProperty(value = "ecompInstanceId", required = true) String ecompInstanceId,
+ @JsonProperty(value = "ecompInstanceName", required = true) String ecompInstanceName,
+ @JsonProperty(value = "operationalEnvironmentType", required = true) String operationalEnvironmentType,
+ @JsonProperty(value = "tenantContext", required = true) String tenantContext,
+ @JsonProperty(value = "workloadContext", required = true) String workloadContext) {
+ this.instanceName = instanceName;
+ this.ecompInstanceId = ecompInstanceId;
+ this.ecompInstanceName = ecompInstanceName;
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ this.tenantContext = tenantContext;
+ this.workloadContext = workloadContext;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public String getEcompInstanceId() {
+ return ecompInstanceId;
+ }
+
+ public String getEcompInstanceName() {
+ return ecompInstanceName;
+ }
+
+ public String getOperationalEnvironmentType() {
+ return operationalEnvironmentType;
+ }
+
+ public String getTenantContext() {
+ return tenantContext;
+ }
+
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("instanceName", instanceName)
+ .add("ecompInstanceId", ecompInstanceId)
+ .add("ecompInstanceName", ecompInstanceName)
+ .add("operationalEnvironmentType", operationalEnvironmentType)
+ .add("tenantContext", tenantContext)
+ .add("workloadContext", workloadContext)
+ .toString();
+ }
+ }
+
+ private void debugEnd(RestObject<RequestReferencesContainer> msoResponse) {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodCallerName(), msoResponse);
+ }
+
+ private void debugStart(Object requestInfo) {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodCallerName(), requestInfo);
+ }
+
+ private void verifyIsNotEmpty(String fieldValue, String fieldName) throws MissingServletRequestParameterException {
+ if (StringUtils.isEmpty(fieldValue)) {
+ throw new MissingServletRequestParameterException(fieldName, "String");
+ }
+ }
+
+ public static class BadManifestException extends RuntimeException {
+ public BadManifestException(String message) {
+ super(message);
+ }
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/PolicyController.java b/vid-app-common/src/main/java/org/onap/vid/controller/PolicyController.java
new file mode 100644
index 000000000..4e9ec2539
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/PolicyController.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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.json.simple.JSONObject;
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.policy.*;
+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) throws Exception {
+
+ 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) throws Exception {
+ 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/controller/PropertyController.java b/vid-app-common/src/main/java/org/onap/vid/controller/PropertyController.java
new file mode 100644
index 000000000..2d282edb8
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/PropertyController.java
@@ -0,0 +1,132 @@
+/*-
+ * ============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.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.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;
+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;
+
+/**
+ * The Class PropertyController.
+ */
+@RestController
+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;
+
+
+ /**
+ * Welcome.
+ *
+ * @param request the request
+ * @return the model and view
+ */
+ @RequestMapping(value = {"/propertyhome" }, method = RequestMethod.GET)
+ public ModelAndView welcome(HttpServletRequest request) {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== PropertyController welcome start");
+ return new ModelAndView(getViewName());
+ }
+
+ /**
+ * Gets the property.
+ *
+ * @param name the name
+ * @param defaultvalue the defaultvalue
+ * @param request the request
+ * @return the property
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/get_property/{name}/{defaultvalue}", method = RequestMethod.GET)
+ public ResponseEntity<String> getProperty (@PathVariable("name") String name, @PathVariable("defaultvalue") String defaultvalue,
+ HttpServletRequest request) throws Exception {
+
+ String methodName = "getProperty";
+ ResponseEntity<String> resp = null;
+ String pvalue = null;
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+ // convert "_" to "." in the property name
+ if (name == null || name.length() == 0 ) {
+ return ( new ResponseEntity<String> (defaultvalue, HttpStatus.OK));
+ }
+ // convert "_" to "." in the property name
+ String propertyName = name.replace('_', '.');
+ pvalue = SystemProperties.getProperty(propertyName);
+ if ( ( pvalue == null ) || ( pvalue.length() == 0 ) ) {
+ pvalue = defaultvalue;
+ }
+ resp = new ResponseEntity<String>(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());
+ throw e;
+ }
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " returning " + pvalue);
+ return ( resp );
+ }
+
+ /**
+ * Gets the owning entity properties.
+ * @param request the request
+ * @return the property
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/category_parameter", method = RequestMethod.GET)
+ public ResponseEntity getCategoryParameter(HttpServletRequest request, @RequestParam(value="familyName", required = true) Family familyName) throws Exception {
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName());
+ try {
+ CategoryParametersResponse response = categoryParameterService.getCategoryParameters(familyName);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger, "end {}() => {}", getMethodName(), response);
+ return new ResponseEntity<>(response, HttpStatus.OK);
+ }
+ catch (Exception exception) {
+ LOGGER.error("failed to retrieve category parameter list from DB.", exception);
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java b/vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java
new file mode 100644
index 000000000..3e15153ac
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java
@@ -0,0 +1,31 @@
+package org.onap.vid.controller;
+
+import fj.test.Bool;
+import org.json.JSONObject;
+import org.openecomp.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.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PathVariable;
+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;
+
+@RestController
+public class RoleGeneratorController extends UnRestrictedBaseController {
+ @Autowired
+ private RoleGeneratorService roleGeneratorService;
+ public static final String GENERATE_ROLE_SCRIPT = "generateRoleScript";
+ @RequestMapping(value = GENERATE_ROLE_SCRIPT +"/{firstRun}", method = RequestMethod.GET )
+ public ResponseEntity<String> generateRoleScript (@PathVariable("firstRun") boolean firstRun) throws Exception {
+ ResponseEntity<String> response = null;
+ String query = roleGeneratorService.generateRoleScript(firstRun);
+ response = new ResponseEntity<String>(query, HttpStatus.OK);
+ return response;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/VidController.java b/vid-app-common/src/main/java/org/onap/vid/controller/VidController.java
new file mode 100644
index 000000000..c93d8027f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/VidController.java
@@ -0,0 +1,149 @@
+/*-
+ * ============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.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.asdc.beans.SecureServices;
+import org.onap.vid.exceptions.VidServiceUnavailableException;
+import org.onap.vid.model.ServiceModel;
+import org.onap.vid.roles.Role;
+import org.onap.vid.roles.RoleProvider;
+import org.onap.vid.services.AaiService;
+import org.onap.vid.services.VidService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+//import org.onap.vid.model.Service;
+
+@RestController
+public class VidController extends RestrictedBaseController {
+
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VidController.class);
+
+ private final VidService service;
+
+ @Autowired
+ public VidController(VidService vidService) throws SdcToscaParserException{
+
+ service = vidService;
+ }
+
+ @Autowired
+ private AaiService aaiService;
+
+ @Autowired
+ RoleProvider roleProvider;
+
+// /**
+// * Gets the services.
+// *
+// * @param request the request
+// * @return the services
+// * @throws VidServiceUnavailableException the vid service unavailable exception
+// */
+// @RequestMapping(value={"/rest/models/services"}, method = RequestMethod.GET)
+// public SecureServices getServices(HttpServletRequest request) throws VidServiceUnavailableException {
+// try {
+// AaiService aaiService = new AaiServiceImpl();
+// LOG.info("Start API for browse ASDC was called");
+// SecureServices secureServices = new SecureServices();
+// Map<String, String[]> requestParams = request.getParameterMap();
+// List<Role> roles = roleProvider.getUserRoles(request);
+// secureServices.setServices(aaiService.getServicesByDistributionStatus());
+// secureServices.setServices(service.getServices(requestParams));
+// secureServices.setReadOnly(roleProvider.userPermissionIsReadOnly(roles));
+// return secureServices;
+// } catch (AsdcCatalogException e) {
+// LOG.error("Failed to retrieve service definitions from SDC", e);
+// throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e);
+// } catch (Throwable t) {
+// LOG.debug("Unexpected error while retrieving service definitions from SDC: " + t.getMessage() + ":", t);
+// t.printStackTrace();
+// throw new VidServiceUnavailableException("Unexpected error while retrieving service definitions from SDC: " + t.getMessage(), t);
+// }
+// }
+
+ /**
+ * Gets the services.
+ *
+ * @param request the request
+ * @return the services
+ * @throws VidServiceUnavailableException the vid service unavailable exception
+ */
+ @RequestMapping(value={"/rest/models/services"}, method = RequestMethod.GET)
+ public SecureServices getServices(HttpServletRequest request) throws VidServiceUnavailableException {
+ try {
+ LOG.info("Start API for browse ASDC was called");
+ SecureServices secureServices = new SecureServices();
+ List<Role> roles = roleProvider.getUserRoles(request);
+ secureServices.setServices(aaiService.getServicesByDistributionStatus());
+ secureServices.setReadOnly(roleProvider.userPermissionIsReadOnly(roles));
+ return secureServices;
+ }
+ catch (Exception t) {
+ LOG.debug("Unexpected error while retrieving service definitions from A&AI: " + t.getMessage() + ":", t);
+ t.printStackTrace();
+ throw new VidServiceUnavailableException("Unexpected error while retrieving service definitions from A&AI: " + t.getMessage(), t);
+ }
+ }
+
+
+
+ /**
+ * Gets the services.
+ *
+ * @param uuid the uuid
+ * @return the services
+ * @throws VidServiceUnavailableException the vid service unavailable exception
+ */
+ @RequestMapping(value={"/rest/models/services/{uuid}"}, method = RequestMethod.GET)
+ public ServiceModel getServices(@PathVariable("uuid") String uuid, HttpServletRequest request) throws VidServiceUnavailableException {
+ try {
+ return service.getService(uuid);
+ } catch (AsdcCatalogException e) {
+ LOG.error("Failed to retrieve service definitions from SDC", e);
+ throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e);
+ }
+ }
+
+
+ /**
+ * Gets the services view.
+ *
+ * @param request the request
+ * @return the services view
+ * @throws VidServiceUnavailableException the vid service unavailable exception
+ */
+ @RequestMapping(value={"/serviceModels"}, method=RequestMethod.GET)
+ public ModelAndView getServicesView(HttpServletRequest request) throws VidServiceUnavailableException {
+ return new ModelAndView("serviceModels");
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/ViewLogController.java b/vid-app-common/src/main/java/org/onap/vid/controller/ViewLogController.java
new file mode 100644
index 000000000..4a87df10d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/ViewLogController.java
@@ -0,0 +1,65 @@
+/*-
+ * ============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.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+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.RestController;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+
+/**
+ * The Class ViewLogController.
+ */
+@RestController
+public class ViewLogController extends RestrictedBaseController{
+
+ /** The logger. */
+ private static final EELFLoggerDelegate LOGGER = EELFLoggerDelegate.getLogger(ViewLogController.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The servlet context. */
+ private @Autowired ServletContext servletContext;
+
+ /**
+ * Welcome.
+ *
+ * @param request the request
+ * @return the model and view
+ */
+ @RequestMapping(value = {"/viewlog" }, method = RequestMethod.GET)
+ public ModelAndView welcome(HttpServletRequest request) {
+
+ return new ModelAndView(getViewName());
+ }
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
new file mode 100644
index 000000000..2838e7f3c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
@@ -0,0 +1,123 @@
+package org.onap.vid.controller;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.io.IOUtils;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import org.onap.vid.aai.AaiClient;
+import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.asdc.AsdcClient;
+import org.onap.vid.asdc.local.LocalAsdcClient;
+import org.onap.vid.asdc.memory.InMemoryAsdcClient;
+import org.onap.vid.asdc.parser.ToscaParserImpl2;
+import org.onap.vid.asdc.rest.RestfulAsdcClient;
+import org.onap.vid.properties.AsdcClientConfiguration;
+import org.onap.vid.properties.AsdcClientConfiguration.AsdcClientType;
+import org.onap.vid.services.AaiService;
+import org.onap.vid.services.AaiServiceImpl;
+import org.onap.vid.services.VidService;
+import org.onap.vid.services.VidServiceImpl;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.net.ssl.SSLContext;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+
+@Configuration
+public class WebConfig {
+
+ /**
+ * Gets the object mapper.
+ *
+ * @return the object mapper
+ */
+ @Bean
+ public ObjectMapper getObjectMapper() {
+ return new ObjectMapper();
+ }
+
+
+
+
+ @Bean
+ public VidService vidService(AsdcClient asdcClient) {
+ return new VidServiceImpl(asdcClient);
+ }
+
+ @Bean
+ public AaiService getAaiService(){
+ return new AaiServiceImpl();
+ }
+
+ @Bean
+ public AaiClientInterface getAaiClientInterface(){
+ return new AaiClient();
+ }
+
+ @Bean
+ public AsdcClient asdcClient(AsdcClientConfiguration asdcClientConfig) throws IOException {
+ switch (asdcClientConfig.getAsdcClientType()) {
+ case IN_MEMORY:
+ final InputStream asdcCatalogFile = VidController.class.getClassLoader().getResourceAsStream("catalog.json");
+ final JSONTokener tokener = new JSONTokener(asdcCatalogFile);
+ final JSONObject catalog = new JSONObject(tokener);
+
+ return new InMemoryAsdcClient.Builder().catalog(catalog).build();
+ case REST:
+
+ final String protocol = asdcClientConfig.getAsdcClientProtocol();
+ final String host = asdcClientConfig.getAsdcClientHost();
+ final int port = asdcClientConfig.getAsdcClientPort();
+ final String auth = asdcClientConfig.getAsdcClientAuth();
+ Client cl = null;
+ if (protocol.equalsIgnoreCase("https")) {
+ try {
+ SSLContext ctx = SSLContext.getInstance("TLSv1.2");
+ ctx.init(null, null, null);
+ cl = ClientBuilder.newBuilder().sslContext(ctx).build();
+ } catch (NoSuchAlgorithmException n) {
+ throw new RuntimeException("SDC Client could not be instantiated due to unsupported protocol TLSv1.2", n);
+ } catch (KeyManagementException k) {
+ throw new RuntimeException("SDC Client could not be instantiated due to a key management exception", k);
+ }
+ } else {
+ cl = ClientBuilder.newBuilder().build();
+ }
+
+ try {
+ final URI uri = new URI(protocol + "://" + host + ":" + port + "/");
+ return new RestfulAsdcClient.Builder(cl, uri)
+ .auth(auth)
+ .build();
+ } catch (URISyntaxException e) {
+ throw new RuntimeException("SDC Client could not be instantiated due to a syntax error in the URI", e);
+ }
+
+ case LOCAL:
+
+ final InputStream asdcServicesFile = VidController.class.getClassLoader().getResourceAsStream("sdcservices.json");
+
+ final JSONTokener jsonTokener = new JSONTokener(IOUtils.toString(asdcServicesFile));
+ final JSONObject sdcServicesCatalog = new JSONObject(jsonTokener);
+
+ return new LocalAsdcClient.Builder().catalog(sdcServicesCatalog).build();
+
+ default:
+ throw new RuntimeException(asdcClientConfig.getAsdcClientType() + " is invalid; must be one of " + Arrays.toString(AsdcClientType.values()));
+ }
+ }
+
+ @Bean
+ public ToscaParserImpl2 getToscaParser() {
+ return new ToscaParserImpl2();
+ }
+
+}
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
new file mode 100644
index 000000000..a83fa281b
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java
@@ -0,0 +1,94 @@
+package org.onap.vid.controller.filter;
+
+
+import com.google.common.collect.ImmutableList;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.web.filter.GenericFilterBean;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.UUID;
+
+import static org.openecomp.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";
+
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException {
+
+ if (request instanceof HttpServletRequest) {
+ request = wrapIfNeeded(request);
+
+ if (response instanceof HttpServletResponse) {
+ final String actualRequestId = ((HttpServletRequest) request).getHeader(ECOMP_REQUEST_ID);
+ ((HttpServletResponse) response).addHeader(REQUEST_ID_RESPONSE_HEADER, actualRequestId);
+ }
+ }
+
+ chain.doFilter(request, response);
+ }
+
+ public static ServletRequest wrapIfNeeded(ServletRequest request) {
+ final HttpServletRequest httpRequest = (HttpServletRequest) request;
+ final String originalRequestId = httpRequest.getHeader(ECOMP_REQUEST_ID);
+
+ if (StringUtils.isEmpty(originalRequestId)) {
+ request = new PromiseEcompRequestIdRequestWrapper(httpRequest);
+ }
+
+ return request;
+ }
+
+ private static class PromiseEcompRequestIdRequestWrapper extends HttpServletRequestWrapper {
+
+ private final UUID requestId;
+
+ PromiseEcompRequestIdRequestWrapper(HttpServletRequest request) {
+ super(request);
+ requestId = UUID.randomUUID();
+ }
+
+ @Override
+ public String getHeader(String name) {
+ return isRequestIdHeaderName(name) ?
+ requestId.toString() : super.getHeader(name);
+ }
+
+ @Override
+ public Enumeration<String> getHeaders(String name) {
+ if (isRequestIdHeaderName(name)) {
+ return Collections.enumeration(Collections.singleton(requestId.toString()));
+ } else {
+ return super.getHeaders(name);
+ }
+ }
+
+ @Override
+ public Enumeration<String> getHeaderNames() {
+ return Collections.enumeration(ImmutableList.<String>builder()
+ .add(ECOMP_REQUEST_ID)
+ .addAll(Collections.list(super.getHeaderNames()))
+ .build());
+ }
+
+ private boolean isRequestIdHeaderName(String name) {
+ return ECOMP_REQUEST_ID.equalsIgnoreCase(name);
+ }
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/filter/TempFilterForCORS.java b/vid-app-common/src/main/java/org/onap/vid/controller/filter/TempFilterForCORS.java
new file mode 100644
index 000000000..02dcde095
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/filter/TempFilterForCORS.java
@@ -0,0 +1,48 @@
+package org.onap.vid.controller.filter;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.springframework.web.filter.GenericFilterBean;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@WebFilter(urlPatterns = "/*")
+public class TempFilterForCORS extends GenericFilterBean {
+
+ private static final String ENV_MODE = "env.mode";
+ private Boolean devMode = null;
+
+ //dev mode is initialized here since @WebFilter doesn't support @Autowired
+ //So we are sure that SystemProperties bean was initialed only after the first call to doFilter
+ private boolean isDevMode() {
+ if (devMode!=null) {
+ return devMode;
+ }
+ else {
+ if (!SystemProperties.containsProperty(ENV_MODE)) {
+ devMode = Boolean.FALSE;
+ return devMode;
+ }
+
+ String envMode = SystemProperties.getProperty(ENV_MODE);
+ devMode = StringUtils.equalsIgnoreCase(envMode, "dev") ;
+ }
+ return devMode;
+ }
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+
+ if (isDevMode() && response instanceof HttpServletResponse) {
+ ((HttpServletResponse) response).addHeader("Access-Control-Allow-Origin", "http://localhost:3000");
+ ((HttpServletResponse) response).addHeader("Access-Control-Allow-Credentials", "true");
+ }
+ chain.doFilter(request, response);
+ }
+}
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
new file mode 100644
index 000000000..29e7a4d7d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAaiController.java
@@ -0,0 +1,87 @@
+/*-
+ * ============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.test;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.vid.model.ExceptionResponse;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * The Class TestAaiController.
+ */
+@RestController
+@RequestMapping("testaai")
+public class TestAaiController extends RestrictedBaseController {
+
+ /**
+ * Gets the subscription service type list.
+ *
+ * @param globalCustomerId the global customer id
+ * @param request the request
+ * @return the subscription service type list
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/getSubscriptionServiceTypeList/{globalCustomerId}", method = RequestMethod.GET)
+ public String getSubscriptionServiceTypeList(@PathVariable("globalCustomerId") String globalCustomerId, HttpServletRequest request)
+ throws Exception {
+
+ System.err.println("GET SUBSCRIPTION SERVICE TYPE LIST: globalCustomerId: " + globalCustomerId);
+
+ return "[\"vMOG\", \"sevice type 2\", \"sevice type 3\", \"sevice type 4\"]";
+ }
+
+ /**
+ * Exception.
+ *
+ * @param e the e
+ * @param response the response
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @ExceptionHandler(Exception.class)
+ private void exception(Exception e, HttpServletResponse response) throws IOException {
+
+ /*
+ * This logging step should preferably be replaced with an appropriate
+ * logging method consistent whatever logging mechanism the rest of the
+ * application code uses.
+ */
+
+ e.printStackTrace(System.err);
+
+ response.setContentType("application/json; charset=UTF-8");
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+
+ ExceptionResponse exceptionResponse = new ExceptionResponse();
+ exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
+ exceptionResponse.setMessage(e.getMessage());
+
+ response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
+
+ response.flushBuffer();
+
+ }
+
+}
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
new file mode 100644
index 000000000..2b289b91a
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestAsdcController.java
@@ -0,0 +1,106 @@
+/*-
+ * ============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.test;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.vid.model.ExceptionResponse;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * The Class TestAsdcController.
+ */
+@RestController
+@RequestMapping("testasdc")
+public class TestAsdcController extends RestrictedBaseController {
+
+ /**
+ * Gets the model.
+ *
+ * @param modelId the model id
+ * @param request the request
+ * @return the model
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/getModel/{modelId}", method = RequestMethod.GET)
+ public String getModel(@PathVariable("modelId") String modelId, HttpServletRequest request) throws Exception {
+
+ System.err.println("SDC: GET MODEL: modelId: " + modelId);
+
+ // @formatter:off
+ return
+ "{" +
+ "\"uuid\": \"5be686dc-fdca-4d54-8548-5d0ed23e962b\"," +
+ "\"invariantUUID\": \"e5962da9-fe4f-433a-bc99-b43e0d88a9a1\"," +
+ "\"name\": \"DE220127\"," +
+ "\"version\": \"0.1\"," +
+ "\"inputs\": {" +
+ "\"defaultGateway\": {" +
+ "\"type\": \"String\"," +
+ "\"default\": \"192.168.1.1\"," +
+ "\"description\": \"Router default gateway - use any valid IPv4 address\"" +
+ "}," +
+ "\"subnetMask\": {" +
+ "\"type\": \"String\"," +
+ "\"default\": \"255.255.255.0\"," +
+ "\"description\": \"Router subnet mask - example (255.255.255.0)\"" +
+ "}" +
+ "}" +
+ "}";
+ // @formatter:on
+ }
+
+ /**
+ * Exception.
+ *
+ * @param e the e
+ * @param response the response
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @ExceptionHandler(Exception.class)
+ private void exception(Exception e, HttpServletResponse response) throws IOException {
+
+ /*
+ * This logging step should preferably be replaced with an appropriate
+ * logging method consistent whatever logging mechanism the rest of the
+ * application code uses.
+ */
+
+ e.printStackTrace(System.err);
+
+ response.setContentType("application/json; charset=UTF-8");
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+
+ ExceptionResponse exceptionResponse = new ExceptionResponse();
+ exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
+ exceptionResponse.setMessage(e.getMessage());
+
+ response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
+
+ response.flushBuffer();
+
+ }
+
+}
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
new file mode 100644
index 000000000..9d6a3de9c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestMsoController.java
@@ -0,0 +1,723 @@
+/*-
+ * ============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.test;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.vid.model.ExceptionResponse;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.stream.Collectors;
+
+/*
+ * The "TestMsoController" class is primarily designed to help test "msoCommitController.js"
+ *
+ * This class expects and receives JSON data in the same format as expected
+ * in the "real" application version of this code. However, string versions of JSON are
+ * maintained internally here instead of marshalled / unmarshalled JSON objects.
+ * The primary reasons for this were to encapsulate all the test code in this single file and
+ * minimize the time required to support initial test cases.
+ *
+ * The non-test equivalent of this controller could alternatively incorporate POJO objects
+ * instead of strings. However, the same data format sent to / received from the browser
+ * JavaScript code would still be expected.
+ *
+ * Two specific mechanisms used in this test class may be useful to the application version:
+ *
+ * 1) The use of "{variable}" elements in @RequestMappings along with the corresponding
+ * @PathVariable declarations.
+ *
+ * 2) The use of @ExceptionHandler for general purpose exception handler.
+ * (See @ExceptionHandler comments)
+ *
+ * This class is intended to be used in either:
+ *
+ * A) Eclipse environments
+ * OR
+ * B) Linux environments with ONLY a single user running tests.
+ * The "quick and dirty" error simulation approach used here makes use of static states for some
+ * scenarios. Thus multiple users simultaneously testing in Linux environments
+ * may have contention issues.
+ */
+
+/**
+ * The Class TestMsoController.
+ */
+@RestController
+@RequestMapping("testmso")
+public class TestMsoController extends RestrictedBaseController {
+
+ /*
+ * Artificial delay (in milliseconds) added before responding to create /
+ * delete requests
+ */
+
+ /** The Constant TEST_DELAY_SHORT_MSEC. */
+ private final static int TEST_DELAY_SHORT_MSEC = 1000;
+
+ /*
+ * Long delay to simulate non-responsive server test
+ */
+
+ /** The Constant TEST_DELAY_LONG_MSEC. */
+ private final static int TEST_DELAY_LONG_MSEC = 15000;
+
+ /*
+ * Default number of polls expected before transaction complete.
+ */
+
+ /** The Constant MAXIMUM_POLLS_DEFAULT. */
+ private final static int MAXIMUM_POLLS_DEFAULT = 4;
+
+ /*
+ * Number of polls to simulate "maximum polls exceeded" test.
+ */
+
+ /** The Constant MAXIMUM_POLLS_LARGE. */
+ private final static int MAXIMUM_POLLS_LARGE = 10;
+
+ /*
+ * Simulated error types. The GUI front end is expected to set these values
+ * in the "modelName" field of the "mso_create_svc_instance" request.
+ */
+
+ /** The Constant ERROR_POLICY_EXCEPTION. */
+ private final static String ERROR_POLICY_EXCEPTION = "ERROR_POLICY_EXCEPTION";
+
+ /** The Constant ERROR_SERVICE_EXCEPTION. */
+ private final static String ERROR_SERVICE_EXCEPTION = "ERROR_SERVICE_EXCEPTION";
+
+ /** The Constant ERROR_POLL_FAILURE. */
+ private final static String ERROR_POLL_FAILURE = "ERROR_POLL_FAILURE";
+
+ /** The Constant ERROR_INVALID_FIELD_INITIAL. */
+ private final static String ERROR_INVALID_FIELD_INITIAL = "ERROR_INVALID_FIELD_INITIAL";
+
+ /** The Constant ERROR_INVALID_FIELD_POLL. */
+ private final static String ERROR_INVALID_FIELD_POLL = "ERROR_INVALID_FIELD_POLL";
+
+ /** The Constant ERROR_GENERAL_SERVER_EXCEPTION. */
+ private final static String ERROR_GENERAL_SERVER_EXCEPTION = "ERROR_GENERAL_SERVER_EXCEPTION";
+
+ /** The Constant ERROR_MAX_POLLS. */
+ private final static String ERROR_MAX_POLLS = "ERROR_MAX_POLLS";
+
+ /** The Constant ERROR_SERVER_TIMEOUT_INITIAL. */
+ private final static String ERROR_SERVER_TIMEOUT_INITIAL = "ERROR_SERVER_TIMEOUT_INITIAL";
+
+ /** The Constant ERROR_SERVER_TIMEOUT_POLL. */
+ private final static String ERROR_SERVER_TIMEOUT_POLL = "ERROR_SERVER_TIMEOUT_POLL";
+
+ /** The simulated error. */
+ private String simulatedError = "";
+
+ /** The maximum polls. */
+ private int maximumPolls = 0;
+
+ /** The attempt count. */
+ private int attemptCount = 0;
+
+ /**
+ * Creates the svc instance.
+ *
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
+ public ResponseEntity<String> createSvcInstance(HttpServletRequest request) throws Exception {
+ readAndLogRequest("CREATE SERVICE INSTANCE", request);
+ Thread.sleep(TEST_DELAY_SHORT_MSEC);
+ maximumPolls = MAXIMUM_POLLS_DEFAULT; // Simulates MSO polling behavior
+ attemptCount = 0;
+
+ /*
+ * This block of code simulates various errors and would NOT be expected
+ * in a non-test method
+ */
+ System.err.println("simulatedError: " + simulatedError);
+
+ if (simulatedError.equals(ERROR_POLICY_EXCEPTION)) {
+ return new ResponseEntity<String>(policyExceptionResponse, HttpStatus.OK);
+ }
+ if (simulatedError.equals(ERROR_SERVICE_EXCEPTION)) {
+ return new ResponseEntity<String>(serviceExceptionResponse, HttpStatus.OK);
+ }
+ if (simulatedError.equals(ERROR_INVALID_FIELD_INITIAL)) {
+ /*
+ * Force invalid response field name. Return
+ * "XXXXXrequestReferences" instead of "requestReferences"
+ */
+ return new ResponseEntity<String>(acceptResponse.replace("requestReferences", "XXXXXrequestReferences"),
+ HttpStatus.OK);
+ }
+
+ if (simulatedError.equals(ERROR_GENERAL_SERVER_EXCEPTION)) {
+ throw new IOException("an example of an IO exception");
+ }
+
+ if (simulatedError.equals(ERROR_SERVER_TIMEOUT_INITIAL)) {
+ Thread.sleep(TEST_DELAY_LONG_MSEC);
+ }
+
+ if (simulatedError.equals(ERROR_MAX_POLLS)) {
+ maximumPolls = MAXIMUM_POLLS_LARGE;
+ }
+
+ /*
+ * End of block of simulated error code.
+ */
+
+ return new ResponseEntity<String>(acceptResponse, HttpStatus.OK);
+ }
+
+ /**
+ * Delete svc instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ HttpServletRequest request) throws Exception {
+ readAndLogRequest("DELETE SERVICE INSTANCE: serviceInstanceId: " + serviceInstanceId, request);
+ Thread.sleep(TEST_DELAY_SHORT_MSEC);
+ maximumPolls = MAXIMUM_POLLS_DEFAULT; // Simulates MSO polling behavior
+ attemptCount = 0;
+ return new ResponseEntity<String>(acceptResponse, HttpStatus.OK);
+ }
+
+ /**
+ * Creates the vnf instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_create_vnf_instance/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> createVnfInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ HttpServletRequest request) throws Exception {
+ readAndLogRequest("CREATE VNF INSTANCE: serviceInstanceId: " + serviceInstanceId, request);
+ Thread.sleep(TEST_DELAY_SHORT_MSEC);
+ maximumPolls = MAXIMUM_POLLS_DEFAULT; // Simulates MSO polling behavior
+ attemptCount = 0;
+ return new ResponseEntity<String>(acceptResponse, HttpStatus.OK);
+ }
+
+ /**
+ * Delete vnf instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> deleteVnfInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request) throws Exception {
+ readAndLogRequest(
+ "DELETE VNF INSTANCE: serviceInstanceId: " + serviceInstanceId + " vnfInstanceId: " + vnfInstanceId,
+ request);
+ Thread.sleep(TEST_DELAY_SHORT_MSEC);
+ maximumPolls = MAXIMUM_POLLS_DEFAULT; // Simulates MSO polling behavior
+ attemptCount = 0;
+ return new ResponseEntity<String>(acceptResponse, HttpStatus.OK);
+ }
+
+ /**
+ * Creates the vf module instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ // /serviceInstances/v2/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-ff1b-adb2-eb6b9e5460ff/vfModules
+ @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) throws Exception {
+ readAndLogRequest("CREATE VF MODULE INSTANCE: serviceInstanceId: " + serviceInstanceId + " vnfInstanceId: "
+ + vnfInstanceId, request);
+ Thread.sleep(TEST_DELAY_SHORT_MSEC);
+ maximumPolls = MAXIMUM_POLLS_DEFAULT; // Simulates MSO polling behavior
+ attemptCount = 0;
+ return new ResponseEntity<String>(acceptResponse, HttpStatus.OK);
+ }
+
+ /**
+ * Delete vf module instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param vfModuleInstanceId the vf module instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ // /serviceInstances/v2/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-ff1b-adb2-eb6b9e5460ff/vfModules/ff305d54-75b4-ff1b-bdb2-eb6b9e5460ff
+ @RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> deleteVfModuleInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("vnfInstanceId") String vnfInstanceId,
+ @PathVariable("vfModuleInstanceId") String vfModuleInstanceId, HttpServletRequest request)
+ throws Exception {
+ readAndLogRequest("DELETE VF MODULE INSTANCE: serviceInstanceId: " + serviceInstanceId + " vnfInstanceId: "
+ + vnfInstanceId + " vfModuleInstanceId: " + vfModuleInstanceId, request);
+ Thread.sleep(TEST_DELAY_SHORT_MSEC);
+ maximumPolls = MAXIMUM_POLLS_DEFAULT; // Simulates MSO polling behavior
+ attemptCount = 0;
+ return new ResponseEntity<String>(acceptResponse, HttpStatus.OK);
+ }
+
+ // POST
+ /**
+ * Creates the volume group instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ // /serviceInstances/v2/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups
+ @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) throws Exception {
+ readAndLogRequest("CREATE VOLUME GROUP INSTANCE: seviceInstanceId: " + serviceInstanceId + " vnfInstanceId: "
+ + vnfInstanceId, request);
+ Thread.sleep(TEST_DELAY_SHORT_MSEC);
+ maximumPolls = MAXIMUM_POLLS_DEFAULT; // Simulates MSO polling behavior
+ attemptCount = 0;
+ return new ResponseEntity<String>(acceptResponse, HttpStatus.OK);
+ }
+
+ /**
+ * Delete volume group instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param vnfInstanceId the vnf instance id
+ * @param volumeGroupInstanceId the volume group instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ // /serviceInstances/v2/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-ff1b-cdb2-eb6b9e5460ff
+ @RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> deleteVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("vnfInstanceId") String vnfInstanceId,
+ @PathVariable("volumeGroupInstanceId") String volumeGroupInstanceId, HttpServletRequest request)
+ throws Exception {
+ readAndLogRequest("DELETE NW INSTANCE: serviceInstanceId: " + serviceInstanceId + " vnfInstanceId: "
+ + vnfInstanceId + " volumeGroupInstanceId: " + volumeGroupInstanceId, request);
+ Thread.sleep(TEST_DELAY_SHORT_MSEC);
+ maximumPolls = MAXIMUM_POLLS_DEFAULT; // Simulates MSO polling behavior
+ attemptCount = 0;
+ return new ResponseEntity<String>(acceptResponse, HttpStatus.OK);
+ }
+
+ /**
+ * Creates the nw instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_create_nw_instance/{serviceInstanceId}", method = RequestMethod.POST)
+ public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ HttpServletRequest request) throws Exception {
+ readAndLogRequest("CREATE NW INSTANCE: serviceInstanceId: " + serviceInstanceId, request);
+ Thread.sleep(TEST_DELAY_SHORT_MSEC);
+ maximumPolls = MAXIMUM_POLLS_DEFAULT; // Simulates MSO polling behavior
+ attemptCount = 0;
+ return new ResponseEntity<String>(acceptResponse, HttpStatus.OK);
+ }
+
+ /**
+ * Delete nw instance.
+ *
+ * @param serviceInstanceId the service instance id
+ * @param networkInstanceId the network instance id
+ * @param request the request
+ * @return the response entity
+ * @throws Exception the exception
+ */
+ @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) throws Exception {
+ readAndLogRequest("DELETE NW INSTANCE: serviceInstanceId: " + serviceInstanceId + " networkInstanceId: "
+ + networkInstanceId, request);
+ Thread.sleep(TEST_DELAY_SHORT_MSEC);
+ maximumPolls = MAXIMUM_POLLS_DEFAULT; // Simulates MSO polling behavior
+ attemptCount = 0;
+ return new ResponseEntity<String>(acceptResponse, HttpStatus.OK);
+ }
+
+ /**
+ * Gets the orchestration request.
+ *
+ * @param requestId the request id
+ * @param request the request
+ * @return the orchestration request
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
+ public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
+ HttpServletRequest request) throws Exception {
+
+ System.err.println("GET ORCHESTRATION REQUEST: requestId: " + requestId);
+
+ /*
+ * This block of code simulates various errors and would NOT be expected
+ * in a non-test method
+ */
+
+ if (simulatedError.equals(ERROR_INVALID_FIELD_POLL)) {
+ /*
+ * Force invalid response field name. Return "XXXXXrequestStatus"
+ * instead of "requestStatus"
+ */
+ return new ResponseEntity<String>(inProgressResponse.replace("requestStatus", "XXXXXrequestStatus"),
+ HttpStatus.OK);
+ }
+
+ if (simulatedError.equals(ERROR_POLL_FAILURE)) {
+ /*
+ * Force status field with "Failure"
+ */
+ return new ResponseEntity<String>(inProgressResponse.replace("InProgress", "Failure"), HttpStatus.OK);
+ }
+
+ if (simulatedError.equals(ERROR_SERVER_TIMEOUT_POLL)) {
+ Thread.sleep(TEST_DELAY_LONG_MSEC);
+ }
+
+ /*
+ * End of block of simulated error code.
+ */
+
+ /*
+ * This logic simulates how MSO might behave ... i.e. return different
+ * results depending on the value of 'maximumPolls'.
+ *
+ */
+ int percentProgress = (++attemptCount * 100) / maximumPolls;
+
+ System.err.println("attempts: " + attemptCount + " max: " + maximumPolls + " percent: " + percentProgress);
+
+ String response = inProgressResponse.replace("\"50\"", "\"" + Integer.toString(percentProgress) + "\"");
+
+ if (attemptCount < maximumPolls) {
+ if (attemptCount > 1) {
+ response = response.replace("vLan setup", "setup step " + Integer.toString(attemptCount));
+ }
+ return new ResponseEntity<String>(response, HttpStatus.OK);
+ } else {
+ return new ResponseEntity<String>(
+ response.replace("InProgress", "Complete").replace("vLan setup complete", ""), HttpStatus.OK);
+ }
+ }
+
+ /**
+ * Gets the orchestration requests.
+ *
+ * @param filterString the filter string
+ * @param request the request
+ * @return the orchestration requests
+ * @throws Exception the exception
+ */
+ @RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
+ public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
+ HttpServletRequest request) throws Exception {
+
+ System.err.println("GET ORCHESTRATION REQUESTS: filterString: " + filterString);
+
+ return new ResponseEntity<String>(getOrchestrationRequestsResponse, HttpStatus.OK);
+
+ }
+
+ /*
+ * General purpose exception handler that could be used in application code.
+ *
+ * The method returns exceptions as error code 500. Both the exception type
+ * and message are written as a JSON object.
+ *
+ * See the following references:
+ *
+ * 1) The ExceptionResponse POJO.
+ *
+ * 2) The "getHttpErrorMessage" function in "utilityService.js" - an example
+ * of how the browser JavaScript code can interpret this response.
+ */
+
+ /**
+ * Exception.
+ *
+ * @param e the e
+ * @param response the response
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @ExceptionHandler(Exception.class)
+ private void exception(Exception e, HttpServletResponse response) throws IOException {
+
+ /*
+ * This logging step should preferably be replaced with an appropriate
+ * logging method consistent whatever logging mechanism the rest of the
+ * application code uses.
+ */
+
+ e.printStackTrace(System.err);
+
+ response.setContentType("application/json; charset=UTF-8");
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+
+ ExceptionResponse exceptionResponse = new ExceptionResponse();
+ exceptionResponse.setException(e.getClass().toString().replaceFirst("^.*\\.", ""));
+ exceptionResponse.setMessage(e.getMessage());
+
+ response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
+
+ response.flushBuffer();
+
+ }
+
+ /*
+ * 'readAndLogRequest' only intended to be used for testing.
+ *
+ * The method reads JSON from the input stream and thus prevents other
+ * mechanisms from reading the input.
+ */
+
+ /**
+ * Read and log request.
+ *
+ * @param label the label
+ * @param request the request
+ * @throws Exception the exception
+ */
+ private void readAndLogRequest(String label, HttpServletRequest request) throws Exception {
+ String input = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
+
+ ObjectMapper mapper = new ObjectMapper();
+ Object json = mapper.readValue(input, Object.class);
+
+ System.err.println(label + "\n" + mapper.writerWithDefaultPrettyPrinter().writeValueAsString(json));
+
+ /*
+ * Only needed for error simulation ...
+ */
+ if (input.matches("^.*modelName.*$")) {
+ simulatedError = input.replaceAll("^.*\"modelName\":\"", "").replaceAll("\".*$", "");
+ }
+ }
+
+ /*
+ * Various test responses:
+ */
+
+ // @formatter:off
+
+ /** The accept response. */
+ /*
+ * Sample responses to initial create / delete transaction
+ */
+ private String acceptResponse =
+ "{" +
+ " \"status\": 202," +
+ " \"entity\": {" +
+ " \"requestReferences\": {" +
+ " \"instanceId\": \"bc305d54-75b4-431b-adb2-eb6b9e546014\"," +
+ " \"requestId\": \"rq1234d1-5a33-55df-13ab-12abad84e331\"" +
+ " }" +
+ " }" +
+ "}";
+
+ /** The policy exception response. */
+ private String policyExceptionResponse =
+ "{" +
+ " \"status\": 400," +
+ " \"entity\": { " +
+ " \"requestError\": {" +
+ " \"policyException\": {" +
+ " \"messageId\": \"POL9003\"," +
+ " \"text\": \"Message content size exceeds the allowable limit\"" +
+ " }" +
+ " }" +
+ " }" +
+ "}";
+
+ /** The service exception response. */
+ private String serviceExceptionResponse =
+ "{" +
+ " \"status\": 400," +
+ " \"entity\": { " +
+ " \"requestError\": {" +
+ " \"serviceException\": {" +
+ " \"messageId\": \"SVC2000\"," +
+ " \"text\": \"Missing Parameter: %1. Error code is %2\"," +
+ " \"variables\": [" +
+ " \"severity\"," +
+ " \"400\"" +
+ " ]" +
+ " }" +
+ " }" +
+ " }" +
+ "}" +
+ "";
+
+ /** The in progress response. */
+ /*
+ * Sample response to subsequent getOrchestrationRequest
+ */
+ private String inProgressResponse =
+ "{" +
+ " \"status\": 200," +
+ " \"entity\": {" +
+ " \"request\": {" +
+ " \"requestId\": \"rq1234d1-5a33-55df-13ab-12abad84e333\"," +
+ " \"startTime\": \"Thu, 04 Jun 2009 02:51:59 GMT\"," +
+ " \"instanceIds\": {" +
+ " \"serviceInstanceId\": \"bc305d54-75b4-431b-adb2-eb6b9e546014\"" +
+ " }," +
+ " \"requestScope\": \"service\"," +
+ " \"requestType\": \"createInstance\"," +
+ " \"requestDetails\": {" +
+ " \"modelInfo\": {" +
+ " \"modelType\": \"service\"," +
+ " \"modelId\": \"sn5256d1-5a33-55df-13ab-12abad84e764\"," +
+ " \"modelNameVersionId\": \"ab6478e4-ea33-3346-ac12-ab121484a333\"," +
+ " \"modelName\": \"WanBonding\"," +
+ " \"modelVersion\": \"1\"" +
+ " }," +
+ " \"subscriberInfo\": {" +
+ " \"globalSubscriberId\": \"C12345\"," +
+ " \"subscriberName\": \"General Electric Division 12\"" +
+ " }," +
+ " \"requestParameters\": {" +
+ " \"vpnId\": \"1a2b3c4d5e6f\"," +
+ " \"productName\": \"Trinity\"," +
+ " \"customerId\": \"icore9883749\"" +
+ " }" +
+ " }," +
+ " \"requestStatus\": {" +
+ " \"timestamp\": \"Thu, 04 Jun 2009 02:53:39 GMT\"," +
+ " \"requestState\": \"InProgress\"," +
+ " \"statusMessage\": \"vLan setup complete\"," +
+ " \"percentProgress\": \"50\"" +
+ " }" +
+ " }" +
+ " }" +
+ "}";
+
+ /*
+ * Sample response to subsequent getOrchestrationRequests
+ */
+
+ /** The get orchestration requests response. */
+ private String getOrchestrationRequestsResponse =
+ "{" +
+ " \"status\": 200," +
+ " \"entity\": {" +
+ " \"requestList\": [" +
+ " {" +
+ " \"request\": {" +
+ " \"requestId\": \"rq1234d1-5a33-55df-13ab-12abad84e333\"," +
+ " \"startTime\": \"Thu, 04 Jun 2009 02:51:59 GMT\"," +
+ " \"finishTime\": \"Thu, 04 Jun 2009 02:55:59 GMT\"," +
+ " \"instanceReferences\": {" +
+ " \"serviceInstanceId\": \"bc305d54-75b4-431b-adb2-eb6b9e546014\"" +
+ " }," +
+ " \"requestScope\": \"service\"," +
+ " \"requestType\": \"createInstance\"," +
+ " \"requestDetails\": {" +
+ " \"modelInfo\": {" +
+ " \"modelType\": \"service\"," +
+ " \"modelId\": \"sn5256d1-5a33-55df-13ab-12abad84e764\"," +
+ " \"modelNameVersionId\": \"ab6478e4-ea33-3346-ac12-ab121484a333\"," +
+ " \"modelName\": \"WanBonding\"," +
+ " \"modelVersion\": \"1\"" +
+ " }," +
+ " \"subscriberInfo\": {" +
+ " \"globalSubscriberId\": \"C12345\"," +
+ " \"subscriberName\": \"General Electric Division 12\"" +
+ " }," +
+ " \"requestParameters\": {" +
+ " \"vpnId\": \"1a2b3c4d5e6f\"," +
+ " \"productName\": \"Trinity\"," +
+ " \"customerId\": \"icore9883749\"" +
+ " }" +
+ " }," +
+ " \"requestStatus\": {" +
+ " \"timestamp\": \"Thu, 04 Jun 2009 02:54:49 GMT\"," +
+ " \"requestState\": \"complete\"," +
+ " \"statusMessage\": \"Resource Created\"," +
+ " \"percentProgress\": \"100\"" +
+ " }" +
+ " }" +
+ " }," +
+ " {" +
+ " \"request\": {" +
+ " \"requestId\": \"rq1234d1-5a33-55df-13ab-12abad84e334\"," +
+ " \"startTime\": \"Thu, 04 Jun 2009 03:52:59 GMT\"," +
+ " \"instanceReferences\": {" +
+ " \"serviceInstanceId\": \"bc305d54-75b4-431b-adb2-eb6b9e546014\"" +
+ " }," +
+ " \"requestScope\": \"service\"," +
+ " \"requestType\": \"updateInstance\"," +
+ " \"requestDetails\": {" +
+ " \"modelInfo\": {" +
+ " \"modelType\": \"service\"," +
+ " \"modelId\": \"sn5256d1-5a33-55df-13ab-12abad84e764\"," +
+ " \"modelNameVersionId\": \"ab6478e4-ea33-3346-ac12-ab121484a333\"," +
+ " \"modelName\": \"WanBonding\"," +
+ " \"modelVersion\": \"1\"" +
+ " }," +
+ " \"subscriberInfo\": {" +
+ " \"globalSubscriberId\": \"C12345\"," +
+ " \"subscriberName\": \"General Electric Division 12\"" +
+ " }," +
+ " \"requestParameters\": {" +
+ " \"vpnId\": \"1a2b3c4d5e70\"," +
+ " \"productName\": \"Trinity\"," +
+ " \"customerId\": \"icore9883749\"" +
+ " }" +
+ " }," +
+ " \"requestStatus\": {" +
+ " \"timestamp\": \"Thu, 04 Jun 2009 03:53:39 GMT\"," +
+ " \"requestState\": \"InProgress\"," +
+ " \"statusMessage\": \"vLan setup complete\"," +
+ " \"percentProgress\": \"50\"" +
+ " }" +
+ " }" +
+ " }" +
+ " ]" +
+ " }" +
+ "}";
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/test/TestPageController.java b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestPageController.java
new file mode 100644
index 000000000..48ccdf8d8
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/test/TestPageController.java
@@ -0,0 +1,55 @@
+/*-
+ * ============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.test;
+
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.servlet.ModelAndView;
+
+/**
+ * The Class TestPageController.
+ */
+@Controller
+public class TestPageController extends RestrictedBaseController {
+
+ /**
+ * Test mso page.
+ *
+ * @return the model and view
+ */
+ @RequestMapping(value = { "testMso.htm" }, method = RequestMethod.GET)
+ public ModelAndView testMsoPage() {
+ return new ModelAndView(getViewName());
+ }
+
+ /**
+ * Test view edit page.
+ *
+ * @return the model and view
+ */
+ @RequestMapping(value = { "testViewEdit" }, method = RequestMethod.GET)
+ public ModelAndView testViewEditPage() {
+ return new ModelAndView(getViewName());
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java b/vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java
new file mode 100644
index 000000000..c27d17e1e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/dao/FnAppDoaImpl.java
@@ -0,0 +1,112 @@
+/*-
+ * ============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.dao;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
+
+public class FnAppDoaImpl {
+
+ /** The logger. */
+ static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnAppDoaImpl.class);
+
+ public int getProfileCount(String driver, String URL, String username, String password) {
+ Connection dbc = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ String q = null;
+ int count = 0;
+ try {
+ dbc = getConnection(driver,URL,username,password);
+ logger.debug(EELFLoggerDelegate.debugLogger, "getConnection:::"+ dbc);
+ q = "select count(*) from fn_app";
+ pst = dbc.prepareStatement(q);
+ rs = pst.executeQuery();
+
+ if (rs.next())
+ count = rs.getInt(1);
+ } catch(Exception ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex);
+ } finally {
+ cleanup(rs,pst,dbc);
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger, "count:::"+ count);
+ return count;
+ }
+
+ public static Connection getConnection(String driver2, String url, String username, String password) throws IOException, SQLException, ClassNotFoundException{
+ java.sql.Connection con=null;
+
+ if( url!=null && username!=null && password!=null ){
+ con = DriverManager.getConnection(url, username, password);
+ }
+
+ System.out.println("Connection Successful");
+ return con;
+
+ }
+
+ public static void cleanup(ResultSet rs, PreparedStatement st, Connection c) {
+ if (rs != null) {
+ try {
+ rs.close();
+ } catch (Exception e) {
+ if (logger != null)
+ logger.error("Error when trying to close result set", e);
+ }
+ }
+ if (st != null) {
+ try {
+ st.close();
+ } catch (Exception e) {
+ if (logger != null)
+ logger.error("Error when trying to close statement", e);
+ }
+ }
+ if (c != null) {
+ try {
+ c.rollback();
+ } catch (Exception e) {
+ if (logger != null)
+ logger.error("Error when trying to rollback connection", e);
+ }
+ try {
+ c.close();
+ } catch (Exception e) {
+ if (logger != null)
+ logger.error("Error when trying to close connection", e);
+ }
+ }
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/dao/ProfileDao.java b/vid-app-common/src/main/java/org/onap/vid/dao/ProfileDao.java
new file mode 100644
index 000000000..e6a8a4e54
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/dao/ProfileDao.java
@@ -0,0 +1,45 @@
+/*-
+ * ============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.dao;
+
+import java.util.List;
+import org.openecomp.portalsdk.core.domain.Profile;
+
+/**
+ * The Interface ProfileDao.
+ */
+public interface ProfileDao {
+
+ /**
+ * Find all.
+ *
+ * @return the list
+ */
+ List<Profile> findAll();
+
+ /**
+ * Gets the profile.
+ *
+ * @param id the id
+ * @return the profile
+ */
+ Profile getProfile(int id);
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/exceptions/NotFoundException.java b/vid-app-common/src/main/java/org/onap/vid/exceptions/NotFoundException.java
new file mode 100644
index 000000000..0616aa1f1
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/exceptions/NotFoundException.java
@@ -0,0 +1,12 @@
+package org.onap.vid.exceptions;
+
+public class NotFoundException extends RuntimeException {
+
+ public NotFoundException(String message) {
+ super(message);
+ }
+
+ public NotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/exceptions/VidServiceUnavailableException.java b/vid-app-common/src/main/java/org/onap/vid/exceptions/VidServiceUnavailableException.java
new file mode 100644
index 000000000..622b34c22
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/exceptions/VidServiceUnavailableException.java
@@ -0,0 +1,69 @@
+/*-
+ * ============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.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * The Class VidServiceUnavailableException.
+ */
+@ResponseStatus(value=HttpStatus.SERVICE_UNAVAILABLE)
+public class VidServiceUnavailableException extends Exception {
+
+ /** The Constant serialVersionUID. */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Instantiates a new vid service unavailable exception.
+ */
+ public VidServiceUnavailableException() {
+ super();
+ }
+
+ /**
+ * Instantiates a new vid service unavailable exception.
+ *
+ * @param msg the msg
+ */
+ public VidServiceUnavailableException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Instantiates a new vid service unavailable exception.
+ *
+ * @param t the t
+ */
+ public VidServiceUnavailableException(Throwable t) {
+ super(t);
+ }
+
+ /**
+ * Instantiates a new vid service unavailable exception.
+ *
+ * @param msg the msg
+ * @param t the t
+ */
+ public VidServiceUnavailableException(String msg, Throwable t) {
+ super(msg, t);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/factories/MsoRequestFactory.java b/vid-app-common/src/main/java/org/onap/vid/factories/MsoRequestFactory.java
new file mode 100644
index 000000000..22bfa47bc
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/factories/MsoRequestFactory.java
@@ -0,0 +1,15 @@
+package org.onap.vid.factories;
+
+import org.onap.vid.mso.rest.RequestDetails;
+
+/**
+ * Created by pickjonathan on 19/06/2017.
+ */
+public class MsoRequestFactory {
+
+ public RequestDetails createMsoRequest(String path)
+ {
+ return null;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/logging/VidLoggerAspect.java b/vid-app-common/src/main/java/org/onap/vid/logging/VidLoggerAspect.java
new file mode 100644
index 000000000..e4e0edb8c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/logging/VidLoggerAspect.java
@@ -0,0 +1,85 @@
+package org.onap.vid.logging;
+
+import org.apache.commons.lang3.StringUtils;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.openecomp.portalsdk.core.logging.aspect.EELFLoggerAdvice;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
+
+
+@Aspect
+@org.springframework.context.annotation.Configuration
+public class VidLoggerAspect {
+
+ private String canonicalHostName;
+ @Autowired
+ EELFLoggerAdvice advice;
+
+ public VidLoggerAspect() {
+ try {
+ final InetAddress localHost = InetAddress.getLocalHost();
+ canonicalHostName = localHost.getCanonicalHostName();
+ } catch (UnknownHostException e) {
+ // YOLO
+ canonicalHostName = null;
+ }
+ }
+
+ @Pointcut("execution(public * org.onap.vid.controller.*Controller.*(..))")
+ public void vidControllers() {}
+
+ @Around("vidControllers() && (" +
+ " @within(org.openecomp.portalsdk.core.logging.aspect.AuditLog)" +
+ " || @annotation(org.openecomp.portalsdk.core.logging.aspect.AuditLog)" +
+ " || @annotation(org.springframework.web.bind.annotation.RequestMapping)" +
+ ")")
+ public Object logAuditMethodClassAround(ProceedingJoinPoint joinPoint) throws Throwable {
+ return logAroundMethod(joinPoint, SystemProperties.SecurityEventTypeEnum.INCOMING_REST_MESSAGE);
+ }
+
+ private Object logAroundMethod(ProceedingJoinPoint joinPoint, SystemProperties.SecurityEventTypeEnum securityEventType) throws Throwable {
+ //Before
+ Object[] passOnArgs = new Object[] {joinPoint.getSignature().getDeclaringType().getName(),joinPoint.getSignature().getName()};
+ Object[] returnArgs = advice.before(securityEventType, joinPoint.getArgs(), passOnArgs);
+
+ fixServerFqdnInMDC();
+
+ //Execute the actual method
+ Object result;
+ String restStatus = "COMPLETE";
+ try {
+ result = joinPoint.proceed();
+ } catch(Exception e) {
+ restStatus = "ERROR";
+ throw e;
+ } finally {
+ fixStatusCodeInMDC(restStatus);
+ advice.after(securityEventType, restStatus, joinPoint.getArgs(), returnArgs, passOnArgs);
+ }
+
+ return result;
+ }
+
+ // Set the status code into MDC *before* the metrics log is written by advice.after()
+ private void fixStatusCodeInMDC(String restStatus) {
+ EELFLoggerDelegate.mdcPut(SystemProperties.STATUS_CODE, restStatus);
+ }
+
+ // Override the non-canonical hostname set by EELFLoggerDelegate::setGlobalLoggingContext()
+ // that was invoked by advice.before() (and some other SDK cases)
+ private void fixServerFqdnInMDC() {
+ if (!StringUtils.isBlank(canonicalHostName)) {
+ EELFLoggerDelegate.mdcPut(MDC_SERVER_FQDN, canonicalHostName);
+ }
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameter.java b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameter.java
new file mode 100644
index 000000000..e2939996f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameter.java
@@ -0,0 +1,120 @@
+package org.onap.vid.model;
+
+//import org.hibernate.annotations.Table;
+import org.openecomp.portalsdk.core.domain.support.DomainVo;
+import org.onap.vid.controller.MaintenanceController;
+
+//import javax.persistence.*;
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+@Entity
+@Table(name = "vid_category_parameter", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
+public class CategoryParameter extends DomainVo {
+
+ public enum Family {
+ PARAMETER_STANDARDIZATION,
+ TENANT_ISOLATION
+ }
+
+ private String name;
+ private boolean idSupported;
+
+ @Column(name = "FAMILY")
+ @Enumerated(EnumType.STRING)
+ private String family;
+
+ public String getFamily() {
+ return family;
+ }
+
+ public void setFamily(String family) {
+ this.family = family;
+ }
+
+ private Set<CategoryParameterOption> options = new HashSet<>(0);
+
+ @Override
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "CATEGORY_ID")
+ public Long getId() {
+ return super.getId();
+ }
+
+ @Override
+ @Column(name = "CREATED_DATE")
+ public Date getCreated() {
+ return super.getCreated();
+ }
+
+ @Override
+ @Column(name = "MODIFIED_DATE")
+ public Date getModified() {
+ return super.getModified();
+ }
+
+ @Override
+ @Transient
+ public Long getCreatedId() {
+ return super.getCreatedId();
+ }
+
+ @Override
+ @Transient
+ public Long getModifiedId() {
+ return super.getModifiedId();
+ }
+
+ @Column(name = "NAME", unique = true, nullable = false, length=50)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ @Transient
+ public Serializable getAuditUserId() {
+ return super.getAuditUserId();
+ }
+
+ @Override
+ @Transient
+ public Long getRowNum() {
+ return super.getRowNum();
+ }
+
+ @Override
+ @Transient
+ public Set getAuditTrail() {
+ return super.getAuditTrail();
+ }
+
+ @OneToMany(fetch = FetchType.EAGER, mappedBy = "categoryParameter")
+ public Set<CategoryParameterOption> getOptions() {
+ return options;
+ }
+
+ public void setOptions(Set<CategoryParameterOption> options) {
+ this.options = options;
+ }
+
+ public boolean addOption(CategoryParameterOption option) {
+ return options.add(option);
+ }
+
+ @Column(name = "ID_SUPPORTED")
+ public boolean isIdSupported() {
+ return idSupported;
+ }
+
+ public void setIdSupported(boolean idSupported) {
+ this.idSupported = idSupported;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
new file mode 100644
index 000000000..39efb2c57
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
@@ -0,0 +1,139 @@
+package org.onap.vid.model;
+
+import org.openecomp.portalsdk.core.domain.support.DomainVo;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Set;
+
+@Entity
+@Table(name = "vid_category_parameter_option")
+public class CategoryParameterOption extends DomainVo {
+
+ private Long id;
+ private String appId;
+ private String name;
+
+ private CategoryParameter categoryParameter;
+
+ public CategoryParameterOption() {
+ }
+
+ public CategoryParameterOption(String appId, String name, CategoryParameter categoryParameter) {
+ setAppId(appId);
+ setName(name);
+ setCategoryParameter(categoryParameter);
+ }
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "CATEGORY_OPT_DB_ID")
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Column(name = "CATEGORY_OPT_APP_ID")
+ public String getAppId() {
+ return appId;
+ }
+
+ public void setAppId(String appId) {
+ this.appId = appId;
+ }
+
+ @Column(name = "NAME")
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @ManyToOne
+ @JoinColumn(name="CATEGORY_ID", nullable=false)
+ public CategoryParameter getCategoryParameter() {
+ return categoryParameter;
+ }
+
+ public void setCategoryParameter(CategoryParameter categoryParameter) {
+ this.categoryParameter = categoryParameter;
+ }
+
+ @Override
+ @Column(name = "CREATED_DATE")
+ public Date getCreated() {
+ return super.getCreated();
+ }
+
+ @Override
+ @Column(name = "MODIFIED_DATE")
+ public Date getModified() {
+ return super.getModified();
+ }
+
+ @Override
+ @Transient
+ public Long getCreatedId() {
+ return super.getCreatedId();
+ }
+
+ @Override
+ @Transient
+ public Long getModifiedId() {
+ return super.getModifiedId();
+ }
+
+ @Override
+ @Transient
+ public Serializable getAuditUserId() {
+ return super.getAuditUserId();
+ }
+
+ @Override
+ @Transient
+ public Long getRowNum() {
+ return super.getRowNum();
+ }
+
+ @Override
+ @Transient
+ public Set getAuditTrail() {
+ return super.getAuditTrail();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ CategoryParameterOption that = (CategoryParameterOption) o;
+
+ if (getAppId() != null ? !getAppId().equals(that.getAppId()) : that.getAppId() != null) return false;
+ if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
+ return getCategoryParameter() != null ? getCategoryParameter().equals(that.getCategoryParameter()) : that.getCategoryParameter() == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = getAppId() != null ? getAppId().hashCode() : 0;
+ result = 31 * result + (getName() != null ? getName().hashCode() : 0);
+ result = 31 * result + (getCategoryParameter() != null ? getCategoryParameter().hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "CategoryParameterOption{" +
+ "id=" + id +
+ ", key='" + appId + '\'' +
+ ", value='" + name + '\'' +
+ ", categoryParameterId=" + categoryParameter.getId() +
+ '}';
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/CommandProperty.java b/vid-app-common/src/main/java/org/onap/vid/model/CommandProperty.java
new file mode 100644
index 000000000..4f5ee173f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/CommandProperty.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.model;
+
+import java.util.Map;
+
+/**
+ * The Class Command Property.
+ */
+public class CommandProperty {
+
+ /** The display name for this input */
+ private String displayName;
+
+ /** The command, "get_input" */
+ private String command;
+
+ /** The input name we refer to back under the inputs section */
+ private String inputName;
+
+ /**
+ * Gets the display name.
+ *
+ * @return the displayName
+ */
+ public String getDisplayName() {
+ return displayName;
+ }
+ /**
+ * Gets the command.
+ *
+ * @return the command
+ */
+ public String getCommand() {
+ return command;
+ }
+ /**
+ * Gets the inputName.
+ *
+ * @return the inputName
+ */
+ public String getInputName() {
+ return inputName;
+ }
+ /**
+ * Sets the display name value.
+ *
+ * @param i the new get_input value
+ */
+ public void setDisplayName(String i) {
+ this.displayName = i;
+ }
+ /**
+ * Sets the command value.
+ *
+ * @param i the new command value
+ */
+ public void setCommand(String i) {
+ this.command = i;
+ }
+
+ /**
+ * Sets the input name value.
+ *
+ * @param i the new input name value
+ */
+ public void setInputName(String i) {
+ this.inputName=i;
+ }
+
+ public String toString () {
+ String result = "displayName=" + displayName + " command=" + command + " inputName" + inputName;
+ return result;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ExceptionResponse.java b/vid-app-common/src/main/java/org/onap/vid/model/ExceptionResponse.java
new file mode 100644
index 000000000..444a4ba11
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ExceptionResponse.java
@@ -0,0 +1,91 @@
+/*-
+ * ============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.model;
+
+import org.slf4j.MDC;
+
+import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
+
+/**
+ * The Class ExceptionResponse.
+ */
+public class ExceptionResponse {
+
+ public ExceptionResponse() {
+ }
+
+ /** The exception. */
+ private String exception;
+
+ /** The message. */
+ private String message;
+
+ public ExceptionResponse(String exception, String message) {
+ this.exception = exception;
+ this.message = message;
+ }
+
+ public ExceptionResponse(Exception exception) {
+ setException(exception);
+ }
+
+ /**
+ * Gets the exception.
+ *
+ * @return the exception
+ */
+ public String getException() {
+ return exception;
+ }
+
+ /**
+ * Sets the exception.
+ *
+ * @param exception the new exception
+ */
+ public void setException(String exception) {
+ this.exception = exception;
+ }
+
+ public void setException(Exception exception) {
+ setException(exception.getClass().toString().replaceFirst("^.*[\\.$]", ""));
+ setMessage(exception.getMessage() + " (Request id: " + MDC.get(MDC_KEY_REQUEST_ID) + ")");
+ }
+
+ /**
+ * Gets the message.
+ *
+ * @return the message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Sets the message.
+ *
+ * @param message the new message
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ExceptionTranslator.java b/vid-app-common/src/main/java/org/onap/vid/model/ExceptionTranslator.java
new file mode 100644
index 000000000..c600243a8
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ExceptionTranslator.java
@@ -0,0 +1,39 @@
+package org.onap.vid.model;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
+
+import static org.onap.vid.utils.Logging.getMethodCallerName;
+
+@ControllerAdvice
+public class ExceptionTranslator {
+
+ /** The logger. */
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ExceptionTranslator.class);
+
+ @ExceptionHandler(MethodArgumentTypeMismatchException.class)
+ @ResponseBody
+ public ExceptionResponse handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "{}: {}", getMethodCallerName(), ExceptionUtils.getMessage(e), e);
+ Class<?> type = e.getRequiredType();
+ String message;
+ if (type.isEnum()) {
+ message = "The parameter " + e.getName() + " must have a value among : " + StringUtils.join(type.getEnumConstants(), ", ");
+ }
+ else {
+ message = "The parameter " + e.getName() + " must be of type " + type.getTypeName();
+ }
+ return new ExceptionResponse(new ArgumentTypeMismatchException(message));
+ }
+
+ public static class ArgumentTypeMismatchException extends RuntimeException {
+ public ArgumentTypeMismatchException(String message) {
+ super(message);
+ }
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ListOfErrorsResponse.java b/vid-app-common/src/main/java/org/onap/vid/model/ListOfErrorsResponse.java
new file mode 100644
index 000000000..9339d7cd8
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ListOfErrorsResponse.java
@@ -0,0 +1,24 @@
+package org.onap.vid.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ListOfErrorsResponse {
+ protected List<String> errors;
+
+ public ListOfErrorsResponse() {
+ this.errors = new ArrayList<>();
+ }
+
+ public ListOfErrorsResponse(List<String> errors) {
+ this.errors = errors;
+ }
+
+ public List<String> getErrors() {
+ return errors;
+ }
+
+ public void setErrors(List<String> errors) {
+ this.errors = errors;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ModelConstants.java b/vid-app-common/src/main/java/org/onap/vid/model/ModelConstants.java
new file mode 100644
index 000000000..cb1a5f9a0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ModelConstants.java
@@ -0,0 +1,44 @@
+/*-
+ * ============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.model;
+/**
+ * The Class ModelConstants
+ */
+public class ModelConstants {
+
+ /** The Constant GET_INPUT_TAG. */
+ public final static String GET_INPUT_TAG = "get_input";
+
+ public static final String ASDC_MODEL_NAMESPACE = "asdc.model.namespace";
+ public static final String ASDC_SVC_API_PATH = "sdc.svc.api.path";
+ public static final String ASDC_RESOURCE_API_PATH = "sdc.resource.api.path";
+
+ public static final String DEFAULT_ASDC_MODEL_NAMESPACE = "org.openecomp.";
+ public static final String DEFAULT_ASDC_SVC_API_PATH = "sdc/v1/catalog/services";
+ public static final String DEFAULT_ASDC_RESOURCE_API_PATH = "sdc/v1/catalog/resources";
+
+ public final static String VF_MODULE = "groups.VfModule";
+ public final static String VNF = "resource.vf";
+ public final static String NETWORK = "resource.vl";
+
+ public final static String ROLE_DELIMITER = "___";
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ModelUtil.java b/vid-app-common/src/main/java/org/onap/vid/model/ModelUtil.java
new file mode 100644
index 000000000..897c6e76c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ModelUtil.java
@@ -0,0 +1,45 @@
+/**
+ *
+ */
+package org.onap.vid.model;
+
+/**
+ * The Class ModelUtil.
+ *
+ */
+public class ModelUtil {
+ /**
+ * Gets the tags for the given element according to the configured namespace
+ * @param namespaces the namespace list from the configuration
+ * @param constantValue the constant portion of the tag name, i.e. resource.vf...
+ * @return the tags
+ */
+ public static String[] getTags ( String[] namespaces, String constantValue ) {
+ String[] tags;
+ if ( namespaces == null || namespaces.length == 0 ) {
+ return null;
+ }
+ int le = namespaces.length;
+ tags = new String[le];
+ for ( int i = 0; i < le; i++ ) {
+ tags[i] = namespaces[i] + constantValue;
+ }
+ return (tags);
+ }
+ /**
+ * Determine if a note template type matches a set of configurable tags
+ * @param type the node template type
+ * @param tags the model configurable namespaces
+ * @return true if type starts with a tag in the array, false otherwise
+ */
+ public static boolean isType ( String type, String[] tags ) {
+ if ( (tags != null) && (tags.length > 0) ) {
+ for ( int i = 0; i < tags.length; i++ ) {
+ if ( type.startsWith (tags[i]) ) {
+ return (true);
+ }
+ }
+ }
+ return (false);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/MsoExceptionResponse.java b/vid-app-common/src/main/java/org/onap/vid/model/MsoExceptionResponse.java
new file mode 100644
index 000000000..0fe49d604
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/MsoExceptionResponse.java
@@ -0,0 +1,32 @@
+package org.onap.vid.model;
+
+public class MsoExceptionResponse {
+
+ public static class ServiceException {
+
+ public ServiceException(String messageId, String text) {
+ this.messageId = messageId;
+ this.text = text;
+ }
+
+ public ServiceException() {
+ }
+
+ public String messageId;
+ public String text;
+ }
+
+ public ServiceException serviceException;
+
+ public MsoExceptionResponse() {
+ }
+
+ public MsoExceptionResponse(String messageId, String text) {
+ this.serviceException = new ServiceException(messageId, text);
+ }
+
+ public MsoExceptionResponse(Exception exception) {
+ ExceptionResponse exceptionResponse = new ExceptionResponse(exception);
+ this.serviceException = new ServiceException(exceptionResponse.getException(), exceptionResponse.getMessage());
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Network.java b/vid-app-common/src/main/java/org/onap/vid/model/Network.java
new file mode 100644
index 000000000..ef342e407
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/Network.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.model;
+
+import org.onap.vid.asdc.beans.tosca.NodeTemplate;
+
+/**
+ * The Class Network.
+ */
+public class Network extends Node {
+
+ /** The model customization name. */
+ private String modelCustomizationName;
+
+ /**
+ * Instantiates a new network.
+ */
+ public Network() {
+ super();
+ }
+ /**
+ * Gets the model customization name.
+ *
+ * @return the model customization name
+ */
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+ /**
+ * Sets the model customization name.
+ *
+ * @param modelCustomizationName the new model customization name
+ */
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+
+ public void extractNetwork(String modelCustomizationName, NodeTemplate nodeTemplate) {
+
+ super.extractNode(nodeTemplate);
+ setModelCustomizationName(modelCustomizationName);
+
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/NewNetwork.java b/vid-app-common/src/main/java/org/onap/vid/model/NewNetwork.java
new file mode 100644
index 000000000..9f1ffd356
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/NewNetwork.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.model;
+
+import org.onap.vid.asdc.beans.tosca.NodeTemplate;
+
+/**
+ * The Class Network.
+ */
+public class NewNetwork extends NewNode {
+
+ /** The model customization name. */
+ private String modelCustomizationName;
+
+ /**
+ * Instantiates a new network.
+ */
+ public NewNetwork() {
+ super();
+ }
+ /**
+ * Gets the model customization name.
+ *
+ * @return the model customization name
+ */
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+ /**
+ * Sets the model customization name.
+ *
+ * @param modelCustomizationName the new model customization name
+ */
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/NewNode.java b/vid-app-common/src/main/java/org/onap/vid/model/NewNode.java
new file mode 100644
index 000000000..89a808b19
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/NewNode.java
@@ -0,0 +1,209 @@
+package org.onap.vid.model;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.asdc.beans.tosca.Input;
+
+
+public class NewNode {
+
+ /** The Constant LOG. */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(Node.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The uuid. */
+ private String uuid;
+
+ /** The invariant uuid. */
+ private String invariantUuid;
+
+ /** The description. */
+ private String description;
+
+ /** The name. */
+ private String name;
+
+ /** The version. */
+ private String version;
+
+ /** The model customization uuid. */
+ private String customizationUuid;
+
+ /** The inputs. */
+ private Map<String, Input> inputs;
+
+ /** The get_input or other constructs from node template properties. */
+ private Map<String, CommandProperty> commands;
+
+ /** The get_input or other constructs from node template properties. */
+ private Map<String, String> properties;
+ /**
+ * Instantiates a new node.
+ */
+ public NewNode() {
+ this.commands = new HashMap<String, CommandProperty>();
+ this.properties = new HashMap<String, String>();
+ }
+
+ /**
+ * Gets the uuid.
+ *
+ * @return the uuid
+ */
+ public String getUuid() {
+ return uuid;
+ }
+
+ /**
+ * Gets the invariant uuid.
+ *
+ * @return the invariant uuid
+ */
+ public String getInvariantUuid() {
+ return invariantUuid;
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the version.
+ *
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Gets the customization uuid.
+ *
+ * @return the model customization uuid
+ */
+ public String getCustomizationUuid() {
+ return customizationUuid;
+ }
+ /**
+ * Gets the inputs.
+ *
+ * @return the inputs
+ */
+ public Map<String, Input> getInputs() {
+ return inputs;
+ }
+ /**
+ * Gets the commands.
+ *
+ * @return the commands
+ */
+ public Map<String, CommandProperty> getCommands() {
+ return commands;
+ }
+ /**
+ * Gets the properties.
+ *
+ * @return the properties
+ */
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+ /**
+ * Sets the uuid.
+ *
+ * @param uuid the new uuid
+ */
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ /**
+ * Sets the invariant uuid.
+ *
+ * @param invariantUuid the new invariant uuid
+ */
+ public void setInvariantUuid(String invariantUuid) {
+ this.invariantUuid = invariantUuid;
+ }
+
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Sets the name.
+ *
+ * @param name the new name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the version.
+ *
+ * @param version the new version
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+ /**
+ * Sets the customization uuid.
+ *
+ * @param u the new customization uuid
+ */
+ public void setCustomizationUuid(String u) {
+ this.customizationUuid = u;
+ }
+
+ /**
+ * Sets the inputs.
+ *
+ * @param inputs the inputs
+ */
+ public void setInputs(Map<String, Input> inputs) {
+ this.inputs = inputs;
+ }
+ /**
+ * Sets the commands.
+ *
+ * @param m the commands
+ */
+ public void setCommands( Map<String, CommandProperty>m ) {
+ commands = m;
+ }
+ /**
+ * Sets the properties.
+ *
+ * @param p the properties
+ */
+ public void setProperties( Map<String, String>p) {
+ properties = p;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/NewService.java b/vid-app-common/src/main/java/org/onap/vid/model/NewService.java
new file mode 100644
index 000000000..1346c0d95
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/NewService.java
@@ -0,0 +1,252 @@
+/*-
+ * ============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.model;
+
+import java.util.Map;
+import java.util.UUID;
+
+import org.onap.vid.asdc.beans.tosca.Input;
+
+/**
+ * The Class Service.
+ */
+public class NewService {
+
+ /** The uuid. */
+ private String uuid;
+
+ /** The invariant uuid. */
+ private String invariantUuid;
+
+ /** The name. */
+ private String name;
+
+ /** The version. */
+ private String version;
+
+ /** The tosca model URL. */
+ private String toscaModelURL;
+
+ /** The category. */
+ private String category;
+
+ /** The description. */
+ private String description;
+
+ /** The service ecomp naming flag */
+ private String serviceEcompNaming;
+
+ /** The inputs. */
+ private Map<String, Input> inputs;
+
+ /**
+ * Gets the uuid.
+ *
+ * @return the uuid
+ */
+ public String getUuid() {
+ return uuid;
+ }
+
+ /**
+ * Gets the invariant uuid.
+ *
+ * @return the invariant uuid
+ */
+ public String getInvariantUuid() {
+ return invariantUuid;
+ }
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the version.
+ *
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Gets the tosca model URL.
+ *
+ * @return the tosca model URL
+ */
+ public String getToscaModelURL() {
+ return toscaModelURL;
+ }
+
+ /**
+ * Gets the category.
+ *
+ * @return the category
+ */
+ public String getCategory() {
+ return category;
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Gets the inputs.
+ *
+ * @return the inputs
+ */
+ public Map<String, Input> getInputs() {
+ return inputs;
+ }
+ /**
+ * Get the serviceEcompNaming value
+ *
+ * @return serviceEcompNaming
+ */
+ public String getServiceEcompNaming() {
+ return serviceEcompNaming;
+ }
+ /**
+ * Sets the uuid.
+ *
+ * @param uuid the new uuid
+ */
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ /**
+ * Sets the invariant uuid.
+ *
+ * @param invariantUuid the new invariant uuid
+ */
+ public void setInvariantUuid(String invariantUuid) {
+ this.invariantUuid = invariantUuid;
+ }
+
+ /**
+ * Sets the name.
+ *
+ * @param name the new name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the version.
+ *
+ * @param version the new version
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ /**
+ * Sets the tosca model URL.
+ *
+ * @param toscaModelURL the new tosca model URL
+ */
+ public void setToscaModelURL(String toscaModelURL) {
+ this.toscaModelURL = toscaModelURL;
+ }
+
+ /**
+ * Sets the category.
+ *
+ * @param category the new category
+ */
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Sets the inputs.
+ *
+ * @param inputs the inputs
+ */
+ public void setInputs(Map<String, Input> inputs) {
+ this.inputs = inputs;
+ }
+ /**
+ * Sets the service ecomp naming.
+ *
+ * @param serviceEcompNaming the new service ecomp naming
+ */
+ public void setServiceEcompNaming(String serviceEcompNaming) {
+ this.serviceEcompNaming = serviceEcompNaming;
+ }
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final UUID uuid = UUID.fromString(getUuid());
+
+ return uuid.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if (!(o instanceof NewService)) return false;
+
+ final NewService service = (NewService) o;
+
+ return (service.getUuid().equals(getUuid()));
+ }
+ /*public static void extractVfModuleCustomizationUUID (Service s, String vnfCustomizationName, VfModule vfMod ) {
+
+ //Look for vnfCustomizationName..vfModuleCustomizationName
+ String nameToFind = vnfCustomizationName + ".." + vfMod.getModelCustomizationName();
+ for (Entry<UUID, VfModule> vfModuleComponent : s.getVfModules().entrySet()) {
+ VfModule xMod = vfModuleComponent.getValue();
+ if ( (xMod.getModelCustomizationName() != null) && (xMod.getModelCustomizationName().equalsIgnoreCase(nameToFind)) ) {
+ vfMod.setCustomizationUuid( xMod.getCustomizationUuid());
+ return;
+ }
+ }
+ }*/
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/NewServiceModel.java b/vid-app-common/src/main/java/org/onap/vid/model/NewServiceModel.java
new file mode 100644
index 000000000..e343b6de0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/NewServiceModel.java
@@ -0,0 +1,288 @@
+/*-
+ * ============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.model;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.onap.vid.asdc.beans.tosca.Group;
+import org.onap.vid.asdc.beans.tosca.ToscaModel;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.properties.VidProperties;
+/**
+ * The Class ServiceModel.
+ */
+
+public class NewServiceModel {
+
+ /** The Constant LOG. */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(NewServiceModel.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+ /** The service. */
+ private Service service;
+
+ /** The vnfs. */
+ private Map<String, VNF> vnfs;
+
+ /** The networks. */
+ private Map<String, Network> networks;
+
+ /**
+ * The vf modules. The VNF also has vfmodules but the vfmodules at the service level may have additional info
+ * that is not present in the VNF, like the vf module customization String
+ */
+ private Map<String, VfModule> vfModules;
+ /**
+ * The volume groups. The VNF also has volume groups but the volume groups will be populated at the service level
+ * for newer models
+ */
+ private Map<String, VolumeGroup> volumeGroups;
+
+ private Map<String, PortMirroringConfig> configurations;
+
+ private Map<String, ServiceProxy> serviceProxies;
+
+ private Map<String, Node> pnfs;
+
+ /**
+ * Instantiates a new service model.
+ */
+ public NewServiceModel() {}
+
+ /**
+ * Gets the service.
+ *
+ * @return the service
+ */
+ public Service getService() {
+ return service;
+ }
+
+ /**
+ * Gets the vnfs.
+ *
+ * @return the vnfs
+ */
+ public Map<String, VNF> getVnfs() {
+ return vnfs;
+ }
+
+ /**
+ * Gets the networks.
+ *
+ * @return the networks
+ */
+ public Map<String, Network> getNetworks() {
+ return networks;
+ }
+
+ /**
+ * Sets the service.
+ *
+ * @param service the new service
+ */
+ public void setService(Service service) {
+ this.service = service;
+ }
+
+ /**
+ * Sets the vnfs.
+ *
+ * @param vnfs the vnfs
+ */
+ public void setVnfs(Map<String, VNF> vnfs) {
+ this.vnfs = vnfs;
+ }
+
+ /**
+ * Sets the networks.
+ *
+ * @param networks the networks
+ */
+ public void setNetworks(Map<String, Network> networks) {
+ this.networks = networks;
+ }
+ /**
+ * Gets the vf modules.
+ *
+ * @return the vf modules
+ */
+ public Map<String, VfModule> getVfModules() {
+ return vfModules;
+ }
+ /**
+ * Gets the volume groups.
+ *
+ * @return the volume groups
+ */
+ public Map<String, VolumeGroup> getVolumeGroups() {
+ return volumeGroups;
+ }
+
+ public Map<String, PortMirroringConfig> getConfigurations() {
+ return configurations;
+ }
+
+ public Map<String, ServiceProxy> getServiceProxies() {
+ return serviceProxies;
+ }
+
+ /**
+ * Sets the vf modules.
+ *
+ * @param vfModules the vf modules
+ */
+
+
+ public void setVfModules(Map<String, VfModule> vfModules) {
+ this.vfModules = vfModules;
+ }
+ /**
+ * Sets the volume groups.
+ *
+ * @param volumeGroups the volume groups
+ */
+ public void setVolumeGroups(Map<String, VolumeGroup> volumeGroups) {
+ this.volumeGroups = volumeGroups;
+ }
+
+
+ public Map<String, Node> getPnfs() {
+ return pnfs;
+ }
+
+ public void setPnfs(Map<String, Node> pnfs) {
+ this.pnfs = pnfs;
+ }
+
+ /**
+ * Extract service.
+ *
+ * @param serviceToscaModel the service tosca model
+ * @param asdcServiceMetadata the asdc service metadata
+ * @return the service
+ */
+ public static Service extractService(ToscaModel serviceToscaModel, org.onap.vid.asdc.beans.Service asdcServiceMetadata) {
+
+ final Service service = new Service();
+
+ service.setCategory(serviceToscaModel.getMetadata().getCategory());
+ service.setInvariantUuid(serviceToscaModel.getMetadata().getInvariantUUID());
+ service.setName(serviceToscaModel.getMetadata().getName());
+ service.setUuid(serviceToscaModel.getMetadata().getUUID());
+ service.setDescription(serviceToscaModel.getMetadata().getDescription());
+ service.setServiceEcompNaming(serviceToscaModel.getMetadata().getServiceEcompNaming());
+ service.setInputs(serviceToscaModel.gettopology_template().getInputs());
+ //FIXME: SDC is not sending the Version with the Tosca Model for 1610 - they should send it in 1702
+ //THIS IS A TEMPORARY FIX, AT SOME POINT UNCOMMENT ME
+ //service.setVersion(serviceToscaModel.getMetadata().getVersion());
+ service.setVersion(asdcServiceMetadata.getVersion());
+
+ return service;
+ }
+ public static void extractGroups (ToscaModel serviceToscaModel,NewServiceModel serviceModel) {
+ // Get the groups. The groups may duplicate the groups that are in the VNF model and have
+ // additional data like the VF module customization String>
+
+ final Map<String, VfModule> vfModules = new HashMap<String, VfModule> ();
+ final Map<String, VolumeGroup> volumeGroups = new HashMap<String, VolumeGroup> ();
+
+ String asdcModelNamespace = VidProperties.getAsdcModelNamespace();
+ String vfModuleTag = asdcModelNamespace + ModelConstants.VF_MODULE;
+
+ for (Entry<String, Group> component : serviceToscaModel.gettopology_template().getGroups().entrySet()) {
+ final Group group = component.getValue();
+ final String type = group.getType();
+ final String customizationName = component.getKey();
+
+ if (type.startsWith(vfModuleTag)) {
+ VfModule vfMod = VfModule.extractVfModule(customizationName, group);
+ vfModules.put(customizationName, vfMod);
+ if ( vfMod.isVolumeGroupAllowed() ) {
+ //volume groups have the same customization name as the vf module
+ volumeGroups.put(customizationName, VolumeGroup.extractVolumeGroup(customizationName,group));
+ }
+ }
+ }
+ // add this point vfModules and volume groups are disconnected from VNF
+ serviceModel.setVfModules (vfModules);
+ serviceModel.setVolumeGroups (volumeGroups);
+
+ }
+ /**
+ * Populate the vf modules and volume groups that we may have under the service level under each VNF.
+ */
+// public void associateGroups() {
+// String methodName = "associateGroups()";
+// LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " start");
+// // go through the vnfs, get the vnf normalized name and look for a vf module with a customization name that starts
+// // with vnf + ".."
+// String vnfCustomizationName = null;
+// String normalizedVnfCustomizationName = null;
+// String vfModuleCustomizationName = null;
+// NewVNF tmpVnf = null;
+//
+// if ( ( getVnfs() != null ) && (!(getVnfs().isEmpty())) ) {
+// for (Entry<String, NewVNF> vnfComponent : getVnfs().entrySet()) {
+// vnfCustomizationName = vnfComponent.getValue().getModelCustomizationName();
+// normalizedVnfCustomizationName = VNF.normalizeName(vnfCustomizationName);
+//
+// LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName +
+// " VNF customizationName=" + vnfCustomizationName + "normalized customization name=" + normalizedVnfCustomizationName);
+//
+// // now check to see if there is a vf module with customization name that starts with normalizedVnfCustomizationName
+//
+// if (( getVfModules() != null ) && (!(getVfModules().isEmpty()))) {
+// for (Entry<String, VfModule> vfModuleComponent : getVfModules().entrySet()) {
+// vfModuleCustomizationName = vfModuleComponent.getValue().getModelCustomizationName();
+//
+// LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName +
+// " VF Module customizationName=" + vfModuleCustomizationName );
+// if ( vfModuleCustomizationName.startsWith(normalizedVnfCustomizationName + ".." )) {
+//
+// // this vf module belongs to the VNF
+// tmpVnf = vnfComponent.getValue();
+// (tmpVnf.getVfModules()).put(vfModuleComponent.getKey(), vfModuleComponent.getValue());
+//
+// LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName +
+// " Associated VF Module customizationName=" + vfModuleComponent.getKey() + " with VNF customization name=" + vnfCustomizationName);
+//
+// // now find if this vf module has volume groups, if so, find the volume group with the same customization name and put it under the VNF
+// if ( vfModuleComponent.getValue().isVolumeGroupAllowed() ) {
+// if (( getVolumeGroups() != null ) && (!(getVolumeGroups().isEmpty()))) {
+// if (getVolumeGroups().containsKey((vfModuleCustomizationName))) {
+// (vnfComponent.getValue().getVolumeGroups()).put(vfModuleCustomizationName, (getVolumeGroups()).get(vfModuleCustomizationName));
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+// }
+
+// }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/NewVNF.java b/vid-app-common/src/main/java/org/onap/vid/model/NewVNF.java
new file mode 100644
index 000000000..8e8c89f51
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/NewVNF.java
@@ -0,0 +1,123 @@
+package org.onap.vid.model;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.asdc.beans.tosca.NodeTemplate;
+
+public class NewVNF extends NewNode {
+
+ /** The Constant LOG. */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VNF.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The pattern used to normalize VNF names */
+ final static Pattern COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+");
+
+ /** The model customization name. */
+ private String modelCustomizationName;
+
+ /** The vf modules. */
+ private Map<String, VfModule> vfModules = new HashMap<String, VfModule>();
+
+ /** The volume groups. */
+ private Map<String, VolumeGroup> volumeGroups = new HashMap<String, VolumeGroup>();
+
+ /**
+ * Instantiates a newvnf.
+ */
+ public NewVNF() {
+ super();
+ }
+
+ /**
+ * Gets the model customization name.
+ *
+ * @return the model customization name
+ */
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+
+ /**
+ * Gets the vf modules.
+ *
+ * @return the vf modules
+ */
+ public Map<String, VfModule> getVfModules() {
+ return vfModules;
+ }
+
+ /**
+ * Sets the vf modules.
+ *
+ * @param vfModules the vf modules
+ */
+ public void setVfModules(Map<String, VfModule> vfModules) {
+ this.vfModules = vfModules;
+ }
+
+ /**
+ * Gets the volume groups.
+ *
+ * @return the volume groups
+ */
+ public Map<String, VolumeGroup> getVolumeGroups() {
+ return volumeGroups;
+ }
+
+ /**
+ * Sets the volume groups.
+ *
+ * @param volumeGroups the volume groups
+ */
+ public void setVolumeGroups(Map<String, VolumeGroup> volumeGroups) {
+ this.volumeGroups = volumeGroups;
+ }
+
+
+ /**
+ * Sets the model customization name.
+ *
+ * @param modelCustomizationName the new model customization name
+ */
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+ /**
+ * Normalize the VNF name
+ * @param originalName
+ * @return the normalized name
+ */
+ public static String normalizeName (String originalName) {
+
+ String normalizedName = originalName.toLowerCase();
+ normalizedName = COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" ");
+ String[] splitArr = null;
+
+ try {
+ splitArr = normalizedName.split(" ");
+ }
+ catch (Exception ex ) {
+ return (normalizedName);
+ }
+ StringBuffer sb = new StringBuffer();
+ if ( splitArr != null ) {
+ for (String splitElement : splitArr) {
+ sb.append(splitElement);
+ }
+ return (sb.toString());
+ }
+ else {
+ return (normalizedName);
+ }
+
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Node.java b/vid-app-common/src/main/java/org/onap/vid/model/Node.java
new file mode 100644
index 000000000..7623a3869
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/Node.java
@@ -0,0 +1,322 @@
+/*-
+ * ============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.model;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.onap.vid.asdc.beans.tosca.Input;
+import org.onap.vid.asdc.beans.tosca.NodeTemplate;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+/**
+ * The Class Node.
+ */
+public class Node {
+ /** The Constant LOG. */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(Node.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The uuid. */
+ private String uuid;
+
+ /** The invariant uuid. */
+ private String invariantUuid;
+
+ /** The description. */
+ private String description;
+
+ /** The name. */
+ private String name;
+
+ /** The version. */
+ private String version;
+
+ /** The model customization uuid. */
+ private String customizationUuid;
+
+ /** The inputs. */
+ private Map<String, Input> inputs;
+
+ /** The get_input or other constructs from node template properties. */
+ private Map<String, CommandProperty> commands;
+
+ /** The get_input or other constructs from node template properties. */
+ private Map<String, String> properties;
+
+ /** Type from Metadata */
+ private String type;
+ /**
+ * Instantiates a new node.
+ */
+ public Node() {
+ this.commands = new HashMap<String, CommandProperty>();
+ this.properties = new HashMap<String, String>();
+ }
+
+ /**
+ * Gets the uuid.
+ *
+ * @return the uuid
+ */
+ public String getUuid() {
+ return uuid;
+ }
+
+ /**
+ * Gets the invariant uuid.
+ *
+ * @return the invariant uuid
+ */
+ public String getInvariantUuid() {
+ return invariantUuid;
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the version.
+ *
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Gets the customization uuid.
+ *
+ * @return the model customization uuid
+ */
+ public String getCustomizationUuid() {
+ return customizationUuid;
+ }
+ /**
+ * Gets the inputs.
+ *
+ * @return the inputs
+ */
+ public Map<String, Input> getInputs() {
+ return inputs;
+ }
+ /**
+ * Gets the commands.
+ *
+ * @return the commands
+ */
+ public Map<String, CommandProperty> getCommands() {
+ return commands;
+ }
+ /**
+ * Gets the properties.
+ *
+ * @return the properties
+ */
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+ /**
+ * Sets the uuid.
+ *
+ * @param uuid the new uuid
+ */
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ /**
+ * Sets the invariant uuid.
+ *
+ * @param invariantUuid the new invariant uuid
+ */
+ public void setInvariantUuid(String invariantUuid) {
+ this.invariantUuid = invariantUuid;
+ }
+
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Sets the name.
+ *
+ * @param name the new name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the version.
+ *
+ * @param version the new version
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+ /**
+ * Sets the customization uuid.
+ *
+ * @param u the new customization uuid
+ */
+ public void setCustomizationUuid(String u) {
+ this.customizationUuid = u;
+ }
+
+ /**
+ * Sets the inputs.
+ *
+ * @param inputs the inputs
+ */
+ public void setInputs(Map<String, Input> inputs) {
+ this.inputs = inputs;
+ }
+ /**
+ * Sets the commands.
+ *
+ * @param m the commands
+ */
+ public void setCommands( Map<String, CommandProperty>m ) {
+ commands = m;
+ }
+ /**
+ * Sets the properties.
+ *
+ * @param p the properties
+ */
+ public void setProperties( Map<String, String>p) {
+ properties = p;
+ }
+
+
+ /**
+ * @return metadata type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Set metadata type
+ *
+ * @param type e.g. VF/CP/SERVICE_PROXY
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Extract node.
+ *
+ * @param modelCustomizationName the model customization name
+ * @param nodeTemplate the node template
+ * @return the node
+ */
+ public void extractNode (NodeTemplate nodeTemplate) {
+
+ String methodName = "extractNode";
+
+ setUuid(nodeTemplate.getMetadata().getUUID());
+ setInvariantUuid(nodeTemplate.getMetadata().getInvariantUUID());
+ setDescription(nodeTemplate.getMetadata().getDescription());
+ setName(nodeTemplate.getMetadata().getName());
+ setVersion(nodeTemplate.getMetadata().getVersion());
+ // add customizationUUID
+ setCustomizationUuid(nodeTemplate.getMetadata().getCustomizationUUID());
+
+ try {
+ // nodeTemplate.getProperties() map of String->Object
+ for (Entry<String, Object> e : nodeTemplate.getProperties().entrySet()) {
+
+ String k = e.getKey();
+
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " node template property: " + k );
+
+ if ( e.getValue() != null ) {
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " property: " +
+ k + "=" + e.getValue());
+ //LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " V class name: " +
+ // e.getValue().getClass().getName());
+ Class<?> c = e.getValue().getClass();
+ if ( c.getName().equalsIgnoreCase(java.lang.String.class.getName())) {
+ getProperties().put (k, (String)e.getValue());
+ }
+ else {
+ Class<?>[] interfaces = e.getValue().getClass().getInterfaces();
+
+ for(Class<?> ifc: interfaces ) {
+ //LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " ifc name: " +
+ // ifc.getName());
+ if ( ifc.getName().equalsIgnoreCase(java.util.Map.class.getName()) ) {
+ // only extract get_input for now
+ @SuppressWarnings("unchecked")
+ HashMap<String,String> v = (HashMap<String,String>)e.getValue();
+ for (Entry<String, String> entry : v.entrySet()) {
+ // only include get_input for now
+ if ( ModelConstants.GET_INPUT_TAG.equalsIgnoreCase ( entry.getKey() ) ) {
+ CommandProperty cp = new CommandProperty();
+ cp.setCommand(entry.getKey());
+ cp.setInputName(entry.getValue());
+ cp.setDisplayName(k);
+ getCommands().put(k,cp);
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+ catch ( Exception e ) {
+ LOG.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + " Unable to parse node properties: e=" +
+ e.toString());
+ }
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/PortMirroringConfig.java b/vid-app-common/src/main/java/org/onap/vid/model/PortMirroringConfig.java
new file mode 100644
index 000000000..dd3d5db72
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/PortMirroringConfig.java
@@ -0,0 +1,77 @@
+package org.onap.vid.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.RequirementAssignments;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+public class PortMirroringConfig extends Node {
+
+ /** The Constant LOG. */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(PortMirroringConfig.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The model customization name. */
+ private String modelCustomizationName;
+
+ /** The port miroring requirements for source/collector */
+ @JsonIgnore
+ private RequirementAssignments requirementAssignments;
+
+ private List<String> sourceNodes;
+
+ private List<String> collectorNodes;
+
+ private boolean configurationByPolicy;
+
+ public PortMirroringConfig() {
+ super();
+ this.configurationByPolicy = false;
+ }
+
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+
+ public RequirementAssignments getRequirementAssignments() {
+ return requirementAssignments;
+ }
+
+ public void setRequirementAssignments(RequirementAssignments requirementAssignments) {
+ this.requirementAssignments = requirementAssignments;
+ }
+
+ public List<String> getSourceNodes() {
+ return sourceNodes;
+ }
+
+ public void setSourceNodes(List<String> sourceNodes) {
+ this.sourceNodes = sourceNodes;
+ }
+
+ public List<String> getCollectorNodes() {
+ return collectorNodes;
+ }
+
+ public void setCollectorNodes(List<String> collectorNodes) {
+ this.collectorNodes = collectorNodes;
+ }
+
+ public void setConfigurationByPolicy(boolean configurationByPolicy) {
+ this.configurationByPolicy = configurationByPolicy;
+ }
+
+ public boolean isConfigurationByPolicy() {
+ return configurationByPolicy;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ProxyResponse.java b/vid-app-common/src/main/java/org/onap/vid/model/ProxyResponse.java
new file mode 100644
index 000000000..1931fa39e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ProxyResponse.java
@@ -0,0 +1,30 @@
+package org.onap.vid.model;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Created by Oren on 7/10/17.
+ */
+public class ProxyResponse {
+
+ protected String errorMessage;
+
+ protected int httpCode;
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+
+ public int getHttpCode() {
+ return httpCode;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("httpCode", httpCode)
+ .add("errorMessage", errorMessage)
+ .toString();
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java b/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java
new file mode 100644
index 000000000..9c12a52a6
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java
@@ -0,0 +1,42 @@
+package org.onap.vid.model;
+
+import com.fasterxml.jackson.annotation.*;
+import com.google.common.base.MoreObjects;
+import org.onap.vid.domain.mso.RequestReferences;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class RequestReferencesContainer {
+ private final RequestReferences requestReferences;
+
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ public RequestReferencesContainer(@JsonProperty("requestReferences") RequestReferences requestReferences) {
+ this.requestReferences = requestReferences;
+ }
+
+ public RequestReferences getRequestReferences() {
+ return requestReferences;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("requestReferences", requestReferences)
+ .add("additionalProperties", additionalProperties)
+ .toString();
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Resource.java b/vid-app-common/src/main/java/org/onap/vid/model/Resource.java
new file mode 100644
index 000000000..184f9ee6e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/Resource.java
@@ -0,0 +1,28 @@
+/*-
+ * ============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.model;
+
+/**
+ * The Class Resource.
+ */
+public class Resource {
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Result.java b/vid-app-common/src/main/java/org/onap/vid/model/Result.java
new file mode 100644
index 000000000..c972bccaa
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/Result.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.model;
+
+/**
+ * The Class Result.
+ */
+public class Result {
+
+ /** The result. */
+ private String result;
+
+ /**
+ * Instantiates a new result.
+ *
+ * @param result the result
+ */
+ public Result(String result) {
+ this.result = result;
+ }
+
+ /**
+ * Gets the result.
+ *
+ * @return the result
+ */
+ public String getResult() {
+ return result;
+ }
+
+ /**
+ * Sets the result.
+ *
+ * @param result the new result
+ */
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Service.java b/vid-app-common/src/main/java/org/onap/vid/model/Service.java
new file mode 100644
index 000000000..b0597c649
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/Service.java
@@ -0,0 +1,283 @@
+/*-
+ * ============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.model;
+
+import org.onap.vid.asdc.beans.tosca.Input;
+
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * The Class Service.
+ */
+public class Service {
+
+ /** The uuid. */
+ private String uuid;
+
+ /** The invariant uuid. */
+ private String invariantUuid;
+
+ /** The name. */
+ private String name;
+
+ /** The version. */
+ private String version;
+
+ /** The tosca model URL. */
+ private String toscaModelURL;
+
+ /** The category. */
+ private String category;
+
+ /** The Service Type. */
+ private String serviceType;
+
+ /** The Service Role */
+ private String serviceRole;
+
+ /** The description. */
+ private String description;
+
+ /** The service ecomp naming flag */
+ private String serviceEcompNaming;
+
+ private String instantiationType;
+
+
+ /** The inputs. */
+ private Map<String, Input> inputs;
+
+ /**
+ * Gets the uuid.
+ *
+ * @return the uuid
+ */
+ public String getUuid() {
+ return uuid;
+ }
+
+ /**
+ * Gets the invariant uuid.
+ *
+ * @return the invariant uuid
+ */
+ public String getInvariantUuid() {
+ return invariantUuid;
+ }
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the version.
+ *
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Gets the tosca model URL.
+ *
+ * @return the tosca model URL
+ */
+ public String getToscaModelURL() {
+ return toscaModelURL;
+ }
+
+ /**
+ * Gets the category.
+ *
+ * @return the category
+ */
+ public String getCategory() {
+ return category;
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Gets the inputs.
+ *
+ * @return the inputs
+ */
+ public Map<String, Input> getInputs() {
+ return inputs;
+ }
+ /**
+ * Get the serviceEcompNaming value
+ *
+ * @return serviceEcompNaming
+ */
+ public String getServiceEcompNaming() {
+ return serviceEcompNaming;
+ }
+
+
+ public String getInstantiationType() { return instantiationType; }
+
+ public void setInstantiationType(String instantiationType) { this.instantiationType = instantiationType; }
+ /**
+ * Sets the uuid.
+ *
+ * @param uuid the new uuid
+ */
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ /**
+ * Sets the invariant uuid.
+ *
+ * @param invariantUuid the new invariant uuid
+ */
+ public void setInvariantUuid(String invariantUuid) {
+ this.invariantUuid = invariantUuid;
+ }
+
+ /**
+ * Sets the name.
+ *
+ * @param name the new name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the version.
+ *
+ * @param version the new version
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ /**
+ * Sets the tosca model URL.
+ *
+ * @param toscaModelURL the new tosca model URL
+ */
+ public void setToscaModelURL(String toscaModelURL) {
+ this.toscaModelURL = toscaModelURL;
+ }
+
+ /**
+ * Sets the category.
+ *
+ * @param category the new category
+ */
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Sets the inputs.
+ *
+ * @param inputs the inputs
+ */
+ public void setInputs(Map<String, Input> inputs) {
+ this.inputs = inputs;
+ }
+ /**
+ * Sets the service ecomp naming.
+ *
+ * @param serviceEcompNaming the new service ecomp naming
+ */
+ public void setServiceEcompNaming(String serviceEcompNaming) {
+ this.serviceEcompNaming = serviceEcompNaming;
+ }
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final UUID uuid = UUID.fromString(getUuid());
+
+ return uuid.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if (!(o instanceof Service)) return false;
+
+ final Service service = (Service) o;
+
+ return (service.getUuid().equals(getUuid()));
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public String getServiceRole() {
+ return serviceRole;
+ }
+
+ public void setServiceRole(String serviceRole) {
+ this.serviceRole = serviceRole;
+ }
+
+ /*public static void extractVfModuleCustomizationUUID (Service s, String vnfCustomizationName, VfModule vfMod ) {
+
+ //Look for vnfCustomizationName..vfModuleCustomizationName
+ String nameToFind = vnfCustomizationName + ".." + vfMod.getModelCustomizationName();
+ for (Entry<UUID, VfModule> vfModuleComponent : s.getVfModules().entrySet()) {
+ VfModule xMod = vfModuleComponent.getValue();
+ if ( (xMod.getModelCustomizationName() != null) && (xMod.getModelCustomizationName().equalsIgnoreCase(nameToFind)) ) {
+ vfMod.setCustomizationUuid( xMod.getCustomizationUuid());
+ return;
+ }
+ }
+ }*/
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ServiceInstanceSearchResult.java b/vid-app-common/src/main/java/org/onap/vid/model/ServiceInstanceSearchResult.java
new file mode 100644
index 000000000..abf60d689
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ServiceInstanceSearchResult.java
@@ -0,0 +1,139 @@
+/*-
+ * ============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.model;
+
+public class ServiceInstanceSearchResult {
+
+ private String serviceInstanceId;
+
+ private String globalCustomerId;
+
+ private String serviceType;
+
+ private String serviceInstanceName;
+
+ private String subscriberName;
+
+ private String aaiModelInvariantId;
+
+ private String aaiModelVersionId;
+
+ private boolean isPermitted;
+
+ public ServiceInstanceSearchResult(){
+
+ }
+ public ServiceInstanceSearchResult(String serviceInstanceId, String globalCustomerId, String serviceType,
+ String serviceInstanceName, String subscriberName, String aaiModelInvariantId,
+ String aaiModelVersionId, boolean isPermitted) {
+ this.serviceInstanceId = serviceInstanceId;
+ this.globalCustomerId = globalCustomerId;
+ this.serviceType = serviceType;
+ this.serviceInstanceName = serviceInstanceName;
+ this.subscriberName = subscriberName;
+ this.aaiModelInvariantId = aaiModelInvariantId;
+ this.aaiModelVersionId = aaiModelVersionId;
+ this.isPermitted = isPermitted;
+ }
+
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public String getGlobalCustomerId() {
+ return globalCustomerId;
+ }
+
+ public void setGlobalCustomerId(String globalCustomerId) {
+ this.globalCustomerId = globalCustomerId;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ public String getServiceInstanceName() {
+ return serviceInstanceName;
+ }
+
+ public void setServiceInstanceName(String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ }
+
+ public String getSubscriberName() {
+ return subscriberName;
+ }
+
+ public void setSubscriberName(String subscriberName) {
+ this.subscriberName = subscriberName;
+ }
+
+ public String getAaiModelInvariantId() {
+ return aaiModelInvariantId;
+ }
+
+ public void setAaiModelInvariantId(String aaiModelInvariantId) {
+ this.aaiModelInvariantId = aaiModelInvariantId;
+ }
+
+ public String getAaiModelVersionId() {
+ return aaiModelVersionId;
+ }
+
+ public void setAaiModelVersionId(String aaiModelVersionId) {
+ this.aaiModelVersionId = aaiModelVersionId;
+ }
+
+ public boolean getIsPermitted() {
+ return isPermitted;
+ }
+
+ public void setIsPermitted(boolean isPermitted) {
+ this.isPermitted = isPermitted;
+ }
+
+ @Override
+ public boolean equals(Object other){
+ if (other instanceof ServiceInstanceSearchResult) {
+ ServiceInstanceSearchResult serviceInstanceSearchResultOther = (ServiceInstanceSearchResult) other;
+ if (this.getServiceInstanceId().equals(serviceInstanceSearchResultOther.getServiceInstanceId())) {
+ return true;
+ }
+ }
+ return false;
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ result = 31 * result + serviceInstanceId.hashCode();
+ return result;
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java b/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java
new file mode 100644
index 000000000..dab18d518
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java
@@ -0,0 +1,330 @@
+/*-
+ * ============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.model;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.onap.vid.asdc.beans.tosca.Group;
+import org.onap.vid.asdc.beans.tosca.NodeTemplate;
+import org.onap.vid.asdc.beans.tosca.ToscaModel;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.properties.VidProperties;
+/**
+ * The Class ServiceModel.
+ */
+@SuppressWarnings("ALL")
+public class ServiceModel {
+
+ /** The Constant LOG. */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(ServiceModel.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+ /** The service. */
+ private Service service;
+
+ /** The vnfs. */
+ private Map<String, VNF> vnfs;
+
+ /** The networks. */
+ private Map<String, Network> networks;
+
+ /** Port Mirroring Configuration node templates */
+ private Map<String, PortMirroringConfig> configurations;
+
+ /** Service Proxy Nodes */
+ private Map<String, ServiceProxy> serviceProxies;
+
+ /**
+ * The vf modules. The VNF also has vfmodules but the vfmodules at the service level may have additional info
+ * that is not present in the VNF, like the vf module customization String
+ */
+ private Map<String, VfModule> vfModules;
+ /**
+ * The volume groups. The VNF also has volume groups but the volume groups will be populated at the service level
+ * for newer models
+ */
+ private Map<String, VolumeGroup> volumeGroups;
+
+ /** The pnfs. */
+ private Map<String, Node> pnfs;
+ /**
+ * Instantiates a new service model.
+ */
+ public ServiceModel() {}
+
+ /**
+ * Gets the service.
+ *
+ * @return the service
+ */
+ public Service getService() {
+ return service;
+ }
+
+ /**
+ * Gets the vnfs.
+ *
+ * @return the vnfs
+ */
+ public Map<String, VNF> getVnfs() {
+ return vnfs;
+ }
+
+ /**
+ * Gets the networks.
+ *
+ * @return the networks
+ */
+ public Map<String, Network> getNetworks() {
+ return networks;
+ }
+
+
+ /**
+ * Gets the pnfs.
+ *
+ * @return the pnfs
+ */
+ public Map<String, Node> getPnfs() {
+ return pnfs;
+ }
+
+
+ /**
+ * Gets the Configuration Node Templates
+ *
+ * @return the configuration type node templates
+ */
+ public Map<String, PortMirroringConfig> getConfigurations() {
+ return configurations;
+ }
+
+ /**
+ * Gets the Service Proxy Node Templates
+ *
+ * @return the Service Proxy type node templates
+ */
+ public Map<String, ServiceProxy> getServiceProxies() {
+ return serviceProxies;
+ }
+
+ /**
+ * Sets the service.
+ *
+ * @param service the new service
+ */
+ public void setService(Service service) {
+ this.service = service;
+ }
+
+ /**
+ * Sets the vnfs.
+ *
+ * @param vnfs the vnfs
+ */
+ public void setVnfs(Map<String, VNF> vnfs) {
+ this.vnfs = vnfs;
+ }
+
+ /**
+ * Sets the networks.
+ *
+ * @param networks the networks
+ */
+ public void setNetworks(Map<String, Network> networks) {
+ this.networks = networks;
+ }
+
+ /**
+ * Sets the configuraion node templates.
+ *
+ * @param configurations
+ */
+ public void setConfigurations(Map<String, PortMirroringConfig> configurations) {
+ this.configurations = configurations;
+ }
+
+ /**
+ * Sets the service proxy node templates.
+ *
+ * @param serviceProxies
+ */
+ public void setServiceProxies(Map<String, ServiceProxy> serviceProxies) {
+ this.serviceProxies = serviceProxies;
+ }
+
+ /**
+ * Gets the vf modules.
+ *
+ * @return the vf modules
+ */
+ public Map<String, VfModule> getVfModules() {
+ return vfModules;
+ }
+
+
+ /**
+ * Gets the volume groups.
+ *
+ * @return the volume groups
+ */
+ public Map<String, VolumeGroup> getVolumeGroups() {
+ return volumeGroups;
+ }
+ /**
+ * Sets the vf modules.
+ *
+ * @param vfModules the vf modules
+ */
+ public void setVfModules(Map<String, VfModule> vfModules) {
+ this.vfModules = vfModules;
+ }
+ /**
+ * Sets the volume groups.
+ *
+ * @param volumeGroups the volume groups
+ */
+ public void setVolumeGroups(Map<String, VolumeGroup> volumeGroups) {
+ this.volumeGroups = volumeGroups;
+ }
+ /**
+ * Sets the pnfs.
+ *
+ * @param pnfs the pnfs
+ */
+ public void setPnfs(Map<String,Node> pnfs) {this.pnfs = pnfs;}
+
+ /**
+ * Extract service.
+ *
+ * @param serviceToscaModel the service tosca model
+ * @param asdcServiceMetadata the asdc service metadata
+ * @return the service
+ */
+ public static Service extractService(ToscaModel serviceToscaModel, org.onap.vid.asdc.beans.Service asdcServiceMetadata) {
+
+ final Service service = new Service();
+
+ service.setCategory(serviceToscaModel.getMetadata().getCategory());
+ service.setInvariantUuid(serviceToscaModel.getMetadata().getInvariantUUID());
+ service.setName(serviceToscaModel.getMetadata().getName());
+ service.setUuid(serviceToscaModel.getMetadata().getUUID());
+ service.setDescription(serviceToscaModel.getMetadata().getDescription());
+ service.setServiceEcompNaming(serviceToscaModel.getMetadata().getServiceEcompNaming());
+ service.setInputs(serviceToscaModel.gettopology_template().getInputs());
+ //FIXME: SDC is not sending the Version with the Tosca Model for 1610 - they should send it in 1702
+ //THIS IS A TEMPORARY FIX, AT SOME POINT UNCOMMENT ME
+ //service.setVersion(serviceToscaModel.getMetadata().getVersion());
+ service.setVersion(asdcServiceMetadata.getVersion());
+
+ return service;
+ }
+ public static void extractGroups (ToscaModel serviceToscaModel,ServiceModel serviceModel) {
+ // Get the groups. The groups may duplicate the groups that are in the VNF model and have
+ // additional data like the VF module customization String>
+
+ final Map<String, VfModule> vfModules = new HashMap<String, VfModule> ();
+ final Map<String, VolumeGroup> volumeGroups = new HashMap<String, VolumeGroup> ();
+
+ String asdcModelNamespace = VidProperties.getAsdcModelNamespace();
+ String vfModuleTag = asdcModelNamespace + ModelConstants.VF_MODULE;
+
+ for (Entry<String, Group> component : serviceToscaModel.gettopology_template().getGroups().entrySet()) {
+ final Group group = component.getValue();
+ final String type = group.getType();
+ final String customizationName = component.getKey();
+
+ if (type.startsWith(vfModuleTag)) {
+ VfModule vfMod = VfModule.extractVfModule(customizationName, group);
+ vfModules.put(customizationName, vfMod);
+ if ( vfMod.isVolumeGroupAllowed() ) {
+ //volume groups have the same customization name as the vf module
+ volumeGroups.put(customizationName, VolumeGroup.extractVolumeGroup(customizationName,group));
+ }
+ }
+ }
+ // add this point vfModules and volume groups are disconnected from VNF
+ serviceModel.setVfModules (vfModules);
+ serviceModel.setVolumeGroups (volumeGroups);
+
+ }
+ /**
+ * Populate the vf modules and volume groups that we may have under the service level under each VNF.
+ */
+ public void associateGroups() {
+ String methodName = "associateGroups()";
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " start");
+ // go through the vnfs, get the vnf normalized name and look for a vf module with a customization name that starts
+ // with vnf + ".."
+ String vnfCustomizationName = null;
+ String normalizedVnfCustomizationName = null;
+ String vfModuleCustomizationName = null;
+ VNF tmpVnf = null;
+
+ if ( ( getVnfs() != null ) && (!(getVnfs().isEmpty())) ) {
+ for (Entry<String, VNF> vnfComponent : getVnfs().entrySet()) {
+ vnfCustomizationName = vnfComponent.getValue().getModelCustomizationName();
+ normalizedVnfCustomizationName = VNF.normalizeName(vnfCustomizationName);
+
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName +
+ " VNF customizationName=" + vnfCustomizationName + "normalized customization name=" + normalizedVnfCustomizationName);
+
+ // now check to see if there is a vf module with customization name that starts with normalizedVnfCustomizationName
+
+ if (( getVfModules() != null ) && (!(getVfModules().isEmpty()))) {
+ for (Entry<String, VfModule> vfModuleComponent : getVfModules().entrySet()) {
+ vfModuleCustomizationName = vfModuleComponent.getValue().getModelCustomizationName();
+
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName +
+ " VF Module customizationName=" + vfModuleCustomizationName );
+ if ( vfModuleCustomizationName.startsWith(normalizedVnfCustomizationName + ".." )) {
+
+ // this vf module belongs to the VNF
+ tmpVnf = vnfComponent.getValue();
+ (tmpVnf.getVfModules()).put(vfModuleComponent.getKey(), vfModuleComponent.getValue());
+
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName +
+ " Associated VF Module customizationName=" + vfModuleComponent.getKey() + " with VNF customization name=" + vnfCustomizationName);
+
+ // now find if this vf module has volume groups, if so, find the volume group with the same customization name and put it under the VNF
+ if ( vfModuleComponent.getValue().isVolumeGroupAllowed() ) {
+ if (( getVolumeGroups() != null ) && (!(getVolumeGroups().isEmpty()))) {
+ if (getVolumeGroups().containsKey((vfModuleCustomizationName))) {
+ (vnfComponent.getValue().getVolumeGroups()).put(vfModuleCustomizationName, (getVolumeGroups()).get(vfModuleCustomizationName));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ServiceProxy.java b/vid-app-common/src/main/java/org/onap/vid/model/ServiceProxy.java
new file mode 100644
index 000000000..f412a1e51
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ServiceProxy.java
@@ -0,0 +1,46 @@
+package org.onap.vid.model;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+public class ServiceProxy extends Node {
+
+ /** The Constant LOG. */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(ServiceProxy.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ private String sourceModelUuid;
+
+ private String sourceModelInvariant;
+
+ private String sourceModelName;
+
+ public String getSourceModelUuid() {
+ return sourceModelUuid;
+ }
+
+ public void setSourceModelUuid(String sourceModelUuid) {
+ this.sourceModelUuid = sourceModelUuid;
+ }
+
+ public String getSourceModelInvariant() {
+ return sourceModelInvariant;
+ }
+
+ public void setSourceModelInvariant(String sourceModelInvariant) {
+ this.sourceModelInvariant = sourceModelInvariant;
+ }
+
+ public String getSourceModelName() {
+ return sourceModelName;
+ }
+
+ public void setSourceModelName(String sourceModelName) {
+ this.sourceModelName = sourceModelName;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Subscriber.java b/vid-app-common/src/main/java/org/onap/vid/model/Subscriber.java
new file mode 100644
index 000000000..70711b804
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/Subscriber.java
@@ -0,0 +1,26 @@
+package org.onap.vid.model;
+
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * Created by Oren on 7/4/17.
+ */
+public class Subscriber {
+
+ @JsonProperty("global-customer-id")
+ public String globalCustomerId;
+
+ @JsonProperty("subscriber-name")
+ public String subscriberName;
+
+ @JsonProperty("subscriber-type")
+ public String subscriberType;
+
+ @JsonProperty("resource-version")
+ public String resourceVersion;
+
+
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/SubscriberList.java b/vid-app-common/src/main/java/org/onap/vid/model/SubscriberList.java
new file mode 100644
index 000000000..5f935971e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/SubscriberList.java
@@ -0,0 +1,15 @@
+package org.onap.vid.model;
+
+import org.openecomp.portalsdk.core.web.support.UserUtils;
+
+import java.util.List;
+
+/**
+ * Created by Oren on 7/4/17.
+ */
+public class SubscriberList {
+
+ public List<Subscriber> customer;
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/VNF.java b/vid-app-common/src/main/java/org/onap/vid/model/VNF.java
new file mode 100644
index 000000000..e558e9574
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/VNF.java
@@ -0,0 +1,165 @@
+/*-
+ * ============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.model;
+
+import java.util.Map;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map.Entry;
+import java.util.regex.Pattern;
+
+import org.onap.vid.asdc.beans.tosca.NodeTemplate;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.controller.VidController;
+
+import org.onap.vid.asdc.beans.tosca.Group;
+import org.onap.vid.asdc.beans.tosca.Input;
+
+/**
+ * The Class VNF.
+ */
+public class VNF extends Node {
+
+ /** The Constant LOG. */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VNF.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The pattern used to normalize VNF names */
+ final static Pattern COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+");
+
+ /** The model customization name. */
+ private String modelCustomizationName;
+
+ /** The vf modules. */
+ private Map<String, VfModule> vfModules = new HashMap<String, VfModule>();
+
+ /** The volume groups. */
+ private Map<String, VolumeGroup> volumeGroups = new HashMap<String, VolumeGroup>();
+
+ /**
+ * Instantiates a new vnf.
+ */
+ public VNF() {
+ super();
+ }
+
+ /**
+ * Gets the model customization name.
+ *
+ * @return the model customization name
+ */
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+
+ /**
+ * Gets the vf modules.
+ *
+ * @return the vf modules
+ */
+ public Map<String, VfModule> getVfModules() {
+ return vfModules;
+ }
+
+ /**
+ * Sets the vf modules.
+ *
+ * @param vfModules the vf modules
+ */
+ public void setVfModules(Map<String, VfModule> vfModules) {
+ this.vfModules = vfModules;
+ }
+
+ /**
+ * Gets the volume groups.
+ *
+ * @return the volume groups
+ */
+ public Map<String, VolumeGroup> getVolumeGroups() {
+ return volumeGroups;
+ }
+
+ /**
+ * Sets the volume groups.
+ *
+ * @param volumeGroups the volume groups
+ */
+ public void setVolumeGroups(Map<String, VolumeGroup> volumeGroups) {
+ this.volumeGroups = volumeGroups;
+ }
+
+ /**
+ * Extract vnf.
+ *
+ * @param modelCustomizationName the model customization name
+ * @param nodeTemplate the node template
+ * @return the vnf
+ */
+ public void extractVnf(String modelCustomizationName, NodeTemplate nodeTemplate) {
+
+ super.extractNode(nodeTemplate);
+ setModelCustomizationName(modelCustomizationName);
+
+ }
+
+ /**
+ * Sets the model customization name.
+ *
+ * @param modelCustomizationName the new model customization name
+ */
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+ /**
+ * Normalize the VNF name
+ * @param originalName
+ * @return the normalized name
+ */
+ public static String normalizeName (String originalName) {
+
+ String normalizedName = originalName.toLowerCase();
+ normalizedName = COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" ");
+ String[] splitArr = null;
+
+ try {
+ splitArr = normalizedName.split(" ");
+ }
+ catch (Exception ex ) {
+ return (normalizedName);
+ }
+ StringBuffer sb = new StringBuffer();
+ if ( splitArr != null ) {
+ for (String splitElement : splitArr) {
+ sb.append(splitElement);
+ }
+ return (sb.toString());
+ }
+ else {
+ return (normalizedName);
+ }
+
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/VNFDao.java b/vid-app-common/src/main/java/org/onap/vid/model/VNFDao.java
new file mode 100644
index 000000000..13e2ebb56
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/VNFDao.java
@@ -0,0 +1,105 @@
+package org.onap.vid.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.openecomp.portalsdk.core.domain.support.DomainVo;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+@Entity
+@Table(name = "vid_vnf")
+public class VNFDao extends DomainVo {
+
+ private String vnfUUID;
+ private String vnfInvariantUUID;
+ private Set<VidWorkflow> workflows = new HashSet<>(0);
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "VNF_DB_ID")
+ @JsonIgnore
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ @Column(name = "CREATED_DATE")
+ @JsonIgnore
+ public Date getCreated() {
+ return super.getCreated();
+ }
+
+ @Override
+ @Column(name = "MODIFIED_DATE")
+ @JsonIgnore
+ public Date getModified() {
+ return super.getModified();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getCreatedId() {
+ return super.getCreatedId();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getModifiedId() {
+ return super.getModifiedId();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Serializable getAuditUserId() {
+ return super.getAuditUserId();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getRowNum() {
+ return super.getRowNum();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Set getAuditTrail() {
+ return super.getAuditTrail();
+ }
+
+ @Column(name = "VNF_APP_UUID")
+ public String getVnfUUID() {
+ return vnfUUID;
+ }
+
+ @Column(name = "VNF_APP_INVARIANT_UUID")
+ public String getVnfInvariantUUID() {
+ return vnfInvariantUUID;
+ }
+
+
+ public void setVnfUUID(String vnfUUID) {
+ this.vnfUUID = vnfUUID;
+ }
+
+ public void setVnfInvariantUUID(String vnfInvariantUUID) {
+ this.vnfInvariantUUID = vnfInvariantUUID;
+ }
+
+ @ManyToMany(cascade = CascadeType.ALL, fetch =FetchType.EAGER )
+ @JoinTable(name = "vid_vnf_workflow", joinColumns = { @JoinColumn(name = "VNF_DB_ID") }, inverseJoinColumns = { @JoinColumn(name = "WORKFLOW_DB_ID") })
+ public Set<VidWorkflow> getWorkflows() {
+ return workflows;
+ }
+
+ public void setWorkflows(Set<VidWorkflow> workflows) {
+ this.workflows = workflows;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/VersionByInvariantIdsRequest.java b/vid-app-common/src/main/java/org/onap/vid/model/VersionByInvariantIdsRequest.java
new file mode 100644
index 000000000..907f4938d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/VersionByInvariantIdsRequest.java
@@ -0,0 +1,11 @@
+package org.onap.vid.model;
+
+import java.util.List;
+
+/**
+ * Created by Oren on 9/5/17.
+ */
+public class VersionByInvariantIdsRequest {
+
+ public List<String> versions;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/VfModule.java b/vid-app-common/src/main/java/org/onap/vid/model/VfModule.java
new file mode 100644
index 000000000..ac19587e1
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/VfModule.java
@@ -0,0 +1,308 @@
+/*-
+ * ============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.model;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.onap.vid.asdc.beans.tosca.Group;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
+/**
+ * The Class VfModule.
+ */
+public class VfModule {
+
+ /** The Constant LOG. */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VfModule.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The uuid. */
+ private String uuid;
+
+ /** The invariant uuid. */
+ private String invariantUuid;
+
+ /** The customization uuid. */
+ private String customizationUuid;
+
+ /** The description. */
+ private String description;
+
+ /** The name. */
+ private String name;
+
+ /** The version. */
+ private String version;
+
+ /** The volume group allowed. */
+ private boolean volumeGroupAllowed;
+
+ /** The get_input or other constructs for VF Module. */
+ private Map<String, CommandProperty> commands;
+
+ /** The model customization name. */
+ private String modelCustomizationName;
+
+ /**
+ * Instantiates a new vf module.
+ */
+ public VfModule() {
+ commands = new HashMap<String, CommandProperty>();
+ }
+ /**
+ * Gets the model customization name.
+ *
+ * @return the model customization name
+ */
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+ /**
+ * Gets the uuid.
+ *
+ * @return the uuid
+ */
+ public String getUuid() {
+ return uuid;
+ }
+
+ /**
+ * Gets the invariant uuid.
+ *
+ * @return the invariant uuid
+ */
+ public String getInvariantUuid() {
+ return invariantUuid;
+ }
+ /**
+ * Gets the customization uuid.
+ *
+ * @return the invariant uuid
+ */
+ public String getCustomizationUuid() {
+ return customizationUuid;
+ }
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+ /**
+ * Gets the commands.
+ *
+ * @return the commands
+ */
+ public Map<String, CommandProperty> getCommands() {
+ return commands;
+ }
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the version.
+ *
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Checks if is volume group allowed.
+ *
+ * @return true, if is volume group allowed
+ */
+ public boolean isVolumeGroupAllowed() {
+ return volumeGroupAllowed;
+ }
+
+ /**
+ * Sets the uuid.
+ *
+ * @param uuid the new uuid
+ */
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ /**
+ * Sets the invariant uuid.
+ *
+ * @param invariantUuid the new invariant uuid
+ */
+ public void setInvariantUuid(String invariantUuid) {
+ this.invariantUuid = invariantUuid;
+ }
+ /**
+ * Sets the customization uuid.
+ *
+ * @param customizationUuid the new customization uuid
+ */
+ public void setCustomizationUuid(String customizationUuid) {
+ this.customizationUuid = customizationUuid;
+ }
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Sets the name.
+ *
+ * @param name the new name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the version.
+ *
+ * @param version the new version
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ /**
+ * Sets the volume group allowed.
+ *
+ * @param volumeGroupAllowed the new volume group allowed
+ */
+ public void setVolumeGroupAllowed(boolean volumeGroupAllowed) {
+ this.volumeGroupAllowed = volumeGroupAllowed;
+ }
+ /**
+ * Sets the commands.
+ *
+ * @param m the commands
+ */
+ public void setCommands( Map<String, CommandProperty>m ) {
+ commands = m;
+ }
+ /**
+ * Sets the model customization name.
+ *
+ * @param modelCustomizationName the new model customization name
+ */
+ public void setModelCustomizationName(String modelCustomizationName) {
+ this.modelCustomizationName = modelCustomizationName;
+ }
+ /**
+ * Extract vf module.
+ *
+ * @param group the group
+ * @return the vf module
+ */
+ public static VfModule extractVfModule(String modelCustomizationName, Group group) {
+
+ String methodName = "extractVfModule";
+
+ final VfModule vfModule = new VfModule();
+
+ try {
+ vfModule.setUuid(group.getMetadata().getVfModuleModelUUID());
+ vfModule.setInvariantUuid(group.getMetadata().getVfModuleModelInvariantUUID());
+ vfModule.setDescription(group.getMetadata().getDescription());
+ vfModule.setName(group.getMetadata().getVfModuleModelName());
+ vfModule.setVersion(group.getMetadata().getVfModuleModelVersion());
+ vfModule.setCustomizationUuid(group.getMetadata().getVfModuleModelCustomizationUUID());
+ vfModule.setModelCustomizationName (modelCustomizationName);
+
+ if (group.getProperties().containsKey("volume_group")) {
+ if (group.getProperties().get("volume_group") != null) {
+
+ Class<?> c = group.getProperties().get("volume_group").getClass();
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " class name=" +
+ c.getName());
+
+ if ( c.getName().equalsIgnoreCase(Boolean.class.getName()) ) {
+ Boolean b = (Boolean)group.getProperties().get("volume_group");
+ vfModule.setVolumeGroupAllowed( b.booleanValue() );
+ }
+ }
+ } else {
+ vfModule.setVolumeGroupAllowed(false);
+ }
+ }
+ catch ( Exception e ) {
+ LOG.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + " Unable to parse VF Module from group: e=" +
+ e.toString());
+ }
+ /* Not extracting other types of properties for 1702
+ try {
+
+ for (Entry<String, Object> e : group.getProperties().entrySet()) {
+
+ String k = e.getKey();
+ if ( e.getValue() != null ) {
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " property: " +
+ k + "=" + e.getValue());
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " V class name: " +
+ e.getValue().getClass().getName());
+ Class<?>[] interfaces = e.getValue().getClass().getInterfaces();
+
+ for(Class<?> ifc: interfaces ){
+ LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " ifc name: " +
+ ifc.getName());
+ }
+
+ // only extract get_input for now
+ for (Entry<String, String> entry : v.entrySet()) {
+ // only include get_input for now
+ if ( ModelConstants.GET_INPUT_TAG.equalsIgnoreCase ( entry.getKey() ) ) {
+ CommandProperty cp = new CommandProperty();
+ cp.setDisplayName(entry.getValue());
+ cp.setCommand(entry.getKey());
+ cp.setInputName(k);
+ (vfModule.getCommands()).put(k,cp);
+ }
+ }
+ }
+ }
+ }
+ catch ( Exception e ) {
+ LOG.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + " Unable to parse VF Module properties: e=" +
+ e.toString());
+ }*/
+ return vfModule;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/VidWorkflow.java b/vid-app-common/src/main/java/org/onap/vid/model/VidWorkflow.java
new file mode 100644
index 000000000..985289b4a
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/VidWorkflow.java
@@ -0,0 +1,83 @@
+package org.onap.vid.model;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.openecomp.portalsdk.core.domain.support.DomainVo;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Set;
+
+@Entity
+@Table(name = "vid_workflow")
+public class VidWorkflow extends DomainVo {
+
+ private String wokflowName;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "WORKFLOW_DB_ID")
+ @JsonIgnore
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ @Column(name = "CREATED_DATE")
+ @JsonIgnore
+ public Date getCreated() {
+ return super.getCreated();
+ }
+
+ @Override
+ @Column(name = "MODIFIED_DATE")
+ @JsonIgnore
+ public Date getModified() {
+ return super.getModified();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getCreatedId() {
+ return super.getCreatedId();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getModifiedId() {
+ return super.getModifiedId();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Serializable getAuditUserId() {
+ return super.getAuditUserId();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Long getRowNum() {
+ return super.getRowNum();
+ }
+
+ @Override
+ @Transient
+ @JsonIgnore
+ public Set getAuditTrail() {
+ return super.getAuditTrail();
+ }
+
+ @Column(name = "WORKFLOW_APP_NAME")
+ public String getWokflowName() {
+ return wokflowName;
+ }
+
+ public void setWokflowName(String wokflowName) {
+ this.wokflowName = wokflowName;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/VolumeGroup.java b/vid-app-common/src/main/java/org/onap/vid/model/VolumeGroup.java
new file mode 100644
index 000000000..969c287ce
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/VolumeGroup.java
@@ -0,0 +1,196 @@
+/*-
+ * ============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.model;
+
+import org.onap.vid.asdc.beans.tosca.Group;
+
+/**
+ * The Class VolumeGroup.
+ */
+public class VolumeGroup {
+
+ /** The uuid. */
+ private String uuid;
+
+ /** The invariant uuid. */
+ private String invariantUuid;
+
+ /** The description. */
+ private String description;
+
+ /** The name. */
+ private String name;
+
+ /** The version. */
+ private String version;
+
+ /** The customization uuid. */
+ private String customizationUuid;
+
+ /** The customization uuid. */
+ private String modelCustomizationName;
+ /**
+ * Instantiates a new volume group.
+ */
+ public VolumeGroup() {}
+
+ /**
+ * Gets the uuid.
+ *
+ * @return the uuid
+ */
+ public String getUuid() {
+ return uuid;
+ }
+ /**
+ * Gets the customization uuid.
+ *
+ * @return the customization uuid
+ */
+ public String getCustomizationUuid() {
+ return customizationUuid;
+ }
+ /**
+ * Gets the customization name.
+ *
+ * @return the customization name
+ */
+ public String getModelCustomizationName() {
+ return modelCustomizationName;
+ }
+ /**
+ * Gets the invariant uuid.
+ *
+ * @return the invariant uuid
+ */
+ public String getInvariantUuid() {
+ return invariantUuid;
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the version.
+ *
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Sets the uuid.
+ *
+ * @param uuid the new uuid
+ */
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ /**
+ * Sets the invariant uuid.
+ *
+ * @param invariantUuid the new invariant uuid
+ */
+ public void setInvariantUuid(String invariantUuid) {
+ this.invariantUuid = invariantUuid;
+ }
+
+ /**
+ * Sets the description.
+ *
+ * @param description the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Sets the name.
+ *
+ * @param name the new name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the version.
+ *
+ * @param version the new version
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+ /**
+ * Sets the customization uuid.
+ *
+ * @param u the new customization uuid
+ */
+ public void setCustomizationUuid(String u) {
+ this.customizationUuid = u;
+
+ }
+ /**
+ * Sets the customization name.
+ *
+ * @param u the new customization name
+ */
+ public void setModelCustomizationName(String u) {
+ this.modelCustomizationName = u;
+
+ }
+ /**
+ * Extract volume group.
+ *
+ * @param group the group
+ * @return the volume group
+ */
+ public static VolumeGroup extractVolumeGroup(String modelCustomizationName, Group group) {
+ final VolumeGroup volumeGroup = new VolumeGroup();
+
+ volumeGroup.setUuid(group.getMetadata().getVfModuleModelUUID());
+ volumeGroup.setInvariantUuid(group.getMetadata().getVfModuleModelInvariantUUID());
+ volumeGroup.setDescription(group.getMetadata().getDescription());
+ volumeGroup.setName(group.getMetadata().getVfModuleModelName());
+ volumeGroup.setVersion(group.getMetadata().getVfModuleModelVersion());
+ volumeGroup.setCustomizationUuid(group.getMetadata().getVfModuleModelCustomizationUUID());
+ volumeGroup.setModelCustomizationName(modelCustomizationName);
+ return volumeGroup;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Workflow.java b/vid-app-common/src/main/java/org/onap/vid/model/Workflow.java
new file mode 100644
index 000000000..346138dc0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/model/Workflow.java
@@ -0,0 +1,47 @@
+package org.onap.vid.model;
+
+
+import java.util.Collection;
+
+public class Workflow {
+ //Private members:
+ private int id;
+ private String workflowName;
+ private Collection<String> vnfNames;
+
+
+ //Constructors:
+ public Workflow() {}
+
+ public Workflow(int id, String workflowName, Collection<String> vnfNames) {
+ this.id = id;
+ this.workflowName = workflowName;
+ this.vnfNames = vnfNames;
+ }
+
+
+ //Setters and getters:
+ public int getId() {
+ return id;
+ }
+
+ public String getWorkflowName() {
+ return workflowName;
+ }
+
+ public Collection<String> getVnfNames() {
+ return this.vnfNames;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public void setWorkflowName(String workflowName) {
+ this.workflowName = workflowName;
+ }
+
+ public void setVnfName(Collection<String> vnfNames) {
+ this.vnfNames = vnfNames;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
new file mode 100644
index 000000000..c197299ff
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
@@ -0,0 +1,99 @@
+package org.onap.vid.mso;
+
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.controller.OperationalEnvironmentController;
+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.Request;
+import org.onap.vid.mso.rest.RequestDetails;
+import org.onap.vid.mso.rest.Task;
+
+import java.util.List;
+
+public interface MsoBusinessLogic {
+
+ // this function should get params from tosca and send them to instance at mso, then return success response.
+ MsoResponseWrapper createSvcInstance(RequestDetails msoRequest) throws Exception;
+
+ MsoResponseWrapper createVnf(RequestDetails requestDetails, String serviceInstanceId) throws Exception;
+
+ MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception;
+
+ MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception;
+
+ MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception;
+
+ MsoResponseWrapper createConfigurationInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception;
+
+ MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception;
+
+ MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception;
+
+ MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String vfModuleId) throws Exception;
+
+ MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String volumeGroupId)throws Exception;
+
+ MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String serviceInstanceId, String networkInstanceId) throws Exception;
+
+ MsoResponseWrapper getOrchestrationRequest(String requestId)throws Exception;
+
+ MsoResponseWrapper getOrchestrationRequests(String filterString)throws Exception;
+
+ List<Request> getOrchestrationRequestsForDashboard()throws Exception;
+
+ List<Task> getManualTasksByRequestId(String originalRequestId)throws Exception;
+
+ MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String taskId)throws Exception;
+
+ MsoResponseWrapper activateServiceInstance(RequestDetails requestDetails, String serviceInstanceId)throws Exception;
+
+ MsoResponseWrapperInterface updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception;
+
+ MsoResponseWrapperInterface replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception;
+
+ MsoResponseWrapperInterface updateVnfSoftware(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception;
+
+ MsoResponseWrapperInterface updateVnfConfig(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception;
+
+ MsoResponseWrapper deleteConfiguration(
+ RequestDetails requestDetails,
+ String serviceInstanceId,
+ String configurationId) throws Exception;
+
+ MsoResponseWrapper setConfigurationActiveStatus(
+ RequestDetails requestDetails,
+ String serviceInstanceId,
+ String configurationId,
+ boolean isActivate) throws Exception;
+
+ MsoResponseWrapper setPortOnConfigurationStatus(
+ RequestDetails requestDetails,
+ String serviceInstanceId,
+ String configurationId,
+ boolean isEnable) throws Exception;
+
+ RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentActivationRequestDetails(OperationalEnvironmentActivateInfo details);
+
+ String getOperationalEnvironmentActivationPath(OperationalEnvironmentActivateInfo details);
+
+ RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentDeactivationRequestDetails(OperationalEnvironmentDeactivateInfo details);
+
+ String getCloudResourcesRequestsStatusPath(String requestId);
+
+ String getOperationalEnvironmentDeactivationPath(OperationalEnvironmentDeactivateInfo details);
+
+ String getOperationalEnvironmentCreationPath();
+
+ RequestDetailsWrapper<OperationEnvironmentRequestDetails> convertParametersToRequestDetails(OperationalEnvironmentController.OperationalEnvironmentCreateBody input, String userId);
+
+ MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception;
+
+ MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception;
+
+ MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails , String serviceInstanceId, boolean isActivate)throws Exception;
+
+ RequestDetailsWrapper generateInPlaceMsoRequest(org.onap.vid.changeManagement.RequestDetails requestDetails) throws Exception;
+
+ RequestDetailsWrapper generateConfigMsoRequest(org.onap.vid.changeManagement.RequestDetails requestDetails) throws Exception;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
new file mode 100644
index 000000000..6ad6b5fd0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
@@ -0,0 +1,800 @@
+package org.onap.vid.mso;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.onap.vid.changeManagement.ChangeManagementRequest;
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.controller.OperationalEnvironmentController;
+import org.onap.vid.domain.mso.RequestInfo;
+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.*;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.ws.rs.BadRequestException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.regex.Pattern;
+
+import static org.onap.vid.changeManagement.ChangeManagementRequest.MsoChangeManagementRequest;
+import static org.onap.vid.controller.MsoController.*;
+import static org.onap.vid.mso.MsoProperties.*;
+
+public class MsoBusinessLogicImpl implements MsoBusinessLogic {
+
+ /**
+ * The Constant dateFormat.
+ */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+ final static Pattern SOFTWARE_VERSION_PATTERN = Pattern.compile("^[A-Za-z0-9.\\-]+$");
+ final static Pattern NUMBER_PATTERN = Pattern.compile("^[0-9]+$");
+ private static final String ACTIVATE = "/activate";
+ private static final String DEACTIVATE = "/deactivate";
+ private static final String ENABLE_PORT = "/enablePort";
+ private static final String DISABLE_PORT = "/disablePort";
+ private final static String RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT = "operationalEnvironment";
+ private final static String SOURCE_OPERATIONAL_ENVIRONMENT = "VID";
+ final static private ObjectMapper objectMapper = new ObjectMapper();
+ /**
+ * The Mso REST client
+ * This should be replaced with mso client factory.
+ */
+ private final MsoInterface msoClientInterface;
+ /**
+ * The logger.
+ */
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoBusinessLogicImpl.class);
+
+ @Autowired
+ public MsoBusinessLogicImpl(MsoInterface msoClientInterface) {
+ this.msoClientInterface = msoClientInterface;
+ }
+
+ static String validateEndpointPath(String endpointEnvVariable) {
+ String endpoint = SystemProperties.getProperty(endpointEnvVariable);
+ if (endpoint == null || endpoint.isEmpty()) {
+ throw new RuntimeException(endpointEnvVariable + " env variable is not defined");
+ }
+ return endpoint;
+ }
+
+ // this function should get params from tosca and send them to instance at mso, then return success response.
+ @Override
+ public MsoResponseWrapper createSvcInstance(RequestDetails msoRequest) throws Exception {
+ String methodName = "createSvcInstance ";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint;
+ try {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ } catch (Exception exception) {
+ throw exception;
+ }
+
+ return msoClientInterface.createSvcInstance(msoRequest, endpoint);
+ }
+
+ void validateLineOfBusiness(RequestDetails requestDetails) {
+
+ Object value = requestDetails.getAdditionalProperties();
+
+ for(String prop: ImmutableList.of("requestDetails", "lineOfBusiness", "lineOfBusinessName")) {
+ if(value==null ||!(value instanceof Map)) {
+ value = null;
+ break;
+ }
+ else {
+ value = ((Map)value).get(prop);
+ }
+ }
+
+ if(value == null || value.toString().isEmpty()) {
+ throw new BadRequestException("lineOfBusiness is required");
+ }
+
+ }
+
+ @Override
+ public MsoResponseWrapper createVnf(RequestDetails requestDetails, String serviceInstanceId) throws Exception {
+ String methodName = "createVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint;
+ try {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE);
+ } catch (Exception exception) {
+ throw exception;
+ }
+
+ String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ return msoClientInterface.createVnf(requestDetails, vnf_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception {
+ String methodName = "createNwInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint;
+ try {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
+ } catch (Exception exception) {
+ throw exception;
+ }
+
+ String nw_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ return msoClientInterface.createNwInstance(requestDetails, nw_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception {
+ String methodName = "createVolumeGroupInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint;
+ try {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
+ } catch (Exception exception) {
+ throw exception;
+ }
+
+ String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ vnf_endpoint = vnf_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+
+ return msoClientInterface.createVolumeGroupInstance(requestDetails, vnf_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception {
+ String methodName = "createVfModuleInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint;
+ try {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
+ } catch (Exception exception) {
+ throw exception;
+ }
+
+ String partial_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ String vf_module_endpoint = partial_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+
+ return msoClientInterface.createVfModuleInstance(requestDetails, vf_module_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createConfigurationInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception {
+ String methodName = "createConfigurationInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATIONS);
+ endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId);
+
+ return msoClientInterface.createConfigurationInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception {
+ String methodName = "deleteSvcInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint;
+ try {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ } catch (Exception exception) {
+ throw exception;
+ }
+
+ String svc_endpoint = endpoint + "/" + serviceInstanceId;
+
+ return msoClientInterface.deleteSvcInstance(requestDetails, svc_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception {
+ String methodName = "deleteVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint;
+ try {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE);
+ } catch (Exception exception) {
+ throw exception;
+ }
+ String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ vnf_endpoint = vnf_endpoint + '/' + vnfInstanceId;
+
+ return msoClientInterface.deleteVnf(requestDetails, vnf_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String vfModuleId) throws Exception {
+ String methodName = "deleteVfModule";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint;
+ try {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
+ } catch (Exception exception) {
+ throw exception;
+ }
+
+ String vf__modules_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId).replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+
+ String delete_vf_endpoint = vf__modules_endpoint + '/' + vfModuleId;
+
+ return msoClientInterface.deleteVfModule(requestDetails, delete_vf_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId, String volumeGroupId) throws Exception {
+ String methodName = "deleteVolumeGroupInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint;
+ try {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VOLUME_GROUP_INSTANCE);
+ } catch (Exception exception) {
+ throw exception;
+ }
+
+ String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ String vnf_endpoint = svc_endpoint.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
+ String delete_volume_group_endpoint = vnf_endpoint + "/" + volumeGroupId;
+
+ return msoClientInterface.deleteVolumeGroupInstance(requestDetails, delete_volume_group_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String serviceInstanceId, String networkInstanceId) throws Exception {
+ String methodName = "deleteNwInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint;
+ try {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_NETWORK_INSTANCE);
+ } catch (Exception exception) {
+ throw exception;
+ }
+
+ String svc_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ String delete_nw_endpoint = svc_endpoint + "/" + networkInstanceId;
+
+ return msoClientInterface.deleteNwInstance(requestDetails, delete_nw_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper getOrchestrationRequest(String requestId) throws Exception {
+ String methodName = "getOrchestrationRequest";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ MsoResponseWrapper w = null;
+ try {
+ String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ);
+ String path = p + "/" + requestId;
+
+ RestObject<String> restObjStr = new RestObject<String>();
+ String str = new String();
+ restObjStr.set(str);
+
+ msoClientInterface.getOrchestrationRequest(str, "", path, restObjStr);
+
+ return MsoUtil.wrapResponse(restObjStr);
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper getOrchestrationRequests(String filterString) throws Exception {
+ String methodName = "getOrchestrationRequest";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ MsoResponseWrapper w = null;
+ try {
+ String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS);
+ String path = p + filterString;
+
+ RestObject<String> restObjStr = new RestObject<String>();
+ String str = new String();
+ restObjStr.set(str);
+
+ msoClientInterface.getOrchestrationRequest(str, "", path, restObjStr);
+
+ return MsoUtil.wrapResponse(restObjStr);
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public List<Request> getOrchestrationRequestsForDashboard() throws Exception {
+ String methodName = "getOrchestrationRequestsForDashboard";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ List<Request> filteredOrchestrationRequests = new ArrayList<>();
+ try {
+ String path = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQS);
+ path += "filter=modelType:EQUALS:vnf";
+ RestObject<String> restObjStr = new RestObject<String>();
+ String str = new String();
+ restObjStr.set(str);
+
+ MsoResponseWrapper msoResponseWrapper = msoClientInterface.getOrchestrationRequestsForDashboard(str, "", path, restObjStr);
+ List<RequestWrapper> allOrchestrationRequests = deserializeOrchestrationRequestsJson(msoResponseWrapper.getEntity());
+
+ ;
+ for (RequestWrapper currentRequest : allOrchestrationRequests) {
+ if ((currentRequest.getRequest() != null) && (currentRequest.getRequest().getRequestScope() == Request.RequestScope.VNF) && ((currentRequest.getRequest().getRequestType() ==
+ Request.RequestType.REPLACE_INSTANCE) || (currentRequest.getRequest().getRequestType() ==
+ Request.RequestType.UPDATE_INSTANCE))) {
+ filteredOrchestrationRequests.add(currentRequest.getRequest());
+ }
+ }
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ }
+ return filteredOrchestrationRequests;
+
+ }
+
+ private List<RequestWrapper> deserializeOrchestrationRequestsJson(String orchestrationRequestsJson) throws Exception {
+ String methodName = "deserializeOrchestrationRequestsJson";
+ logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true);
+ RequestList requestList = mapper.readValue(orchestrationRequestsJson, RequestList.class);
+ return requestList.getRequestList();
+ }
+
+
+ @Override
+ public List<Task> getManualTasksByRequestId(String originalRequestId) throws Exception {
+ String methodName = "getManualTasksByRequestId";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+ String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_MAN_TASKS);
+ String path = p + "?originalRequestId=" + originalRequestId;
+
+ RestObject<String> restObjStr = new RestObject<String>();
+ String str = new String();
+ restObjStr.set(str);
+
+ MsoResponseWrapper msoResponseWrapper = msoClientInterface.getManualTasksByRequestId(str, "", path, restObjStr);
+ return deserializeManualTasksJson(msoResponseWrapper.getEntity());
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ private List<Task> deserializeManualTasksJson(String manualTasksJson) throws Exception {
+ String methodName = "deserializeManualTasksJson";
+ logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ ObjectMapper mapper = new ObjectMapper();
+ TaskList taskList = mapper.readValue(manualTasksJson, TaskList.class);
+ return taskList.getTaskList();
+ }
+
+
+ @Override
+ public MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String taskId) throws Exception {
+ String methodName = "completeManualTask";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ MsoResponseWrapper w = null;
+ try {
+ String p = SystemProperties.getProperty(MsoProperties.MSO_REST_API_GET_MAN_TASKS);
+ String path = p + "/" + taskId + "/complete";
+
+ RestObject<String> restObjStr = new RestObject<String>();
+ String str = new String();
+ restObjStr.set(str);
+
+ msoClientInterface.completeManualTask(requestDetails, str, "", path, restObjStr);
+
+ return MsoUtil.wrapResponse(restObjStr);
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper activateServiceInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception {
+ String methodName = "activateServiceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ try {
+ String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String activateServicePath = serviceEndpoint + "/" + serviceInstanceId + "/activate";
+
+ RestObject<String> restObjStr = new RestObject<>();
+ String str = "";
+ restObjStr.set(str);
+
+ msoClientInterface.setServiceInstanceStatus(requestDetails, str, "", activateServicePath, restObjStr);
+
+ return MsoUtil.wrapResponse(restObjStr);
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+
+ @Override
+ public MsoResponseWrapperInterface updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception {
+ String methodName = "updateVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint;
+ try {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_INSTANCE);
+ } catch (Exception exception) {
+ throw exception;
+ }
+ String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ vnf_endpoint = vnf_endpoint + '/' + vnfInstanceId;
+ return msoClientInterface.updateVnf(requestDetails, vnf_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapperInterface replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception {
+ String methodName = "replaceVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint;
+ try {
+ endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE);
+ } catch (Exception exception) {
+ throw exception;
+ }
+ String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ vnf_endpoint = vnf_endpoint.replace(VNF_INSTANCE_ID, vnfInstanceId);
+ vnf_endpoint = vnf_endpoint.replace(REQUEST_TYPE, MsoChangeManagementRequest.REPLACE);
+ return msoClientInterface.replaceVnf(requestDetails, vnf_endpoint);
+ }
+
+ public RequestDetailsWrapper generateInPlaceMsoRequest(org.onap.vid.changeManagement.RequestDetails requestDetails) throws Exception {
+ validateUpdateVnfSoftwarePayload(requestDetails);
+ RequestDetails inPlaceSoftwareUpdateRequest = new RequestDetails();
+ inPlaceSoftwareUpdateRequest.setCloudConfiguration(requestDetails.getCloudConfiguration());
+ inPlaceSoftwareUpdateRequest.setRequestParameters(requestDetails.getRequestParameters());
+ inPlaceSoftwareUpdateRequest.setRequestInfo(requestDetails.getRequestInfo());
+ RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
+ requestDetailsWrapper.requestDetails = inPlaceSoftwareUpdateRequest;
+ return requestDetailsWrapper;
+ }
+
+ @Override
+ public RequestDetailsWrapper generateConfigMsoRequest(org.onap.vid.changeManagement.RequestDetails requestDetails) throws Exception {
+ validateUpdateVnfConfig(requestDetails);
+ RequestDetails ConfigUpdateRequest = new RequestDetails();
+ ConfigUpdateRequest.setRequestParameters(requestDetails.getRequestParameters());
+ ConfigUpdateRequest.setRequestInfo(requestDetails.getRequestInfo());
+ RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
+ requestDetailsWrapper.requestDetails = ConfigUpdateRequest;
+ return requestDetailsWrapper;
+ }
+
+ @Override
+ public MsoResponseWrapperInterface updateVnfSoftware(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception {
+ String methodName = "updateVnfSoftware";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ String vnf_endpoint = getChangeManagementEndpoint(serviceInstanceId, vnfInstanceId, MsoChangeManagementRequest.SOFTWARE_UPDATE); //workflow name in mso is different than workflow name in vid UI
+ RequestDetailsWrapper finalRequestDetails = generateInPlaceMsoRequest(requestDetails);
+ return msoClientInterface.changeManagementUpdate(finalRequestDetails, vnf_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapperInterface updateVnfConfig(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) throws Exception {
+ String methodName = "updateVnfConfig";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ RequestDetailsWrapper finalRequestDetails = generateConfigMsoRequest(requestDetails);
+ String vnf_endpoint = getChangeManagementEndpoint(serviceInstanceId, vnfInstanceId, MsoChangeManagementRequest.CONFIG_UPDATE);
+ return msoClientInterface.changeManagementUpdate(finalRequestDetails, vnf_endpoint);
+ }
+
+ private String getChangeManagementEndpoint(String serviceInstanceId, String vnfInstanceId, String vnfRequestType) {
+ String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE);
+ String vnf_endpoint = endpoint.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
+ vnf_endpoint = vnf_endpoint.replace(VNF_INSTANCE_ID, vnfInstanceId);
+ vnf_endpoint = vnf_endpoint.replace(REQUEST_TYPE, vnfRequestType);
+ return vnf_endpoint;
+ }
+
+ private Map getChangeManagementPayload(RequestDetails requestDetails, String message) throws Exception{
+ if(requestDetails.getRequestParameters()==null||requestDetails.getRequestParameters().getAdditionalProperties()==null){
+ throw new BadRequestException(message);
+ }
+ Object payloadRaw=requestDetails.getRequestParameters().getAdditionalProperties().get("payload");
+ try{
+ return objectMapper.readValue((String)payloadRaw,Map.class);
+ }
+ catch(Exception exception){
+ throw new BadRequestException(message);
+ }
+ }
+
+ private void validateUpdateVnfSoftwarePayload(RequestDetails requestDetails) throws Exception {
+ final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.VNF_IN_PLACE_SOFTWARE_UPDATE + " request";
+
+ Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg);
+ validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "existing-software-version", SOFTWARE_VERSION_PATTERN);
+ validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "new-software-version", SOFTWARE_VERSION_PATTERN);
+
+ //if "operations-timeout" is not integer, trying to read it as String that represent a number
+ if (!(payload.get("operations-timeout") instanceof Integer)) {
+ validateUpdateVnfSoftwarePayloadProperty(payload, noValidPayloadMsg, "operations-timeout", NUMBER_PATTERN);
+ }
+
+ }
+
+ private void validateUpdateVnfSoftwarePayloadProperty(Map payload, String noValidPayloadMsg, String propertyName, Pattern pattern) {
+ Object forValidation = payload.get(propertyName);
+ final String noValidPayloadPropertyMsg = noValidPayloadMsg + ", " + propertyName + " property is not valid";
+ if (!(forValidation instanceof String)) {
+ throw new BadRequestException(noValidPayloadPropertyMsg);
+ }
+ if (!pattern.matcher((String) forValidation).matches()) {
+ throw new BadRequestException(noValidPayloadPropertyMsg);
+ }
+ }
+
+ private void validateUpdateVnfConfig(RequestDetails requestDetails) throws Exception {
+ final String noValidPayloadMsg = "No valid payload in " + ChangeManagementRequest.CONFIG_UPDATE + " request";
+
+ Map payload = getChangeManagementPayload(requestDetails, noValidPayloadMsg);
+ validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "request-parameters");
+ validateConfigUpdateVnfPayloadProperty(payload, noValidPayloadMsg, "configuration-parameters");
+ }
+
+ private void validateConfigUpdateVnfPayloadProperty(Map payload, String noValidPayloadMsg, String propertyName) {
+ Object forValidation = payload.get(propertyName);
+ final String noValidPayloadPropertyMsg = noValidPayloadMsg+ ", "+ propertyName + " property is not valid";
+ if(!payload.containsKey(propertyName)) {
+ throw new BadRequestException( noValidPayloadPropertyMsg);
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper deleteConfiguration(
+ RequestDetails requestDetails,
+ String serviceInstanceId,
+ String configurationId) throws Exception {
+
+ String methodName = "deleteConfiguration";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE);
+ endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId);
+ endpoint = endpoint.replace(CONFIGURATION_ID, configurationId);
+
+ return msoClientInterface.deleteConfiguration(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper setConfigurationActiveStatus(
+ RequestDetails requestDetails,
+ String serviceInstanceId,
+ String configurationId,
+ boolean isActivate) throws Exception {
+
+ String methodName = "setConfigurationActiveStatus";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE);
+ endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId);
+ endpoint = endpoint.replace(CONFIGURATION_ID, configurationId);
+
+ String isActivateState = (isActivate ? ACTIVATE : DEACTIVATE);
+ endpoint = endpoint + isActivateState;
+
+ return msoClientInterface.setConfigurationActiveStatus(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails , String serviceInstanceId, boolean isActivate)throws Exception{
+ String methodName = "setServiceInstanceStatus";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ try {
+ String serviceEndpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String endpoint = serviceEndpoint + "/" + serviceInstanceId;
+
+ String isActivateState = (isActivate ? ACTIVATE : DEACTIVATE);
+ endpoint = endpoint + isActivateState;
+
+
+ RestObject<String> restObjStr = new RestObject<>();
+ String str = "";
+ restObjStr.set(str);
+
+ msoClientInterface.setServiceInstanceStatus(requestDetails , str, "", endpoint, restObjStr);
+
+ return MsoUtil.wrapResponse(restObjStr);
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper setPortOnConfigurationStatus(
+ RequestDetails requestDetails,
+ String serviceInstanceId,
+ String configurationId,
+ boolean isEnable) throws Exception {
+ String methodName = "setPortOnConfigurationStatus";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_CONFIGURATION_INSTANCE);
+ endpoint = endpoint.replace(SVC_INSTANCE_ID, serviceInstanceId);
+ endpoint = endpoint.replace(CONFIGURATION_ID, configurationId);
+
+ String isEnablePortStatus = (isEnable ? ENABLE_PORT : DISABLE_PORT);
+ endpoint = endpoint + isEnablePortStatus;
+
+ return msoClientInterface.setPortOnConfigurationStatus(requestDetails, endpoint);
+ }
+
+
+ @Override
+ public RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentActivationRequestDetails(OperationalEnvironmentActivateInfo details) {
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setAdditionalProperty("resourceType", RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT);
+ requestInfo.setSource(SOURCE_OPERATIONAL_ENVIRONMENT);
+ requestInfo.setRequestorId(details.getUserId());
+ requestDetails.setRequestInfo(requestInfo);
+
+ org.onap.vid.domain.mso.RelatedInstance relatedInstance = new org.onap.vid.domain.mso.RelatedInstance();
+ relatedInstance.setAdditionalProperty("resourceType", RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT);
+ relatedInstance.setInstanceId(details.getRelatedInstanceId());
+ relatedInstance.setInstanceName(details.getRelatedInstanceName());
+ requestDetails.setAdditionalProperty("relatedInstanceList", Collections.singletonList(ImmutableMap.of("relatedInstance", relatedInstance)));
+
+ org.onap.vid.domain.mso.RequestParameters requestParameters = new org.onap.vid.domain.mso.RequestParameters();
+ requestParameters.setUserParams(null);
+ requestParameters.setAdditionalProperty("operationalEnvironmentType", "VNF");
+ requestParameters.setAdditionalProperty("workloadContext", details.getWorkloadContext());
+ requestParameters.setAdditionalProperty("manifest", details.getManifest());
+ requestDetails.setRequestParameters(requestParameters);
+
+ RequestDetailsWrapper<RequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails);
+
+ debugRequestDetails(requestDetailsWrapper);
+
+ return requestDetailsWrapper;
+ }
+
+ @Override
+ public String getOperationalEnvironmentActivationPath(OperationalEnvironmentActivateInfo details) {
+ String path = validateEndpointPath(MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE);
+ path = path.replace("<operational_environment_id>", details.getOperationalEnvironmentId());
+ return path;
+ }
+
+ @Override
+ public RequestDetailsWrapper<RequestDetails> createOperationalEnvironmentDeactivationRequestDetails(OperationalEnvironmentDeactivateInfo details) {
+ RequestDetails requestDetails = new RequestDetails();
+
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setAdditionalProperty("resourceType", RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT);
+ requestInfo.setSource(SOURCE_OPERATIONAL_ENVIRONMENT);
+ requestInfo.setRequestorId(details.getUserId());
+ requestDetails.setRequestInfo(requestInfo);
+
+ org.onap.vid.domain.mso.RequestParameters requestParameters = new org.onap.vid.domain.mso.RequestParameters();
+ requestParameters.setUserParams(null);
+ requestParameters.setAdditionalProperty("operationalEnvironmentType", "VNF");
+ requestDetails.setRequestParameters(requestParameters);
+ RequestDetailsWrapper<RequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails);
+ debugRequestDetails(requestDetailsWrapper);
+ return requestDetailsWrapper;
+ }
+
+ @Override
+ public String getCloudResourcesRequestsStatusPath(String requestId) {
+ String path = validateEndpointPath(MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS);
+ path = path.replace("<request_id>", requestId);
+ return path;
+ }
+
+ @Override
+ public String getOperationalEnvironmentDeactivationPath(OperationalEnvironmentDeactivateInfo details) {
+ String path = validateEndpointPath(MSO_REST_API_OPERATIONAL_ENVIRONMENT_DEACTIVATE);
+ path = path.replace("<operational_environment_id>", details.getOperationalEnvironmentId());
+ return path;
+ }
+
+ private void debugRequestDetails(Object requestDetails) {
+ if (logger.isDebugEnabled()) {
+ String requestDetailsAsString;
+ try {
+ requestDetailsAsString = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(requestDetails);
+ } catch (JsonProcessingException e) {
+ requestDetailsAsString = "error: cannot stringify RequestDetails";
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger, "requestDetailsAsString: {}", requestDetailsAsString);
+ }
+ }
+
+ @Override
+ public String getOperationalEnvironmentCreationPath() {
+ String path = validateEndpointPath(MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE);
+ return path;
+ }
+
+ @Override
+ public RequestDetailsWrapper<OperationEnvironmentRequestDetails> convertParametersToRequestDetails(OperationalEnvironmentController.OperationalEnvironmentCreateBody input, String userId) {
+ OperationEnvironmentRequestDetails.RequestInfo requestInfo = new OperationEnvironmentRequestDetails.RequestInfo(
+ RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT,
+ input.getInstanceName(),
+ SOURCE_OPERATIONAL_ENVIRONMENT,
+ userId);
+
+ OperationEnvironmentRequestDetails.RelatedInstance relatedInstance = new OperationEnvironmentRequestDetails.RelatedInstance(
+ RESOURCE_TYPE_OPERATIONAL_ENVIRONMENT,
+ input.getEcompInstanceId(),
+ input.getEcompInstanceName());
+
+ List<OperationEnvironmentRequestDetails.RelatedInstance> relatedInstanceList = Collections.singletonList((relatedInstance));
+
+ OperationEnvironmentRequestDetails.RequestParameters requestParameters = new OperationEnvironmentRequestDetails.RequestParameters(
+ input.getOperationalEnvironmentType(),
+ input.getTenantContext(),
+ input.getWorkloadContext());
+
+ OperationEnvironmentRequestDetails requestDetails = new OperationEnvironmentRequestDetails(requestInfo, relatedInstanceList, requestParameters);
+ RequestDetailsWrapper<OperationEnvironmentRequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails);
+ debugRequestDetails(requestDetailsWrapper);
+ return requestDetailsWrapper;
+ }
+
+ @Override
+ public MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception {
+ String methodName = "removeRelationshipFromServiceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String removeRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/removeRelationships";
+
+ return msoClientInterface.removeRelationshipFromServiceInstance(requestDetails, removeRelationshipsPath);
+ }
+
+ @Override
+ public MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String serviceInstanceId) throws Exception {
+ String methodName = "addRelationshipToServiceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String addRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/addRelationships";
+
+ return msoClientInterface.addRelationshipToServiceInstance(requestDetails, addRelationshipsPath);
+ }
+
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
new file mode 100644
index 000000000..2d09630f0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
@@ -0,0 +1,85 @@
+package org.onap.vid.mso;
+
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.mso.rest.RequestDetails;
+
+/**
+ * Created by pickjonathan on 21/06/2017.
+ */
+public interface MsoInterface {
+
+ /**
+ * This function will post MSO service with information about how to instantiate the requested service
+ * @param requestDetails The details about the service as they come from the web.
+ * @return MsoResponseWrapper containing information about the service instantiation
+ * --> success : see JSON at resources folder mso_create_instance_response.
+ * --> failure : would return 200 with failure data.
+ * @throws Exception
+ */
+ MsoResponseWrapper createSvcInstance(RequestDetails requestDetails, String endpoint) throws Exception;
+
+ /**
+ * will create a virtual network function using MSO service.
+ * @param requestDetails - information about the vnf to create
+ * @return - the response body recived from MSO
+ * @throws Exception
+ */
+ MsoResponseWrapper createVnf(RequestDetails requestDetails, String endpoint) throws Exception;
+
+ MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String endpoint) throws Exception;
+ /**
+ *
+ * @param requestDetails
+ * @param path
+ * @return
+ * @throws Exception
+ */
+ MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String path) throws Exception;
+
+ /**
+ *
+ * @param requestDetails
+ * @return
+ * @throws Exception
+ */
+ MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String endpoint) throws Exception;
+
+ MsoResponseWrapper createConfigurationInstance(RequestDetails requestDetails, String endpoint) throws Exception;
+
+ MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String endpoint) throws Exception;
+
+ MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String endpoint) throws Exception;
+
+ MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String endpoint) throws Exception;
+
+ MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String endpoint) throws Exception;
+
+ MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String endpoint) throws Exception;
+
+ void getOrchestrationRequest(String t, String sourceId, String endpoint, RestObject restObject) throws Exception;
+
+ MsoResponseWrapper getOrchestrationRequestsForDashboard(String t , String sourceId , String endpoint , RestObject restObject) throws Exception;
+
+ MsoResponseWrapper getManualTasksByRequestId(String t , String sourceId , String endpoint , RestObject restObject) throws Exception;
+
+ MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject restObject) throws Exception;
+
+ MsoResponseWrapper updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String vnf_endpoint) throws Exception;
+
+ MsoResponseWrapper replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String vnf_endpoint) throws Exception;
+
+ MsoResponseWrapper deleteConfiguration(RequestDetails requestDetails, String pmc_endpoint) throws Exception;
+
+ MsoResponseWrapper setConfigurationActiveStatus(RequestDetails requestDetails, String endpoint) throws Exception;
+
+ MsoResponseWrapper setPortOnConfigurationStatus(RequestDetails requestDetails, String endpoint) throws Exception;
+
+ void setServiceInstanceStatus(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject<String> restObject) throws Exception;
+
+ MsoResponseWrapperInterface changeManagementUpdate(RequestDetailsWrapper requestDetails, String endpoint) throws Exception;
+
+ MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String endpoint) throws Exception;
+
+ MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath) throws Exception;
+}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
new file mode 100644
index 000000000..607d84194
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
@@ -0,0 +1,119 @@
+/*-
+ * ============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.mso;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+/**
+ * The Class MsoProperties.
+ */
+public class MsoProperties extends SystemProperties {
+
+ /** The Constant MSO_SERVER_URL. */
+ //VID Properties related to MSO
+ public static final String MSO_SERVER_URL = "mso.server.url";
+
+ /** The Constant MSO_DME2_SERVER_URL. */
+ public static final String MSO_DME2_SERVER_URL = "mso.dme2.server.url";
+
+ /** The Constant MSO_DME2_CLIENT_TIMEOUT. */
+ public static final String MSO_DME2_CLIENT_TIMEOUT = "mso.dme2.client.timeout";
+
+ /** The Constant MSO_DME2_CLIENT_READ_TIMEOUT. */
+ public static final String MSO_DME2_CLIENT_READ_TIMEOUT = "mso.dme2.client.read.timeout";
+
+ /** The Constant MSO_SERVER_URL_DEFAULT. */
+ public static final String MSO_SERVER_URL_DEFAULT= "";
+
+ /** The Constant MSO_POLLING_INTERVAL_MSECS. */
+ // number of msecs to wait between polling requests
+ public static final String MSO_POLLING_INTERVAL_MSECS = "mso.polling.interval.msecs";
+
+ /** The Constant MSO_POLLING_INTERVAL_MSECS_DEFAULT. */
+ public static final String MSO_POLLING_INTERVAL_MSECS_DEFAULT = "60000";
+
+ /** The Constant MSO_DME2_ENABLED. */
+ public static final String MSO_DME2_ENABLED = "mso.dme2.enabled";
+
+ /** The Constant MSO_MAX_POLLS. */
+ public static final String MSO_MAX_POLLS = "mso.max.polls";
+
+ /** The Constant MSO_MAX_POLLS_DEFAULT. */
+ public static final String MSO_MAX_POLLS_DEFAULT = "10"; //10
+
+ /** The Constant MSO_USER_NAME. */
+ public static final String MSO_USER_NAME = "mso.user.name"; //m03346
+
+ /** The Constant MSO_PASSWORD. */
+ public static final String MSO_PASSWORD = "mso.password.x";
+
+ /** The Constant MSO_REST_API_SVC_INSTANCE. */
+ public static final String MSO_REST_API_SVC_INSTANCE = "mso.restapi.svc.instance"; // /serviceInstances/v2
+
+ /** The Constant MSO_REST_API_VNF_INSTANCE. */
+ public static final String MSO_REST_API_VNF_INSTANCE = "mso.restapi.vnf.instance"; // /serviceInstances/v2/{service_instance_id}/vnfs
+
+ /** The Constant MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE. */
+ public static final String MSO_REST_API_VNF_CHANGE_MANAGEMENT_INSTANCE = "mso.restapi.vnf.changemanagement.instance"; // /serviceInstances/v2/{service_instance_id}/vnfs/{request_type}
+
+ /** The Constant MSO_REST_API_NETWORK_INSTANCE. */
+ public static final String MSO_REST_API_NETWORK_INSTANCE = "mso.restapi.network.instance"; // /serviceInstances/v2/{serviceInstanceId}/networks
+
+ /** The Constant MSO_REST_API_GET_ORC_REQ. */
+ public static final String MSO_REST_API_GET_ORC_REQ = "mso.restapi.get.orc.req";
+
+ /** The Constant MSO_REST_API_GET_ORC_REQS. */
+ public static final String MSO_REST_API_GET_ORC_REQS = "mso.restapi.get.orc.reqs";
+
+ /** The Constant MSO_REST_API_GET_MAN_TASK. */
+ public static final String MSO_REST_API_GET_MAN_TASKS = "mso.restapi.get.man.tasks";
+
+ /** The Constant MSO_REST_API_VF_MODULE_INSTANCE. */
+ public static final String MSO_REST_API_VF_MODULE_INSTANCE = "mso.restapi.vf.module.instance";
+
+ /** The Constant MSO_REST_API_VOLUME_GROUP_INSTANCE. */
+ public static final String MSO_REST_API_VOLUME_GROUP_INSTANCE = "mso.restapi.volume.group.instance"; //serviceInstances/v2/{serviceInstanceId}/volumeGroups
+
+ /** The Constant MSO_REST_API_CONFIGURATION_INSTANCE. */
+ public static final String MSO_REST_API_CONFIGURATIONS = "mso.restapi.configurations"; //serviceInstances/v5/{serviceInstanceId}/configurations/
+ public static final String MSO_REST_API_CONFIGURATION_INSTANCE = "mso.restapi.configuration.instance"; //serviceInstances/v5/{serviceInstanceId}/configurations/{configurationId}
+
+ /** The Constant MSO_REST_API_OPERATIONAL_ENVIRONMENT */
+ public static final String MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE = "mso.restapi.operationalEnvironment.activate";
+ public static final String MSO_REST_API_OPERATIONAL_ENVIRONMENT_DEACTIVATE = "mso.restapi.operationalEnvironment.deactivate";
+
+ /** The Constant MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE */
+ public static final String MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE = "mso.restapi.operationalEnvironment.create";
+
+ /** The Constant MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS */
+ public static final String MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS = "mso.restapi.operationalEnvironment.cloudResourcesRequests.status";
+
+ /** The logger. */
+ public EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoProperties.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper.java
new file mode 100644
index 000000000..b890114b5
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper.java
@@ -0,0 +1,129 @@
+/*-
+ * ============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.mso;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import javax.ws.rs.core.Response;
+
+/**
+ * This wrapper encapsulates the MSO response in the format expected by the pages.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "status",
+ "entity"
+})
+
+public class MsoResponseWrapper implements MsoResponseWrapperInterface {
+
+
+ public MsoResponseWrapper() {
+ }
+
+ public MsoResponseWrapper(Response response) {
+ setEntity(response.readEntity(String.class));
+ setStatus(response.getStatus());
+ }
+
+
+ /** The status. */
+ @JsonProperty("status")
+ private int status;
+
+ /** The entity. */
+ @JsonProperty("entity")
+ private String entity;
+
+ /**
+ * Gets the entity.
+ *
+ * @return the entity
+ */
+ @Override
+ @JsonProperty("entity")
+ public String getEntity() {
+ return entity;
+ }
+
+ /**
+ * Gets the status.
+ *
+ * @return the status
+ */
+ @Override
+ @JsonProperty("status")
+ public int getStatus() {
+ return status;
+ }
+
+ /**
+ * Sets the status.
+ *
+ * @param v the new status
+ */
+ @JsonProperty("status")
+ public void setStatus(int v) {
+ this.status = v;
+ }
+
+ /**
+ * Sets the entity.
+ *
+ * @param v the new entity
+ */
+ @JsonProperty("entity")
+ public void setEntity(String v) {
+ this.entity = v;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /**
+ * Gets the response.
+ *
+ * @return the response
+ */
+ @org.codehaus.jackson.annotate.JsonIgnore
+ @com.fasterxml.jackson.annotation.JsonIgnore
+ public String getResponse () {
+
+ StringBuilder b = new StringBuilder ("{ \"status\": ");
+ b.append(getStatus()).append(", \"entity\": " );
+ if (this.getEntity() == null || this.getEntity().isEmpty()) {
+ b.append("\"\"");
+ } else {
+ b.append(this.getEntity());
+ }
+ b.append("}");
+ return (b.toString());
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper2.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper2.java
new file mode 100644
index 000000000..5a73a048a
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapper2.java
@@ -0,0 +1,60 @@
+package org.onap.vid.mso;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@JsonPropertyOrder({
+ "status",
+ "entity"
+})
+
+/*
+This is a brother of MsoResponseWrapper. I (Ittay) think it's better.
+It is generic, immutable, and has some knowledge about RestObject.
+The serialized "entity" field may be either String or nested object.
+ */
+public class MsoResponseWrapper2<T> implements MsoResponseWrapperInterface {
+
+ final static ObjectMapper objectMapper = new ObjectMapper();
+
+ private final int status;
+ private final T entity;
+ private final String raw;
+
+ public MsoResponseWrapper2(RestObject<T> msoResponse) {
+ this.status = msoResponse.getStatusCode();
+ this.entity = msoResponse.get();
+ this.raw = msoResponse.getRaw();
+ }
+
+ public MsoResponseWrapper2(
+ @JsonProperty(value = "status", required = true) int status,
+ @JsonProperty(value = "entity", required = true) T entity) {
+ this.status = status;
+ this.entity = entity;
+ this.raw = null;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ @Override
+ @org.codehaus.jackson.annotate.JsonIgnore
+ @com.fasterxml.jackson.annotation.JsonIgnore
+ public String getResponse() {
+ try {
+ return objectMapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ return getEntity() != null ? getEntity().toString() : null;
+ }
+ }
+
+ @JsonProperty
+ public Object getEntity() {
+ return entity != null ? entity : raw;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapperInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapperInterface.java
new file mode 100644
index 000000000..ad251bdeb
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoResponseWrapperInterface.java
@@ -0,0 +1,15 @@
+package org.onap.vid.mso;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public interface MsoResponseWrapperInterface {
+ @JsonProperty("entity")
+ Object getEntity();
+
+ @JsonProperty("status")
+ int getStatus();
+
+ @org.codehaus.jackson.annotate.JsonIgnore
+ @com.fasterxml.jackson.annotation.JsonIgnore
+ String getResponse();
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java
new file mode 100644
index 000000000..eae705aba
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoUtil.java
@@ -0,0 +1,126 @@
+/*-
+ * ============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.mso;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.glassfish.jersey.client.ClientResponse;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+import static org.onap.vid.utils.Logging.getMethodName;
+
+/**
+ * The Class MsoUtil.
+ */
+public class MsoUtil {
+
+ /** The logger. */
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoUtil.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /**
+ * Wrap response.
+ *
+ * @param body the body
+ * @param statusCode the status code
+ * @return the mso response wrapper
+ */
+ public static MsoResponseWrapper wrapResponse ( String body, int statusCode ) {
+
+ MsoResponseWrapper w = new MsoResponseWrapper();
+ w.setStatus (statusCode);
+ w.setEntity(body);
+
+ return w;
+ }
+
+ /**
+ * Wrap response.
+ *
+ * @param cres the cres
+ * @return the mso response wrapper
+ */
+ public static MsoResponseWrapper wrapResponse (ClientResponse cres) {
+ String resp_str = "";
+ if ( cres != null ) {
+ resp_str = cres.readEntity(String.class);
+ }
+ int statuscode = cres.getStatus();
+ MsoResponseWrapper w = MsoUtil.wrapResponse ( resp_str, statuscode );
+ return (w);
+ }
+
+ /**
+ * Wrap response.
+ *
+ * @param rs the rs
+ * @return the mso response wrapper
+ */
+ public static MsoResponseWrapper wrapResponse (RestObject<String> rs) {
+ String resp_str = null;
+ int status = 0;
+ if ( rs != null ) {
+ resp_str = rs.get() != null ? rs.get() : rs.getRaw();
+ status = rs.getStatusCode();
+ }
+ MsoResponseWrapper w = MsoUtil.wrapResponse ( resp_str, status );
+ return (w);
+ }
+
+ /**
+ * Convert pojo to string.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @return the string
+ * @throws JsonProcessingException the json processing exception
+ */
+ public static <T> String convertPojoToString ( T t ) {
+
+ String methodName = "convertPojoToString";
+ ObjectMapper mapper = new ObjectMapper();
+ String r_json_str = "";
+ if ( t != null ) {
+ try {
+ r_json_str = mapper.writeValueAsString(t);
+ }
+ catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,getMethodName() + " Unable to parse object of type " + t.getClass().getName() + " as json", j);
+ }
+ }
+ return (r_json_str);
+ }
+
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java
new file mode 100644
index 000000000..8cee23b49
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java
@@ -0,0 +1,380 @@
+package org.onap.vid.mso;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.codec.binary.Base64;
+import org.eclipse.jetty.util.security.Password;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.onap.vid.client.HttpBasicClient;
+import org.onap.vid.client.HttpsBasicClient;
+import org.onap.vid.mso.rest.RequestDetails;
+import org.onap.vid.mso.rest.RestInterface;
+import org.onap.vid.utils.Logging;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.Response;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Date;
+
+import static org.onap.vid.utils.Logging.*;
+
+/**
+ * Created by pickjonathan on 26/06/2017.
+ */
+public class RestMsoImplementation implements RestInterface {
+
+ /**
+ * The logger.
+ */
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMsoImplementation.class);
+ final private EELFLogger outgoingRequestsLogger = Logging.getRequestsLogger("mso");
+
+ /**
+ * The Constant dateFormat.
+ */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The client. */
+ private static Client client = null;
+
+ /** The common headers. */
+ //private MultivaluedHashMap<String, Object> commonHeaders;
+ /**
+ * Instantiates a new mso rest interface.
+ */
+
+ @SuppressWarnings("Duplicates")
+ @Override
+ public MultivaluedHashMap<String, Object> initMsoClient()
+ {
+ final String methodname = "initRestClient()";
+
+ final String username = SystemProperties.getProperty(MsoProperties.MSO_USER_NAME);
+ final String password = SystemProperties.getProperty(MsoProperties.MSO_PASSWORD);
+ final String mso_url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL);
+ final String decrypted_password = Password.deobfuscate(password);
+
+ String authString = username + ":" + decrypted_password;
+
+ byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
+ String authStringEnc = new String(authEncBytes);
+
+ MultivaluedHashMap<String, Object> commonHeaders = new MultivaluedHashMap();
+ commonHeaders.put("Authorization", Collections.singletonList(("Basic " + authStringEnc)));
+ commonHeaders.put(requestIdHeaderKey, Collections.singletonList(getHttpServletRequest().getHeader(requestIdHeaderKey)));
+ //Pass calling application identifier to SO
+ commonHeaders.put("X-FromAppId", Collections.singletonList(SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME)));
+
+ boolean use_ssl = true;
+ if ( (mso_url != null) && ( !(mso_url.isEmpty()) ) ) {
+ if ( mso_url.startsWith("https")) {
+ use_ssl = true;
+ }
+ else {
+ use_ssl = false;
+ }
+ }
+ if (client == null) {
+
+ try {
+ if ( use_ssl ) {
+ //logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodname + " getting HttpsBasicClient with username=" + username
+ // + " password=" + password);
+ client = HttpsBasicClient.getClient();
+ }
+ else {
+ //logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodname + " getting HttpsBasicClient with username=" + username
+ // + " password=" + password);
+ client = HttpBasicClient.getClient();
+ }
+ } catch (Exception e) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodname + " Unable to get the SSL client");
+ }
+ }
+
+ return commonHeaders;
+ }
+
+ public <T> void Get (T t, String sourceId, String path, RestObject<T> restObject ) throws Exception {
+ String methodName = "Get";
+
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + " start");
+
+ String url="";
+ restObject.set(t);
+
+ url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+
+ MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
+ final Response cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ .get();
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, cres);
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if (status == 200 || status == 202) {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " REST api was successfull!");
+
+ } else {
+ throw new Exception(methodName + " with status="+ status + ", url= " + url );
+ }
+
+ logger.debug(EELFLoggerDelegate.debugLogger,methodName + " received status=" + status );
+
+ return;
+ }
+
+ public <T> RestObject<T> GetForObject(String sourceID, String path, Class<T> clazz) throws Exception {
+ final String methodName = getMethodName();
+ logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {}, {})", getMethodCallerName(), methodName, sourceID, path, clazz);
+
+ String url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " sending request to url= " + url);
+
+ MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
+ final Response cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ .get();
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.GET, url, cres);
+ final RestObject<T> restObject = cresToRestObject(cres, clazz);
+ int status = cres.getStatus();
+
+ if (status == 200 || status == 202) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " REST api was successfull!");
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with status="+status+", url="+url);
+ }
+
+ logger.debug(EELFLoggerDelegate.debugLogger,methodName + " received status=" + status );
+
+ return restObject;
+ }
+
+ @Override
+ public <T> void Delete(T t, RequestDetails r, String sourceID, String path, RestObject<T> restObject) {
+
+ String methodName = "Delete";
+ String url="";
+ Response cres = null;
+
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+ MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
+
+ url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url, r);
+ cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ //.entity(r)
+ .build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON)).invoke();
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres);
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if (status == 404) { // resource not found
+ String msg = "Resource does not exist...: " + cres.getStatus();
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg);
+ } else if (status == 200 || status == 204){
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + "Resource " + url + " deleted");
+ } else if (status == 202) {
+ String msg = "Delete in progress: " + status;
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg);
+ }
+ else {
+ String msg = "Deleting Resource failed: " + status;
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg);
+ }
+
+ try {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " No response entity, this is probably ok, e="
+ + e.getMessage());
+ }
+
+ }
+ catch (Exception e)
+ {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with url="+url+ ", Exception: " + e.toString());
+ throw e;
+
+ }
+ }
+
+ public <T> RestObject<T> PostForObject(Object requestDetails, String sourceID, String path, Class<T> clazz) throws RuntimeException {
+ logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {}, {}, {})", getMethodCallerName(), getMethodName(), requestDetails, sourceID, path, clazz);
+ RestObject<T> restObject = new RestObject<>();
+ Post(clazz, requestDetails, sourceID, path, restObject);
+ return restObject;
+ }
+
+ @Override
+ public <T> void Post(T t, Object r, String sourceID, String path, RestObject<T> restObject) throws RuntimeException {
+ logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {}, {}, {})", getMethodCallerName(), getMethodName(), t.getClass(), r, sourceID, path);
+ Post(t.getClass(), r, sourceID, path, restObject);
+ }
+
+ public Invocation.Builder prepareClient(String path, String methodName) {
+ MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
+
+ String url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " sending request to url= " + url);
+ // Change the content length
+ return client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders);
+ }
+
+
+
+ public <T> void Post(Class<?> tClass, Object requestDetails, String sourceID, String path, RestObject<T> restObject) throws RuntimeException {
+ String methodName = "Post";
+ String url="";
+
+ try {
+
+ MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
+
+ url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.POST, url, requestDetails);
+ // Change the content length
+ final Response cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ .post(Entity.entity(requestDetails, MediaType.APPLICATION_JSON));
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.POST, url, cres);
+
+ final RestObject<T> cresToRestObject = cresToRestObject(cres, tClass);
+ restObject.set(cresToRestObject.get());
+ restObject.setStatusCode(cresToRestObject.getStatusCode());
+ restObject.setRaw(cresToRestObject.getRaw());
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if ( status >= 200 && status <= 299 ) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!");
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!");
+
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with status="+status+", url="+url);
+ }
+
+ } catch (Exception e)
+ {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with url="+url+ ", Exception: " + e.toString());
+ throw e;
+
+ }
+
+ logger.debug(EELFLoggerDelegate.debugLogger, "end {}() => ({}){}", getMethodName(), tClass, restObject);
+ }
+
+ private <T> RestObject<T> cresToRestObject(Response cres, Class<?> tClass) {
+ RestObject<T> restObject = new RestObject<>();
+
+ String rawEntity = null;
+ try {
+ cres.bufferEntity();
+ rawEntity = cres.readEntity(String.class);
+ T t = (T) new ObjectMapper().readValue(rawEntity, tClass);
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+ try {
+ restObject.setRaw(rawEntity);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + getMethodCallerName() + " Error reading response entity as " + tClass + ": , e="
+ + e.getMessage() + ", Entity=" + rawEntity);
+ } catch (Exception e2) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + getMethodCallerName() + " No response entity, this is probably ok, e="
+ + e.getMessage());
+ }
+ }
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ return restObject;
+
+ }
+
+ @Override
+ public <T> void Put(T t, org.onap.vid.changeManagement.RequestDetailsWrapper r, String sourceID, String path, RestObject<T> restObject) throws Exception {
+
+ String methodName = "Put";
+ String url="";
+
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+// logRequest (r);
+ try {
+
+ MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
+
+ url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path;
+ Logging.logRequest(outgoingRequestsLogger, HttpMethod.PUT, url, r);
+ // Change the content length
+ final Response cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ //.header("content-length", 201)
+ //.header("X-FromAppId", sourceID)
+ .put(Entity.entity(r, MediaType.APPLICATION_JSON));
+
+ Logging.logResponse(outgoingRequestsLogger, HttpMethod.PUT, url, cres);
+
+ try {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " No response entity, this is probably ok, e="
+ + e.getMessage());
+ }
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if ( status >= 200 && status <= 299 ) {
+ logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!");
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!");
+
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with status="+status+", url="+url);
+ }
+
+ } catch (Exception e)
+ {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with url="+url+ ", Exception: " + e.toString());
+ throw e;
+
+ }
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/RestObject.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestObject.java
new file mode 100644
index 000000000..4e2bea050
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestObject.java
@@ -0,0 +1,131 @@
+/*-
+ * ============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.mso;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.MoreObjects;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+
+import javax.ws.rs.core.Response;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import static org.onap.vid.utils.Logging.getMethodCallerName;
+
+/**
+ * The Class RestObject.
+ *
+ * @param <T> the generic type
+ */
+public class RestObject<T> {
+
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ final static ObjectMapper objectMapper = new ObjectMapper();
+
+ /**
+ * Generic version of the RestObject class.
+ *
+ */
+ // T stands for "Type"
+ private T t;
+
+ // The string source of t, if available
+ private String rawT;
+
+ /** The status code. */
+ private int statusCode= 0;
+
+ public RestObject() {
+ }
+
+ public RestObject(Response cres, Class<?> tClass, EELFLoggerDelegate logger) {
+
+ String rawEntity = null;
+ try {
+ cres.bufferEntity();
+ rawEntity = cres.readEntity(String.class);
+ T t = (T) objectMapper.readValue(rawEntity, tClass);
+ this.set(t);
+ }
+ catch ( Exception e ) {
+ try {
+ this.setRaw(rawEntity);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + getMethodCallerName() + " Error reading response entity as " + tClass + ": , e="
+ + e.getMessage() + ", Entity=" + rawEntity);
+ } catch (Exception e2) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + getMethodCallerName() + " No response entity, this is probably ok, e="
+ + e.getMessage());
+ }
+ }
+
+ int status = cres.getStatus();
+ this.setStatusCode (status);
+ }
+
+
+ /**
+ * Sets the.
+ *
+ * @param t the t
+ */
+ public void set(T t) { this.t = t; }
+
+ /**
+ * Gets the.
+ *
+ * @return the t
+ */
+ public T get() { return t; }
+
+ /**
+ * Sets the status code.
+ *
+ * @param v the new status code
+ */
+ public void setStatusCode(int v) { this.statusCode = v; }
+
+ /**
+ * Gets the status code.
+ *
+ * @return the status code
+ */
+ public int getStatusCode() { return this.statusCode; }
+
+ public String getRaw() {
+ return rawT;
+ }
+
+ public void setRaw(String rawT) {
+ this.rawT = rawT;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("t", t)
+ .add("rawT", rawT)
+ .add("statusCode", statusCode)
+ .toString();
+ }
+}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfo.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfo.java
new file mode 100644
index 000000000..bca643a6d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfo.java
@@ -0,0 +1,33 @@
+package org.onap.vid.mso.model;
+
+import com.google.common.base.MoreObjects;
+import org.onap.vid.controller.OperationalEnvironmentController;
+
+public class OperationalEnvironmentActivateInfo extends OperationalEnvironmentController.OperationalEnvironmentActivateBody {
+ private final String userId;
+ private final String operationalEnvironmentId;
+
+ public OperationalEnvironmentActivateInfo(OperationalEnvironmentController.OperationalEnvironmentActivateBody o, String userId, String operationalEnvironmentId) {
+ super(o.getRelatedInstanceId(), o.getRelatedInstanceName(), o.getWorkloadContext(), o.getManifest());
+
+ this.userId = userId;
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public String getOperationalEnvironmentId() {
+ return operationalEnvironmentId;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("operationalEnvironmentId", operationalEnvironmentId)
+ .add("userId", userId)
+ .add("super", super.toString())
+ .toString();
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfo.java b/vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfo.java
new file mode 100644
index 000000000..1a756eda8
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfo.java
@@ -0,0 +1,29 @@
+package org.onap.vid.mso.model;
+
+import com.google.common.base.MoreObjects;
+
+public class OperationalEnvironmentDeactivateInfo {
+ private final String userId;
+ private final String operationalEnvironmentId;
+
+ public OperationalEnvironmentDeactivateInfo(String userId, String operationalEnvironmentId) {
+ this.userId = userId;
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public String getOperationalEnvironmentId() {
+ return operationalEnvironmentId;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("operationalEnvironmentId", operationalEnvironmentId)
+ .add("userId", userId)
+ .toString();
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java
new file mode 100644
index 000000000..f47e16fe0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/AsyncRequestStatus.java
@@ -0,0 +1,123 @@
+/*-
+ * ============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.mso.rest;
+
+//import java.util.HashMap;
+//import java.util.Map;
+//import javax.annotation.Generated;
+
+import org.onap.vid.domain.mso.InstanceIds;
+import org.onap.vid.domain.mso.RequestStatus;
+//import com.fasterxml.jackson.annotation.JsonAnyGetter;
+//import com.fasterxml.jackson.annotation.JsonAnySetter;
+//import com.fasterxml.jackson.annotation.JsonCreator;
+//import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+//import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+//import com.fasterxml.jackson.annotation.JsonValue;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+
+/**
+ * request structure.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+
+public class AsyncRequestStatus extends org.onap.vid.domain.mso.AsyncRequestStatus {
+
+
+ /** The instance ids. */
+ private InstanceIds instanceIds;
+
+ /** The request status. */
+ private RequestStatus requestStatus;
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.AsyncRequestStatus#getInstanceIds()
+ */
+ public InstanceIds getInstanceIds() {
+ return instanceIds;
+ }
+
+ /**
+ * Sets the instance ids.
+ *
+ * @param instanceIds the new instance ids
+ */
+ public void setInstanceIds(InstanceIds instanceIds) {
+ this.instanceIds = instanceIds;
+ }
+
+
+ /**
+ * (Required).
+ *
+ * @return The requestStatus
+ */
+ @JsonProperty("requestStatus")
+ public RequestStatus getRequestStatus() {
+ return requestStatus;
+ }
+
+ /**
+ * (Required).
+ *
+ * @param requestStatus The requestStatus
+ */
+ @JsonProperty("requestStatus")
+ public void setRequestStatus(RequestStatus requestStatus) {
+ this.requestStatus = requestStatus;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.AsyncRequestStatus#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.AsyncRequestStatus#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(getCorrelator()).append(getFinishTime()).append(instanceIds).append(getRequestId()).append(getRequestScope()).append(getRequestStatus()).append(getRequestType()).append(getStartTime()).append(getAdditionalProperties()).toHashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.AsyncRequestStatus#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof AsyncRequestStatus) == false) {
+ return false;
+ }
+ AsyncRequestStatus rhs = ((AsyncRequestStatus) other);
+ return new EqualsBuilder().append(getCorrelator(), rhs.getCorrelator()).append(getFinishTime(), rhs.getFinishTime()).append(instanceIds, rhs.instanceIds).append(getRequestId(), rhs.getRequestId()).append(getRequestScope(), rhs.getRequestScope()).append(getRequestStatus(), rhs.getRequestStatus()).append(getRequestType(), rhs.getRequestType()).append(getStartTime(), rhs.getStartTime()).append(getAdditionalProperties(), rhs.getAdditionalProperties()).isEquals();
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
new file mode 100644
index 000000000..9bb54035d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
@@ -0,0 +1,435 @@
+package org.onap.vid.mso.rest;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.changeManagement.MsoRequestDetails;
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.mso.*;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+
+/**
+ * Created by pickjonathan on 21/06/2017.
+ */
+public class MsoRestClientNew extends RestMsoImplementation implements MsoInterface {
+
+ /**
+ * The Constant dateFormat.
+ */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+ private final String ORIGINAL_REQUEST_ID = "originalRequestId";
+ /**
+ * The logger.
+ */
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestClientNew.class);
+
+ @Override
+ public MsoResponseWrapper createSvcInstance(RequestDetails requestDetails, String endpoint) throws Exception {
+ String methodName = "createSvcInstance ";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return createInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createVnf(RequestDetails requestDetails, String endpoint) throws Exception {
+
+ String methodName = "createVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return createInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createNwInstance(RequestDetails requestDetails, String endpoint) throws Exception {
+
+ String methodName = "createNwInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return createInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createVolumeGroupInstance(RequestDetails requestDetails, String endpoint) throws Exception {
+ String methodName = "createVolumeGroupInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return createInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createVfModuleInstance(RequestDetails requestDetails, String endpoint) throws Exception {
+ String methodName = "createVfModuleInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return createInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper createConfigurationInstance(RequestDetails requestDetails, String endpoint) throws Exception {
+ String methodName = "createConfigurationInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return createInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteSvcInstance(RequestDetails requestDetails, String endpoint) throws Exception {
+ String methodName = "deleteSvcInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return deleteInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteVnf(RequestDetails requestDetails, String endpoint) throws Exception {
+ String methodName = "deleteVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return deleteInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteVfModule(RequestDetails requestDetails, String endpoint) throws Exception {
+ String methodName = "deleteVfModule";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return deleteInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteVolumeGroupInstance(RequestDetails requestDetails, String endpoint) throws Exception {
+ String methodName = "deleteVolumeGroupInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return deleteInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteNwInstance(RequestDetails requestDetails, String endpoint) throws Exception {
+ String methodName = "deleteNwInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return deleteInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public void getOrchestrationRequest(String t, String sourceId, String endpoint, RestObject restObject) throws Exception {
+ Get(t, sourceId, endpoint, restObject);
+ }
+
+ public void getManualTasks(String t, String sourceId, String endpoint, RestObject restObject) throws Exception {
+ Get(t, sourceId, endpoint, restObject);
+ }
+
+
+ public MsoResponseWrapper createInstance(RequestDetails request, String path) throws Exception {
+ String methodName = "createInstance";
+ logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+ RestObject<String> restObjStr = new RestObject<String>();
+
+ String str = new String();
+
+ restObjStr.set(str);
+
+ Post(str, request, "", path, restObjStr);
+ MsoResponseWrapper w = MsoUtil.wrapResponse(restObjStr);
+
+ return w;
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+
+ /**
+ * Delete instance.
+ *
+ * @param request the request
+ * @param path the path
+ * @return the mso response wrapper
+ * @throws Exception the exception
+ */
+ public MsoResponseWrapper deleteInstance(RequestDetails request, String path) throws Exception {
+ String methodName = "deleteInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]");
+
+ RestObject<String> restObjStr = new RestObject<String>();
+ String str = new String();
+ restObjStr.set(str);
+ Delete(str, request, "", path, restObjStr);
+ MsoResponseWrapper w = MsoUtil.wrapResponse(restObjStr);
+
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+ return w;
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+
+ }
+
+ public MsoResponseWrapper getOrchestrationRequestsForDashboard(String t, String sourceId, String endpoint, RestObject restObject) throws Exception {
+ String methodName = "getOrchestrationRequestsForDashboard";
+ logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+ getOrchestrationRequest(t, sourceId, endpoint, restObject);
+ MsoResponseWrapper w = MsoUtil.wrapResponse(restObject);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+
+ return w;
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ public MsoResponseWrapper getManualTasksByRequestId(String t, String sourceId, String endpoint, RestObject restObject) throws Exception {
+ String methodName = "getManualTasksByRequestId";
+ logger.debug(dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+ getManualTasks(t, sourceId, endpoint, restObject);
+ MsoResponseWrapper w = MsoUtil.wrapResponse(restObject);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+
+ return MsoUtil.wrapResponse(restObject);
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+
+ @Override
+ public MsoResponseWrapper completeManualTask(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject restObject) throws Exception {
+ String methodName = "completeManualTask";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Complete ");
+ try {
+
+ Post(t, requestDetails, sourceId, endpoint, restObject);
+ MsoResponseWrapper w = MsoUtil.wrapResponse(restObject);
+
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+ return w;
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper replaceVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String endpoint) throws Exception {
+ String methodName = "replaceVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ return replaceInstance(requestDetails, endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper deleteConfiguration(RequestDetails requestDetails, String pmc_endpoint)
+ throws Exception {
+ String methodName = "deleteConfiguration";
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ return deleteInstance(requestDetails, pmc_endpoint);
+ }
+
+ @Override
+ public MsoResponseWrapper setConfigurationActiveStatus(RequestDetails request, String path) throws Exception {
+ String methodName = "setConfigurationActiveStatus";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling change configuration active status, path =[" + path + "]");
+
+ RestObject<String> restObjStr = new RestObject<String>();
+ String str = new String();
+ restObjStr.set(str);
+ Post(str, request, "", path, restObjStr);
+ MsoResponseWrapper msoResponseWrapperObject = MsoUtil.wrapResponse(restObjStr);
+
+ return msoResponseWrapperObject;
+ } 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());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper setPortOnConfigurationStatus(RequestDetails request, String path) throws Exception {
+ String methodName = "setPortOnConfigurationStatus";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling change port configuration status, path =[" + path + "]");
+
+ RestObject<String> restObjStr = new RestObject<String>();
+ String str = new String();
+ restObjStr.set(str);
+ Post(str, request, "", path, restObjStr);
+ MsoResponseWrapper msoResponseWrapperObject = MsoUtil.wrapResponse(restObjStr);
+
+ return msoResponseWrapperObject;
+ } 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());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapperInterface changeManagementUpdate(RequestDetailsWrapper requestDetails, String endpoint) throws Exception {
+ RestObject<RequestReferencesContainer> msoResponse = PostForObject(requestDetails, "", endpoint, RequestReferencesContainer.class);
+ return new MsoResponseWrapper2<>(msoResponse);
+ }
+
+ public MsoResponseWrapper replaceInstance(org.onap.vid.changeManagement.RequestDetails request, String path) throws Exception {
+ String methodName = "replaceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+
+
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Replace VNF, path =[" + path + "]");
+ RestObject<String> restObjStr = new RestObject<String>();
+ String str = new String();
+ restObjStr.set(str);
+ RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
+ requestDetailsWrapper.requestDetails = new MsoRequestDetails(request);
+
+ Post(str, requestDetailsWrapper, "", path, restObjStr);
+ MsoResponseWrapper msoResponseWrapperObject = MsoUtil.wrapResponse(restObjStr);
+ int status = msoResponseWrapperObject.getStatus();
+ if (status == 202) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName +
+ ",post succeeded, msoResponseWrapperObject response:" + msoResponseWrapperObject.getResponse());
+ } else {
+ logger.error(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName +
+ ": post failed, msoResponseWrapperObject status" + status + ", response:" + msoResponseWrapperObject.getResponse());
+
+ // TODO
+ }
+ return msoResponseWrapperObject;
+
+ } 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());
+ throw e;
+ }
+
+ }
+
+ @Override
+ public MsoResponseWrapper updateVnf(org.onap.vid.changeManagement.RequestDetails requestDetails, String endpoint) throws Exception {
+ String methodName = "updateVnf";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+ RequestDetailsWrapper wrapper = new RequestDetailsWrapper();
+ wrapper.requestDetails = new MsoRequestDetails(requestDetails);
+ return updateInstance(requestDetails, endpoint);
+ }
+
+ public MsoResponseWrapper updateInstance(org.onap.vid.changeManagement.RequestDetails request, String path) throws Exception {
+ String methodName = "updateInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Delete, path =[" + path + "]");
+ RestObject<String> restObjStr = new RestObject<String>();
+ String str = new String();
+ restObjStr.set(str);
+ RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
+ requestDetailsWrapper.requestDetails = new MsoRequestDetails(request);
+ Put(str, requestDetailsWrapper, "", path, restObjStr);
+ MsoResponseWrapper w = MsoUtil.wrapResponse(restObjStr);
+
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w=" + w.getResponse());
+ return w;
+
+ } 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());
+ throw e;
+ }
+
+ }
+
+ public void setServiceInstanceStatus(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject<String> restObject) throws Exception {
+ String methodName = "activateServiceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start ");
+ try {
+
+ Post(t, requestDetails, sourceId, endpoint, restObject);
+ MsoResponseWrapper w = MsoUtil.wrapResponse(restObject);
+
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " w =" + w.getResponse());
+
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + "." + methodName + e.toString());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String endpoint) throws Exception {
+ String methodName = "removeRelationshipFromServiceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Remove relationship from service instance, path =[" + endpoint + "]");
+
+ RestObject<String> restObjStr = new RestObject<String>();
+ String str = "";
+ restObjStr.set(str);
+ Post(str, requestDetails, "", endpoint, restObjStr);
+
+ return MsoUtil.wrapResponse(restObjStr);
+ } 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());
+ throw e;
+ }
+ }
+
+ @Override
+ public MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath) throws Exception {
+ String methodName = "addRelationshipToServiceInstance";
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " start");
+
+ try {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " calling Add relationship to service instance, path =[" + addRelationshipsPath + "]");
+
+ RestObject<String> restObjStr = new RestObject<>();
+ restObjStr.set("");
+ Post("", requestDetails, "", addRelationshipsPath, restObjStr);
+
+ return MsoUtil.wrapResponse(restObjStr);
+ } 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());
+ throw e;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/OperationalEnvironment/OperationEnvironmentRequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/OperationalEnvironment/OperationEnvironmentRequestDetails.java
new file mode 100644
index 000000000..2f6d233c2
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/OperationalEnvironment/OperationEnvironmentRequestDetails.java
@@ -0,0 +1,120 @@
+package org.onap.vid.mso.rest.OperationalEnvironment;
+
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+
+import java.util.List;
+
+public class OperationEnvironmentRequestDetails {
+ private final RequestInfo requestInfo;
+ private final List<RelatedInstance> relatedInstanceList;
+ private final RequestParameters requestParameters;
+
+ public OperationEnvironmentRequestDetails(@JsonProperty(value = "requestInfo", required = true) RequestInfo requestInfo,
+ @JsonProperty(value = "relatedInstanceList", required = true) List<RelatedInstance> relatedInstanceList,
+ @JsonProperty(value = "requestParameters", required = true) RequestParameters requestParameters) {
+ this.requestInfo = requestInfo;
+ this.relatedInstanceList = relatedInstanceList;
+ this.requestParameters = requestParameters;
+ }
+
+ public RequestInfo getRequestInfo() {
+ return requestInfo;
+ }
+
+ public List<RelatedInstance> getRelatedInstanceList() {
+ return relatedInstanceList;
+ }
+
+ public RequestParameters getRequestParameters() {
+ return requestParameters;
+ }
+
+ public static class RequestInfo {
+ private final String resourceType;
+ private final String instanceName;
+ private final String source;
+ private final String requestorId;
+
+ public RequestInfo(@JsonProperty(value = "resourceType", required = true) String resourceType,
+ @JsonProperty(value = "instanceName", required = true) String instanceName,
+ @JsonProperty(value = "source", required = true) String source,
+ @JsonProperty(value = "requestorId", required = true) String requestorId) {
+ this.resourceType = resourceType;
+ this.instanceName = instanceName;
+ this.source = source;
+ this.requestorId = requestorId;
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public String getRequestorId() {
+ return requestorId;
+ }
+ }
+
+ public static class RequestParameters {
+ private final String operationalEnvironmentType;
+ private final String tenantContext;
+ private final String workloadContext;
+
+ public RequestParameters(@JsonProperty(value = "operationalEnvironmentType", required = true) String operationalEnvironmentType,
+ @JsonProperty(value = "tenantContext", required = true) String tenantContext,
+ @JsonProperty(value = "workloadContext", required = true) String workloadContext) {
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ this.tenantContext = tenantContext;
+ this.workloadContext = workloadContext;
+ }
+ public String getOperationalEnvironmentType() {
+ return operationalEnvironmentType;
+ }
+
+ public String getTenantContext() {
+ return tenantContext;
+ }
+
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+ }
+
+ @JsonTypeName("relatedInstance")
+ @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
+ public static class RelatedInstance {
+ private final String resourceType;
+ private final String instanceId;
+ private final String instanceName;
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public RelatedInstance(@JsonProperty(value = "instanceName", required = true) String resourceType,
+ @JsonProperty(value = "instanceId", required = true) String instanceId,
+ @JsonProperty(value = "instanceName", required = true) String instanceName) {
+ this.resourceType = resourceType;
+ this.instanceId = instanceId;
+ this.instanceName = instanceName;
+ }
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedInstance.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedInstance.java
new file mode 100644
index 000000000..b7f120330
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedInstance.java
@@ -0,0 +1,125 @@
+/*-
+ * ============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.mso.rest;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Generated;
+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;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+
+/**
+ * modelInfo and optional instanceId and instanceName for a model related to the modelInfo being operated on.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "instanceName",
+ "instanceId",
+ "modelInfo"
+})
+public class RelatedInstance extends org.onap.vid.domain.mso.RelatedInstance{
+
+
+ /** The model info. */
+ @JsonProperty("modelInfo")
+ private org.onap.vid.domain.mso.ModelInfo modelInfo;
+
+ /** The additional properties. */
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * (Required).
+ *
+ * @return The modelInfo
+ */
+ @JsonProperty("modelInfo")
+ public org.onap.vid.domain.mso.ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+
+ /**
+ * (Required).
+ *
+ * @param modelInfo The modelInfo
+ */
+ @JsonProperty("modelInfo")
+ public void setModelInfo(org.onap.vid.domain.mso.ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RelatedInstance#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RelatedInstance#getAdditionalProperties()
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RelatedInstance#setAdditionalProperty(java.lang.String, java.lang.Object)
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RelatedInstance#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(getInstanceName()).append(getInstanceId()).append(modelInfo).append(additionalProperties).toHashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RelatedInstance#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof RelatedInstance) == false) {
+ return false;
+ }
+ RelatedInstance rhs = ((RelatedInstance) other);
+ return new EqualsBuilder().append(getInstanceName(), rhs.getInstanceName()).append(getInstanceId(), rhs.getInstanceId()).append(modelInfo, rhs.getModelInfo()).append(additionalProperties, rhs.additionalProperties).isEquals();
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedModel.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedModel.java
new file mode 100644
index 000000000..39722e172
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RelatedModel.java
@@ -0,0 +1,125 @@
+/*-
+ * ============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.mso.rest;
+
+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;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+
+/**
+ * modelInfo and optional instance id for a model related to the modelInfo being operated on.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "instanceId",
+ "modelInfo"
+})
+public class RelatedModel extends org.onap.vid.domain.mso.RelatedModel {
+
+ /** (Required). */
+ @JsonProperty("modelInfo")
+ private org.onap.vid.domain.mso.ModelInfo modelInfo;
+
+// /** The related model object instance list. */
+// @JsonProperty("instanceId")
+// private org.openecomp.vid.domain.mso.InstanceIds instanceId;
+
+ /** The additional properties. */
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * (Required).
+ *
+ * @return The modelInfo
+ */
+ @JsonProperty("modelInfo")
+ public org.onap.vid.domain.mso.ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+
+ /**
+ * (Required).
+ *
+ * @param modelInfo The modelInfo
+ */
+ @JsonProperty("modelInfo")
+ public void setModelInfo(org.onap.vid.domain.mso.ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RelatedModel#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RelatedModel#getAdditionalProperties()
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RelatedModel#setAdditionalProperty(java.lang.String, java.lang.Object)
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RelatedModel#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(getInstanceId()).append(modelInfo).append(additionalProperties).toHashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RelatedModel#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof RelatedModel) == false) {
+ return false;
+ }
+ RelatedModel rhs = ((RelatedModel) other);
+ return new EqualsBuilder().append(getInstanceId(), rhs.getInstanceId()).append(modelInfo, rhs.modelInfo).append(additionalProperties, rhs.additionalProperties).isEquals();
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Request.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Request.java
new file mode 100644
index 000000000..b1a84ab29
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Request.java
@@ -0,0 +1,146 @@
+/*-
+ * ============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.mso.rest;
+
+//import java.util.HashMap;
+//import java.util.Map;
+//import javax.annotation.Generated;
+
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.onap.vid.domain.mso.InstanceIds;
+import org.onap.vid.domain.mso.RequestStatus;
+//import com.fasterxml.jackson.annotation.JsonAnyGetter;
+//import com.fasterxml.jackson.annotation.JsonAnySetter;
+//import com.fasterxml.jackson.annotation.JsonCreator;
+//import com.fasterxml.jackson.annotation.JsonIgnore;
+//import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+//import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+//import com.fasterxml.jackson.annotation.JsonValue;
+import org.apache.commons.lang.builder.EqualsBuilder;
+//import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+
+/**
+ * request structure.
+ */
+public class Request extends org.onap.vid.domain.mso.Request {
+
+
+ /** The instance ids. */
+ private InstanceIds instanceIds;
+
+ /** The request details. */
+ private RequestDetails requestDetails;
+
+ /** The request status. */
+ private RequestStatus requestStatus;
+
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.Request#getInstanceIds()
+ */
+ @JsonProperty("instanceIds")
+ public InstanceIds getInstanceIds() {
+ return instanceIds;
+ }
+
+ /**
+ * Sets the instance ids.
+ *
+ * @param instanceIds The instanceIds
+ */
+ @JsonProperty("instanceIds")
+ public void setInstanceIds(InstanceIds instanceIds) {
+ this.instanceIds = instanceIds;
+ }
+
+ /**
+ * (Required).
+ *
+ * @return The requestDetails
+ */
+ @JsonProperty("requestDetails")
+ public RequestDetails getRequestDetails() {
+ return requestDetails;
+ }
+
+ /**
+ * (Required).
+ *
+ * @param requestDetails The requestDetails
+ */
+ @JsonProperty("requestDetails")
+ public void setRequestDetails(RequestDetails requestDetails) {
+ this.requestDetails = requestDetails;
+ }
+
+
+ /**
+ * Gets the request status.
+ *
+ * @return The requestStatus
+ */
+ @JsonProperty("requestStatus")
+ public RequestStatus getRequestStatus() {
+ return requestStatus;
+ }
+
+ /**
+ * Sets the request status.
+ *
+ * @param requestStatus The requestStatus
+ */
+ @JsonProperty("requestStatus")
+ public void setRequestStatus(RequestStatus requestStatus) {
+ this.requestStatus = requestStatus;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.Request#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.Request#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof Request) == false) {
+ return false;
+ }
+ Request rhs = ((Request) other);
+ return new EqualsBuilder().append(getFinishTime(), rhs.getFinishTime()).append(getInstanceIds(), rhs.getInstanceIds()).append(getRequestDetails(), rhs.getRequestDetails()).append(getRequestId(), rhs.getRequestId()).append(getRequestScope(), rhs.getRequestScope()).append(getRequestStatus(), rhs.getRequestStatus()).append(getRequestType(), rhs.getRequestType()).append(getStartTime(), rhs.getStartTime()).append(getAdditionalProperties(), rhs.getAdditionalProperties()).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37).append(getFinishTime()).append(getInstanceIds()).append(getRequestDetails()).append(getRequestId()).append(getRequestScope()).append(getRequestStatus()).append(getRequestType()).append(getStartTime()).append(getAdditionalProperties()).toHashCode();
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java
new file mode 100644
index 000000000..1e059896f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestDetails.java
@@ -0,0 +1,235 @@
+/*-
+ * ============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.mso.rest;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.List;
+
+import org.onap.vid.domain.mso.*;
+import org.onap.vid.domain.mso.SubscriberInfo;
+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;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+
+/**
+ * aggregates the context, configuraiton and detailed parameters associated with the request into a single structure.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "cloudConfiguration",
+ "modelInfo",
+ "relatedModelList",
+ "requestInfo",
+ "subscriberInfo",
+ "requestParameters"
+})
+public class RequestDetails{
+
+ /** The cloud configuration. */
+ @JsonProperty("cloudConfiguration")
+ private CloudConfiguration cloudConfiguration;
+
+ /** The model info. */
+ @JsonProperty("modelInfo")
+ private ModelInfo modelInfo;
+
+ /** The related model list. */
+ @JsonProperty("relatedModelList")
+ private List<RelatedModel> relatedInstanceList;
+
+ /** The request info. */
+ @JsonProperty("requestInfo")
+ private RequestInfo requestInfo;
+
+ /** The subscriber info. */
+ @JsonProperty("subscriberInfo")
+ private SubscriberInfo subscriberInfo;
+
+ /** The request parameters. */
+ @JsonProperty("requestParameters")
+ private RequestParameters requestParameters;
+
+ /** The additional properties. */
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * Gets the cloud configuration.
+ *
+ * @return The cloudConfiguration
+ */
+ @JsonProperty("cloudConfiguration")
+ public CloudConfiguration getCloudConfiguration() {
+ return cloudConfiguration;
+ }
+
+ /**
+ * Sets the cloud configuration.
+ *
+ * @param cloudConfiguration The cloudConfiguration
+ */
+ @JsonProperty("cloudConfiguration")
+ public void setCloudConfiguration(CloudConfiguration cloudConfiguration) {
+ this.cloudConfiguration = cloudConfiguration;
+ }
+
+ /**
+ * Gets the model info.
+ *
+ * @return The modelInfo
+ */
+ @JsonProperty("modelInfo")
+ public ModelInfo getModelInfo() {
+ return modelInfo;
+ }
+
+ /**
+ * Sets the model info.
+ *
+ * @param modelInfo The modelInfo
+ */
+ @JsonProperty("modelInfo")
+ public void setModelInfo(ModelInfo modelInfo) {
+ this.modelInfo = modelInfo;
+ }
+ /**
+ * Gets the related instance list.
+ *
+ * @return The relatedInstanceList
+ */
+ @JsonProperty("relatedInstanceList")
+ public List<RelatedModel> getRelatedInstanceList() {
+ return relatedInstanceList;
+ }
+
+ /**
+ * Sets the related model list.
+ *
+ * @param relatedInstanceList The relatedInstanceList
+ */
+ @JsonProperty("relatedInstanceList")
+ public void setRelatedInstanceList( List<RelatedModel> relatedInstanceList) {
+ this.relatedInstanceList = relatedInstanceList;
+ }
+
+ /**
+ * Gets the request info.
+ *
+ * @return The requestInfo
+ */
+ @JsonProperty("requestInfo")
+ public RequestInfo getRequestInfo() {
+ return requestInfo;
+ }
+
+ /**
+ * Sets the request info.
+ *
+ * @param requestInfo The requestInfo
+ */
+ @JsonProperty("requestInfo")
+ public void setRequestInfo(RequestInfo requestInfo) {
+ this.requestInfo = requestInfo;
+ }
+
+ /**
+ * Gets the subscriber info.
+ *
+ * @return The subscriberInfo
+ */
+ @JsonProperty("subscriberInfo")
+ public SubscriberInfo getSubscriberInfo() {
+ return subscriberInfo;
+ }
+
+ /**
+ * Sets the subscriber info.
+ *
+ * @param subscriberInfo The subscriberInfo
+ */
+ @JsonProperty("subscriberInfo")
+ public void setSubscriberInfo(SubscriberInfo subscriberInfo) {
+ this.subscriberInfo = subscriberInfo;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RequestDetails#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RequestDetails#getAdditionalProperties()
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RequestDetails#setAdditionalProperty(java.lang.String, java.lang.Object)
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RequestDetails#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(cloudConfiguration).append(modelInfo).append(relatedInstanceList).append(requestInfo).append(getRequestParameters()).append(subscriberInfo).append(additionalProperties).toHashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.domain.mso.RequestDetails#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof RequestDetails) == false) {
+ return false;
+ }
+ RequestDetails rhs = ((RequestDetails) other);
+ return new EqualsBuilder().append(cloudConfiguration, rhs.cloudConfiguration).append(modelInfo, rhs.modelInfo).append(relatedInstanceList, rhs.relatedInstanceList).append(requestInfo, rhs.requestInfo).append(getRequestParameters(), rhs.getRequestParameters()).append(subscriberInfo, rhs.subscriberInfo).append(additionalProperties, rhs.additionalProperties).isEquals();
+ }
+
+ public RequestParameters getRequestParameters() {
+ return requestParameters;
+ }
+
+ public void setRequestParameters(RequestParameters requestParameters) {
+ this.requestParameters = requestParameters;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestList.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestList.java
new file mode 100644
index 000000000..8f8272c07
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestList.java
@@ -0,0 +1,137 @@
+/*-
+ * ============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.mso.rest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.Generated;
+
+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 com.fasterxml.jackson.annotation.JsonInclude;
+//import com.fasterxml.jackson.annotation.JsonProperty;
+//import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import java.util.List;
+
+/**
+ * List of relatedModel structures that are related to a modelInfo being operated on.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "finishTime",
+ "instanceIds",
+ "requestDetails",
+ "requestId",
+ "requestScope",
+ "requestStatus",
+ "requestType",
+ "startTime"
+})
+
+public class RequestList {
+
+ /** The request list. */
+ private List<RequestWrapper> requestList;
+
+ /** The additional properties. */
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * (Required).
+ *
+ * @return The RelatedModel List
+ */
+ public List<RequestWrapper> getRequestList() {
+ return requestList;
+ }
+
+ /**
+ * Sets the request list.
+ *
+ * @param l the new request list
+ */
+ public void setRequestList(List<RequestWrapper> l) {
+ this.requestList = l;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ /**
+ * Gets the additional properties.
+ *
+ * @return the additional properties
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /**
+ * Sets the additional property.
+ *
+ * @param name the name
+ * @param value the value
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(getRequestList()).append(additionalProperties).toHashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+ if ((other instanceof RequestList) == false) {
+ return false;
+ }
+ RequestList rhs = ((RequestList) other);
+ return new EqualsBuilder().append(getRequestList(), rhs.getRequestList()).append(additionalProperties, rhs.additionalProperties).isEquals();
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestWrapper.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestWrapper.java
new file mode 100644
index 000000000..c93d0e563
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RequestWrapper.java
@@ -0,0 +1,35 @@
+package org.onap.vid.mso.rest;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * request wrapper structure.
+ */
+public class RequestWrapper {
+
+
+ /** The request. */
+ private Request request;
+
+
+ /**
+ * Gets the request.
+ *
+ * @return The requestDetails
+ */
+ @JsonProperty("request")
+ public Request getRequest() {
+ return request;
+ }
+
+ /**
+ * Sets the request.
+ *
+ * @param request The request
+ */
+ @JsonProperty
+ public void setRequest(Request request) {
+ this.request = request;
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Response.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Response.java
new file mode 100644
index 000000000..ee074f38d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Response.java
@@ -0,0 +1,54 @@
+package org.onap.vid.mso.rest;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Response {
+
+ /** The status. */
+ private int status;
+
+ /** The entity. */
+ private RequestList entity;
+
+ /**
+ * Gets the status.
+ *
+ * @return The status
+ */
+ @JsonProperty("status")
+ public int getStatus() {
+ return status;
+ }
+
+ /**
+ * Sets the status.
+ *
+ * @param status The status
+ */
+ @JsonProperty("status")
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ /**
+ * Gets the entity.
+ *
+ * @return The entity
+ */
+ @JsonProperty("entity")
+ public RequestList getEntity() {
+ return entity;
+ }
+
+ /**
+ * Sets the entity.
+ *
+ * @param entity The entity
+ */
+ @JsonProperty("entity")
+ public void setEntity(RequestList entity) {
+ this.entity = entity;
+ }
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java
new file mode 100644
index 000000000..9fc95fcec
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/RestInterface.java
@@ -0,0 +1,68 @@
+package org.onap.vid.mso.rest;
+
+import org.onap.vid.mso.RestObject;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+
+/**
+ * Created by pickjonathan on 26/06/2017.
+ */
+public interface RestInterface {
+
+ /**
+ * Inits the rest client.
+ */
+ MultivaluedHashMap<String, Object> initMsoClient();
+
+ /**
+ * Gets the.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param sourceId the source id
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ <T> void Get (T t, String sourceId, String path, RestObject<T> restObject ) throws Exception;
+
+ /**
+ * Delete.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param r the r
+ * @param sourceID the source ID
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ <T> void Delete(T t, RequestDetails r, String sourceID, String path, RestObject<T> restObject) throws Exception;
+
+ /**
+ * Post.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param r the r
+ * @param sourceID the source ID
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ <T> void Post(T t, Object r, String sourceID, String path, RestObject<T> restObject) throws Exception;
+
+ /**
+ * Put.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param r the r
+ * @param sourceID the source ID
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ <T> void Put(T t, org.onap.vid.changeManagement.RequestDetailsWrapper r, String sourceID, String path, RestObject<T> restObject) throws Exception;
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java
new file mode 100644
index 000000000..79aaaea51
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java
@@ -0,0 +1,119 @@
+package org.onap.vid.mso.rest;
+
+import java.util.List;
+
+public class Task {
+
+ private String taskId;
+ private String type;
+ private String nfRole;
+ private String subscriptionServiceType;
+ private String originalRequestId;
+ private String originalRequestorId;
+ private String errorSource;
+ private String errorCode;
+ private String errorMessage;
+ private String buildingBlockName;
+ private String buildingBlockStep;
+ private List<String> validResponses;
+
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getNfRole() {
+ return nfRole;
+ }
+
+ public void setNfRole(String nfRole) {
+ this.nfRole = nfRole;
+ }
+
+ public String getSubscriptionServiceType() {
+ return subscriptionServiceType;
+ }
+
+ public void setSubscriptionServiceType(String subscriptionServiceType) {
+ this.subscriptionServiceType = subscriptionServiceType;
+ }
+
+ public String getOriginalRequestId() {
+ return originalRequestId;
+ }
+
+ public void setOriginalRequestId(String originalRequestId) {
+ this.originalRequestId = originalRequestId;
+ }
+
+ public String getOriginalRequestorId() {
+ return originalRequestorId;
+ }
+
+ public void setOriginalRequestorId(String originalRequestorId) {
+ this.originalRequestorId = originalRequestorId;
+ }
+
+ public String getErrorSource() {
+ return errorSource;
+ }
+
+ public void setErrorSource(String errorSource) {
+ this.errorSource = errorSource;
+ }
+
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public String getBuildingBlockName() {
+ return buildingBlockName;
+ }
+
+ public void setBuildingBlockName(String buildingBlockName) {
+ this.buildingBlockName = buildingBlockName;
+ }
+
+ public String getBuildingBlockStep() {
+ return buildingBlockStep;
+ }
+
+ public void setBuildingBlockStep(String buildingBlockStep) {
+ this.buildingBlockStep = buildingBlockStep;
+ }
+
+ public List<String> getValidResponses() {
+ return validResponses;
+ }
+
+ public void setValidResponses(List<String> validResponses) {
+ this.validResponses = validResponses;
+ }
+
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/TaskList.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/TaskList.java
new file mode 100644
index 000000000..bbff333af
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/TaskList.java
@@ -0,0 +1,16 @@
+package org.onap.vid.mso.rest;
+
+import java.util.List;
+
+public class TaskList {
+
+ public List<Task> getTaskList() {
+ return taskList;
+ }
+
+ public void setTaskList(List<Task> taskList) {
+ this.taskList = taskList;
+ }
+
+ private List<Task> taskList;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/policy/PolicyProperties.java b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyProperties.java
new file mode 100644
index 000000000..2afb2d4a7
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyProperties.java
@@ -0,0 +1,26 @@
+package org.onap.vid.policy;
+
+import org.openecomp.portalsdk.core.util.SystemProperties;
+
+
+public class PolicyProperties extends SystemProperties {
+
+ public static final String POLICY_CLIENTAUTH_VAL = "policy.ClientAuth";
+
+ public static final String POLICY_CLIENT_MECHID_VAL = "policy.client.mechId";
+
+ public static final String POLICY_CLIENT_PASSWORD_VAL = "policy.client.password";
+
+ public static final String POLICY_USERNAME_VAL = "policy.username";
+
+ public static final String POLICY_PASSWORD_VAL = "policy.password";
+
+ public static final String POLICY_AUTHORIZATION_VAL = "policy.Authorization";
+
+ public static final String POLICY_SERVER_URL_VAL = "policy.server.url";
+
+ public static final String POLICY_ENVIRONMENT_VAL = "policy.environment";
+
+ public static final String POLICY_GET_CONFIG_VAL = "policy.get.config";
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/policy/PolicyResponseWrapper.java b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyResponseWrapper.java
new file mode 100644
index 000000000..d5a4d124c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyResponseWrapper.java
@@ -0,0 +1,56 @@
+package org.onap.vid.policy;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+/**
+ * This wrapper encapsulates the Policy response
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "status",
+ "entity"
+})
+
+public class PolicyResponseWrapper {
+
+ @JsonProperty("status")
+ private int status;
+
+ @JsonProperty("entity")
+ private String entity;
+
+ @JsonProperty("entity")
+ public String getEntity() {
+ return entity;
+ }
+
+ @JsonProperty("status")
+ public int getStatus() {
+ return status;
+ }
+
+ @JsonProperty("status")
+ public void setStatus(int v) {
+ this.status = v;
+ }
+
+ @JsonProperty("entity")
+ public void setEntity(String v) {
+ this.entity = v;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+ public String getResponse () {
+
+ StringBuilder b = new StringBuilder ("{ \"status\": ");
+ b.append(getStatus()).append(", \"entity\": " ).append(this.getEntity()).append("}");
+ return (b.toString());
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInt.java b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInt.java
new file mode 100644
index 000000000..b58fe28ff
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInt.java
@@ -0,0 +1,66 @@
+/*-
+ * ============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.policy;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.policy.rest.RequestDetails;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class PolicyRestInt {
+
+ /** The logger. */
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PolicyRestInt.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The request date format. */
+ public DateFormat requestDateFormat = new SimpleDateFormat("EEE, dd MMM YYYY HH:mm:ss z");
+
+ public PolicyRestInt() {
+ requestDateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
+ }
+
+ /**
+ * Log request.
+ *
+ * @param r the r
+ */
+ public void logRequest ( RequestDetails r ) {
+ String methodName = "logRequest";
+ ObjectMapper mapper = new ObjectMapper();
+ String r_json_str = "";
+ if ( r != null ) {
+ r_json_str = r.toString();
+ try {
+ r_json_str = mapper.writeValueAsString(r);
+ }
+ catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " Unable to parse request as json");
+ }
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " Request=(" + r_json_str + ")");
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInterface.java
new file mode 100644
index 000000000..875586d99
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInterface.java
@@ -0,0 +1,233 @@
+package org.onap.vid.policy;
+
+import org.apache.commons.codec.binary.Base64;
+import org.eclipse.jetty.util.security.Password;
+import org.json.simple.JSONObject;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.onap.vid.client.HttpBasicClient;
+import org.onap.vid.policy.rest.RequestDetails;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.Response;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Date;
+
+public class PolicyRestInterface extends PolicyRestInt implements PolicyRestInterfaceIfc {
+
+ /** The logger. */
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PolicyRestInterface.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /** The client. */
+ private static Client client = null;
+
+ /** The common headers. */
+ private MultivaluedHashMap<String, Object> commonHeaders;
+
+ public PolicyRestInterface() {
+ super();
+ }
+
+ public void initRestClient()
+ {
+ final String methodname = "initRestClient()";
+
+ //final String clientAuth = SystemProperties.getProperty(PolicyProperties.POLICY_CLIENTAUTH_VAL);
+ //final String authorization = SystemProperties.getProperty(PolicyProperties.POLICY_AUTHORIZATION_VAL);
+ final String mechId = SystemProperties.getProperty(PolicyProperties.POLICY_CLIENT_MECHID_VAL);
+ final String clientPassword = SystemProperties.getProperty(PolicyProperties.POLICY_CLIENT_PASSWORD_VAL);
+ final String username = SystemProperties.getProperty(PolicyProperties.POLICY_USERNAME_VAL);
+ final String password = SystemProperties.getProperty(PolicyProperties.POLICY_PASSWORD_VAL);
+ final String environment = SystemProperties.getProperty(PolicyProperties.POLICY_ENVIRONMENT_VAL);
+
+ final String decrypted_client_password = Password.deobfuscate(clientPassword);
+ String mechAuthString = mechId + ":" + decrypted_client_password;
+ byte[] mechAuthEncBytes = Base64.encodeBase64(mechAuthString.getBytes());
+ String clientAuth = new String(mechAuthEncBytes);
+
+ final String decrypted_password = Password.deobfuscate(password);
+ String authString = username + ":" + decrypted_password;
+ byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
+ String authorization = new String(authEncBytes);
+
+ commonHeaders = new MultivaluedHashMap<String, Object> ();
+ commonHeaders.put("ClientAuth", Collections.singletonList((Object) ("Basic " + clientAuth)));
+ commonHeaders.put("Authorization", Collections.singletonList((Object) ("Basic " + authorization)));
+ commonHeaders.put("Environment", Collections.singletonList((Object) (environment)));
+
+ if (client == null) {
+
+ try {
+ client = HttpBasicClient.getClient();
+ } catch (Exception e) {
+ System.out.println( methodname + " Unable to get the SSL client");
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> void Get (T t, String sourceId, String path, RestObject<T> restObject ) throws Exception {
+ String methodName = "Get";
+
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + " start");
+
+ String url="";
+ restObject.set(t);
+
+ url = SystemProperties.getProperty(PolicyProperties.POLICY_SERVER_URL_VAL) + path;
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " sending request to url= " + url);
+
+ initRestClient();
+
+ final Response cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ .get();
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if (status == 200) {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " REST api was successfull!");
+
+ } else {
+ throw new Exception(methodName + " with status="+ status + ", url= " + url );
+ }
+
+ logger.debug(EELFLoggerDelegate.debugLogger,methodName + " received status=" + status );
+
+ return;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> void Delete(T t, RequestDetails r, String sourceID, String path, RestObject<T> restObject) {
+
+ String methodName = "Delete";
+ String url="";
+ Response cres = null;
+
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " start");
+ logRequest (r);
+
+ try {
+ initRestClient();
+
+ url = SystemProperties.getProperty(PolicyProperties.POLICY_SERVER_URL_VAL) + path;
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + " methodName sending request to: " + url);
+
+ cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ //.entity(r)
+ .build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON)).invoke();
+ // .method("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON));
+ //.delete(Entity.entity(r, MediaType.APPLICATION_JSON));
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if (status == 404) { // resource not found
+ String msg = "Resource does not exist...: " + cres.getStatus();
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg);
+ } else if (status == 200 || status == 204){
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + "Resource " + url + " deleted");
+ } else if (status == 202) {
+ String msg = "Delete in progress: " + status;
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg);
+ }
+ else {
+ String msg = "Deleting Resource failed: " + status;
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + msg);
+ }
+
+ try {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " No response entity, this is probably ok, e="
+ + e.getMessage());
+ }
+
+ }
+ catch (Exception e)
+ {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " with url="+url+ ", Exception: " + e.toString());
+ throw e;
+
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> void Post(T t, JSONObject requestDetails, String uuid, String path, RestObject<T> restObject) throws Exception {
+
+ String methodName = "Post";
+ String url="";
+
+ System.out.println( "POST policy rest interface");
+
+ // logRequest (requestDetails);
+ try {
+
+ initRestClient();
+
+ url = SystemProperties.getProperty(PolicyProperties.POLICY_SERVER_URL_VAL) + path;
+ System.out.println( "<== " + methodName + " sending request to url= " + url);
+ // Change the content length
+ final Response cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ //.header("content-length", 201)
+ //.header("X-FromAppId", sourceID)
+ .post(Entity.entity(requestDetails, MediaType.APPLICATION_JSON));
+
+ try {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+
+ System.out.println("<== " + methodName + " No response entity, this is probably ok, e=" + e.getMessage());
+ }
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if ( status >= 200 && status <= 299 ) {
+ System.out.println( "<== " + methodName + " REST api POST was successful!");
+
+ } else {
+ System.out.println( "<== " + methodName + " with status="+status+", url="+url);
+ }
+
+ } catch (Exception e)
+ {
+ System.out.println( "<== " + methodName + " with url="+url+ ", Exception: " + e.toString());
+ throw e;
+
+ }
+ }
+
+ public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException
+ {
+ return clazz.newInstance();
+ }
+
+ @Override
+ public void logRequest(RequestDetails r) {
+ // TODO Auto-generated method stub
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInterfaceFactory.java b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInterfaceFactory.java
new file mode 100644
index 000000000..40cb854bf
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInterfaceFactory.java
@@ -0,0 +1,14 @@
+
+package org.onap.vid.policy;
+
+public class PolicyRestInterfaceFactory {
+
+
+ public static PolicyRestInterfaceIfc getInstance () {
+ PolicyRestInterfaceIfc obj = null;
+
+ obj = new PolicyRestInterface();
+
+ return ( obj );
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInterfaceIfc.java b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInterfaceIfc.java
new file mode 100644
index 000000000..59b0ad3dc
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyRestInterfaceIfc.java
@@ -0,0 +1,58 @@
+
+package org.onap.vid.policy;
+
+import org.json.simple.JSONObject;
+import org.onap.vid.policy.rest.RequestDetails;
+
+public interface PolicyRestInterfaceIfc {
+ /**
+ * Inits the rest client.
+ */
+ public void initRestClient();
+
+ /**
+ * Gets the.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param sourceId the source id
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ public <T> void Get (T t, String sourceId, String path, RestObject<T> restObject ) throws Exception;
+
+ /**
+ * Delete.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param r the r
+ * @param sourceID the source ID
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ public <T> void Delete(T t, RequestDetails r, String sourceID, String path, RestObject<T> restObject) throws Exception;
+
+ /**
+ * Post.
+ *
+ * @param <T> the generic type
+ * @param t the t
+ * @param r the r
+ * @param sourceID the source ID
+ * @param path the path
+ * @param restObject the rest object
+ * @throws Exception the exception
+ */
+ public <T> void Post(T t, JSONObject r, String sourceID, String path, RestObject<T> restObject) throws Exception;
+
+ /***
+ * Log request.
+ *
+ * @param r the r
+ */
+ public void logRequest ( RequestDetails r );
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/policy/PolicyUtil.java b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyUtil.java
new file mode 100644
index 000000000..608352845
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/policy/PolicyUtil.java
@@ -0,0 +1,71 @@
+package org.onap.vid.policy;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.glassfish.jersey.client.ClientResponse;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.policy.PolicyResponseWrapper;
+import org.onap.vid.policy.PolicyUtil;
+import org.onap.vid.policy.RestObject;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class PolicyUtil {
+
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PolicyUtil.class);
+
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ public static PolicyResponseWrapper wrapResponse ( String body, int statusCode ) {
+
+ PolicyResponseWrapper w = new PolicyResponseWrapper();
+ w.setStatus (statusCode);
+ w.setEntity(body);
+
+ return w;
+ }
+
+ public static PolicyResponseWrapper wrapResponse (ClientResponse cres) {
+ String resp_str = "";
+ if ( cres != null ) {
+ resp_str = cres.readEntity(String.class);
+ }
+ int statuscode = cres.getStatus();
+ PolicyResponseWrapper w = PolicyUtil.wrapResponse ( resp_str, statuscode );
+ return (w);
+ }
+
+ public static PolicyResponseWrapper wrapResponse (RestObject<String> rs) {
+ String resp_str = "";
+ int status = 0;
+ if ( rs != null ) {
+ resp_str = rs.get();
+ status = rs.getStatusCode();
+ }
+ PolicyResponseWrapper w = PolicyUtil.wrapResponse ( resp_str, status );
+ return (w);
+ }
+
+ public static <T> String convertPojoToString ( T t ) throws com.fasterxml.jackson.core.JsonProcessingException {
+
+ String methodName = "convertPojoToString";
+ ObjectMapper mapper = new ObjectMapper();
+ String r_json_str = "";
+ if ( t != null ) {
+ try {
+ r_json_str = mapper.writeValueAsString(t);
+ }
+ catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {
+ logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " Unable to parse object as json");
+ }
+ }
+ return (r_json_str);
+ }
+
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/policy/RestObject.java b/vid-app-common/src/main/java/org/onap/vid/policy/RestObject.java
new file mode 100644
index 000000000..81b354eb0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/policy/RestObject.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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.policy;
+
+/**
+ * The Class RestObject.
+ *
+ * @param <T> the generic type
+ */
+public class RestObject<T> {
+
+ /**
+ * Generic version of the RestObject class.
+ *
+ */
+ // T stands for "Type"
+ private T t;
+
+ /** The status code. */
+ private int statusCode= 0;
+
+ /**
+ * Sets the.
+ *
+ * @param t the t
+ */
+ public void set(T t) { this.t = t; }
+
+ /**
+ * Gets the.
+ *
+ * @return the t
+ */
+ public T get() { return t; }
+
+ /**
+ * Sets the status code.
+ *
+ * @param v the new status code
+ */
+ public void setStatusCode(int v) { this.statusCode = v; }
+
+ /**
+ * Gets the status code.
+ *
+ * @return the status code
+ */
+ public int getStatusCode() { return this.statusCode; }
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/policy/rest/RequestDetails.java b/vid-app-common/src/main/java/org/onap/vid/policy/rest/RequestDetails.java
new file mode 100644
index 000000000..81e2f2d8b
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/policy/rest/RequestDetails.java
@@ -0,0 +1,107 @@
+/*-
+ * ============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.policy.rest;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+/*
+ [
+ {
+ "policyConfigMessage": "Config Retrieved! ",
+ "policyConfigStatus": "CONFIG_RETRIEVED",
+ "type": "JSON",
+ "config": "{\"service\":\"TimeLimitAndVerticalTopology\",\"policyName\":\"SNIRO_CM_1707.Demo_TimeLimitAndVerticalTopology_zone_localTime\",\"description\":\"dev instance\",\"templateVersion\":\"1702.03\",\"version\":\"1707\",\"priority\":\"4\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"serviceType\":\"networkOnDemand\",\"identity\":\"vnf_upgrade_policy\",\"policyScope\":{\"serviceType\":[\"networkOnDemand\"],\"aicZone\":[\" \"],\"entityType\":[\"vnf\"]},\"timeSchedule\":{\"allowedPeriodicTime\":[{\"day\":\"weekday\",\"timeRange\":[{\"start_time\":\"04:00:00\",\"end_time\":\"13:00:00\"}]}]},\"nodeType\":[\"vnf\"],\"type\":\"timeLimitAndVerticalTopology\",\"conflictScope\":\"vnf_zone\"}}",
+ "policyName": "SNIRO_CM_1707.Config_MS_Demo_TimeLimitAndVerticalTopology_zone_localTime.1.xml",
+ "policyVersion": "1",
+ "matchingConditions": {
+ "ECOMPName": "SNIRO-Placement",
+ "ConfigName": "",
+ "service": "TimeLimitAndVerticalTopology",
+ "uuid": "",
+ "Location": ""
+ },
+ "responseAttributes": {},
+ "property": null
+ },
+ {
+ "policyConfigMessage": "Config Retrieved! ",
+ "policyConfigStatus": "CONFIG_RETRIEVED",
+ "type": "JSON",
+ "config": "{\"service\":\"TimeLimitAndVerticalTopology\",\"policyName\":\"SNIRO_CM_1707.Demo_TimeLimitAndVerticalTopology_pserver_localTime\",\"description\":\"dev instance\",\"templateVersion\":\"1702.03\",\"version\":\"1707\",\"priority\":\"4\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"serviceType\":\"networkOnDemand\",\"identity\":\"vnf_upgrade_policy\",\"policyScope\":{\"serviceType\":[\"networkOnDemand\"],\"aicZone\":[\" \"],\"entityType\":[\"vnf\"]},\"timeSchedule\":{\"allowedPeriodicTime\":[{\"day\":\"weekday\",\"timeRange\":[{\"start_time\":\"04:00:00\",\"end_time\":\"13:00:00\"}]}]},\"nodeType\":[\"vnf\"],\"type\":\"timeLimitAndVerticalTopology\",\"conflictScope\":\"vnf_pserver\"}}",
+ "policyName": "SNIRO_CM_1707.Config_MS_Demo_TimeLimitAndVerticalTopology_pserver_localTime.1.xml",
+ "policyVersion": "1",
+ "matchingConditions": {
+ "ECOMPName": "SNIRO-Placement",
+ "ConfigName": "",
+ "service": "TimeLimitAndVerticalTopology",
+ "uuid": "",
+ "Location": ""
+ },
+ "responseAttributes": {},
+ "property": null
+ },
+ {
+ "policyConfigMessage": "Config Retrieved! ",
+ "policyConfigStatus": "CONFIG_RETRIEVED",
+ "type": "JSON",
+ "config": "{\"service\":\"TimeLimitAndVerticalTopology\",\"policyName\":\"SNIRO_CM_1707.Demo_TimeLimitAndVerticalTopology_vnf_localTime\",\"description\":\"dev instance\",\"templateVersion\":\"1702.03\",\"version\":\"1707\",\"priority\":\"4\",\"riskType\":\"test\",\"riskLevel\":\"3\",\"guard\":\"False\",\"content\":{\"serviceType\":\"networkOnDemand\",\"identity\":\"vnf_upgrade_policy\",\"policyScope\":{\"serviceType\":[\"networkOnDemand\"],\"aicZone\":[\" \"],\"entityType\":[\"vnf\"]},\"timeSchedule\":{\"allowedPeriodicTime\":[{\"day\":\"weekday\",\"timeRange\":[{\"start_time\":\"04:00:00\",\"end_time\":\"13:00:00\"}]}]},\"nodeType\":[\"vnf\"],\"type\":\"timeLimitAndVerticalTopology\",\"conflictScope\":\"vnf\"}}",
+ "policyName": "SNIRO_CM_1707.Config_MS_Demo_TimeLimitAndVerticalTopology_vnf_localTime.1.xml",
+ "policyVersion": "1",
+ "matchingConditions": {
+ "ECOMPName": "SNIRO-Placement",
+ "ConfigName": "",
+ "service": "TimeLimitAndVerticalTopology",
+ "uuid": "",
+ "Location": ""
+ },
+ "responseAttributes": {},
+ "property": null
+ }
+ ]
+*/
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "policyConfigMessage",
+ "policyConfigStatus",
+ "type",
+ "config",
+ "policyName",
+ "policyVersion",
+ "matchingConditions"
+})
+public class RequestDetails {
+
+ @JsonProperty("policyName")
+ private String policyName;
+
+ @JsonProperty("policyName")
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ @JsonProperty("policyName")
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/properties/AsdcClientConfiguration.java b/vid-app-common/src/main/java/org/onap/vid/properties/AsdcClientConfiguration.java
new file mode 100644
index 000000000..c767967f1
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/properties/AsdcClientConfiguration.java
@@ -0,0 +1,124 @@
+/*-
+ * ============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.properties;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.annotation.PropertySources;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+
+/**
+ * The Class AsdcClientConfiguration.
+ */
+@Configuration
+
+@PropertySources({
+ @PropertySource(value="asdc.properties", ignoreResourceNotFound = true),
+ @PropertySource(value="${container.classpath:}/WEB-INF/conf/asdc.properties", ignoreResourceNotFound = true)
+})
+public class AsdcClientConfiguration {
+
+ @Bean
+ public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
+ }
+
+ @Value("${asdc.client.type}")
+ private AsdcClientType asdcClientType;
+
+ /** The asdc client host. */
+ @Value("${asdc.client.rest.host}")
+ private String asdcClientHost;
+
+ /** The asdc client port. */
+ @Value("${asdc.client.rest.port}")
+ private int asdcClientPort;
+
+ /** The asdc client auth. */
+ @Value("${asdc.client.rest.auth}")
+ public String asdcClientAuth;
+
+ /** The asdc client protocol. */
+ @Value("${asdc.client.rest.protocol}")
+ public String asdcClientProtocol;
+
+ /**
+ * Gets the asdc client type.
+ *
+ * @return the asdc client type
+ */
+ public AsdcClientType getAsdcClientType() {
+ return asdcClientType;
+ }
+
+ /**
+ * Gets the asdc client host.
+ *
+ * @return the asdc client host
+ */
+ public String getAsdcClientHost() {
+ return asdcClientHost;
+ }
+
+ /**
+ * Gets the asdc client port.
+ *
+ * @return the asdc client port
+ */
+ public int getAsdcClientPort() {
+ return asdcClientPort;
+ }
+
+ /**
+ * Gets the asdc client auth.
+ *
+ * @return the asdc client auth
+ */
+ public String getAsdcClientAuth() {
+ return asdcClientAuth;
+ }
+
+ /**
+ * Gets the asdc client protocol.
+ *
+ * @return the asdc client protocol
+ */
+ public String getAsdcClientProtocol() {
+ return asdcClientProtocol;
+ }
+
+ /**
+ * The Enum AsdcClientType.
+ */
+ public enum AsdcClientType {
+
+ /** The in memory. */
+ IN_MEMORY,
+
+ /** The rest. */
+ REST,
+
+ /** The local. */
+ LOCAL
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/properties/MsoClientConfiguration.java b/vid-app-common/src/main/java/org/onap/vid/properties/MsoClientConfiguration.java
new file mode 100644
index 000000000..ca58a954d
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/properties/MsoClientConfiguration.java
@@ -0,0 +1,9 @@
+package org.onap.vid.properties;
+
+/**
+ * Created by pickjonathan on 20/06/2017.
+ */
+public class MsoClientConfiguration {
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/properties/VidProperties.java b/vid-app-common/src/main/java/org/onap/vid/properties/VidProperties.java
new file mode 100644
index 000000000..9108ae16c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/properties/VidProperties.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.properties;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.onap.vid.model.ModelConstants;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+/**
+ * The Class VidProperties.
+ */
+public class VidProperties extends SystemProperties {
+
+ //VID General Properties
+
+ /** The Constant VID_TRUSTSTORE_FILENAME. */
+ public static final String VID_TRUSTSTORE_FILENAME = "vid.truststore.filename";
+
+ /** The Constant VID_TRUSTSTORE_PASSWD_X. */
+ public static final String VID_TRUSTSTORE_PASSWD_X = "vid.truststore.passwd.x";
+
+ /** The Constant FILESEPARATOR. */
+ public static final String FILESEPARATOR = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
+
+ /** The Constant LOG. */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VidProperties.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+ /**
+ * Gets the asdc model namespace prefix property
+ *
+ * @return the property value or a default value
+ */
+ public static String getAsdcModelNamespace() {
+ String methodName = "getAsdcModelNamespace ";
+ String asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
+ try {
+ asdcModelNamespace = SystemProperties.getProperty(ModelConstants.ASDC_MODEL_NAMESPACE);
+ if ( asdcModelNamespace == null || asdcModelNamespace.isEmpty()) {
+ asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
+ }
+ }
+ catch ( Exception e ) {
+ LOG.error (EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + "unable to find the value, using the default "
+ + ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE);
+ asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
+ }
+ return (asdcModelNamespace);
+ }
+ /**
+ * Gets the specified property value. If the property is not defined, returns a default value.
+ *
+ * @return the property value or a default value
+ */
+ public static String getPropertyWithDefault ( String propName, String defaultValue ) {
+ String methodName = "getPropertyWithDefault ";
+ String propValue = defaultValue;
+ try {
+ propValue = SystemProperties.getProperty(propName);
+ if ( propValue == null || propValue.isEmpty()) {
+ propValue = defaultValue;
+ }
+ }
+ catch ( Exception e ) {
+ LOG.error (EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + "unable to find the value, using the default "
+ + defaultValue);
+ propValue = defaultValue;
+ }
+ return (propValue);
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/EcompRole.java b/vid-app-common/src/main/java/org/onap/vid/roles/EcompRole.java
new file mode 100644
index 000000000..63492cd97
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/roles/EcompRole.java
@@ -0,0 +1,5 @@
+package org.onap.vid.roles;
+
+public enum EcompRole {
+ READ;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/Role.java b/vid-app-common/src/main/java/org/onap/vid/roles/Role.java
new file mode 100644
index 000000000..902da5bcd
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/roles/Role.java
@@ -0,0 +1,48 @@
+package org.onap.vid.roles;
+
+/**
+ * Created by Oren on 7/1/17.
+ */
+
+public class Role {
+
+ private EcompRole ecompRole;
+
+ private String subscribeName;
+
+ private String serviceType;
+
+ private String tenant;
+
+ public Role(EcompRole ecompRole, String subscribeName, String serviceType, String tenant) {
+ this.ecompRole = ecompRole;
+ this.subscribeName = subscribeName;
+ this.serviceType = serviceType;
+ this.tenant = tenant;
+ }
+
+ public EcompRole getEcompRole() {
+ return ecompRole;
+ }
+
+
+ public String getSubscribeName() {
+ return subscribeName;
+ }
+
+ public void setSubscribeName(String subscribeName) {
+ this.subscribeName = subscribeName;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+
+ public String getTenant() {
+ return tenant;
+ }
+
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java
new file mode 100644
index 000000000..63cc2bbb0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleProvider.java
@@ -0,0 +1,138 @@
+package org.onap.vid.roles;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.web.support.UserUtils;
+import org.onap.vid.aai.AaiResponse;
+import org.onap.vid.aai.exceptions.RoleParsingException;
+import org.onap.vid.model.ModelConstants;
+import org.onap.vid.model.Subscriber;
+import org.onap.vid.model.SubscriberList;
+import org.onap.vid.services.AaiService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import javax.servlet.http.HttpServletRequest;
+import java.util.*;
+
+//import org.codehaus.jackson.map.ObjectMapper;
+
+/**
+ * Created by Oren on 7/1/17.
+ */
+
+@Component
+public class RoleProvider {
+
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(RoleProvider.class);
+ final String readPermissionString = "read";
+ SubscriberList subscribers;
+ ObjectMapper om = new ObjectMapper();
+ @Autowired
+ private AaiService aaiService;
+
+ public static List<String> extractRoleFromSession(HttpServletRequest request) {
+
+ return new ArrayList<String>();
+
+ }
+
+ @PostConstruct
+ public void init() {
+ LOG.debug(EELFLoggerDelegate.debugLogger, "Role provider => init method started");
+ AaiResponse<SubscriberList> subscribersResponse = aaiService.getFullSubscriberList();
+ subscribers = subscribersResponse.getT();
+ LOG.debug(EELFLoggerDelegate.debugLogger, "Role provider => init method finished");
+ }
+
+ public List<Role> getUserRoles(HttpServletRequest request) throws JsonProcessingException {
+ String logPrefix = "Role Provider (" + UserUtils.getUserId(request) + ") ==>";
+
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "Entering to get user role for user " + UserUtils.getUserId(request));
+
+ List<Role> roleList = new ArrayList<>();
+ HashMap roles = UserUtils.getRoles(request);
+ for (Object role : roles.keySet()) {
+ org.openecomp.portalsdk.core.domain.Role sdkRol = (org.openecomp.portalsdk.core.domain.Role) roles.get(role);
+
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "Role " + sdkRol.getName() + " is being proccessed");
+ try {
+ if (sdkRol.getName().contains(readPermissionString)) {
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + " Role " + sdkRol.getName() + " contain " + readPermissionString);
+
+ continue;
+ }
+ String[] roleParts = splitRole((sdkRol.getName()), logPrefix);
+ roleList.add(createRoleFromStringArr(roleParts, logPrefix));
+ String msg = String.format(logPrefix + " User %s got permissions %s", UserUtils.getUserId(request), Arrays.toString(roleParts));
+ LOG.debug(EELFLoggerDelegate.debugLogger, msg);
+ } catch (RoleParsingException e) {
+ LOG.error(logPrefix + " Failed to parse permission");
+
+ }
+ }
+
+ return roleList;
+ }
+
+ public String[] splitRole(String roleAsString, String logPrefix) {
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "Spliting role = " + roleAsString + "With delimeter = " + ModelConstants.ROLE_DELIMITER);
+ return roleAsString.split(ModelConstants.ROLE_DELIMITER);
+ }
+
+ public boolean userPermissionIsReadOnly(List<Role> roles) {
+
+ return (!(roles.size() > 0));
+ }
+
+ public boolean userPermissionIsReadLogs(List<Role> roles){
+ for(Role role: roles){
+ if(role.getServiceType().equals("LOGS")){
+ if(role.getTenant().equals("PERMITTED")){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private String replaceSubscriberNameToGlobalCustomerID(String subscriberName, String logPrefix) throws JsonProcessingException {
+ if (subscribers == null) {
+ LOG.debug(EELFLoggerDelegate.debugLogger, "replaceSubscriberNameToGlobalCustomerID calling init method");
+ init();
+ }
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "subscribers list size is " + subscribers.customer.size() + " with the values " + om.writeValueAsString(subscribers.customer));
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "subscribers list size is " + subscribers.customer.size() + " with the values " + om.writeValueAsString(subscribers.customer));
+
+
+ Optional<Subscriber> s = subscribers.customer.stream().filter(x -> x.subscriberName.equals(subscriberName)).findFirst();
+ //Fixing bug of logging "optional get" before isPresent
+ String replacement = s.isPresent() ? s.get().globalCustomerId : "";
+ LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "Subscribername " + subscriberName + " changed to " + replacement);
+ return replacement;
+ }
+
+ public Role createRoleFromStringArr(String[] roleParts, String rolePrefix) throws JsonProcessingException, RoleParsingException {
+ String globalCustomerID = replaceSubscriberNameToGlobalCustomerID(roleParts[0], rolePrefix);
+ try {
+ if (roleParts.length > 2) {
+ return new Role(EcompRole.READ, globalCustomerID, roleParts[1], roleParts[2]);
+ } else {
+ return new Role(EcompRole.READ, globalCustomerID, roleParts[1], null);
+ }
+ } catch (ArrayIndexOutOfBoundsException e) {
+ if (roleParts.length > 0)
+ LOG.debug(EELFLoggerDelegate.debugLogger, "Could not parse role ", roleParts[0]);
+ else {
+ LOG.debug(EELFLoggerDelegate.debugLogger, "Got empty role, Could not parse it ");
+
+ }
+ throw new RoleParsingException();
+ }
+
+ }
+
+}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java
new file mode 100644
index 000000000..f4f17facb
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/roles/RoleValidator.java
@@ -0,0 +1,57 @@
+package org.onap.vid.roles;
+
+import org.onap.vid.mso.rest.RequestDetails;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by Oren on 7/12/17.
+ */
+public class RoleValidator {
+
+ private List<Role> userRoles;
+
+ public RoleValidator(List<Role> roles) {
+ this.userRoles = roles;
+ }
+
+ public boolean isSubscriberPermitted(String subscriberName) {
+ for (Role role : userRoles) {
+ if (role.getSubscribeName().equals(subscriberName))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isServicePermitted(String subscriberName, String serviceType) {
+ for (Role role : userRoles) {
+ if (role.getSubscribeName().equals(subscriberName) && role.getServiceType().equals(serviceType))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isMsoRequestValid(RequestDetails mso_request) {
+ try {
+ String globalSubscriberIdRequested = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("subscriberInfo")).get("globalSubscriberId");
+ String serviceType = (String) ((Map) ((Map) mso_request.getAdditionalProperties().get("requestDetails")).get("requestParameters")).get("subscriptionServiceType");
+ return isServicePermitted(globalSubscriberIdRequested, serviceType);
+ } catch (Exception e) {
+ //Until we'll get the exact information regarding the tenants and the global customer id, we'll return true on unknown requests to mso
+ return true;
+ }
+// return false;
+ }
+
+ public boolean isTenantPermitted(String globalCustomerId, String serviceType, String tenantName) {
+ for (Role role : userRoles) {
+ if (role.getSubscribeName().equals(globalCustomerId)
+ && role.getServiceType().equals(serviceType)
+ && (role.getTenant() == null || role.getTenant().equalsIgnoreCase(tenantName))) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/scheduler/RestObject.java b/vid-app-common/src/main/java/org/onap/vid/scheduler/RestObject.java
new file mode 100644
index 000000000..4accb55da
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/scheduler/RestObject.java
@@ -0,0 +1,44 @@
+/*-
+ * ============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.scheduler;
+
+
+public class RestObject<T> {
+
+ private T t;
+
+ private int statusCode= 0;
+
+ public String uuid;
+
+ public void set(T t) { this.t = t; }
+
+ public T get() { return t; }
+
+ public void setStatusCode(int v) { this.statusCode = v; }
+
+ public int getStatusCode() { return this.statusCode; }
+
+ public void setUUID(String uuid) { this.uuid = uuid; }
+
+ public String getUUID() { return this.uuid; }
+}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/scheduler/RestObjects/RestObject.java b/vid-app-common/src/main/java/org/onap/vid/scheduler/RestObjects/RestObject.java
new file mode 100644
index 000000000..ff1ffb4c5
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/scheduler/RestObjects/RestObject.java
@@ -0,0 +1,39 @@
+/*-
+ * ============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.scheduler.RestObjects;
+
+
+public class RestObject<T> {
+
+ private T t;
+
+ private int statusCode= 0;
+
+ public void set(T t) { this.t = t; }
+
+ public T get() { return t; }
+
+ public void setStatusCode(int v) { this.statusCode = v; }
+
+ public int getStatusCode() { return this.statusCode; }
+
+}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerProperties.java b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerProperties.java
new file mode 100644
index 000000000..bb5f6ebb4
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerProperties.java
@@ -0,0 +1,19 @@
+package org.onap.vid.scheduler;
+
+import org.openecomp.portalsdk.core.util.SystemProperties;
+
+
+public class SchedulerProperties extends SystemProperties {
+
+ public static final String SCHEDULER_USER_NAME_VAL = "scheduler.user.name";
+
+ public static final String SCHEDULER_PASSWORD_VAL = "scheduler.password";
+
+ public static final String SCHEDULER_SERVER_URL_VAL = "scheduler.server.url";
+
+ public static final String SCHEDULER_GET_SCHEDULES = "scheduler.get.schedules";
+
+ public static final String SCHEDULER_DELETE_SCHEDULE = "scheduler.delete.schedule";
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java
new file mode 100644
index 000000000..2077e7a40
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterface.java
@@ -0,0 +1,214 @@
+package org.onap.vid.scheduler;
+
+import java.util.Collections;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.Response;
+
+import org.apache.commons.codec.binary.Base64;
+import org.eclipse.jetty.util.security.Password;
+import org.json.simple.JSONObject;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.onap.vid.client.HttpBasicClient;
+import org.onap.vid.client.HttpsBasicClient;
+import org.onap.vid.scheduler.SchedulerProperties;
+import org.onap.vid.scheduler.RestObjects.RestObject;
+import org.springframework.stereotype.Service;
+
+import static org.onap.vid.utils.Logging.getHttpServletRequest;
+import static org.onap.vid.utils.Logging.requestIdHeaderKey;
+
+@Service
+public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
+
+ private static Client client = null;
+
+ private MultivaluedHashMap<String, Object> commonHeaders;
+
+ /** The logger. */
+ static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SchedulerRestInterface.class);
+
+ public SchedulerRestInterface() {
+ super();
+ }
+
+ public void initRestClient()
+ {
+ System.out.println( "\t <== Starting to initialize rest client ");
+
+ final String username;
+ final String password;
+
+ /*Setting user name based on properties*/
+ String retrievedUsername = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_USER_NAME_VAL);
+ if(retrievedUsername.isEmpty()) {
+ username = "";
+ } else {
+ username = retrievedUsername;
+ }
+
+ /*Setting password based on properties*/
+ String retrievedPassword = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_PASSWORD_VAL);
+ if(retrievedPassword.isEmpty()) {
+ password = "";
+ } else {
+ if (retrievedPassword.contains("OBF:")) {
+ password = Password.deobfuscate(retrievedPassword);
+ } else {
+ password = retrievedPassword;
+ }
+ }
+
+ String authString = username + ":" + password;
+
+ byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
+ String authStringEnc = new String(authEncBytes);
+
+ commonHeaders = new MultivaluedHashMap<String, Object> ();
+ commonHeaders.put("Authorization", Collections.singletonList((Object) ("Basic " + authStringEnc)));
+
+ try {
+ if ( !username.isEmpty() ) {
+
+ client = HttpsBasicClient.getClient();
+ }
+ else {
+
+ client = HttpBasicClient.getClient();
+ }
+ } catch (Exception e) {
+ System.out.println( " <== Unable to initialize rest client ");
+ }
+
+ System.out.println( "\t<== Client Initialized \n");
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> void Get (T t, String sourceId, String path, org.onap.vid.scheduler.RestObject<T> restObject ) throws Exception {
+
+ String methodName = "Get";
+ String url = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_SERVER_URL_VAL) + path;
+
+
+ System.out.println( "<== URL FOR GET : " + url + "\n");
+
+ initRestClient();
+
+ final Response cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .get();
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if (status == 200) {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+
+ } else {
+ throw new Exception(methodName + " with status="+ status + ", url= " + url );
+ }
+
+ return;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> void Post(T t, JSONObject requestDetails, String path, RestObject<T> restObject) throws Exception {
+
+ String methodName = "Post";
+ String url = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_SERVER_URL_VAL) + path;
+
+ System.out.println( "<== URL FOR POST : " + url + "\n");
+
+ try {
+
+ initRestClient();
+
+ // Change the content length
+ final Response cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ .post(Entity.entity(requestDetails, MediaType.APPLICATION_JSON));
+
+ try {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+
+ System.out.println("<== " + methodName + " : No response entity, this is probably ok, e=" + e.getMessage());
+ }
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ if ( status >= 200 && status <= 299 ) {
+
+ System.out.println( "<== " + methodName + " : REST api POST was successful!" + "\n");
+
+ } else {
+ System.out.println( "<== " + methodName + " : FAILED with http status : "+status+", url = " + url + "\n");
+ }
+
+ } catch (Exception e)
+ {
+ System.out.println( "<== " + methodName + " : with url="+url+ ", Exception: " + e.toString() + "\n");
+ throw e;
+ }
+ }
+
+ @Override
+ public void logRequest(JSONObject requestDetails) {}
+
+ @SuppressWarnings("unchecked")
+ public <T> void Delete(T t, String sourceID, String path, org.onap.vid.scheduler.RestObject<T> restObject) {
+
+ String url="";
+ Response cres = null;
+
+ try {
+ initRestClient();
+
+ url = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_SERVER_URL_VAL) + path;
+
+ cres = client.target(url)
+ .request()
+ .accept("application/json")
+ .headers(commonHeaders)
+ .header(requestIdHeaderKey, getHttpServletRequest().getHeader(requestIdHeaderKey))
+ //.entity(r)
+ .delete();
+ // .method("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON));
+ //.delete(Entity.entity(r, MediaType.APPLICATION_JSON));
+
+ int status = cres.getStatus();
+ restObject.setStatusCode (status);
+
+ try {
+ t = (T) cres.readEntity(t.getClass());
+ restObject.set(t);
+ }
+ catch ( Exception e ) {
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ }
+
+ public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException
+ {
+ return clazz.newInstance();
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterfaceFactory.java b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterfaceFactory.java
new file mode 100644
index 000000000..1c3bea9f5
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterfaceFactory.java
@@ -0,0 +1,15 @@
+
+package org.onap.vid.scheduler;
+
+public class SchedulerRestInterfaceFactory {
+
+
+ public static SchedulerRestInterfaceIfc getInstance () {
+ SchedulerRestInterfaceIfc obj = null;
+
+ obj = new SchedulerRestInterface();
+
+ return ( obj );
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterfaceIfc.java b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterfaceIfc.java
new file mode 100644
index 000000000..7be8480ff
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/scheduler/SchedulerRestInterfaceIfc.java
@@ -0,0 +1,23 @@
+
+package org.onap.vid.scheduler;
+
+import org.json.simple.JSONObject;
+import org.onap.vid.scheduler.RestObjects.RestObject;
+import org.springframework.stereotype.Service;
+
+@Service
+public interface SchedulerRestInterfaceIfc {
+
+ public void initRestClient();
+
+ public <T> void Get (T t, String sourceId, String path, org.onap.vid.scheduler.RestObject<T> restObject ) throws Exception;
+
+ public <T> void Delete(T t, String sourceID, String path, org.onap.vid.scheduler.RestObject<T> restObject)
+ throws Exception;
+
+ public <T> void Post(T t, JSONObject r, String path, RestObject<T> restObject) throws Exception;
+
+ public void logRequest(JSONObject requestDetails);
+}
+
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java
new file mode 100644
index 000000000..4e86281c6
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiService.java
@@ -0,0 +1,63 @@
+package org.onap.vid.services;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.onap.vid.aai.AaiResponse;
+import org.onap.vid.aai.SubscriberFilteredResults;
+import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
+import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.model.ServiceInstanceSearchResult;
+import org.onap.vid.model.SubscriberList;
+import org.onap.vid.roles.RoleValidator;
+
+import javax.ws.rs.core.Response;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by Oren on 7/4/17.
+ */
+public interface AaiService {
+
+
+ SubscriberFilteredResults getFullSubscriberList(RoleValidator roleValidator);
+
+ AaiResponse getSubscriberData(String subscriberId, RoleValidator roleValidator);
+
+ AaiResponse getServiceInstanceSearchResults(String subscriberId, String instanceIdentifier, RoleValidator roleProvider, List<String> owningEntities, List<String> projects);
+
+ AaiResponse<SubscriberList> getFullSubscriberList();
+
+ AaiResponse getServices(RoleValidator roleValidator);
+
+ AaiResponse getAaiZones();
+
+ AaiResponse<OperationalEnvironmentList> getOperationalEnvironments(String operationalEnvironmentType, String operationalEnvironmentStatus);
+
+ AaiResponse getAicZoneForPnf(String globalCustomerId , String serviceType , String serviceId);
+
+ Response getVNFData(String globalSubscriberId, String serviceType);
+
+ AaiResponse<GetTenantsResponse[]> getTenants(String globalCustomerId, String serviceType, RoleValidator roleValidator);
+
+ AaiResponse getVNFData(String globalSubscriberId, String serviceType, String serviceInstanceId);
+
+ AaiResponse getNodeTemplateInstances(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion);
+
+ Response getVersionByInvariantId(List<String> modelInvariantId);
+
+ Collection<Service> getServicesByDistributionStatus();
+
+ AaiResponse<Pnf> getSpecificPnf(String pnfId);
+
+ List<String> getServiceInstanceAssociatedPnfs(String globalCustomerId, String serviceType, String serviceInstanceId);
+
+ AaiResponse getPNFData(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion, String equipVendor, String equipModel);
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
new file mode 100644
index 000000000..ffb43803c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
@@ -0,0 +1,435 @@
+package org.onap.vid.services;
+
+import org.apache.http.HttpStatus;
+import org.onap.vid.aai.model.AaiGetAicZone.AicZones;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.vid.aai.*;
+import org.onap.vid.aai.ServiceInstance;
+import org.onap.vid.aai.ServiceSubscription;
+import org.onap.vid.aai.Services;
+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.AaiGetTenatns.GetTenantsResponse;
+import org.onap.vid.aai.model.*;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.model.ServiceInstanceSearchResult;
+import org.onap.vid.model.SubscriberList;
+import org.onap.vid.roles.RoleValidator;
+import org.onap.vid.utils.Intersection;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.ws.rs.core.Response;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Created by Oren on 7/4/17.
+ */
+public class AaiServiceImpl implements AaiService {
+ private String serviceInstanceId = "service-instance.service-instance-id";
+ private String serviceType = "service-subscription.service-type";
+ private String customerId = "customer.global-customer-id";
+ private String serviceInstanceName = "service-instance.service-instance-name";
+ private int indexOfSubscriberName = 6;
+
+ @Autowired
+ private AaiClientInterface aaiClient;
+
+ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AaiServiceImpl.class);
+
+ private List<Service> convertModelToService(Model model) {
+ List<Service> services = new ArrayList<>();
+ String category = "";
+
+ if(validateModel(model)){
+ if(model.getModelType() != null)
+ category = model.getModelType();
+
+ for (ModelVer modelVer: model.getModelVers().getModelVer()) {
+ Service service = new Service();
+ if (modelVer.getModelVersionId() != null)
+ service.setUuid(modelVer.getModelVersionId());
+ if(model.getModelInvariantId() != null)
+ service.setInvariantUUID(model.getModelInvariantId());
+ if(modelVer.getModelVersion() != null)
+ service.setVersion(modelVer.getModelVersion());
+ if(modelVer.getModelName() != null)
+ service.setName(modelVer.getModelName());
+ if(modelVer.getDistributionStatus() != null)
+ service.setDistributionStatus(Service.DistributionStatus.valueOf(modelVer.getDistributionStatus()));
+ service.setCategory(category);
+
+ services.add(service);
+ }
+ } else {
+ return null;
+ }
+
+ return services;
+ }
+
+ private boolean validateModel(Model model){
+ if(model != null){
+ if(model.getModelVers() != null && model.getModelVers().getModelVer() != null && model.getModelVers().getModelVer().get(0).getModelVersionId() != null){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private List<ServiceInstanceSearchResult> getServicesByOwningEntityId(List<String> owningEntities, RoleValidator roleValidator) {
+ AaiResponse<OwningEntityResponse> owningEntityResponse = aaiClient.getServicesByOwningEntityId(owningEntities);
+ List<ServiceInstanceSearchResult> serviceInstanceSearchResultList = new ArrayList<>();
+ if (owningEntityResponse.getT() != null) {
+ for (OwningEntity owningEntity : owningEntityResponse.getT().getOwningEntity()) {
+ if (owningEntity.getRelationshipList() != null) {
+ serviceInstanceSearchResultList = convertRelationshipToSearchResult(owningEntity, serviceInstanceSearchResultList, roleValidator);
+ }
+ }
+ }
+ return serviceInstanceSearchResultList;
+ }
+
+ private List<ServiceInstanceSearchResult> getServicesByProjectNames(List<String> projectNames, RoleValidator roleValidator) {
+ AaiResponse<ProjectResponse> projectByIdResponse = aaiClient.getServicesByProjectNames(projectNames);
+ List<ServiceInstanceSearchResult> serviceInstanceSearchResultList = new ArrayList<>();
+ if (projectByIdResponse.getT() != null) {
+ for (Project project : projectByIdResponse.getT().getProject()) {
+ if (project.getRelationshipList() != null)
+ serviceInstanceSearchResultList = convertRelationshipToSearchResult(project, serviceInstanceSearchResultList, roleValidator);
+ }
+ }
+ return serviceInstanceSearchResultList;
+ }
+
+ private List<ServiceInstanceSearchResult> convertRelationshipToSearchResult(AaiRelationResponse owningEntityResponse, List<ServiceInstanceSearchResult> serviceInstanceSearchResultList, RoleValidator roleValidator) {
+ if (owningEntityResponse.getRelationshipList().getRelationship() != null) {
+ List<Relationship> relationshipList = owningEntityResponse.getRelationshipList().getRelationship();
+ for (Relationship relationship : relationshipList) {
+ ServiceInstanceSearchResult serviceInstanceSearchResult = new ServiceInstanceSearchResult();
+ extractRelationshipData(relationship, serviceInstanceSearchResult, roleValidator);
+ extractRelatedToProperty(relationship, serviceInstanceSearchResult);
+ serviceInstanceSearchResultList.add(serviceInstanceSearchResult);
+ }
+ }
+ return serviceInstanceSearchResultList;
+ }
+
+ private void extractRelationshipData(Relationship relationship, ServiceInstanceSearchResult serviceInstanceSearchResult, RoleValidator roleValidator) {
+ List<RelationshipData> relationshipDataList = relationship.getRelationDataList();
+ if (relationshipDataList != null) {
+ setSubscriberName(relationship, serviceInstanceSearchResult);
+ for (RelationshipData relationshipData : relationshipDataList) {
+ String key = relationshipData.getRelationshipKey();
+ if (key.equals(serviceInstanceId)) {
+ serviceInstanceSearchResult.setServiceInstanceId(relationshipData.getRelationshipValue());
+ } else if (key.equals(serviceType)) {
+ serviceInstanceSearchResult.setServiceType(relationshipData.getRelationshipValue());
+ } else if (key.equals(customerId)) {
+ serviceInstanceSearchResult.setGlobalCustomerId(relationshipData.getRelationshipValue());
+ }
+ }
+
+ boolean isPermitted = roleValidator.isServicePermitted(serviceInstanceSearchResult.getSubscriberName(), serviceInstanceSearchResult.getServiceType());
+ serviceInstanceSearchResult.setIsPermitted(isPermitted);
+ }
+ }
+
+ private void setSubscriberName(Relationship relationship, ServiceInstanceSearchResult serviceInstanceSearchResult) {
+ String relatedLink = relationship.getRelatedLink();
+ String[] subsciber = relatedLink.split("/");
+ serviceInstanceSearchResult.setSubscriberName(subsciber[indexOfSubscriberName]);
+ }
+
+ private void extractRelatedToProperty(Relationship relationship, ServiceInstanceSearchResult serviceInstanceSearchResult) {
+ List<RelatedToProperty> relatedToPropertyList = relationship.getRelatedToPropertyList();
+ if (relatedToPropertyList != null) {
+ for (RelatedToProperty relatedToProperty : relatedToPropertyList) {
+ if (relatedToProperty.getPropertyKey().equals(serviceInstanceName)) {
+ serviceInstanceSearchResult.setServiceInstanceName(relatedToProperty.getPropertyValue());
+ }
+ }
+ }
+ }
+
+ @Override
+ public SubscriberFilteredResults getFullSubscriberList(RoleValidator roleValidator) {
+ AaiResponse<SubscriberList> subscriberResponse = aaiClient.getAllSubscribers();
+ SubscriberFilteredResults subscriberFilteredResults =
+ new SubscriberFilteredResults(roleValidator, subscriberResponse.getT(),
+ subscriberResponse.getErrorMessage(),
+ subscriberResponse.getHttpCode());
+
+ return subscriberFilteredResults;
+ }
+
+ @Override
+ public AaiResponse<OperationalEnvironmentList> getOperationalEnvironments(String operationalEnvironmentType, String operationalEnvironmentStatus) {
+ AaiResponse<OperationalEnvironmentList> subscriberResponse = aaiClient.getOperationalEnvironments(operationalEnvironmentType, operationalEnvironmentStatus);
+ return subscriberResponse;
+ }
+
+ @Override
+ public AaiResponse<SubscriberList> getFullSubscriberList() {
+ AaiResponse<SubscriberList> subscriberResponse = aaiClient.getAllSubscribers();
+ return subscriberResponse;
+ }
+
+ @Override
+ public AaiResponse getSubscriberData(String subscriberId, RoleValidator roleValidator) {
+ AaiResponse<Services> subscriberResponse = aaiClient.getSubscriberData(subscriberId);
+ String subscriberGlobalId = subscriberResponse.getT().globalCustomerId;
+ for (ServiceSubscription serviceSubscription : subscriberResponse.getT().serviceSubscriptions.serviceSubscription) {
+ String serviceType = serviceSubscription.serviceType;
+ serviceSubscription.isPermitted = roleValidator.isServicePermitted(subscriberGlobalId, serviceType);
+ }
+ return subscriberResponse;
+
+ }
+
+ @Override
+ public AaiResponse getServiceInstanceSearchResults(String subscriberId, String instanceIdentifier, RoleValidator roleValidator, List<String> owningEntities, List<String> projects) {
+ List<List<ServiceInstanceSearchResult>> resultList = new ArrayList<>();
+ ServiceInstancesSearchResults serviceInstancesSearchResults = new ServiceInstancesSearchResults();
+
+ if (subscriberId != null || instanceIdentifier != null) {
+ resultList.add(getServicesBySubscriber(subscriberId, instanceIdentifier, roleValidator));
+ }
+ if (owningEntities != null) {
+ resultList.add(getServicesByOwningEntityId(owningEntities, roleValidator));
+ }
+ if (projects != null) {
+ resultList.add(getServicesByProjectNames(projects, roleValidator));
+ }
+ if (resultList.size() > 0) {
+ Intersection<ServiceInstanceSearchResult> intersection = new Intersection<>();
+ serviceInstancesSearchResults.serviceInstances = intersection.intersectMultipileArray(resultList);
+ }
+
+ return new AaiResponse<>(serviceInstancesSearchResults, null, HttpStatus.SC_OK);
+ }
+
+
+ private List<ServiceInstanceSearchResult> getServicesBySubscriber(String subscriberId, String instanceIdentifier, RoleValidator roleValidator) {
+ AaiResponse<Services> subscriberResponse = aaiClient.getSubscriberData(subscriberId);
+ String subscriberGlobalId = subscriberResponse.getT().globalCustomerId;
+ String subscriberName = subscriberResponse.getT().subscriberName;
+ ServiceSubscriptions serviceSubscriptions = subscriberResponse.getT().serviceSubscriptions;
+
+ return getSearchResultsForSubscriptions(serviceSubscriptions, subscriberId, instanceIdentifier, roleValidator, subscriberGlobalId, subscriberName);
+
+ }
+
+
+ private ArrayList<ServiceInstanceSearchResult> getSearchResultsForSubscriptions(ServiceSubscriptions serviceSubscriptions, String subscriberId, String instanceIdentifier, RoleValidator roleValidator, String subscriberGlobalId, String subscriberName) {
+ ArrayList<ServiceInstanceSearchResult> results = new ArrayList<>();
+
+ if (serviceSubscriptions != null) {
+ for (ServiceSubscription serviceSubscription : serviceSubscriptions.serviceSubscription) {
+ String serviceType = serviceSubscription.serviceType;
+ serviceSubscription.isPermitted = roleValidator.isServicePermitted(subscriberGlobalId, serviceType);
+ ArrayList<ServiceInstanceSearchResult> resultsForSubscription = getSearchResultsForSingleSubscription(serviceSubscription, subscriberId, instanceIdentifier, subscriberName, serviceType);
+ results.addAll(resultsForSubscription);
+ }
+ }
+
+ return results;
+ }
+
+ private ArrayList<ServiceInstanceSearchResult> getSearchResultsForSingleSubscription(ServiceSubscription serviceSubscription, String subscriberId, String instanceIdentifier, String subscriberName, String serviceType) {
+ ArrayList<ServiceInstanceSearchResult> results = new ArrayList<>();
+
+ if (serviceSubscription.serviceInstances != null) {
+ for (ServiceInstance serviceInstance : serviceSubscription.serviceInstances.serviceInstance) {
+ ServiceInstanceSearchResult serviceInstanceSearchResult =
+ new ServiceInstanceSearchResult(serviceInstance.serviceInstanceId, subscriberId, serviceType, serviceInstance.serviceInstanceName,
+ subscriberName, serviceInstance.modelInvariantId, serviceInstance.modelVersionId, serviceSubscription.isPermitted);
+
+ if (instanceIdentifier == null) {
+ results.add(serviceInstanceSearchResult);
+ } else if (serviceInstanceMatchesIdentifier(instanceIdentifier, serviceInstance)) {
+ results.add(serviceInstanceSearchResult);
+ }
+ }
+ }
+
+ return results;
+ }
+
+ private boolean serviceInstanceMatchesIdentifier(String instanceIdentifier, ServiceInstance serviceInstance) {
+ return instanceIdentifier.equals(serviceInstance.serviceInstanceId) || instanceIdentifier.equals(serviceInstance.serviceInstanceName);
+ }
+
+ @Override
+ public Response getVersionByInvariantId(List<String> modelInvariantId) {
+ try {
+ return aaiClient.getVersionByInvariantId(modelInvariantId);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ public AaiResponse<Pnf> getSpecificPnf(String pnfId) {
+ return aaiClient.getSpecificPnf(pnfId);
+ }
+
+ @Override
+ public AaiResponse getPNFData(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion, String equipVendor, String equipModel) {
+ return aaiClient.getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, equipModel);
+ }
+
+
+
+ @Override
+ public AaiResponse getServices(RoleValidator roleValidator) {
+ AaiResponse<GetServicesAAIRespone> subscriberResponse = aaiClient.getServices();
+ if (subscriberResponse.getT() != null)
+ for (org.onap.vid.aai.model.AaiGetServicesRequestModel.Service service : subscriberResponse.getT().service) {
+ service.isPermitted = true;
+ }
+ return subscriberResponse;
+ }
+
+ @Override
+ public AaiResponse<GetTenantsResponse[]> getTenants(String globalCustomerId, String serviceType, RoleValidator roleValidator) {
+ AaiResponse<GetTenantsResponse[]> aaiGetTenantsResponse = aaiClient.getTenants(globalCustomerId, serviceType);
+ GetTenantsResponse[] tenants = aaiGetTenantsResponse.getT();
+ if (tenants != null) {
+ for (int i = 0; i < tenants.length; i++) {
+ tenants[i].isPermitted = roleValidator.isTenantPermitted(globalCustomerId, serviceType, tenants[i].tenantName);
+ }
+ }
+ return aaiGetTenantsResponse;
+
+
+ }
+
+ @Override
+ public AaiResponse getVNFData(String globalSubscriberId, String serviceType, String serviceInstanceId) {
+ return aaiClient.getVNFData(globalSubscriberId, serviceType, serviceInstanceId);
+ }
+
+ @Override
+ public Response getVNFData(String globalSubscriberId, String serviceType) {
+ return aaiClient.getVNFData(globalSubscriberId, serviceType);
+ }
+
+ @Override
+ public AaiResponse getAaiZones() {
+ AaiResponse<AicZones> response = aaiClient.getAllAicZones();
+ return response;
+ }
+
+ @Override
+ public AaiResponse getAicZoneForPnf(String globalCustomerId, String serviceType, String serviceId) {
+ String aicZone = "";
+
+ AaiResponse<ServiceRelationships> serviceInstanceResp = aaiClient.getServiceInstance(globalCustomerId, serviceType, serviceId);
+ if (serviceInstanceResp.getT() != null) {
+ List<String> aicZoneList = getRelationshipDataByType(serviceInstanceResp.getT().getRelationshipList(), "zone", "zone.zone-id");
+ if (aicZoneList.size() > 0) {
+ aicZone = aicZoneList.get(0);
+ } else {
+ logger.warn("aic zone not found for service instance " + serviceId);
+ }
+ } else {
+ if (serviceInstanceResp.getErrorMessage() != null) {
+ logger.error("get service instance " + serviceId + " return error", serviceInstanceResp.getErrorMessage());
+ return new AaiResponse(aicZone , serviceInstanceResp.getErrorMessage() ,serviceInstanceResp.getHttpCode());
+ } else {
+ logger.warn("get service instance " + serviceId + " return empty body");
+ return new AaiResponse(aicZone , "get service instance " + serviceId + " return empty body" ,serviceInstanceResp.getHttpCode());
+ }
+ }
+
+ return new AaiResponse(aicZone , null ,HttpStatus.SC_OK);
+ }
+
+ @Override
+ public AaiResponse getNodeTemplateInstances(String globalCustomerId, String serviceType, String modelVersionId, String modelInvariantId, String cloudRegion) {
+ return aaiClient.getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion);
+ }
+
+ @Override
+ public Collection<Service> getServicesByDistributionStatus() {
+ AaiResponse<GetServiceModelsByDistributionStatusResponse> serviceModelsByDistributionStatusResponse = aaiClient.getServiceModelsByDistributionStatus();
+ Collection<Service> services = new ArrayList<>();
+ if (serviceModelsByDistributionStatusResponse.getT() != null) {
+ List<Result> results = serviceModelsByDistributionStatusResponse.getT().getResults();
+ for (Result result : results) {
+ if(result.getModel() != null) {
+ List<Service> service = convertModelToService(result.getModel());
+ if (service != null) {
+ services.addAll(service);
+ }
+ }
+ }
+ }
+ return services;
+ }
+
+ @Override
+ public List<String> getServiceInstanceAssociatedPnfs(String globalCustomerId, String serviceType, String serviceInstanceId) {
+ List<String> pnfs = new ArrayList<>();
+
+ AaiResponse<ServiceRelationships> serviceInstanceResp = aaiClient.getServiceInstance(globalCustomerId, serviceType, serviceInstanceId);
+ if (serviceInstanceResp.getT() != null) {
+ List<String> logicalLinks = getRelationshipDataByType(serviceInstanceResp.getT().getRelationshipList(), "logical-link", "logical-link.link-name");
+ for (String logicalLink : logicalLinks) {
+ String link = "";
+ try {
+ link = URLEncoder.encode(logicalLink, "UTF-8");
+ AaiResponse<LogicalLinkResponse> logicalLinkResp = aaiClient.getLogicalLink(link);
+ if (logicalLinkResp.getT() != null) {
+ //lag-interface is the key for pnf - approved by Bracha
+ List<String> linkPnfs = getRelationshipDataByType(logicalLinkResp.getT().getRelationshipList(), "lag-interface", "pnf.pnf-name");
+ if (linkPnfs.size() > 0) {
+ pnfs.addAll(linkPnfs);
+ } else {
+ logger.warn("no pnf found for logical link " + logicalLink);
+ }
+ } else {
+ if (logicalLinkResp.getErrorMessage() != null) {
+ logger.error("get logical link " + logicalLink + " return error", logicalLinkResp.getErrorMessage());
+ } else {
+ logger.warn("get logical link " + logicalLink + " return empty body");
+ }
+ }
+ } catch (UnsupportedEncodingException e) {
+ logger.error("Failed to encode logical link: " + logicalLink, e.getMessage());
+ }
+ }
+ } else {
+ if (serviceInstanceResp.getErrorMessage() != null) {
+ logger.error("get service instance " + serviceInstanceId + " return error", serviceInstanceResp.getErrorMessage());
+ } else {
+ logger.warn("get service instance " + serviceInstanceId + " return empty body");
+ }
+ }
+
+ return pnfs.stream().distinct().collect(Collectors.toList());
+ }
+
+ private List<String> getRelationshipDataByType(RelationshipList relationshipList, String relationshipType, String relationshipDataKey) {
+ List<String> relationshipValues = new ArrayList<>();
+ for (Relationship relationship : relationshipList.getRelationship()) {
+ if (relationship.getRelatedTo().equals(relationshipType)) {
+ relationshipValues.addAll( relationship.getRelationDataList().stream()
+ .filter(rel -> rel.getRelationshipKey().equals(relationshipDataKey))
+ .map(RelationshipData::getRelationshipValue)
+ .collect(Collectors.toList())
+ );
+ }
+ }
+
+
+ return relationshipValues;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterService.java b/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterService.java
new file mode 100644
index 000000000..a140007b0
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterService.java
@@ -0,0 +1,18 @@
+package org.onap.vid.services;
+
+import java.io.IOException;
+
+import org.onap.vid.category.AddCategoryOptionResponse;
+import org.onap.vid.category.CategoryParameterOptionRep;
+import org.onap.vid.category.CategoryParametersResponse;
+import org.onap.vid.category.AddCategoryOptionsRequest;
+import org.onap.vid.model.CategoryParameterOption;
+import org.onap.vid.model.CategoryParameter.Family;
+
+public interface CategoryParameterService {
+
+ CategoryParametersResponse getCategoryParameters(Family familyName) throws IOException;
+ AddCategoryOptionResponse createCategoryParameterOptions(String categoryName, AddCategoryOptionsRequest option) throws IOException;
+ AddCategoryOptionResponse updateCategoryParameterOption(String categoryName, CategoryParameterOptionRep option);
+ void deleteCategoryOption(String categoryName, CategoryParameterOption option) throws IOException;
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java
new file mode 100644
index 000000000..02d3521dc
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/CategoryParameterServiceImpl.java
@@ -0,0 +1,144 @@
+package org.onap.vid.services;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.service.DataAccessService;
+import org.onap.vid.category.AddCategoryOptionResponse;
+import org.onap.vid.category.CategoryParameterOptionRep;
+import org.onap.vid.model.CategoryParameter;
+import org.onap.vid.model.CategoryParameterOption;
+import org.onap.vid.category.AddCategoryOptionsRequest;
+import org.onap.vid.category.CategoryParametersResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.onap.vid.model.CategoryParameter.Family;
+
+import javax.ws.rs.ForbiddenException;
+
+
+@Service
+public class CategoryParameterServiceImpl implements CategoryParameterService {
+
+ @Autowired
+ private DataAccessService dataAccessService;
+
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(CategoryParameterServiceImpl.class);
+
+ public static class UnfoundedCategoryException extends RuntimeException {
+
+ public UnfoundedCategoryException(String message) {
+ super(message);
+ }
+ }
+
+ public static class UnfoundedCategoryOptionException extends RuntimeException {
+
+ public UnfoundedCategoryOptionException(String message) {
+ super(message);
+ }
+ }
+
+ public static class AlreadyExistOptionNameException extends RuntimeException {
+
+ public AlreadyExistOptionNameException(String message) {
+ super(message);
+ }
+ }
+
+ @Override
+ public CategoryParametersResponse getCategoryParameters(Family familyName) throws IOException {
+ List<CategoryParameter> categoryParameters = dataAccessService.getList(CategoryParameter.class, String.format(" where family = '%s' ",familyName), null, null);
+ return convertToCategoryParametersResponse(categoryParameters);
+ }
+
+ private CategoryParametersResponse convertToCategoryParametersResponse(List<CategoryParameter> categoryParameters) {
+ Comparator<CategoryParameterOptionRep> comparator = Comparator.comparing(CategoryParameterOptionRep::getName, String.CASE_INSENSITIVE_ORDER);
+ Map<String, List<CategoryParameterOptionRep>> categoryParametersMap = categoryParameters.stream().collect(Collectors.toMap(
+ CategoryParameter::getName,
+ x -> x.getOptions().stream().map(opt -> new CategoryParameterOptionRep(opt.getAppId(), opt.getName())).sorted(comparator).collect(Collectors.toList())));
+ return new CategoryParametersResponse(categoryParametersMap);
+ }
+
+ @Override
+ public AddCategoryOptionResponse createCategoryParameterOptions(String categoryName, AddCategoryOptionsRequest optionsRequest) throws IOException, UnfoundedCategoryException {
+
+ AddCategoryOptionResponse response = new AddCategoryOptionResponse(new ArrayList<>());
+ CategoryParameter categoryParameter = getCategoryParameter(categoryName);
+ Set<String> categoryOptions = categoryParameter.getOptions().stream().map(CategoryParameterOption::getName).collect(Collectors.toSet());
+ for (String optionName : optionsRequest.options) {
+ if (categoryOptions.contains(optionName)) {
+ response.getErrors().add(String.format("Option %s already exist for category %s", optionName, categoryName));
+ continue;
+ }
+ String appId = categoryParameter.isIdSupported() ? UUID.randomUUID().toString() : optionName;
+ CategoryParameterOption categoryParameterOption = new CategoryParameterOption(appId, optionName, categoryParameter);
+ dataAccessService.saveDomainObject(categoryParameterOption, null);
+ }
+
+ return response;
+ }
+
+ private CategoryParameter getCategoryParameter( String categoryName) {
+ List<CategoryParameter> categoryParameters = dataAccessService.getList(CategoryParameter.class, String.format(" where name = '%s' ", categoryName), null, null);
+ if (categoryParameters.size() != 1) {
+ String msg = "There is no category parameter with name " + categoryName;
+ LOG.debug(msg);
+ throw new UnfoundedCategoryException(msg);
+ }
+
+
+ return categoryParameters.get(0);
+ }
+
+ @Override
+ public AddCategoryOptionResponse updateCategoryParameterOption(String categoryName, CategoryParameterOptionRep option) {
+ AddCategoryOptionResponse response = new AddCategoryOptionResponse(new ArrayList<>());
+ CategoryParameter categoryParameter = getCategoryParameter(categoryName);
+ if (!categoryParameter.isIdSupported()) {
+ String msg = "Updating option name for category: " + categoryName + ", is not allowed";
+ LOG.debug(msg);
+ throw new ForbiddenException(msg);
+ }
+ Optional<CategoryParameterOption> categoryParameterOptionOptional = categoryParameter.getOptions().stream().filter(x->x.getAppId().equals(option.getId())).findFirst();
+ if (!categoryParameterOptionOptional.isPresent()) {
+ String msg = "There is no option with id "+option.getId() + " for category " + categoryName;
+ LOG.debug(msg);
+ throw new UnfoundedCategoryOptionException(msg);
+ }
+ CategoryParameterOption categoryParameterOption = categoryParameterOptionOptional.get();
+ Optional<CategoryParameterOption> alreadyExistOptionWithName = categoryParameter.getOptions().stream().filter(x->x.getName().equals(option.getName())).findFirst();
+ if (alreadyExistOptionWithName.isPresent() && !alreadyExistOptionWithName.get().getAppId().equals(categoryParameterOption.getAppId())) {
+ String msg = "Option with name "+option.getName() + " already exist for category " + categoryName;
+ LOG.debug(msg);
+ throw new AlreadyExistOptionNameException(msg);
+ }
+
+ categoryParameterOption.setName(option.getName());
+ dataAccessService.saveDomainObject(categoryParameterOption, null);
+
+ return response;
+ }
+
+ @Override
+ public void deleteCategoryOption(String categoryName, CategoryParameterOption option) throws IOException {
+ List<CategoryParameter> categoryParameters = dataAccessService.getList(CategoryParameter.class, String.format(" where name = '%s'", categoryName), null, null);
+ if (categoryParameters.size() != 1) {
+ String msg = "There is no category parameter with name " + categoryName;
+ LOG.debug(msg);
+ throw new UnfoundedCategoryException(msg);
+ }
+ CategoryParameter categoryParameter = categoryParameters.get(0);
+ Set<CategoryParameterOption> categoryOptions = categoryParameter.getOptions();
+ for (CategoryParameterOption categoryOption: categoryOptions) {
+ if(categoryOption.getName().equals(option.getName()))
+ {
+ dataAccessService.deleteDomainObject(categoryOption, null);
+ }
+ }
+ }
+
+}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java
new file mode 100644
index 000000000..bf0833182
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementService.java
@@ -0,0 +1,32 @@
+package org.onap.vid.services;
+
+import fj.data.Either;
+import org.apache.commons.lang3.tuple.Pair;
+import org.json.JSONObject;
+import org.onap.vid.changeManagement.*;
+import org.json.simple.JSONArray;
+import org.onap.vid.mso.rest.Request;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Collection;
+import java.util.List;
+
+public interface ChangeManagementService {
+ Collection<Request> getMSOChangeManagements() throws Exception;
+ ResponseEntity<String> doChangeManagement(ChangeManagementRequest request, String vnfName) throws Exception;
+ JSONArray getSchedulerChangeManagements();
+
+ /**
+ * Deleting a scheduled flow.
+ * @param scheduleId - the ID of the schedule.
+ * @return - a pair, left - String representation of the response, right - response code.
+ */
+ Pair<String, Integer> deleteSchedule(String scheduleId);
+ VnfWorkflowRelationResponse addVnfWorkflowRelation(VnfWorkflowRelationRequest vnfWorkflowRelationRequest);
+ List<String> getWorkflowsForVnf(GetVnfWorkflowRelationRequest getVnfWorkflowRelationRequest);
+ VnfWorkflowRelationResponse deleteVnfWorkflowRelation(VnfWorkflowRelationRequest vnfWorkflowRelationRequest);
+ VnfWorkflowRelationAllResponse getAllVnfWorkflowRelations();
+ String uploadConfigUpdateFile(MultipartFile file) throws Exception;
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java
new file mode 100644
index 000000000..078f44945
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ChangeManagementServiceImpl.java
@@ -0,0 +1,303 @@
+package org.onap.vid.services;
+
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
+import org.hibernate.NonUniqueObjectException;
+import org.json.JSONObject;
+import org.json.simple.JSONArray;
+import org.json.simple.parser.JSONParser;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.service.DataAccessService;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.onap.vid.changeManagement.*;
+import org.onap.vid.exceptions.NotFoundException;
+import org.onap.vid.model.VNFDao;
+import org.onap.vid.model.VidWorkflow;
+import org.onap.vid.mso.MsoBusinessLogic;
+import org.onap.vid.mso.MsoResponseWrapperInterface;
+import org.onap.vid.mso.rest.Request;
+import org.onap.vid.scheduler.SchedulerProperties;
+import org.onap.vid.scheduler.SchedulerRestInterfaceFactory;
+import org.onap.vid.scheduler.SchedulerRestInterfaceIfc;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.ws.rs.BadRequestException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+
+@Service
+public class ChangeManagementServiceImpl implements ChangeManagementService {
+
+ private final static String primaryKey = "payload";
+ private final static Set<String> requiredKeys = new HashSet<>(Arrays.asList("request-parameters", "configuration-parameters"));
+ private final DataAccessService dataAccessService;
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ChangeManagementServiceImpl.class);
+ private MsoBusinessLogic msoBusinessLogic;
+ @Autowired
+ private CsvService csvService;
+
+ @Autowired
+ public ChangeManagementServiceImpl(DataAccessService dataAccessService, MsoBusinessLogic msoBusinessLogic) {
+ this.dataAccessService = dataAccessService;
+ this.msoBusinessLogic = msoBusinessLogic;
+ }
+
+ @Override
+ public Collection<Request> getMSOChangeManagements() throws Exception {
+ Collection<Request> result = null;
+ return msoBusinessLogic.getOrchestrationRequestsForDashboard();
+ }
+
+ private RequestDetails findRequestByVnfName(List<RequestDetails> requests, String vnfName) {
+
+ if (requests == null)
+ return null;
+
+ for (RequestDetails requestDetails : requests) {
+ if (requestDetails.getVnfName().equals(vnfName)) {
+ return requestDetails;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<String> doChangeManagement(ChangeManagementRequest request, String vnfName) throws Exception {
+ if (request == null)
+ return null;
+ ResponseEntity<String> response;
+ RequestDetails currentRequestDetails = findRequestByVnfName(request.getRequestDetails(), vnfName);
+ MsoResponseWrapperInterface msoResponseWrapperObject = null;
+ if (currentRequestDetails != null) {
+
+ String serviceInstanceId = extractServiceInstanceId(currentRequestDetails, request.getRequestType());
+ String vnfInstanceId = extractVnfInstanceId(currentRequestDetails, request.getRequestType());
+ String requestType = request.getRequestType();
+ try {
+ switch (requestType.toLowerCase()) {
+ case ChangeManagementRequest.UPDATE: {
+ msoResponseWrapperObject = msoBusinessLogic.updateVnf(currentRequestDetails, serviceInstanceId, vnfInstanceId);
+ break;
+ }
+ case ChangeManagementRequest.REPLACE: {
+ msoResponseWrapperObject = msoBusinessLogic.replaceVnf(currentRequestDetails, serviceInstanceId, vnfInstanceId);
+ break;
+ }
+ case ChangeManagementRequest.VNF_IN_PLACE_SOFTWARE_UPDATE: {
+ msoResponseWrapperObject = msoBusinessLogic.updateVnfSoftware(currentRequestDetails, serviceInstanceId, vnfInstanceId);
+ break;
+ }
+ case ChangeManagementRequest.CONFIG_UPDATE: {
+ msoResponseWrapperObject = msoBusinessLogic.updateVnfConfig(currentRequestDetails, serviceInstanceId, vnfInstanceId);
+ break;
+ }
+ }
+ response = new ResponseEntity<String>(msoResponseWrapperObject.getResponse(), HttpStatus.OK);
+ return response;
+ } catch (Exception e) {
+ logger.error("Failure during doChangeManagement with request " + request.toString(), e);
+ throw e;
+ }
+
+ }
+
+ // AH:TODO: return ChangeManagementResponse
+ return null;
+ }
+
+ private String extractVnfInstanceId(RequestDetails currentRequestDetails, String requestType) {
+ if (currentRequestDetails.getVnfInstanceId() == null) {
+ logger.error("Failed to extract vnfInstanceId");
+ throw new BadRequestException("No vnfInstanceId in request " + requestType);
+ }
+ return currentRequestDetails.getVnfInstanceId();
+ }
+
+ private String extractServiceInstanceId(RequestDetails currentRequestDetails, String requestType) {
+ try {
+ String serviceInstanceId = currentRequestDetails.getRelatedInstList().get(0).getRelatedInstance().getInstanceId();
+ serviceInstanceId.toString(); //throw exception in case that serviceInstanceId is null...
+ return serviceInstanceId;
+ } catch (Exception e) {
+ logger.error("Failed to extract serviceInstanceId");
+ throw new BadRequestException("No instanceId in request " + requestType);
+ }
+ }
+
+ @Override
+ public JSONArray getSchedulerChangeManagements() {
+ JSONArray result = null;
+ try {
+ String path = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_GET_SCHEDULES);
+ org.onap.vid.scheduler.RestObject<String> restObject = new org.onap.vid.scheduler.RestObject<>();
+ SchedulerRestInterfaceIfc restClient = SchedulerRestInterfaceFactory.getInstance();
+
+ String str = new String();
+ restObject.set(str);
+ restClient.Get(str, "", path, restObject);
+ String restCallResult = restObject.get();
+ JSONParser parser = new JSONParser();
+ Object parserResult = parser.parse(restCallResult);
+ result = (JSONArray) parserResult;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ @Override
+ public Pair<String, Integer> deleteSchedule(String scheduleId) {
+ try {
+ String path = String.format(SystemProperties.getProperty(SchedulerProperties.SCHEDULER_DELETE_SCHEDULE), scheduleId);
+ org.onap.vid.scheduler.RestObject<String> restObject = new org.onap.vid.scheduler.RestObject<>();
+ SchedulerRestInterfaceIfc restClient = SchedulerRestInterfaceFactory.getInstance();
+ String str = new String();
+ restObject.set(str);
+ restClient.Delete(str, "", path, restObject);
+ String restCallResult = restObject.get();
+ return new ImmutablePair<>(restCallResult, restObject.getStatusCode());
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ return new ImmutablePair<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR.value());
+ }
+ }
+
+ @Override
+ public VnfWorkflowRelationResponse addVnfWorkflowRelation(VnfWorkflowRelationRequest vnfWorkflowRelationRequest) {
+ VnfWorkflowRelationResponse vnfWorkflowRelationResponse = new VnfWorkflowRelationResponse();
+ for (WorkflowsDetail workflowsDetail : vnfWorkflowRelationRequest.getWorkflowsDetails()) {
+ if (StringUtils.isEmpty(workflowsDetail.getVnfDetails().getUUID()) ||
+ StringUtils.isEmpty(workflowsDetail.getVnfDetails().getInvariantUUID())) {
+ vnfWorkflowRelationResponse.getErrors().add("Using empty UUID or invariantUUID is not allowed. Relation details: " + workflowsDetail.toString());
+ continue;
+ }
+ @SuppressWarnings("unchecked") List<VNFDao> vnfList = dataAccessService.getList(VNFDao.class, getVnfQueryString(workflowsDetail.getVnfDetails().getUUID(), workflowsDetail.getVnfDetails().getInvariantUUID()), null, null);
+ if (vnfList.size() == 0) {
+ vnfList.add(saveNewVnf(workflowsDetail));
+ }
+ @SuppressWarnings("unchecked") List<VidWorkflow> workflowList = dataAccessService.getList(VidWorkflow.class, String.format(" where wokflowName = '%s'", workflowsDetail.getWorkflowName()), null, null);
+ if (workflowList.size() == 0) {
+ vnfWorkflowRelationResponse.getErrors().add("Not Found instance of workflow " + workflowsDetail.getWorkflowName() + " for vnf with UUID " + workflowsDetail.getVnfDetails().getUUID() + " and with invariantUUID " + workflowsDetail.getVnfDetails().getInvariantUUID());
+ continue;
+ }
+ vnfList.get(0).getWorkflows().add(workflowList.get(0));
+ try {
+ dataAccessService.saveDomainObject(vnfList.get(0), null);
+ } catch (NonUniqueObjectException e) {
+ //In case the relation already exists, we continue running on the list
+ }
+ }
+ return vnfWorkflowRelationResponse;
+ }
+
+ @Override
+ public VnfWorkflowRelationResponse deleteVnfWorkflowRelation(VnfWorkflowRelationRequest vnfWorkflowRelationRequest) {
+ VnfWorkflowRelationResponse vnfWorkflowRelationResponse = new VnfWorkflowRelationResponse();
+ for (WorkflowsDetail workflowsDetail : vnfWorkflowRelationRequest.getWorkflowsDetails()) {
+ @SuppressWarnings("unchecked") List<VNFDao> vnfList = dataAccessService.getList(VNFDao.class, getVnfQueryString(workflowsDetail.getVnfDetails().getUUID(), workflowsDetail.getVnfDetails().getInvariantUUID()), null, null);
+ if (vnfList.size() != 1) {
+ vnfWorkflowRelationResponse.getErrors().add("Found " + vnfList.size() + " instances of vnf with UUID " + workflowsDetail.getVnfDetails().getUUID() + " and vnfInvariantUUID " + workflowsDetail.getVnfDetails().getInvariantUUID());
+ continue;
+ }
+ VidWorkflow vidWorkflow = getWorkflowOfVnf(vnfList.get(0), workflowsDetail.getWorkflowName());
+ if (vidWorkflow == null) {
+ vnfWorkflowRelationResponse.getErrors().add("Not Found instance of workflow " + workflowsDetail.getWorkflowName() + " for vnf with UUID " + workflowsDetail.getVnfDetails().getUUID() + " and with invariantUUID " + workflowsDetail.getVnfDetails().getInvariantUUID());
+ continue;
+ }
+ vnfList.get(0).getWorkflows().remove(vidWorkflow);
+ dataAccessService.saveDomainObject(vnfList.get(0), null);
+ }
+ return vnfWorkflowRelationResponse;
+
+ }
+
+ @Override
+ public List<String> getWorkflowsForVnf(GetVnfWorkflowRelationRequest getVnfWorkflowRelationRequest) {
+ List<VNFDao> vnfDaoList = new ArrayList<>();
+ List<Set<String>> workflowsList = new ArrayList<>();
+ getVnfDaoList(vnfDaoList, getVnfWorkflowRelationRequest);
+ getWorkflowsList(workflowsList, vnfDaoList);
+ return intersectWorkflows(workflowsList);
+ }
+
+ private void getVnfDaoList(List<VNFDao> vnfDaoList, GetVnfWorkflowRelationRequest getVnfWorkflowRelationRequest) {
+ for (VnfDetails vnfDetails : getVnfWorkflowRelationRequest.getVnfDetails()) {
+ @SuppressWarnings("unchecked") List<VNFDao> vnfList = dataAccessService.getList(VNFDao.class, getVnfQueryString(vnfDetails.getUUID(), vnfDetails.getInvariantUUID()), null, null);
+ if (vnfList.size() != 1) {
+ throw new NotFoundException("Found" + vnfList.size() + " instances of vnf with UUID" + vnfDetails.getUUID() + " and vnfInvariantUUID" + vnfDetails.getInvariantUUID());
+ }
+ vnfDaoList.add(vnfList.get(0));
+ }
+ }
+
+ private void getWorkflowsList(List<Set<String>> workflowsList, List<VNFDao> vnfDaoList) {
+ for (VNFDao vnfDao : vnfDaoList) {
+ Set<String> tempWorkflows = vnfDao.getWorkflows().stream().map(VidWorkflow::getWokflowName).collect(Collectors.toSet());
+ workflowsList.add(tempWorkflows);
+ }
+ }
+
+ private List<String> intersectWorkflows(List<Set<String>> workflowsList) {
+ Set<String> workflows = workflowsList.get(0);
+ for (Set<String> workflow : workflowsList) {
+ workflows.retainAll(workflow);
+ }
+ return new ArrayList<>(workflows);
+ }
+
+ private String getVnfQueryString(String UUID, String invariantUUID) {
+ return " where vnfInvariantUUID = '" + invariantUUID + "' and vnfUUID = '" + UUID + "'";
+ }
+
+ private VidWorkflow getWorkflowOfVnf(VNFDao vnfDao, String workflowName) {
+ VidWorkflow vidWorkflowRes = null;
+ for (VidWorkflow vidWorkflow : vnfDao.getWorkflows()) {
+ if (vidWorkflow.getWokflowName().equals(workflowName)) {
+ vidWorkflowRes = vidWorkflow;
+ }
+ }
+ return vidWorkflowRes;
+ }
+
+ private VNFDao saveNewVnf(WorkflowsDetail workflowsDetail) {
+ VNFDao vnfDao = new VNFDao();
+ vnfDao.setVnfUUID(workflowsDetail.getVnfDetails().getUUID());
+ vnfDao.setVnfInvariantUUID(workflowsDetail.getVnfDetails().getInvariantUUID());
+ dataAccessService.saveDomainObject(vnfDao, null);
+ return vnfDao;
+ }
+
+ @Override
+ public VnfWorkflowRelationAllResponse getAllVnfWorkflowRelations() {
+ @SuppressWarnings("unchecked") List<VNFDao> vnfList = dataAccessService.getList(VNFDao.class, null);
+ return new VnfWorkflowRelationAllResponse(
+ vnfList.stream()
+ .map(VnfDetailsWithWorkflows::new)
+ .collect(Collectors.toList()));
+ }
+
+ @Override
+ public String uploadConfigUpdateFile(MultipartFile file)
+ throws Exception {
+ JSONObject json = csvService.convertCsvToJson(csvService.readCsv(file));
+ if (!validateJsonOutput(json))
+ throw new BadRequestException("Invalid csv file");
+ json = json.getJSONObject(primaryKey);
+ json = new JSONObject().put(primaryKey, json.toString());
+ return json.toString();
+ }
+
+ private boolean validateJsonOutput(org.json.JSONObject json) {
+ if (!json.has(primaryKey) || !json.getJSONObject(primaryKey).keySet().containsAll(requiredKeys))
+ return false;
+ return true;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CsvService.java b/vid-app-common/src/main/java/org/onap/vid/services/CsvService.java
new file mode 100644
index 000000000..248068fba
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/CsvService.java
@@ -0,0 +1,15 @@
+package org.onap.vid.services;
+
+import org.json.JSONObject;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.List;
+
+public interface CsvService {
+ List<String[]> readCsv(String filePath) throws IOException;
+ JSONObject convertCsvToJson (List<String[]> myEntries) throws InstantiationException, IllegalAccessException;
+ List<String[]> readCsv(MultipartFile file) throws IOException;
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java
new file mode 100644
index 000000000..8152dae04
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/CsvServiceImpl.java
@@ -0,0 +1,250 @@
+//package org.onap.vid.services;
+//
+////import com.opencsv.CSVReader;
+//import org.json.JSONArray;
+//import org.json.JSONObject;
+//import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+//import org.springframework.stereotype.Service;
+//import org.springframework.web.multipart.MultipartFile;
+//
+//import javax.ws.rs.BadRequestException;
+//import java.io.FileNotFoundException;
+//import java.io.FileReader;
+//import java.io.IOException;
+//import java.io.InputStreamReader;
+//import java.util.ArrayList;
+//import java.util.Arrays;
+//import java.util.List;
+//
+//import static org.onap.vid.utils.Logging.getMethodName;
+//
+//@Service
+//public class CsvServiceImpl implements CsvService{
+//
+//
+// /** The logger. */
+// static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CsvServiceImpl.class);
+//
+// private static final String arrayRegex = "\\[(.*?)\\]";
+//
+//
+// /**
+// * In UTF-8 the first line starts with "\uFEFF" so need to remove it
+// * @param line is first line contains BOM
+// * @return line after change
+// */
+// private String [] removeBOMFromCsv(String [] line){
+// if (line.length>0)
+// line[0] = line[0].replaceFirst("\uFEFF","").replaceFirst("","");
+// return line;
+// }
+//
+// /**
+// * read a csv file and puts its content in list of string arrays (without the empty lines)
+// * @param filePath - the path of file to read
+// * @return the content of file
+// * @throws IOException
+// */
+// /*@Override
+// public List<String[]> readCsv(String filePath) throws IOException {
+// CSVReader reader = new CSVReader(new FileReader(filePath));
+// return readCsv(reader);
+// }
+//
+// @Override
+// public List<String[]> readCsv(MultipartFile file) throws IOException {
+// CSVReader reader = new CSVReader(new InputStreamReader(file.getInputStream()));
+// return readCsv(reader);
+// }
+//
+// private List<String[]> addLineWithoutSpaces(List<String[]> myEntries, String [] line){
+// line = Arrays.stream(line).filter(x -> !"".equals(x)).toArray(String[]::new);
+// if(line.length > 0)
+// myEntries.add(line);
+// return myEntries;
+// }
+//
+//
+// private List<String[]> readCsv(CSVReader reader) throws IOException {
+// try {
+// List<String[]> myEntries = new ArrayList<>() ;
+// String [] line;
+// Boolean firstLine = true;
+// while ((line = reader.readNext())!= null) {
+// if (firstLine) {
+// line = removeBOMFromCsv(line);
+// firstLine = false;
+// }
+// myEntries = addLineWithoutSpaces(myEntries, line);
+// }
+// return myEntries;
+// }
+// catch (Exception e){
+// logger.error("error during reading CSV file. exception:" + e.getMessage());
+// throw e;
+// }
+//
+// }*/
+//
+// /**
+// * main function that call to the recursive function with initial parameters
+// * @param myEntries - the matrix with file content
+// * @return the json
+// * @throws IOException
+// * @throws InstantiationException
+// * @throws IllegalAccessException
+// */
+// @Override
+// public JSONObject convertCsvToJson (List<String[]> myEntries) throws InstantiationException, IllegalAccessException {
+// try {
+// return buildJSON(myEntries, 0, 0, myEntries.size(), JSONObject.class);
+// }
+// catch (Exception e){
+// logger.error("error during parsing CSV file. exception:" + e.getMessage());
+// throw e;
+// }
+//
+// }
+//
+// /**
+// * it goes over the matrix column while the values are the same and returns the index of changed value
+// * @param myEntries the matrix
+// * @param i row index refer to the whole matrix
+// * @param j column index
+// * @param numLines the length of the current inner matrix
+// * @param startLine row index of inner matrix
+// * @return the index of changed line
+// */
+// private int findIndexOfChangedLine(List<String[]> myEntries, final int i, final int j, final int numLines, final int startLine) {
+// int k;
+// for(k = 0; k + i - startLine < numLines && myEntries.get(i)[j].equals(myEntries.get(k + i)[j]) ; k++);
+// return k;
+// }
+//
+// /**
+// * check in array if its first element or if the key already exist in the previous item
+// * @param jsonArray - the array to search in
+// * @param key - the key to check
+// * @return if exists or first element return true, otherwise- false
+// */
+// private Boolean keyExistsOrFirstElement( JSONArray jsonArray,String key){
+// Boolean exists = false;
+// Boolean first = false;
+// JSONObject lastItem = lastItemInArray(jsonArray);
+// if (lastItem == null) {
+// first = true;
+// }
+// else {
+// if (lastItem.has(key)) {
+// exists = true;
+// }
+// }
+// return exists||first;
+// }
+//
+// /**
+// * return last json in json array
+// * @param jsonArray
+// * @return last item or null if the array is empty
+// */
+// private JSONObject lastItemInArray(JSONArray jsonArray){
+// JSONObject lastItem = null;
+// if(jsonArray.length()>0) {
+// lastItem = (JSONObject) jsonArray.get(jsonArray.length() - 1);
+// }
+// return lastItem;
+// }
+//
+// /**
+// * append current json to the main json
+// * @param json - the main json to append to it
+// * @param key - key to append
+// * @param values - value(s) to append
+// * @param <T> can be JSONObject or JSONArray
+// * @param <E> string or jsonObject or jsonArray
+// * @return json after put
+// * @throws IllegalAccessException
+// * @throws InstantiationException
+// */
+// private <T, E> T putJson(T json, String key, E values) throws IllegalAccessException, InstantiationException {
+// if (json instanceof JSONArray){
+// JSONArray currentJson= ((JSONArray)json);
+// if (values == null) //array of strings (for last item)
+// {
+// currentJson.put(key);
+// }
+// else {
+// if (keyExistsOrFirstElement(currentJson, key)) {
+// currentJson.put(new JSONObject().put(key, values));
+// } else {
+// JSONObject lastItem = lastItemInArray(currentJson);
+// lastItem.put(key, values);
+// }
+// }
+// }
+// if (json instanceof JSONObject){
+// if (values == null)
+// throw new BadRequestException("Invalid csv file");
+// ((JSONObject)json).put(key,values);
+// }
+// return json;
+// }
+//
+//
+// /**
+// * recursive function to build JSON. Each time it counts the same values in left and send the smaller matrix
+// * (until the changed value) to the next time.
+// *
+// * @param myEntries - the whole matrix
+// * @param i- row index of the whole matrix
+// * @param j - column index
+// * @param numLines - number of lines of inner matrix (num of same values in the left column)
+// * @param clazz JSONArray or JSONObject
+// * @param <T> JSONArray or JSONObject
+// * @return the json object
+// * @throws IllegalAccessException
+// * @throws InstantiationException
+// */
+// private <T> T buildJSON(List<String[]> myEntries, int i, final int j, final int numLines, Class<T> clazz) throws IllegalAccessException, InstantiationException {
+// logger.debug(EELFLoggerDelegate.debugLogger, "start {}({}, {}, {})", getMethodName(), i, j, numLines);
+// T json = clazz.newInstance();
+// int startLine = i;
+// while(i < numLines + startLine){
+// String[] currentRow = myEntries.get(i);
+// int length = currentRow.length;
+// int currentDuplicateRows = findIndexOfChangedLine(myEntries,i,j,numLines, startLine);
+// String key = currentRow[j];
+// if (j == length-1) {
+// json = putJson(json,currentRow[j],null);
+//
+// }
+// else
+// {
+// if (key.matches(arrayRegex)){
+// JSONArray arrayObjects = buildJSON(myEntries, i, j + 1, currentDuplicateRows, JSONArray.class);
+// json = putJson(json,key.replaceAll("\\[","").replaceAll("]",""),arrayObjects);
+// }
+// else {
+// if (j < length - 2) {
+// json = putJson(json, currentRow[j], buildJSON(myEntries, i, j + 1, currentDuplicateRows, JSONObject.class));
+// }
+// else
+// {
+// if (j == length - 2)//last object
+// {
+// if(currentDuplicateRows > 1) {
+// throw new BadRequestException("Invalid csv file");
+// }
+// json = putJson(json, currentRow[j], currentRow[j + 1]);
+// }
+// }
+// }
+// }
+// i += currentDuplicateRows;
+// }
+// logger.debug(EELFLoggerDelegate.debugLogger, "end {} json = {}", getMethodName(), json);
+// return json;
+// }
+//
+//}
+//
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java
new file mode 100644
index 000000000..ea2cea57b
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/RoleGenaratorServiceImpl.java
@@ -0,0 +1,164 @@
+package org.onap.vid.services;
+
+import jline.internal.Log;
+import org.junit.Test;
+import org.onap.vid.aai.*;
+import org.onap.vid.model.ModelConstants;
+import org.onap.vid.model.Subscriber;
+import org.onap.vid.model.SubscriberList;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+
+@Service
+public class RoleGenaratorServiceImpl implements RoleGeneratorService {
+
+ @Autowired
+ AaiClientInterface client;
+
+ public static final String dbName = "vid_portal";
+ public static final String tblName = "fn_role";
+ public static final String tempDelimiter ="***";
+ public static final String oldDelimiter = "_";
+
+ @Override
+ public String generateRoleScript(Boolean firstRun) {
+ String query = "USE " + dbName + ";\r\n" +
+ "SET SQL_SAFE_UPDATES = 0;\r\n";
+ try {
+ AaiResponse<SubscriberList> subscribers = client.getAllSubscribers();
+ if (firstRun) {
+ query += replaceRolesToTempDelimiter("subscriber",buildSubscribersValuesForMappingsTable(subscribers.getT()));
+ }
+ query += addAvailableRolesCombination(firstRun, subscribers);
+
+ }
+ catch (Exception e) {
+ Log.error("There was an error in updating roles "+e.getMessage());
+ }
+ return query;
+ }
+
+ private String addAvailableRolesCombination(Boolean firstRun, AaiResponse<SubscriberList> subscribers) {
+ String query, availableRoles="";
+ HashMap<String,String> servicesNames = new HashMap<String,String>();
+ for (Subscriber subscriber: subscribers.getT().customer) {
+ AaiResponse<Services> subscriberResponse = client.getSubscriberData(subscriber.globalCustomerId);
+ for(ServiceSubscription service: subscriberResponse.getT().serviceSubscriptions.serviceSubscription) {
+ servicesNames.put(service.serviceType,"");
+ String roleName = "'" + subscriber.subscriberName + ModelConstants.ROLE_DELIMITER + service.serviceType + "'";
+ availableRoles += "("+roleName+"),";
+
+
+ }
+ }
+ availableRoles = availableRoles.substring(0,availableRoles.length()-1);
+ query = createTemporaryTableAvailableRoles(availableRoles);
+ if (firstRun){
+ query += replaceRolesToTempDelimiter("service",buildServicesValuesForMappingsTable(servicesNames));
+ query += replaceToNewDelimiter();
+ query += deleteWrongRecords();
+
+ }
+ query += insertAvailableRolesToFnRole();
+ query += dropTemporaryTable("available_roles");
+ return query;
+ }
+
+ private String buildSubscribersValuesForMappingsTable(SubscriberList subscribers){
+ String query="";
+ for (Subscriber subscriber : subscribers.customer) {
+ String subscriberName = subscriber.subscriberName.contains(oldDelimiter) ? subscriber.subscriberName.replace(oldDelimiter, tempDelimiter) : subscriber.subscriberName;
+ query = query + "('" + subscriber.globalCustomerId + "','" + subscriberName + "') ,";
+ }
+ if(query.length() > 0)
+ query = query.substring(0, query.length()-1) + ";\r\n";
+ return query;
+ }
+
+ private String buildServicesValuesForMappingsTable(HashMap<String,String> servicesNames){
+ final String[] query = {""};
+ servicesNames.forEach((k,v)->{
+ if (k.contains(oldDelimiter)) {
+ query[0] += "('" + k + "' ,'" + k.replace(oldDelimiter, tempDelimiter) +"'),";
+ }
+ });
+ if(query[0].length() > 0)
+ query[0] = query[0].substring(0, query[0].length()-1) + ";\r\n";
+ return query[0];
+ }
+
+ private String replaceRolesToTempDelimiter(String entityName, String valuesForMappingsTable ) {
+
+ AaiResponse<Services> services = client.getServices();
+ String query = "";
+ if (valuesForMappingsTable.length() > 0) {
+ query = "CREATE TEMPORARY TABLE IF NOT EXISTS " + entityName + "Mappings(mapKey VARCHAR(255),mapValue VARCHAR(255));\r\n" +
+ "INSERT INTO " + entityName + "Mappings VALUES ";
+ query += valuesForMappingsTable;
+ query += "UPDATE " + tblName + "\r\n" +
+ "INNER JOIN " + entityName + "Mappings ON role_name LIKE concat('%',mapKey, '%')\r\n" +
+ "SET ROLE_NAME = REPLACE(ROLE_NAME, mapKey, mapValue) ; \r\n" +
+ dropTemporaryTable(entityName + "Mappings");
+ }
+ return query;
+ }
+
+ private String replaceToNewDelimiter(){
+ String query = "UPDATE " + tblName + "\r\n" +
+ "SET ROLE_NAME = REPLACE(ROLE_NAME, '" + oldDelimiter + "', '" + ModelConstants.ROLE_DELIMITER + "');\r\n" ;
+ query += "UPDATE fn_role\r\n" +
+ "SET ROLE_NAME = REPLACE(ROLE_NAME, '" + tempDelimiter + "', '" + oldDelimiter + "');\r\n" ;
+ return query;
+ }
+
+ private String insertAvailableRolesToFnRole(){
+ String query="INSERT INTO fn_role (ROLE_NAME, ACTIVE_YN, PRIORITY)\r\n" +
+ "SELECT RNAME, 'Y', 5\r\n" +
+ "FROM available_roles\r\n" +
+ "WHERE NOT EXISTS (SELECT ROLE_NAME\r\n" +
+ "FROM fn_role \r\n" +
+ "where RNAME = ROLE_NAME);\r\n";
+ return query;
+ }
+
+
+
+ private String createTemporaryTableAvailableRoles(String availableRoles) {
+ String query = "CREATE TEMPORARY TABLE IF NOT EXISTS available_roles(rname VARCHAR(255));\r\n";
+ query += "INSERT INTO available_roles VALUES "+availableRoles+";\r\n";
+ return query;
+ }
+
+ private String deleteWrongRecords(){
+ String query ="CREATE TEMPORARY TABLE IF NOT EXISTS wrong_roles(roleID INT);\r\n" +
+ "INSERT INTO wrong_roles (roleID)\r\n" +
+ "SELECT ROLE_ID FROM fn_role LEFT JOIN available_roles ON role_name LIKE concat(rname, '%')\r\n" +
+ "WHERE available_roles.rname IS NULL AND ROLE_ID NOT IN (1,16);\r\n";
+ query += deleteCascade();
+ query += dropTemporaryTable("wrong_roles");
+ return query;
+ }
+
+ private String deleteCascade() {
+ String query = deleteFromTableByRoles("fn_role_composite", "PARENT_ROLE_ID");
+ query = query.substring(0, query.length()-1);
+ query += " OR wrong_roles.ROLEID = fn_role_composite.CHILD_ROLE_ID;\r\n";
+ query += deleteFromTableByRoles("fn_role_function", "ROLE_ID")+ "\r\n";
+ query += deleteFromTableByRoles("fn_user_role", "ROLE_ID")+ "\r\n";
+ query += deleteFromTableByRoles("fn_role", "ROLE_ID")+ "\r\n";
+ return query;
+ }
+
+ private String deleteFromTableByRoles(String table, String column) {
+ String query = "DELETE FROM " + table + "\r\n";
+ query += "using " + table + " inner join wrong_roles\r\n" +
+ "where wrong_roles.ROLEID = " + table + "." + column + ";";
+ return query;
+ }
+
+ private String dropTemporaryTable(String table) {
+ return "DROP TEMPORARY TABLE IF EXISTS " + table + ";\r\n";
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/RoleGeneratorService.java b/vid-app-common/src/main/java/org/onap/vid/services/RoleGeneratorService.java
new file mode 100644
index 000000000..2bc96a5b2
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/RoleGeneratorService.java
@@ -0,0 +1,5 @@
+package org.onap.vid.services;
+
+public interface RoleGeneratorService {
+ String generateRoleScript(Boolean firstRun);
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/VidService.java b/vid-app-common/src/main/java/org/onap/vid/services/VidService.java
new file mode 100644
index 000000000..328fad019
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/VidService.java
@@ -0,0 +1,17 @@
+package org.onap.vid.services;
+
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.model.ServiceModel;
+
+import java.util.Collection;
+import java.util.Map;
+
+public interface VidService {
+
+ Collection<Service> getServices(Map<String, String[]> requestParams)
+ throws AsdcCatalogException;
+
+ ServiceModel getService(String uuid) throws AsdcCatalogException;
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
new file mode 100644
index 000000000..81966439e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/VidServiceImpl.java
@@ -0,0 +1,79 @@
+package org.onap.vid.services;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.asdc.AsdcClient;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.asdc.parser.ToscaParser;
+import org.onap.vid.asdc.parser.ToscaParserImpl;
+import org.onap.vid.asdc.parser.ToscaParserImpl2;
+import org.onap.vid.model.ServiceModel;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * The Class VidController.
+ */
+
+public class VidServiceImpl implements VidService {
+ /**
+ * The Constant LOG.
+ */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VidServiceImpl.class);
+ /**
+ * The Constant dateFormat.
+ */
+ protected final AsdcClient asdcClient;
+ @Autowired
+ private ToscaParserImpl2 toscaParser;
+
+ public VidServiceImpl(AsdcClient asdcClient) {
+ this.asdcClient = asdcClient;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.vid.controller.VidService#getServices(java.util.Map)
+ */
+ @Override
+ public Collection<Service> getServices(Map<String, String[]> requestParams)
+ throws AsdcCatalogException {
+ return asdcClient.getServices(requestParams);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.vid.controller.VidService#getService(java.lang.String)
+ */
+ @Override
+ public ServiceModel getService(String uuid) throws AsdcCatalogException {
+ final Path serviceCsar = asdcClient.getServiceToscaModel(UUID.fromString(uuid));
+ ToscaParser tosca = new ToscaParserImpl();
+ serviceCsar.toFile().getAbsolutePath();
+ ServiceModel serviceModel = null;
+ try {
+ final Service asdcServiceMetadata = asdcClient.getService(UUID.fromString(uuid));
+ return getServiceModel(uuid, serviceCsar, tosca, asdcServiceMetadata);
+ } catch (Exception e) {
+ LOG.error("Failed to download and proccess service from ASDC", e);
+ }
+ return serviceModel;
+ }
+
+ private ServiceModel getServiceModel(String uuid, Path serviceCsar, ToscaParser tosca, Service asdcServiceMetadata) throws Exception {
+ try {
+ return toscaParser.makeServiceModel(serviceCsar, asdcServiceMetadata);
+ } catch (SdcToscaParserException e) {
+ return tosca.makeServiceModel(uuid, serviceCsar, asdcServiceMetadata);
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/WorkflowService.java b/vid-app-common/src/main/java/org/onap/vid/services/WorkflowService.java
new file mode 100644
index 000000000..ea139080f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/WorkflowService.java
@@ -0,0 +1,9 @@
+package org.onap.vid.services;
+
+import org.onap.vid.model.Workflow;
+import java.util.Collection;
+
+public interface WorkflowService {
+ Collection<String> getWorkflowsForVNFs(Collection<String> vnfNames);
+ Collection<String> getAllWorkflows();
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/WorkflowServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/WorkflowServiceImpl.java
new file mode 100644
index 000000000..037c49c17
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/WorkflowServiceImpl.java
@@ -0,0 +1,40 @@
+package org.onap.vid.services;
+
+import org.onap.vid.model.Workflow;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.stream.Collectors;
+
+@Service
+public class WorkflowServiceImpl implements WorkflowService {
+ //TODO: Add the list of workflows hard coded or from DB.
+ private ArrayList<Workflow> workflows = new ArrayList<>(Arrays.asList(
+ new Workflow(0, "Upgrade", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF3", "VNF4"))),
+ new Workflow(1, "Clean", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF3"))),
+ new Workflow(2, "Reinstall", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF4"))),
+ new Workflow(3, "Dump", new ArrayList<>(Arrays.asList("VNF1", "VNF3", "VNF4"))),
+ new Workflow(4, "Flush", new ArrayList<>(Arrays.asList("VNF2", "VNF3", "VNF4")))
+ ));
+
+ @Override
+ public Collection<String> getWorkflowsForVNFs(Collection<String> vnfNames) {
+ Collection<String> result = workflows.stream()
+ .filter(workflow -> workflow.getVnfNames().containsAll(vnfNames))
+ .map(workflow -> workflow.getWorkflowName())
+ .distinct()
+ .collect(Collectors.toList());
+
+ return result;
+ }
+
+ @Override
+ public Collection<String> getAllWorkflows() {
+ return workflows.stream()
+ .map(workflow -> workflow.getWorkflowName())
+ .distinct()
+ .collect(Collectors.toList());
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/utils/Intersection.java b/vid-app-common/src/main/java/org/onap/vid/utils/Intersection.java
new file mode 100644
index 000000000..6e0d1fc25
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/utils/Intersection.java
@@ -0,0 +1,31 @@
+package org.onap.vid.utils;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Created by moriya1 on 10/10/2017.
+ */
+public class Intersection<T> {
+ public List<T> intersectMultipileArray(List<List<T>> lists) {
+ if (lists.size() == 1) {
+ return lists.get(0);
+ } else {
+ List<T> intersectResult = intersectTwoArrays(lists.get(0),lists.get(1));
+
+ lists.remove(0);
+ lists.remove(0);
+ lists.add(0,intersectResult);
+ return intersectMultipileArray(lists);
+ }
+
+ }
+
+ public List<T> intersectTwoArrays(List<T> list1, List<T> list2) {
+
+ List<T> intersect = list1.stream()
+ .filter(list2::contains)
+ .collect(Collectors.toList());
+ return intersect;
+ }
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java b/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
new file mode 100644
index 000000000..16dde5682
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
@@ -0,0 +1,105 @@
+package org.onap.vid.utils;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.springframework.http.HttpMethod;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.ProcessingException;
+import javax.ws.rs.core.Response;
+import java.util.Arrays;
+import java.util.Optional;
+
+import static org.onap.vid.utils.Streams.not;
+
+public class Logging {
+
+ private Logging() {
+ }
+
+ public static final String HTTP_REQUESTS_OUTGOING = "http.requests.outgoing.";
+
+ public static final String requestIdHeaderKey = SystemProperties.ECOMP_REQUEST_ID;
+
+ private static ObjectMapper objectMapper = new ObjectMapper();
+
+ public static String getMethodName() {
+ return getMethodName(0);
+ }
+
+ public static String getMethodCallerName() {
+ return getMethodName(1);
+ }
+
+ private static String getMethodName(int depth) {
+ final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+ String thisClassName = stackTrace[1].getClassName();
+ final Optional<String> caller =
+ Arrays.stream(stackTrace)
+ .skip(1)
+ .filter(not(frame -> frame.getClassName().equals(thisClassName)))
+ .skip(depth)
+ .map(StackTraceElement::getMethodName)
+ .findFirst();
+ return caller.orElse("<unknonwn method name>");
+ }
+
+ public static EELFLogger getRequestsLogger(String serverName) {
+ return EELFLoggerDelegate.getLogger(HTTP_REQUESTS_OUTGOING +serverName);
+ }
+
+ public static void logRequest(final EELFLogger logger, final HttpMethod method, final String url, final Object body) {
+ if (!logger.isDebugEnabled()) {
+ return;
+ }
+
+ if (body == null) {
+ logRequest(logger, method, url);
+ return;
+ }
+
+ try {
+ String bodyAsJson = objectMapper.writeValueAsString(body);
+ logger.debug("Sending {} {} Body: {}", method.name(), url, bodyAsJson);
+ } catch (JsonProcessingException e) {
+ logRequest(logger, method, url);
+ logger.debug("Failed to parse object in logRequest. {}", body);
+ }
+ }
+
+ public static void logRequest(final EELFLogger logger, final HttpMethod method, final String url) {
+ logger.debug("Sending {} {}", method.name(), url);
+ }
+
+ public static <T> void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final Response response, final Class<T> entityClass) {
+ if (!logger.isDebugEnabled()) {
+ return;
+ }
+ if (response == null) {
+ logger.debug("Received {} {} response: null", method.name(), url);
+ return;
+ }
+ try {
+ response.bufferEntity();
+ logger.debug("Received {} {} Status: {} . Body: {}", method.name(), url, response.getStatus(), response.readEntity(entityClass));
+ }
+ catch (ProcessingException | IllegalStateException e) {
+ logger.debug("Received {} {} Status: {} . Failed to read response as {}", method.name(), url, response.getStatus(), entityClass.getName());
+ }
+ }
+
+ public static void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final Response response) {
+ logResponse(logger, method, url, response, String.class);
+ }
+
+ public static HttpServletRequest getHttpServletRequest(){
+ return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
+ }
+
+
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/utils/Streams.java b/vid-app-common/src/main/java/org/onap/vid/utils/Streams.java
new file mode 100644
index 000000000..7f81b225a
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/utils/Streams.java
@@ -0,0 +1,47 @@
+package org.onap.vid.utils;
+
+import java.util.Iterator;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+
+public class Streams {
+ public static <R> Predicate<R> not(Predicate<R> predicate) {
+ return predicate.negate();
+ }
+
+ public static <T> Stream<T> fromIterator(final Iterator<T> iterator) {
+ Iterable<T> iterable = () -> iterator;
+ return StreamSupport.<T>stream(iterable.spliterator(), false);
+ }
+
+
+ // https://stackoverflow.com/questions/20746429/limit-a-stream-by-a-predicate
+ private static <T> Spliterator<T> takeWhile(
+ Spliterator<T> splitr, Predicate<? super T> predicate) {
+ return new Spliterators.AbstractSpliterator<T>(splitr.estimateSize(), 0) {
+ boolean stillGoing = true;
+ @Override public boolean tryAdvance(Consumer<? super T> consumer) {
+ if (stillGoing) {
+ boolean hadNext = splitr.tryAdvance(elem -> {
+ if (predicate.test(elem)) {
+ consumer.accept(elem);
+ } else {
+ stillGoing = false;
+ }
+ });
+ return hadNext && stillGoing;
+ }
+ return false;
+ }
+ };
+ }
+
+ public static <T> Stream<T> takeWhile(Stream<T> stream, Predicate<? super T> predicate) {
+ return StreamSupport.stream(takeWhile(stream.spliterator(), predicate), false);
+ }
+
+}