From 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Mon, 30 Jul 2018 15:56:09 -0400 Subject: Containerization feature of SO Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) --- .../java/org/onap/so/client/DefaultProperties.java | 42 + .../main/java/org/onap/so/client/HttpClient.java | 53 + .../so/client/PreconditionFailedException.java | 35 + .../onap/so/client/ResponseExceptionMapper.java | 101 ++ .../so/client/ResponseExceptionMapperImpl.java | 38 + .../main/java/org/onap/so/client/RestClient.java | 320 ++++++ .../java/org/onap/so/client/RestClientSSL.java | 94 ++ .../java/org/onap/so/client/RestProperties.java | 39 + .../org/onap/so/client/RestPropertiesLoader.java | 79 ++ .../main/java/org/onap/so/client/RestRequest.java | 91 ++ .../java/org/onap/so/client/aai/AAIClient.java | 62 + .../aai/AAIClientResponseExceptionMapper.java | 63 ++ .../aai/AAICommonObjectMapperPatchProvider.java | 35 + .../client/aai/AAICommonObjectMapperProvider.java | 52 + .../onap/so/client/aai/AAIConfigurationClient.java | 83 ++ .../org/onap/so/client/aai/AAIErrorFormatter.java | 56 + .../onap/so/client/aai/AAINamespaceConstants.java | 31 + .../org/onap/so/client/aai/AAIObjectPlurals.java | 69 ++ .../java/org/onap/so/client/aai/AAIObjectType.java | 104 ++ .../java/org/onap/so/client/aai/AAIProperties.java | 34 + .../org/onap/so/client/aai/AAIQueryClient.java | 83 ++ .../client/aai/AAIQueryObjectMapperProvider.java | 39 + .../org/onap/so/client/aai/AAIResourcesClient.java | 254 +++++ .../aai/AAIResourcesObjectMapperProvider.java | 29 + .../java/org/onap/so/client/aai/AAIRestClient.java | 131 +++ .../org/onap/so/client/aai/AAIRestClientI.java | 51 + .../org/onap/so/client/aai/AAIRestClientImpl.java | 197 ++++ .../org/onap/so/client/aai/AAISubgraphType.java | 38 + .../onap/so/client/aai/AAITransactionalClient.java | 264 +++++ .../java/org/onap/so/client/aai/AAIUpdator.java | 31 + .../org/onap/so/client/aai/AAIUpdatorImpl.java | 51 + .../java/org/onap/so/client/aai/AAIValidator.java | 32 + .../org/onap/so/client/aai/AAIValidatorImpl.java | 71 ++ .../java/org/onap/so/client/aai/AAIVersion.java | 44 + .../so/client/aai/EmptyStringToNullSerializer.java | 52 + .../org/onap/so/client/aai/entities/AAIEntity.java | 25 + .../so/client/aai/entities/AAIEntityObject.java | 29 + .../org/onap/so/client/aai/entities/AAIError.java | 46 + .../so/client/aai/entities/AAIResultWrapper.java | 92 ++ .../onap/so/client/aai/entities/Configuration.java | 161 +++ .../onap/so/client/aai/entities/CustomQuery.java | 82 ++ .../onap/so/client/aai/entities/Relationships.java | 140 +++ .../onap/so/client/aai/entities/RequestError.java | 46 + .../org/onap/so/client/aai/entities/Results.java | 51 + .../so/client/aai/entities/ServiceException.java | 75 ++ .../aai/entities/bulkprocess/OperationBody.java | 69 ++ .../aai/entities/bulkprocess/Transaction.java | 95 ++ .../aai/entities/bulkprocess/Transactions.java | 54 + .../so/client/aai/entities/uri/AAIResourceUri.java | 46 + .../so/client/aai/entities/uri/AAISimpleUri.java | 111 ++ .../onap/so/client/aai/entities/uri/AAIUri.java | 60 + .../so/client/aai/entities/uri/AAIUriFactory.java | 86 ++ .../onap/so/client/aai/entities/uri/NodesUri.java | 43 + .../aai/entities/uri/ServiceInstanceUri.java | 126 +++ .../aai/objects/AAIOperationalEnvironment.java | 159 +++ .../so/client/aai/objects/AAIServiceInstance.java | 141 +++ .../so/client/adapter/rest/AdapterRestClient.java | 79 ++ .../client/adapter/rest/AdapterRestProperties.java | 29 + .../DefaultDmaapPropertiesImpl.java | 49 + .../PolicyRestPropertiesImpl.java | 81 ++ .../java/org/onap/so/client/dmaap/Consumer.java | 26 + .../java/org/onap/so/client/dmaap/DmaapClient.java | 74 ++ .../org/onap/so/client/dmaap/DmaapConsumer.java | 126 +++ .../org/onap/so/client/dmaap/DmaapProperties.java | 32 + .../so/client/dmaap/DmaapPropertiesLoader.java | 69 ++ .../org/onap/so/client/dmaap/DmaapPublisher.java | 51 + .../java/org/onap/so/client/dmaap/Publisher.java | 26 + .../dmaap/exceptions/DMaaPConsumerFailure.java | 34 + .../exceptions/ExceededMaximumPollingTime.java | 34 + .../onap/so/client/dmaap/rest/DMaaPRestClient.java | 50 + .../onap/so/client/dmaap/rest/PropertiesBean.java | 131 +++ .../onap/so/client/dmaap/rest/RestConsumer.java | 61 + .../onap/so/client/dmaap/rest/RestPublisher.java | 55 + .../onap/so/client/exceptions/SDNOException.java | 39 + .../org/onap/so/client/graphinventory/Format.java | 43 + .../graphinventory/GraphInventoryClient.java | 48 + .../graphinventory/GraphInventoryObjectName.java | 29 + .../GraphInventoryObjectPlurals.java | 25 + .../graphinventory/GraphInventoryObjectType.java | 25 + .../GraphInventoryObjectUriPartial.java | 26 + .../GraphInventoryObjectUriTemplate.java | 26 + .../graphinventory/GraphInventoryVersion.java | 25 + .../client/graphinventory/entities/uri/Depth.java | 44 + .../entities/uri/GraphInventoryResourceUri.java | 44 + .../entities/uri/GraphInventoryUri.java | 60 + .../graphinventory/entities/uri/SimpleUri.java | 216 ++++ .../entities/uri/parsers/UriParser.java | 29 + .../entities/uri/parsers/UriParserSpringImpl.java | 68 ++ .../exceptions/BulkProcessFailed.java | 28 + .../GraphInventoryPatchDepthExceededException.java | 31 + .../exceptions/GraphInventoryPayloadException.java | 40 + .../GraphInventoryUriComputationException.java | 34 + .../GraphInventoryUriNotFoundException.java | 29 + .../java/org/onap/so/client/grm/GRMAction.java | 37 + .../java/org/onap/so/client/grm/GRMClient.java | 83 ++ .../so/client/grm/GRMDefaultPropertiesImpl.java | 63 ++ .../java/org/onap/so/client/grm/GRMProperties.java | 30 + .../onap/so/client/grm/GRMPropertiesLoader.java | 48 + .../java/org/onap/so/client/grm/GRMRestClient.java | 54 + .../org/onap/so/client/grm/GRMRestInvoker.java | 73 ++ .../onap/so/client/grm/beans/OperationalInfo.java | 88 ++ .../org/onap/so/client/grm/beans/Property.java | 64 ++ .../onap/so/client/grm/beans/ServiceEndPoint.java | 247 ++++ .../so/client/grm/beans/ServiceEndPointList.java | 48 + .../so/client/grm/beans/ServiceEndPointLookup.java | 61 + .../grm/beans/ServiceEndPointLookupRequest.java | 58 + .../client/grm/beans/ServiceEndPointRequest.java | 58 + .../java/org/onap/so/client/grm/beans/Status.java | 88 ++ .../java/org/onap/so/client/grm/beans/Version.java | 75 ++ .../onap/so/client/grm/beans/VersionLookup.java | 49 + .../client/grm/exceptions/GRMClientCallFailed.java | 32 + .../client/policy/CommonObjectMapperProvider.java | 46 + .../onap/so/client/policy/DecisionAttributes.java | 93 ++ .../client/policy/JettisonStyleMapperProvider.java | 45 + .../org/onap/so/client/policy/LoggingFilter.java | 157 +++ .../org/onap/so/client/policy/PolicyClient.java | 32 + .../onap/so/client/policy/PolicyClientImpl.java | 96 ++ .../onap/so/client/policy/PolicyRestClient.java | 54 + .../so/client/policy/PolicyRestProperties.java | 31 + .../client/policy/entities/AllowedTreatments.java | 105 ++ .../org/onap/so/client/policy/entities/Bbid.java | 87 ++ .../client/policy/entities/DecisionAttributes.java | 94 ++ .../so/client/policy/entities/DictionaryData.java | 105 ++ .../policy/entities/DictionaryItemsRequest.java | 55 + .../so/client/policy/entities/DictionaryJson.java | 54 + .../org/onap/so/client/policy/entities/Id.java | 69 ++ .../so/client/policy/entities/PolicyDecision.java | 57 + .../policy/entities/PolicyDecisionRequest.java | 57 + .../client/policy/entities/PolicyServiceType.java | 48 + .../onap/so/client/policy/entities/Treatments.java | 87 ++ .../onap/so/client/policy/entities/Workstep.java | 87 ++ .../java/org/onap/so/client/ruby/RubyClient.java | 90 ++ .../java/org/onap/so/client/ruby/beans/Event.java | 67 ++ .../org/onap/so/client/ruby/beans/MsoRequest.java | 207 ++++ .../java/org/onap/so/client/ruby/beans/Ruby.java | 67 ++ .../dmaap/RubyCreateTicketRequestPublisher.java | 56 + .../onap/so/client/sdno/SDNOHealthCheckClient.java | 158 +++ .../org/onap/so/client/sdno/SDNOValidator.java | 55 + .../org/onap/so/client/sdno/SDNOValidatorImpl.java | 125 ++ .../onap/so/client/sdno/beans/AAIParamList.java | 87 ++ .../java/org/onap/so/client/sdno/beans/Body.java | 80 ++ .../java/org/onap/so/client/sdno/beans/Input.java | 95 ++ .../onap/so/client/sdno/beans/RequestHdCustom.java | 191 ++++ .../client/sdno/beans/RequestHealthDiagnostic.java | 207 ++++ .../org/onap/so/client/sdno/beans/ResultInfo.java | 119 ++ .../java/org/onap/so/client/sdno/beans/SDNO.java | 135 +++ .../sdno/dmaap/SDNOHealthCheckDmaapConsumer.java | 159 +++ .../sdno/dmaap/SDNOHealthCheckDmaapPublisher.java | 55 + .../main/java/org/onap/so/entity/MsoRequest.java | 64 ++ .../main/java/org/onap/so/entity/package-info.java | 26 + .../onap/so/exceptions/MarshallerException.java | 49 + .../onap/so/exceptions/ValidationException.java | 54 + .../java/org/onap/so/jsonpath/JsonPathUtil.java | 87 ++ .../org/onap/so/logger/LoggerStartupListener.java | 87 ++ .../main/java/org/onap/so/logger/MessageEnum.java | 223 ++++ .../java/org/onap/so/logger/MsoAlarmLogger.java | 187 +++ .../main/java/org/onap/so/logger/MsoLogger.java | 1193 ++++++++++++++++++++ .../jaxrs/filter/jersey/JaxRsClientLogging.java | 135 +++ .../jaxrs/filter/jersey/JaxRsFilterLogging.java | 180 +++ .../jaxrs/filter/jersey/SpringClientFilter.java | 67 ++ .../openpojo/rules/CustomSetterMustExistRule.java | 58 + .../so/openpojo/rules/EqualsAndHashCodeTester.java | 128 +++ .../so/openpojo/rules/HasAnnotationMatcher.java | 71 ++ .../HasAnnotationPropertyWithValueMatcher.java | 78 ++ .../openpojo/rules/HasEqualsAndHashCodeRule.java | 81 ++ .../onap/so/openpojo/rules/HasToStringRule.java | 72 ++ .../org/onap/so/openpojo/rules/ToStringTester.java | 55 + .../onap/so/properties/MsoDatabaseException.java | 51 + .../org/onap/so/security/MSOSpringFirewall.java | 34 + .../java/org/onap/so/security/UserCredentials.java | 53 + .../onap/so/security/UserDetailsServiceImpl.java | 56 + .../org/onap/so/security/WebSecurityConfig.java | 76 ++ .../serviceinstancebeans/CloudConfiguration.java | 106 ++ .../so/serviceinstancebeans/ExceptionType.java | 168 +++ .../GetOrchestrationListResponse.java | 47 + .../GetOrchestrationResponse.java | 47 + .../so/serviceinstancebeans/InstanceDirection.java | 35 + .../serviceinstancebeans/InstanceReferences.java | 123 ++ .../so/serviceinstancebeans/LineOfBusiness.java | 49 + .../onap/so/serviceinstancebeans/ModelInfo.java | 169 +++ .../onap/so/serviceinstancebeans/ModelType.java | 36 + .../org/onap/so/serviceinstancebeans/Networks.java | 98 ++ .../onap/so/serviceinstancebeans/OwningEntity.java | 60 + .../org/onap/so/serviceinstancebeans/Platform.java | 49 + .../so/serviceinstancebeans/PolicyException.java | 59 + .../org/onap/so/serviceinstancebeans/Project.java | 51 + .../so/serviceinstancebeans/RelatedInstance.java | 76 ++ .../serviceinstancebeans/RelatedInstanceList.java | 53 + .../org/onap/so/serviceinstancebeans/Request.java | 90 ++ .../so/serviceinstancebeans/RequestDetails.java | 303 +++++ .../onap/so/serviceinstancebeans/RequestError.java | 128 +++ .../onap/so/serviceinstancebeans/RequestInfo.java | 239 ++++ .../onap/so/serviceinstancebeans/RequestList.java | 44 + .../so/serviceinstancebeans/RequestParameters.java | 171 +++ .../so/serviceinstancebeans/RequestReferences.java | 55 + .../so/serviceinstancebeans/RequestStatus.java | 65 ++ .../onap/so/serviceinstancebeans/Resources.java | 60 + .../org/onap/so/serviceinstancebeans/Service.java | 98 ++ .../so/serviceinstancebeans/ServiceException.java | 62 + .../ServiceInstancesRequest.java | 125 ++ .../ServiceInstancesResponse.java | 43 + .../so/serviceinstancebeans/SubscriberInfo.java | 94 ++ .../onap/so/serviceinstancebeans/VfModules.java | 99 ++ .../org/onap/so/serviceinstancebeans/Vnfs.java | 131 +++ .../org/onap/so/test/categories/SlowTests.java | 25 + .../main/java/org/onap/so/utils/CheckResults.java | 118 ++ .../main/java/org/onap/so/utils/CryptoUtils.java | 129 +++ .../main/java/org/onap/so/utils/TargetEntity.java | 32 + .../main/java/org/onap/so/utils/UUIDChecker.java | 80 ++ .../main/java/org/onap/so/utils/XmlMarshaller.java | 84 ++ .../onap/so/web/exceptions/ExceptionResponse.java | 46 + .../so/web/exceptions/RuntimeExceptionMapper.java | 46 + .../mso/client/PreconditionFailedException.java | 35 - .../mso/client/ResponseExceptionMapper.java | 94 -- .../mso/client/ResponseExceptionMapperImpl.java | 44 - .../org/openecomp/mso/client/RestProperties.java | 30 - .../openecomp/mso/client/RestPropertiesLoader.java | 73 -- .../org/openecomp/mso/client/aai/AAIClient.java | 69 -- .../aai/AAIClientResponseExceptionMapper.java | 61 - .../client/aai/AAICommonObjectMapperProvider.java | 62 - .../mso/client/aai/AAIConfigurationClient.java | 74 -- .../mso/client/aai/AAIErrorFormatter.java | 57 - .../mso/client/aai/AAINamespaceConstants.java | 31 - .../openecomp/mso/client/aai/AAIObjectName.java | 29 - .../openecomp/mso/client/aai/AAIObjectPlurals.java | 65 -- .../openecomp/mso/client/aai/AAIObjectType.java | 98 -- .../mso/client/aai/AAIObjectUriPartial.java | 26 - .../mso/client/aai/AAIObjectUriTemplate.java | 26 - .../openecomp/mso/client/aai/AAIProperties.java | 30 - .../openecomp/mso/client/aai/AAIQueryClient.java | 93 -- .../client/aai/AAIQueryObjectMapperProvider.java | 44 - .../mso/client/aai/AAIResourcesClient.java | 254 ----- .../aai/AAIResourcesObjectMapperProvider.java | 35 - .../openecomp/mso/client/aai/AAIRestClient.java | 76 -- .../openecomp/mso/client/aai/AAIRestClientI.java | 50 - .../mso/client/aai/AAIRestClientImpl.java | 195 ---- .../openecomp/mso/client/aai/AAISubgraphType.java | 38 - .../mso/client/aai/AAITransactionalClient.java | 263 ----- .../org/openecomp/mso/client/aai/AAIUpdator.java | 31 - .../openecomp/mso/client/aai/AAIUpdatorImpl.java | 49 - .../org/openecomp/mso/client/aai/AAIValidator.java | 32 - .../openecomp/mso/client/aai/AAIValidatorImpl.java | 71 -- .../org/openecomp/mso/client/aai/AAIVersion.java | 41 - .../java/org/openecomp/mso/client/aai/Format.java | 43 - .../mso/client/aai/entities/AAIEntity.java | 25 - .../mso/client/aai/entities/AAIEntityObject.java | 29 - .../mso/client/aai/entities/AAIError.java | 46 - .../mso/client/aai/entities/AAIResultWrapper.java | 78 -- .../mso/client/aai/entities/Configuration.java | 162 --- .../mso/client/aai/entities/CustomQuery.java | 82 -- .../mso/client/aai/entities/Relationships.java | 140 --- .../mso/client/aai/entities/RequestError.java | 46 - .../openecomp/mso/client/aai/entities/Results.java | 51 - .../mso/client/aai/entities/ServiceException.java | 75 -- .../aai/entities/bulkprocess/OperationBody.java | 69 -- .../aai/entities/bulkprocess/Transaction.java | 95 -- .../aai/entities/bulkprocess/Transactions.java | 54 - .../client/aai/entities/uri/AAIResourceUri.java | 36 - .../mso/client/aai/entities/uri/AAIUri.java | 58 - .../mso/client/aai/entities/uri/AAIUriFactory.java | 73 -- .../mso/client/aai/entities/uri/Depth.java | 45 - .../mso/client/aai/entities/uri/NodesUri.java | 44 - .../aai/entities/uri/ServiceInstanceUri.java | 129 --- .../mso/client/aai/entities/uri/SimpleUri.java | 187 --- .../client/aai/entities/uri/parsers/UriParser.java | 29 - .../entities/uri/parsers/UriParserSpringImpl.java | 68 -- .../client/aai/exceptions/AAIPayloadException.java | 40 - .../aai/exceptions/AAIUriComputationException.java | 34 - .../aai/exceptions/AAIUriNotFoundException.java | 29 - .../client/aai/exceptions/BulkProcessFailed.java | 28 - .../aai/objects/AAIOperationalEnvironment.java | 159 --- .../mso/client/aai/objects/AAIOwningEntity.java | 67 -- .../mso/client/aai/objects/AAIProject.java | 55 - .../mso/client/aai/objects/AAIServiceInstance.java | 135 --- .../DefaultAAIPropertiesImpl.java | 78 -- .../DefaultDmaapPropertiesImpl.java | 49 - .../PolicyRestPropertiesImpl.java | 79 -- .../org/openecomp/mso/client/dmaap/Consumer.java | 26 - .../openecomp/mso/client/dmaap/DmaapClient.java | 73 -- .../openecomp/mso/client/dmaap/DmaapConsumer.java | 126 --- .../mso/client/dmaap/DmaapProperties.java | 32 - .../mso/client/dmaap/DmaapPropertiesLoader.java | 62 - .../openecomp/mso/client/dmaap/DmaapPublisher.java | 51 - .../org/openecomp/mso/client/dmaap/Publisher.java | 26 - .../dmaap/exceptions/DMaaPConsumerFailure.java | 34 - .../exceptions/ExceededMaximumPollingTime.java | 34 - .../mso/client/dmaap/rest/DMaaPRestClient.java | 58 - .../mso/client/dmaap/rest/PropertiesBean.java | 131 --- .../mso/client/dmaap/rest/RestConsumer.java | 60 - .../mso/client/dmaap/rest/RestPublisher.java | 56 - .../mso/client/exceptions/SDNOException.java | 39 - .../org/openecomp/mso/client/grm/GRMAction.java | 37 - .../org/openecomp/mso/client/grm/GRMClient.java | 83 -- .../mso/client/grm/GRMDefaultPropertiesImpl.java | 63 -- .../openecomp/mso/client/grm/GRMProperties.java | 30 - .../mso/client/grm/GRMPropertiesLoader.java | 48 - .../openecomp/mso/client/grm/GRMRestClient.java | 61 - .../openecomp/mso/client/grm/GRMRestInvoker.java | 73 -- .../mso/client/grm/beans/OperationalInfo.java | 82 -- .../openecomp/mso/client/grm/beans/Property.java | 58 - .../mso/client/grm/beans/ServiceEndPoint.java | 247 ---- .../mso/client/grm/beans/ServiceEndPointList.java | 48 - .../client/grm/beans/ServiceEndPointLookup.java | 61 - .../grm/beans/ServiceEndPointLookupRequest.java | 63 -- .../client/grm/beans/ServiceEndPointRequest.java | 63 -- .../org/openecomp/mso/client/grm/beans/Status.java | 82 -- .../openecomp/mso/client/grm/beans/Version.java | 69 -- .../mso/client/grm/beans/VersionLookup.java | 49 - .../client/grm/exceptions/GRMClientCallFailed.java | 32 - .../client/policy/CommonObjectMapperProvider.java | 49 - .../mso/client/policy/DecisionAttributes.java | 93 -- .../client/policy/JettisonStyleMapperProvider.java | 49 - .../openecomp/mso/client/policy/LoggingFilter.java | 157 --- .../openecomp/mso/client/policy/PolicyClient.java | 33 - .../mso/client/policy/PolicyClientImpl.java | 94 -- .../mso/client/policy/PolicyDecision.java | 57 - .../mso/client/policy/PolicyDecisionRequest.java | 57 - .../mso/client/policy/PolicyRestClient.java | 66 -- .../mso/client/policy/PolicyRestProperties.java | 35 - .../openecomp/mso/client/policy/RestClient.java | 243 ---- .../openecomp/mso/client/policy/RestClientSSL.java | 109 -- .../client/policy/entities/AllowedTreatments.java | 105 -- .../openecomp/mso/client/policy/entities/Bbid.java | 87 -- .../client/policy/entities/DecisionAttributes.java | 94 -- .../mso/client/policy/entities/DictionaryData.java | 105 -- .../policy/entities/DictionaryItemsRequest.java | 56 - .../mso/client/policy/entities/DictionaryJson.java | 53 - .../openecomp/mso/client/policy/entities/Id.java | 69 -- .../mso/client/policy/entities/PolicyDecision.java | 58 - .../policy/entities/PolicyDecisionRequest.java | 58 - .../client/policy/entities/PolicyServiceType.java | 48 - .../mso/client/policy/entities/Treatments.java | 87 -- .../mso/client/policy/entities/Workstep.java | 88 -- .../org/openecomp/mso/client/ruby/RubyClient.java | 90 -- .../org/openecomp/mso/client/ruby/beans/Event.java | 67 -- .../mso/client/ruby/beans/MsoRequest.java | 207 ---- .../org/openecomp/mso/client/ruby/beans/Ruby.java | 68 -- .../dmaap/RubyCreateTicketRequestPublisher.java | 56 - .../mso/client/sdno/SDNOHealthCheckClient.java | 158 --- .../openecomp/mso/client/sdno/SDNOValidator.java | 38 - .../mso/client/sdno/SDNOValidatorImpl.java | 111 -- .../mso/client/sdno/beans/AAIParamList.java | 87 -- .../org/openecomp/mso/client/sdno/beans/Body.java | 80 -- .../org/openecomp/mso/client/sdno/beans/Input.java | 95 -- .../mso/client/sdno/beans/RequestHdCustom.java | 170 --- .../client/sdno/beans/RequestHealthDiagnostic.java | 189 ---- .../mso/client/sdno/beans/ResultInfo.java | 119 -- .../org/openecomp/mso/client/sdno/beans/SDNO.java | 135 --- .../sdno/dmaap/SDNOHealthCheckDmaapConsumer.java | 159 --- .../sdno/dmaap/SDNOHealthCheckDmaapPublisher.java | 55 - .../mso/db/AbstractSessionFactoryManager.java | 74 -- .../java/org/openecomp/mso/entity/MsoRequest.java | 61 - .../org/openecomp/mso/entity/package-info.java | 26 - .../org/openecomp/mso/jsonpath/JsonPathUtil.java | 82 -- .../java/org/openecomp/mso/logger/LogFilter.java | 68 -- .../java/org/openecomp/mso/logger/MessageEnum.java | 233 ---- .../org/openecomp/mso/logger/MsoAlarmLogger.java | 181 --- .../openecomp/mso/logger/MsoLogInitializer.java | 108 -- .../java/org/openecomp/mso/logger/MsoLogger.java | 1164 ------------------- .../openecomp/mso/logger/MsoLoggingServlet.java | 163 --- .../openpojo/rules/CustomSetterMustExistRule.java | 58 - .../openpojo/rules/EqualsAndHashCodeTester.java | 126 --- .../mso/openpojo/rules/HasAnnotationMatcher.java | 69 -- .../HasAnnotationPropertyWithValueMatcher.java | 78 -- .../openpojo/rules/HasEqualsAndHashCodeRule.java | 81 -- .../mso/openpojo/rules/HasToStringRule.java | 72 -- .../mso/openpojo/rules/ToStringTester.java | 55 - .../mso/properties/AbstractMsoProperties.java | 75 -- .../mso/properties/MsoDatabaseException.java | 51 - .../mso/properties/MsoJavaProperties.java | 228 ---- .../mso/properties/MsoJsonProperties.java | 167 --- .../mso/properties/MsoPropertiesException.java | 51 - .../mso/properties/MsoPropertiesFactory.java | 395 ------- .../mso/properties/MsoPropertiesParameters.java | 33 - .../mso/properties/MsoPropertyInitializer.java | 87 -- .../serviceinstancebeans/CloudConfiguration.java | 106 -- .../mso/serviceinstancebeans/ExceptionType.java | 167 --- .../GetOrchestrationListResponse.java | 47 - .../GetOrchestrationResponse.java | 47 - .../serviceinstancebeans/InstanceDirection.java | 35 - .../serviceinstancebeans/InstanceReferences.java | 123 -- .../mso/serviceinstancebeans/LineOfBusiness.java | 49 - .../mso/serviceinstancebeans/ModelInfo.java | 154 --- .../mso/serviceinstancebeans/ModelType.java | 35 - .../mso/serviceinstancebeans/OwningEntity.java | 60 - .../mso/serviceinstancebeans/Platform.java | 49 - .../mso/serviceinstancebeans/PolicyException.java | 59 - .../mso/serviceinstancebeans/Project.java | 51 - .../mso/serviceinstancebeans/RelatedInstance.java | 76 -- .../serviceinstancebeans/RelatedInstanceList.java | 53 - .../mso/serviceinstancebeans/Request.java | 91 -- .../mso/serviceinstancebeans/RequestDetails.java | 280 ----- .../mso/serviceinstancebeans/RequestError.java | 125 -- .../mso/serviceinstancebeans/RequestInfo.java | 239 ---- .../mso/serviceinstancebeans/RequestList.java | 44 - .../serviceinstancebeans/RequestParameters.java | 152 --- .../serviceinstancebeans/RequestReferences.java | 49 - .../mso/serviceinstancebeans/RequestStatus.java | 65 -- .../mso/serviceinstancebeans/ServiceException.java | 59 - .../ServiceInstancesRequest.java | 125 -- .../ServiceInstancesResponse.java | 43 - .../mso/serviceinstancebeans/SubscriberInfo.java | 94 -- .../java/org/openecomp/mso/utils/CheckResults.java | 118 -- .../java/org/openecomp/mso/utils/CryptoUtils.java | 95 -- .../mso/utils/RootIgnoringJsonDeserializer.java | 67 -- .../mso/utils/RootIgnoringObjectMapper.java | 39 - .../java/org/openecomp/mso/utils/UUIDChecker.java | 80 -- common/src/main/resources/Policy.properties | 12 +- .../resources/dmaap/default-consumer.properties | 2 +- .../resources/dmaap/default-publisher.properties | 2 +- common/src/main/resources/test | 159 +++ common/src/test/java/org/onap/so/BeansTest.java | 97 ++ .../onap/so/adapter_utils/tests/CryptoTest.java | 83 ++ .../so/adapter_utils/tests/MsoAlarmLoggerTest.java | 134 +++ .../onap/so/adapter_utils/tests/MsoLoggerTest.java | 331 ++++++ .../java/org/onap/so/client/RestClientTest.java | 87 ++ .../aai/AAIClientResponseExceptionMapperTest.java | 70 ++ .../so/client/aai/AAIConfigurationClientTest.java | 181 +++ .../onap/so/client/aai/AAIErrorFormatterTest.java | 88 ++ .../org/onap/so/client/aai/AAIObjectTypeTest.java | 55 + .../org/onap/so/client/aai/AAIPServerTest.java | 57 + .../org/onap/so/client/aai/AAIQueryClientTest.java | 93 ++ .../onap/so/client/aai/AAIResourcesClientTest.java | 191 ++++ .../org/onap/so/client/aai/AAIRestClientTest.java | 124 ++ .../so/client/aai/AAITransactionalClientTest.java | 148 +++ .../java/org/onap/so/client/aai/AAIURITest.java | 44 + .../org/onap/so/client/aai/AAIUpdatorImplTest.java | 53 + .../org/onap/so/client/aai/AAIUpdatorTest.java | 61 + .../org/onap/so/client/aai/AAIValidatorTest.java | 98 ++ .../client/aai/entities/AAIResultWrapperTest.java | 94 ++ .../so/client/aai/entities/RelationshipsTest.java | 61 + .../aai/entities/uri/AAISimpleUriFromUriTest.java | 60 + .../client/aai/entities/uri/AAISimpleUriTest.java | 78 ++ .../client/aai/entities/uri/AAIUriFactoryTest.java | 68 ++ .../aai/entities/uri/ServiceInstanceUriTest.java | 192 ++++ .../aai/objects/AAIOperationalEnvironmentTest.java | 55 + .../client/aai/objects/AAIServiceInstanceTest.java | 53 + .../DefaultAAIPropertiesImpl.java | 78 ++ .../org/onap/so/client/dmaap/DmaapClientTest.java | 41 + .../onap/so/client/dmaap/DmaapPublisherTest.java | 60 + .../uri/parsers/UriParserSpringImplTest.java | 49 + .../GraphInventoryPayloadExceptionTest.java | 40 + .../java/org/onap/so/client/grm/GRMBeansTest.java | 62 + .../java/org/onap/so/client/grm/GRMClientTest.java | 217 ++++ .../so/client/grm/ServiceEndPointListTest.java | 75 ++ .../so/client/grm/ServiceEndPointRequestTest.java | 90 ++ .../so/client/policy/PolicyClientImplTest.java | 111 ++ .../client/policy/entities/PolicyEntitiesTest.java | 59 + .../onap/so/client/ruby/RubyCheckClientTest.java | 106 ++ .../onap/so/client/ruby/beans/RubyBeansTest.java | 59 + .../so/client/sdno/SDNOHealthCheckClientTest.java | 94 ++ .../org/onap/so/client/sdno/SDNOValidatorTest.java | 116 ++ .../onap/so/client/sdno/beans/SdnoBeansTest.java | 59 + .../java/org/onap/so/entity/MsoRequestTest.java | 64 ++ .../so/exceptions/ValidationExceptionTest.java | 53 + .../org/onap/so/jsonpath/JsonPathUtilTest.java | 55 + .../ServiceInstanceBeansTest.java | 64 ++ .../ServiceInstancesRequestTest.java | 44 + .../java/org/onap/so/utils/CheckResultsTest.java | 58 + .../test/java/org/onap/so/utils/TestAppender.java | 41 + .../java/org/onap/so/utils/UUIDCheckerTest.java | 60 + .../java/org/onap/so/utils/XMLMarshallerTest.java | 101 ++ .../web/exceptions/RuntimeExceptionMapperTest.java | 71 ++ .../mso/adapter_utils/tests/CryptoTest.java | 79 -- .../adapter_utils/tests/MsoAlarmLoggerTest.java | 131 --- .../mso/adapter_utils/tests/MsoLoggerTest.java | 331 ------ .../tests/MsoPropertiesFactoryConcurrencyTest.java | 174 --- .../tests/MsoPropertiesFactoryTest.java | 611 ---------- .../tests/MsoPropertyInitializerTest.java | 88 -- .../mso/client/aai/AAIConfigurationTest.java | 75 -- .../mso/client/aai/AAIExceptionMapperTest.java | 63 -- .../mso/client/aai/AAIObjectTypeTest.java | 39 - .../openecomp/mso/client/aai/AAIPServerTest.java | 57 - .../mso/client/aai/AAIResourcesClientTest.java | 111 -- .../mso/client/aai/AAITransactionalClientTest.java | 83 -- .../org/openecomp/mso/client/aai/AAIURITest.java | 44 - .../mso/client/aai/AAIUpdatorImplTest.java | 53 - .../openecomp/mso/client/aai/AAIValidatorTest.java | 98 -- .../mso/client/aai/entities/RelationshipsTest.java | 61 - .../client/aai/entities/uri/AAIUriFactoryTest.java | 40 - .../aai/entities/uri/ServiceInstanceUriTest.java | 194 ---- .../aai/entities/uri/SimpleUriFromUriTest.java | 59 - .../mso/client/aai/entities/uri/SimpleUriTest.java | 69 -- .../uri/parsers/UriParserSpringImplTest.java | 47 - .../aai/exceptions/AAIPayloadExceptionTest.java | 39 - .../aai/objects/AAIOperationalEnvironmentTest.java | 55 - .../client/aai/objects/AAIOwningEntityTest.java | 40 - .../mso/client/aai/objects/AAIProjectTest.java | 41 - .../client/aai/objects/AAIServiceInstanceTest.java | 53 - .../mso/client/dmaap/DmaapClientTest.java | 41 - .../mso/client/dmaap/DmaapPublisherTest.java | 60 - .../org/openecomp/mso/client/grm/GRMBeansTest.java | 62 - .../openecomp/mso/client/grm/GRMClientTest.java | 185 --- .../mso/client/grm/ServiceEndPointListTest.java | 75 -- .../mso/client/grm/ServiceEndPointRequestTest.java | 90 -- .../mso/client/policy/PolicyClientImplTest.java | 104 -- .../client/policy/entities/PolicyEntitiesTest.java | 59 - .../mso/client/ruby/RubyCheckClientTest.java | 106 -- .../mso/client/ruby/beans/RubyBeansTest.java | 59 - .../mso/client/sdno/SDNOHealthCheckClientTest.java | 94 -- .../mso/client/sdno/SDNOValidatorTest.java | 116 -- .../mso/client/sdno/beans/SdnoBeansTest.java | 59 - .../org/openecomp/mso/entity/MsoRequestTest.java | 64 -- .../openecomp/mso/jsonpath/JsonPathUtilTest.java | 49 - .../ServiceInstanceBeansTest.java | 64 -- .../ServiceInstancesRequestTest.java | 44 - .../org/openecomp/mso/utils/CheckResultsTest.java | 56 - .../mso/utils/RootIgnoringObjectMapperTest.java | 94 -- .../org/openecomp/mso/utils/UUIDCheckerTest.java | 44 - .../aai/bulkprocess/test-request-small.json | 10 + .../__files/aai/resources/e2e-complex.json | 78 +- .../resources/service-instance-pathed-query.json | 2 +- .../src/test/resources/__files/grm/endpoints.json | 6 +- common/src/test/resources/dmaap.properties | 4 +- common/src/test/resources/logback-test.xml | 39 +- common/src/test/resources/mso-bad.json | 38 +- .../ruby/create-ticket/create-ticket-request.json | 15 + .../custom-lport-mirror-post-check-request.json | 27 + .../custom-lport-mirror-pre-check-request.json | 27 + .../custom-port-mirror-post-check-request.json | 23 + .../custom-port-mirror-pre-check-request.json | 23 + .../org/onap/so/client/sdno/output-failure.json | 25 + .../org/onap/so/client/sdno/output-success.json | 22 + .../org/onap/so/client/sdno/response.json | 17 + .../ruby/create-ticket/create-ticket-request.json | 15 - .../custom-lport-mirror-post-check-request.json | 26 - .../custom-lport-mirror-pre-check-request.json | 26 - .../custom-port-mirror-post-check-request.json | 22 - .../custom-port-mirror-pre-check-request.json | 22 - .../openecomp/mso/client/sdno/output-failure.json | 25 - .../openecomp/mso/client/sdno/output-success.json | 22 - .../org/openecomp/mso/client/sdno/response.json | 17 - 532 files changed, 22952 insertions(+), 21670 deletions(-) create mode 100644 common/src/main/java/org/onap/so/client/DefaultProperties.java create mode 100644 common/src/main/java/org/onap/so/client/HttpClient.java create mode 100644 common/src/main/java/org/onap/so/client/PreconditionFailedException.java create mode 100644 common/src/main/java/org/onap/so/client/ResponseExceptionMapper.java create mode 100644 common/src/main/java/org/onap/so/client/ResponseExceptionMapperImpl.java create mode 100644 common/src/main/java/org/onap/so/client/RestClient.java create mode 100644 common/src/main/java/org/onap/so/client/RestClientSSL.java create mode 100644 common/src/main/java/org/onap/so/client/RestProperties.java create mode 100644 common/src/main/java/org/onap/so/client/RestPropertiesLoader.java create mode 100644 common/src/main/java/org/onap/so/client/RestRequest.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIClient.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIClientResponseExceptionMapper.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIConfigurationClient.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIObjectType.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIProperties.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIQueryObjectMapperProvider.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIResourcesObjectMapperProvider.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIRestClient.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAISubgraphType.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIUpdator.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIUpdatorImpl.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIValidator.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java create mode 100644 common/src/main/java/org/onap/so/client/aai/AAIVersion.java create mode 100644 common/src/main/java/org/onap/so/client/aai/EmptyStringToNullSerializer.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/AAIEntity.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/AAIEntityObject.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/AAIError.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/Configuration.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/CustomQuery.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/Relationships.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/RequestError.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/Results.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/ServiceException.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/OperationBody.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transaction.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transactions.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/uri/AAIResourceUri.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUri.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java create mode 100644 common/src/main/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUri.java create mode 100644 common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java create mode 100644 common/src/main/java/org/onap/so/client/aai/objects/AAIServiceInstance.java create mode 100644 common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java create mode 100644 common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestProperties.java create mode 100644 common/src/main/java/org/onap/so/client/defaultproperties/DefaultDmaapPropertiesImpl.java create mode 100644 common/src/main/java/org/onap/so/client/defaultproperties/PolicyRestPropertiesImpl.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/Consumer.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/DmaapClient.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/DmaapConsumer.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/DmaapProperties.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/DmaapPropertiesLoader.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/DmaapPublisher.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/Publisher.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/exceptions/DMaaPConsumerFailure.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/exceptions/ExceededMaximumPollingTime.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/rest/PropertiesBean.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/rest/RestConsumer.java create mode 100644 common/src/main/java/org/onap/so/client/dmaap/rest/RestPublisher.java create mode 100644 common/src/main/java/org/onap/so/client/exceptions/SDNOException.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/Format.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryClient.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectName.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectPlurals.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectType.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriPartial.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriTemplate.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryVersion.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/entities/uri/Depth.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryResourceUri.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParser.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/exceptions/BulkProcessFailed.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPatchDepthExceededException.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPayloadException.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriComputationException.java create mode 100644 common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriNotFoundException.java create mode 100644 common/src/main/java/org/onap/so/client/grm/GRMAction.java create mode 100644 common/src/main/java/org/onap/so/client/grm/GRMClient.java create mode 100644 common/src/main/java/org/onap/so/client/grm/GRMDefaultPropertiesImpl.java create mode 100644 common/src/main/java/org/onap/so/client/grm/GRMProperties.java create mode 100644 common/src/main/java/org/onap/so/client/grm/GRMPropertiesLoader.java create mode 100644 common/src/main/java/org/onap/so/client/grm/GRMRestClient.java create mode 100644 common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java create mode 100644 common/src/main/java/org/onap/so/client/grm/beans/OperationalInfo.java create mode 100644 common/src/main/java/org/onap/so/client/grm/beans/Property.java create mode 100644 common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPoint.java create mode 100644 common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointList.java create mode 100644 common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointLookup.java create mode 100644 common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointLookupRequest.java create mode 100644 common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointRequest.java create mode 100644 common/src/main/java/org/onap/so/client/grm/beans/Status.java create mode 100644 common/src/main/java/org/onap/so/client/grm/beans/Version.java create mode 100644 common/src/main/java/org/onap/so/client/grm/beans/VersionLookup.java create mode 100644 common/src/main/java/org/onap/so/client/grm/exceptions/GRMClientCallFailed.java create mode 100644 common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java create mode 100644 common/src/main/java/org/onap/so/client/policy/DecisionAttributes.java create mode 100644 common/src/main/java/org/onap/so/client/policy/JettisonStyleMapperProvider.java create mode 100644 common/src/main/java/org/onap/so/client/policy/LoggingFilter.java create mode 100644 common/src/main/java/org/onap/so/client/policy/PolicyClient.java create mode 100644 common/src/main/java/org/onap/so/client/policy/PolicyClientImpl.java create mode 100644 common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java create mode 100644 common/src/main/java/org/onap/so/client/policy/PolicyRestProperties.java create mode 100644 common/src/main/java/org/onap/so/client/policy/entities/AllowedTreatments.java create mode 100644 common/src/main/java/org/onap/so/client/policy/entities/Bbid.java create mode 100644 common/src/main/java/org/onap/so/client/policy/entities/DecisionAttributes.java create mode 100644 common/src/main/java/org/onap/so/client/policy/entities/DictionaryData.java create mode 100644 common/src/main/java/org/onap/so/client/policy/entities/DictionaryItemsRequest.java create mode 100644 common/src/main/java/org/onap/so/client/policy/entities/DictionaryJson.java create mode 100644 common/src/main/java/org/onap/so/client/policy/entities/Id.java create mode 100644 common/src/main/java/org/onap/so/client/policy/entities/PolicyDecision.java create mode 100644 common/src/main/java/org/onap/so/client/policy/entities/PolicyDecisionRequest.java create mode 100644 common/src/main/java/org/onap/so/client/policy/entities/PolicyServiceType.java create mode 100644 common/src/main/java/org/onap/so/client/policy/entities/Treatments.java create mode 100644 common/src/main/java/org/onap/so/client/policy/entities/Workstep.java create mode 100644 common/src/main/java/org/onap/so/client/ruby/RubyClient.java create mode 100644 common/src/main/java/org/onap/so/client/ruby/beans/Event.java create mode 100644 common/src/main/java/org/onap/so/client/ruby/beans/MsoRequest.java create mode 100644 common/src/main/java/org/onap/so/client/ruby/beans/Ruby.java create mode 100644 common/src/main/java/org/onap/so/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java create mode 100644 common/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java create mode 100644 common/src/main/java/org/onap/so/client/sdno/SDNOValidator.java create mode 100644 common/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java create mode 100644 common/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java create mode 100644 common/src/main/java/org/onap/so/client/sdno/beans/Body.java create mode 100644 common/src/main/java/org/onap/so/client/sdno/beans/Input.java create mode 100644 common/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java create mode 100644 common/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java create mode 100644 common/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java create mode 100644 common/src/main/java/org/onap/so/client/sdno/beans/SDNO.java create mode 100644 common/src/main/java/org/onap/so/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java create mode 100644 common/src/main/java/org/onap/so/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java create mode 100644 common/src/main/java/org/onap/so/entity/MsoRequest.java create mode 100644 common/src/main/java/org/onap/so/entity/package-info.java create mode 100644 common/src/main/java/org/onap/so/exceptions/MarshallerException.java create mode 100644 common/src/main/java/org/onap/so/exceptions/ValidationException.java create mode 100644 common/src/main/java/org/onap/so/jsonpath/JsonPathUtil.java create mode 100644 common/src/main/java/org/onap/so/logger/LoggerStartupListener.java create mode 100644 common/src/main/java/org/onap/so/logger/MessageEnum.java create mode 100644 common/src/main/java/org/onap/so/logger/MsoAlarmLogger.java create mode 100644 common/src/main/java/org/onap/so/logger/MsoLogger.java create mode 100644 common/src/main/java/org/onap/so/logging/jaxrs/filter/jersey/JaxRsClientLogging.java create mode 100644 common/src/main/java/org/onap/so/logging/jaxrs/filter/jersey/JaxRsFilterLogging.java create mode 100644 common/src/main/java/org/onap/so/logging/jaxrs/filter/jersey/SpringClientFilter.java create mode 100644 common/src/main/java/org/onap/so/openpojo/rules/CustomSetterMustExistRule.java create mode 100644 common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java create mode 100644 common/src/main/java/org/onap/so/openpojo/rules/HasAnnotationMatcher.java create mode 100644 common/src/main/java/org/onap/so/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java create mode 100644 common/src/main/java/org/onap/so/openpojo/rules/HasEqualsAndHashCodeRule.java create mode 100644 common/src/main/java/org/onap/so/openpojo/rules/HasToStringRule.java create mode 100644 common/src/main/java/org/onap/so/openpojo/rules/ToStringTester.java create mode 100644 common/src/main/java/org/onap/so/properties/MsoDatabaseException.java create mode 100644 common/src/main/java/org/onap/so/security/MSOSpringFirewall.java create mode 100644 common/src/main/java/org/onap/so/security/UserCredentials.java create mode 100644 common/src/main/java/org/onap/so/security/UserDetailsServiceImpl.java create mode 100644 common/src/main/java/org/onap/so/security/WebSecurityConfig.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/ExceptionType.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/GetOrchestrationListResponse.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/GetOrchestrationResponse.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/InstanceDirection.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/InstanceReferences.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/LineOfBusiness.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/ModelInfo.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/Networks.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/OwningEntity.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/Platform.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/PolicyException.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/Project.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/RelatedInstance.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/RelatedInstanceList.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/Request.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/RequestDetails.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/RequestError.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/RequestList.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/RequestReferences.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/Resources.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/Service.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/ServiceException.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesResponse.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/SubscriberInfo.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/VfModules.java create mode 100644 common/src/main/java/org/onap/so/serviceinstancebeans/Vnfs.java create mode 100644 common/src/main/java/org/onap/so/test/categories/SlowTests.java create mode 100644 common/src/main/java/org/onap/so/utils/CheckResults.java create mode 100644 common/src/main/java/org/onap/so/utils/CryptoUtils.java create mode 100644 common/src/main/java/org/onap/so/utils/TargetEntity.java create mode 100644 common/src/main/java/org/onap/so/utils/UUIDChecker.java create mode 100644 common/src/main/java/org/onap/so/utils/XmlMarshaller.java create mode 100644 common/src/main/java/org/onap/so/web/exceptions/ExceptionResponse.java create mode 100644 common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/PreconditionFailedException.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/ResponseExceptionMapper.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/ResponseExceptionMapperImpl.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/RestProperties.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/RestPropertiesLoader.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIConfigurationClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIErrorFormatter.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAINamespaceConstants.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIObjectName.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIObjectPlurals.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIObjectType.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriPartial.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriTemplate.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIProperties.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIQueryClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientI.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAISubgraphType.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAITransactionalClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/AAIVersion.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/Format.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntityObject.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/AAIResultWrapper.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/Configuration.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/Relationships.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/Results.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/OperationBody.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transaction.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transactions.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIResourceUri.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUri.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactory.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/uri/Depth.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/uri/NodesUri.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUri.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/uri/SimpleUri.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParser.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImpl.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIPayloadException.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriComputationException.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriNotFoundException.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/exceptions/BulkProcessFailed.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOperationalEnvironment.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOwningEntity.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/objects/AAIProject.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/aai/objects/AAIServiceInstance.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/defaultproperties/DefaultAAIPropertiesImpl.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/defaultproperties/DefaultDmaapPropertiesImpl.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/defaultproperties/PolicyRestPropertiesImpl.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/DmaapClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/DmaapProperties.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/Publisher.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/exceptions/DMaaPConsumerFailure.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/exceptions/ExceededMaximumPollingTime.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/rest/PropertiesBean.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/rest/RestConsumer.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/dmaap/rest/RestPublisher.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/exceptions/SDNOException.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/GRMAction.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/GRMClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/GRMDefaultPropertiesImpl.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/GRMProperties.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/GRMPropertiesLoader.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/GRMRestClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/GRMRestInvoker.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/beans/OperationalInfo.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/beans/Property.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPoint.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointList.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointLookup.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointLookupRequest.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointRequest.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/beans/Status.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/beans/Version.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/beans/VersionLookup.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/grm/exceptions/GRMClientCallFailed.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/CommonObjectMapperProvider.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/DecisionAttributes.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/JettisonStyleMapperProvider.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/PolicyClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/PolicyClientImpl.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/PolicyDecision.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/PolicyDecisionRequest.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/PolicyRestProperties.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/RestClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/RestClientSSL.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/entities/AllowedTreatments.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/entities/Bbid.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/entities/DecisionAttributes.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/entities/DictionaryData.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/entities/DictionaryItemsRequest.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/entities/DictionaryJson.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/entities/Id.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/entities/PolicyDecision.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/entities/PolicyDecisionRequest.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/entities/PolicyServiceType.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/entities/Treatments.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/policy/entities/Workstep.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/ruby/RubyClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/ruby/beans/Event.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/ruby/beans/MsoRequest.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/ruby/beans/Ruby.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClient.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/sdno/beans/AAIParamList.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHdCustom.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java delete mode 100644 common/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java delete mode 100644 common/src/main/java/org/openecomp/mso/db/AbstractSessionFactoryManager.java delete mode 100644 common/src/main/java/org/openecomp/mso/entity/MsoRequest.java delete mode 100644 common/src/main/java/org/openecomp/mso/entity/package-info.java delete mode 100644 common/src/main/java/org/openecomp/mso/jsonpath/JsonPathUtil.java delete mode 100644 common/src/main/java/org/openecomp/mso/logger/LogFilter.java delete mode 100644 common/src/main/java/org/openecomp/mso/logger/MessageEnum.java delete mode 100644 common/src/main/java/org/openecomp/mso/logger/MsoAlarmLogger.java delete mode 100644 common/src/main/java/org/openecomp/mso/logger/MsoLogInitializer.java delete mode 100644 common/src/main/java/org/openecomp/mso/logger/MsoLogger.java delete mode 100644 common/src/main/java/org/openecomp/mso/logger/MsoLoggingServlet.java delete mode 100644 common/src/main/java/org/openecomp/mso/openpojo/rules/CustomSetterMustExistRule.java delete mode 100644 common/src/main/java/org/openecomp/mso/openpojo/rules/EqualsAndHashCodeTester.java delete mode 100644 common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationMatcher.java delete mode 100644 common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java delete mode 100644 common/src/main/java/org/openecomp/mso/openpojo/rules/HasEqualsAndHashCodeRule.java delete mode 100644 common/src/main/java/org/openecomp/mso/openpojo/rules/HasToStringRule.java delete mode 100644 common/src/main/java/org/openecomp/mso/openpojo/rules/ToStringTester.java delete mode 100644 common/src/main/java/org/openecomp/mso/properties/AbstractMsoProperties.java delete mode 100644 common/src/main/java/org/openecomp/mso/properties/MsoDatabaseException.java delete mode 100644 common/src/main/java/org/openecomp/mso/properties/MsoJavaProperties.java delete mode 100644 common/src/main/java/org/openecomp/mso/properties/MsoJsonProperties.java delete mode 100644 common/src/main/java/org/openecomp/mso/properties/MsoPropertiesException.java delete mode 100644 common/src/main/java/org/openecomp/mso/properties/MsoPropertiesFactory.java delete mode 100644 common/src/main/java/org/openecomp/mso/properties/MsoPropertiesParameters.java delete mode 100644 common/src/main/java/org/openecomp/mso/properties/MsoPropertyInitializer.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/CloudConfiguration.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/ExceptionType.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/GetOrchestrationListResponse.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/GetOrchestrationResponse.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/InstanceDirection.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/InstanceReferences.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/LineOfBusiness.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/ModelInfo.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/ModelType.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/OwningEntity.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/Platform.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/PolicyException.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/Project.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/RelatedInstance.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/RelatedInstanceList.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/Request.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestDetails.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestError.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestInfo.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestList.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestParameters.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestReferences.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestStatus.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/ServiceException.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesRequest.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesResponse.java delete mode 100644 common/src/main/java/org/openecomp/mso/serviceinstancebeans/SubscriberInfo.java delete mode 100644 common/src/main/java/org/openecomp/mso/utils/CheckResults.java delete mode 100644 common/src/main/java/org/openecomp/mso/utils/CryptoUtils.java delete mode 100644 common/src/main/java/org/openecomp/mso/utils/RootIgnoringJsonDeserializer.java delete mode 100644 common/src/main/java/org/openecomp/mso/utils/RootIgnoringObjectMapper.java delete mode 100644 common/src/main/java/org/openecomp/mso/utils/UUIDChecker.java create mode 100644 common/src/main/resources/test create mode 100644 common/src/test/java/org/onap/so/BeansTest.java create mode 100644 common/src/test/java/org/onap/so/adapter_utils/tests/CryptoTest.java create mode 100644 common/src/test/java/org/onap/so/adapter_utils/tests/MsoAlarmLoggerTest.java create mode 100644 common/src/test/java/org/onap/so/adapter_utils/tests/MsoLoggerTest.java create mode 100644 common/src/test/java/org/onap/so/client/RestClientTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAIClientResponseExceptionMapperTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAIErrorFormatterTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAIPServerTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAIURITest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAIUpdatorImplTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAIUpdatorTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/entities/AAIResultWrapperTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/entities/RelationshipsTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriFromUriTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/entities/uri/AAIUriFactoryTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java create mode 100644 common/src/test/java/org/onap/so/client/aai/objects/AAIServiceInstanceTest.java create mode 100644 common/src/test/java/org/onap/so/client/defaultproperties/DefaultAAIPropertiesImpl.java create mode 100644 common/src/test/java/org/onap/so/client/dmaap/DmaapClientTest.java create mode 100644 common/src/test/java/org/onap/so/client/dmaap/DmaapPublisherTest.java create mode 100644 common/src/test/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImplTest.java create mode 100644 common/src/test/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPayloadExceptionTest.java create mode 100644 common/src/test/java/org/onap/so/client/grm/GRMBeansTest.java create mode 100644 common/src/test/java/org/onap/so/client/grm/GRMClientTest.java create mode 100644 common/src/test/java/org/onap/so/client/grm/ServiceEndPointListTest.java create mode 100644 common/src/test/java/org/onap/so/client/grm/ServiceEndPointRequestTest.java create mode 100644 common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java create mode 100644 common/src/test/java/org/onap/so/client/policy/entities/PolicyEntitiesTest.java create mode 100644 common/src/test/java/org/onap/so/client/ruby/RubyCheckClientTest.java create mode 100644 common/src/test/java/org/onap/so/client/ruby/beans/RubyBeansTest.java create mode 100644 common/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java create mode 100644 common/src/test/java/org/onap/so/client/sdno/SDNOValidatorTest.java create mode 100644 common/src/test/java/org/onap/so/client/sdno/beans/SdnoBeansTest.java create mode 100644 common/src/test/java/org/onap/so/entity/MsoRequestTest.java create mode 100644 common/src/test/java/org/onap/so/exceptions/ValidationExceptionTest.java create mode 100644 common/src/test/java/org/onap/so/jsonpath/JsonPathUtilTest.java create mode 100644 common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstanceBeansTest.java create mode 100644 common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequestTest.java create mode 100644 common/src/test/java/org/onap/so/utils/CheckResultsTest.java create mode 100644 common/src/test/java/org/onap/so/utils/TestAppender.java create mode 100644 common/src/test/java/org/onap/so/utils/UUIDCheckerTest.java create mode 100644 common/src/test/java/org/onap/so/utils/XMLMarshallerTest.java create mode 100644 common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/adapter_utils/tests/CryptoTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoAlarmLoggerTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoLoggerTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertyInitializerTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/AAIConfigurationTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/AAIExceptionMapperTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/AAIObjectTypeTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/AAIPServerTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/AAIResourcesClientTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/AAITransactionalClientTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/AAIURITest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/AAIUpdatorImplTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/entities/RelationshipsTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactoryTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUriTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriFromUriTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImplTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/exceptions/AAIPayloadExceptionTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/objects/AAIOperationalEnvironmentTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/objects/AAIOwningEntityTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/objects/AAIProjectTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/aai/objects/AAIServiceInstanceTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/dmaap/DmaapClientTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/dmaap/DmaapPublisherTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/grm/GRMBeansTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/grm/GRMClientTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointListTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointRequestTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/policy/PolicyClientImplTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/policy/entities/PolicyEntitiesTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/ruby/RubyCheckClientTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/ruby/beans/RubyBeansTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClientTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/sdno/SDNOValidatorTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/client/sdno/beans/SdnoBeansTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/entity/MsoRequestTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/jsonpath/JsonPathUtilTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/serviceinstancebeans/ServiceInstanceBeansTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesRequestTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/utils/CheckResultsTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/utils/RootIgnoringObjectMapperTest.java delete mode 100644 common/src/test/java/org/openecomp/mso/utils/UUIDCheckerTest.java create mode 100644 common/src/test/resources/__files/aai/bulkprocess/test-request-small.json create mode 100644 common/src/test/resources/org/onap/so/client/ruby/create-ticket/create-ticket-request.json create mode 100644 common/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json create mode 100644 common/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json create mode 100644 common/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json create mode 100644 common/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json create mode 100644 common/src/test/resources/org/onap/so/client/sdno/output-failure.json create mode 100644 common/src/test/resources/org/onap/so/client/sdno/output-success.json create mode 100644 common/src/test/resources/org/onap/so/client/sdno/response.json delete mode 100644 common/src/test/resources/org/openecomp/mso/client/ruby/create-ticket/create-ticket-request.json delete mode 100644 common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-post-check-request.json delete mode 100644 common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-pre-check-request.json delete mode 100644 common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-post-check-request.json delete mode 100644 common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-pre-check-request.json delete mode 100644 common/src/test/resources/org/openecomp/mso/client/sdno/output-failure.json delete mode 100644 common/src/test/resources/org/openecomp/mso/client/sdno/output-success.json delete mode 100644 common/src/test/resources/org/openecomp/mso/client/sdno/response.json (limited to 'common/src') diff --git a/common/src/main/java/org/onap/so/client/DefaultProperties.java b/common/src/main/java/org/onap/so/client/DefaultProperties.java new file mode 100644 index 0000000000..84509ead05 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/DefaultProperties.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client; + +import java.net.MalformedURLException; +import java.net.URL; + +public class DefaultProperties implements RestProperties { + + private final URL url; + public DefaultProperties(URL url) { + this.url = url; + } + @Override + public URL getEndpoint() throws MalformedURLException { + return this.url; + } + + @Override + public String getSystemName() { + return RestClient.ECOMP_COMPONENT_NAME; + } + +} diff --git a/common/src/main/java/org/onap/so/client/HttpClient.java b/common/src/main/java/org/onap/so/client/HttpClient.java new file mode 100644 index 0000000000..ad13745919 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/HttpClient.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client; + +import java.net.URL; +import java.util.Map; +import java.util.Optional; + +import org.onap.so.utils.TargetEntity; + +public class HttpClient extends RestClient { + + private TargetEntity targetEntity; + public HttpClient(URL host, String contentType, TargetEntity targetEntity) { + super(host, contentType); + this.targetEntity = targetEntity; + + } + + @Override + public TargetEntity getTargetEntity(){ + return targetEntity; + } + + @Override + protected void initializeHeaderMap(Map headerMap) { + + } + + @Override + protected Optional addResponseExceptionMapper() { + return Optional.empty(); + } + +} diff --git a/common/src/main/java/org/onap/so/client/PreconditionFailedException.java b/common/src/main/java/org/onap/so/client/PreconditionFailedException.java new file mode 100644 index 0000000000..4ff07a616d --- /dev/null +++ b/common/src/main/java/org/onap/so/client/PreconditionFailedException.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; + +public class PreconditionFailedException extends WebApplicationException { + /** + * + */ + private static final long serialVersionUID = 1L; + + public PreconditionFailedException(String message) { + super(message, Response.Status.PRECONDITION_FAILED); + } +} diff --git a/common/src/main/java/org/onap/so/client/ResponseExceptionMapper.java b/common/src/main/java/org/onap/so/client/ResponseExceptionMapper.java new file mode 100644 index 0000000000..31cdd50aee --- /dev/null +++ b/common/src/main/java/org/onap/so/client/ResponseExceptionMapper.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client; + +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; +import java.util.Optional; + +import javax.ws.rs.BadRequestException; +import javax.ws.rs.ForbiddenException; +import javax.ws.rs.InternalServerErrorException; +import javax.ws.rs.NotAcceptableException; +import javax.ws.rs.NotAllowedException; +import javax.ws.rs.NotAuthorizedException; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.NotSupportedException; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; + +import org.apache.commons.io.IOUtils; + +public abstract class ResponseExceptionMapper { + + public void map(Response response) { + + response.bufferEntity(); + if (response.getStatus() >= 300) { + String message = "empty message"; + if (response.hasEntity()) { + StringWriter writer = new StringWriter(); + try { + IOUtils.copy((InputStream)response.getEntity(), writer, "UTF-8"); + } catch (IOException e) { + writer.append("failed to read entity stream"); + } + Optional result = this.extractMessage(writer.toString()); + if (result.isPresent()) { + message = result.get(); + } + } + Response.Status status = Response.Status.fromStatusCode(response.getStatus()); + WebApplicationException webAppException; + switch (status) { + case BAD_REQUEST: + webAppException = new BadRequestException(message); + break; + case UNAUTHORIZED: + webAppException = new NotAuthorizedException(message); + break; + case FORBIDDEN: + webAppException = new ForbiddenException(message); + break; + case NOT_FOUND: + webAppException = new NotFoundException(message); + break; + case METHOD_NOT_ALLOWED: + webAppException = new NotAllowedException(message); + break; + case NOT_ACCEPTABLE: + webAppException = new NotAcceptableException(message); + break; + case PRECONDITION_FAILED: + webAppException = new PreconditionFailedException(message); + break; + case UNSUPPORTED_MEDIA_TYPE: + webAppException = new NotSupportedException(message); + break; + case INTERNAL_SERVER_ERROR: + webAppException = new InternalServerErrorException(message); + break; + case SERVICE_UNAVAILABLE: + webAppException = new WebApplicationException(message); + break; + default: + webAppException = new WebApplicationException(message); + } + throw webAppException; + } + } + + public abstract Optional extractMessage(String entity); +} diff --git a/common/src/main/java/org/onap/so/client/ResponseExceptionMapperImpl.java b/common/src/main/java/org/onap/so/client/ResponseExceptionMapperImpl.java new file mode 100644 index 0000000000..0392b49629 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/ResponseExceptionMapperImpl.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client; + +import java.util.Optional; + +import javax.annotation.Priority; +import javax.ws.rs.ext.Provider; + +@Provider +@Priority(Integer.MIN_VALUE) +public class ResponseExceptionMapperImpl extends ResponseExceptionMapper { + + @Override + public Optional extractMessage(String entity) { + return Optional.of(entity); + } + + +} diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java new file mode 100644 index 0000000000..79fd7df7ce --- /dev/null +++ b/common/src/main/java/org/onap/so/client/RestClient.java @@ -0,0 +1,320 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client; + +import java.net.ConnectException; +import java.net.MalformedURLException; +import java.net.SocketTimeoutException; +import java.net.URI; +import java.net.URL; +import java.security.GeneralSecurityException; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.concurrent.TimeUnit; +import java.util.function.Predicate; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Invocation.Builder; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriBuilder; + +import org.onap.so.client.policy.CommonObjectMapperProvider; +import org.onap.so.client.policy.LoggingFilter; +import org.onap.so.logger.MsoLogger; +import org.onap.so.logging.jaxrs.filter.jersey.JaxRsClientLogging; +import org.onap.so.utils.CryptoUtils; +import org.onap.so.utils.TargetEntity; +import org.slf4j.MDC; + +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; + +import net.jodah.failsafe.Failsafe; +import net.jodah.failsafe.RetryPolicy; + + +public abstract class RestClient { + public static final String ECOMP_COMPONENT_NAME = "MSO"; + + private static final int MAX_PAYLOAD_SIZE = 1024 * 1024; + private WebTarget webTarget; + + protected final Map headerMap; + protected final MsoLogger msoLogger; + protected URL host; + protected Optional path; + protected String accept; + protected String contentType; + protected String requestId; + protected JaxRsClientLogging jaxRsClientLogging; + protected RestProperties props; + + protected RestClient(RestProperties props, Optional path) { + + msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, RestClient.class); + this.requestId = MDC.get(MsoLogger.REQUEST_ID); + if (requestId == null) { + requestId = ""; + } + headerMap = new HashMap<>(); + try { + host = props.getEndpoint(); + } catch (MalformedURLException e) { + + throw new RuntimeException(e); + } + this.props = props; + this.path = path; + } + + protected RestClient(RestProperties props, Optional path, String accept, String contentType) { + this(props, path); + this.accept = accept; + this.contentType = contentType; + this.requestId = MDC.get(MsoLogger.REQUEST_ID); + if (requestId == null) { + requestId = ""; + } + this.props = props; + } + + protected RestClient(URL host, String contentType) { + headerMap = new HashMap<>(); + + msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, RestClient.class); + this.path = Optional.empty(); + this.host = host; + this.contentType = contentType; + this.requestId = MDC.get(MsoLogger.REQUEST_ID); + if (requestId == null) { + requestId = ""; + } + this.props = new DefaultProperties(host); + } + + /** + * Override method to return false to disable logging. + * + * @return true - to enable logging, false otherwise + */ + protected boolean enableLogging() { + return true; + } + + /** + * Override method to return custom value for max payload size. + * + * @return Default value for MAX_PAYLOAD_SIZE = 1024 * 1024 + */ + protected int getMaxPayloadSize() + { + return MAX_PAYLOAD_SIZE; + } + + protected Builder getBuilder() { + + if (webTarget == null) { + initializeClient(getClient()); + } + Builder builder = webTarget.request(); + initializeHeaderMap(headerMap); + + headerMap.put("X-ECOMP-RequestID", requestId); + for (Entry entry : headerMap.entrySet()) { + builder.header(entry.getKey(), entry.getValue()); + } + return builder; + } + + protected abstract void initializeHeaderMap(Map headerMap); + + protected Optional addResponseExceptionMapper() { + return Optional.of(new ResponseExceptionMapperImpl()); + } + + protected CommonObjectMapperProvider getCommonObjectMapperProvider() { + return new CommonObjectMapperProvider(); + } + + /** + * Adds a basic authentication header to the request. + * @param auth the encrypted credentials + * @param key the key for decrypting the credentials + */ + protected void addBasicAuthHeader(String auth, String key) { + try { + byte[] decryptedAuth = CryptoUtils.decrypt(auth, key).getBytes(); + String authHeaderValue = "Basic " + Base64.getEncoder().encodeToString(decryptedAuth); + headerMap.put("Authorization", authHeaderValue); + } catch (GeneralSecurityException e) { + msoLogger.error(e.getMessage(), e); + } + } + + protected String getAccept() { + return accept; + } + + protected String getContentType() { + return contentType; + } + + protected String getMergeContentType() { + return "application/merge-patch+json"; + } + + protected Client getClient() { + return ClientBuilder.newBuilder().build(); + } + + protected abstract TargetEntity getTargetEntity(); + + protected void initializeClient(Client client) { + if (this.enableLogging()) { + client.register(new LoggingFilter(this.getMaxPayloadSize())); + } + CommonObjectMapperProvider provider = this.getCommonObjectMapperProvider(); + client.register(new JacksonJsonProvider(provider.getMapper())); + + jaxRsClientLogging = new JaxRsClientLogging(); + jaxRsClientLogging.setTargetService(getTargetEntity()); + client.register(jaxRsClientLogging); + + if (!path.isPresent()) { + webTarget = client.target(host.toString()); + } else { + webTarget = client.target(UriBuilder.fromUri(host + path.get().toString())); + } + if (getAccept() == null || getAccept().isEmpty()) { + this.accept = MediaType.APPLICATION_JSON; + } + if (getContentType() == null || getContentType().isEmpty()) { + this.contentType = MediaType.APPLICATION_JSON; + } + } + + protected List> retryOn() { + + List> result = new ArrayList<>(); + + result.add(e -> { + return e.getCause() instanceof SocketTimeoutException; + }); + result.add(e -> { + return e.getCause() instanceof ConnectException; + }); + return result; + } + + public Response get() { + return method("GET", null); + } + + public Response post(Object obj) { + return method("POST", obj); + } + + public Response patch(Object obj) { + return method("PATCH", obj); + } + + public Response put(Object obj) { + return method("PUT", obj); + } + + public Response delete() { + return method("DELETE", null); + } + + public Response delete(Object obj) { + return method("DELETE", obj); + } + + public Optional get(Class resultClass) { + return format(method("GET", null), resultClass); + } + + public Optional get(GenericType resultClass) { + return format(method("GET", null), resultClass); + } + + public T post(Object obj, Class resultClass) { + return format(method("POST", obj), resultClass).orElse(null); + } + + public T patch(Object obj, Class resultClass) { + return format(method("PATCH", obj), resultClass).orElse(null); + } + + public T put(Object obj, Class resultClass) { + return format(method("PUT", obj), resultClass).orElse(null); + } + + public T delete(Class resultClass) { + return format(method("DELETE", null), resultClass).orElse(null); + } + + public T delete(Object obj, Class resultClass) { + return format(method("DELETE", obj), resultClass).orElse(null); + } + + private Response method(String method, Object entity) { + RetryPolicy policy = new RetryPolicy(); + + List> items = retryOn(); + + Predicate pred = items.stream().reduce(Predicate::or).orElse(x -> false); + + policy.retryOn(error -> pred.test(error)); + + policy.withDelay(this.props.getDelayBetweenRetries(), TimeUnit.MILLISECONDS) + .withMaxRetries(this.props.getRetries()); + + return Failsafe.with(policy).get(buildRequest(method, entity)); + } + + protected RestRequest buildRequest(String method, Object entity) { + return new RestRequest(this, method, entity); + } + private Optional format(Response response, Class resultClass) { + if (this.props.mapNotFoundToEmpty() && response.getStatus() == Status.NOT_FOUND.getStatusCode()) { + return Optional.empty(); + } + return Optional.of(response.readEntity(resultClass)); + } + + private Optional format(Response response, GenericType resultClass) { + if (this.props.mapNotFoundToEmpty() && response.getStatus() == Status.NOT_FOUND.getStatusCode()) { + return Optional.empty(); + } + return Optional.of(response.readEntity(resultClass)); + } +} diff --git a/common/src/main/java/org/onap/so/client/RestClientSSL.java b/common/src/main/java/org/onap/so/client/RestClientSSL.java new file mode 100644 index 0000000000..461bb5832c --- /dev/null +++ b/common/src/main/java/org/onap/so/client/RestClientSSL.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client; + +import java.io.FileInputStream; +import java.net.URI; +import java.security.KeyStore; +import java.security.NoSuchAlgorithmException; +import java.util.Optional; + +import javax.net.ssl.SSLContext; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; + +public abstract class RestClientSSL extends RestClient { + + public static final String SSL_KEY_STORE_KEY = "javax.net.ssl.keyStore"; + public static final String SSL_KEY_STORE_PASSWORD_KEY = "javax.net.ssl.keyStorePassword"; + public static final String MSO_LOAD_SSL_CLIENT_KEYSTORE_KEY = "mso.load.ssl.client.keystore"; + + + protected RestClientSSL(RestProperties props, Optional path) { + super(props, path); + } + + protected RestClientSSL(RestProperties props, Optional path, String accept, String contentType) { + super(props, path, accept, contentType); + } + + @Override + protected Client getClient() { + + Client client = null; + try { + String loadSSLKeyStore = System.getProperty(RestClientSSL.MSO_LOAD_SSL_CLIENT_KEYSTORE_KEY); + if(loadSSLKeyStore != null && loadSSLKeyStore.equalsIgnoreCase("true")) { + KeyStore ks = getKeyStore(); + if(ks != null) { + client = ClientBuilder.newBuilder().keyStore(ks, System.getProperty(RestClientSSL.SSL_KEY_STORE_PASSWORD_KEY)).build(); + this.msoLogger.debug("RestClientSSL not using default SSL context - setting keystore here."); + return client; + } + } + //Use default SSL context + client = ClientBuilder.newBuilder().sslContext(SSLContext.getDefault()).build(); + this.msoLogger.debug("RestClientSSL using default SSL context!"); + } catch (NoSuchAlgorithmException e) { + //this.logger.error(MessageEnum.APIH_GENERAL_EXCEPTION, "AAI", "Client init", MsoLogger.ErrorCode.UnknownError, "could not create SSL client", e); + throw new RuntimeException(e); + } + return client; + } + + private KeyStore getKeyStore() { + KeyStore ks = null; + char[] password = System.getProperty(RestClientSSL.SSL_KEY_STORE_PASSWORD_KEY).toCharArray(); + FileInputStream fis = null; + try { + ks = KeyStore.getInstance(KeyStore.getDefaultType()); + fis = new FileInputStream(System.getProperty(RestClientSSL.SSL_KEY_STORE_KEY)); + ks.load(fis, password); + } + catch(Exception e) { + return null; + } + finally { + if (fis != null) { + try { + fis.close(); + } + catch(Exception e) {} + } + } + return ks; + } +} diff --git a/common/src/main/java/org/onap/so/client/RestProperties.java b/common/src/main/java/org/onap/so/client/RestProperties.java new file mode 100644 index 0000000000..7043e89b1e --- /dev/null +++ b/common/src/main/java/org/onap/so/client/RestProperties.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client; + +import java.net.MalformedURLException; +import java.net.URL; + +public interface RestProperties { + + public URL getEndpoint() throws MalformedURLException; + public String getSystemName(); + public default Integer getRetries() { + return Integer.valueOf(2); + } + public default Long getDelayBetweenRetries() { + return Long.valueOf(500); + } + public default boolean mapNotFoundToEmpty() { + return false; + } +} diff --git a/common/src/main/java/org/onap/so/client/RestPropertiesLoader.java b/common/src/main/java/org/onap/so/client/RestPropertiesLoader.java new file mode 100644 index 0000000000..570b48ecb8 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/RestPropertiesLoader.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client; + +import java.util.Iterator; +import java.util.ServiceLoader; + +public class RestPropertiesLoader { + + /* required to make ServiceLoader thread safe */ + private static final ThreadLocal> services = new ThreadLocal>() { + @Override + protected ServiceLoader initialValue() { + return ServiceLoader.load(RestProperties.class); + } + }; + private RestPropertiesLoader() { + } + + private static class Helper { + private static final RestPropertiesLoader INSTANCE = new RestPropertiesLoader(); + } + + public static RestPropertiesLoader getInstance() { + return Helper.INSTANCE; + } + + public T getNewImpl(Class clazz) { + return this.getImpl(clazz, true); + } + public T getImpl(Class clazz) { + return this.getImpl(clazz, false); + } + + private T getImpl(Class clazz, boolean forceNewInstance) { + T result = null; + ServiceLoader loader = this.services.get(); + Iterator propertyImpls = loader.iterator(); + RestProperties item; + while (propertyImpls.hasNext()) { + item = propertyImpls.next(); + if (clazz.isAssignableFrom(item.getClass())) { + try { + if (forceNewInstance) { + result = (T)item.getClass().newInstance(); + } else { + result = (T)item; + } + } catch (InstantiationException | IllegalAccessException e) { + /* all spi implementations must provide a public + * no argument constructor + */ + + } + //break; + } + } + + return result; + } +} diff --git a/common/src/main/java/org/onap/so/client/RestRequest.java b/common/src/main/java/org/onap/so/client/RestRequest.java new file mode 100644 index 0000000000..25bf54b643 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/RestRequest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client; + +import java.util.Optional; +import java.util.concurrent.Callable; + +import javax.ws.rs.NotFoundException; +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; + +import org.onap.so.logger.MsoLogger; + +public class RestRequest implements Callable { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, RestRequest.class); + + private final RestClient client; + private final String method; + private final Object entity; + + public RestRequest(RestClient client, String method, Object entity) { + this.client = client; + this.method = method; + this.entity = entity; + } + @Override + public Response call() throws Exception { + final Response response; + if ("GET".equals(method)) { + response = this.client.getBuilder().accept(this.client.getAccept()).get(); + } else if ("POST".equals(method)) { + response = this.client.getBuilder().accept(this.client.getAccept()).post(Entity.entity(entity, this.client.getContentType())); + } else if ("PATCH".equals(method)) { + response = this.client.getBuilder().header("X-HTTP-Method-Override", "PATCH").accept(this.client.getAccept()) + .post(Entity.entity(entity, this.client.getMergeContentType())); + } else if ("DELETE".equals(method)) { + if (entity == null) { + response = this.client.getBuilder().accept(this.client.getAccept()).delete(); + + } else { + response = this.client.getBuilder().header("X-HTTP-Method-Override", "DELETE").accept(this.client.getAccept()) + .post(Entity.entity(entity, this.client.getContentType())); + } + } else if ("PUT".equals(method)) { + response = this.client.getBuilder().accept(this.client.getAccept()).put(Entity.entity(entity, this.client.getContentType())); + } else { + response = Response.serverError().entity(method + " not valid").build(); + } + + Optional mapper = this.client.addResponseExceptionMapper(); + if (mapper.isPresent()) { + try { + mapper.get().map(response); + } catch (NotFoundException e) { + if (this.client.props.mapNotFoundToEmpty()) { + msoLogger.error(e); + return response; + } else { + throw e; + } + } + } else { + if (response.getStatus() == Status.NOT_FOUND.getStatusCode() && this.client.props.mapNotFoundToEmpty()) { + return response; + } + } + + return response; + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIClient.java b/common/src/main/java/org/onap/so/client/aai/AAIClient.java new file mode 100644 index 0000000000..39843b2263 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIClient.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import java.net.URI; + +import javax.ws.rs.core.UriBuilder; + +import org.onap.so.client.RestClient; +import org.onap.so.client.graphinventory.GraphInventoryClient; +import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public abstract class AAIClient extends GraphInventoryClient { + + private static final String AAI_ROOT = "/aai"; + protected static Logger logger = LoggerFactory.getLogger(AAIClient.class); + protected AAIVersion version; + public AAIClient() { + super(AAIProperties.class); + } + + public AAIClient(AAIVersion version) { + super(AAIProperties.class); + } + @Override + protected URI constructPath(GraphInventoryUri uri) { + + return UriBuilder.fromUri(AAI_ROOT + "/" + this.getVersion().toString() + uri.build().toString()).build(); + } + @Override + protected RestClient createClient(GraphInventoryUri uri) { + return new AAIRestClient(getRestProperties(), constructPath(uri)); + } + + protected AAIVersion getVersion() { + if (version == null) { + return this.getRestProperties().getDefaultVersion(); + } else { + return this.version; + } + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIClientResponseExceptionMapper.java b/common/src/main/java/org/onap/so/client/aai/AAIClientResponseExceptionMapper.java new file mode 100644 index 0000000000..514eab6fc4 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIClientResponseExceptionMapper.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import java.io.IOException; +import java.util.Optional; + +import javax.annotation.Priority; +import javax.ws.rs.ext.Provider; + +import javax.annotation.Priority; +import javax.ws.rs.ext.Provider; + +import org.onap.so.client.ResponseExceptionMapper; +import org.onap.so.client.aai.entities.AAIError; +import org.onap.so.logger.MsoLogger; +import org.slf4j.MDC; + +import com.fasterxml.jackson.databind.ObjectMapper; + +@Provider +@Priority(Integer.MIN_VALUE) +public class AAIClientResponseExceptionMapper extends ResponseExceptionMapper { + + private final String requestId; + public AAIClientResponseExceptionMapper() { + this.requestId = MDC.get(MsoLogger.REQUEST_ID); + } + @Override + public Optional extractMessage(String entity) { + + String errorString = "Error calling A&AI. Request-Id=" + this.getRequestId() + " "; + try { + AAIError error = new ObjectMapper().readValue(entity, AAIError.class); + AAIErrorFormatter formatter = new AAIErrorFormatter(error); + return Optional.of(errorString + formatter.getMessage()); + } catch (IOException e) { + return Optional.of(errorString + entity); + } + } + + protected String getRequestId() { + return this.requestId; + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java b/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java new file mode 100644 index 0000000000..33c9769400 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.aai; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +public class AAICommonObjectMapperPatchProvider extends AAICommonObjectMapperProvider { + + + public AAICommonObjectMapperPatchProvider() { + super(); + EmptyStringToNullSerializer sp = new EmptyStringToNullSerializer(); + SimpleModule emptyStringModule = new SimpleModule(); + emptyStringModule.addSerializer(String.class, sp); + mapper.registerModule(emptyStringModule); + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java b/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java new file mode 100644 index 0000000000..0e2071842f --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import org.onap.so.client.policy.CommonObjectMapperProvider; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.databind.AnnotationIntrospector; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; +import com.fasterxml.jackson.databind.type.TypeFactory; +import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; + +public class AAICommonObjectMapperProvider extends CommonObjectMapperProvider { + + public AAICommonObjectMapperProvider() { + mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); + mapper.enable(MapperFeature.USE_ANNOTATIONS); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + AnnotationIntrospector aiJaxb = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); + AnnotationIntrospector aiJackson = new JacksonAnnotationIntrospector(); + // first Jaxb, second Jackson annotations + mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(aiJaxb, aiJackson)); + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIConfigurationClient.java b/common/src/main/java/org/onap/so/client/aai/AAIConfigurationClient.java new file mode 100644 index 0000000000..b29c8070c8 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIConfigurationClient.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import org.onap.so.client.aai.entities.Configuration; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.serviceinstancebeans.RequestDetails; + +public class AAIConfigurationClient { + + private AAIResourcesClient aaiClient; + + private static final String ORCHESTRATION_STATUS = "PreCreated"; + + public AAIConfigurationClient() { + aaiClient = new AAIResourcesClient(); + } + + public void createConfiguration(RequestDetails requestDetails, String configurationId, String configurationType, + String configurationSubType) { + + AAIResourceUri uri = getConfigurationURI(configurationId); + Configuration payload = configurePayload(requestDetails, configurationId, configurationType, configurationSubType); + + aaiClient.create(uri, payload); + } + + public Configuration configurePayload(RequestDetails requestDetails, String configurationId, String configurationType, + String configurationSubType) { + + Configuration payload = new Configuration(); + payload.setConfigurationId(configurationId); + payload.setConfigurationType(configurationType); + payload.setConfigurationSubType(configurationSubType); + payload.setModelInvariantId(requestDetails.getModelInfo().getModelInvariantId()); + payload.setModelVersionId(requestDetails.getModelInfo().getModelVersionId()); + payload.setOrchestrationStatus(ORCHESTRATION_STATUS); + payload.setOperationalStatus(""); + payload.setConfigurationSelflink(getConfigurationURI(configurationId).build().getPath()); + payload.setModelCustomizationId(requestDetails.getModelInfo().getModelCustomizationId()); + + return payload; + } + + public void deleteConfiguration(String uuid) { + aaiClient.delete(getConfigurationURI(uuid)); + } + + public void updateOrchestrationStatus(String uuid, String payload) { + aaiClient.update(getConfigurationURI(uuid), payload); + } + + public Configuration getConfiguration(String uuid) { + return aaiClient.get(Configuration.class, getConfigurationURI(uuid)).orElse(null); + } + + public boolean configurationExists(String uuid) { + return aaiClient.exists(getConfigurationURI(uuid)); + } + + public AAIResourceUri getConfigurationURI(String uuid) { + return AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, uuid); + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java b/common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java new file mode 100644 index 0000000000..6b3bb545de --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIErrorFormatter.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import java.util.List; + +import org.onap.so.client.aai.entities.AAIError; +import org.onap.so.client.aai.entities.ServiceException; + +public class AAIErrorFormatter { + + private final AAIError error; + public AAIErrorFormatter(AAIError error) { + this.error = error; + } + + public String getMessage() { + if (error.getRequestError() != null && + error.getRequestError().getServiceException() != null) { + ServiceException serviceException = error.getRequestError().getServiceException(); + return this.fillInTemplate(serviceException.getText(), serviceException.getVariables()); + } + + return "no parsable error message found"; + } + + protected String fillInTemplate(String text, List variables) { + for (int i = 0; i < variables.size(); i++) { + variables.set(i, this.format(variables.get(i), variables)); + } + + return format(text, variables); + } + + protected String format(String s, List variables) { + return String.format(s.replaceAll("%(\\d+)", "%$1\\$s"), variables.toArray()); + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java b/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java new file mode 100644 index 0000000000..242fd41b19 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +public class AAINamespaceConstants { + + protected static final String CLOUD_INFRASTRUCTURE = "/cloud-infrastructure"; + protected static final String NETWORK = "/network"; + protected static final String BUSINESS = "/business"; + protected static final String SERVICE_DESIGN_AND_CREATION = "/service-design-and-creation"; + + +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java new file mode 100644 index 0000000000..c50653a203 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; + +import com.google.common.base.CaseFormat; + +public enum AAIObjectPlurals implements GraphInventoryObjectPlurals { + + GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs"), + PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers"), + P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces"), + L3_NETWORK(AAINamespaceConstants.NETWORK, "/l3-networks"), + SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions"), + SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances"), + OWNING_ENTITIES(AAINamespaceConstants.BUSINESS, "/owning-entities"), + VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups/"); + + + private final String uriTemplate; + private final String partialUri; + private AAIObjectPlurals(String parentUri, String partialUri) { + this.uriTemplate = parentUri + partialUri; + this.partialUri = partialUri; + } + + @Override + public String toString() { + return this.uriTemplate(); + } + + @Override + public String uriTemplate() { + return this.uriTemplate; + } + + @Override + public String partialUri() { + return this.partialUri; + } + + @Override + public String typeName() { + return this.typeName(CaseFormat.LOWER_HYPHEN); + } + @Override + public String typeName(CaseFormat format) { + return CaseFormat.UPPER_UNDERSCORE.to(format, this.name()); + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java new file mode 100644 index 0000000000..ce75b1716a --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import org.onap.so.client.graphinventory.GraphInventoryObjectType; + +import com.google.common.base.CaseFormat; + +public enum AAIObjectType implements GraphInventoryObjectType { + + DEFAULT_CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/att-aic/{cloud-region-id}"), + CUSTOMER(AAINamespaceConstants.BUSINESS, "/customers/customer/{global-customer-id}"), + GENERIC_QUERY("/search", "/generic-query"), + BULK_PROCESS("/bulkprocess", ""), + GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs/generic-vnf/{vnf-id}"), + VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules/vf-module/{vf-module-id}"), + L3_NETWORK(AAINamespaceConstants.NETWORK, "/l3-networks/l3-network/{network-id}"), + NETWORK_POLICY(AAINamespaceConstants.NETWORK, "/network-policies/network-policy/{network-policy-id}"), + NODES_QUERY("/search", "/nodes-query"), + CUSTOM_QUERY("/query", ""), + ROUTE_TABLE_REFERENCE(AAINamespaceConstants.NETWORK, "/route-table-references/route-table-reference/{route-table-reference-id}"), + DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/att-aic/AAIAIC25", "/tenants/tenant/{tenant-id}"), + VCE(AAINamespaceConstants.NETWORK, "/vces/vce/{vnf-id}"), + VPN_BINDING(AAINamespaceConstants.NETWORK, "/vpn-bindings/vpn-binding/{vpn-id}"), + VPN_BINDINGS(AAINamespaceConstants.NETWORK, "/vpn-bindings"), + CONFIGURATION(AAINamespaceConstants.NETWORK, "/configurations/configuration/{configuration-id}"), + PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers/pserver/{hostname}"), + SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions/service-subscription/{service-type}"), + SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances/service-instance/{service-instance-id}"), + PROJECT(AAINamespaceConstants.BUSINESS, "/projects/project/{id}"), + LINE_OF_BUSINESS(AAINamespaceConstants.BUSINESS, "/lines-of-business/line-of-business/{id}"), + PLATFORM(AAINamespaceConstants.BUSINESS, "/platforms/platform/{id}"), + OWNING_ENTITY(AAINamespaceConstants.BUSINESS, "/owning-entities/owning-entity/{id}"), + ALLOTTED_RESOURCE(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/allotted-resources/allotted-resource/{id}"), + PNF(AAINamespaceConstants.NETWORK, "/pnfs/pnf/{pnf-name}"), + OPERATIONAL_ENVIRONMENT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/operational-environments/operational-environment/{operational-environment-id}"), + CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/{cloud-owner-id}/{cloud-region-id}"), + TENANT(AAIObjectType.CLOUD_REGION.uriTemplate(), "/tenants/tenant/{tenant-id}"), + VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups/volume-group/{volume-group-id}"), + VSERVER(AAIObjectType.TENANT.uriTemplate(), "/vservers/vserver/{vserver-id}"), + MODEL_VER(AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/models/model/{model-invariant-id}", "/model-vers/model-ver/{model-version-id}"), + TUNNEL_XCONNECT(AAIObjectType.ALLOTTED_RESOURCE.uriTemplate(), "/tunnel-xconnects/tunnel-xconnect/{tunnel-id}"), + P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces/p-interface/{interface-name}"), + PHYSICAL_LINK(AAINamespaceConstants.NETWORK, "/physical-links/physical-link/{link-name}"), + INSTANCE_GROUP(AAINamespaceConstants.NETWORK, "/instance-groups/instance-group/{id}"), + COLLECTION(AAINamespaceConstants.NETWORK, "/collections/collection/{collection-id}"), + UNKNOWN("", ""); + + private final String uriTemplate; + private final String parentUri; + private final String partialUri; + private AAIObjectType(String parentUri, String partialUri) { + this.parentUri = parentUri; + this.partialUri = partialUri; + this.uriTemplate = parentUri + partialUri; + } + + @Override + public String toString() { + return this.uriTemplate(); + } + + @Override + public String typeName() { + return this.typeName(CaseFormat.LOWER_HYPHEN); + } + @Override + public String typeName(CaseFormat format) { + String enumName = this.name(); + if (this.equals(AAIObjectType.DEFAULT_CLOUD_REGION) || this.equals(AAIObjectType.DEFAULT_TENANT)) { + enumName = enumName.replace("DEFAULT_", ""); + } + + return CaseFormat.UPPER_UNDERSCORE.to(format, enumName); + } + + @Override + public String uriTemplate() { + return this.uriTemplate; + } + + @Override + public String partialUri() { + return this.partialUri; + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIProperties.java b/common/src/main/java/org/onap/so/client/aai/AAIProperties.java new file mode 100644 index 0000000000..9f6708200c --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIProperties.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import org.onap.so.client.RestProperties; + +public interface AAIProperties extends RestProperties { + + public AAIVersion getDefaultVersion(); + public String getAuth(); + public String getKey(); + @Override + public default boolean mapNotFoundToEmpty() { + return true; + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java b/common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java new file mode 100644 index 0000000000..184b4e5251 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIQueryClient.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import java.util.Optional; + +import org.onap.so.client.RestClient; +import org.onap.so.client.aai.entities.CustomQuery; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.graphinventory.Format; +import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri; + +public class AAIQueryClient extends AAIClient { + + private Optional depth = Optional.empty(); + private boolean nodesOnly = false; + private Optional subgraph = Optional.empty(); + + public AAIQueryClient() { + super(); + } + + public AAIQueryClient(AAIVersion version) { + super(); + this.version = version; + } + + public String query(Format format, CustomQuery query) { + return this.createClient(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY).queryParam("format", format.toString())) + .put(query, String.class); + } + + public AAIQueryClient depth (String depth) { + this.depth = Optional.of(depth); + return this; + } + public AAIQueryClient nodesOnly() { + this.nodesOnly = true; + return this; + } + public AAIQueryClient subgraph(AAISubgraphType type){ + + subgraph = Optional.of(type); + + return this; + } + + protected GraphInventoryUri setupQueryParams(GraphInventoryUri uri) { + GraphInventoryUri clone = uri.clone(); + if (this.depth.isPresent()) { + clone.queryParam("depth", depth.get()); + } + if (this.nodesOnly) { + clone.queryParam("nodesOnly", ""); + } + if (this.subgraph.isPresent()) { + clone.queryParam("subgraph", this.subgraph.get().toString()); + } + return clone; + } + @Override + protected RestClient createClient(GraphInventoryUri uri) { + return super.createClient(setupQueryParams(uri)); + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIQueryObjectMapperProvider.java b/common/src/main/java/org/onap/so/client/aai/AAIQueryObjectMapperProvider.java new file mode 100644 index 0000000000..d5eeb83041 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIQueryObjectMapperProvider.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import com.fasterxml.jackson.databind.AnnotationIntrospector; +import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; +import com.fasterxml.jackson.databind.type.TypeFactory; +import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; + +public class AAIQueryObjectMapperProvider extends AAICommonObjectMapperProvider { + + public AAIQueryObjectMapperProvider() { + super(); + AnnotationIntrospector aiJaxb = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); + AnnotationIntrospector aiJackson = new JacksonAnnotationIntrospector(); + // first Jaxb, second Jackson annotations + mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(aiJaxb, aiJackson)); + + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java new file mode 100644 index 0000000000..04757c6fc2 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java @@ -0,0 +1,254 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import java.lang.reflect.InvocationTargetException; +import java.util.Map; +import java.util.Optional; + +import javax.ws.rs.NotFoundException; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; + +import org.onap.aai.domain.yang.Relationship; +import org.onap.so.client.RestClient; +import org.onap.so.client.RestProperties; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUri; +import org.onap.so.client.graphinventory.entities.uri.Depth; + +public class AAIResourcesClient extends AAIClient { + + public AAIResourcesClient() { + super(); + } + + public AAIResourcesClient(AAIVersion version) { + super(); + this.version = version; + } + + /** + * creates a new object in A&AI + * + * @param obj - can be any object which will marshal into a valid A&AI payload + * @param uri + * @return + */ + public void create(AAIResourceUri uri, Object obj) { + RestClient aaiRC = this.createClient(uri); + aaiRC.put(obj); + return; + } + + /** + * creates a new object in A&AI with no payload body + * + * @param uri + * @return + */ + public void createEmpty(AAIResourceUri uri) { + RestClient aaiRC = this.createClient(uri); + aaiRC.put(""); + return; + } + + /** + * returns false if the object does not exist in A&AI + * + * @param uri + * @return + */ + public boolean exists(AAIResourceUri uri) { + AAIUri forceMinimal = this.addParams(Optional.of(Depth.ZERO), true, uri); + RestClient aaiRC = this.createClient(forceMinimal); + + return aaiRC.get().getStatus() == Status.OK.getStatusCode(); + } + + /** + * Adds a relationship between two objects in A&AI + * @param uriA + * @param uriB + * @return + */ + public void connect(AAIResourceUri uriA, AAIResourceUri uriB) { + AAIResourceUri uriAClone = uriA.clone(); + RestClient aaiRC = this.createClient(uriAClone.relationshipAPI()); + aaiRC.put(this.buildRelationship(uriB)); + return; + } + + /** + * Removes relationship from two objects in A&AI + * + * @param uriA + * @param uriB + * @return + */ + public void disconnect(AAIResourceUri uriA, AAIResourceUri uriB) { + AAIResourceUri uriAClone = uriA.clone(); + RestClient aaiRC = this.createClient(uriAClone.relationshipAPI()); + aaiRC.delete(this.buildRelationship(uriB)); + return; + } + + /** + * Deletes object from A&AI. Automatically handles resource-version. + * + * @param uri + * @return + */ + public void delete(AAIResourceUri uri) { + AAIResourceUri clone = uri.clone(); + RestClient aaiRC = this.createClient(clone); + Map result = aaiRC.get(new GenericType>(){}) + .orElseThrow(() -> new NotFoundException(clone.build() + " does not exist in A&AI")); + String resourceVersion = (String) result.get("resource-version"); + aaiRC = this.createClient(clone.resourceVersion(resourceVersion)); + aaiRC.delete(); + return; + } + + /** + * @param obj - can be any object which will marshal into a valid A&AI payload + * @param uri + * @return + */ + public void update(AAIResourceUri uri, Object obj) { + RestClient aaiRC = this.createClient(uri); + aaiRC.patch(obj); + return; + } + + /** + * Retrieves an object from A&AI and unmarshalls it into the Class specified + * @param clazz + * @param uri + * @return + */ + public Optional get(Class clazz, AAIResourceUri uri) { + return this.createClient(uri).get(clazz); + } + + /** + * Retrieves an object from A&AI and returns complete response + * @param uri + * @return + */ + public Response getFullResponse(AAIResourceUri uri) { + return this.createClient(uri).get(); + } + + /** + * Retrieves an object from A&AI and automatically unmarshalls it into a Map or List + * @param resultClass + * @param uri + * @return + */ + public Optional get(GenericType resultClass, AAIResourceUri uri) { + return this.createClient(uri).get(resultClass); + } + + /** + * Retrieves an object from A&AI wrapped in a helper class which offer additional features + * + * @param uri + * @return + */ + public AAIResultWrapper get(AAIResourceUri uri) { + String json = this.createClient(uri).get(String.class).orElse(null); + return new AAIResultWrapper(json); + } + + /** + * Retrieves an object from A&AI wrapped in a helper class which offer additional features + * If the object cannot be found in A&AI the method will throw the runtime exception + * included as an argument + * @param uri + * @return + */ + public AAIResultWrapper get(AAIResourceUri uri, Class c) { + + RuntimeException e; + try { + e = c.getConstructor(String.class).newInstance(uri.build() + " not found in A&AI"); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException + | NoSuchMethodException | SecurityException e1) { + throw new IllegalArgumentException("could not create instance for " + c.getName()); + } + String json = this.createClient(uri).get(String.class) + .orElseThrow(() -> e); + return new AAIResultWrapper(json); + } + + private Relationship buildRelationship(AAIResourceUri uri) { + final Relationship result = new Relationship(); + result.setRelatedLink(uri.build().toString()); + return result; + } + + /** + * Will automatically create the object if it does not exist + * + * @param obj - Optional object which serializes to a valid A&AI payload + * @param uri + * @return + */ + public AAIResourcesClient createIfNotExists(AAIResourceUri uri, Optional obj) { + if(!this.exists(uri)){ + if (obj.isPresent()) { + this.create(uri, obj.get()); + } else { + this.createEmpty(uri); + } + + } + return this; + } + + /** + * Starts a transaction which encloses multiple A&AI mutations + * + * @return + */ + public AAITransactionalClient beginTransaction() { + return new AAITransactionalClient(this.getVersion()); + } + + private AAIUri addParams(Optional depth, boolean nodesOnly, AAIUri uri) { + AAIUri clone = uri.clone(); + if (depth.isPresent()) { + clone.depth(depth.get()); + } + if (nodesOnly) { + clone.nodesOnly(nodesOnly); + } + + return clone; + } + @Override + protected T getRestProperties() { + return super.getRestProperties(); + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIResourcesObjectMapperProvider.java b/common/src/main/java/org/onap/so/client/aai/AAIResourcesObjectMapperProvider.java new file mode 100644 index 0000000000..15f2ed2fa2 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIResourcesObjectMapperProvider.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +public class AAIResourcesObjectMapperProvider extends AAICommonObjectMapperProvider { + + public AAIResourcesObjectMapperProvider() { + super(); + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java new file mode 100644 index 0000000000..2bd5f118c0 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import java.net.URI; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.regex.Pattern; + +import javax.ws.rs.core.Response; + +import org.onap.so.client.ResponseExceptionMapper; +import org.onap.so.client.RestClientSSL; +import org.onap.so.client.graphinventory.exceptions.GraphInventoryPatchDepthExceededException; +import org.onap.so.client.policy.CommonObjectMapperProvider; +import org.onap.so.jsonpath.JsonPathUtil; +import org.onap.so.utils.TargetEntity; + +import com.fasterxml.jackson.core.JsonProcessingException; + +public class AAIRestClient extends RestClientSSL { + + private final AAIProperties aaiProperties; + private static final AAICommonObjectMapperProvider standardProvider = new AAICommonObjectMapperProvider(); + private static final AAICommonObjectMapperPatchProvider patchProvider = new AAICommonObjectMapperPatchProvider(); + private static final Pattern LOCATE_COMPLEX_OBJECT = Pattern.compile("^((?!relationship-list).)+?\\['[^\\[\\]]+?'\\]$"); + + protected AAIRestClient(AAIProperties props, URI uri) { + super(props, Optional.of(uri)); + this.aaiProperties = props; + } + + @Override + public TargetEntity getTargetEntity(){ + return TargetEntity.AAI; + } + + @Override + protected void initializeHeaderMap(Map headerMap) { + headerMap.put("X-FromAppId", "MSO"); + headerMap.put("X-TransactionId", requestId); + String auth = aaiProperties.getAuth(); + String key = aaiProperties.getKey(); + + if (auth != null && !auth.isEmpty() && key != null && !key.isEmpty()) { + addBasicAuthHeader(auth, key); + } + } + + @Override + protected Optional addResponseExceptionMapper() { + + return Optional.of(new AAIClientResponseExceptionMapper()); + } + + @Override + protected CommonObjectMapperProvider getCommonObjectMapperProvider() { + return standardProvider; + } + + @Override + public Response patch(Object obj) { + String value = convertObjectToPatchFormat(obj); + validatePatchObject(value); + return super.patch(value); + } + + @Override + public T patch(Object obj, Class resultClass) { + String value = convertObjectToPatchFormat(obj); + validatePatchObject(value); + return super.patch(value, resultClass); + } + + protected String convertObjectToPatchFormat(Object obj) { + Object value = obj; + try { + if (!(obj instanceof Map || obj instanceof String)) { + value = patchProvider.getMapper().writeValueAsString(obj); + } else if (obj instanceof Map) { + value = standardProvider.getMapper().writeValueAsString(obj); + } + } catch (JsonProcessingException e) { + value = "{}"; + } + + return (String)value; + } + + + protected void validatePatchObject(String payload) { + if (hasComplexObject(payload)) { + throw new GraphInventoryPatchDepthExceededException(payload); + } + } + + /** validates client side that json does not include any complex objects + * relationship-list is omitted from this validation + */ + protected boolean hasComplexObject(String json) { + if (json.isEmpty()) { + return false; + } + String complex = "$.*.*"; + String array = "$.*.*.*"; + List result = JsonPathUtil.getInstance().getPathList(json, complex); + List result2 = JsonPathUtil.getInstance().getPathList(json, array); + + result.addAll(result2); + return result.stream().anyMatch(item -> LOCATE_COMPLEX_OBJECT.matcher(item).find()); + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java new file mode 100644 index 0000000000..b56a6779cc --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.List; +import java.util.Optional; + +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.Pnf; +import org.onap.aai.domain.yang.Pserver; +import org.onap.aai.domain.yang.Pservers; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; + +public interface AAIRestClientI { + + Pservers getPhysicalServers(String hostName, String uuid); + + List getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) throws UnsupportedEncodingException, JsonParseException, JsonMappingException, IOException; + + void updateMaintenceFlag(String vnfId,boolean inMaint, String transactionLoggingUuid) throws Exception; + + void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) throws Exception; + + GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws Exception; + + Optional getPnfByName(String pnfId, String transactionLoggingUuid) throws Exception; + + void createPnf(String pnfId, String transactionLoggingUuid, Pnf pnf) throws IOException; +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java new file mode 100644 index 0000000000..b471a1e53d --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java @@ -0,0 +1,197 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import javax.ws.rs.core.Response; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.GenericVnfs; +import org.onap.aai.domain.yang.Pnf; +import org.onap.aai.domain.yang.Pserver; +import org.onap.aai.domain.yang.Pservers; +import org.onap.so.client.aai.entities.CustomQuery; +import org.onap.so.client.aai.entities.Results; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.graphinventory.Format; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + + + +public class AAIRestClientImpl implements AAIRestClientI { + + private static Logger logger = LoggerFactory.getLogger(AAIClient.class); + private static final AAIVersion ENDPOINT_VERSION = AAIVersion.V10; + private static final String ENDPOINT_GET_ALL = ENDPOINT_VERSION + "/cloud-infrastructure/pservers"; + private static final String ENDPOINT_GET_ALL_VNFS = ENDPOINT_VERSION + "/network/generic-vnfs"; + private static final String ENDPOINT_CUSTOM_QUERY = ENDPOINT_VERSION + "/query"; + private static final String PSERVER_VNF_QUERY = "pservers-fromVnf"; + private static final String GENERIC_VNF_PATH = ENDPOINT_VERSION + "/network/generic-vnfs/generic-vnf"; + private static final String SERVICE_TOPOLOGY_BY_SERVICE_INSTANCE_ID = + "store(‘x’).union(__.in(‘subscribesTo’).has(‘aai-node-type’,’customer’).store(‘x’),__.out(‘uses’).has(‘aai-node-type’,’allotted-resource’).store(‘x’),__.in(‘hasInstance’).has(‘aai-node-type’,’generic-vnf’).store(‘x’).union(" + + ".out(‘has’).has(‘aai-node-type’,’vf-module’).store(‘x’),out(‘uses’).has(‘aai-node-type’,’volume-group’).store(‘x’)," + + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union(" + + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)," + + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)" + + ")," + ".out(‘runsOnVserver’).has(‘aai-node-type’,’vserver’).store(‘x’).union(" + + ".in(‘owns’).has(‘aai-node-type’,’tenant’).store(‘x’).in(‘has’).has(‘aai-node-type’,’cloud-region’).store(‘x’)," + + ".out(‘runsOnPserver’).has(‘aai-node-type’,’pserver’).store(‘x’)," + + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union(" + + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)," + + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)" + + ")" + ")" + ")" + ").cap(‘x’).unfold().dedup()"; + + public AAIRestClientImpl() { + } + + @Override + public Pservers getPhysicalServers(String hostName, String uuid) { + UUID requestId; + try { + requestId = UUID.fromString(uuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + uuid + " creating valid uuid automatically"); + requestId = UUID.randomUUID(); + } + return new AAIResourcesClient(ENDPOINT_VERSION) + .get(Pservers.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.PSERVER)).orElse(null); + } + + @Override + public List getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) throws IOException { + UUID requestId; + try { + requestId = UUID.fromString(transactionLoggingUuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); + requestId = UUID.randomUUID(); + } + List startNodes = new ArrayList<>(); + startNodes.add(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); + String jsonInput = new AAIQueryClient(ENDPOINT_VERSION) + .query(Format.RESOURCE, new CustomQuery(startNodes, PSERVER_VNF_QUERY)); + + return this.getListOfPservers(jsonInput); + + } + + protected List getListOfPservers(String jsonInput) throws IOException { + ObjectMapper mapper = new AAICommonObjectMapperProvider().getMapper(); + Results> resultsFromJson = mapper.readValue(jsonInput, + new TypeReference>>() { + }); + List results = new ArrayList<>(); + for (Map m : resultsFromJson.getResult()) { + results.add(m.get("pserver")); + } + return results; + } + + @Override + public void updateMaintenceFlag(String vnfName, boolean inMaint, String transactionLoggingUuid) throws IOException { + UUID requestId; + try { + requestId = UUID.fromString(transactionLoggingUuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); + requestId = UUID.randomUUID(); + } + GenericVnfs genericVnfs = new AAIResourcesClient(ENDPOINT_VERSION).get(GenericVnfs.class, + AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName)).orElse(null); + if (genericVnfs.getGenericVnf().size() > 1) { + throw new IndexOutOfBoundsException("Multiple Generic Vnfs Returned"); + } + + GenericVnf genericVnf = genericVnfs.getGenericVnf().get(0); + updateMaintenceFlagVnfId(genericVnf.getVnfId(), inMaint, transactionLoggingUuid); + } + + @Override + public void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) + throws IOException { + UUID requestId; + try { + requestId = UUID.fromString(transactionLoggingUuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); + requestId = UUID.randomUUID(); + } + GenericVnf genericVnf = new GenericVnf(); + genericVnf.setInMaint(inMaint); + new AAIResourcesClient(ENDPOINT_VERSION) + .update(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId), genericVnf); + + } + + @Override + public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws IOException { + UUID requestId; + try { + requestId = UUID.fromString(transactionLoggingUuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); + requestId = UUID.randomUUID(); + } + return new AAIResourcesClient(ENDPOINT_VERSION) + .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)).orElse(null); + } + + @Override + public Optional getPnfByName(String pnfId, String transactionLoggingUuid) throws IOException { + UUID requestId; + try { + requestId = UUID.fromString(transactionLoggingUuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically", e); + requestId = UUID.randomUUID(); + } + Response response = new AAIResourcesClient(ENDPOINT_VERSION) + .getFullResponse(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId)); + if (response.getStatus() != 200) { + return Optional.empty(); + } else { + return Optional.of(response.readEntity(Pnf.class)); + } + } + + @Override + public void createPnf(String pnfId, String transactionLoggingUuid, Pnf pnf) throws IOException { + UUID requestId; + try { + requestId = UUID.fromString(transactionLoggingUuid); + } catch (IllegalArgumentException e) { + logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically", e); + requestId = UUID.randomUUID(); + } + new AAIResourcesClient(ENDPOINT_VERSION) + .createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), Optional.of(pnf)); + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAISubgraphType.java b/common/src/main/java/org/onap/so/client/aai/AAISubgraphType.java new file mode 100644 index 0000000000..e9beb143fd --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAISubgraphType.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + + +public enum AAISubgraphType { + STAR("star"), + PRUNE("prune"); + + private final String name; + + private AAISubgraphType(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java b/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java new file mode 100644 index 0000000000..884d2aaec6 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java @@ -0,0 +1,264 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; + +import javax.ws.rs.NotFoundException; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.Response; + +import org.onap.aai.domain.yang.Relationship; +import org.onap.so.client.RestClient; +import org.onap.so.client.aai.entities.AAIError; +import org.onap.so.client.aai.entities.bulkprocess.OperationBody; +import org.onap.so.client.aai.entities.bulkprocess.Transaction; +import org.onap.so.client.aai.entities.bulkprocess.Transactions; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.graphinventory.exceptions.BulkProcessFailed; +import org.onap.so.jsonpath.JsonPathUtil; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Joiner; + +public class AAITransactionalClient extends AAIClient { + + private final Transactions transactions; + private Transaction currentTransaction; + private final AAIVersion version; + private int actionCount = 0; + protected AAITransactionalClient(AAIVersion version) { + super(); + this.version = version; + this.transactions = new Transactions(); + startTransaction(); + } + + private void startTransaction() { + Transaction transaction = new Transaction(); + transactions.getTransactions().add(transaction); + currentTransaction = transaction; + } + + /** + * adds an additional transaction and closes the previous transaction + * + * @return AAITransactionalClient + */ + public AAITransactionalClient beginNewTransaction() { + startTransaction(); + return this; + } + + /** + * creates a new object in A&AI + * + * @param obj - can be any object which will marshal into a valid A&AI payload + * @param uri + * @return + */ + public AAITransactionalClient create(AAIResourceUri uri, Object obj) { + currentTransaction.getPut().add(new OperationBody().withUri(uri.build().toString()).withBody(obj)); + incrementActionAmount(); + return this; + } + + /** + * creates a new object in A&AI with no payload body + * + * @param uri + * @return + */ + public AAITransactionalClient createEmpty(AAIResourceUri uri) { + currentTransaction.getPut().add(new OperationBody().withUri(uri.build().toString()).withBody(new HashMap())); + incrementActionAmount(); + return this; + } + + /** + * Adds a relationship between two objects in A&AI + * @param uriA + * @param uriB + * @return + */ + public AAITransactionalClient connect(AAIResourceUri uriA, AAIResourceUri uriB) { + AAIResourceUri uriAClone = uriA.clone(); + currentTransaction.getPut().add(new OperationBody().withUri(uriAClone.relationshipAPI().build().toString()).withBody(this.buildRelationship(uriB))); + incrementActionAmount(); + return this; + } + + /** + * relationship between multiple objects in A&AI - connects A to all objects specified in list + * + * @param uriA + * @param uris + * @return + */ + public AAITransactionalClient connect(AAIResourceUri uriA, List uris) { + for (AAIResourceUri uri : uris) { + this.connect(uriA, uri); + } + return this; + } + + /** + * Removes relationship from two objects in A&AI + * + * @param uriA + * @param uriB + * @return + */ + public AAITransactionalClient disconnect(AAIResourceUri uriA, AAIResourceUri uriB) { + AAIResourceUri uriAClone = uriA.clone(); + currentTransaction.getDelete().add(new OperationBody().withUri(uriAClone.relationshipAPI().build().toString()).withBody(this.buildRelationship(uriB))); + incrementActionAmount(); + return this; + } + + /** + * Removes relationship from multiple objects - disconnects A from all objects specified in list + * @param uriA + * @param uris + * @return + */ + public AAITransactionalClient disconnect(AAIResourceUri uriA, List uris) { + for (AAIResourceUri uri : uris) { + this.disconnect(uriA, uri); + } + return this; + } + /** + * Deletes object from A&AI. Automatically handles resource-version. + * + * @param uri + * @return + */ + public AAITransactionalClient delete(AAIResourceUri uri) { + AAIResourcesClient client = new AAIResourcesClient(); + AAIResourceUri clone = uri.clone(); + Map result = client.get(new GenericType>(){}, clone) + .orElseThrow(() -> new NotFoundException(clone.build() + " does not exist in A&AI")); + String resourceVersion = (String) result.get("resource-version"); + currentTransaction.getDelete().add(new OperationBody().withUri(clone.resourceVersion(resourceVersion).build().toString()).withBody("")); + incrementActionAmount(); + return this; + } + + /** + * @param obj - can be any object which will marshal into a valid A&AI payload + * @param uri + * @return + */ + public AAITransactionalClient update(AAIResourceUri uri, Object obj) { + currentTransaction.getPatch().add(new OperationBody().withUri(uri.build().toString()).withBody(obj)); + incrementActionAmount(); + return this; + } + + private void incrementActionAmount() { + actionCount++; + } + /** + * Executes all created transactions in A&AI + * @throws BulkProcessFailed + */ + public void execute() throws BulkProcessFailed { + RestClient client = this.createClient(AAIUriFactory.createResourceUri(AAIObjectType.BULK_PROCESS)); + try { + Response response = client.put(this.transactions); + if (response.hasEntity()) { + final Optional errorMessage = this.locateErrorMessages(response.readEntity(String.class)); + if (errorMessage.isPresent()) { + throw new BulkProcessFailed("One or more transactions failed in A&AI. Check logs for payloads.\nMessages:\n" + errorMessage.get()); + } + } else { + throw new BulkProcessFailed("Transactions acccepted by A&AI, but there was no response. Unsure of result."); + } + } finally { + this.transactions.getTransactions().clear(); + this.currentTransaction = null; + this.actionCount = 0; + } + } + + protected Optional locateErrorMessages(String response) { + final List errorMessages = new ArrayList<>(); + final List results = JsonPathUtil.getInstance().locateResultList(response, "$..body"); + final ObjectMapper mapper = new ObjectMapper(); + if (!results.isEmpty()) { + List> parsed = new ArrayList<>(); + try { + for (String result : results) { + parsed.add(mapper.readValue(result, new TypeReference>(){})); + } + } catch (IOException e) { + logger.error("could not map json", e); + } + for (Map map : parsed) { + for (Entry entry : map.entrySet()) { + if (!entry.getKey().matches("2\\d\\d")) { + AAIError error; + try { + error = mapper.readValue(entry.getValue().toString(), AAIError.class); + } catch (IOException e) { + logger.error("could not parse error object from A&AI", e); + error = new AAIError(); + } + AAIErrorFormatter formatter = new AAIErrorFormatter(error); + String outputMessage = formatter.getMessage(); + logger.error("part of a bulk action failed in A&AI: " + entry.getValue()); + errorMessages.add(outputMessage); + } + } + } + } + + if (!errorMessages.isEmpty()) { + return Optional.of(Joiner.on("\n").join(errorMessages)); + } else { + return Optional.empty(); + } + } + private Relationship buildRelationship(AAIUri uri) { + final Relationship result = new Relationship(); + result.setRelatedLink(uri.build().toString()); + return result; + } + + @Override + protected AAIVersion getVersion() { + return this.version; + } + + protected Transactions getTransactions() { + return this.transactions; + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIUpdator.java b/common/src/main/java/org/onap/so/client/aai/AAIUpdator.java new file mode 100644 index 0000000000..8921e4bbbe --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIUpdator.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import java.io.IOException; + +public interface AAIUpdator { + + void updateVnfToLocked(String vnfName, String uuid) throws IOException, Exception; + + void updateVnfToUnLocked(String vnfName, String uuid) throws IOException, Exception; + +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIUpdatorImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIUpdatorImpl.java new file mode 100644 index 0000000000..a971fded0e --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIUpdatorImpl.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +public class AAIUpdatorImpl implements AAIUpdator { + + @Autowired + protected AAIRestClientI client; + + public AAIRestClientI getClient() { + return client; + } + + + public void setClient(AAIRestClientI client) { + this.client = client; + } + + @Override + public void updateVnfToLocked(String vnfId, String uuid) throws Exception { + client.updateMaintenceFlagVnfId(vnfId, true, uuid); + } + + @Override + public void updateVnfToUnLocked(String vnfId, String uuid) throws Exception { + client.updateMaintenceFlagVnfId(vnfId, false, uuid); + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIValidator.java b/common/src/main/java/org/onap/so/client/aai/AAIValidator.java new file mode 100644 index 0000000000..bf6485a631 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIValidator.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import java.io.IOException; + +public interface AAIValidator { + + boolean isPhysicalServerLocked(String hostName, String transactionLoggingUuid) throws IOException; + + boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws IOException, Exception; + + +} \ No newline at end of file diff --git a/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java new file mode 100644 index 0000000000..fb6d122630 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import java.io.IOException; +import java.util.List; + +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.Pserver; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + + + +public class AAIValidatorImpl implements AAIValidator { + + + @Autowired + protected AAIRestClientI client; + + public AAIRestClientI getClient() { + return client; + } + + + public void setClient(AAIRestClientI client) { + this.client = client; + } + + @Override + public boolean isPhysicalServerLocked(String vnfId, String transactionLoggingUuid) throws IOException { + List pservers; + boolean isLocked = false; + pservers = client.getPhysicalServerByVnfId(vnfId, transactionLoggingUuid); + for (Pserver pserver : pservers) + if (pserver.isInMaint()) + isLocked = true; + + return isLocked; + } + + @Override + public boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws Exception { + boolean isLocked = false; + GenericVnf genericVnf = client.getVnfByName(vnfId, transactionLoggingUuid); + if (genericVnf.isInMaint()) + isLocked = true; + + return isLocked; + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/AAIVersion.java b/common/src/main/java/org/onap/so/client/aai/AAIVersion.java new file mode 100644 index 0000000000..20ee5becca --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIVersion.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import org.onap.so.client.graphinventory.GraphInventoryVersion; + +public enum AAIVersion implements GraphInventoryVersion { + V8("v8"), + V9("v9"), + V10("v10"), + V11("v11"), + V12("v12"), + V13("v13"); + + public final static AAIVersion LATEST = AAIVersion.values()[AAIVersion.values().length - 1]; + private final String value; + private AAIVersion(String value){ + this.value = value; + } + @Override + public String toString(){ + return this.value; + } +} + + diff --git a/common/src/main/java/org/onap/so/client/aai/EmptyStringToNullSerializer.java b/common/src/main/java/org/onap/so/client/aai/EmptyStringToNullSerializer.java new file mode 100644 index 0000000000..1120ebe0b9 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/EmptyStringToNullSerializer.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.aai; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +public class EmptyStringToNullSerializer extends StdSerializer { + + private static final long serialVersionUID = 5367385969270400106L; + + public EmptyStringToNullSerializer() { + this(null); + } + public EmptyStringToNullSerializer(Class t) { + super(t); + } + + @Override + public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) + throws IOException, JsonProcessingException { + + if("".equals(value)) { + gen.writeNull(); + } else { + gen.writeString(value); + } + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIEntity.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIEntity.java new file mode 100644 index 0000000000..c2aceeeeba --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIEntity.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities; + +public class AAIEntity{ + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIEntityObject.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIEntityObject.java new file mode 100644 index 0000000000..dc91c8a034 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIEntityObject.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities; + +import org.onap.so.client.aai.entities.uri.AAIResourceUri; + +public interface AAIEntityObject { + + public AAIResourceUri getUri(); + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIError.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIError.java new file mode 100644 index 0000000000..4261f4f3c0 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIError.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "requestError" +}) +public class AAIError { + + @JsonProperty("requestError") + private RequestError requestError; + + @JsonProperty("requestError") + public RequestError getRequestError() { + return requestError; + } + + @JsonProperty("requestError") + public void setRequestError(RequestError requestError) { + this.requestError = requestError; + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java new file mode 100644 index 0000000000..9087995f97 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities; + +import java.io.IOException; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.onap.so.client.aai.AAICommonObjectMapperProvider; +import org.onap.so.jsonpath.JsonPathUtil; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class AAIResultWrapper implements Serializable { + + private static final long serialVersionUID = 5895841925807816737L; + private final Optional jsonBody; + private final ObjectMapper mapper; + public AAIResultWrapper(String json) { + this.jsonBody = Optional.ofNullable(json); + this.mapper = new AAICommonObjectMapperProvider().getMapper(); + } + + public Optional getRelationships() { + final String path = "$.relationship-list"; + if (!jsonBody.isPresent()) { + return Optional.empty(); + } + Optional result = JsonPathUtil.getInstance().locateResult(jsonBody.get(), path); + if (result.isPresent()) { + return Optional.of(new Relationships(result.get())); + } else { + return Optional.empty(); + } + } + + public String getJson() { + return jsonBody.orElse("{}"); + } + + public Map asMap() { + if (!this.jsonBody.isPresent()) { + return new HashMap<>(); + } + try { + return mapper.readValue(this.jsonBody.get(), new TypeReference>(){}); + } catch (IOException e) { + return new HashMap<>(); + } + } + + public Optional asBean(Class clazz) { + if (!this.jsonBody.isPresent()) { + return Optional.empty(); + } + try { + return Optional.of(mapper.readValue(this.jsonBody.get(), clazz)); + } catch (IOException e) { + return Optional.empty(); + } + } + + public boolean isEmpty() { + return !this.jsonBody.isPresent(); + } + @Override + public String toString() { + return this.getJson(); + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/Configuration.java b/common/src/main/java/org/onap/so/client/aai/entities/Configuration.java new file mode 100644 index 0000000000..e1ce3a8adc --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/Configuration.java @@ -0,0 +1,161 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "configuration-id", + "configuration-type", + "configuration-sub-type", + "model-invariant-id", + "model-version-id", + "orchestration-status", + "operational-status", + "configuration-selflink", + "model-customization-id" +}) +public class Configuration { + + @JsonProperty("configuration-id") + private String configurationId; + @JsonProperty("configuration-name") + private String configurationName; + @JsonProperty("configuration-type") + private String configurationType; + @JsonProperty("configuration-sub-type") + private String configurationSubType; + @JsonProperty("model-invariant-id") + private String modelInvariantId; + @JsonProperty("model-version-id") + private String modelVersionId; + @JsonProperty("orchestration-status") + private String orchestrationStatus; + @JsonProperty("operational-status") + private String operationalStatus; + @JsonProperty("configuration-selflink") + private String configurationSelflink; + @JsonProperty("model-customization-id") + private String modelCustomizationId; + + @JsonProperty("configuration-id") + public String getConfigurationId() { + return configurationId; + } + + @JsonProperty("configuration-id") + public void setConfigurationId(String configurationId) { + this.configurationId = configurationId; + } + + @JsonProperty("configuration-name") + public String getConfigurationName() { + return configurationName; + } + + @JsonProperty("configuration-name") + public void setConfigurationName(String configurationName) { + this.configurationName = configurationName; + } + + @JsonProperty("configuration-type") + public String getConfigurationType() { + return configurationType; + } + + @JsonProperty("configuration-type") + public void setConfigurationType(String configurationType) { + this.configurationType = configurationType; + } + + @JsonProperty("configuration-sub-type") + public String getConfigurationSubType() { + return configurationSubType; + } + + @JsonProperty("configuration-sub-type") + public void setConfigurationSubType(String configurationSubType) { + this.configurationSubType = configurationSubType; + } + + @JsonProperty("model-invariant-id") + public String getModelInvariantId() { + return modelInvariantId; + } + + @JsonProperty("model-invariant-id") + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + @JsonProperty("model-version-id") + public String getModelVersionId() { + return modelVersionId; + } + + @JsonProperty("model-version-id") + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + @JsonProperty("orchestration-status") + public String getOrchestrationStatus() { + return orchestrationStatus; + } + + @JsonProperty("orchestration-status") + public void setOrchestrationStatus(String orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + + @JsonProperty("operational-status") + public String getOperationalStatus() { + return operationalStatus; + } + + @JsonProperty("operational-status") + public void setOperationalStatus(String operationalStatus) { + this.operationalStatus = operationalStatus; + } + + @JsonProperty("model-customization-id") + public String getModelCustomizationId() { + return modelCustomizationId; + } + + @JsonProperty("model-customization-id") + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationId = modelCustomizationId; + } + + @JsonProperty("configuration-selflink") + public String getConfigurationSelflink() { + return configurationSelflink; + } + + @JsonProperty("configuration-selflink") + public void setConfigurationSelflink(String configurationSelflink) { + this.configurationSelflink = configurationSelflink; + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/CustomQuery.java b/common/src/main/java/org/onap/so/client/aai/entities/CustomQuery.java new file mode 100644 index 0000000000..8203476c82 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/CustomQuery.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities; + +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; + +import org.onap.so.client.aai.entities.uri.AAIResourceUri; + +import com.fasterxml.jackson.annotation.JsonInclude; + + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class CustomQuery { + + private List start; + private String query; + private String gremlin; + + public String getGremlin() { + return gremlin; + } + + public void setGremlin(String gremlin) { + this.gremlin = gremlin; + } + + + public CustomQuery(List start){ + this.setStart(start); + } + + public CustomQuery(List start, String query){ + this.setStart(start); + this.query= "query/" + query; + } + + public CustomQuery(String gremlin) throws UnsupportedEncodingException{ + this.gremlin=gremlin; + } + + public List getStart() { + return start; + } + + public void setStart(List start) { + this.start = this.mapUris(start); + } + + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + private List mapUris(List uris) { + final List result = new ArrayList<>(); + uris.stream().map(item -> item.build().toString()).forEach(result::add); + return result; + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java b/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java new file mode 100644 index 0000000000..bab145b3fd --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java @@ -0,0 +1,140 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Predicate; + +import javax.ws.rs.core.UriBuilder; + +import org.onap.so.client.aai.AAICommonObjectMapperProvider; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.graphinventory.GraphInventoryObjectName; +import org.onap.so.jsonpath.JsonPathUtil; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.CaseFormat; + +public class Relationships { + + private final ObjectMapper mapper; + private Map map; + private final String jsonBody; + public Relationships(String json) { + this.jsonBody = json; + this.mapper = new AAICommonObjectMapperProvider().getMapper(); + try { + this.map = mapper.readValue(json, new TypeReference>() {}); + } catch (IOException e) { + this.map = new HashMap<>(); + } + } + + public List getByType(GraphInventoryObjectName type) { + + return this.getAll(Optional.of(type)); + } + + public List getAll() { + + return this.getAll(Optional.empty()); + } + + + public List getRelatedLinks() { + return this.getRelatedLinks(Optional.empty()); + } + + public List getRelatedLinks(GraphInventoryObjectName type) { + return this.getRelatedLinks(Optional.of(type)); + } + + public List getRelatedAAIUris() { + return this.getRelatedAAIUris(x -> true); + } + + public List getRelatedAAIUris(GraphInventoryObjectName type) { + return this.getRelatedAAIUris(x -> type.typeName().equals(x)); + } + protected List getRelatedAAIUris(Predicate p) { + List result = new ArrayList<>(); + if (map.containsKey("relationship")) { + List> relationships = (List>)map.get("relationship"); + for (Map relationship : relationships) { + final String relatedTo = (String)relationship.get("related-to"); + if (p.test(relatedTo)) { + AAIObjectType type; + try { + type = AAIObjectType.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, relatedTo)); + } catch (IllegalArgumentException e) { + type = AAIObjectType.UNKNOWN; + } + final String relatedLink = (String)relationship.get("related-link"); + + result.add(AAIUriFactory.createResourceFromExistingURI(type, UriBuilder.fromPath(relatedLink).build())); + } + } + } + return result; + } + + + + protected List getAll(final Optional type) { + List relatedLinks; + if (type.isPresent()) { + relatedLinks = this.getRelatedAAIUris(type.get()); + } else { + relatedLinks = this.getRelatedAAIUris(); + } + ArrayList result = new ArrayList<>(); + for (AAIResourceUri link : relatedLinks) { + result.add(this.get(link)); + } + return result; + } + + protected AAIResultWrapper get(AAIResourceUri uri) { + return new AAIResourcesClient().get(uri); + + } + + protected List getRelatedLinks(Optional type) { + String matcher = ""; + if (type.isPresent()) { + matcher = "[?(@.related-to=='" + type.get() + "')]"; + } + return JsonPathUtil.getInstance().locateResultList(this.jsonBody, String.format("$.relationship%s.related-link", matcher)); + } + + public String getJson() { + return this.jsonBody; + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/RequestError.java b/common/src/main/java/org/onap/so/client/aai/entities/RequestError.java new file mode 100644 index 0000000000..bc8c283e34 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/RequestError.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "serviceException" +}) +public class RequestError { + + @JsonProperty("serviceException") + private ServiceException serviceException; + + @JsonProperty("serviceException") + public ServiceException getServiceException() { + return serviceException; + } + + @JsonProperty("serviceException") + public void setServiceException(ServiceException serviceException) { + this.serviceException = serviceException; + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/Results.java b/common/src/main/java/org/onap/so/client/aai/entities/Results.java new file mode 100644 index 0000000000..c3f0ad1fa1 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/Results.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"results" +}) +public class Results { + @JsonProperty("results") + protected List results; + + @JsonProperty("results") + public List getResult() { + if (results == null) { + results = new ArrayList<>(); + } + return this.results; + } + @JsonProperty("results") + public void setResult(List results) { + this.results=results; + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/ServiceException.java b/common/src/main/java/org/onap/so/client/aai/entities/ServiceException.java new file mode 100644 index 0000000000..9d9723c514 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/ServiceException.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "messageId", + "text", + "variables" +}) +public class ServiceException { + + @JsonProperty("messageId") + private String messageId; + @JsonProperty("text") + private String text; + @JsonProperty("variables") + private List variables = new ArrayList<>(); + + @JsonProperty("messageId") + public String getMessageId() { + return messageId; + } + + @JsonProperty("messageId") + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + @JsonProperty("text") + public String getText() { + return text; + } + + @JsonProperty("text") + public void setText(String text) { + this.text = text; + } + + @JsonProperty("variables") + public List getVariables() { + return variables; + } + + @JsonProperty("variables") + public void setVariables(List variables) { + this.variables = variables; + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/OperationBody.java b/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/OperationBody.java new file mode 100644 index 0000000000..1803440edd --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/OperationBody.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities.bulkprocess; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"uri", +"body" +}) +public class OperationBody { + +@JsonProperty("uri") +private String uri; +@JsonProperty("body") +private Object body; + +@JsonProperty("uri") +public String getUri() { +return uri; +} + +@JsonProperty("uri") +public void setUri(String uri) { +this.uri = uri; +} + +public OperationBody withUri(String uri) { +this.uri = uri; +return this; +} + +@JsonProperty("body") +public Object getBody() { +return body; +} + +@JsonProperty("body") +public void setBody(Object body) { +this.body = body; +} + +public OperationBody withBody(Object body) { +this.body = body; +return this; +} + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transaction.java b/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transaction.java new file mode 100644 index 0000000000..1c405753c3 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transaction.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities.bulkprocess; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"patch", +"patch", +"delete" +}) +public class Transaction { + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonProperty("put") +private List put = new ArrayList<>(); + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonProperty("patch") +private List patch = new ArrayList<>(); + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonProperty("delete") +private List delete = new ArrayList<>(); + +@JsonProperty("put") +public List getPut() { +return put; +} + +@JsonProperty("put") +public void setPut(List put) { +this.put = put; +} + +public Transaction withPut(List put) { +this.put = put; +return this; +} + +@JsonProperty("patch") +public List getPatch() { +return patch; +} + +@JsonProperty("patch") +public void setPatch(List patch) { +this.patch = patch; +} + +public Transaction withPatch(List patch) { +this.patch = patch; +return this; +} + +@JsonProperty("delete") +public List getDelete() { +return delete; +} + +@JsonProperty("delete") +public void setDelete(List delete) { +this.delete = delete; +} + +public Transaction withDelete(List delete) { +this.delete = delete; +return this; +} + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transactions.java b/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transactions.java new file mode 100644 index 0000000000..51d56d371a --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/bulkprocess/Transactions.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities.bulkprocess; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"transactions" +}) +public class Transactions { + +@JsonProperty("transactions") +private List transactions = new ArrayList<>(); + +@JsonProperty("transactions") +public List getTransactions() { +return transactions; +} + +@JsonProperty("transactions") +public void setTransactions(List transactions) { +this.transactions = transactions; +} + +public Transactions withTransactions(List transactions) { +this.transactions = transactions; +return this; +} + +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIResourceUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIResourceUri.java new file mode 100644 index 0000000000..42fa1ad02a --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIResourceUri.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities.uri; + +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.graphinventory.Format; +import org.onap.so.client.graphinventory.entities.uri.Depth; +import org.onap.so.client.graphinventory.entities.uri.GraphInventoryResourceUri; + +public interface AAIResourceUri extends AAIUri, GraphInventoryResourceUri { + + public AAIResourceUri relationshipAPI(); + public AAIResourceUri relatedTo(AAIObjectPlurals plural); + public AAIResourceUri relatedTo(AAIObjectType type, String... values); + public AAIResourceUri resourceVersion(String version); + public AAIResourceUri format(Format format); + @Override + public AAIResourceUri depth(Depth depth); + @Override + public AAIResourceUri nodesOnly(boolean nodesOnly); + @Override + public AAIResourceUri queryParam(String name, String... values); + @Override + public AAIResourceUri replaceQueryParam(String name, String... values); + @Override + public AAIResourceUri clone(); +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java new file mode 100644 index 0000000000..14671b2f85 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.aai.entities.uri; + +import java.net.URI; + +import javax.ws.rs.core.UriBuilder; + +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.graphinventory.Format; +import org.onap.so.client.graphinventory.entities.uri.Depth; +import org.onap.so.client.graphinventory.entities.uri.SimpleUri; + +public class AAISimpleUri extends SimpleUri implements AAIResourceUri { + + protected AAISimpleUri(AAIObjectType type, Object... values) { + super(type, values); + + } + protected AAISimpleUri(AAIObjectType type, URI uri) { + super(type, uri); + } + protected AAISimpleUri(AAIObjectType type, UriBuilder builder, Object... values) { + super(type, builder, values); + } + protected AAISimpleUri(AAIObjectPlurals type, UriBuilder builder, Object... values) { + super(type, builder, values); + } + protected AAISimpleUri(AAIObjectPlurals type) { + super(type); + } + protected AAISimpleUri(AAIObjectPlurals type, Object... values) { + super(type, values); + } + + @Override + public AAISimpleUri relationshipAPI() { + return (AAISimpleUri) super.relationshipAPI(); + } + + @Override + public AAISimpleUri relatedTo(AAIObjectPlurals plural) { + return (AAISimpleUri) super.relatedTo(plural); + } + @Override + public AAISimpleUri relatedTo(AAIObjectType type, String... values) { + return (AAISimpleUri) super.relatedTo(type, values); + } + + @Override + public AAISimpleUri resourceVersion(String version) { + return (AAISimpleUri) super.resourceVersion(version); + } + + @Override + public AAISimpleUri queryParam(String name, String... values) { + return (AAISimpleUri) super.queryParam(name, values); + } + + @Override + public AAISimpleUri replaceQueryParam(String name, String... values) { + return (AAISimpleUri) super.replaceQueryParam(name, values); + } + + @Override + public AAISimpleUri clone() { + if (this.type != null) { + return new AAISimpleUri((AAIObjectType)this.type, this.internalURI.clone(), values); + } else { + return new AAISimpleUri((AAIObjectPlurals)this.pluralType, this.internalURI.clone(), values); + } + } + + @Override + public AAIObjectType getObjectType() { + return (AAIObjectType)this.type; + } + + @Override + public AAISimpleUri depth(Depth depth) { + return (AAISimpleUri) super.depth(depth); + } + @Override + public AAISimpleUri nodesOnly(boolean nodesOnly) { + return (AAISimpleUri)super.nodesOnly(nodesOnly); + } + + @Override + public AAISimpleUri format(Format format) { + return (AAISimpleUri)super.format(format); + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUri.java new file mode 100644 index 0000000000..eb336d9219 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUri.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities.uri; + +import java.net.URI; +import java.util.Map; + +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.graphinventory.GraphInventoryObjectType; +import org.onap.so.client.graphinventory.entities.uri.Depth; +import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri; + +public interface AAIUri extends GraphInventoryUri { + + /** + * By default A&AI enforces a depth of 1. Some objects can be told to retrieve objects + * nested beneath them by increasing this number. + * + * You can use 0 to restrict the returned information to only the object you requested + * You can use all to retrieve all nested objects (this should only be used if you really need a massive amount of information and are caching the retrieval) + * @param depth + * @return + */ + @Override + public AAIUri depth(Depth depth); + /** + * Makes client only return object fields, no relationships + * + * @return + */ + @Override + public AAIUri nodesOnly(boolean nodesOnly); + @Override + public AAIUri queryParam(String name, String... values); + @Override + public AAIUri replaceQueryParam(String name, String... values); + @Override + public AAIUri clone(); + + @Override + public AAIObjectType getObjectType(); +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java new file mode 100644 index 0000000000..2a7c8ee78c --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAIUriFactory.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities.uri; + +import java.net.URI; + +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.graphinventory.entities.uri.SimpleUri; + + +public class AAIUriFactory { + + /** + * values are filled into the URI template specified in {@link AAIObjectType} in order + * + * @param type + * @param values + * @return + */ + public static AAIResourceUri createResourceUri(AAIObjectType type, Object... values) { + if (AAIObjectType.SERVICE_INSTANCE.equals(type)) { + return new ServiceInstanceUri(values); + } else { + return new AAISimpleUri(type, values); + } + } + + public static AAIResourceUri createNodesUri(AAIObjectType type, Object... values) { + return new NodesUri(type, values); + + } + + /** + * This method should only be used to wrap a URI retrieved from A&AI contained within an object response + * + * @param type + * @param uri + * @return + */ + public static AAIResourceUri createResourceFromExistingURI(AAIObjectType type, URI uri) { + return new AAISimpleUri(type, uri); + } + + /** + * Creates a uri for a plural type e.g. /cloud-infrastructure/pservers + * + * @param type + * @return + */ + public static AAIResourceUri createResourceUri(AAIObjectPlurals type) { + + return new AAISimpleUri(type); + + } + + /** + * Creates a uri for a plural type with values e.g. /cloud-infrastructure/pservers + * + * @param type + * @return + */ + public static AAIResourceUri createResourceUri(AAIObjectPlurals type, Object... values) { + + return new AAISimpleUri(type, values); + + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java new file mode 100644 index 0000000000..ccae0b44b7 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/NodesUri.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities.uri; + +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; +import org.onap.so.client.graphinventory.GraphInventoryObjectType; + +public class NodesUri extends AAISimpleUri { + + protected NodesUri(AAIObjectType type, Object... values) { + super(type, values); + } + + + @Override + protected String getTemplate(GraphInventoryObjectType type) { + return "/nodes" + type.partialUri(); + } + + @Override + protected String getTemplate(GraphInventoryObjectPlurals type) { + return "/nodes" + type.partialUri(); + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUri.java new file mode 100644 index 0000000000..093918d49b --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUri.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities.uri; + +import java.io.IOException; +import java.net.URI; +import java.util.Collections; +import java.util.Map; +import java.util.Optional; + +import javax.ws.rs.BadRequestException; +import javax.ws.rs.core.UriBuilder; + +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIQueryClient; +import org.onap.so.client.graphinventory.Format; +import org.onap.so.client.aai.entities.CustomQuery; +import org.onap.so.client.aai.entities.Results; +import org.onap.so.client.graphinventory.entities.uri.SimpleUri; +import org.onap.so.client.graphinventory.exceptions.GraphInventoryPayloadException; +import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException; +import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriNotFoundException; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class ServiceInstanceUri extends AAISimpleUri { + + private Optional cachedValue = Optional.empty(); + + protected ServiceInstanceUri(Object... values) { + super(AAIObjectType.SERVICE_INSTANCE, values); + } + protected ServiceInstanceUri(UriBuilder builder, Optional cachedValue, Object... values) { + super(AAIObjectType.SERVICE_INSTANCE, builder, values); + this.cachedValue = cachedValue; + } + protected String getSerivceInstance(Object id) throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException { + if (!this.getCachedValue().isPresent()) { + AAIResourceUri serviceInstanceUri = AAIUriFactory.createNodesUri(AAIObjectType.SERVICE_INSTANCE, id); + CustomQuery query = new CustomQuery(Collections.singletonList(serviceInstanceUri)); + String resultJson; + try { + resultJson = this.getQueryClient().query(Format.PATHED, query); + } catch (BadRequestException e) { + throw new GraphInventoryUriNotFoundException("Service instance " + id + " not found at: " + serviceInstanceUri.build()); + + } + try { + cachedValue = extractRelatedLink(resultJson); + if (!cachedValue.isPresent()) { + throw new GraphInventoryUriNotFoundException("Service instance " + id + " not found at: " + serviceInstanceUri.build()); + } + } catch (IOException e) { + throw new GraphInventoryPayloadException("could not map payload: " + resultJson, e); + } + } + Optional cachedValueOpt = this.getCachedValue(); + return cachedValueOpt.isPresent() ? cachedValueOpt.get() : ""; + } + + protected Optional extractRelatedLink(String jsonString) throws IOException { + Optional result; + ObjectMapper mapper = new ObjectMapper(); + + Results> results = mapper.readValue(jsonString, new TypeReference>>(){}); + if (results.getResult().size() == 1) { + String uriString = results.getResult().get(0).get("resource-link"); + URI uri = UriBuilder.fromUri(uriString).build(); + String rawPath = uri.getRawPath(); + result = Optional.of(rawPath.replaceAll("/aai/v\\d+", "")); + } else if (results.getResult().isEmpty()) { + result = Optional.empty(); + } else { + throw new IllegalStateException("more than one result returned"); + } + + return result; + } + + protected Optional getCachedValue() { + return this.cachedValue; + } + + @Override + public URI build() { + try { + if (this.values.length == 1) { + String uri = getSerivceInstance(this.values[0]); + Map map = getURIKeys(uri); + return super.build(map.values().toArray(values)); + } + } catch (GraphInventoryUriNotFoundException | GraphInventoryPayloadException e) { + throw new GraphInventoryUriComputationException(e); + } + return super.build(); + } + + @Override + public ServiceInstanceUri clone() { + return new ServiceInstanceUri(this.internalURI.clone(), this.getCachedValue(), values); + } + + protected AAIQueryClient getQueryClient() { + AAIResourceUri uri = AAIUriFactory.createNodesUri(AAIObjectType.ALLOTTED_RESOURCE, "").clone(); + return new AAIQueryClient(); + } +} diff --git a/common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java b/common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java new file mode 100644 index 0000000000..02d8d56867 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java @@ -0,0 +1,159 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.objects; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"operational-environment-id", +"operational-environment-name", +"operational-environment-type", +"operational-environment-status", +"tenant-context", +"workload-context", +"resource-version" +}) +public class AAIOperationalEnvironment { + +@JsonProperty("operational-environment-id") +private String operationalEnvironmentId; +@JsonProperty("operational-environment-name") +private String operationalEnvironmentName; +@JsonProperty("operational-environment-type") +private String operationalEnvironmentType; +@JsonProperty("operational-environment-status") +private String operationalEnvironmentStatus; +@JsonProperty("tenant-context") +private String tenantContext; +@JsonProperty("workload-context") +private String workloadContext; +@JsonProperty("resource-version") +private String resourceVersion; + +@JsonProperty("operational-environment-id") +public String getOperationalEnvironmentId() { +return operationalEnvironmentId; + } + +@JsonProperty("operational-environment-id") +public void setOperationalEnvironmentId(String operationalEnvironmentId) { +this.operationalEnvironmentId = operationalEnvironmentId; + } + +public AAIOperationalEnvironment withOperationalEnvironmentId(String operationalEnvironmentId) { +this.operationalEnvironmentId = operationalEnvironmentId; +return this; + } + +@JsonProperty("operational-environment-name") +public String getOperationalEnvironmentName() { +return operationalEnvironmentName; + } + +@JsonProperty("operational-environment-name") +public void setOperationalEnvironmentName(String operationalEnvironmentName) { +this.operationalEnvironmentName = operationalEnvironmentName; + } + +public AAIOperationalEnvironment withOperationalEnvironmentName(String operationalEnvironmentName) { +this.operationalEnvironmentName = operationalEnvironmentName; +return this; + } + +@JsonProperty("operational-environment-type") +public String getOperationalEnvironmentType() { +return operationalEnvironmentType; + } + +@JsonProperty("operational-environment-type") +public void setOperationalEnvironmentType(String operationalEnvironmentType) { +this.operationalEnvironmentType = operationalEnvironmentType; + } + +public AAIOperationalEnvironment withOperationalEnvironmentType(String operationalEnvironmentType) { +this.operationalEnvironmentType = operationalEnvironmentType; +return this; + } + +@JsonProperty("operational-environment-status") +public String getOperationalEnvironmentStatus() { +return operationalEnvironmentStatus; + } + +@JsonProperty("operational-environment-status") +public void setOperationalEnvironmentStatus(String operationalEnvironmentStatus) { +this.operationalEnvironmentStatus = operationalEnvironmentStatus; + } + +public AAIOperationalEnvironment withOperationalEnvironmentStatus(String operationalEnvironmentStatus) { +this.operationalEnvironmentStatus = operationalEnvironmentStatus; +return this; + } + +@JsonProperty("tenant-context") +public String getTenantContext() { +return tenantContext; + } + +@JsonProperty("tenant-context") +public void setTenantContext(String tenantContext) { +this.tenantContext = tenantContext; + } + +public AAIOperationalEnvironment withTenantContext(String tenantContext) { +this.tenantContext = tenantContext; +return this; + } + +@JsonProperty("workload-context") +public String getWorkloadContext() { +return workloadContext; + } + +@JsonProperty("workload-context") +public void setWorkloadContext(String workloadContext) { +this.workloadContext = workloadContext; + } + +public AAIOperationalEnvironment withWorkloadContext(String workloadContext) { +this.workloadContext = workloadContext; +return this; + } + +@JsonProperty("resource-version") +public String getResourceVersion() { +return resourceVersion; + } + +@JsonProperty("resource-version") +public void setResourceVersion(String resourceVersion) { +this.resourceVersion = resourceVersion; + } + +public AAIOperationalEnvironment withResourceVersion(String resourceVersion) { +this.resourceVersion = resourceVersion; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/aai/objects/AAIServiceInstance.java b/common/src/main/java/org/onap/so/client/aai/objects/AAIServiceInstance.java new file mode 100644 index 0000000000..af21949277 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/objects/AAIServiceInstance.java @@ -0,0 +1,141 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.objects; + +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.AAIEntityObject; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class AAIServiceInstance implements AAIEntityObject { + + @JsonProperty("service-instance-id") + private String serviceInstanceId; + @JsonProperty("service-instance-name") + private String serviceInstanceName; + @JsonProperty("service-type") + private String serviceType; + @JsonProperty("service-role") + private String serviceRole; + @JsonProperty("orchestration-status") + private String oStatus; + @JsonProperty("model-invariant-id") + private String modelInvariantUuid; + @JsonProperty("model-version-id") + private String modelUuid; + @JsonProperty("environment-context") + private String environmentContext; + @JsonProperty("workload-context") + private String workloadContext; + + public String getServiceInstanceName() { + return serviceInstanceName; + } + + public void setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + } + + 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 String getoStatus() { + return oStatus; + } + + public void setoStatus(String oStatus) { + this.oStatus = oStatus; + } + + public String getModelInvariantUuid() { + return modelInvariantUuid; + } + + public void setModelInvariantUuid(String modelInvariantUuid) { + this.modelInvariantUuid = modelInvariantUuid; + } + + public String getModelUuid() { + return modelUuid; + } + + public void setModelUuid(String modelUuid) { + this.modelUuid = modelUuid; + } + + public String getEnvironmentContext() { + return environmentContext; + } + + public void setEnvironmentContext(String environmentContext) { + this.environmentContext = environmentContext; + } + + public String getWorkloadContext() { + return workloadContext; + } + + public void setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + } + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public AAIServiceInstance withServiceInstance(String serviceInstanceId) { + this.setServiceInstanceId(serviceInstanceId); + return this; + } + + @Override + public AAIResourceUri getUri() { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, this.serviceInstanceId); + return uri; + } + @Override + public String toString() { + return "AAIServiceInstance [serviceInstanceId=" + serviceInstanceId + ", serviceInstanceName=" + + serviceInstanceName + ", serviceType=" + serviceType + ", serviceRole=" + serviceRole + ", oStatus=" + + oStatus + ", modelInvariantUuid=" + modelInvariantUuid + ", modelUuid=" + modelUuid + + ", environmentContext=" + environmentContext + ", workloadContext=" + workloadContext + "]"; + } + +} diff --git a/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java b/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java new file mode 100644 index 0000000000..2329a5acb9 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.adapter.rest; + +import java.net.URI; +import java.security.GeneralSecurityException; +import java.util.Map; +import java.util.Optional; + +import org.apache.commons.codec.binary.Base64; +import org.onap.so.client.RestClient; +import org.onap.so.client.policy.CommonObjectMapperProvider; +import org.onap.so.client.policy.JettisonStyleMapperProvider; +import org.onap.so.utils.CryptoUtils; +import org.onap.so.utils.TargetEntity; + +public class AdapterRestClient extends RestClient { + + private final AdapterRestProperties adapterRestProperties; + public AdapterRestClient(AdapterRestProperties props, URI uri) { + super(props, Optional.of(uri)); + this.adapterRestProperties = props; + } + + public AdapterRestClient(AdapterRestProperties props, URI uri, String accept, String contentType) { + super(props, Optional.of(uri), accept, contentType); + this.adapterRestProperties = props; + } + + @Override + public TargetEntity getTargetEntity(){ + return TargetEntity.OPENSTACK_ADAPTER; + } + + @Override + protected void initializeHeaderMap(Map headerMap) { + headerMap.put("Authorization", + this.getBasicAuth(adapterRestProperties.getAuth(), adapterRestProperties.getKey())); + } + + @Override + protected CommonObjectMapperProvider getCommonObjectMapperProvider() { + return new JettisonStyleMapperProvider(); + } + + private String getBasicAuth(String encryptedAuth, String msoKey) { + if ((encryptedAuth == null || encryptedAuth.isEmpty()) || (msoKey == null || msoKey.isEmpty())) { + return null; + } + try { + String auth = CryptoUtils.decrypt(encryptedAuth, msoKey); + byte[] encoded = Base64.encodeBase64(auth.getBytes()); + String encodedString = new String(encoded); + encodedString = "Basic " + encodedString; + return encodedString; + } catch (GeneralSecurityException e) { + this.msoLogger.debug(e.getMessage()); + return null; + } + } +} diff --git a/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestProperties.java b/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestProperties.java new file mode 100644 index 0000000000..18e0bd8996 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestProperties.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.adapter.rest; + +import org.onap.so.client.RestProperties; + +public interface AdapterRestProperties extends RestProperties { + + public String getAuth(); + public String getKey(); +} diff --git a/common/src/main/java/org/onap/so/client/defaultproperties/DefaultDmaapPropertiesImpl.java b/common/src/main/java/org/onap/so/client/defaultproperties/DefaultDmaapPropertiesImpl.java new file mode 100644 index 0000000000..ffebe77620 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/defaultproperties/DefaultDmaapPropertiesImpl.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.defaultproperties; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.onap.so.client.dmaap.DmaapProperties; + +public class DefaultDmaapPropertiesImpl implements DmaapProperties { + + private final Map properties; + public DefaultDmaapPropertiesImpl() throws IOException { + File initialFile = new File("src/test/resources/dmaap.properties"); + InputStream targetStream = new FileInputStream(initialFile); + Properties properties = new Properties(); + properties.load(targetStream); + this.properties = new HashMap<>(); + properties.forEach((key, value) -> this.properties.put((String)key, (String)value)); + } + @Override + public Map getProperties() { + return this.properties; + } + +} diff --git a/common/src/main/java/org/onap/so/client/defaultproperties/PolicyRestPropertiesImpl.java b/common/src/main/java/org/onap/so/client/defaultproperties/PolicyRestPropertiesImpl.java new file mode 100644 index 0000000000..9e4574df4c --- /dev/null +++ b/common/src/main/java/org/onap/so/client/defaultproperties/PolicyRestPropertiesImpl.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.defaultproperties; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.onap.so.client.policy.PolicyRestProperties; + +public class PolicyRestPropertiesImpl implements PolicyRestProperties { + + + final Map props; + public PolicyRestPropertiesImpl() { + File initialFile = new File("src/test/resources/policy.properties"); + Map temp; + try (InputStream targetStream = new FileInputStream(initialFile)) { + Properties properties = new Properties(); + properties.load(targetStream); + temp = properties; + } catch (IOException e) { + temp = new HashMap<>(); + } + this.props = temp; + + } + @Override + public URL getEndpoint() { + try { + return new URL((String)props.getOrDefault("policy.endpoint", "")); + } catch (MalformedURLException e) { + return null; + } + } + + @Override + public String getSystemName() { + return "MSO"; + } + + @Override + public String getClientAuth() { + return (String)props.get("policy.client.auth"); + } + + @Override + public String getAuth() { + return (String)props.get("policy.auth"); + } + + @Override + public String getEnvironment() { + return (String)props.get("policy.environment"); + } + +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/Consumer.java b/common/src/main/java/org/onap/so/client/dmaap/Consumer.java new file mode 100644 index 0000000000..7b1310f252 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/Consumer.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap; + +public interface Consumer { + + public Iterable fetch(); +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/DmaapClient.java b/common/src/main/java/org/onap/so/client/dmaap/DmaapClient.java new file mode 100644 index 0000000000..dde0b31c90 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/DmaapClient.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap; + +import java.io.IOException; +import java.util.Base64; +import java.util.Map; +import java.util.Optional; +import java.util.Properties; + +import org.onap.so.client.defaultproperties.DefaultDmaapPropertiesImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; + + +public abstract class DmaapClient { + + protected static Logger logger = LoggerFactory.getLogger(DmaapClient.class); + protected final Map msoProperties; + protected final Properties properties; + public DmaapClient(String filepath) throws IOException { + Resource resource = new ClassPathResource(filepath); + DmaapProperties dmaapProperties = DmaapPropertiesLoader.getInstance().getNewImpl(); + if (dmaapProperties == null) { + logger.error("No RestProperty implementation found on classpath, loading default"); + dmaapProperties = new DefaultDmaapPropertiesImpl(); + } + this.msoProperties = dmaapProperties.getProperties(); + this.properties = new Properties(); + this.properties.load(resource.getInputStream()); + this.properties.put("password", this.deobfuscatePassword(this.getPassword())); + this.properties.put("username", this.getUserName()); + this.properties.put("topic", this.getTopic()); + Optional host = this.getHost(); + if (host.isPresent()) { + this.properties.put("host", host.get()); + } + } + protected String deobfuscatePassword(String password) { + + try { + return new String(Base64.getDecoder().decode(password.getBytes())); + } catch(IllegalArgumentException iae) { + logger.error("llegal Arguments",iae); + return password; + } + } + + + public abstract String getUserName(); + public abstract String getPassword(); + public abstract String getTopic(); + public abstract Optional getHost(); +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/DmaapConsumer.java b/common/src/main/java/org/onap/so/client/dmaap/DmaapConsumer.java new file mode 100644 index 0000000000..c9acdd7e89 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/DmaapConsumer.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap; + +import com.google.common.base.Stopwatch; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import org.onap.so.client.dmaap.exceptions.DMaaPConsumerFailure; +import org.onap.so.client.dmaap.exceptions.ExceededMaximumPollingTime; +import org.onap.so.client.dmaap.rest.RestConsumer; + +public abstract class DmaapConsumer extends DmaapClient { + + public DmaapConsumer() throws IOException { + super("dmaap/default-consumer.properties"); + } + + public Consumer getConsumer() { + return new RestConsumer(this.properties); + } + + public boolean consume() throws Exception { + Consumer mrConsumer = this.getConsumer(); + boolean accepted = false; + Stopwatch stopwatch = Stopwatch.createUnstarted(); + try { + while (this.continuePolling()) { + if (stopwatch.elapsed(TimeUnit.MILLISECONDS) >= this.getMaximumElapsedTime()) { + final String message = "exceeded maximum retries on " + this.getRequestId() + " on " + this.getTopic(); + logger.error(message); + throw new ExceededMaximumPollingTime(message); + } + stopwatch.start(); + Iterable itr = mrConsumer.fetch(); + stopwatch.stop(); + for (String message : itr) { + if (!accepted && this.isAccepted(message)) { + logger.info("accepted message found for " + this.getRequestId() + " on " + this.getTopic()); + accepted = true; + } + if (accepted) { + logger.info("received dmaap message: " + message); + if (this.isFailure(message)) { + this.stopProcessingMessages(); + final String errorMsg = "failure received from dmaap topic " + this.getTopic(); + logger.error(errorMsg); + throw new DMaaPConsumerFailure(errorMsg); + } else { + this.processMessage(message); + } + } + } + } + return true; + } finally { + if (stopwatch.isRunning()) { + stopwatch.stop(); + } + } + } + + /** + * Should this consumer continue to consume messages from the topic? + * @return + */ + public abstract boolean continuePolling(); + /** + * Process a message from a DMaaP topic + * + * @param message + * @throws Exception + */ + public abstract void processMessage(String message) throws Exception; + /** + * Has the request been accepted by the receiving system? + * Should the consumer move to processing messages? + * + * @param message + * @return + */ + public abstract boolean isAccepted(String message); + /** + * has the request failed? + * + * @param message + * @return + */ + public abstract boolean isFailure(String message); + /** + * The request id to filter messages on + * @return + */ + public abstract String getRequestId(); + /** + * Logic that defines when the consumer should stop processing messages + */ + public abstract void stopProcessingMessages(); + + /** + * time in milliseconds + */ + public int getMaximumElapsedTime() { + return 180000; + } + + + +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/DmaapProperties.java b/common/src/main/java/org/onap/so/client/dmaap/DmaapProperties.java new file mode 100644 index 0000000000..161608dc77 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/DmaapProperties.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap; + +import java.util.Map; + +public interface DmaapProperties { + + /** + * A map of strings which contains the properties for a dmaap client + * @return + */ + public Map getProperties(); +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/DmaapPropertiesLoader.java b/common/src/main/java/org/onap/so/client/dmaap/DmaapPropertiesLoader.java new file mode 100644 index 0000000000..3064f6142f --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/DmaapPropertiesLoader.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap; + +import java.util.ServiceLoader; + +public class DmaapPropertiesLoader { + /* required to make ServiceLoader thread safe */ + private static final ThreadLocal> services = new ThreadLocal>() { + @Override + protected ServiceLoader initialValue() { + return ServiceLoader.load(DmaapProperties.class); + } + }; + + private DmaapPropertiesLoader() { + } + + private static class Helper { + private static final DmaapPropertiesLoader INSTANCE = new DmaapPropertiesLoader(); + } + + public static DmaapPropertiesLoader getInstance() { + return Helper.INSTANCE; + } + public DmaapProperties getImpl() { + return this.getImpl(false); + } + public DmaapProperties getNewImpl() { + return this.getImpl(true); + } + private DmaapProperties getImpl(boolean forceNewInstance) { + + ServiceLoader loader = this.services.get(); + for (DmaapProperties service : loader) { + if (forceNewInstance) { + try { + return service.getClass().newInstance(); + } catch (InstantiationException | IllegalAccessException e) { + /* all spi implementations must provide a public + * no argument constructor + */ + } + } else { + return service; + } + } + + return null; + } +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/DmaapPublisher.java b/common/src/main/java/org/onap/so/client/dmaap/DmaapPublisher.java new file mode 100644 index 0000000000..48691dcd84 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/DmaapPublisher.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.onap.so.client.dmaap.rest.RestPublisher; + +public abstract class DmaapPublisher extends DmaapClient { + + private long seconds; + private final Publisher publisher; + public DmaapPublisher() throws FileNotFoundException, IOException { + super("dmaap/default-consumer.properties"); + this.publisher = new RestPublisher(properties); + this.seconds = 20; + + } + + public DmaapPublisher(long seconds) throws FileNotFoundException, IOException { + this(); + this.seconds = seconds; + } + + public void send(String json){ + logger.info("publishing message to dmaap topic " + this.getTopic() + ": " + json); + publisher.send(json); + //publisher.close(seconds, TimeUnit.SECONDS); + } + + +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/Publisher.java b/common/src/main/java/org/onap/so/client/dmaap/Publisher.java new file mode 100644 index 0000000000..ba6ce16418 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/Publisher.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap; + +public interface Publisher { + + public void send(String json); +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/exceptions/DMaaPConsumerFailure.java b/common/src/main/java/org/onap/so/client/dmaap/exceptions/DMaaPConsumerFailure.java new file mode 100644 index 0000000000..f845f7e6ef --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/exceptions/DMaaPConsumerFailure.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap.exceptions; + +public class DMaaPConsumerFailure extends Exception { + + private static final long serialVersionUID = 2499229901897110362L; + + public DMaaPConsumerFailure() { + super(); + } + + public DMaaPConsumerFailure(String message) { + super(message); + } +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/exceptions/ExceededMaximumPollingTime.java b/common/src/main/java/org/onap/so/client/dmaap/exceptions/ExceededMaximumPollingTime.java new file mode 100644 index 0000000000..0002f878d8 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/exceptions/ExceededMaximumPollingTime.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap.exceptions; + +public class ExceededMaximumPollingTime extends RuntimeException { + + private static final long serialVersionUID = 2331207691092906423L; + + public ExceededMaximumPollingTime() { + super(); + } + + public ExceededMaximumPollingTime(String message) { + super(message); + } +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java b/common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java new file mode 100644 index 0000000000..0438ff237a --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap.rest; + +import java.net.URL; +import java.util.Base64; +import java.util.Map; + +import org.onap.so.client.RestClient; +import org.onap.so.utils.TargetEntity; + +public class DMaaPRestClient extends RestClient { + + private final String username; + private final String password; + public DMaaPRestClient(URL url, String contentType, String username, String password) { + super(url, contentType); + this.username = username; + this.password = password; + } + + @Override + public TargetEntity getTargetEntity(){ + return TargetEntity.DMAAP; + } + + @Override + protected void initializeHeaderMap(Map headerMap) { + headerMap.put("Authorization", "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes())); + } + +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/rest/PropertiesBean.java b/common/src/main/java/org/onap/so/client/dmaap/rest/PropertiesBean.java new file mode 100644 index 0000000000..f43c65808a --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/rest/PropertiesBean.java @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap.rest; + +import java.util.Properties; + +public class PropertiesBean { + + private String username; + private String password; + private String environment; + private String partition; + private String contentType; + private String host; + private String topic; + private String timeout; + + + public PropertiesBean(Properties properties) { + this.withUsername(properties.getProperty("username")) + .withPassword(properties.getProperty("password")) + .withTopic(properties.getProperty("topic")) + .withEnvironment(properties.getProperty("environment")) + .withHost(properties.getProperty("host")) + .withTimeout(properties.getProperty("timeout", "20000")) + .withPartition(properties.getProperty("partition")) + .withContentType(properties.getProperty("contentType", "application/json")); + } + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + public PropertiesBean withUsername(String username) { + this.username = username; + return this; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + public PropertiesBean withPassword(String password) { + this.password = password; + return this; + } + public String getEnvironment() { + return environment; + } + public void setEnvironment(String environment) { + this.environment = environment; + } + public PropertiesBean withEnvironment(String environment) { + this.environment = environment; + return this; + } + public String getPartition() { + return partition; + } + public void setPartition(String partition) { + this.partition = partition; + } + public PropertiesBean withPartition(String partition) { + this.partition = partition; + return this; + } + public String getContentType() { + return contentType; + } + public void setContentType(String contentType) { + this.contentType = contentType; + } + public PropertiesBean withContentType(String contentType) { + this.contentType = contentType; + return this; + } + public String getHost() { + return host; + } + public void setHost(String host) { + this.host = host; + } + public PropertiesBean withHost(String host) { + this.host = host; + return this; + } + public String getTopic() { + return topic; + } + public void setTopic(String topic) { + this.topic = topic; + } + public PropertiesBean withTopic(String topic) { + this.topic = topic; + return this; + } + public String getTimeout() { + return timeout; + } + public void setTimeout(String timeout) { + this.timeout = timeout; + } + public PropertiesBean withTimeout(String timeout) { + this.timeout = timeout; + return this; + } + + + + +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/rest/RestConsumer.java b/common/src/main/java/org/onap/so/client/dmaap/rest/RestConsumer.java new file mode 100644 index 0000000000..39af15635a --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/rest/RestConsumer.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap.rest; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.UriBuilder; + +import org.onap.so.client.RestClient; +import org.onap.so.client.dmaap.Consumer; + +public class RestConsumer implements Consumer { + + private final RestClient client; + public RestConsumer(Properties properties) { + PropertiesBean bean = new PropertiesBean(properties); + client = new DMaaPRestClient(this.createURL(bean), bean.getContentType(), bean.getUsername(), bean.getPassword()); + } + + private URL createURL(PropertiesBean properties) { + try { + return UriBuilder.fromUri(properties.getHost()) + .path("events").path(properties.getTopic()) + .path(properties.getPartition()) + .path("consumer1") + .queryParam("timeout", properties.getTimeout()).build().toURL(); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } + + @Override + public Iterable fetch() { + + return client.get(new GenericType>() {}).orElse(new ArrayList<>()); + } + +} diff --git a/common/src/main/java/org/onap/so/client/dmaap/rest/RestPublisher.java b/common/src/main/java/org/onap/so/client/dmaap/rest/RestPublisher.java new file mode 100644 index 0000000000..090e50543b --- /dev/null +++ b/common/src/main/java/org/onap/so/client/dmaap/rest/RestPublisher.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap.rest; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Properties; + +import javax.ws.rs.core.UriBuilder; + +import org.onap.so.client.RestClient; +import org.onap.so.client.dmaap.Publisher; + +public class RestPublisher implements Publisher { + + private final RestClient client; + + public RestPublisher(Properties properties) { + PropertiesBean bean = new PropertiesBean(properties); + client = new DMaaPRestClient(this.createURL(bean), bean.getContentType(), bean.getUsername(), bean.getPassword()); + } + + private URL createURL(PropertiesBean properties) { + try { + return UriBuilder.fromUri(properties.getHost()) + .path("events").path(properties.getTopic()) + .queryParam("timeout", properties.getTimeout()).build().toURL(); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } + + @Override + public void send(String json) { + client.post(json); + } +} diff --git a/common/src/main/java/org/onap/so/client/exceptions/SDNOException.java b/common/src/main/java/org/onap/so/client/exceptions/SDNOException.java new file mode 100644 index 0000000000..1e14308ad5 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/exceptions/SDNOException.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.exceptions; + + +public class SDNOException extends Exception { + + private static final long serialVersionUID = 6189163383568887383L; + + public SDNOException() { + super(); + } + + public SDNOException(String string) { + super("SDN-O exception: " + string); + } + + public SDNOException(Exception e) { + super(e); + } +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/Format.java b/common/src/main/java/org/onap/so/client/graphinventory/Format.java new file mode 100644 index 0000000000..5cbf1320c1 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/Format.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.graphinventory; + +public enum Format { + + RESOURCE("resource"), + SIMPLE("simple"), + RAW("raw"), + CONSOLE("console"), + PATHED("pathed"), + GRAPHSON("graphson"), + ID("id"); + + private final String name; + + private Format(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryClient.java new file mode 100644 index 0000000000..0d10c21886 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryClient.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.graphinventory; + +import java.net.URI; + +import org.onap.so.client.RestClient; +import org.onap.so.client.RestProperties; +import org.onap.so.client.RestPropertiesLoader; +import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri; + +public abstract class GraphInventoryClient { + + private RestProperties props; + protected GraphInventoryClient(Class propertiesClass) { + + RestProperties props = RestPropertiesLoader.getInstance().getNewImpl(propertiesClass); + this.props = props; + } + protected abstract URI constructPath(GraphInventoryUri uri); + + protected abstract RestClient createClient(GraphInventoryUri uri); + + protected T getRestProperties() { + if (props == null) { + throw new IllegalStateException("No RestProperty implementation found on classpath"); + } + return (T)props; + } +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectName.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectName.java new file mode 100644 index 0000000000..4543d8523b --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectName.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.graphinventory; + +import com.google.common.base.CaseFormat; + +public interface GraphInventoryObjectName { + + public String typeName(); + public String typeName(CaseFormat format); +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectPlurals.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectPlurals.java new file mode 100644 index 0000000000..ba48eb279f --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectPlurals.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.graphinventory; + +public interface GraphInventoryObjectPlurals extends GraphInventoryObjectName, GraphInventoryObjectUriTemplate, GraphInventoryObjectUriPartial { + +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectType.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectType.java new file mode 100644 index 0000000000..453becb75a --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectType.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.graphinventory; + +public interface GraphInventoryObjectType extends GraphInventoryObjectName, GraphInventoryObjectUriTemplate, GraphInventoryObjectUriPartial { + +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriPartial.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriPartial.java new file mode 100644 index 0000000000..0987221b0d --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriPartial.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.graphinventory; + +public interface GraphInventoryObjectUriPartial { + + public String partialUri(); +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriTemplate.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriTemplate.java new file mode 100644 index 0000000000..e231ddb811 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryObjectUriTemplate.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.graphinventory; + +public interface GraphInventoryObjectUriTemplate { + + public String uriTemplate(); +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryVersion.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryVersion.java new file mode 100644 index 0000000000..3b7dba70f8 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryVersion.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.graphinventory; + +public interface GraphInventoryVersion { + +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/Depth.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/Depth.java new file mode 100644 index 0000000000..1205511d11 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/Depth.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.graphinventory.entities.uri; + +public enum Depth { + ZERO("0"), + ONE("1"), + TWO("2"), + THREE("3"), + FOUR("4"), + FIVE("5"), + SIX("6"), + ALL("all"); + + private final String depth; + private Depth(String s) { + + this.depth = s; + } + + + @Override + public String toString() { + return this.depth; + } +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryResourceUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryResourceUri.java new file mode 100644 index 0000000000..08e7304978 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryResourceUri.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.graphinventory.entities.uri; + +import org.onap.so.client.graphinventory.Format; +import org.onap.so.client.graphinventory.entities.uri.Depth; +import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; +import org.onap.so.client.graphinventory.GraphInventoryObjectType; + +public interface GraphInventoryResourceUri extends GraphInventoryUri { + public GraphInventoryResourceUri relationshipAPI(); + public GraphInventoryResourceUri relatedTo(GraphInventoryObjectPlurals plural); + public GraphInventoryResourceUri relatedTo(GraphInventoryObjectType type, String... values); + public GraphInventoryResourceUri resourceVersion(String version); + public GraphInventoryResourceUri format(Format format); + @Override + public GraphInventoryResourceUri depth(Depth depth); + @Override + public GraphInventoryResourceUri nodesOnly(boolean nodesOnly); + @Override + public GraphInventoryResourceUri queryParam(String name, String... values); + @Override + public GraphInventoryResourceUri replaceQueryParam(String name, String... values); + @Override + public GraphInventoryResourceUri clone(); +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java new file mode 100644 index 0000000000..8a25c23895 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/GraphInventoryUri.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.graphinventory.entities.uri; + +import java.net.URI; +import java.util.Map; + +import org.onap.so.client.graphinventory.entities.uri.Depth; +import org.onap.so.client.graphinventory.GraphInventoryObjectType; + +public interface GraphInventoryUri { + + public URI build(); + /** + * By default GraphInventory enforces a depth of 1. Some objects can be told to retrieve objects + * nested beneath them by increasing this number. + * + * You can use 0 to restrict the returned information to only the object you requested + * You can use all to retrieve all nested objects (this should only be used if you really need a massive amount of information and are caching the retrieval) + * @param depth + * @return + */ + public GraphInventoryUri depth(Depth depth); + /** + * Makes client only return object fields, no relationships + * + * @return + */ + public GraphInventoryUri nodesOnly(boolean nodesOnly); + public GraphInventoryUri queryParam(String name, String... values); + public GraphInventoryUri replaceQueryParam(String name, String... values); + public GraphInventoryUri clone(); + + /** + * returns all key values of the URI as a map. Key names can be found in {@link GraphInventoryObjectType} + * @return + */ + public Map getURIKeys(); + public GraphInventoryObjectType getObjectType(); + public boolean equals(Object o); + public int hashCode(); +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java new file mode 100644 index 0000000000..9c86ec6348 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java @@ -0,0 +1,216 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.graphinventory.entities.uri; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + +import javax.ws.rs.core.UriBuilder; + +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.client.graphinventory.Format; +import org.onap.so.client.aai.entities.uri.AAIUri; +import org.onap.so.client.graphinventory.entities.uri.Depth; +import org.onap.so.client.graphinventory.entities.uri.parsers.UriParser; +import org.onap.so.client.graphinventory.entities.uri.parsers.UriParserSpringImpl; +import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; +import org.onap.so.client.graphinventory.GraphInventoryObjectType; +import org.springframework.web.util.UriUtils; + +public class SimpleUri implements GraphInventoryResourceUri { + + protected UriBuilder internalURI; + protected final static String relationshipAPI = "/relationship-list/relationship"; + protected final static String relatedTo = "/related-to"; + protected final Object[] values; + protected final GraphInventoryObjectType type; + protected final GraphInventoryObjectPlurals pluralType; + protected SimpleUri(GraphInventoryObjectType type, Object... values) { + this.type = type; + this.pluralType = null; + this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); + this.values = values; + } + protected SimpleUri(GraphInventoryObjectType type, URI uri) { + this.type = type; + this.pluralType = null; + this.internalURI = UriBuilder.fromPath(uri.getRawPath().replaceAll("/aai/v\\d+", "")); + this.values = new Object[0]; + } + protected SimpleUri(GraphInventoryObjectType type, UriBuilder builder, Object... values) { + this.internalURI = builder; + this.values = values; + this.type = type; + this.pluralType = null; + } + protected SimpleUri(GraphInventoryObjectPlurals type, UriBuilder builder, Object... values) { + this.internalURI = builder; + this.values = values; + this.type = null; + this.pluralType = type; + } + protected SimpleUri(GraphInventoryObjectPlurals type) { + this.type = null; + this.pluralType = type; + this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); + this.values = new Object[0]; + } + protected SimpleUri(GraphInventoryObjectPlurals type, Object... values) { + this.type = null; + this.pluralType = type; + this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); + this.values = values; + } + + @Override + public SimpleUri relationshipAPI() { + this.internalURI = internalURI.path(relationshipAPI); + return this; + } + + @Override + public SimpleUri relatedTo(GraphInventoryObjectPlurals plural) { + + this.internalURI = internalURI.path(relatedTo).path(plural.partialUri()); + return this; + } + @Override + public SimpleUri relatedTo(GraphInventoryObjectType type, String... values) { + this.internalURI = internalURI.path(relatedTo).path(UriBuilder.fromPath(type.partialUri()).build(values).toString()); + return this; + } + + @Override + public SimpleUri resourceVersion(String version) { + this.internalURI = internalURI.replaceQueryParam("resource-version", version); + return this; + } + + @Override + public SimpleUri queryParam(String name, String... values) { + this.internalURI = internalURI.queryParam(name, values); + return this; + } + + @Override + public SimpleUri replaceQueryParam(String name, String... values) { + this.internalURI = internalURI.replaceQueryParam(name, values); + return this; + } + + @Override + public URI build() { + return build(this.values); + } + + protected URI build(Object... values) { + //This is a workaround because resteasy does not encode URIs correctly + final String[] encoded = new String[values.length]; + for (int i = 0; i < values.length; i++) { + try { + encoded[i] = UriUtils.encode(values[i].toString(), StandardCharsets.UTF_8.toString()); + } catch (UnsupportedEncodingException e) { + encoded[i] = values[i].toString(); + } + } + return internalURI.buildFromEncoded(encoded); + } + + @Override + public Map getURIKeys() { + return this.getURIKeys(this.build().toString()); + } + + protected Map getURIKeys(String uri) { + UriParser parser; + if (this.type != null) { + if (!("".equals(this.getTemplate(type)))) { + parser = new UriParserSpringImpl(this.getTemplate(type)); + } else { + return new HashMap<>(); + } + } else { + parser = new UriParserSpringImpl(this.getTemplate(pluralType)); + } + + + return parser.parse(uri); + } + + @Override + public SimpleUri clone() { + if (this.type != null) { + return new SimpleUri(this.type, this.internalURI.clone(), values); + } else { + return new SimpleUri(this.pluralType, this.internalURI.clone(), values); + } + } + + @Override + public GraphInventoryObjectType getObjectType() { + return this.type; + } + + @Override + public boolean equals(Object o) { + if (o instanceof AAIUri) { + return this.build().equals(((AAIUri)o).build()); + } + return false; + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(this.build()).toHashCode(); + } + + + @Override + public SimpleUri depth(Depth depth) { + this.internalURI.replaceQueryParam("depth", depth.toString()); + return this; + } + @Override + public SimpleUri nodesOnly(boolean nodesOnly) { + if (nodesOnly) { + this.internalURI.replaceQueryParam("nodes-only", ""); + } + return this; + } + + @Override + public SimpleUri format(Format format) { + this.internalURI.replaceQueryParam("format", format); + return this; + } + + protected String getTemplate(GraphInventoryObjectType type) { + return type.uriTemplate(); + } + + protected String getTemplate(GraphInventoryObjectPlurals type) { + return type.uriTemplate(); + } + +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParser.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParser.java new file mode 100644 index 0000000000..03d83ebfb6 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParser.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.graphinventory.entities.uri.parsers; + +import java.util.Map; +import java.util.Set; + +public interface UriParser { + public Set getVariables(); + public Map parse(final String uri); +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java new file mode 100644 index 0000000000..aeaa923d1b --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImpl.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.graphinventory.entities.uri.parsers; +import java.io.UnsupportedEncodingException; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.springframework.web.util.UriTemplate; +import org.springframework.web.util.UriUtils; + +public class UriParserSpringImpl implements UriParser { + + private final UriTemplate uriTemplate; + + public UriParserSpringImpl(final String template) { + this.uriTemplate = new UriTemplate(template); + } + + @Override + public Map parse(final String uri) { + final boolean match = this.uriTemplate.matches(uri); + if (!match) { + return new LinkedHashMap<>(); + } + return Collections.unmodifiableMap(decodeParams(this.uriTemplate.match(uri))); + } + + @Override + public Set getVariables() { + return Collections.unmodifiableSet(new LinkedHashSet(this.uriTemplate.getVariableNames())); + } + + protected Map decodeParams(Map map) { + final Map result = new LinkedHashMap<>(); + + for (Entry entry : map.entrySet()) { + try { + result.put(entry.getKey(), UriUtils.decode(entry.getValue(), "UTF-8")); + } catch (UnsupportedEncodingException e) { + result.put(entry.getKey(), ""); + } + } + + return result; + } +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/exceptions/BulkProcessFailed.java b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/BulkProcessFailed.java new file mode 100644 index 0000000000..0c973a8457 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/BulkProcessFailed.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.graphinventory.exceptions; + +public class BulkProcessFailed extends Exception { + + public BulkProcessFailed(String message) { + super(message); + } +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPatchDepthExceededException.java b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPatchDepthExceededException.java new file mode 100644 index 0000000000..07af13049c --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPatchDepthExceededException.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.graphinventory.exceptions; + +public class GraphInventoryPatchDepthExceededException extends RuntimeException { + + private static final long serialVersionUID = -3740429832086738907L; + + + public GraphInventoryPatchDepthExceededException(String payload) { + super("Object exceeds allowed depth for update action: " + payload); + } +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPayloadException.java b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPayloadException.java new file mode 100644 index 0000000000..24a6e5ccf9 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPayloadException.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.graphinventory.exceptions; + +public class GraphInventoryPayloadException extends Exception { + + private static final long serialVersionUID = -5712783905947711065L; + + public GraphInventoryPayloadException(Throwable t) { + super(t); + } + + public GraphInventoryPayloadException(String s, Throwable t) { + super(s, t); + } + + public GraphInventoryPayloadException(String s) { + super(s); + } + + +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriComputationException.java b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriComputationException.java new file mode 100644 index 0000000000..51747d495a --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriComputationException.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.graphinventory.exceptions; + +public class GraphInventoryUriComputationException extends RuntimeException { + + private static final long serialVersionUID = 5187931752227522034L; + + public GraphInventoryUriComputationException(String s) { + super(s); + } + + public GraphInventoryUriComputationException(Throwable t) { + super(t); + } +} diff --git a/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriNotFoundException.java b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriNotFoundException.java new file mode 100644 index 0000000000..d2f47a5b00 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryUriNotFoundException.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.graphinventory.exceptions; + +public class GraphInventoryUriNotFoundException extends Exception { + private static final long serialVersionUID = 2789643165122257833L; + + public GraphInventoryUriNotFoundException(String message) { + super(message); + } +} diff --git a/common/src/main/java/org/onap/so/client/grm/GRMAction.java b/common/src/main/java/org/onap/so/client/grm/GRMAction.java new file mode 100644 index 0000000000..376c736037 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/GRMAction.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm; + +public enum GRMAction { + + FIND_RUNNING("findRunning"), + ADD("add"); + + private final String action; + + GRMAction(String action) { + this.action = action; + } + + public String getAction() { + return action; + } +} diff --git a/common/src/main/java/org/onap/so/client/grm/GRMClient.java b/common/src/main/java/org/onap/so/client/grm/GRMClient.java new file mode 100644 index 0000000000..84e25b9ce4 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/GRMClient.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm; + +import org.onap.so.client.grm.beans.ServiceEndPointList; +import org.onap.so.client.grm.beans.ServiceEndPointLookup; +import org.onap.so.client.grm.beans.ServiceEndPointLookupRequest; +import org.onap.so.client.grm.beans.ServiceEndPointRequest; +import org.onap.so.client.grm.beans.VersionLookup; +import org.onap.so.client.grm.exceptions.GRMClientCallFailed; + +public class GRMClient { + + public String findRunningServicesAsString(String name, int majorVersion, String env) throws Exception { + + ServiceEndPointLookupRequest request = buildServiceEndPointlookupRequest(name, majorVersion, env); + try { + GRMRestInvoker invoker = this.getInvoker(GRMAction.FIND_RUNNING); + return invoker.post(request, String.class); + } + catch(Exception e) { + throw new GRMClientCallFailed("Call to GRM findRunning failed: " + e.getMessage(), e); + } + } + + public ServiceEndPointList findRunningServices(String name, int majorVersion, String env) throws Exception { + + ServiceEndPointLookupRequest request = buildServiceEndPointlookupRequest(name, majorVersion, env); + try { + GRMRestInvoker invoker = this.getInvoker(GRMAction.FIND_RUNNING); + return invoker.post(request, ServiceEndPointList.class); + } + catch(Exception e) { + throw new GRMClientCallFailed("Call to GRM findRunning failed: " + e.getMessage(), e); + } + } + + protected ServiceEndPointLookupRequest buildServiceEndPointlookupRequest(String name, int majorVersion, String env) { + VersionLookup version = new VersionLookup(); + version.setMajor(majorVersion); + + ServiceEndPointLookup endpoint = new ServiceEndPointLookup(); + endpoint.setName(name); + endpoint.setVersion(version); + + ServiceEndPointLookupRequest request = new ServiceEndPointLookupRequest(); + request.setServiceEndPoint(endpoint); + request.setEnv(env); + return request; + } + + public void addServiceEndPoint(ServiceEndPointRequest request) throws Exception { + try { + GRMRestInvoker invoker = this.getInvoker(GRMAction.ADD); + invoker.post(request); + } + catch(Exception e) { + throw new GRMClientCallFailed("Call to GRM addServiceEndPoint failed: " + e.getMessage(), e); + } + } + + protected GRMRestInvoker getInvoker(GRMAction action) { + return new GRMRestInvoker(action); + } +} diff --git a/common/src/main/java/org/onap/so/client/grm/GRMDefaultPropertiesImpl.java b/common/src/main/java/org/onap/so/client/grm/GRMDefaultPropertiesImpl.java new file mode 100644 index 0000000000..b38072e769 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/GRMDefaultPropertiesImpl.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm; + +import java.net.MalformedURLException; +import java.net.URL; + +import javax.ws.rs.core.MediaType; + +public class GRMDefaultPropertiesImpl implements GRMProperties { + + public GRMDefaultPropertiesImpl() { + } + + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL("http://localhost:47389"); + } + + @Override + public String getSystemName() { + return "MSO"; + } + + @Override + public String getDefaultVersion() { + return "v1"; + } + + @Override + public String getUsername() { + return "gmruser"; + } + + @Override + public String getPassword() { + return "cGFzc3dvcmQ="; + } + + @Override + public String getContentType() { + return MediaType.APPLICATION_JSON; + } + +} diff --git a/common/src/main/java/org/onap/so/client/grm/GRMProperties.java b/common/src/main/java/org/onap/so/client/grm/GRMProperties.java new file mode 100644 index 0000000000..da9f215aac --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/GRMProperties.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm; + +import org.onap.so.client.RestProperties; + +public interface GRMProperties extends RestProperties { + public String getDefaultVersion(); + public String getUsername(); + public String getPassword(); + public String getContentType(); +} diff --git a/common/src/main/java/org/onap/so/client/grm/GRMPropertiesLoader.java b/common/src/main/java/org/onap/so/client/grm/GRMPropertiesLoader.java new file mode 100644 index 0000000000..485b9b0d15 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/GRMPropertiesLoader.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm; + +import java.util.Iterator; +import java.util.ServiceLoader; + +public class GRMPropertiesLoader { + + private final ServiceLoader services; + private GRMPropertiesLoader() { + services = ServiceLoader.load(GRMProperties.class); + } + + private static class Helper { + private static final GRMPropertiesLoader INSTANCE = new GRMPropertiesLoader(); + } + + public static GRMPropertiesLoader getInstance() { + return Helper.INSTANCE; + } + + public GRMProperties getImpl() { + Iterator propertyImpls = services.iterator(); + while (propertyImpls.hasNext()) { + return propertyImpls.next(); + } + return null; + } +} diff --git a/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java b/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java new file mode 100644 index 0000000000..ce16ccaaaa --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm; + + +import java.net.URI; +import java.util.Base64; +import java.util.Map; +import java.util.Optional; + +import org.onap.so.client.RestClient; +import org.onap.so.client.RestProperties; +import org.onap.so.utils.TargetEntity; + +public class GRMRestClient extends RestClient { + + private final String username; + private final String password; + + public GRMRestClient(RestProperties props, URI path, String username, String password) { + super(props, Optional.of(path)); + this.username = username; + this.password = password; + } + + @Override + public TargetEntity getTargetEntity(){ + return TargetEntity.GRM; + } + + @Override + protected void initializeHeaderMap(Map headerMap) { + headerMap.put("Authorization", "Basic " + Base64.getEncoder().encodeToString(new String(username + ":" + password).getBytes())); + } + +} diff --git a/common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java b/common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java new file mode 100644 index 0000000000..3045cb35f4 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/GRMRestInvoker.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm; + +import java.net.URI; +import java.util.Base64; + +import javax.ws.rs.core.UriBuilder; + +import org.onap.so.client.RestClient; + +public class GRMRestInvoker { + + private final RestClient client; + private final GRMProperties properties; + + public GRMRestInvoker(GRMAction action) { + GRMProperties props = GRMPropertiesLoader.getInstance().getImpl(); + if (props == null) { + props = new GRMDefaultPropertiesImpl(); + } + this.properties = props; + this.client = new GRMRestClient(this.properties, this.createURI(action), this.properties.getUsername(), this.decode(this.properties.getPassword())); + } + + private URI createURI(GRMAction action) { + return UriBuilder.fromUri("/GRMLWPService") + .path(this.properties.getDefaultVersion()) + .path("serviceEndPoint") + .path(action.getAction()) + .build(); + } + + private String decode(String cred) { + try { + return new String(Base64.getDecoder().decode(cred.getBytes())); + } + catch(IllegalArgumentException iae) { + return cred; + } + } + + private RestClient getClient() { + return this.client; + } + + public void post(Object obj) { + getClient().post(obj); + } + + public T post(Object obj, Class resultClass) { + return getClient().post(obj, resultClass); + } + +} diff --git a/common/src/main/java/org/onap/so/client/grm/beans/OperationalInfo.java b/common/src/main/java/org/onap/so/client/grm/beans/OperationalInfo.java new file mode 100644 index 0000000000..85e15f597c --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/beans/OperationalInfo.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm.beans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonPropertyOrder({ "createdBy", "updatedBy", "createdTimestamp", "updatedTimestamp" }) +public class OperationalInfo implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = -7213334079745439793L; + @JsonProperty("createdBy") + private String createdBy; + @JsonProperty("updatedBy") + private String updatedBy; + @JsonProperty("createdTimestamp") + private String createdTimestamp; + @JsonProperty("updatedTimestamp") + private String updatedTimestamp; + + @JsonProperty("createdBy") + public String getCreatedBy() { + return createdBy; + } + + @JsonProperty("createdBy") + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + @JsonProperty("updatedBy") + public String getUpdatedBy() { + return updatedBy; + } + + @JsonProperty("updatedBy") + public void setUpdatedBy(String updatedBy) { + this.updatedBy = updatedBy; + } + + @JsonProperty("createdTimestamp") + public String getCreatedTimestamp() { + return createdTimestamp; + } + + @JsonProperty("createdTimestamp") + public void setCreatedTimestamp(String createdTimestamp) { + this.createdTimestamp = createdTimestamp; + } + + @JsonProperty("updatedTimestamp") + public String getUpdatedTimestamp() { + return updatedTimestamp; + } + + @JsonProperty("updatedTimestamp") + public void setUpdatedTimestamp(String updatedTimestamp) { + this.updatedTimestamp = updatedTimestamp; + } + +} diff --git a/common/src/main/java/org/onap/so/client/grm/beans/Property.java b/common/src/main/java/org/onap/so/client/grm/beans/Property.java new file mode 100644 index 0000000000..705db95222 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/beans/Property.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm.beans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonPropertyOrder({ "name", "value" }) +public class Property implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = -6060749559638446881L; + @JsonProperty("name") + private String name; + @JsonProperty("value") + private String value; + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @JsonProperty("value") + public void setValue(String value) { + this.value = value; + } + +} diff --git a/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPoint.java b/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPoint.java new file mode 100644 index 0000000000..e739f00c9a --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPoint.java @@ -0,0 +1,247 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm.beans; + +import java.io.Serializable; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "serviceEndPoint") +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonPropertyOrder({ "name", "version", "hostAddress", "listenPort", "latitude", "longitude", "registrationTime", + "expirationTime", "contextPath", "routeOffer", "statusInfo", "eventStatusInfo", "validatorStatusInfo", + "operationalInfo", "protocol", "properties", "disableType" }) +public class ServiceEndPoint implements Serializable { + + private static final long serialVersionUID = -1594441352549128491L; + + @JsonProperty("name") + private String name; + @JsonProperty("version") + private Version version; + @JsonProperty("hostAddress") + private String hostAddress; + @JsonProperty("listenPort") + private String listenPort; + @JsonProperty("latitude") + private String latitude; + @JsonProperty("longitude") + private String longitude; + @JsonProperty("registrationTime") + private String registrationTime; + @JsonProperty("expirationTime") + private String expirationTime; + @JsonProperty("contextPath") + private String contextPath; + @JsonProperty("routeOffer") + private String routeOffer; + @JsonProperty("statusInfo") + private Status statusInfo; + @JsonProperty("eventStatusInfo") + private Status eventStatusInfo; + @JsonProperty("validatorStatusInfo") + private Status validatorStatusInfo; + @JsonProperty("operationalInfo") + private OperationalInfo operationalInfo; + @JsonProperty("protocol") + private String protocol; + @JsonProperty("properties") + private List properties = null; + @JsonProperty("disableType") + private List disableType = null; + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonProperty("version") + public Version getVersion() { + return version; + } + + @JsonProperty("version") + public void setVersion(Version version) { + this.version = version; + } + + @JsonProperty("hostAddress") + public String getHostAddress() { + return hostAddress; + } + + @JsonProperty("hostAddress") + public void setHostAddress(String hostAddress) { + this.hostAddress = hostAddress; + } + + @JsonProperty("listenPort") + public String getListenPort() { + return listenPort; + } + + @JsonProperty("listenPort") + public void setListenPort(String listenPort) { + this.listenPort = listenPort; + } + + @JsonProperty("latitude") + public String getLatitude() { + return latitude; + } + + @JsonProperty("latitude") + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + @JsonProperty("longitude") + public String getLongitude() { + return longitude; + } + + @JsonProperty("longitude") + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + @JsonProperty("registrationTime") + public String getRegistrationTime() { + return registrationTime; + } + + @JsonProperty("registrationTime") + public void setRegistrationTime(String registrationTime) { + this.registrationTime = registrationTime; + } + + @JsonProperty("expirationTime") + public String getExpirationTime() { + return expirationTime; + } + + @JsonProperty("expirationTime") + public void setExpirationTime(String expirationTime) { + this.expirationTime = expirationTime; + } + + @JsonProperty("contextPath") + public String getContextPath() { + return contextPath; + } + + @JsonProperty("contextPath") + public void setContextPath(String contextPath) { + this.contextPath = contextPath; + } + + @JsonProperty("routeOffer") + public String getRouteOffer() { + return routeOffer; + } + + @JsonProperty("routeOffer") + public void setRouteOffer(String routeOffer) { + this.routeOffer = routeOffer; + } + + @JsonProperty("statusInfo") + public Status getStatusInfo() { + return statusInfo; + } + + @JsonProperty("statusInfo") + public void setStatusInfo(Status statusInfo) { + this.statusInfo = statusInfo; + } + + @JsonProperty("eventStatusInfo") + public Status getEventStatusInfo() { + return eventStatusInfo; + } + + @JsonProperty("eventStatusInfo") + public void setEventStatusInfo(Status eventStatusInfo) { + this.eventStatusInfo = eventStatusInfo; + } + + @JsonProperty("validatorStatusInfo") + public Status getValidatorStatusInfo() { + return validatorStatusInfo; + } + + @JsonProperty("validatorStatusInfo") + public void setValidatorStatusInfo(Status validatorStatusInfo) { + this.validatorStatusInfo = validatorStatusInfo; + } + + @JsonProperty("operationalInfo") + public OperationalInfo getOperationalInfo() { + return operationalInfo; + } + + @JsonProperty("operationalInfo") + public void setOperationalInfo(OperationalInfo operationalInfo) { + this.operationalInfo = operationalInfo; + } + + @JsonProperty("protocol") + public String getProtocol() { + return protocol; + } + + @JsonProperty("protocol") + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + @JsonProperty("properties") + public List getProperties() { + return properties; + } + + @JsonProperty("properties") + public void setProperties(List properties) { + this.properties = properties; + } + + @JsonProperty("disableType") + public List getDisableType() { + return disableType; + } + + @JsonProperty("disableType") + public void setDisableType(List disableType) { + this.disableType = disableType; + } + +} diff --git a/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointList.java b/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointList.java new file mode 100644 index 0000000000..19bbe69cf2 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointList.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm.beans; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonPropertyOrder({ "serviceEndPointList" }) +public class ServiceEndPointList { + + @JsonProperty("serviceEndPointList") + private List serviceEndPointList = null; + + @JsonProperty("serviceEndPointList") + public List getServiceEndPointList() { + return serviceEndPointList; + } + + @JsonProperty("serviceEndPointList") + public void setServiceEndPointList(List serviceEndPointList) { + this.serviceEndPointList = serviceEndPointList; + } + +} diff --git a/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointLookup.java b/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointLookup.java new file mode 100644 index 0000000000..cab10e64f4 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointLookup.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm.beans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "serviceEndPoint") +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "name", "version"}) +public class ServiceEndPointLookup implements Serializable { + + private static final long serialVersionUID = 8867758152519088615L; + + @JsonProperty("name") + private String name; + @JsonProperty("version") + private VersionLookup version; + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonProperty("version") + public VersionLookup getVersion() { + return version; + } + + @JsonProperty("version") + public void setVersion(VersionLookup version) { + this.version = version; + } +} diff --git a/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointLookupRequest.java b/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointLookupRequest.java new file mode 100644 index 0000000000..5e886300dd --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointLookupRequest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm.beans; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonPropertyOrder({ "serviceEndPoint", "env" }) +public class ServiceEndPointLookupRequest { + + @JsonProperty("serviceEndPoint") + private ServiceEndPointLookup serviceEndPoint; + @JsonProperty("env") + private String env; + + @JsonProperty("serviceEndPoint") + public ServiceEndPointLookup getServiceEndPoint() { + return serviceEndPoint; + } + + @JsonProperty("serviceEndPoint") + public void setServiceEndPoint(ServiceEndPointLookup serviceEndPoint) { + this.serviceEndPoint = serviceEndPoint; + } + + @JsonProperty("env") + public String getEnv() { + return env; + } + + @JsonProperty("env") + public void setEnv(String env) { + this.env = env; + } + +} diff --git a/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointRequest.java b/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointRequest.java new file mode 100644 index 0000000000..f7ea352f21 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/beans/ServiceEndPointRequest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm.beans; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonPropertyOrder({ "serviceEndPoint", "env" }) +public class ServiceEndPointRequest { + + @JsonProperty("serviceEndPoint") + private ServiceEndPoint serviceEndPoint; + @JsonProperty("env") + private String env; + + @JsonProperty("serviceEndPoint") + public ServiceEndPoint getServiceEndPoint() { + return serviceEndPoint; + } + + @JsonProperty("serviceEndPoint") + public void setServiceEndPoint(ServiceEndPoint serviceEndPoint) { + this.serviceEndPoint = serviceEndPoint; + } + + @JsonProperty("env") + public String getEnv() { + return env; + } + + @JsonProperty("env") + public void setEnv(String env) { + this.env = env; + } + +} diff --git a/common/src/main/java/org/onap/so/client/grm/beans/Status.java b/common/src/main/java/org/onap/so/client/grm/beans/Status.java new file mode 100644 index 0000000000..8794139b67 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/beans/Status.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm.beans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonPropertyOrder({ "status", "statusReasonCode", "statusReasonDescription", "statusCheckTime" }) +public class Status implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3555636617671062648L; + @JsonProperty("status") + private String status; + @JsonProperty("statusReasonCode") + private String statusReasonCode; + @JsonProperty("statusReasonDescription") + private String statusReasonDescription; + @JsonProperty("statusCheckTime") + private String statusCheckTime; + + @JsonProperty("status") + public String getStatus() { + return status; + } + + @JsonProperty("status") + public void setStatus(String status) { + this.status = status; + } + + @JsonProperty("statusReasonCode") + public String getStatusReasonCode() { + return statusReasonCode; + } + + @JsonProperty("statusReasonCode") + public void setStatusReasonCode(String statusReasonCode) { + this.statusReasonCode = statusReasonCode; + } + + @JsonProperty("statusReasonDescription") + public String getStatusReasonDescription() { + return statusReasonDescription; + } + + @JsonProperty("statusReasonDescription") + public void setStatusReasonDescription(String statusReasonDescription) { + this.statusReasonDescription = statusReasonDescription; + } + + @JsonProperty("statusCheckTime") + public String getStatusCheckTime() { + return statusCheckTime; + } + + @JsonProperty("statusCheckTime") + public void setStatusCheckTime(String statusCheckTime) { + this.statusCheckTime = statusCheckTime; + } + +} diff --git a/common/src/main/java/org/onap/so/client/grm/beans/Version.java b/common/src/main/java/org/onap/so/client/grm/beans/Version.java new file mode 100644 index 0000000000..fd1e5803ab --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/beans/Version.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm.beans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonPropertyOrder({ "major", "minor", "patch" }) +public class Version implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = 7509573030831487410L; + @JsonProperty("major") + private Integer major; + @JsonProperty("minor") + private Integer minor; + @JsonProperty("patch") + private String patch; + + @JsonProperty("major") + public Integer getMajor() { + return major; + } + + @JsonProperty("major") + public void setMajor(Integer major) { + this.major = major; + } + + @JsonProperty("minor") + public Integer getMinor() { + return minor; + } + + @JsonProperty("minor") + public void setMinor(Integer minor) { + this.minor = minor; + } + + @JsonProperty("patch") + public String getPatch() { + return patch; + } + + @JsonProperty("patch") + public void setPatch(String patch) { + this.patch = patch; + } +} diff --git a/common/src/main/java/org/onap/so/client/grm/beans/VersionLookup.java b/common/src/main/java/org/onap/so/client/grm/beans/VersionLookup.java new file mode 100644 index 0000000000..0dc86b04d6 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/beans/VersionLookup.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm.beans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonPropertyOrder({ "major" }) +public class VersionLookup implements Serializable { + + private static final long serialVersionUID = 3802602253627725770L; + + @JsonProperty("major") + private Integer major; + + @JsonProperty("major") + public Integer getMajor() { + return major; + } + + @JsonProperty("major") + public void setMajor(Integer major) { + this.major = major; + } +} diff --git a/common/src/main/java/org/onap/so/client/grm/exceptions/GRMClientCallFailed.java b/common/src/main/java/org/onap/so/client/grm/exceptions/GRMClientCallFailed.java new file mode 100644 index 0000000000..7107d4027f --- /dev/null +++ b/common/src/main/java/org/onap/so/client/grm/exceptions/GRMClientCallFailed.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm.exceptions; + +public class GRMClientCallFailed extends Exception { + + private static final long serialVersionUID = -8714110346844078779L; + + public GRMClientCallFailed(String message, Throwable cause) { + super(message, cause); + } + + +} diff --git a/common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java b/common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java new file mode 100644 index 0000000000..f2f6f0362f --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +public class CommonObjectMapperProvider { + + protected ObjectMapper mapper; + + public CommonObjectMapperProvider() { + + mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + mapper.enable(MapperFeature.USE_ANNOTATIONS); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + public ObjectMapper getMapper() { + return mapper; + } +} \ No newline at end of file diff --git a/common/src/main/java/org/onap/so/client/policy/DecisionAttributes.java b/common/src/main/java/org/onap/so/client/policy/DecisionAttributes.java new file mode 100644 index 0000000000..951372db42 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/DecisionAttributes.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy; + + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "ServiceType", "VNFType", "BB_ID", "WorkStep", "ErrorCode" }) +public class DecisionAttributes { + + @JsonProperty("ServiceType") + private String serviceType; + @JsonProperty("VNFType") + private String vNFType; + @JsonProperty("BB_ID") + private String bbID; + @JsonProperty("WorkStep") + private String workStep; + @JsonProperty("ErrorCode") + private String errorCode; + + @JsonProperty("ServiceType") + public String getServiceType() { + return serviceType; + } + + @JsonProperty("ServiceType") + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + @JsonProperty("VNFType") + public String getVNFType() { + return vNFType; + } + + @JsonProperty("VNFType") + public void setVNFType(String vNFType) { + this.vNFType = vNFType; + } + + @JsonProperty("BB_ID") + public String getBBID() { + return bbID; + } + + @JsonProperty("BB_ID") + public void setBBID(String bBID) { + this.bbID = bBID; + } + + @JsonProperty("WorkStep") + public String getWorkStep() { + return workStep; + } + + @JsonProperty("WorkStep") + public void setWorkStep(String workStep) { + this.workStep = workStep; + } + + @JsonProperty("ErrorCode") + public String getErrorCode() { + return errorCode; + } + + @JsonProperty("ErrorCode") + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } +} diff --git a/common/src/main/java/org/onap/so/client/policy/JettisonStyleMapperProvider.java b/common/src/main/java/org/onap/so/client/policy/JettisonStyleMapperProvider.java new file mode 100644 index 0000000000..23b984a3d0 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/JettisonStyleMapperProvider.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy; + +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; + +@Component +public class JettisonStyleMapperProvider extends CommonObjectMapperProvider { + + public JettisonStyleMapperProvider() { + + mapper = new ObjectMapper(); + JaxbAnnotationModule jaxbModule = new JaxbAnnotationModule(); + mapper.setSerializationInclusion(Include.NON_NULL); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.registerModule(jaxbModule); + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/LoggingFilter.java b/common/src/main/java/org/onap/so/client/policy/LoggingFilter.java new file mode 100644 index 0000000000..83cf08f77f --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/LoggingFilter.java @@ -0,0 +1,157 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy; + +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + +import javax.annotation.Priority; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.client.ClientRequestContext; +import javax.ws.rs.client.ClientRequestFilter; +import javax.ws.rs.client.ClientResponseContext; +import javax.ws.rs.client.ClientResponseFilter; +import javax.ws.rs.ext.Provider; +import javax.ws.rs.ext.WriterInterceptor; +import javax.ws.rs.ext.WriterInterceptorContext; + +import org.onap.so.logger.MsoLogger; + + +@Provider +@Priority(0) +public class LoggingFilter implements ClientRequestFilter, ClientResponseFilter, WriterInterceptor { + + private static final MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, LoggingFilter.class); + private static final String ENTITY_STREAM_PROPERTY = "LoggingFilter.entityStream"; + private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; + private final int maxEntitySize; + + public LoggingFilter() { + maxEntitySize = 1024 * 1024; + } + + public LoggingFilter(int maxPayloadSize) { + this.maxEntitySize = Integer.min(maxPayloadSize, 1024 * 1024); + } + + private void log(StringBuilder sb) { + logger.debug(sb.toString()); + } + + protected InputStream logInboundEntity(final StringBuilder b, InputStream stream, final Charset charset) + throws IOException { + if (!stream.markSupported()) { + stream = new BufferedInputStream(stream); + } + stream.mark(maxEntitySize + 1); + final byte[] entity = new byte[maxEntitySize + 1]; + final int entitySize = stream.read(entity); + if (entitySize != -1) { + b.append(new String(entity, 0, Math.min(entitySize, maxEntitySize), charset)); + } + if (entitySize > maxEntitySize) { + b.append("...more..."); + } + b.append('\n'); + stream.reset(); + return stream; + } + + @Override + public void filter(ClientRequestContext requestContext) throws IOException { + if (requestContext.hasEntity()) { + final OutputStream stream = new LoggingStream(requestContext.getEntityStream()); + requestContext.setEntityStream(stream); + requestContext.setProperty(ENTITY_STREAM_PROPERTY, stream); + } + String method = formatMethod(requestContext); + log(new StringBuilder("Making " + method + " request to: " + requestContext.getUri() + "\nRequest Headers: " + requestContext.getHeaders().toString())); + + } + + @Override + public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { + final StringBuilder sb = new StringBuilder(); + if (responseContext.hasEntity()) { + responseContext.setEntityStream(logInboundEntity(sb, responseContext.getEntityStream(), DEFAULT_CHARSET)); + String method = formatMethod(requestContext); + log(sb.insert(0, "Response from " + method + ": " + requestContext.getUri() + "\nResponse Headers: " + responseContext.getHeaders().toString())); + } + } + + @Override + public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException { + final LoggingStream stream = (LoggingStream) context.getProperty(ENTITY_STREAM_PROPERTY); + context.proceed(); + if (stream != null) { + log(stream.getStringBuilder(DEFAULT_CHARSET)); + } + } + + private class LoggingStream extends FilterOutputStream { + + private final StringBuilder sb = new StringBuilder(); + private final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + LoggingStream(OutputStream out) { + super(out); + } + + StringBuilder getStringBuilder(Charset charset) { + // write entity to the builder + final byte[] entity = baos.toByteArray(); + + sb.append(new String(entity, 0, entity.length, charset)); + if (entity.length > maxEntitySize) { + sb.append("...more..."); + } + sb.append('\n'); + + return sb; + } + + @Override + public void write(final int i) throws IOException { + if (baos.size() <= maxEntitySize) { + baos.write(i); + } + out.write(i); + } + } + + private String formatMethod(ClientRequestContext requestContext) { + String method = requestContext.getHeaderString("X-HTTP-Method-Override"); + if (method == null) { + method = requestContext.getMethod(); + } else { + method = requestContext.getMethod() + " (overridden to " + method + ")"; + } + + return method; + } +} \ No newline at end of file diff --git a/common/src/main/java/org/onap/so/client/policy/PolicyClient.java b/common/src/main/java/org/onap/so/client/policy/PolicyClient.java new file mode 100644 index 0000000000..74c1e398db --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/PolicyClient.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy; + +import org.onap.so.client.policy.entities.DictionaryData; +import org.onap.so.client.policy.entities.PolicyDecision; + +public interface PolicyClient { + + public PolicyDecision getDecision(String serviceType, String vnfType, String bbID, String workStep, + String errorCode); + + public DictionaryData getAllowedTreatments(String bbID, String workStep); +} diff --git a/common/src/main/java/org/onap/so/client/policy/PolicyClientImpl.java b/common/src/main/java/org/onap/so/client/policy/PolicyClientImpl.java new file mode 100644 index 0000000000..1fd01e65ed --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/PolicyClientImpl.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy; + +import java.util.List; + +import org.onap.so.client.RestClient; +import org.onap.so.client.RestPropertiesLoader; +import org.onap.so.client.defaultproperties.PolicyRestPropertiesImpl; +import org.onap.so.client.policy.entities.AllowedTreatments; +import org.onap.so.client.policy.entities.Bbid; +import org.onap.so.client.policy.entities.DecisionAttributes; +import org.onap.so.client.policy.entities.DictionaryData; +import org.onap.so.client.policy.entities.DictionaryItemsRequest; +import org.onap.so.client.policy.entities.DictionaryJson; +import org.onap.so.client.policy.entities.PolicyDecision; +import org.onap.so.client.policy.entities.PolicyDecisionRequest; +import org.onap.so.client.policy.entities.PolicyServiceType; +import org.onap.so.client.policy.entities.Workstep; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class PolicyClientImpl implements PolicyClient { + + private static Logger logger = LoggerFactory.getLogger(PolicyClientImpl.class); + private PolicyRestProperties props; + public PolicyClientImpl() { + props = RestPropertiesLoader.getInstance().getNewImpl(PolicyRestProperties.class); + if (props == null) { + logger.error("No RestProperty.PolicyRestProperties implementation found on classpath"); + props = new PolicyRestPropertiesImpl(); + } + } + public PolicyDecision getDecision(String serviceType, String vnfType, String bbID, String workStep, + String errorCode) { + DecisionAttributes decisionAttributes = new DecisionAttributes(); + decisionAttributes.setServiceType(serviceType); + decisionAttributes.setvNFType(vnfType); + decisionAttributes.setBbID(bbID); + decisionAttributes.setWorkStep(workStep); + decisionAttributes.setErrorCode(errorCode); + + return this.getDecision(decisionAttributes); + } + + protected PolicyDecision getDecision(DecisionAttributes decisionAttributes) { + PolicyRestClient client = new PolicyRestClient(this.props, PolicyServiceType.GET_DECISION); + PolicyDecisionRequest decisionRequest = new PolicyDecisionRequest(); + decisionRequest.setDecisionAttributes(decisionAttributes); + decisionRequest.setEcompcomponentName(RestClient.ECOMP_COMPONENT_NAME); + + return client.post(decisionRequest, PolicyDecision.class); + } + + public DictionaryData getAllowedTreatments(String bbID, String workStep) + { + PolicyRestClient client = new PolicyRestClient(this.props, PolicyServiceType.GET_DICTIONARY_ITEMS); + DictionaryItemsRequest dictionaryItemsRequest = new DictionaryItemsRequest(); + dictionaryItemsRequest.setDictionaryType("Decision"); + dictionaryItemsRequest.setDictionary("RainyDayTreatments"); + final AllowedTreatments response = client.post(dictionaryItemsRequest, AllowedTreatments.class); + final DictionaryJson dictionaryJson = response.getDictionaryJson(); + final List dictionaryDataList = dictionaryJson.getDictionaryDatas(); + for(DictionaryData dictData : dictionaryDataList){ + Bbid bBid = dictData.getBbid(); + Workstep workstep = dictData.getWorkstep(); + String bBidString = bBid.getString(); + String workstepString = workstep.getString(); + if(bbID.equals(bBidString) && workStep.equals(workstepString)){ + return dictData; + } + } + logger.error("There is no AllowedTreatments with that specified parameter set"); + return null; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java b/common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java new file mode 100644 index 0000000000..9427fa7eb9 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy; + + +import java.util.Map; +import java.util.Optional; + +import javax.ws.rs.core.UriBuilder; + +import org.onap.so.client.RestClient; +import org.onap.so.client.policy.entities.PolicyServiceType; +import org.onap.so.utils.TargetEntity; + +public class PolicyRestClient extends RestClient { + + private final PolicyRestProperties properties; + + public PolicyRestClient(PolicyRestProperties props, PolicyServiceType serviceType) { + super(props, Optional.of(UriBuilder.fromPath(serviceType.toString()).build())); + this.properties = props; + } + + @Override + public TargetEntity getTargetEntity(){ + return TargetEntity.POLICY; + } + + @Override + protected void initializeHeaderMap(Map headerMap) { + headerMap.put("ClientAuth", properties.getClientAuth()); + headerMap.put("Authorization", properties.getAuth()); + headerMap.put("Environment", properties.getEnvironment()); + } + +} \ No newline at end of file diff --git a/common/src/main/java/org/onap/so/client/policy/PolicyRestProperties.java b/common/src/main/java/org/onap/so/client/policy/PolicyRestProperties.java new file mode 100644 index 0000000000..1de6e8cd97 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/PolicyRestProperties.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy; + +import org.onap.so.client.RestProperties; + +public interface PolicyRestProperties extends RestProperties { + + public String getClientAuth(); + public String getAuth(); + public String getEnvironment(); + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/AllowedTreatments.java b/common/src/main/java/org/onap/so/client/policy/entities/AllowedTreatments.java new file mode 100644 index 0000000000..e82eca56b8 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/AllowedTreatments.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"dictionaryJson", +"dictionaryData", +"responseCode", +"responseMessage" +}) +public class AllowedTreatments{ + +@JsonProperty("dictionaryJson") +private DictionaryJson dictionaryJson; +@JsonProperty("dictionaryData") +private Object dictionaryData; +@JsonProperty("responseCode") +private Integer responseCode; +@JsonProperty("responseMessage") +private String responseMessage; + +@JsonProperty("dictionaryJson") +public DictionaryJson getDictionaryJson() { +return dictionaryJson; + } + +@JsonProperty("dictionaryJson") +public void setDictionaryJson(DictionaryJson dictionaryJson) { +this.dictionaryJson = dictionaryJson; + } + +public AllowedTreatments withDictionaryJson(DictionaryJson dictionaryJson) { +this.dictionaryJson = dictionaryJson; +return this; + } + +@JsonProperty("dictionaryData") +public Object getDictionaryData() { +return dictionaryData; + } + +@JsonProperty("dictionaryData") +public void setDictionaryData(Object dictionaryData) { +this.dictionaryData = dictionaryData; + } + +public AllowedTreatments withDictionaryData(Object dictionaryData) { +this.dictionaryData = dictionaryData; +return this; + } + +@JsonProperty("responseCode") +public Integer getResponseCode() { +return responseCode; + } + +@JsonProperty("responseCode") +public void setResponseCode(Integer responseCode) { +this.responseCode = responseCode; + } + +public AllowedTreatments withResponseCode(Integer responseCode) { +this.responseCode = responseCode; +return this; + } + +@JsonProperty("responseMessage") +public String getResponseMessage() { +return responseMessage; + } + +@JsonProperty("responseMessage") +public void setResponseMessage(String responseMessage) { +this.responseMessage = responseMessage; + } + +public AllowedTreatments withResponseMessage(String responseMessage) { +this.responseMessage = responseMessage; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/Bbid.java b/common/src/main/java/org/onap/so/client/policy/entities/Bbid.java new file mode 100644 index 0000000000..34faa7df09 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/Bbid.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"valueType", +"string", +"chars" +}) +public class Bbid { + +@JsonProperty("valueType") +private String valueType; +@JsonProperty("string") +private String string; +@JsonProperty("chars") +private String chars; + +@JsonProperty("valueType") +public String getValueType() { +return valueType; + } + +@JsonProperty("valueType") +public void setValueType(String valueType) { +this.valueType = valueType; + } + +public Bbid withValueType(String valueType) { +this.valueType = valueType; +return this; + } + +@JsonProperty("string") +public String getString() { +return string; + } + +@JsonProperty("string") +public void setString(String string) { +this.string = string; + } + +public Bbid withString(String string) { +this.string = string; +return this; + } + +@JsonProperty("chars") +public String getChars() { +return chars; + } + +@JsonProperty("chars") +public void setChars(String chars) { +this.chars = chars; + } + +public Bbid withChars(String chars) { +this.chars = chars; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/DecisionAttributes.java b/common/src/main/java/org/onap/so/client/policy/entities/DecisionAttributes.java new file mode 100644 index 0000000000..07db7d8568 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/DecisionAttributes.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy.entities; + + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "ServiceType", "VNFType", "BB_ID", "WorkStep", "ErrorCode" }) +public class DecisionAttributes { + + @JsonProperty("ServiceType") + private String serviceType; + @JsonProperty("VNFType") + private String vNFType; + @JsonProperty("BB_ID") + private String bbID; + @JsonProperty("WorkStep") + private String workStep; + @JsonProperty("ErrorCode") + private String errorCode; + + @JsonProperty("ServiceType") + public String getServiceType() { + return serviceType; + } + + @JsonProperty("ServiceType") + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + @JsonProperty("WorkStep") + public String getWorkStep() { + return workStep; + } + + @JsonProperty("WorkStep") + public void setWorkStep(String workStep) { + this.workStep = workStep; + } + + @JsonProperty("ErrorCode") + public String getErrorCode() { + return errorCode; + } + + @JsonProperty("ErrorCode") + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + @JsonProperty("VNFType") + public String getvNFType() { + return vNFType; + } + + @JsonProperty("VNFType") + public void setvNFType(String vNFType) { + this.vNFType = vNFType; + } + + @JsonProperty("BB_ID") + public String getBbID() { + return bbID; + } + + @JsonProperty("BB_ID") + public void setBbID(String bbID) { + this.bbID = bbID; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/DictionaryData.java b/common/src/main/java/org/onap/so/client/policy/entities/DictionaryData.java new file mode 100644 index 0000000000..8207999a80 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/DictionaryData.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"id", +"bbid", +"workstep", +"treatments" +}) +public class DictionaryData { + +@JsonProperty("id") +private Id id; +@JsonProperty("bbid") +private Bbid bbid; +@JsonProperty("workstep") +private Workstep workstep; +@JsonProperty("treatments") +private Treatments treatments; + +@JsonProperty("id") +public Id getId() { +return id; + } + +@JsonProperty("id") +public void setId(Id id) { +this.id = id; + } + +public DictionaryData withId(Id id) { +this.id = id; +return this; + } + +@JsonProperty("bbid") +public Bbid getBbid() { +return bbid; + } + +@JsonProperty("bbid") +public void setBbid(Bbid bbid) { +this.bbid = bbid; + } + +public DictionaryData withBbid(Bbid bbid) { +this.bbid = bbid; +return this; + } + +@JsonProperty("workstep") +public Workstep getWorkstep() { +return workstep; + } + +@JsonProperty("workstep") +public void setWorkstep(Workstep workstep) { +this.workstep = workstep; + } + +public DictionaryData withWorkstep(Workstep workstep) { +this.workstep = workstep; +return this; + } + +@JsonProperty("treatments") +public Treatments getTreatments() { +return treatments; + } + +@JsonProperty("treatments") +public void setTreatments(Treatments treatments) { +this.treatments = treatments; + } + +public DictionaryData withTreatments(Treatments treatments) { +this.treatments = treatments; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/DictionaryItemsRequest.java b/common/src/main/java/org/onap/so/client/policy/entities/DictionaryItemsRequest.java new file mode 100644 index 0000000000..8b063e83c7 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/DictionaryItemsRequest.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "dictionaryType", "dictionary" }) +public class DictionaryItemsRequest { + + @JsonProperty("dictionary") + private String dictionary; + @JsonProperty("dictionaryType") + private String dictionaryType; + + @JsonProperty("dictionary") + public String getDictionary() { + return dictionary; + } + + @JsonProperty("dictionary") + public void setDictionary(String dictionary) { + this.dictionary = dictionary; + } + + @JsonProperty("dictionaryType") + public String getDictionaryType() { + return dictionaryType; + } + + @JsonProperty("dictionaryType") + public void setDictionaryType(String dictionaryType) { + this.dictionaryType = dictionaryType; + } +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/DictionaryJson.java b/common/src/main/java/org/onap/so/client/policy/entities/DictionaryJson.java new file mode 100644 index 0000000000..097c9a5cb9 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/DictionaryJson.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy.entities; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"DictionaryDatas" +}) +public class DictionaryJson { + +@JsonProperty("DictionaryDatas") +private List dictionaryDatas = new ArrayList(); + +@JsonProperty("DictionaryDatas") +public List getDictionaryDatas() { +return dictionaryDatas; + } + +@JsonProperty("DictionaryDatas") +public void setDictionaryDatas(List dictionaryDatas) { +this.dictionaryDatas = dictionaryDatas; + } + +public DictionaryJson withDictionaryDatas(List dictionaryDatas) { +this.dictionaryDatas = dictionaryDatas; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/Id.java b/common/src/main/java/org/onap/so/client/policy/entities/Id.java new file mode 100644 index 0000000000..af164d6866 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/Id.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"integral", +"valueType" +}) +public class Id { + +@JsonProperty("integral") +private Boolean integral; +@JsonProperty("valueType") +private String valueType; + +@JsonProperty("integral") +public Boolean getIntegral() { +return integral; + } + +@JsonProperty("integral") +public void setIntegral(Boolean integral) { +this.integral = integral; + } + +public Id withIntegral(Boolean integral) { +this.integral = integral; +return this; + } + +@JsonProperty("valueType") +public String getValueType() { +return valueType; + } + +@JsonProperty("valueType") +public void setValueType(String valueType) { +this.valueType = valueType; + } + +public Id withValueType(String valueType) { +this.valueType = valueType; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/PolicyDecision.java b/common/src/main/java/org/onap/so/client/policy/entities/PolicyDecision.java new file mode 100644 index 0000000000..57c93927cb --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/PolicyDecision.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy.entities; + + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "decision", "details" }) +public class PolicyDecision { + + @JsonProperty("decision") + private String decision; + @JsonProperty("details") + private String details; + + @JsonProperty("decision") + public String getDecision() { + return decision; + } + + @JsonProperty("decision") + public void setDecision(String decision) { + this.decision = decision; + } + + @JsonProperty("details") + public String getDetails() { + return details; + } + + @JsonProperty("details") + public void setDetails(String details) { + this.details = details; + } +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/PolicyDecisionRequest.java b/common/src/main/java/org/onap/so/client/policy/entities/PolicyDecisionRequest.java new file mode 100644 index 0000000000..b402e85e32 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/PolicyDecisionRequest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy.entities; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "decisionAttributes", "ecompcomponentName" }) +public class PolicyDecisionRequest { + + @JsonProperty("decisionAttributes") + private DecisionAttributes decisionAttributes; + @JsonProperty("ecompcomponentName") + private String ecompcomponentName; + + @JsonProperty("decisionAttributes") + public DecisionAttributes getDecisionAttributes() { + return decisionAttributes; + } + + @JsonProperty("decisionAttributes") + public void setDecisionAttributes(DecisionAttributes decisionAttributes) { + this.decisionAttributes = decisionAttributes; + } + + @JsonProperty("ecompcomponentName") + public String getEcompcomponentName() { + return ecompcomponentName; + } + + @JsonProperty("ecompcomponentName") + public void setEcompcomponentName(String ecompcomponentName) { + this.ecompcomponentName = ecompcomponentName; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/PolicyServiceType.java b/common/src/main/java/org/onap/so/client/policy/entities/PolicyServiceType.java new file mode 100644 index 0000000000..83dc6b7862 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/PolicyServiceType.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy.entities; + +public enum PolicyServiceType { + GET_CONFIG("getConfig"), + SEND_EVENT("sendEvent"), + PUSH_POLICY("pushPolicy"), + CREATE_POLICY("createPolicy"), + UPDATE_POLICY("updatePolicy"), + GET_DECISION("getDecision"), + GET_METRICS("getMetrics"), + DELETE_POLICY("deletePolicy"), + LIST_CONFIG("listConfig"), + CREATE_DICTIONARY_ITEM("createDictionaryItem"), + UPDATE_DICTIONARY_ITEM("updateDictionaryItem"), + GET_DICTIONARY_ITEMS("getDictionaryItems"); + + private final String name; + + PolicyServiceType(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/Treatments.java b/common/src/main/java/org/onap/so/client/policy/entities/Treatments.java new file mode 100644 index 0000000000..433d32756c --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/Treatments.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"valueType", +"string", +"chars" +}) +public class Treatments { + +@JsonProperty("valueType") +private String valueType; +@JsonProperty("string") +private String string; +@JsonProperty("chars") +private String chars; + +@JsonProperty("valueType") +public String getValueType() { +return valueType; + } + +@JsonProperty("valueType") +public void setValueType(String valueType) { +this.valueType = valueType; + } + +public Treatments withValueType(String valueType) { +this.valueType = valueType; +return this; + } + +@JsonProperty("string") +public String getString() { +return string; + } + +@JsonProperty("string") +public void setString(String string) { +this.string = string; + } + +public Treatments withString(String string) { +this.string = string; +return this; + } + +@JsonProperty("chars") +public String getChars() { +return chars; + } + +@JsonProperty("chars") +public void setChars(String chars) { +this.chars = chars; + } + +public Treatments withChars(String chars) { +this.chars = chars; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/policy/entities/Workstep.java b/common/src/main/java/org/onap/so/client/policy/entities/Workstep.java new file mode 100644 index 0000000000..4fbd6e2f8a --- /dev/null +++ b/common/src/main/java/org/onap/so/client/policy/entities/Workstep.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy.entities; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"valueType", +"string", +"chars" +}) +public class Workstep { + +@JsonProperty("valueType") +private String valueType; +@JsonProperty("string") +private String string; +@JsonProperty("chars") +private String chars; + +@JsonProperty("valueType") +public String getValueType() { +return valueType; + } + +@JsonProperty("valueType") +public void setValueType(String valueType) { +this.valueType = valueType; + } + +public Workstep withValueType(String valueType) { +this.valueType = valueType; +return this; + } + +@JsonProperty("string") +public String getString() { +return string; + } + +@JsonProperty("string") +public void setString(String string) { +this.string = string; + } + +public Workstep withString(String string) { +this.string = string; +return this; + } + +@JsonProperty("chars") +public String getChars() { +return chars; + } + +@JsonProperty("chars") +public void setChars(String chars) { +this.chars = chars; + } + +public Workstep withChars(String chars) { +this.chars = chars; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/ruby/RubyClient.java b/common/src/main/java/org/onap/so/client/ruby/RubyClient.java new file mode 100644 index 0000000000..15b232475b --- /dev/null +++ b/common/src/main/java/org/onap/so/client/ruby/RubyClient.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.ruby; + +import java.io.IOException; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +import org.onap.so.client.dmaap.DmaapPublisher; +import org.onap.so.client.ruby.beans.Event; +import org.onap.so.client.ruby.beans.MsoRequest; +import org.onap.so.client.ruby.beans.Ruby; +import org.onap.so.client.ruby.dmaap.RubyCreateTicketRequestPublisher; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + + +public class RubyClient { + + private static final String REQUEST_CLIENT_NAME = "MSO"; + private static final String ACTION = "Create Ticket"; + + protected String buildRequest(String requestId, String sourceName, String reason, String workflowId, String notification) throws JsonProcessingException { + final MsoRequest request = new MsoRequest(); + request.withRequestClientName(REQUEST_CLIENT_NAME) + .withRequestId(requestId) + .withSourceName(sourceName) + .withWorkflowId(workflowId) + .withAction(ACTION); + + request.withRequestTime(this.getTime()); + + if(reason.length() <= 255){ + request.withReason(reason); + } else { + throw new IllegalArgumentException("reason exceeds 255 characters"); + } + if(notification.length() <= 1024){ + request.withNotification(notification); + } else { + throw new IllegalArgumentException("notification exceeds 1024 characters"); + } + final Event event = new Event(); + event.setMsoRequest(request); + final Ruby ruby = new Ruby(); + ruby.setEvent(event); + return this.getJson(ruby); + } + + protected String getJson(Ruby obj) throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(obj); + } + + protected DmaapPublisher getPublisher() throws IOException { + return new RubyCreateTicketRequestPublisher(); + } + + protected String getTime() { + final ZonedDateTime currentDateTime = ZonedDateTime.now(ZoneOffset.UTC); + final DateTimeFormatter format = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss Z"); + return currentDateTime.format(format); + } + + public void rubyCreateTicketCheckRequest(String requestId, String sourceName, String reason, String workflowId, String notification) throws Exception { + String request = this.buildRequest(requestId, sourceName, reason, workflowId, notification); + final DmaapPublisher publisher = this.getPublisher(); + publisher.send(request); + } +} diff --git a/common/src/main/java/org/onap/so/client/ruby/beans/Event.java b/common/src/main/java/org/onap/so/client/ruby/beans/Event.java new file mode 100644 index 0000000000..93745ff55e --- /dev/null +++ b/common/src/main/java/org/onap/so/client/ruby/beans/Event.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.ruby.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"msoRequest" +}) +public class Event { + +@JsonProperty("msoRequest") +private MsoRequest msoRequest; + +/** +* No args constructor for use in serialization +* +*/ +public Event() { + } + +/** +* +* @param msoRequest +*/ +public Event(MsoRequest msoRequest) { +super(); +this.msoRequest = msoRequest; + } + +@JsonProperty("msoRequest") +public MsoRequest getMsoRequest() { +return msoRequest; + } + +@JsonProperty("msoRequest") +public void setMsoRequest(MsoRequest msoRequest) { +this.msoRequest = msoRequest; + } + +public Event withMsoRequest(MsoRequest msoRequest) { +this.msoRequest = msoRequest; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/ruby/beans/MsoRequest.java b/common/src/main/java/org/onap/so/client/ruby/beans/MsoRequest.java new file mode 100644 index 0000000000..f2c004ea6e --- /dev/null +++ b/common/src/main/java/org/onap/so/client/ruby/beans/MsoRequest.java @@ -0,0 +1,207 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.ruby.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"requestClientName", +"requestId", +"requestTime", +"sourceName", +"reason", +"action", +"workflowId", +"notification" +}) +public class MsoRequest { + +@JsonProperty("requestClientName") +private String requestClientName; +@JsonProperty("requestId") +private String requestId; +@JsonProperty("requestTime") +private String requestTime; +@JsonProperty("sourceName") +private String sourceName; +@JsonProperty("reason") +private String reason; +@JsonProperty("action") +private String action; +@JsonProperty("workflowId") +private String workflowId; +@JsonProperty("notification") +private String notification; + +/** +* No args constructor for use in serialization +* +*/ +public MsoRequest() { + } + +/** +* +* @param requestClientName +* @param requestTime +* @param reason +* @param requestId +* @param workflowId +* @param sourceName +* @param action +* @param notification +*/ +public MsoRequest(String requestClientName, String requestId, String requestTime, String sourceName, String reason, String action, String workflowId, String notification) { +super(); +this.requestClientName = requestClientName; +this.requestId = requestId; +this.requestTime = requestTime; +this.sourceName = sourceName; +this.reason = reason; +this.action = action; +this.workflowId = workflowId; +this.notification = notification; + } + +@JsonProperty("requestClientName") +public String getRequestClientName() { +return requestClientName; + } + +@JsonProperty("requestClientName") +public void setRequestClientName(String requestClientName) { +this.requestClientName = requestClientName; + } + +public MsoRequest withRequestClientName(String requestClientName) { +this.requestClientName = requestClientName; +return this; + } + +@JsonProperty("requestId") +public String getRequestId() { +return requestId; + } + +@JsonProperty("requestId") +public void setRequestId(String requestId) { +this.requestId = requestId; + } + +public MsoRequest withRequestId(String requestId) { +this.requestId = requestId; +return this; + } + +@JsonProperty("requestTime") +public String getRequestTime() { +return requestTime; + } + +@JsonProperty("requestTime") +public void setRequestTime(String requestTime) { +this.requestTime = requestTime; + } + +public MsoRequest withRequestTime(String requestTime) { +this.requestTime = requestTime; +return this; + } + +@JsonProperty("sourceName") +public String getSourceName() { +return sourceName; + } + +@JsonProperty("sourceName") +public void setSourceName(String sourceName) { +this.sourceName = sourceName; + } + +public MsoRequest withSourceName(String sourceName) { +this.sourceName = sourceName; +return this; + } + +@JsonProperty("reason") +public String getReason() { +return reason; + } + +@JsonProperty("reason") +public void setReason(String reason) { +this.reason = reason; + } + +public MsoRequest withReason(String reason) { +this.reason = reason; +return this; + } + +@JsonProperty("action") +public String getAction() { +return action; + } + +@JsonProperty("action") +public void setAction(String action) { +this.action = action; + } + +public MsoRequest withAction(String action) { +this.action = action; +return this; + } + +@JsonProperty("workflowId") +public String getWorkflowId() { +return workflowId; + } + +@JsonProperty("workflowId") +public void setWorkflowId(String workflowId) { +this.workflowId = workflowId; + } + +public MsoRequest withWorkflowId(String workflowId) { +this.workflowId = workflowId; +return this; + } + +@JsonProperty("notification") +public String getNotification() { +return notification; + } + +@JsonProperty("notification") +public void setNotification(String notification) { +this.notification = notification; + } + +public MsoRequest withNotification(String notification) { +this.notification = notification; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/ruby/beans/Ruby.java b/common/src/main/java/org/onap/so/client/ruby/beans/Ruby.java new file mode 100644 index 0000000000..725e6a3a94 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/ruby/beans/Ruby.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.ruby.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"event" +}) +public class Ruby { + +@JsonProperty("event") +private Event event; + +/** +* No args constructor for use in serialization +* +*/ +public Ruby() { + } + +/** +* +* @param event +*/ +public Ruby(Event event) { +super(); +this.event = event; + } + +@JsonProperty("event") +public Event getEvent() { +return event; + } + +@JsonProperty("event") +public void setEvent(Event event) { +this.event = event; + } + +public Ruby withEvent(Event event) { +this.event = event; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java b/common/src/main/java/org/onap/so/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java new file mode 100644 index 0000000000..1d4e014300 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.ruby.dmaap; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Optional; + +import org.onap.so.client.dmaap.DmaapPublisher; + +public class RubyCreateTicketRequestPublisher extends DmaapPublisher{ + public RubyCreateTicketRequestPublisher() throws FileNotFoundException, IOException { + super(); + } + + @Override + public String getUserName() { + return msoProperties.get("ruby.create-ticket-request.dmaap.username"); + } + + @Override + public String getPassword() { + return msoProperties.get("ruby.create-ticket-request.dmaap.password"); + } + + @Override + public String getTopic() { + return msoProperties.get("ruby.create-ticket-request.publisher.topic"); + } + + @Override + public Optional getHost() { + return Optional.ofNullable(msoProperties.get("ruby.create-ticket-request.publisher.host")); + } + +} + + diff --git a/common/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java b/common/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java new file mode 100644 index 0000000000..93a35f34b0 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java @@ -0,0 +1,158 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import org.onap.so.client.dmaap.DmaapConsumer; +import org.onap.so.client.dmaap.DmaapPublisher; +import org.onap.so.client.sdno.beans.AAIParamList; +import org.onap.so.client.sdno.beans.Body; +import org.onap.so.client.sdno.beans.Input; +import org.onap.so.client.sdno.beans.RequestHdCustom; +import org.onap.so.client.sdno.beans.SDNO; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapPublisher; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class SDNOHealthCheckClient { + + private static final String NODE_TYPE = "VROUTER"; + private static final String API_OPERATION_TYPE = "health-diagnostic-custom"; + private static final String MIRRORING_CHECK = "mirroring_check"; + private static final String CLIENT_NAME = "MSO"; + private static final String PRE_CHECK_CODE = "VROUTER000003"; + private static final String POST_CHECK_CODE = "VROUTER000004"; + private static final String LPORT_MIRRORING_CHECK = "lport_mirroring_check"; + private static final String CONFIGURATION_ID = "configuration-id"; + + + public boolean lPortMirrorHealthPreCheck(String userId, String requestId, OptionalclliCode, String configurationId, String interfaceId) throws Exception{ + String request = buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId); + return this.execute(requestId, request); + } + + public boolean lPortMirrorHealthPostCheck(String userId, String requestId, OptionalclliCode, String configurationId, String interfaceId) throws Exception{ + String request = buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId); + return this.execute(requestId, request); + } + + public boolean portMirrorHealthPreCheck(String userId, String requestId, Optional clliCode, String configurationId) throws Exception { + final String request = this.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId); + return this.execute(requestId, request); + } + + public boolean portMirrorHealthPostCheck(String userId, String requestId, Optional clliCode, String configurationId) throws Exception { + final String request = this.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId); + return this.execute(requestId, request); + } + + protected String buildLPortMirrorCheckPreRequest(String userId, String requestId, Optional clliCode, String configurationId, String interfaceId) throws JsonProcessingException{ + return this.buildLPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, interfaceId, PRE_CHECK_CODE); + } + + protected String buildLPortMirrorCheckPostRequest(String userId, String requestId, Optional clliCode, String configurationId, String interfaceId) throws JsonProcessingException{ + return this.buildLPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, interfaceId, POST_CHECK_CODE); + } + + protected String buildPortMirrorPreCheckRequest(String userId, String requestId, Optional clliCode, String configurationId) throws JsonProcessingException { + return this.buildPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, PRE_CHECK_CODE); + } + + protected String buildPortMirrorPostCheckRequest(String userId, String requestId, Optional clliCode, String configurationId) throws JsonProcessingException { + return this.buildPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, POST_CHECK_CODE); + } + + protected String buildPortMirrorCheckRequest(String userId, String requestId, Optional clliCode, String configurationId, String diagnosticCode) throws JsonProcessingException { + final AAIParamList list = new AAIParamList(); + list.setKey(CONFIGURATION_ID); + list.setValue(configurationId); + + return this.buildRequest(userId, requestId, clliCode, diagnosticCode, MIRRORING_CHECK, Collections.singletonList(list)); + } + + protected String buildLPortMirrorCheckRequest(String userId, String requestId, Optional clliCode, String configurationId, String interfaceId, String diagnosticCode) throws JsonProcessingException { + + final AAIParamList configurationIdParam = new AAIParamList(); + configurationIdParam.setKey(CONFIGURATION_ID); + configurationIdParam.setValue(configurationId); + final AAIParamList interfaceIdParam = new AAIParamList(); + interfaceIdParam.setKey("interface-id"); + interfaceIdParam.setValue(interfaceId); + final List list = new ArrayList<>(); + list.add(configurationIdParam); + list.add(interfaceIdParam); + return this.buildRequest(userId, requestId, clliCode, diagnosticCode, LPORT_MIRRORING_CHECK, list); + } + + + protected String buildRequest(String userId, String requestId, Optional clliCode, String diagnosticCode, String operationType, List paramList) throws JsonProcessingException { + + final RequestHdCustom hdCustom = new RequestHdCustom(); + hdCustom.withRequestUserId(userId) + .withRequestId(requestId) + .withRequestClientName(CLIENT_NAME) + .withHealthDiagnosticCode(diagnosticCode) + .withOperationType(operationType) + .withAaiParamList(paramList); + + final Input input = new Input(); + input.setRequestHdCustom(hdCustom); + final Body body = new Body(); + body.setInput(input); + final SDNO request = new SDNO(); + request.withBody(body).withOperation(API_OPERATION_TYPE).withNodeType(NODE_TYPE); + if (clliCode.isPresent()) { + request.setNodeLoc(clliCode.get()); + } + return this.getJson(request); + + } + protected String getJson(SDNO obj) throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(obj); + } + + protected DmaapPublisher getPublisher() throws FileNotFoundException, IOException { + return new SDNOHealthCheckDmaapPublisher(); + } + + protected DmaapConsumer getConsumer(String requestId) throws FileNotFoundException, IOException { + return new SDNOHealthCheckDmaapConsumer(requestId); + } + + protected boolean execute(String requestId, String request) throws Exception { + final DmaapPublisher publisher = this.getPublisher(); + publisher.send(request); + + final DmaapConsumer consumer = this.getConsumer(requestId); + + return consumer.consume(); + } + +} diff --git a/common/src/main/java/org/onap/so/client/sdno/SDNOValidator.java b/common/src/main/java/org/onap/so/client/sdno/SDNOValidator.java new file mode 100644 index 0000000000..f3cab1e3e8 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/sdno/SDNOValidator.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno; + +import java.io.IOException; +import java.util.UUID; + +import org.onap.aai.domain.yang.GenericVnf; + +public interface SDNOValidator { + + /** + * Issues a health diagnostic request for a given vnf to SDN-O + * + * @param vnfId + * @param uuid + * @param requestingUserId + * @return diagnostic result + * @throws IOException + * @throws Exception + */ + public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception; + + + /** + * Issues a health diagnostic request for a given GenericVnf to SDN-O + * + * @param genericVnf + * @param uuid + * @param requestingUserId + * @return diagnostic result + * @throws IOException + * @throws Exception + */ + public boolean healthDiagnostic(GenericVnf genericVnf, UUID uuid, String requestingUserId) throws IOException, Exception; + +} diff --git a/common/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java b/common/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java new file mode 100644 index 0000000000..be79c8b927 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Optional; +import java.util.UUID; + +import javax.ws.rs.NotFoundException; + +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.AAIVersion; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.dmaap.DmaapConsumer; +import org.onap.so.client.dmaap.DmaapPublisher; +import org.onap.so.client.sdno.beans.Body; +import org.onap.so.client.sdno.beans.Input; +import org.onap.so.client.sdno.beans.RequestHealthDiagnostic; +import org.onap.so.client.sdno.beans.SDNO; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapPublisher; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class SDNOValidatorImpl implements SDNOValidator { + + private final static String clientName = "MSO"; + + @Override + public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception { + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourcesClient client = new AAIResourcesClient(AAIVersion.V10); + GenericVnf vnf = client.get(GenericVnf.class, uri).orElseThrow(() -> new NotFoundException(vnfId + " not found in A&AI")); + + SDNO requestDiagnostic = buildRequestDiagnostic(vnf, uuid, requestingUserId); + ObjectMapper mapper = new ObjectMapper(); + String json = mapper.writeValueAsString(requestDiagnostic); + this.submitRequest(json); + boolean status = this.pollForResponse(uuid.toString()); + return status; + } + + @Override + public boolean healthDiagnostic(GenericVnf genericVnf, UUID uuid, String requestingUserId) throws IOException, Exception { + + SDNO requestDiagnostic = buildRequestDiagnostic(genericVnf, uuid, requestingUserId); + ObjectMapper mapper = new ObjectMapper(); + String json = mapper.writeValueAsString(requestDiagnostic); + this.submitRequest(json); + boolean status = this.pollForResponse(uuid.toString()); + return status; + } + + protected SDNO buildRequestDiagnostic(GenericVnf vnf, UUID uuid, String requestingUserId) { + + Optional vnfType; + if (vnf.getVnfType() == null) { + vnfType = Optional.empty(); + } else { + vnfType = Optional.of(vnf.getVnfType()); + } + Input input = new Input(); + SDNO parentRequest = new SDNO(); + Body body = new Body(); + parentRequest.setBody(body); + parentRequest.setNodeType(vnfType.orElse("NONE").toUpperCase()); + parentRequest.setOperation("health-diagnostic"); + + body.setInput(input); + + RequestHealthDiagnostic request = new RequestHealthDiagnostic(); + + request.setRequestClientName(clientName); + request.setRequestNodeName(vnf.getVnfName()); + request.setRequestNodeUuid(vnf.getVnfId()); + request.setRequestNodeIp(vnf.getIpv4OamAddress()); //generic-vnf oam ip + request.setRequestUserId(requestingUserId); //mech id? + request.setRequestId(uuid.toString()); //something to identify this request by for polling + + input.setRequestHealthDiagnostic(request); + + return parentRequest; + } + protected void submitRequest(String json) throws FileNotFoundException, IOException, InterruptedException { + + DmaapPublisher publisher = new SDNOHealthCheckDmaapPublisher(); + publisher.send(json); + } + protected boolean pollForResponse(String uuid) throws Exception { + DmaapConsumer consumer = this.getConsumer(uuid); + return consumer.consume(); + } + + + + protected DmaapConsumer getConsumer(String uuid) throws FileNotFoundException, IOException { + return new SDNOHealthCheckDmaapConsumer(uuid); + } + + + +} diff --git a/common/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java b/common/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java new file mode 100644 index 0000000000..0de9b90d66 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"key", +"value" +}) +public class AAIParamList { + +@JsonProperty("key") +private String key; +@JsonProperty("value") +private String value; + +/** +* No args constructor for use in serialization +* +*/ +public AAIParamList() { + } + +/** +* +* @param value +* @param key +*/ +public AAIParamList(String key, String value) { +super(); +this.key = key; +this.value = value; + } + +@JsonProperty("key") +public String getKey() { +return key; + } + +@JsonProperty("key") +public void setKey(String key) { +this.key = key; + } + +public AAIParamList withKey(String key) { +this.key = key; +return this; + } + +@JsonProperty("value") +public String getValue() { +return value; + } + +@JsonProperty("value") +public void setValue(String value) { +this.value = value; + } + +public AAIParamList withValue(String value) { +this.value = value; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/sdno/beans/Body.java b/common/src/main/java/org/onap/so/client/sdno/beans/Body.java new file mode 100644 index 0000000000..dfca9ec124 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/sdno/beans/Body.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno.beans; + +import java.io.Serializable; +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({ + "input" +}) +public class Body implements Serializable +{ + + @JsonProperty("input") + private Input input; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 9101706044452851559L; + + @JsonProperty("input") + public Input getInput() { + return input; + } + + @JsonProperty("input") + public void setInput(Input input) { + this.input = input; + } + + public Body withInput(Input input) { + this.input = input; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } + + public Body withAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/sdno/beans/Input.java b/common/src/main/java/org/onap/so/client/sdno/beans/Input.java new file mode 100644 index 0000000000..e565f71445 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/sdno/beans/Input.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno.beans; + +import java.io.Serializable; +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({ + "request-healthdiagnostic", + "request-hd-custom" +}) +public class Input implements Serializable +{ + + @JsonProperty("request-healthdiagnostic") + private RequestHealthDiagnostic RequestHealthDiagnostic; + @JsonProperty("request-hd-custom") + private RequestHdCustom requestHdCustom; + + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 7155546785389227528L; + + @JsonProperty("request-healthdiagnostic") + public RequestHealthDiagnostic getRequestHealthDiagnostic() { + return RequestHealthDiagnostic; + } + + @JsonProperty("request-healthdiagnostic") + public void setRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { + this.RequestHealthDiagnostic = RequestHealthDiagnostic; + } + + @JsonProperty("request-hd-custom") + public RequestHdCustom getRequestHdCustom() { + return requestHdCustom; + } + + @JsonProperty("request-hd-custom") + public void setRequestHdCustom(RequestHdCustom requestHdCustom) { + this.requestHdCustom = requestHdCustom; + } + + public Input withRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { + this.RequestHealthDiagnostic = RequestHealthDiagnostic; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } + + public Input withAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java b/common/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java new file mode 100644 index 0000000000..b3a6a4815e --- /dev/null +++ b/common/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java @@ -0,0 +1,191 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno.beans; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"request-client-name", +"request-user-id", +"request-id", +"health-diagnostic-code", +"operation-type", +"send-detailed-cmd-response", +"aai-param-list" +}) +public class RequestHdCustom implements Serializable { + +/** + * + */ + private static final long serialVersionUID = -206110458275127710L; +@JsonProperty("request-client-name") +private String requestClientName; +@JsonProperty("request-user-id") +private String requestUserId; +@JsonProperty("request-id") +private String requestId; +@JsonProperty("health-diagnostic-code") +private String healthDiagnosticCode; +@JsonProperty("operation-type") +private String operationType; +@JsonProperty("send-detailed-cmd-response") +private String sendDetailedCmdResponse = "false"; +@JsonProperty("aai-param-list") +private List aaiParamList = new ArrayList(); + +/** +* No args constructor for use in serialization +* +*/ +public RequestHdCustom() { + } + +/** +* +* @param requestClientName +* @param operationType +* @param requestId +* @param healthDiagnosticCode +* @param aaiParamList +* @param requestUserId +*/ +public RequestHdCustom(String requestClientName, String requestUserId, String requestId, String healthDiagnosticCode, String operationType, List aaiParamList) { +super(); +this.requestClientName = requestClientName; +this.requestUserId = requestUserId; +this.requestId = requestId; +this.healthDiagnosticCode = healthDiagnosticCode; +this.operationType = operationType; +this.aaiParamList = aaiParamList; + } + +@JsonProperty("request-client-name") +public String getRequestClientName() { +return requestClientName; + } + +@JsonProperty("request-client-name") +public void setRequestClientName(String requestClientName) { +this.requestClientName = requestClientName; + } + +public RequestHdCustom withRequestClientName(String requestClientName) { +this.requestClientName = requestClientName; +return this; + } + +@JsonProperty("request-user-id") +public String getRequestUserId() { +return requestUserId; + } + +@JsonProperty("request-user-id") +public void setRequestUserId(String requestUserId) { +this.requestUserId = requestUserId; + } + +public RequestHdCustom withRequestUserId(String requestUserId) { +this.requestUserId = requestUserId; +return this; + } + +@JsonProperty("request-id") +public String getRequestId() { +return requestId; + } + +@JsonProperty("request-id") +public void setRequestId(String requestId) { +this.requestId = requestId; + } + +public RequestHdCustom withRequestId(String requestId) { +this.requestId = requestId; +return this; + } + +@JsonProperty("health-diagnostic-code") +public String getHealthDiagnosticCode() { +return healthDiagnosticCode; + } + +@JsonProperty("health-diagnostic-code") +public void setHealthDiagnosticCode(String healthDiagnosticCode) { +this.healthDiagnosticCode = healthDiagnosticCode; + } + +public RequestHdCustom withHealthDiagnosticCode(String healthDiagnosticCode) { +this.healthDiagnosticCode = healthDiagnosticCode; +return this; + } + +@JsonProperty("operation-type") +public String getOperationType() { +return operationType; + } + +@JsonProperty("operation-type") +public void setOperationType(String operationType) { +this.operationType = operationType; + } + +public RequestHdCustom withOperationType(String operationType) { +this.operationType = operationType; +return this; + } + +public void setSendDetailedCmdResponse(String sendDetailedCmdResponse) { + this.sendDetailedCmdResponse = sendDetailedCmdResponse; +} + +public String getSendDetailedCmdResponse() { + return sendDetailedCmdResponse; +} + +public RequestHdCustom withSendDetailedCmdResponse(String sendDetailedCmdResponse) { + this.sendDetailedCmdResponse = sendDetailedCmdResponse; + return this; +} + +@JsonProperty("aai-param-list") +public List getAaiParamList() { +return aaiParamList; + } + +@JsonProperty("aai-param-list") +public void setAaiParamList(List aaiParamList) { +this.aaiParamList = aaiParamList; + } + +public RequestHdCustom withAaiParamList(List aaiParamList) { +this.aaiParamList = aaiParamList; +return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java b/common/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java new file mode 100644 index 0000000000..69745d6bfb --- /dev/null +++ b/common/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java @@ -0,0 +1,207 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno.beans; + +import java.io.Serializable; +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({ + "request-client-name", + "request-node-name", + "request-node-uuid", + "request-node-ip", + "request-id", + "request-user-id", + "request-node-type", + "health-diagnostic-code" +}) +public class RequestHealthDiagnostic implements Serializable +{ + + @JsonProperty("request-client-name") + private String requestClientName; + @JsonProperty("request-node-name") + private String requestNodeName; + @JsonProperty("request-node-uuid") + private String requestNodeUuid; + @JsonProperty("request-node-ip") + private String requestNodeIp; + @JsonProperty("request-id") + private String requestId; + @JsonProperty("request-user-id") + private String requestUserId; + @JsonProperty("request-node-type") + private String requestNodeType; + @JsonProperty("health-diagnostic-code") + private String healthDiagnosticCode; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = 1166788526178388021L; + + @JsonProperty("request-client-name") + public String getRequestClientName() { + return requestClientName; + } + + @JsonProperty("request-client-name") + public void setRequestClientName(String requestClientName) { + this.requestClientName = requestClientName; + } + + public RequestHealthDiagnostic withRequestClientName(String requestClientName) { + this.requestClientName = requestClientName; + return this; + } + + @JsonProperty("request-node-name") + public String getRequestNodeName() { + return requestNodeName; + } + + @JsonProperty("request-node-name") + public void setRequestNodeName(String requestNodeName) { + this.requestNodeName = requestNodeName; + } + + public RequestHealthDiagnostic withRequestNodeName(String requestNodeName) { + this.requestNodeName = requestNodeName; + return this; + } + + @JsonProperty("request-node-uuid") + public String getRequestNodeUuid() { + return requestNodeUuid; + } + + @JsonProperty("request-node-uuid") + public void setRequestNodeUuid(String requestNodeUuid) { + this.requestNodeUuid = requestNodeUuid; + } + + public RequestHealthDiagnostic withRequestNodeUuid(String requestNodeUuid) { + this.requestNodeUuid = requestNodeUuid; + return this; + } + + @JsonProperty("request-node-ip") + public String getRequestNodeIp() { + return requestNodeIp; + } + + @JsonProperty("request-node-ip") + public void setRequestNodeIp(String requestNodeIp) { + this.requestNodeIp = requestNodeIp; + } + + public RequestHealthDiagnostic withRequestNodeIp(String requestNodeIp) { + this.requestNodeIp = requestNodeIp; + return this; + } + + @JsonProperty("request-id") + public String getRequestId() { + return requestId; + } + + @JsonProperty("request-id") + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public RequestHealthDiagnostic withRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + @JsonProperty("request-user-id") + public String getRequestUserId() { + return requestUserId; + } + + @JsonProperty("request-user-id") + public void setRequestUserId(String requestUserId) { + this.requestUserId = requestUserId; + } + + public RequestHealthDiagnostic withRequestUserId(String requestUserId) { + this.requestUserId = requestUserId; + return this; + } + + @JsonProperty("request-node-type") + public String getRequestNodeType() { + return requestNodeType; + } + + @JsonProperty("request-node-type") + public void setRequestNodeType(String requestNodeType) { + this.requestNodeType = requestNodeType; + } + + public RequestHealthDiagnostic withRequestNodeType(String requestNodeType) { + this.requestNodeType = requestNodeType; + return this; + } + + @JsonProperty("health-diagnostic-code") + public String getHealthDiagnosticCode() { + return healthDiagnosticCode; + } + + @JsonProperty("health-diagnostic-code") + public void setHealthDiagnosticCode(String healthDiagnosticCode) { + this.healthDiagnosticCode = healthDiagnosticCode; + } + + public RequestHealthDiagnostic withHealthDiagnosticCode(String healthDiagnosticCode) { + this.healthDiagnosticCode = healthDiagnosticCode; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } + + public RequestHealthDiagnostic withAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java b/common/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java new file mode 100644 index 0000000000..7cf9c7cb06 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java @@ -0,0 +1,119 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno.beans; + +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({ +"client-name", +"code", +"processing-host", +"request-id", +"status" +}) +public class ResultInfo { + +@JsonProperty("client-name") +private String clientName; +@JsonProperty("code") +private String code; +@JsonProperty("processing-host") +private String processingHost; +@JsonProperty("request-id") +private String requestId; +@JsonProperty("status") +private String status; +@JsonIgnore +private Map additionalProperties = new HashMap(); + +@JsonProperty("client-name") +public String getClientName() { +return clientName; +} + +@JsonProperty("client-name") +public void setClientName(String clientName) { +this.clientName = clientName; +} + +@JsonProperty("code") +public String getCode() { +return code; +} + +@JsonProperty("code") +public void setCode(String code) { +this.code = code; +} + +@JsonProperty("processing-host") +public String getProcessingHost() { +return processingHost; +} + +@JsonProperty("processing-host") +public void setProcessingHost(String processingHost) { +this.processingHost = processingHost; +} + +@JsonProperty("request-id") +public String getRequestId() { +return requestId; +} + +@JsonProperty("request-id") +public void setRequestId(String requestId) { +this.requestId = requestId; +} + +@JsonProperty("status") +public String getStatus() { +return status; +} + +@JsonProperty("status") +public void setStatus(String status) { +this.status = status; +} + +@JsonAnyGetter +public Map getAdditionalProperties() { +return this.additionalProperties; +} + +@JsonAnySetter +public void setAdditionalProperty(String name, Object value) { +this.additionalProperties.put(name, value); +} + +public void setAdditionalProperties(Map map) { +this.additionalProperties = map; +} +} diff --git a/common/src/main/java/org/onap/so/client/sdno/beans/SDNO.java b/common/src/main/java/org/onap/so/client/sdno/beans/SDNO.java new file mode 100644 index 0000000000..7c728a7bab --- /dev/null +++ b/common/src/main/java/org/onap/so/client/sdno/beans/SDNO.java @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno.beans; + +import java.io.Serializable; +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({ + "operation", + "nodeLoc", + "nodeType", + "body" +}) +public class SDNO implements Serializable +{ + + @JsonProperty("operation") + private String operation; + @JsonProperty("nodeLoc") + private String nodeLoc; + @JsonProperty("nodeType") + private String nodeType; + @JsonProperty("body") + private Body body; + @JsonIgnore + private Map additionalProperties = new HashMap(); + private final static long serialVersionUID = -5303297382564282650L; + + @JsonProperty("operation") + public String getOperation() { + return operation; + } + + @JsonProperty("operation") + public void setOperation(String operation) { + this.operation = operation; + } + + @JsonProperty("nodeLoc") + public String getNodeLoc() { + return nodeLoc; + } + + @JsonProperty("nodeLoc") + public void setNodeLoc(String nodeLoc) { + this.nodeLoc = nodeLoc; + } + + public SDNO withNodeLoc(String nodeLoc) { + this.nodeLoc = nodeLoc; + return this; + } + + public SDNO withOperation(String operation) { + this.operation = operation; + return this; + } + + @JsonProperty("nodeType") + public String getNodeType() { + return nodeType; + } + + @JsonProperty("nodeType") + public void setNodeType(String nodeType) { + this.nodeType = nodeType; + } + + public SDNO withNodeType(String nodeType) { + this.nodeType = nodeType; + return this; + } + + @JsonProperty("body") + public Body getBody() { + return body; + } + + @JsonProperty("body") + public void setBody(Body body) { + this.body = body; + } + + public SDNO withBody(Body body) { + this.body = body; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } + + public SDNO SDNO (String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + +} diff --git a/common/src/main/java/org/onap/so/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java b/common/src/main/java/org/onap/so/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java new file mode 100644 index 0000000000..6f415af8b0 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java @@ -0,0 +1,159 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno.dmaap; + +import java.io.IOException; +import java.util.Optional; +import org.onap.so.client.dmaap.DmaapConsumer; +import org.onap.so.client.exceptions.SDNOException; +import org.onap.so.jsonpath.JsonPathUtil; + +public class SDNOHealthCheckDmaapConsumer extends DmaapConsumer { + + private final String uuid; + private boolean continuePolling = true; + private final static String healthDiagnosticPath = "body.output.*"; + + public SDNOHealthCheckDmaapConsumer() throws IOException { + this("none"); + } + + public SDNOHealthCheckDmaapConsumer(String uuid) throws IOException { + super(); + this.uuid = uuid; + } + + @Override + public String getUserName() { + return msoProperties.get("sdno.health-check.dmaap.username"); + } + + @Override + public String getPassword() { + return msoProperties.get("sdno.health-check.dmaap.password"); + } + + @Override + public String getTopic() { + return msoProperties.get("sdno.health-check.dmaap.subscriber.topic"); + } + + @Override + public Optional getHost() { + return Optional.ofNullable(msoProperties.get("sdno.health-check.dmaap.subscriber.host")); + } + + @Override + public boolean continuePolling() { + return continuePolling; + } + + @Override + public void stopProcessingMessages() { + continuePolling = false; + } + @Override + public void processMessage(String message) throws Exception { + if (isHealthDiagnostic(message, this.getRequestId())) { + if (!healthDiagnosticSuccessful(message)) { + Optional statusMessage = this.getStatusMessage(message); + if (statusMessage.isPresent()) { + throw new SDNOException("failed with message " + statusMessage.get()); + } else { + throw new SDNOException("failed with no status message"); + } + } else { + logger.info("successful health diagnostic found for request: {}" ,getRequestId()); + stopProcessingMessages(); + } + } + } + + @Override + public boolean isAccepted(String message) { + if (isResultInfo(message)) { + Optional code = isAccepted(message, this.getRequestId()); + if (code.isPresent()) { + if ("202".equals(code.get())) { + return true; + } else { + //TODO check other statuses 400 and 500 + } + } else { + //TODO throw error + } + } + + return false; + } + + @Override + public boolean isFailure(String message) { + if (isResultInfo(message)) { + Optional code = isFailure(message, this.getRequestId()); + if (code.isPresent()) { + if ("500".equals(code.get())) { + return true; + } else { + //TODO check other statuses 400 and 500 + } + } else { + //TODO throw error + } + } + + return false; + } + + @Override + public String getRequestId() { + return uuid; + } + + protected Optional isAccepted(String json, String uuid) { + return JsonPathUtil.getInstance().locateResult(json, String.format("$.result-info[?(@.status=='ACCEPTED' && @.request-id=='%s')].code", uuid)); + } + + protected Optional isFailure(String json, String uuid) { + return JsonPathUtil.getInstance().locateResult(json, String.format("$.result-info[?(@.status=='FAILURE' && @.request-id=='%s')].code", uuid)); + } + + protected boolean isResultInfo(String json) { + return JsonPathUtil.getInstance().pathExists(json, "$[?(@.result-info)]"); + } + + protected boolean isHealthDiagnostic(String json, String uuid) { + return JsonPathUtil.getInstance().pathExists(json, String.format("$[?(@.result-info.request-id=='%s')].%s", uuid, healthDiagnosticPath)); + } + + protected boolean healthDiagnosticSuccessful(String json) { + return JsonPathUtil.getInstance().pathExists(json, "$." + healthDiagnosticPath + "[?(@.response-status=='Success')]"); + } + + protected Optional getStatusMessage(String json) { + return JsonPathUtil.getInstance().locateResult(json, "$." + healthDiagnosticPath + ".error-message"); + } + + @Override + public int getMaximumElapsedTime() { + return 300000; + } +} diff --git a/common/src/main/java/org/onap/so/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java b/common/src/main/java/org/onap/so/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java new file mode 100644 index 0000000000..2556e67e3c --- /dev/null +++ b/common/src/main/java/org/onap/so/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno.dmaap; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Optional; + +import org.onap.so.client.dmaap.DmaapPublisher; + +public class SDNOHealthCheckDmaapPublisher extends DmaapPublisher { + + public SDNOHealthCheckDmaapPublisher() throws FileNotFoundException, IOException { + super(); + } + + @Override + public String getUserName() { + return msoProperties.get("sdno.health-check.dmaap.username"); + } + + @Override + public String getPassword() { + return msoProperties.get("sdno.health-check.dmaap.password"); + } + + @Override + public String getTopic() { + return msoProperties.get("sdno.health-check.dmaap.publisher.topic"); + } + + @Override + public Optional getHost() { + return Optional.ofNullable(msoProperties.get("sdno.health-check.dmaap.publisher.host")); + } + +} diff --git a/common/src/main/java/org/onap/so/entity/MsoRequest.java b/common/src/main/java/org/onap/so/entity/MsoRequest.java new file mode 100644 index 0000000000..c61684bec7 --- /dev/null +++ b/common/src/main/java/org/onap/so/entity/MsoRequest.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.entity; + + +import java.io.Serializable; + +/** + * This simple bean holds tracking information for MSO requests within + * the adapters. This tracking information should be added to logs, + * metrics, alarms as appropriate. + * + * + */ +public class MsoRequest implements Serializable +{ + private static final long serialVersionUID = 1797142528913733469L; + private String requestId; + private String serviceInstanceId; + + public MsoRequest() { + this.requestId = null; + this.serviceInstanceId = null; + } + + public MsoRequest(String r, String s) { + this.requestId = r; + this.serviceInstanceId = s; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } +} diff --git a/common/src/main/java/org/onap/so/entity/package-info.java b/common/src/main/java/org/onap/so/entity/package-info.java new file mode 100644 index 0000000000..c4f5a16aee --- /dev/null +++ b/common/src/main/java/org/onap/so/entity/package-info.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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========================================================= + */ + +/** + * Entities used for logging. + */ + +package org.onap.so.entity; + diff --git a/common/src/main/java/org/onap/so/exceptions/MarshallerException.java b/common/src/main/java/org/onap/so/exceptions/MarshallerException.java new file mode 100644 index 0000000000..8b06a8519f --- /dev/null +++ b/common/src/main/java/org/onap/so/exceptions/MarshallerException.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.exceptions; + + +public class MarshallerException extends Exception { + + private static final long serialVersionUID = 1L; + private String message; + private int errorCode; + + public MarshallerException(String message) { + super(message); + } + + public MarshallerException(String message, int errorCode, Exception e) { + super (e); + this.message = message; + this.errorCode = errorCode; + + } + + @Override + public String getMessage() { + return message; + } + + public int getErrorCode() { + return errorCode; + } +} diff --git a/common/src/main/java/org/onap/so/exceptions/ValidationException.java b/common/src/main/java/org/onap/so/exceptions/ValidationException.java new file mode 100644 index 0000000000..713fac70f3 --- /dev/null +++ b/common/src/main/java/org/onap/so/exceptions/ValidationException.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.exceptions; + + +public class ValidationException extends Exception { + + /** + * This class simply extends Exception (without addition additional functionality) + * to provide an identifier for RequestsDB related exceptions on create, delete, query. + * + * + **/ + + private static final long serialVersionUID = 1L; + private static final String VALIDATION_FAIL = "No valid $ELEMENT is specified"; + private static final String INVALID_ELEMENT = "$ELEMENT is not valid in the $VERSION version"; + private static final String REPLACE_ELEMENT_KEY = "\\$ELEMENT"; + private static final String REPLACE_VERSION_KEY = "\\$VERSION"; + + @Deprecated + public ValidationException (String msg) { + super (VALIDATION_FAIL.replaceAll (REPLACE_ELEMENT_KEY, msg)); + } + + public ValidationException(String msg, boolean overrideExistingMessage) { + super(overrideExistingMessage ? VALIDATION_FAIL.replaceAll(REPLACE_ELEMENT_KEY, msg) : msg); + } + + public ValidationException (String msg, Exception cause) { + super (VALIDATION_FAIL.replaceAll (REPLACE_ELEMENT_KEY, msg), cause); + } + public ValidationException(String msg, String version) { + super(INVALID_ELEMENT.replaceAll(REPLACE_ELEMENT_KEY, msg).replaceAll(REPLACE_VERSION_KEY, version)); + } +} diff --git a/common/src/main/java/org/onap/so/jsonpath/JsonPathUtil.java b/common/src/main/java/org/onap/so/jsonpath/JsonPathUtil.java new file mode 100644 index 0000000000..cb0de998ba --- /dev/null +++ b/common/src/main/java/org/onap/so/jsonpath/JsonPathUtil.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.jsonpath; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.jayway.jsonpath.Configuration; +import com.jayway.jsonpath.JsonPath; +import com.jayway.jsonpath.Option; +import com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider; + +public class JsonPathUtil { + + + private final Configuration conf; + private final Configuration pathListConf; + private JsonPathUtil() { + conf = Configuration.defaultConfiguration().jsonProvider(new JacksonJsonNodeJsonProvider()).addOptions(Option.ALWAYS_RETURN_LIST, Option.SUPPRESS_EXCEPTIONS); + pathListConf = Configuration.defaultConfiguration().addOptions(Option.AS_PATH_LIST, Option.SUPPRESS_EXCEPTIONS,Option.ALWAYS_RETURN_LIST); + } + + private static class Helper { + private static final JsonPathUtil INSTANCE = new JsonPathUtil(); + } + + public static JsonPathUtil getInstance() { + return Helper.INSTANCE; + } + public boolean pathExists(String json, String jsonPath) { + return JsonPath.using(conf).parse(json).read(jsonPath).size() != 0; + } + + public Optional locateResult(String json, String jsonPath) { + final ArrayNode result = JsonPath.using(conf).parse(json).read(jsonPath); + if (result.size() == 0) { + return Optional.empty(); + } else { + if (result.get(0).isValueNode()) { + return Optional.of(result.get(0).asText()); + } else { + return Optional.of(result.get(0).toString()); + } + + } + } + + public List locateResultList(String json, String jsonPath) { + final ArrayNode resultNodes = JsonPath.using(conf).parse(json).read(jsonPath); + final ArrayList result = new ArrayList<>(); + + for (JsonNode node : resultNodes) { + if (node.isValueNode()) { + result.add(node.asText()); + } else { + result.add(node.toString()); + } + + } + return result; + } + + public List getPathList(String json, String jsonPath) { + return JsonPath.using(pathListConf).parse(json).read(jsonPath); + } +} diff --git a/common/src/main/java/org/onap/so/logger/LoggerStartupListener.java b/common/src/main/java/org/onap/so/logger/LoggerStartupListener.java new file mode 100644 index 0000000000..0d20dd8bf9 --- /dev/null +++ b/common/src/main/java/org/onap/so/logger/LoggerStartupListener.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.logger; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +import org.springframework.stereotype.Component; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.spi.LoggerContextListener; +import ch.qos.logback.core.Context; +import ch.qos.logback.core.spi.ContextAwareBase; +import ch.qos.logback.core.spi.LifeCycle; + +@Component +public class LoggerStartupListener extends ContextAwareBase implements LoggerContextListener, LifeCycle { + + private boolean started = false; + + @Override + public void start() { + if (started) + return; + InetAddress addr= null; + try { + addr = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + Context context = getContext(); + if (addr != null) { + context.putProperty("server.name", addr.getHostName()); + } + started = true; + } + + @Override + public void stop() { + } + + @Override + public boolean isStarted() { + return started; + } + + @Override + public boolean isResetResistant() { + return true; + } + + @Override + public void onLevelChange(Logger arg0, Level arg1) { + } + + @Override + public void onReset(LoggerContext arg0) { + } + + @Override + public void onStart(LoggerContext arg0) { + } + + @Override + public void onStop(LoggerContext arg0) { + } +} diff --git a/common/src/main/java/org/onap/so/logger/MessageEnum.java b/common/src/main/java/org/onap/so/logger/MessageEnum.java new file mode 100644 index 0000000000..fcaa52024b --- /dev/null +++ b/common/src/main/java/org/onap/so/logger/MessageEnum.java @@ -0,0 +1,223 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.logger; + + + +public enum MessageEnum{ + // Api Handler Messages + APIH_REQUEST_NULL, + APIH_QUERY_FOUND, + APIH_QUERY_NOT_FOUND, + APIH_QUERY_PARAM_WRONG, + APIH_DB_ACCESS_EXC, + APIH_DB_ACCESS_EXC_REASON, + APIH_VALIDATION_ERROR, + APIH_REQUEST_VALIDATION_ERROR, + APIH_SERVICE_VALIDATION_ERROR, + APIH_GENERAL_EXCEPTION_ARG, + APIH_GENERAL_EXCEPTION, + APIH_GENERAL_WARNING, + APIH_AUDIT_EXEC, + APIH_GENERAL_METRICS, + APIH_DUPLICATE_CHECK_EXC, + APIH_DUPLICATE_FOUND, + APIH_BAD_ORDER, + APIH_DB_ATTRIBUTE_NOT_FOUND, + APIH_BPEL_COMMUNICATE_ERROR, + APIH_BPEL_RESPONSE_ERROR, + APIH_WARP_REQUEST, + APIH_ERROR_FROM_BPEL_SERVER, + APIH_DB_INSERT_EXC, + APIH_DB_UPDATE_EXC, + APIH_NO_PROPERTIES, + APIH_PROPERTY_LOAD_SUC, + APIH_LOAD_PROPERTIES_FAIL, + APIH_SDNC_COMMUNICATE_ERROR, + APIH_SDNC_RESPONSE_ERROR, + APIH_CANNOT_READ_SCHEMA, + APIH_HEALTH_CHECK_EXCEPTION, + APIH_REQUEST_VALIDATION_ERROR_REASON, + APIH_JAXB_MARSH_ERROR, + APIH_JAXB_UNMARSH_ERROR, + APIH_VNFREQUEST_VALIDATION_ERROR, + APIH_DOM2STR_ERROR, + APIH_READ_VNFOUTPUT_CLOB_EXCEPTION, + APIH_DUPLICATE_CHECK_EXC_ATT, + APIH_GENERATED_REQUEST_ID, + APIH_GENERATED_SERVICE_INSTANCE_ID, + APIH_REPLACE_REQUEST_ID, + // Resource Adapter Messages + RA_GENERAL_EXCEPTION_ARG, + RA_GENERAL_EXCEPTION, + RA_GENERAL_WARNING, + RA_MISSING_PARAM, + RA_AUDIT_EXEC, + RA_GENERAL_METRICS, + RA_CREATE_STACK_TIMEOUT, + RA_DELETE_STACK_TIMEOUT, + RA_UPDATE_STACK_TIMEOUT, + RA_CONNECTION_EXCEPTION, + RA_PARSING_ERROR, + RA_PROPERTIES_NOT_FOUND, + RA_LOAD_PROPERTIES_SUC, + RA_NETWORK_ALREADY_EXIST, + RA_UPDATE_NETWORK_ERR, + RA_CREATE_STACK_ERR, + RA_UPDATE_STACK_ERR, + RA_CREATE_TENANT_ERR, + RA_NETWORK_NOT_FOUND, + RA_NETWORK_ORCHE_MODE_NOT_SUPPORT, + RA_CREATE_NETWORK_EXC, + RA_NS_EXC, + RA_PARAM_NOT_FOUND, + RA_CONFIG_EXC, + RA_UNKOWN_PARAM, + RA_VLAN_PARSE, + RA_DELETE_NETWORK_EXC, + RA_ROLLBACK_NULL, + RA_TENANT_NOT_FOUND, + RA_QUERY_NETWORK_EXC, + RA_CREATE_NETWORK_NOTIF_EXC, + RA_ASYNC_ROLLBACK, + RA_WSDL_NOT_FOUND, + RA_WSDL_URL_CONVENTION_EXC, + RA_INIT_NOTIF_EXC, + RA_SET_CALLBACK_AUTH_EXC, + RA_FAULT_INFO_EXC, + RA_MARSHING_ERROR, + RA_PARSING_REQUEST_ERROR, + RA_SEND_REQUEST_SDNC, + RA_RESPONSE_FROM_SDNC, + RA_EXCEPTION_COMMUNICATE_SDNC, + RA_EVALUATE_XPATH_ERROR, + RA_ANALYZE_ERROR_EXC, + RA_ERROR_GET_RESPONSE_SDNC, + RA_CALLBACK_BPEL, + RA_INIT_CALLBACK_WSDL_ERR, + RA_CALLBACK_BPEL_EXC, + RA_CALLBACK_BPEL_COMPLETE, + RA_SDNC_MISS_CONFIG_PARAM, + RA_SDNC_INVALID_CONFIG, + RA_PRINT_URL, + RA_ERROR_CREATE_SDNC_REQUEST, + RA_ERROR_CREATE_SDNC_RESPONSE, + RA_ERROR_CONVERT_XML2STR, + RA_RECEIVE_SDNC_NOTIF, + RA_INIT_SDNC_ADAPTER, + RA_SEND_REQUEST_APPC_ERR, + RA_SEND_REQUEST_SDNC_ERR, + RA_RECEIVE_BPEL_REQUEST, + RA_TENANT_ALREADY_EXIST, + RA_UPDATE_TENANT_ERR, + RA_DELETE_TEMAMT_ERR, + RA_ROLLBACK_TENANT_ERR, + RA_QUERY_VNF_ERR, + RA_VNF_ALREADY_EXIST, + RA_VNF_UNKNOWN_PARAM, + RA_VNF_EXTRA_PARAM, + RA_CREATE_VNF_ERR, + RA_VNF_NOT_EXIST, + RA_UPDATE_VNF_ERR, + RA_DELETE_VNF_ERR, + RA_ASYNC_CREATE_VNF, + RA_SEND_VNF_NOTIF_ERR, + RA_ASYNC_CREATE_VNF_COMPLETE, + RA_ASYNC_UPDATE_VNF, + RA_ASYNC_UPDATE_VNF_COMPLETE, + RA_ASYNC_QUERY_VNF, + RA_ASYNC_QUERY_VNF_COMPLETE, + RA_ASYNC_DELETE_VNF, + RA_ASYNC_DELETE_VNF_COMPLETE, + RA_ASYNC_ROLLBACK_VNF, + RA_ASYNC_ROLLBACK_VNF_COMPLETE, + RA_ROLLBACK_VNF_ERR, + RA_DB_INVALID_STATUS, + RA_CANT_UPDATE_REQUEST, + RA_DB_REQUEST_NOT_EXIST, + RA_CONFIG_NOT_FOUND, + RA_CONFIG_LOAD, + RA_RECEIVE_WORKFLOW_MESSAGE, + // BPEL engine Messages + BPMN_GENERAL_INFO, + BPMN_GENERAL_EXCEPTION_ARG, + BPMN_GENERAL_EXCEPTION, + BPMN_GENERAL_WARNING, + BPMN_AUDIT_EXEC, + BPMN_GENERAL_METRICS, + BPMN_URN_MAPPING_FAIL, + BPMN_VARIABLE_NULL, + BPMN_CALLBACK_EXCEPTION, + // ASDC Messages + ASDC_GENERAL_EXCEPTION_ARG, + ASDC_GENERAL_EXCEPTION, + ASDC_GENERAL_WARNING, + ASDC_GENERAL_INFO, + ASDC_AUDIT_EXEC, + ASDC_GENERAL_METRICS, + ASDC_CREATE_SERVICE, + ASDC_ARTIFACT_ALREADY_DEPLOYED, + ASDC_CREATE_ARTIFACT, + ASDC_ARTIFACT_INSTALL_EXC, + ASDC_ARTIFACT_ALREADY_DEPLOYED_DETAIL, + ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL, + ASDC_ARTIFACT_CHECK_EXC, + ASDC_INIT_ASDC_CLIENT_EXC, + ASDC_INIT_ASDC_CLIENT_SUC, + ASDC_LOAD_ASDC_CLIENT_EXC, + ASDC_SINGLETON_CHECKT_EXC, + ASDC_SHUTDOWN_ASDC_CLIENT_EXC, + ASDC_CHECK_HEAT_TEMPLATE, + ASDC_START_INSTALL_ARTIFACT, + ASDC_ARTIFACT_TYPE_NOT_SUPPORT, + ASDC_ARTIFACT_ALREADY_EXIST, + ASDC_ARTIFACT_DOWNLOAD_SUC, + ASDC_ARTIFACT_DOWNLOAD_FAIL, + ASDC_START_DEPLOY_ARTIFACT, + ASDC_SEND_NOTIF_ASDC, + ASDC_SEND_NOTIF_ASDC_EXEC, + ASDC_RECEIVE_CALLBACK_NOTIF, + ASDC_RECEIVE_SERVICE_NOTIF, + ASDC_ARTIFACT_NULL, + ASDC_SERVICE_NOT_SUPPORT, + ASDC_ARTIFACT_DEPLOY_SUC, + ASDC_PROPERTIES_NOT_FOUND, + ASDC_PROPERTIES_LOAD_SUCCESS, + // Default Messages, in case Log catalog is not defined + GENERAL_EXCEPTION_ARG, + GENERAL_EXCEPTION, + GENERAL_WARNING, + AUDIT_EXEC, + GENERAL_METRICS, + LOGGER_SETUP, + LOGGER_NOT_FOUND, + LOGGER_UPDATE_SUC, + LOGGER_UPDATE_DEBUG, + LOGGER_UPDATE_DEBUG_SUC, + LOAD_PROPERTIES_SUC, + NO_PROPERTIES, + MADATORY_PARAM_MISSING, + LOAD_PROPERTIES_FAIL, + INIT_LOGGER, + INIT_LOGGER_FAIL, + JAXB_EXCEPTION, + IDENTITY_SERVICE_NOT_FOUND; +} diff --git a/common/src/main/java/org/onap/so/logger/MsoAlarmLogger.java b/common/src/main/java/org/onap/so/logger/MsoAlarmLogger.java new file mode 100644 index 0000000000..890aac93c0 --- /dev/null +++ b/common/src/main/java/org/onap/so/logger/MsoAlarmLogger.java @@ -0,0 +1,187 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.logger; + + +import java.io.File; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +import org.slf4j.LoggerFactory; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.encoder.PatternLayoutEncoder; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.rolling.RollingFileAppender; +import ch.qos.logback.core.rolling.TimeBasedRollingPolicy; + +/** + * Wrapper around log4j and Nagios NRDP passive alarming for MSO. + * + * For local alarm logging, this class will look for an alarm log file name + * in the servlet context parameter "mso.alarms.file". If none is found, + * it will look for an MsoProperty of the same name. As a last resort, + * it will use the default path "/var/log/ecomp/MSO/alarms/alarm.log". + * It is expected that all alarms within an application will use the same + * alarm file, so there is no way to dynamically add other alarm files. + * + * Alarms are logged as a simple pipe-delimited string of the format: + * ||| + * + * This class also supports real-time Nagios NRDP alarming. If enabled via + * MsoProperties, all alarms generated and logged to the local alarm file will + * also be transmitted to a Nagios NRDP instance. NRDP requires 4 parameters + * in service alarm events (all Mso Alarms will be Service Alarms): + * hostname, servicename, state, detail + * + * The log file format is also intended to be compatible with Nagios NRDP for + * non-real-time reporting. The command-line tool for sending alarms is + * is "send_nrdp.php", which takes the same 4 parameters as input. + * It will be easy enough to translate entries from an alarm.log file to + * NRDP if real-time NRDP alarming is not enabled. + * + * For Nagios integration, the alarmTypes should all match "service names" + * configured in the receiving Nagios server. Also, the alarm state will + * be limited to the 4 values defined by Nagios: + * 0 = OK, 1 = Warning, 2 = Critical, 3 = Unknown + * + * + */ +public class MsoAlarmLogger implements ServletContextListener { + + private Logger alarmLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(MSO_ALARM_CONTEXT); + private static RollingFileAppender fileAppender = null; + public static final String DEFAULT_MSO_ALARM_FILE = "/var/log/ecomp/MSO/alarms/alarm.log"; + public static final String MSO_ALARM_CONTEXT = "mso.alarms"; + + public static final int OK = 0; + public static final int WARNING = 1; + public static final int CRITICAL = 2; + public static final int UNKNOWN = 3; + + /** + * Get the default MSO Alarm Logger + */ + public MsoAlarmLogger () { + + initializeAlarmLogger(null); + + } + + public MsoAlarmLogger (String alarmFile) { + initializeAlarmLogger(alarmFile); + + } + + /** + * Method to record an alarm. + * + * @param alarm - the alarm identifier (Nagios "service") + * @param state - the alarm state/severity, based on Nagios service + * state values: 0 = OK, 1 = Warning, 2 = Critical, 3 = Unknown + * @param detail - detail message (may contain additional internal + * structure per alarm type) + */ + public void sendAlarm (String alarm, int state, String detail) { + // Write the alarm to Log file + if (alarmLogger != null) { + String output = alarm + "|" + state + "|" + detail; + alarmLogger.info (output); + } + + } + + @Override + public void contextDestroyed (ServletContextEvent event) { + // Nothing to do... + } + + @Override + public void contextInitialized (ServletContextEvent event) { + String msoAlarmFile = event.getServletContext ().getInitParameter ("mso.alarm.file"); + if (msoAlarmFile == null) { + msoAlarmFile = DEFAULT_MSO_ALARM_FILE; + } + + initializeAlarmLogger (msoAlarmFile); + } + + private void initializeAlarmLogger (String alarmFile) { + synchronized (MsoAlarmLogger.class) { + if (fileAppender == null) { + if (alarmFile != null) { + fileAppender = MsoAlarmLogger.getAppender (alarmFile); + } else { + fileAppender = MsoAlarmLogger.getAppender (DEFAULT_MSO_ALARM_FILE); + } + } + } + // The alarmLogger was static originally. + // The initialization of the alarmLogger was fine, but not sure why, it lost its appender info later + // Due to that issue, the alarmLogger is not static any more. + // Instead static attribute fileAppender is added and will be assigned to the alarmLogger every time new MsoAlarmLogger is created. + alarmLogger.setLevel (Level.INFO); + alarmLogger.addAppender (fileAppender); + alarmLogger.setAdditive (false); + } + + public void resetAppender() { + synchronized (MsoAlarmLogger.class) { + fileAppender = null; + } + } + + private static RollingFileAppender getAppender (String msoAlarmFile) { + // Create a Logger for alarms. Just use a default Pattern that outputs + // a message. MsoAlarmLogger will handle the formatting. + File alarmFile = new File (msoAlarmFile); + File alarmDir = alarmFile.getParentFile (); + if (!alarmDir.exists ()) { + alarmDir.mkdirs (); + } + + String logPattern = "%d{yyyy-MM-dd HH:mm:ss}|%m%n"; + + LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); + PatternLayoutEncoder encoder=new PatternLayoutEncoder(); + encoder.setPattern(logPattern); + encoder.setContext(context); + encoder.start(); + RollingFileAppender fileAppender= new RollingFileAppender<>(); + TimeBasedRollingPolicy rollingPolicy= new TimeBasedRollingPolicy<>(); + rollingPolicy.setContext(context); + rollingPolicy.setFileNamePattern(msoAlarmFile + ".%d"); + rollingPolicy.setParent(fileAppender); + rollingPolicy.start(); + fileAppender.setFile(msoAlarmFile); + fileAppender.setAppend(true); + fileAppender.setEncoder(encoder); + fileAppender.setRollingPolicy(rollingPolicy); + fileAppender.setContext(context); + fileAppender.start(); + + return fileAppender; + } + +} diff --git a/common/src/main/java/org/onap/so/logger/MsoLogger.java b/common/src/main/java/org/onap/so/logger/MsoLogger.java new file mode 100644 index 0000000000..10f572e772 --- /dev/null +++ b/common/src/main/java/org/onap/so/logger/MsoLogger.java @@ -0,0 +1,1193 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.so.logger; + + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.invoke.MethodHandles; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.onap.so.entity.MsoRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + + +/** + * This class supports all of the normal logging functions (debug, info, etc.), prepending + * a string of format "[| clazz) { + this.logger = LoggerFactory.getLogger(clazz); + this.auditLogger = LoggerFactory.getLogger("AUDIT"); + this.metricsLogger = LoggerFactory.getLogger("METRIC"); + MsoLogger.initialization(); + setDefaultLogCatalog(cat); + } + + private static synchronized void initialization() { + if (instanceUUID == null || ("").equals(instanceUUID)) { + instanceUUID = getInstanceUUID(); + } + + if (serverIP == null || serverName == null || ("").equals(serverIP) || ("").equals(serverName)) { + try { + InetAddress server = InetAddress.getLocalHost(); + serverIP = server.getHostAddress(); + serverName = server.getHostName(); + } catch (UnknownHostException e) { + initLOGGER.error("Could not get local hostname", e); + serverIP = ""; + serverName = ""; + } + } + } + + + + public static MsoLogger getMsoLogger(MsoLogger.Catalog cat, Class clazz) { + return new MsoLogger(cat,clazz); + } + + + + /** + * Record the Metrics event with no argument + * + * @param startTime + * Transaction starting time in millieseconds + * @param statusCode + * StatusCode of the transaction, either COMPLETE or ERROR + * @param responseCode + * The response code returned by the sub-components + * @param responseDesc + * Human redable description of the response code + * @param targetEntity + * The component which is invoked for this sub-operation + * @param targetServiceName + * API invoked on the TargetEntity + * @param targetVEntity + * Target VNF or VM acted opon by the component, if available + */ + public void recordMetricEvent() { + metricsLogger.info(""); + MDC.remove(TIMER); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + public void recordMetricEvent(Long startTime, StatusCode statusCode, ResponseCode responseCode, String responseDesc, + String targetEntity, String targetServiceName, String targetVEntity) { + prepareMetricMsg(startTime, statusCode, responseCode.getValue(), responseDesc, targetEntity, targetServiceName, + targetVEntity); + metricsLogger.info(""); + MDC.remove(TIMER); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + + /** + * Record the Audit event + * + * @param startTime + * Transaction starting time in millieseconds + * @param statusCode + * StatusCode of the transaction, either COMPLETE or ERROR + * @param responseCode + * The application specific response code + * @param responseDesc + * Human redable description of the application response code + */ + public void recordAuditEvent(){ + auditLogger.info(""); + } + + public void recordAuditEvent(Long startTime, StatusCode statusCode, ResponseCode responseCode, + String responseDesc) { + MDC.put(MsoLogger.PARTNERNAME, "UNKNOWN"); + prepareAuditMsg(startTime, statusCode, responseCode.getValue(), responseDesc); + auditLogger.info(""); + MDC.remove(TIMER); + } + + // Debug methods + /** + * Record the Debug event + * + * @param msg + * The log message to put + */ + public void debug(String msg) { + prepareMsg(DEBUG_LEVEL); + logger.debug(msg); + } + + /** + * Record the Debug event + * + * @param msg + * The log message to put + * @param t + * The exception to put + */ + public void debug(String msg, Throwable t) { + prepareMsg(DEBUG_LEVEL); + logger.debug(msg, t); + } + + public void info(String msg) { + prepareMsg(DEBUG_LEVEL); + logger.info(msg); + } + + + /** + * Log error message with the details of the exception that caused the error. + * @param msg + * @param throwable + */ + public void error(String msg) { + prepareMsg(ERROR_LEVEL); + logger.error(msg); + } + + /** + * Log error message with the details of the exception that caused the error. + * @param msg + * @param throwable + */ + public void error(String msg, Throwable throwable) { + prepareMsg(ERROR_LEVEL); + logger.error(msg, throwable); + } + + // Info methods + /** + * Record the Info event + * + * @param msg + * The log message to put + */ + public void info(String msg, String targetEntity, String targetServiceName) { + prepareErrorMsg(INFO_LEVEL, targetEntity, targetServiceName, null, ""); + + logger.info(msg); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Info event with 1 argument + * + * @param msg + * The log message to put + * @param arg0 + * The argument used in the log message + */ + public void info(MessageEnum msg, String arg0, String targetEntity, String targetServiceName) { + prepareErrorMsg(INFO_LEVEL, targetEntity, targetServiceName, null, ""); + + logger.info(msg.toString(), normalize(arg0)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Info event with 2 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1 + * The arguments used in the log message + */ + public void info(String msg, String arg0, String arg1, String targetEntity, + String targetServiceName) { + prepareErrorMsg(INFO_LEVEL, targetEntity, targetServiceName, null, ""); + + logger.info(msg, normalize(arg0), normalize(arg1)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Info event with 3 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2 + * The arguments used in the log message + */ + public void info(MessageEnum msg, String arg0, String arg1, String arg2, String targetEntity, + String targetServiceName) { + prepareErrorMsg(INFO_LEVEL, targetEntity, targetServiceName, null, ""); + + logger.info(msg.toString(), normalize(arg0), normalize(arg1), normalize(arg2)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Info event with 4 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2,arg3 + * The arguments used in the log message + */ + public void info(String msg, String arg0, String arg1, String arg2, String arg3, + String targetEntity, String targetServiceName) { + prepareErrorMsg(INFO_LEVEL, targetEntity, targetServiceName, null, ""); + + logger.info(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Info event with 5 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2,arg3,arg4 + * The arguments used in the log message + */ + public void info(String msg, String arg0, String arg1, String arg2, String arg3, String arg4, + String targetEntity, String targetServiceName) { + prepareErrorMsg(INFO_LEVEL, targetEntity, targetServiceName, null, ""); + + logger.info(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), normalize(arg4)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Info event with 6 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2,arg3,arg4,arg5 + * The arguments used in the log message + */ + public void info(String msg, String arg0, String arg1, String arg2, String arg3, String arg4, + String arg5, String targetEntity, String targetServiceName) { + prepareErrorMsg(INFO_LEVEL, targetEntity, targetServiceName, null, ""); + + logger.info(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), normalize(arg4), + normalize(arg5)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + // Warning methods + + + /** + * Record the Warning event + * + * @param msg + * The log message to put + */ + public void warnSimple( String targetServiceName, String errorDesc) { + logger.warn("Service Name: {} Error: {}" , targetServiceName, errorDesc); + } + /** + * Record the Warning event + * + * @param msg + * The log message to put + */ + public void warn(MessageEnum msg, String targetEntity, String targetServiceName, ErrorCode errorCode, + String errorDesc) { + prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + + logger.warn(msg.toString()); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Warning event + * + * @param msg + * The log message to put + * @param t + * The exception info + */ + public void warn(MessageEnum msg, String targetEntity, String targetServiceName, ErrorCode errorCode, + String errorDesc, Throwable t) { + prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.warn("Warning: "+msg, t); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Warn event with 1 argument + * + * @param msg + * The log message to put + * @param arg + * The argument used in the log message + */ + public void warn(MessageEnum msg, String arg, String targetEntity, String targetServiceName, + ErrorCode errorCode, String errorDesc) { + prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.warn(msg.toString(), arg); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Warn event with 1 argument + * + * @param msg + * The log message to put + * @param arg + * The arguments used in the log message + * @param t + * The exception info + */ + public void warn(MessageEnum msg, String arg, String targetEntity, String targetServiceName, + ErrorCode errorCode, String errorDesc, Throwable t) { + prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.warn(msg.toString(), arg); + logger.debug("Exception raised", t); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Warn event with 2 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1 + * The arguments used in the log message + */ + public void warn(MessageEnum msg, String arg0, String arg1, String targetEntity, + String targetServiceName, ErrorCode errorCode, String errorDesc) { + prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.warn(msg.toString(), normalize(arg0), normalize(arg1)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Warn event with 2 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1 + * The arguments used in the log message + * @param t + * The exception info + */ + public void warn(String msg, String arg0, String arg1, String targetEntity, + String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.warn(msg, normalize(arg0), normalize(arg1)); + logger.warn(msg, t); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Warn event with 3 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2 + * The arguments used in the log message + */ + public void warn(String msg, String arg0, String arg1, String arg2, String targetEntity, + String targetServiceName, ErrorCode errorCode, String errorDesc) { + prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.warn(msg, normalize(arg0), normalize(arg1), normalize(arg2)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Warn event with 3 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2 + * The arguments used in the log message + * @param t + * The exception info + */ + public void warn(String msg, String arg0, String arg1, String arg2, String targetEntity, + String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.warn(msg, normalize(arg0), normalize(arg1), normalize(arg2)); + logger.warn(msg, t); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Warn event with 4 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2,arg3 + * The arguments used in the log message + */ + public void warn(String msg, String arg0, String arg1, String arg2, String arg3, + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc) { + prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.warn(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Warn event with 4 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2, + * arg3 The arguments used in the log message + * @param t + * The exception info + */ + public void warn(String msg, String arg0, String arg1, String arg2, String arg3, + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.warn(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3)); + logger.warn(msg, t); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Warn event with 5 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2,arg3,arg4 + * The arguments used in the log message + */ + public void warn(String msg, String arg0, String arg1, String arg2, String arg3, String arg4, + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc) { + prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.warn(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), normalize(arg4)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Warn event with 5 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2,arg3,arg4 + * The arguments used in the log message + * @param t + * The exception info + */ + public void warn(String msg, String arg0, String arg1, String arg2, String arg3, String arg4, + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + prepareErrorMsg(WARN_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.warn(msg, normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), normalize(arg4)); + logger.warn(msg, t); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + + + // Error methods + /** + * Record the Error event + * + * @param generalException + * The log message to put + */ + public void error(MessageEnum generalException, String targetEntity, String targetServiceName, ErrorCode errorCode, + String errorDesc) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.error(generalException.toString() + ": " +errorDesc); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + + /** + * Record the Error event + * + * @param msg + * The log message to put + * @param t + * The exception info + */ + public void trace(String traceMessage) { + logger.trace(traceMessage); + } + + + /** + * Record the Error event + * + * @param msg + * The log message to put + * @param t + * The exception info + */ + public void error( Throwable t) { + logger.error(t.getMessage(), t); + } + + + /** + * Record the Error event + * + * @param msg + * The log message to put + * @param t + * The exception info + */ + public void error(MessageEnum msg, String targetEntity, String targetServiceName, ErrorCode errorCode, + String errorDesc, Throwable t) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.error(msg.toString(), t); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Error event with 1 argument + * + * @param msg + * The log message to put + * @param arg0 + * The arguments used in the log message + */ + public void error(MessageEnum msg, String arg0, String targetEntity, String targetServiceName, + ErrorCode errorCode, String errorDesc) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.error(msg.toString(), normalize(arg0)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Error event with 1 argument + * + * @param msg + * The log message to put + * @param arg0 + * The arguments used in the log message + * @param t + * The exception info + */ + public void error(MessageEnum msg, String arg0, String targetEntity, String targetServiceName, + ErrorCode errorCode, String errorDesc, Throwable t) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.error(msg.toString(), normalize(arg0), t); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Error event with 2 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1 + * The arguments used in the log message + */ + public void error(MessageEnum msg, String arg0, String arg1, String targetEntity, + String targetServiceName, ErrorCode errorCode, String errorDesc) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.error(msg.toString(), normalize(arg0), normalize(arg1)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Error event with 2 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1 + * The arguments used in the log message + * @param t + * The exception info + */ + public void error(MessageEnum msg, String arg0, String arg1, String targetEntity, + String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.error(msg.toString(), normalize(arg0), normalize(arg1), t); + logger.debug("Exception raised", t); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Error event with 3 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2 + * The arguments used in the log message + */ + public void error(MessageEnum msg, String arg0, String arg1, String arg2, String targetEntity, + String targetServiceName, ErrorCode errorCode, String errorDesc) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.error(msg.toString(), normalize(arg0), normalize(arg1), normalize(arg2)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Error event with 3 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2 + * The arguments used in the log message + * @param t + * The exception info + */ + public void error(MessageEnum msg, String arg0, String arg1, String arg2, String targetEntity, + String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.error(msg.toString(), normalize(arg0), normalize(arg1), normalize(arg2), t); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Error event with 4 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2,arg3 + * The arguments used in the log message + */ + public void error(MessageEnum msg, String arg0, String arg1, String arg2, String arg3, + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.error(msg.toString(), normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Error event with 4 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2,arg3 + * The arguments used in the log message + * @param t + * The exception info + */ + public void error(MessageEnum msg, String arg0, String arg1, String arg2, String arg3, + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.error(msg.toString(), normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), t); + + logger.debug("Exception raised", t); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Error event with 5 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2,arg3,arg4 + * The arguments used in the log message + */ + public void error(MessageEnum msg, String arg0, String arg1, String arg2, String arg3, String arg4, + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.error(msg.toString(), normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), normalize(arg4)); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + /** + * Record the Error event with 5 arguments + * + * @param msg + * The log message to put + * @param arg0,arg1,arg2,arg3,arg4 + * The arguments used in the log message + * @param t + * The exception info + */ + public void error(MessageEnum msg, String arg0, String arg1, String arg2, String arg3, String arg4, + String targetEntity, String targetServiceName, ErrorCode errorCode, String errorDesc, Throwable t) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorDesc); + logger.error(msg.toString(), normalize(arg0), normalize(arg1), normalize(arg2), normalize(arg3), normalize(arg4), t); + logger.debug("Exception raised", t); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + } + + public void error(String errorMessage, String errorSource, String targetEntity, String targetServiceName, + ErrorCode errorCode, String errorText) { + prepareErrorMsg(ERROR_LEVEL, targetEntity, targetServiceName, errorCode, errorText); + logger.error(errorMessage); + MDC.remove(TARGETENTITY); + MDC.remove(TARGETSERVICENAME); + + } + + public void logStackTrace(Exception ex){ + StringWriter errors = new StringWriter(); + ex.printStackTrace(new PrintWriter(errors)); + logger.error(errors.toString()); + } + + public boolean isDebugEnabled() { + return logger.isDebugEnabled(); + } + + private void prepareMsg(String loggingLevel) { + prepareMsg(loggingLevel, null, null); + } + + private void prepareMsg(String loggingLevel, String serviceNamep, String timer) { + String reqId = MDC.get(REQUEST_ID); + String svcId = MDC.get(SERVICE_INSTANCE_ID); + + // Based on the discussion with Adrian, + // if these 2 parameters is not available, using dummy value "trace-#" + if (reqId == null || reqId.isEmpty()) { + MDC.put(REQUEST_ID, DUMMY_VALUE); + } + + if (timer != null) { + MDC.put(TIMER, timer); + } + + writeIfNotNullorEmpty(SERVICE_NAME,getFinalServiceName(serviceNamep)); + writeIfNotNullorEmpty(ALERT_SEVERITY,getSeverityLevel(loggingLevel)); + writeIfNotNullorEmpty(INSTANCE_UUID,instanceUUID); + writeIfNotNullorEmpty(SERVER_IP,serverIP); + writeIfNotNullorEmpty(FQDN,serverName); + + } + + private void writeIfNotNullorEmpty(String Key, String value) { + if (MDC.get(Key) == null|| MDC.get(Key).isEmpty()) { + MDC.put(Key, value); + } + } + + private void prepareAuditMsg(long startTime, StatusCode statusCode, int responseCode, String responseDesc) { + long endTime = System.currentTimeMillis(); + prepareMsg(INFO_LEVEL, null, String.valueOf(endTime - startTime)); + prepareAuditMetricMsg(startTime, endTime, statusCode, responseCode, responseDesc); + } + + private void prepareAuditMetricMsg(long startTime, long endTime, StatusCode statusCode, int responseCode, + String responseDesc) { + Date startDate = new Date(startTime); + Date endDate = new Date(endTime); + DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + + MDC.put(BEGINTIME, String.valueOf(formatter.format(startDate))); + MDC.put(ENDTIME, String.valueOf(formatter.format(endDate))); + MDC.put(STATUSCODE, statusCode.name()); + MDC.put(RESPONSECODE, String.valueOf(responseCode)); + MDC.put(RESPONSEDESC, responseDesc); + } + + private void prepareErrorMsg(String loggingLevel, String targetEntity, String targetServiceName, + ErrorCode errorCode, String errorDesc) { + MDC.put(ALERT_SEVERITY, getSeverityLevel(loggingLevel)); + if(errorCode != null) { + MDC.put(ERRORCODE, Integer.toString(errorCode.getValue())); + } + MDC.put(ERRORDESC, errorDesc); + MDC.put(TARGETENTITY, targetEntity); + MDC.put(TARGETSERVICENAME, targetServiceName); + MDC.put(SERVICE_NAME, getFinalServiceName(getServiceName())); + } + + private void prepareMetricMsg(long startTime, StatusCode statusCode, int responseCode, String responseDesc, + String targetEntity, String targetServiceName, String targetVEntity) { + long endTime = System.currentTimeMillis(); + prepareMsg(INFO_LEVEL, null, String.valueOf(endTime - startTime)); + prepareAuditMetricMsg(startTime, endTime, statusCode, responseCode, responseDesc); + + // Populate Metric log specific parameter + MDC.put(TARGETENTITY, targetEntity); + MDC.put(TARGETSERVICENAME, targetServiceName); + + if (null != targetVEntity) { + MDC.put(TARGETVIRTUALENTITY, targetVEntity); + } + } + + private String getSeverityLevel(String loggingLevel) { + String severity; + // According to the Nagios alerting: 0=OK; 1=WARNING; 2=UNKOWN; + // 3=CRITICAL + switch (loggingLevel) { + case ERROR_LEVEL: + severity = "2"; + break; + case FATAL_LEVEL: + severity = "3"; + break; + case WARN_LEVEL: + severity = "1"; + break; + default: + severity = "0"; + break; + } + return severity; + } + + private String getFinalServiceName(String serviceNamep) { + // This step to set the serviceName should be put after the className is + // get, + // since the default serviceName is obtained during the method to get + // the className. + // + // There's 3 ways to set the serviceName. The first method has the most + // priority to set the value. + // a) If the serviceName is set within the log method, this value will + // be used first + // b) If serviceName is not set within the log method, the value defined + // in the MDC will be used + // c) If nothing is set specifically, then MsoLogger will assign a + // default(MSO.) value to it + String serName = MDC.get(MsoLogger.SERVICE_NAME); + + // Check if service name was already set as the method name by a + // previous call to this method. + String isMethodNameStr = MDC.get(MsoLogger.SERVICE_NAME_IS_METHOD_NAME); + boolean isMethodName = isMethodNameStr != null && isMethodNameStr.equals(Boolean.TRUE.toString()); + if (serviceNamep != null) { + return serviceNamep; + } else if (serName != null && !isMethodName) { + return serName; + } + + MDC.put(MsoLogger.SERVICE_NAME_IS_METHOD_NAME, Boolean.TRUE.toString()); + int limit; + StackTraceElement[] classArr = new Exception().getStackTrace(); + if (classArr.length >= 6) { + limit = 7; + } else { + limit = classArr.length; + } + for (int i = 1; i < limit; i++) { + if (!classArr[i].getClassName().equals(this.getClass().getName())) { + return classArr[i].getMethodName(); + } + } + return classArr[0].getMethodName(); + } + + // Based on the discussion with Adrian, instanceUUID is used to identifiy + // the mso instance, + // it is generated during mso instance initialization period + // The same mso instnace will use the same instanceUUID value, even after + // restart + private static String getInstanceUUID() { + return System.getProperty("mso-instance-id"); + } + + /** + * Set the requestId and serviceInstanceId + * + * @param reqId + * The requestId + * @param svcId + * The serviceInstanceId + */ + public static void setLogContext(String reqId, String svcId) { + if (null != reqId) { + MDC.put(REQUEST_ID, reqId); + } + + if (null != svcId) { + MDC.put(SERVICE_INSTANCE_ID, svcId); + } + } + + /** + * Set the remoteIp and the basic HTTP Authentication user + * + * @param remoteIpp + * The remote ip address + * @param userp + * The basic http authencitation user + */ + public static void setLoggerParameters(String remoteIpp, String userp) { + if (null != remoteIpp) { + MDC.put(REMOTE_HOST, remoteIpp); + } + if (null != userp) { + MDC.put(USER, userp); + } + } + + /** + * Set the serviceName + * + * @param serviceNamep + * The service name + */ + public static void setServiceName(String serviceNamep) { + if (null != serviceNamep) { + MDC.put(SERVICE_NAME, serviceNamep); + MDC.remove(SERVICE_NAME_IS_METHOD_NAME); + } + } + + /** + * Get the serviceName + * + * @return The service name + */ + public static String getServiceName() { + return MDC.get(SERVICE_NAME); + } + + /** + * Reset the serviceName + */ + public static void resetServiceName() { + MDC.remove(SERVICE_NAME); + } + + /** + * Set the requestId and serviceInstanceId based on the mso request + * + * @param msoRequest + * The mso request + */ + public static void setLogContext(MsoRequest msoRequest) { + if (msoRequest != null) { + MDC.put(REQUEST_ID, msoRequest.getRequestId()); + MDC.put(SERVICE_INSTANCE_ID, msoRequest.getServiceInstanceId()); + } else { + MDC.put(REQUEST_ID, DUMMY_VALUE); + MDC.put(SERVICE_INSTANCE_ID, DUMMY_VALUE); + } + } + + private String normalize(String input) { + if (input == null) { + return null; + } + String result = input.replace('|', '!'); + result = result.replace("\n", " - "); + return result; + } + + private void setDefaultLogCatalog(MsoLogger.Catalog cat) { + if ("APIH".equals(cat.toString())) { + exceptionArg = MessageEnum.APIH_GENERAL_EXCEPTION_ARG; + defaultException = MessageEnum.APIH_GENERAL_EXCEPTION; + defaultWarning = MessageEnum.APIH_GENERAL_WARNING; + defaultAudit = MessageEnum.APIH_AUDIT_EXEC; + defaultMetrics = MessageEnum.APIH_GENERAL_METRICS; + } else if ("RA".equals(cat.toString())) { + exceptionArg = MessageEnum.RA_GENERAL_EXCEPTION_ARG; + defaultException = MessageEnum.RA_GENERAL_EXCEPTION; + defaultWarning = MessageEnum.RA_GENERAL_WARNING; + defaultAudit = MessageEnum.RA_AUDIT_EXEC; + defaultMetrics = MessageEnum.RA_GENERAL_METRICS; + } else if ("BPEL".equals(cat.toString())) { + exceptionArg = MessageEnum.BPMN_GENERAL_EXCEPTION_ARG; + defaultException = MessageEnum.BPMN_GENERAL_EXCEPTION; + defaultWarning = MessageEnum.BPMN_GENERAL_WARNING; + defaultAudit = MessageEnum.BPMN_AUDIT_EXEC; + defaultMetrics = MessageEnum.BPMN_GENERAL_METRICS; + } else if ("ASDC".equals(cat.toString())) { + exceptionArg = MessageEnum.ASDC_GENERAL_EXCEPTION_ARG; + defaultException = MessageEnum.ASDC_GENERAL_EXCEPTION; + defaultWarning = MessageEnum.ASDC_GENERAL_WARNING; + defaultAudit = MessageEnum.ASDC_AUDIT_EXEC; + defaultMetrics = MessageEnum.ASDC_GENERAL_METRICS; + } else { + exceptionArg = MessageEnum.GENERAL_EXCEPTION_ARG; + defaultException = MessageEnum.GENERAL_EXCEPTION; + defaultWarning = MessageEnum.GENERAL_WARNING; + defaultAudit = MessageEnum.AUDIT_EXEC; + defaultMetrics = MessageEnum.GENERAL_METRICS; + } + } + + public void warnSimple(String message, Exception e) { + logger.warn(message,e); + + } + + + + + +} diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/jersey/JaxRsClientLogging.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/jersey/JaxRsClientLogging.java new file mode 100644 index 0000000000..2888cbf3a1 --- /dev/null +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/jersey/JaxRsClientLogging.java @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.logging.jaxrs.filter.jersey; + + +import org.apache.commons.io.IOUtils; +import org.onap.so.logger.MsoLogger; +import org.onap.so.utils.TargetEntity; +import org.slf4j.MDC; +import org.springframework.stereotype.Component; + +import javax.ws.rs.client.ClientRequestContext; +import javax.ws.rs.client.ClientRequestFilter; +import javax.ws.rs.client.ClientResponseContext; +import javax.ws.rs.client.ClientResponseFilter; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; + +import java.io.*; + +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.Locale; +import java.util.UUID; + +@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") +@Component +public class JaxRsClientLogging implements ClientRequestFilter,ClientResponseFilter { + + private static MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,JaxRsClientLogging.class); + + private TargetEntity targetEntity; + + public void setTargetService(TargetEntity targetEntity){ + this.targetEntity = targetEntity; + } + + @Override + public void filter(ClientRequestContext clientRequest) { + try{ + MultivaluedMap headers = clientRequest.getHeaders(); + + + Instant instant = Instant.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX" ) + .withLocale( Locale.US ) + .withZone( ZoneId.systemDefault() ); + + String requestId = MDC.get(MsoLogger.REQUEST_ID); + if(requestId == null || requestId.isEmpty()){ + requestId = UUID.randomUUID().toString(); + logger.warnSimple(clientRequest.getUri().getPath(),"Could not Find Request ID Generating New One"); + } + + MDC.put(MsoLogger.METRIC_BEGIN_TIME, formatter.format(instant)); + MDC.put(MsoLogger.METRIC_START_TIME, String.valueOf(System.currentTimeMillis())); + MDC.put(MsoLogger.REQUEST_ID,requestId); + MDC.put(MsoLogger.TARGETSERVICENAME, clientRequest.getUri().toString()); + } catch (Exception e) { + logger.warnSimple("Error in incoming JAX-RS Inteceptor", e); + } + } + + + @Override + public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) { + + try { + Instant instant = Instant.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX" ) + .withLocale( Locale.US ) + .withZone( ZoneId.systemDefault() ); + String startTime= MDC.get(MsoLogger.METRIC_START_TIME); + + long elapsedTime = System.currentTimeMillis()-Long.parseLong(startTime); + String statusCode; + if(Response.Status.Family.familyOf(responseContext.getStatus()).equals(Response.Status.Family.SUCCESSFUL)){ + statusCode=MsoLogger.COMPLETE; + }else{ + statusCode=MsoLogger.StatusCode.ERROR.toString(); + } + MultivaluedMap headers = responseContext.getHeaders(); + + String partnerName = headers.getFirst(MsoLogger.HEADER_FROM_APP_ID ); + if(partnerName == null || partnerName.isEmpty()) + partnerName="UNKNOWN"; + MDC.put(MsoLogger.RESPONSEDESC,getStringFromInputStream(responseContext)); + MDC.put(MsoLogger.STATUSCODE, statusCode); + MDC.put(MsoLogger.RESPONSECODE,String.valueOf(responseContext.getStatus())); + MDC.put(MsoLogger.METRIC_TIMER, String.valueOf(elapsedTime)); + MDC.put(MsoLogger.METRIC_END_TIME,formatter.format(instant)); + MDC.put(MsoLogger.PARTNERNAME,partnerName); + MDC.put(MsoLogger.TARGETENTITY, targetEntity.toString()); + logger.recordMetricEvent(); + } catch ( Exception e) { + logger.warnSimple("Error in outgoing JAX-RS Inteceptor", e); + } + } + + private static String getStringFromInputStream(ClientResponseContext clientResponseContext) { + + InputStream is = clientResponseContext.getEntityStream(); + ByteArrayOutputStream boas = new ByteArrayOutputStream(); + + try { + IOUtils.copy(is,boas); + InputStream copiedStream = new ByteArrayInputStream(boas.toByteArray()); + clientResponseContext.setEntityStream(copiedStream); + return boas.toString(); + + } catch (IOException e) { + logger.warnSimple("Failed to read response body", e); + } + return "Unable to read input stream"; + } +} diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/jersey/JaxRsFilterLogging.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/jersey/JaxRsFilterLogging.java new file mode 100644 index 0000000000..9fab4ff0df --- /dev/null +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/jersey/JaxRsFilterLogging.java @@ -0,0 +1,180 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.logging.jaxrs.filter.jersey; + + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.Locale; +import java.util.UUID; + +import javax.annotation.Priority; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerRequestFilter; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.MessageBodyWriter; +import javax.ws.rs.ext.Provider; +import javax.ws.rs.ext.Providers; + +import org.onap.so.logger.MsoLogger; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.ObjectMapper; + +@Priority(1) +@Provider +@Component +public class JaxRsFilterLogging implements ContainerRequestFilter,ContainerResponseFilter { + + private static MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,JaxRsFilterLogging.class); + + @Context + private HttpServletRequest httpServletRequest; + + @Context + private Providers providers; + + @Autowired + ObjectMapper objectMapper; + + @Override + public void filter(ContainerRequestContext containerRequest) { + + try { + String clientID = null; + //check headers for request id + MultivaluedMap headers = containerRequest.getHeaders(); + String requestId = (String) headers.getFirst(MsoLogger.HEADER_REQUEST_ID ); + if(requestId == null || requestId.isEmpty()){ + if(headers.containsKey(MsoLogger.TRANSACTION_ID)){ + requestId = headers.getFirst(MsoLogger.TRANSACTION_ID); + }else if(headers.containsKey(MsoLogger.ECOMP_REQUEST_ID)){ + requestId = headers.getFirst(MsoLogger.ECOMP_REQUEST_ID); + }else{ + requestId = UUID.randomUUID().toString(); + logger.warnSimple(containerRequest.getUriInfo().getPath(),"Generating RequestId for Request"); + } + } + containerRequest.setProperty("requestId", requestId); + if(headers.containsKey(MsoLogger.CLIENT_ID)){ + clientID = headers.getFirst(MsoLogger.CLIENT_ID); + }else{ + clientID = "UNKNOWN"; + headers.add(MsoLogger.CLIENT_ID, clientID); + } + String remoteIpAddress = ""; + if (httpServletRequest != null) { + remoteIpAddress = httpServletRequest.getRemoteAddr(); + } + Instant instant = Instant.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX" ) + .withLocale( Locale.US ) + .withZone( ZoneId.systemDefault() ); + + String partnerName = headers.getFirst(MsoLogger.HEADER_FROM_APP_ID ); + if(partnerName == null || partnerName.isEmpty()) + partnerName="UNKNOWN"; + + MDC.put(MsoLogger.FROM_APP_ID,partnerName); + MDC.put(MsoLogger.SERVICE_NAME, containerRequest.getUriInfo().getPath()); + MDC.put(MsoLogger.BEGINTIME, formatter.format(instant)); + MDC.put(MsoLogger.REQUEST_ID,requestId); + MDC.put(MsoLogger.PARTNERNAME,partnerName); + MDC.put(MsoLogger.REMOTE_HOST, String.valueOf(remoteIpAddress)); + MDC.put(MsoLogger.STARTTIME, String.valueOf(System.currentTimeMillis())); + MDC.put(MsoLogger.CLIENT_ID, clientID); + } catch (Exception e) { + logger.warnSimple("Error in incoming JAX-RS Inteceptor", e); + } + } + + + @Override + public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) + throws IOException { + try { + Instant instant = Instant.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX" ) + .withLocale( Locale.US ) + .withZone( ZoneId.systemDefault() ); + String startTime= MDC.get(MsoLogger.STARTTIME); + long elapsedTime; + try { + elapsedTime = System.currentTimeMillis() - Long.parseLong(startTime); + }catch(NumberFormatException e){ + elapsedTime = 0; + } + String statusCode; + if(Response.Status.Family.familyOf(responseContext.getStatus()).equals(Response.Status.Family.SUCCESSFUL)){ + statusCode=MsoLogger.COMPLETE; + }else{ + statusCode= MsoLogger.StatusCode.ERROR.toString(); + } + + MDC.put(MsoLogger.RESPONSEDESC,payloadMessage(responseContext)); + MDC.put(MsoLogger.STATUSCODE, statusCode); + MDC.put(MsoLogger.RESPONSECODE,String.valueOf(responseContext.getStatus())); + MDC.put(MsoLogger.TIMER, String.valueOf(elapsedTime)); + MDC.put(MsoLogger.ENDTIME,formatter.format(instant)); + logger.recordAuditEvent(); + } catch ( Exception e) { + logger.warnSimple("Error in outgoing JAX-RS Inteceptor", e); + } + } + + private String payloadMessage(ContainerResponseContext responseContext) throws IOException { + String message = new String(); + if (responseContext.hasEntity()) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + Class entityClass = responseContext.getEntityClass(); + Type entityType = responseContext.getEntityType(); + Annotation[] entityAnnotations = responseContext.getEntityAnnotations(); + MediaType mediaType = responseContext.getMediaType(); + @SuppressWarnings("unchecked") + MessageBodyWriter bodyWriter = (MessageBodyWriter) providers.getMessageBodyWriter(entityClass, + entityType, + entityAnnotations, + mediaType); + bodyWriter.writeTo(responseContext.getEntity(), + entityClass, + entityType, + entityAnnotations, + mediaType, + responseContext.getHeaders(), + baos); + message = message.concat(new String(baos.toByteArray())); + } + return message; + } +} diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/jersey/SpringClientFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/jersey/SpringClientFilter.java new file mode 100644 index 0000000000..0477c9a429 --- /dev/null +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/jersey/SpringClientFilter.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.logging.jaxrs.filter.jersey; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpRequest; +import org.springframework.http.client.ClientHttpRequestExecution; +import org.springframework.http.client.ClientHttpRequestInterceptor; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.util.StreamUtils; + +import java.io.IOException; +import java.nio.charset.Charset; + +public class SpringClientFilter implements ClientHttpRequestInterceptor { + + private final Logger log = LoggerFactory.getLogger(this.getClass()); + + @Override + public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { + logRequest(request, body); + ClientHttpResponse response = execution.execute(request, body); + logResponse(response); + return response; + } + + private void logRequest(HttpRequest request, byte[] body) throws IOException { + if (log.isDebugEnabled()) { + log.debug("===========================request begin================================================"); + log.debug("URI : {}", request.getURI()); + log.debug("Method : {}", request.getMethod()); + log.debug("Headers : {}", request.getHeaders()); + log.debug("Request body: {}", new String(body, "UTF-8")); + log.debug("==========================request end================================================"); + } + } + + private void logResponse(ClientHttpResponse response) throws IOException { + if (log.isDebugEnabled()) { + log.debug("============================response begin=========================================="); + log.debug("Status code : {}", response.getStatusCode()); + log.debug("Status text : {}", response.getStatusText()); + log.debug("Headers : {}", response.getHeaders()); + log.debug("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset())); + log.debug("=======================response end================================================="); + } + } +} diff --git a/common/src/main/java/org/onap/so/openpojo/rules/CustomSetterMustExistRule.java b/common/src/main/java/org/onap/so/openpojo/rules/CustomSetterMustExistRule.java new file mode 100644 index 0000000000..2c6590afb3 --- /dev/null +++ b/common/src/main/java/org/onap/so/openpojo/rules/CustomSetterMustExistRule.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.openpojo.rules; + +import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.anything; +import static org.hamcrest.CoreMatchers.not; + +import org.hamcrest.Matcher; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoField; +import com.openpojo.validation.affirm.Affirm; +import com.openpojo.validation.rule.Rule; + +public class CustomSetterMustExistRule implements Rule { + + private Matcher[] excludeMatchers = new Matcher[]{not(anything())}; + private Matcher[] includeMatchers = new Matcher[]{anything()}; + public CustomSetterMustExistRule() { + } + @Override + public void evaluate(final PojoClass pojoClass) { + for (PojoField fieldEntry : pojoClass.getPojoFields()) { + if (!anyOf(excludeMatchers).matches(fieldEntry) && anyOf(includeMatchers).matches(fieldEntry) && !fieldEntry.isFinal() && !fieldEntry.hasSetter()) { + Affirm.fail(String.format("[%s] is missing a setter", fieldEntry)); + } + } + } + public CustomSetterMustExistRule exclude(Matcher... excludeMatchers) { + this.excludeMatchers = excludeMatchers; + return this; + } + + public CustomSetterMustExistRule include(Matcher... includeMatchers) { + this.includeMatchers = includeMatchers; + return this; + } + +} diff --git a/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java b/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java new file mode 100644 index 0000000000..5433681b83 --- /dev/null +++ b/common/src/main/java/org/onap/so/openpojo/rules/EqualsAndHashCodeTester.java @@ -0,0 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.openpojo.rules; + +import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.anything; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hamcrest.Matcher; + +import com.openpojo.business.annotation.BusinessKey; +import com.openpojo.random.RandomFactory; +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoField; +import com.openpojo.validation.affirm.Affirm; +import com.openpojo.validation.test.Tester; +import com.openpojo.validation.utils.ValidationHelper; + +public class EqualsAndHashCodeTester implements Tester { + + + private final Matcher m; + private boolean onlyDeclaredMethods = false; + public EqualsAndHashCodeTester() { + m = anything(); + } + + public EqualsAndHashCodeTester(Matcher m) { + this.m = m; + } + + public EqualsAndHashCodeTester onlyDeclaredMethods() { + this.onlyDeclaredMethods = true; + return this; + } + @Override + public void run(PojoClass pojoClass) { + Class clazz = pojoClass.getClazz(); + if (anyOf(m).matches(clazz)) { + final Object classInstanceOne = ValidationHelper.getBasicInstance(pojoClass); + final Object classInstanceTwo = ValidationHelper.getBasicInstance(pojoClass); + if (onlyDeclaredMethods) { + Method[] methods = classInstanceOne.getClass().getDeclaredMethods(); + boolean hasEquals = false; + boolean hasHashcode = false; + for (Method method : methods) { + if (method.getName().equals("equals")) { + hasEquals = true; + } else if (method.getName().equals("hashCode")) { + hasHashcode = true; + } + } + + if (!(hasEquals && hasHashcode)) { + return; + } + } + Set identityFields = hasIdOrBusinessKey(pojoClass); + List otherFields = new ArrayList<>(pojoClass.getPojoFields()); + otherFields.removeAll(identityFields); + + for (PojoField field : identityFields) { + final Object value = RandomFactory.getRandomValue(field); + + field.invokeSetter(classInstanceOne, value); + field.invokeSetter(classInstanceTwo, value); + } + + for (PojoField field : otherFields) { + if (field.hasSetter()) { + final Object valueOne = RandomFactory.getRandomValue(field); + final Object valueTwo = RandomFactory.getRandomValue(field); + + field.invokeSetter(classInstanceOne, valueOne); + field.invokeSetter(classInstanceTwo, valueTwo); + } + } + + Affirm.affirmTrue("Equals test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.equals(classInstanceTwo)); + + Affirm.affirmTrue("Equals test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.equals( + classInstanceOne)); + + Affirm.affirmTrue("HashCode test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.hashCode() == classInstanceTwo.hashCode()); + + Affirm.affirmFalse("Expected false for comparison of two unlike objects", classInstanceOne.equals("test")); + } + } + + + private Set hasIdOrBusinessKey(PojoClass pojoClass) { + final Set fields = new HashSet<>(); + + fields.addAll(pojoClass.getPojoFieldsAnnotatedWith(BusinessKey.class)); + fields.addAll(pojoClass.getPojoFieldsAnnotatedWith(Id.class)); + fields.removeAll(pojoClass.getPojoFieldsAnnotatedWith(GeneratedValue.class)); + + return fields; + + } + +} diff --git a/common/src/main/java/org/onap/so/openpojo/rules/HasAnnotationMatcher.java b/common/src/main/java/org/onap/so/openpojo/rules/HasAnnotationMatcher.java new file mode 100644 index 0000000000..6a06834d87 --- /dev/null +++ b/common/src/main/java/org/onap/so/openpojo/rules/HasAnnotationMatcher.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.openpojo.rules; + +import static org.hamcrest.CoreMatchers.anything; + +import java.lang.annotation.Annotation; +import java.lang.reflect.AnnotatedElement; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeDiagnosingMatcher; + +import com.openpojo.reflection.PojoField; + +public class HasAnnotationMatcher extends TypeSafeDiagnosingMatcher { + private final Class annotationType; + private final Matcher annotationMatcher; + + public HasAnnotationMatcher(final Class annotationType, final Matcher annotationMatcher) { + this.annotationType = annotationType; + this.annotationMatcher = annotationMatcher; + } + + @Override + protected boolean matchesSafely(final PojoField item, final Description mismatchDescription) { + final Annotation annotation = item.getAnnotation(this.annotationType); + if (annotation == null) { + mismatchDescription.appendText("does not have annotation ").appendText(this.annotationType.getName()); + return false; + } + + if (!this.annotationMatcher.matches(annotation)) { + this.annotationMatcher.describeMismatch(annotation, mismatchDescription); + return false; + } + + return true; + } + + @Override + public void describeTo(final Description description) { + // Intentionally left blank. + } + + public static Matcher hasAnnotation(final Class annotationType) { + return hasAnnotation(annotationType, anything("")); + } + + public static Matcher hasAnnotation(final Class annotationType, final Matcher annotationMatcher) { + return new HasAnnotationMatcher(annotationType, annotationMatcher); + } +} diff --git a/common/src/main/java/org/onap/so/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java b/common/src/main/java/org/onap/so/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java new file mode 100644 index 0000000000..551305c14a --- /dev/null +++ b/common/src/main/java/org/onap/so/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.openpojo.rules; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeDiagnosingMatcher; +import org.onap.so.logger.MsoLogger; + +import com.openpojo.reflection.PojoField; + +public class HasAnnotationPropertyWithValueMatcher extends TypeSafeDiagnosingMatcher { + private MsoLogger logger=MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, HasAnnotationPropertyWithValueMatcher.class); + private final String attribute; + private final Matcher annotationMatcher; + private final Class annotationClass; + public HasAnnotationPropertyWithValueMatcher(Class clazz, String attribute, final Matcher annotationMatcher) { + this.attribute = attribute; + this.annotationMatcher = annotationMatcher; + this.annotationClass = clazz; + } + + @Override + protected boolean matchesSafely(T obj, final Description mismatchDescription) { + final PojoField temp = (PojoField)obj; + final Method method; + try { + Annotation a = temp.getAnnotation(this.annotationClass); + if (a == null) { + mismatchDescription.appendText("does not have annotation ").appendText(this.annotationClass.getSimpleName()); + return false; + } + method = a.getClass().getMethod(attribute); + final Object result = method.invoke(a); + if (!this.annotationMatcher.matches(result)) { + this.annotationMatcher.describeMismatch(result, mismatchDescription); + return false; + } + } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + mismatchDescription.appendText("does not have property ").appendText(attribute); + logger.debug("Error occured", e); + return false; + } + return true; + } + + @Override + public void describeTo(final Description description) { + // Intentionally left blank. + } + + public static Matcher hasAnnotationPropertyWithValue(Class clazz, String attribute, final Matcher annotationMatcher) { + return new HasAnnotationPropertyWithValueMatcher(clazz, attribute, annotationMatcher); + } +} diff --git a/common/src/main/java/org/onap/so/openpojo/rules/HasEqualsAndHashCodeRule.java b/common/src/main/java/org/onap/so/openpojo/rules/HasEqualsAndHashCodeRule.java new file mode 100644 index 0000000000..0c7d6add73 --- /dev/null +++ b/common/src/main/java/org/onap/so/openpojo/rules/HasEqualsAndHashCodeRule.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.openpojo.rules; + +import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.anything; + +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; + +import org.hamcrest.Matcher; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.validation.affirm.Affirm; +import com.openpojo.validation.rule.Rule; + +/** + * This rule ensures that classes have overriden the default equals and hashCode methods from Object + */ +public class HasEqualsAndHashCodeRule implements Rule { + + private final Matcher m; + public HasEqualsAndHashCodeRule() { + m = anything(); + } + + public HasEqualsAndHashCodeRule(Matcher m) { + this.m = m; + } + @Override + public void evaluate(PojoClass pojoClass) { + Class clazz = pojoClass.getClazz(); + if (anyOf(m).matches(clazz)) { + boolean hasEquals = false; + boolean hasHashCode = false; + final String name = clazz.getSimpleName(); + final Method[] methods; + if (clazz.getSuperclass().equals(Object.class)) { + methods = clazz.getDeclaredMethods(); + } else { + methods = clazz.getMethods(); + } + for (Method method : methods) { + Parameter[] parameters = method.getParameters(); + if ("equals".equals(method.getName()) && boolean.class.equals(method.getReturnType()) && parameters.length == 1 && Object.class.equals(parameters[0].getType())) { + hasEquals = true; + } else if ("hashCode".equals(method.getName()) && int.class.equals(method.getReturnType())) { + hasHashCode = true; + } + } + + if (!hasEquals) { + Affirm.fail(String.format( + "[%s] does not override equals", name)); + } + if (!hasHashCode) { + Affirm.fail(String.format( + "[%s] does not override hashCode", name)); + } + } + } + +} diff --git a/common/src/main/java/org/onap/so/openpojo/rules/HasToStringRule.java b/common/src/main/java/org/onap/so/openpojo/rules/HasToStringRule.java new file mode 100644 index 0000000000..8a4333e0e2 --- /dev/null +++ b/common/src/main/java/org/onap/so/openpojo/rules/HasToStringRule.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.openpojo.rules; + +import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.anything; + +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; + +import org.hamcrest.Matcher; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.validation.affirm.Affirm; +import com.openpojo.validation.rule.Rule; + +public class HasToStringRule implements Rule { + + private final Matcher m; + public HasToStringRule() { + m = anything(); + } + + public HasToStringRule(Matcher m) { + this.m = m; + } + @Override + public void evaluate(PojoClass pojoClass) { + Class clazz = pojoClass.getClazz(); + if (anyOf(m).matches(clazz)) { + boolean hasToString = false; + final String name = clazz.getSimpleName(); + final Method[] methods; + if (clazz.getSuperclass().equals(Object.class)) { + methods = clazz.getDeclaredMethods(); + } else { + methods = clazz.getMethods(); + } + for (Method method : methods) { + Parameter[] parameters = method.getParameters(); + if ("toString".equals(method.getName()) && String.class.equals(method.getReturnType()) && parameters.length == 0) { + hasToString = true; + break; + } + } + + if (!hasToString) { + Affirm.fail(String.format( + "[%s] does not override toString", name)); + } + } + } + +} diff --git a/common/src/main/java/org/onap/so/openpojo/rules/ToStringTester.java b/common/src/main/java/org/onap/so/openpojo/rules/ToStringTester.java new file mode 100644 index 0000000000..ff1a139768 --- /dev/null +++ b/common/src/main/java/org/onap/so/openpojo/rules/ToStringTester.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.openpojo.rules; + +import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.anything; + +import org.hamcrest.Matcher; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.validation.affirm.Affirm; +import com.openpojo.validation.test.Tester; +import com.openpojo.validation.utils.ValidationHelper; + +public class ToStringTester implements Tester { + + private final Matcher m; + public ToStringTester() { + m = anything(); + } + + public ToStringTester(Matcher m) { + this.m = m; + } + + @Override + public void run(PojoClass pojoClass) { + Class clazz = pojoClass.getClazz(); + if (anyOf(m).matches(clazz)) { + final Object classInstance = ValidationHelper.getBasicInstance(pojoClass); + + Affirm.affirmFalse("Found default toString output", classInstance.toString().matches(Object.class.getName() + "@" + "\\w+")); + } + + } + +} diff --git a/common/src/main/java/org/onap/so/properties/MsoDatabaseException.java b/common/src/main/java/org/onap/so/properties/MsoDatabaseException.java new file mode 100644 index 0000000000..84216af6e8 --- /dev/null +++ b/common/src/main/java/org/onap/so/properties/MsoDatabaseException.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.properties; + + +/** + * Exception during artifact installation. + */ +public class MsoDatabaseException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = -7048331652191419371L; + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public MsoDatabaseException (final String message) { + super (message); + + } + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public MsoDatabaseException (final String message, final Throwable cause) { + super (message, cause); + + } +} diff --git a/common/src/main/java/org/onap/so/security/MSOSpringFirewall.java b/common/src/main/java/org/onap/so/security/MSOSpringFirewall.java new file mode 100644 index 0000000000..82a30f05be --- /dev/null +++ b/common/src/main/java/org/onap/so/security/MSOSpringFirewall.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.security; + +import org.springframework.security.web.firewall.StrictHttpFirewall; + +public class MSOSpringFirewall extends StrictHttpFirewall { + + + public MSOSpringFirewall() { + super(); + this.setAllowUrlEncodedSlash(true); + this.setAllowSemicolon(true); + this.setAllowUrlEncodedPercent(true); + } +} diff --git a/common/src/main/java/org/onap/so/security/UserCredentials.java b/common/src/main/java/org/onap/so/security/UserCredentials.java new file mode 100644 index 0000000000..f411789e00 --- /dev/null +++ b/common/src/main/java/org/onap/so/security/UserCredentials.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.security; + +public class UserCredentials { + + private String username; + private String password; + private String role; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + +} diff --git a/common/src/main/java/org/onap/so/security/UserDetailsServiceImpl.java b/common/src/main/java/org/onap/so/security/UserDetailsServiceImpl.java new file mode 100644 index 0000000000..90d484ebf4 --- /dev/null +++ b/common/src/main/java/org/onap/so/security/UserDetailsServiceImpl.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.security; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import java.util.List; + +@ConfigurationProperties(prefix = "spring.security") +public class UserDetailsServiceImpl implements UserDetailsService { + + private List usercredentials; + + public List getUsercredentials() { + return usercredentials; + } + + public void setUsercredentials(List usercredentials) { + this.usercredentials = usercredentials; + } + + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + + for (int i = 0; usercredentials != null && i < usercredentials.size(); i++) { + if (usercredentials.get(i).getUsername().equals(username)) { + return User.withUsername(username).password(usercredentials.get(i).getPassword()) + .roles(usercredentials.get(i).getRole()).build(); + } + } + + throw new UsernameNotFoundException("User not found, username: " + username); + } + +} diff --git a/common/src/main/java/org/onap/so/security/WebSecurityConfig.java b/common/src/main/java/org/onap/so/security/WebSecurityConfig.java new file mode 100644 index 0000000000..11eec46f41 --- /dev/null +++ b/common/src/main/java/org/onap/so/security/WebSecurityConfig.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.security; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.PostConstruct; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; + + +@ConfigurationProperties(prefix = "spring.security") +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + + private List credentials; + private List roles = new ArrayList<>(); + + public List getRoles() { + return roles; + } + + @PostConstruct + private void addRoles() { + for(int i=0; i getUsercredentials() { + return credentials; + } + + public void setUsercredentials(List usercredentials) { + this.credentials = usercredentials; + } + + @Bean + public UserDetailsService userDetailsService() { + return new UserDetailsServiceImpl(); + } + + @Bean + public BCryptPasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.userDetailsService(userDetailsService()).passwordEncoder(passwordEncoder()); + } + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java b/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java new file mode 100644 index 0000000000..a58949e498 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "cloudConfiguration") +@JsonInclude(Include.NON_DEFAULT) +public class CloudConfiguration implements Serializable { + + private static final long serialVersionUID = 6260165690180745471L; + @JsonProperty("aicNodeClli") + protected String aicNodeClli; + @JsonProperty("tenantId") + protected String tenantId; + @JsonProperty("lcpCloudRegionId") + protected String lcpCloudRegionId; + + /** + * Gets the value of the aicNodeClli property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAicNodeClli() { + return aicNodeClli; + } + + /** + * Sets the value of the aicNodeClli property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAicNodeClli(String value) { + this.aicNodeClli = value; + } + + /** + * Gets the value of the tenantId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTenantId() { + return tenantId; + } + + /** + * Sets the value of the tenantId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTenantId(String value) { + this.tenantId = value; + } + + + public String getLcpCloudRegionId() { + return lcpCloudRegionId; + } + + public void setLcpCloudRegionId(String lcpCloudRegionId) { + this.lcpCloudRegionId = lcpCloudRegionId; + } + + @Override + public String toString() { + return "CloudConfiguration [aicNodeClli=" + aicNodeClli + ", tenantId=" + + tenantId + ", lcpCloudRegionId=" + lcpCloudRegionId + "]"; + } + + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/ExceptionType.java b/common/src/main/java/org/onap/so/serviceinstancebeans/ExceptionType.java new file mode 100644 index 0000000000..e5d586f165 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/ExceptionType.java @@ -0,0 +1,168 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2016.05.03 at 03:56:30 PM CDT +// + + +package org.onap.so.serviceinstancebeans; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; + +import org.apache.commons.lang3.builder.ToStringBuilder; + + +/** + *

Java class for exceptionType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="exceptionType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="text" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="variables" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="50" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "exceptionType", propOrder = { + "messageId", + "text", + "variables" +}) +@XmlSeeAlso({ + ServiceException.class, + PolicyException.class +}) +public class ExceptionType { + + @XmlElement(required = true) + protected String messageId; + @XmlElement(required = true) + protected String text; + protected List variables; + + /** + * Gets the value of the messageId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMessageId() { + return messageId; + } + + /** + * Sets the value of the messageId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMessageId(String value) { + this.messageId = value; + } + + /** + * Gets the value of the text property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getText() { + return text; + } + + /** + * Sets the value of the text property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setText(String value) { + this.text = value; + } + + /** + * Gets the value of the variables property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the variables property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getVariables().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getVariables() { + if (variables == null) { + variables = new ArrayList<>(); + } + return this.variables; + } + + public void setVariables(List variables) { + this.variables = variables; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("messageId", messageId).append("text", text) + .append("variables", variables).toString(); + } +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/GetOrchestrationListResponse.java b/common/src/main/java/org/onap/so/serviceinstancebeans/GetOrchestrationListResponse.java new file mode 100644 index 0000000000..7be03e635f --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/GetOrchestrationListResponse.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import org.apache.commons.lang3.builder.ToStringBuilder; + +@JsonInclude(Include.NON_DEFAULT) +public class GetOrchestrationListResponse { + + protected List requestList; + + public List getRequestList() { + return requestList; + } + + public void setRequestList(List requestList) { + this.requestList = requestList; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("requestList", requestList).toString(); + } + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/GetOrchestrationResponse.java b/common/src/main/java/org/onap/so/serviceinstancebeans/GetOrchestrationResponse.java new file mode 100644 index 0000000000..788cdd973d --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/GetOrchestrationResponse.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +@JsonInclude(Include.NON_DEFAULT) +public class GetOrchestrationResponse { + + protected Request request; + + public Request getRequest() { + return request; + } + + public void setRequest(Request request) { + this.request = request; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("request", request).toString(); + } + + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/InstanceDirection.java b/common/src/main/java/org/onap/so/serviceinstancebeans/InstanceDirection.java new file mode 100644 index 0000000000..ad796b21f9 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/InstanceDirection.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +public enum InstanceDirection { + + source, + destination; + + public String value() { + return name(); + } + + public static InstanceDirection fromValue(String v) { + return valueOf(v); + } +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/InstanceReferences.java b/common/src/main/java/org/onap/so/serviceinstancebeans/InstanceReferences.java new file mode 100644 index 0000000000..69d21c41ac --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/InstanceReferences.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonInclude(Include.NON_DEFAULT) +public class InstanceReferences { + + protected String serviceInstanceId; + protected String serviceInstanceName; + protected String vnfInstanceId; + protected String vnfInstanceName; + protected String vfModuleInstanceId; + protected String vfModuleInstanceName; + protected String volumeGroupInstanceId; + protected String volumeGroupInstanceName; + protected String networkInstanceId; + protected String networkInstanceName; + protected String requestorId; + + + 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 getVnfInstanceId() { + return vnfInstanceId; + } + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + public String getVnfInstanceName() { + return vnfInstanceName; + } + public void setVnfInstanceName(String vnfInstanceName) { + this.vnfInstanceName = vnfInstanceName; + } + public String getVfModuleInstanceId() { + return vfModuleInstanceId; + } + public void setVfModuleInstanceId(String vfModuleInstanceId) { + this.vfModuleInstanceId = vfModuleInstanceId; + } + public String getVfModuleInstanceName() { + return vfModuleInstanceName; + } + public void setVfModuleInstanceName(String vfModuleInstanceName) { + this.vfModuleInstanceName = vfModuleInstanceName; + } + public String getVolumeGroupInstanceId() { + return volumeGroupInstanceId; + } + public void setVolumeGroupInstanceId(String volumeGroupInstanceId) { + this.volumeGroupInstanceId = volumeGroupInstanceId; + } + public String getVolumeGroupInstanceName() { + return volumeGroupInstanceName; + } + public void setVolumeGroupInstanceName(String volumeGroupInstanceName) { + this.volumeGroupInstanceName = volumeGroupInstanceName; + } + public String getNetworkInstanceId() { + return networkInstanceId; + } + public void setNetworkInstanceId(String networkInstanceId) { + this.networkInstanceId = networkInstanceId; + } + public String getNetworkInstanceName() { + return networkInstanceName; + } + public void setNetworkInstanceName(String networkInstanceName) { + this.networkInstanceName = networkInstanceName; + } + + public String getRequestorId() { + return requestorId; + } + + public void setRequestorId(String requestorId) { + this.requestorId = requestorId; + } + @Override + public String toString() { + return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId) + .append("serviceInstanceName", serviceInstanceName).append("vnfInstanceId", vnfInstanceId) + .append("vnfInstanceName", vnfInstanceName).append("vfModuleInstanceId", vfModuleInstanceId) + .append("vfModuleInstanceName", vfModuleInstanceName) + .append("volumeGroupInstanceId", volumeGroupInstanceId) + .append("volumeGroupInstanceName", volumeGroupInstanceName) + .append("networkInstanceId", networkInstanceId).append("networkInstanceName", networkInstanceName) + .append("requestorId", requestorId).toString(); + } +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/LineOfBusiness.java b/common/src/main/java/org/onap/so/serviceinstancebeans/LineOfBusiness.java new file mode 100644 index 0000000000..27bc0e84a4 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/LineOfBusiness.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.ToStringBuilder; + +@JsonRootName(value = "lineOfBusiness") +@JsonInclude(Include.NON_DEFAULT) +public class LineOfBusiness implements Serializable { + + private static final long serialVersionUID = -8574860788160041209L; + @JsonProperty("lineOfBusinessName") + private String lineOfBusinessName; + + public String getLineOfBusinessName(){ + return lineOfBusinessName; + } + public void setLineOfBusinessName(String value){ + this.lineOfBusinessName = value; + } + @Override + public String toString() { + return new ToStringBuilder(this).append("lineOfBusinessName", lineOfBusinessName).toString(); + } +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/ModelInfo.java b/common/src/main/java/org/onap/so/serviceinstancebeans/ModelInfo.java new file mode 100644 index 0000000000..6976fb6791 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/ModelInfo.java @@ -0,0 +1,169 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2016.03.30 at 02:48:23 PM CDT +// + + +package org.onap.so.serviceinstancebeans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "modelInfo") +@JsonInclude(Include.NON_DEFAULT) +public class ModelInfo implements Serializable { + + private static final long serialVersionUID = 5281763573935476852L; + @JsonProperty("modelCustomizationName") + protected String modelCustomizationName; + @JsonProperty("modelInvariantId") + protected String modelInvariantId; + @JsonProperty("modelType") + protected ModelType modelType; + @JsonProperty("modelId") + protected String modelId; + //v2 + @JsonProperty("modelNameVersionId") + protected String modelNameVersionId; + @JsonProperty("modelName") + protected String modelName; + @JsonProperty("modelVersion") + protected String modelVersion; + @JsonProperty("modelCustomizationUuid") + protected String modelCustomizationUuid; + //v3 + @JsonProperty("modelVersionId") + protected String modelVersionId; + @JsonProperty("modelCustomizationId") + protected String modelCustomizationId; + + //Decomposition fields + @JsonProperty("modelUuid") + protected String modelUuid; + @JsonProperty("modelInvariantUuid") + protected String modelInvariantUuid; + @JsonProperty("modelInstanceName") + protected String modelInstanceName; + + public String getModelCustomizationName() { + return modelCustomizationName; + } + public void setModelCustomizationName(String modelCustomizationName) { + modelInstanceName = modelCustomizationName; + this.modelCustomizationName = modelCustomizationName; + } + public String getModelNameVersionId() { + return modelNameVersionId; + } + public void setModelNameVersionId(String modelNameVersionId) { + this.modelNameVersionId = modelNameVersionId; + } + public String getModelName() { + return modelName; + } + public void setModelName(String modelName) { + this.modelName = modelName; + } + public String getModelVersion() { + return modelVersion; + } + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + public ModelType getModelType() { + return modelType; + } + public void setModelType(ModelType modelType) { + this.modelType = modelType; + } + public String getModelInvariantId() { + return modelInvariantId; + } + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantUuid = modelInvariantId; + this.modelInvariantId = modelInvariantId; + } + public String getModelCustomizationUuid() { + return modelCustomizationUuid; + } + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public String getModelVersionId() { + return modelVersionId; + } + public void setModelVersionId(String modelVersionId) { + this.modelUuid=modelVersionId; + this.modelVersionId = modelVersionId; + } + public String getModelCustomizationId() { + return modelCustomizationId; + } + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationUuid = modelCustomizationId; + this.modelCustomizationId = modelCustomizationId; + } + public String getModelUuid() { + return modelUuid; + } + public String getModelId() { + return modelId; + } + public void setModelUuid(String modelUuid) { + this.modelId = modelUuid; + this.modelUuid = modelUuid; + + } + public void setModelId(String modelId) { + this.modelId = modelId; + } + public String getModelInvariantUuid() { + return modelInvariantUuid; + } + public void setModelInvariantUuid(String modelInvariantUuid) { + this.modelInvariantUuid = modelInvariantUuid; + } + public String getModelInstanceName() { + return modelInstanceName; + } + public void setModelInstanceName(String modelInstanceName) { + this.modelInstanceName = modelInstanceName; + } + @Override + public String toString() { + return "ModelInfo [modelCustomizationName=" + modelCustomizationName + ", modelInvariantId=" + modelInvariantId + + ", modelType=" + modelType + ", modelNameVersionId=" + modelNameVersionId + ", modelName=" + modelName + + ", modelVersion=" + modelVersion + ", modelCustomizationUuid=" + modelCustomizationUuid + + ", modelVersionId=" + modelVersionId + ", modelCustomizationId=" + modelCustomizationId + + ", modelUuid=" + modelUuid + ", modelInvariantUuid=" + modelInvariantUuid + ", modelInstanceName=" + + modelInstanceName + "]"; + } + + +} \ No newline at end of file diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java b/common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java new file mode 100644 index 0000000000..2ddad20346 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/ModelType.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +/* + * Enum for Model Type values returned by API Handler to BPMN +*/ +public enum ModelType { + service, + vnf, + vfModule, + volumeGroup, + network, + configuration, + connectionPoint, + pnf, + networkCollection +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Networks.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Networks.java new file mode 100644 index 0000000000..386078a60b --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Networks.java @@ -0,0 +1,98 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.so.serviceinstancebeans; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonRootName(value = "networks") +@JsonInclude(Include.NON_DEFAULT) +public class Networks implements Serializable{ + + private static final long serialVersionUID = 8081495240474276501L; + @JsonProperty("modelInfo") + protected ModelInfo modelInfo; + @JsonProperty("cloudConfiguration") + protected CloudConfiguration cloudConfiguration; + @JsonProperty("instanceName") + protected String instanceName; + @JsonProperty("productFamilyId") + protected String productFamilyId; + @JsonProperty("instanceParams") + private List> instanceParams = new ArrayList<>(); + + public ModelInfo getModelInfo() { + return modelInfo; + } + + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + public CloudConfiguration getCloudConfiguration() { + return cloudConfiguration; + } + + public void setCloudConfiguration(CloudConfiguration cloudConfiguration) { + this.cloudConfiguration = cloudConfiguration; + } + + public String getInstanceName() { + return instanceName; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public String getProductFamilyId() { + return productFamilyId; + } + + public void setProductFamilyId(String productFamilyId) { + this.productFamilyId = productFamilyId; + } + + public List> getInstanceParams() { + return instanceParams; + } + + public void setInstanceParams(List> instanceParams) { + this.instanceParams = instanceParams; + } + + @Override + public String toString() { + return "Networks [modelInfo=" + modelInfo + + ", cloudConfiguration=" + cloudConfiguration + + ", instanceName=" + instanceName + ", productFamilyId=" + productFamilyId + + ", instanceParams=" + instanceParams + "]"; + } + +} \ No newline at end of file diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/OwningEntity.java b/common/src/main/java/org/onap/so/serviceinstancebeans/OwningEntity.java new file mode 100644 index 0000000000..f552554ad4 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/OwningEntity.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "owningEntity") +@JsonInclude(Include.NON_DEFAULT) +public class OwningEntity implements Serializable { + + private static final long serialVersionUID = -3907033130633428448L; + @JsonProperty("owningEntityId") + private String owningEntityId; + @JsonProperty("owningEntityName") + private String owningEntityName; + + public String getOwningEntityId(){ + return owningEntityId; + } + + public void setOwningEntityId(String value) { + this.owningEntityId = value; + } + + public String getOwningEntityName(){ + return owningEntityName; + } + + public void setOwningEntityName(String value){ + this.owningEntityName = value; + } + @Override + public String toString() { + return "OwningEntity [owningEntityId=" + owningEntityId + + ", owningEntityName=" + owningEntityName + "]"; + } +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Platform.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Platform.java new file mode 100644 index 0000000000..961062299f --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Platform.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.ToStringBuilder; + +@JsonInclude(Include.NON_DEFAULT) +@JsonRootName(value = "platform") +public class Platform implements Serializable { + + private static final long serialVersionUID = -7334479240678605536L; + @JsonProperty("platformName") + private String platformName; + + public String getPlatformName(){ + return platformName; + } + public void setPlatformName(String value){ + this.platformName = value; + } + @Override + public String toString() { + return new ToStringBuilder(this).append("platformName", platformName).toString(); + } +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/PolicyException.java b/common/src/main/java/org/onap/so/serviceinstancebeans/PolicyException.java new file mode 100644 index 0000000000..263089e5c1 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/PolicyException.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2016.03.30 at 02:48:23 PM CDT +// + + +package org.onap.so.serviceinstancebeans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for policyException complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="policyException">
+ *   <complexContent>
+ *     <extension base="{http://org.onap/so/request/types/v1}exceptionType">
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "policyException") +public class PolicyException + extends ExceptionType +{ + + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Project.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Project.java new file mode 100644 index 0000000000..47bd2bb802 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Project.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.ToStringBuilder; + +@JsonRootName(value = "project") +@JsonInclude(Include.NON_DEFAULT) +public class Project implements Serializable { + + private static final long serialVersionUID = -3868114191925177035L; + @JsonProperty("projectName") + private String projectName; + + public String getProjectName(){ + return projectName; + } + + public void setProjectName(String value) { + this.projectName = value; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("projectName", projectName).toString(); + } +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RelatedInstance.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RelatedInstance.java new file mode 100644 index 0000000000..cfdba18fe1 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RelatedInstance.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.ToStringBuilder; + +@JsonRootName(value = "relatedInstance") +@JsonInclude(Include.NON_DEFAULT) +public class RelatedInstance implements Serializable { + + private static final long serialVersionUID = 137250604008221644L; + @JsonProperty("instanceName") + protected String instanceName; + @JsonProperty("instanceId") + protected String instanceId; + @JsonProperty("modelInfo") + protected ModelInfo modelInfo; + //Configuration field + @JsonProperty("instanceDirection") + protected InstanceDirection instanceDirection; + + + public String getInstanceName() { + return instanceName; + } + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + public String getInstanceId() { + return instanceId; + } + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + public ModelInfo getModelInfo() { + return modelInfo; + } + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + public InstanceDirection getInstanceDirection() { + return instanceDirection; + } + public void setInstanceDirection(InstanceDirection instanceDirection) { + this.instanceDirection = instanceDirection; + } + @Override + public String toString() { + return new ToStringBuilder(this).append("instanceName", instanceName).append("instanceId", instanceId) + .append("modelInfo", modelInfo).append("instanceDirection", instanceDirection).toString(); + } +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RelatedInstanceList.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RelatedInstanceList.java new file mode 100644 index 0000000000..9d10865e24 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RelatedInstanceList.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "relatedInstanceList") +@JsonInclude(Include.NON_DEFAULT) +public class RelatedInstanceList implements Serializable { + + private static final long serialVersionUID = 6333898302094446243L; + @JsonProperty("relatedInstance") + protected RelatedInstance relatedInstance; + + public RelatedInstance getRelatedInstance() { + return relatedInstance; + } + + public void setRelatedInstance(RelatedInstance relatedInstance) { + this.relatedInstance = relatedInstance; + } + + @Override + public String toString() { + return "RelatedInstanceList [relatedInstance=" + relatedInstance + "]"; + } + + + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java new file mode 100644 index 0000000000..bda3096f05 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import org.apache.commons.lang3.builder.ToStringBuilder; + + +@JsonInclude(Include.NON_DEFAULT) +public class Request { + + protected String requestId; + protected String startTime; + protected String requestScope; + protected String requestType; + protected RequestDetails requestDetails; + protected InstanceReferences instanceReferences; + protected RequestStatus requestStatus; + + + public String getRequestId() { + return requestId; + } + public void setRequestId(String requestId) { + this.requestId = requestId; + } + public String getStartTime() { + return startTime; + } + public void setStartTime(String startTime) { + this.startTime = startTime; + } + public String getRequestScope() { + return requestScope; + } + public void setRequestScope(String requestScope) { + this.requestScope = requestScope; + } + public String getRequestType() { + return requestType; + } + public void setRequestType(String requestType) { + this.requestType = requestType; + } + public RequestStatus getRequestStatus() { + return requestStatus; + } + public void setRequestStatus(RequestStatus requestStatus) { + this.requestStatus = requestStatus; + } + public InstanceReferences getInstanceReferences() { + return instanceReferences; + } + public void setInstanceReferences(InstanceReferences instanceReferences) { + this.instanceReferences = instanceReferences; + } + public RequestDetails getRequestDetails() { + return requestDetails; + } + public void setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } + @Override + public String toString() { + return new ToStringBuilder(this).append("requestId", requestId).append("startTime", startTime) + .append("requestScope", requestScope).append("requestType", requestType) + .append("requestDetails", requestDetails).append("instanceReferences", instanceReferences) + .append("requestStatus", requestStatus).toString(); + } + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestDetails.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestDetails.java new file mode 100644 index 0000000000..d71334288e --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestDetails.java @@ -0,0 +1,303 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "requestDetails") +@JsonInclude(Include.NON_DEFAULT) +public class RequestDetails implements Serializable { + + private static final long serialVersionUID = -73080684945860609L; + @JsonProperty("modelInfo") + protected ModelInfo modelInfo; + @JsonProperty("requestInfo") + protected RequestInfo requestInfo; + @JsonProperty("relatedInstanceList") + protected RelatedInstanceList[] relatedInstanceList; + @JsonProperty("subscriberInfo") + protected SubscriberInfo subscriberInfo; + @JsonProperty("cloudConfiguration") + protected CloudConfiguration cloudConfiguration; + @JsonProperty("requestParameters") + protected RequestParameters requestParameters; + @JsonProperty("project") + protected Project project; + @JsonProperty("owningEntity") + protected OwningEntity owningEntity; + @JsonProperty("platform") + protected Platform platform; + @JsonProperty("lineOfBusiness") + protected LineOfBusiness lineOfBusiness; + @JsonProperty("instanceName") + private List> instanceName = new ArrayList<>(); + + + /** + * Gets the value of the serviceInfo property. + * + * @return + * possible object is + * {@link ModelInfo } + * + */ + public ModelInfo getModelInfo() { + return modelInfo; + } + + /** + * Sets the value of the serviceInfo property. + * + * @param value + * allowed object is + * {@link ModelInfo } + * + */ + public void setModelInfo(ModelInfo value) { + this.modelInfo = value; + } + + /** + * Gets the value of the requestInfo property. + * + * @return + * possible object is + * {@link RequestInfo } + * + */ + public RequestInfo getRequestInfo() { + return requestInfo; + } + + /** + * Sets the value of the requestInfo property. + * + * @param value + * allowed object is + * {@link RequestInfo } + * + */ + public void setRequestInfo(RequestInfo value) { + this.requestInfo = value; + } + + /** + * Gets the value of the subscriberInfo property. + * + * @return + * possible object is + * {@link SubscriberInfo } + * + */ + public SubscriberInfo getSubscriberInfo() { + return subscriberInfo; + } + + /** + * Sets the value of the subscriberInfo property. + * + * @param value + * allowed object is + * {@link SubscriberInfo } + * + */ + public void setSubscriberInfo(SubscriberInfo value) { + this.subscriberInfo = value; + } + + /** + * Gets the value of the cloudConfiguration property. + * + * @return + * possible object is + * {@link CloudConfiguration } + * + */ + public CloudConfiguration getCloudConfiguration() { + return cloudConfiguration; + } + + /** + * Sets the value of the cloudConfiguration property. + * + * @param value + * allowed object is + * {@link CloudConfiguration } + * + */ + public void setCloudConfiguration(CloudConfiguration value) { + this.cloudConfiguration = value; + } + + /** + * Gets the value of the requestParameters property. + * + * @return + * possible object is + * {@link RequestParameters } + * + */ + public RequestParameters getRequestParameters() { + return requestParameters; + } + + /** + * Sets the value of the requestParameters property. + * + * @param value + * allowed object is + * {@link RequestParameters } + * + */ + public void setRequestParameters(RequestParameters value) { + this.requestParameters = value; + } + + public RelatedInstanceList[] getRelatedInstanceList() { + return relatedInstanceList; + } + + public void setRelatedInstanceList(RelatedInstanceList[] relatedInstanceList) { + this.relatedInstanceList = relatedInstanceList; + } + /** + * Gets the value of the project property. + * + * @return + * possible object is + * {@link Project } + * + */ + public Project getProject(){ + return project; + } + /** + * Sets the value of the project property. + * + * @param value + * allowed object is + * {@link Project } + * + */ + public void setProject(Project value){ + this.project = value; + } + /** + * Gets the value of the owningEntity property. + * + * @return + * possible object is + * {@link OwningEntity } + * + */ + public OwningEntity getOwningEntity(){ + return owningEntity; + } + /** + * Sets the value of the owningEntity property. + * + * @param value + * allowed object is + * {@link OwningEntity } + * + */ + public void setOwningEntity(OwningEntity value){ + this.owningEntity = value; + } + /** + * Gets the value of the platform property. + * + * @return + * possible object is + * {@link Platform } + * + */ + public Platform getPlatform(){ + return platform; + } + /** + * Sets the value of the platform property. + * + * @param value + * allowed object is + * {@link Platform } + * + */ + public void setPlatform(Platform value){ + this.platform = value; + } + /** + * Gets the value of the lineOfBusiness property. + * + * @return + * possible object is + * {@link LineOfBusiness } + * + */ + public LineOfBusiness getLineOfBusiness(){ + return lineOfBusiness; + } + /** + * Sets the value of the lineOfBusiness property. + * + * @param value + * allowed object is + * {@link LineOfBusiness } + * + */ + public void setLineOfBusiness(LineOfBusiness value){ + this.lineOfBusiness = value; + } + /** + * Gets the value of the instanceName property. + */ + public List> getInstanceName() { + return instanceName; + } + /** + * Sets the value of the instanceName property. + * + * @param value + * + */ + public void setInstanceName(List> instanceName) { + this.instanceName = instanceName; + } + @Override + public String toString() { + return "RequestDetails [modelInfo=" + modelInfo + ", requestInfo=" + + requestInfo + ", relatedInstanceList=" + + Arrays.toString(relatedInstanceList) + ", subscriberInfo=" + + subscriberInfo + ", cloudConfiguration=" + cloudConfiguration + + ", requestParameters=" + requestParameters + ", platform=" + platform + + ", lineOfBusiness=" + ", project=" + project + ", owningEntity=" + owningEntity + + ", instanceName" + instanceName + "]"; + } +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestError.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestError.java new file mode 100644 index 0000000000..76137d0f58 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestError.java @@ -0,0 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2016.04.07 at 08:25:52 AM CDT +// + + +package org.onap.so.serviceinstancebeans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.fasterxml.jackson.annotation.JsonRootName; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <choice>
+ *           <element name="policyException" type="{http://org.onap/so/request/types/v1}policyException"/>
+ *           <element name="serviceException" type="{http://org.onap/so/request/types/v1}serviceException"/>
+ *         </choice>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "policyException", + "serviceException" +}) +@XmlRootElement(name = "requestError") +@JsonRootName(value = "requestError") +public class RequestError { + + protected PolicyException policyException; + protected ServiceException serviceException; + + /** + * Gets the value of the policyException property. + * + * @return + * possible object is + * {@link PolicyException } + * + */ + public PolicyException getPolicyException() { + return policyException; + } + + /** + * Sets the value of the policyException property. + * + * @param value + * allowed object is + * {@link PolicyException } + * + */ + public void setPolicyException(PolicyException value) { + this.policyException = value; + } + + /** + * Gets the value of the serviceException property. + * + * @return + * possible object is + * {@link ServiceException } + * + */ + public ServiceException getServiceException() { + return serviceException; + } + + /** + * Sets the value of the serviceException property. + * + * @param value + * allowed object is + * {@link ServiceException } + * + */ + public void setServiceException(ServiceException value) { + this.serviceException = value; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("policyException", policyException) + .append("serviceException", serviceException).toString(); + } + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java new file mode 100644 index 0000000000..158ca7a819 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java @@ -0,0 +1,239 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; + +@JsonRootName(value = "requestInfo") +@JsonInclude(Include.NON_DEFAULT) +public class RequestInfo implements Serializable { + + private static final long serialVersionUID = -1370946827136030181L; + @JsonProperty("billingAccountNumber") + protected String billingAccountNumber; + @JsonProperty("callbackUrl") + protected String callbackUrl; + @JsonProperty("correlator") + protected String correlator; + @JsonProperty("orderNumber") + protected String orderNumber; + @JsonProperty("productFamilyId") + protected String productFamilyId; + @JsonProperty("orderVersion") + protected Integer orderVersion; + @JsonSerialize(include=Inclusion.ALWAYS) + @JsonProperty("source") + protected String source; + @JsonProperty("instanceName") + protected String instanceName; + @JsonProperty("suppressRollback") + @JsonSerialize(include=Inclusion.ALWAYS) + protected boolean suppressRollback; + @JsonProperty("requestorId") + protected String requestorId; + + /** + * Gets the value of the callbackUrl property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCallbackUrl() { + return callbackUrl; + } + + /** + * Sets the value of the callbackUrl property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCallbackUrl(String value) { + this.callbackUrl = value; + } + + /** + * Gets the value of the correlator property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCorrelator() { + return correlator; + } + + /** + * Sets the value of the correlator property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCorrelator(String value) { + this.correlator = value; + } + + /** + * Gets the value of the orderNumber property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getOrderNumber() { + return orderNumber; + } + + /** + * Sets the value of the orderNumber property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setOrderNumber(String value) { + this.orderNumber = value; + } + + /** + * Gets the value of the orderVersion property. + * + * @return + * possible object is + * {@link Integer } + * + */ + public Integer getOrderVersion() { + return orderVersion; + } + + /** + * Sets the value of the orderVersion property. + * + * @param value + * allowed object is + * {@link Integer } + * + */ + public void setOrderVersion(Integer value) { + this.orderVersion = value; + } + + /** + * Gets the value of the source property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSource() { + if(null == source || source.isEmpty()){ + source = "VID"; + } + return source; + } + + /** + * Sets the value of the source property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSource(String value) { + this.source = value; + } + + public String getInstanceName() { + return instanceName; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public String getBillingAccountNumber() { + return billingAccountNumber; + } + + public void setBillingAccountNumber(String billingAccountNumber) { + this.billingAccountNumber = billingAccountNumber; + } + + public String getProductFamilyId() { + return productFamilyId; + } + + public void setProductFamilyId(String productFamilyId) { + this.productFamilyId = productFamilyId; + } + + /** + * Required for Marshalers to send the fields. + * @return + */ + public boolean getSuppressRollback() { + return suppressRollback; + } + + public void setSuppressRollback(boolean suppressRollback) { + this.suppressRollback = suppressRollback; + } + + public String getRequestorId() { + return requestorId; + } + + public void setRequestorId(String requestorId) { + this.requestorId = requestorId; + } + + @Override + public String toString() { + return "RequestInfo [billingAccountNumber=" + billingAccountNumber + + ", callbackUrl=" + callbackUrl + ", correlator=" + correlator + + ", orderNumber=" + orderNumber + ", productFamilyId=" + + productFamilyId + ", orderVersion=" + orderVersion + + ", source=" + source + ", instanceName=" + instanceName + + ", suppressRollback=" + suppressRollback + ", requestorId=" + + requestorId + "]"; + } + + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestList.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestList.java new file mode 100644 index 0000000000..a4c0ddfcf2 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestList.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.util.List; +import org.apache.commons.lang3.builder.ToStringBuilder; + + +public class RequestList { + + protected Request request; + + public Request getRequest() { + return request; + } + + public void setRequest(Request request) { + this.request = request; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("request", request).toString(); + } + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java new file mode 100644 index 0000000000..1697a4eb5f --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java @@ -0,0 +1,171 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.persistence.Transient; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "requestParameters") +@JsonInclude(Include.NON_DEFAULT) +public class RequestParameters implements Serializable { + + private static final long serialVersionUID = -5979049912538894930L; + @JsonProperty("subscriptionServiceType") + private String subscriptionServiceType; + @JsonProperty("userParams") + private List> userParams = new ArrayList<>(); + @JsonProperty("aLaCarte") + private Boolean aLaCarte; + + // DONOT USE. It is intended to handle older VID requests(prior to 1802) + @Deprecated + @JsonProperty("alaCarte") + private Boolean alaCarte; + @JsonProperty("autoBuildVfModules") + private Boolean autoBuildVfModules; + @JsonProperty("cascadeDelete") + private Boolean cascadeDelete; + @JsonProperty("testApi") + private String testApi; // usePreload would always be true for Update + @JsonProperty("usePreload") + private Boolean usePreload; // usePreload would always be true for Update + @JsonProperty("rebuildVolumeGroups") + private Boolean rebuildVolumeGroups; + @JsonProperty("payload") + private String payload; + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + @JsonProperty("aLaCarte") + public Boolean getALaCarte() { + return aLaCarte; + } + @JsonProperty("aLaCarte") + public void setaLaCarte(Boolean aLaCarte) { + this.aLaCarte = aLaCarte; + } + + public Boolean isaLaCarte() { + return aLaCarte; + } + + @Deprecated + @Transient + @JsonProperty("alaCarte") + public Boolean getAlaCarte() { + return alaCarte; + } + + @Deprecated + @JsonProperty("alaCarte") + public void setAlaCarte(Boolean alaCarte) { + this.alaCarte = alaCarte; + } + + public String getTestApi() { + return testApi; + } + + public void setTestApi(String testApi) { + this.testApi = testApi; + } + + public List> getUserParams() { + return userParams; + } + + public void setUserParams(List> userParams) { + this.userParams = userParams; + } + + public String getUserParamValue(String name){ + if(userParams!=null){ + for(Map param:userParams){ + if(param.get("name").equals(name)){ + return param.get("value").toString(); + } + } + } + return null; + } + + public Boolean getAutoBuildVfModules() { + return autoBuildVfModules; + } + + public void setAutoBuildVfModules(Boolean autoBuildVfModules) { + this.autoBuildVfModules = autoBuildVfModules; + } + + public Boolean getCascadeDelete() { + return cascadeDelete; + } + + public void setCascadeDelete(Boolean cascadeDelete) { + this.cascadeDelete = cascadeDelete; + } + + public Boolean isUsePreload() { + return usePreload; + } + + public void setUsePreload(Boolean usePreload) { + this.usePreload = usePreload; + } + + public Boolean getRebuildVolumeGroups() { + return rebuildVolumeGroups; + } + + public void setRebuildVolumeGroups(Boolean rebuildVolumeGroups) { + this.rebuildVolumeGroups = rebuildVolumeGroups; + } + public String getPayload(){ + return payload; + } + public void setPayload(String value){ + this.payload = value; + } + + @Override + public String toString() { + return "RequestParameters [subscriptionServiceType=" + + subscriptionServiceType + ", userParams=" + userParams + + ", aLaCarte=" + aLaCarte + ", testApi= " + testApi + ", autoBuildVfModules=" + + autoBuildVfModules + ", usePreload=" + + usePreload + ", rebuildVolumeGroups=" + + rebuildVolumeGroups + ", payload=" + payload + "]"; + } +} \ No newline at end of file diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestReferences.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestReferences.java new file mode 100644 index 0000000000..c30e39a028 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestReferences.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonRootName; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonRootName(value = "requestReferences") +@JsonInclude(Include.NON_DEFAULT) +public class RequestReferences { + + String requestId; + String instanceId; + + + public String getRequestId() { + return requestId; + } + public void setRequestId(String requestId) { + this.requestId = requestId; + } + public String getInstanceId() { + return instanceId; + } + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + @Override + public String toString() { + return new ToStringBuilder(this).append("requestId", requestId).append("instanceId", instanceId).toString(); + } + + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java new file mode 100644 index 0000000000..527aa037ed --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import org.apache.commons.lang3.builder.ToStringBuilder; + +@JsonInclude(Include.NON_DEFAULT) +public class RequestStatus { + + protected String requestState; + protected String statusMessage; + protected Integer percentProgress; + protected String finishTime; + + + public String getRequestState() { + return requestState; + } + public void setRequestState(String requestState) { + this.requestState = requestState; + } + public String getStatusMessage() { + return statusMessage; + } + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + public Integer getPercentProgress() { + return percentProgress; + } + public void setPercentProgress(Integer percentProgress) { + this.percentProgress = percentProgress; + } + public String getFinishTime() { + return finishTime; + } + public void setFinishTime(String finishTime) { + this.finishTime = finishTime; + } + @Override + public String toString() { + return new ToStringBuilder(this).append("requestState", requestState).append("statusMessage", statusMessage) + .append("percentProgress", percentProgress).append("finishTime", finishTime).toString(); + } +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Resources.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Resources.java new file mode 100644 index 0000000000..68fd95c293 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Resources.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.so.serviceinstancebeans; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "resources") +@JsonInclude(Include.NON_DEFAULT) +public class Resources implements Serializable{ + + private static final long serialVersionUID = 2194797231782624520L; + @JsonProperty("vnfs") + private List vnfs = new ArrayList<>(); + @JsonProperty("networks") + private List networks = new ArrayList<>(); + + public List getVnfs() { + return vnfs; + } + public void setVnfs(List vnfs) { + this.vnfs = vnfs; + } + public List getNetworks() { + return networks; + } + public void setNetworks(List networks) { + this.networks = networks; + } + @Override + public String toString() { + return "Resources [vnfs=" + vnfs + ", networks=" + networks + "]"; + } +} \ No newline at end of file diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Service.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Service.java new file mode 100644 index 0000000000..66848d343c --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Service.java @@ -0,0 +1,98 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.so.serviceinstancebeans; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonRootName(value = "service") +@JsonInclude(Include.NON_DEFAULT) +public class Service implements Serializable{ + + private static final long serialVersionUID = 2194797231782624520L; + @JsonProperty("modelInfo") + protected ModelInfo modelInfo; + @JsonProperty("cloudConfiguration") + protected CloudConfiguration cloudConfiguration; + @JsonProperty("instanceName") + protected String instanceName; + @JsonProperty("instanceParams") + private List> instanceParams = new ArrayList<>(); + @JsonProperty("resources") + protected Resources resources; + + public ModelInfo getModelInfo() { + return modelInfo; + } + + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + public CloudConfiguration getCloudConfiguration() { + return cloudConfiguration; + } + + public void setCloudConfiguration(CloudConfiguration cloudConfiguration) { + this.cloudConfiguration = cloudConfiguration; + } + + public String getInstanceName() { + return instanceName; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public List> getInstanceParams() { + return instanceParams; + } + + public void setInstanceParams(List> instanceParams) { + this.instanceParams = instanceParams; + } + + public Resources getResources() { + return resources; + } + + public void setResources(Resources resources) { + this.resources = resources; + } + + @Override + public String toString() { + return "Service [modelInfo=" + modelInfo + + ", cloudConfiguration=" + cloudConfiguration + + ", instanceName=" + instanceName + + ", instanceParams=" + instanceParams + + ", resources=" + resources + "]"; + } +} \ No newline at end of file diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceException.java b/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceException.java new file mode 100644 index 0000000000..7efb7f0bff --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceException.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2016.03.30 at 02:48:23 PM CDT +// + + +package org.onap.so.serviceinstancebeans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + +import com.fasterxml.jackson.annotation.JsonRootName; + + +/** + *

Java class for serviceException complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="serviceException">
+ *   <complexContent>
+ *     <extension base="{http://org.onap/so/request/types/v1}exceptionType">
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "serviceException") +@JsonRootName(value = "serviceException") +public class ServiceException + extends ExceptionType +{ + + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java b/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java new file mode 100644 index 0000000000..3ccf29127f --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ServiceInstancesRequest implements Serializable { + + private static final long serialVersionUID = -4959169541182257787L; + @JsonProperty("requestDetails") + private RequestDetails requestDetails; + @JsonProperty("serviceInstanceId") + private String serviceInstanceId; + @JsonProperty("vnfInstanceId") + private String vnfInstanceId; + @JsonProperty("networkInstanceId") + private String networkInstanceId; + @JsonProperty("volumeGroupInstanceId") + private String volumeGroupInstanceId; + @JsonProperty("vfModuleInstanceId") + private String vfModuleInstanceId; + @JsonProperty("configurationId") + private String configurationId; + @JsonProperty("correlationId") + private String correlationId; + + public RequestDetails getRequestDetails() { + return requestDetails; + } + + public void setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getNetworkInstanceId() { + return networkInstanceId; + } + + public void setNetworkInstanceId(String networkInstanceId) { + this.networkInstanceId = networkInstanceId; + } + + public String getVolumeGroupInstanceId() { + return volumeGroupInstanceId; + } + + public void setVolumeGroupInstanceId(String volumeGroupInstanceId) { + this.volumeGroupInstanceId = volumeGroupInstanceId; + } + + public String getVfModuleInstanceId() { + return vfModuleInstanceId; + } + + public void setVfModuleInstanceId(String vfModuleInstanceId) { + this.vfModuleInstanceId = vfModuleInstanceId; + } + + public String getConfigurationId() { + return configurationId; + } + + public void setConfigurationId(String configurationId) { + this.configurationId = configurationId; + } + + public String getCorrelationId() { + return correlationId; + } + + public void setCorrelationId(String correlationId) { + this.correlationId = correlationId; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("ServiceInstancesRequest{"); + sb.append("requestDetails=").append(requestDetails); + sb.append(", serviceInstanceId='").append(serviceInstanceId).append('\''); + sb.append(", vnfInstanceId='").append(vnfInstanceId).append('\''); + sb.append(", networkInstanceId='").append(networkInstanceId).append('\''); + sb.append(", volumeGroupInstanceId='").append(volumeGroupInstanceId).append('\''); + sb.append(", vfModuleInstanceId='").append(vfModuleInstanceId).append('\''); + sb.append(", configurationId='").append(configurationId).append('\''); + sb.append(", correlationId='").append(correlationId).append('\''); + sb.append('}'); + return sb.toString(); + } +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesResponse.java b/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesResponse.java new file mode 100644 index 0000000000..db3add8d47 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesResponse.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import org.apache.commons.lang3.builder.ToStringBuilder; + +public class ServiceInstancesResponse { + + RequestReferences requestReferences; + + public RequestReferences getRequestReferences() { + return requestReferences; + } + + public void setRequestReferences(RequestReferences requestReferences) { + this.requestReferences = requestReferences; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("requestReferences", requestReferences).toString(); + } + + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/SubscriberInfo.java b/common/src/main/java/org/onap/so/serviceinstancebeans/SubscriberInfo.java new file mode 100644 index 0000000000..03780231fc --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/SubscriberInfo.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "subscriberInfo") +@JsonInclude(Include.NON_DEFAULT) +public class SubscriberInfo implements Serializable { + + private static final long serialVersionUID = -1750701712128104652L; + @JsonProperty("globalSubscriberId") + protected String globalSubscriberId; + @JsonProperty("subscriberName") + protected String subscriberName; + + /** + * Gets the value of the globalSubscriberId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + /** + * Sets the value of the globalSubscriberId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setGlobalSubscriberId(String value) { + this.globalSubscriberId = value; + } + + /** + * Gets the value of the subscriberName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSubscriberName() { + return subscriberName; + } + + /** + * Sets the value of the subscriberName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSubscriberName(String value) { + this.subscriberName = value; + } + + @Override + public String toString() { + return "SubscriberInfo [globalSubscriberId=" + globalSubscriberId + + ", subscriberName=" + subscriberName + "]"; + } + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/VfModules.java b/common/src/main/java/org/onap/so/serviceinstancebeans/VfModules.java new file mode 100644 index 0000000000..74f8af80a7 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/VfModules.java @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.so.serviceinstancebeans; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonRootName(value = "vfmodules") +@JsonInclude(Include.NON_DEFAULT) +public class VfModules implements Serializable{ + + private static final long serialVersionUID = 8081495240474276501L; + @JsonProperty("modelInfo") + protected ModelInfo modelInfo; + @JsonProperty("cloudConfiguration") + protected CloudConfiguration cloudConfiguration; + @JsonProperty("instanceName") + protected String instanceName; + @JsonProperty("volumeGroupInstanceName") + protected String volumeGroupInstanceName; + @JsonProperty("instanceParams") + private List> instanceParams = new ArrayList<>(); + + + public ModelInfo getModelInfo() { + return modelInfo; + } + + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + public CloudConfiguration getCloudConfiguration() { + return cloudConfiguration; + } + + public void setCloudConfiguration(CloudConfiguration cloudConfiguration) { + this.cloudConfiguration = cloudConfiguration; + } + + public String getInstanceName() { + return instanceName; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public String getVolumeGroupInstanceName() { + return volumeGroupInstanceName; + } + + public void setVolumeGroupInstanceName(String volumeGroupInstanceName) { + this.volumeGroupInstanceName = volumeGroupInstanceName; + } + + public List> getInstanceParams() { + return instanceParams; + } + + public void setInstanceParams(List> instanceParams) { + this.instanceParams = instanceParams; + } + + @Override + public String toString() { + return "VfModules [modelInfo=" + modelInfo + + ", cloudConfiguration=" + cloudConfiguration + + ", instanceName=" + instanceName + ", volumeGroupInstanceName=" + + volumeGroupInstanceName + ", instanceParams=" + instanceParams + "]"; + } + +} \ No newline at end of file diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Vnfs.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Vnfs.java new file mode 100644 index 0000000000..b55a528935 --- /dev/null +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Vnfs.java @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.so.serviceinstancebeans; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonRootName(value = "vnfs") +@JsonInclude(Include.NON_DEFAULT) +public class Vnfs implements Serializable{ + + private static final long serialVersionUID = 8081495240474276501L; + @JsonProperty("modelInfo") + protected ModelInfo modelInfo; + @JsonProperty("cloudConfiguration") + protected CloudConfiguration cloudConfiguration; + @JsonProperty("instanceName") + protected String instanceName; + @JsonProperty("platform") + protected Platform platform; + @JsonProperty("lineOfBusiness") + protected LineOfBusiness lineOfBusiness; + @JsonProperty("productFamilyId") + protected String productFamilyId; + @JsonProperty("instanceParams") + private List> instanceParams = new ArrayList<>(); + @JsonProperty("vfModules") + private List vfModules = new ArrayList<>(); + + + public ModelInfo getModelInfo() { + return modelInfo; + } + + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + public CloudConfiguration getCloudConfiguration() { + return cloudConfiguration; + } + + public void setCloudConfiguration(CloudConfiguration cloudConfiguration) { + this.cloudConfiguration = cloudConfiguration; + } + + public String getInstanceName() { + return instanceName; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public Platform getPlatform() { + return platform; + } + + public void setPlatform(Platform platform) { + this.platform = platform; + } + + public LineOfBusiness getLineOfBusiness() { + return lineOfBusiness; + } + + public void setLineOfBusiness(LineOfBusiness lineOfBusiness) { + this.lineOfBusiness = lineOfBusiness; + } + + public String getProductFamilyId() { + return productFamilyId; + } + + public void setProductFamilyId(String productFamilyId) { + this.productFamilyId = productFamilyId; + } + + public List> getInstanceParams() { + return instanceParams; + } + + public void setInstanceParams(List> instanceParams) { + this.instanceParams = instanceParams; + } + + public List getVfModules() { + return vfModules; + } + + public void setVfModules(List vfModules) { + this.vfModules = vfModules; + } + + @Override + public String toString() { + return "Vnfs [modelInfo=" + modelInfo + + ", cloudConfiguration=" + cloudConfiguration + + ", instanceName=" + instanceName + ", platform=" + platform + ", " + + "lineOfBusiness=" + lineOfBusiness + + ", productFamilyId=" + productFamilyId + ", instanceParams=" + instanceParams + + ", vfModules=" + vfModules + "]"; + } + +} \ No newline at end of file diff --git a/common/src/main/java/org/onap/so/test/categories/SlowTests.java b/common/src/main/java/org/onap/so/test/categories/SlowTests.java new file mode 100644 index 0000000000..58a14041d0 --- /dev/null +++ b/common/src/main/java/org/onap/so/test/categories/SlowTests.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.test.categories; + +public interface SlowTests { +/* category marker */ +} diff --git a/common/src/main/java/org/onap/so/utils/CheckResults.java b/common/src/main/java/org/onap/so/utils/CheckResults.java new file mode 100644 index 0000000000..4f6089d0e3 --- /dev/null +++ b/common/src/main/java/org/onap/so/utils/CheckResults.java @@ -0,0 +1,118 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.utils; + + + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "checkresults") +public class CheckResults { + + @XmlElement(name = "checkresult") + private List results; + + public CheckResults () { + results = new ArrayList<>(); + } + + public List getResults () { + return results; + } + + public void addHostCheckResult (String hostname, int state, String output) { + CheckResult newResult = new CheckResult (); + newResult.setType ("host"); + newResult.setHostname (hostname); + newResult.setState (state); + newResult.setOutput (output); + results.add (newResult); + } + + public void addServiceCheckResult (String hostname, String servicename, int state, String output) { + CheckResult newResult = new CheckResult (); + newResult.setType ("service"); + newResult.setHostname (hostname); + newResult.setServicename (servicename); + newResult.setState (state); + newResult.setOutput (output); + results.add (newResult); + } + + public static class CheckResult { + + private String type; + private String hostname; + private String servicename; + private int state; + private String output; + + @XmlAttribute(required = true) + public String getType () { + return type; + } + + public void setType (String type) { + this.type = type; + } + + @XmlElement(required = true) + public String getHostname () { + return hostname; + } + + public void setHostname (String hostname) { + this.hostname = hostname; + } + + @XmlElement(required = false) + public String getServicename () { + return servicename; + } + + public void setServicename (String servicename) { + this.servicename = servicename; + } + + @XmlElement(required = true) + public int getState () { + return state; + } + + public void setState (int state) { + this.state = state; + } + + @XmlElement(required = true) + public String getOutput () { + return output; + } + + public void setOutput (String output) { + this.output = output; + } + } +} diff --git a/common/src/main/java/org/onap/so/utils/CryptoUtils.java b/common/src/main/java/org/onap/so/utils/CryptoUtils.java new file mode 100644 index 0000000000..11d464a85c --- /dev/null +++ b/common/src/main/java/org/onap/so/utils/CryptoUtils.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.utils; + + + +import java.security.GeneralSecurityException; +import java.security.NoSuchAlgorithmException; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; + +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; + + +/** + * CryptoUtils adapted from RTTP client. + * + */ +public final class CryptoUtils { + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, CryptoUtils.class); + + public static final String AES = "AES"; + private static final String CLOUD_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + /** + * encrypt a value and generate a keyfile + * if the keyfile is not found then a new one is created + * + * @throws GeneralSecurityException + */ + public static String encrypt (String value, String keyString) throws GeneralSecurityException { + SecretKeySpec sks = getSecretKeySpec (keyString); + Cipher cipher = Cipher.getInstance (CryptoUtils.AES); + cipher.init (Cipher.ENCRYPT_MODE, sks, cipher.getParameters ()); + byte[] encrypted = cipher.doFinal (value.getBytes ()); + return byteArrayToHexString (encrypted); + } + + /** + * decrypt a value + * + * @throws GeneralSecurityException + */ + public static String decrypt (String message, String keyString) throws GeneralSecurityException { + SecretKeySpec sks = getSecretKeySpec (keyString); + Cipher cipher = Cipher.getInstance (CryptoUtils.AES); + cipher.init (Cipher.DECRYPT_MODE, sks); + byte[] decrypted = cipher.doFinal (hexStringToByteArray (message)); + return new String (decrypted); + } + + /** + * decrypt a value or return defaultValue + * + */ + public static String decryptProperty (String prop, String defaultValue, String encryptionKey) { + try { + return CryptoUtils.decrypt(prop, encryptionKey); + } + catch (GeneralSecurityException e) { + LOGGER.debug("Security exception", e); + } + return defaultValue; + } + + public static String encryptCloudConfigPassword(String message) { + try { + return CryptoUtils.encrypt(message, CryptoUtils.CLOUD_KEY); + } catch (GeneralSecurityException e) { + LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in encryptPassword", e); + return null; + } + } + public static String decryptCloudConfigPassword(String message) { + try { + return CryptoUtils.decrypt(message, CryptoUtils.CLOUD_KEY); + } catch (GeneralSecurityException e) { + LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in encryptPassword", e); + return null; + } + } + private static SecretKeySpec getSecretKeySpec (String keyString) throws NoSuchAlgorithmException { + byte[] key = hexStringToByteArray (keyString); + SecretKeySpec sks = new SecretKeySpec (key, CryptoUtils.AES); + return sks; + } + + public static String byteArrayToHexString (byte[] b) { + StringBuilder sb = new StringBuilder(b.length * 2); + for (byte aB : b) { + int v = aB & 0xff; + if (v < 16) { + sb.append('0'); + } + sb.append(Integer.toHexString(v)); + } + return sb.toString ().toUpperCase (); + } + + private static byte[] hexStringToByteArray (String s) { + byte[] b = new byte[s.length () / 2]; + for (int i = 0; i < b.length; i++) { + int index = i * 2; + int v = Integer.parseInt (s.substring (index, index + 2), 16); + b[i] = (byte) v; + } + return b; + } +} diff --git a/common/src/main/java/org/onap/so/utils/TargetEntity.java b/common/src/main/java/org/onap/so/utils/TargetEntity.java new file mode 100644 index 0000000000..ad76e56a56 --- /dev/null +++ b/common/src/main/java/org/onap/so/utils/TargetEntity.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.utils; + + +public enum TargetEntity { + OPENSTACK_ADAPTER, BPMN, GRM ,AAI, DMAAP, POLICY, CATALOG_DB, REQUEST_DB, VNF_ADAPTER, SDNC_ADAPTER, NARAD; + + private static final String PREFIX = "MSO"; + @Override + public String toString(){ + return TargetEntity.PREFIX + "." + this.name(); + } +} diff --git a/common/src/main/java/org/onap/so/utils/UUIDChecker.java b/common/src/main/java/org/onap/so/utils/UUIDChecker.java new file mode 100644 index 0000000000..fac73e84f9 --- /dev/null +++ b/common/src/main/java/org/onap/so/utils/UUIDChecker.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.so.utils; + +import java.util.UUID; + +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; + +/** + */ +public class UUIDChecker { + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL, UUIDChecker.class); + + private UUIDChecker() { + + } + + public static boolean isValidUUID (String id) { + try { + if (null == id) { + return false; + } + UUID uuid = UUID.fromString(id); + return uuid.toString().equalsIgnoreCase(id); + } catch (IllegalArgumentException iae) { + LOGGER.debug("IllegalArgumentException", iae); + return false; + } + } + + public static String getUUID () { + return UUID.randomUUID().toString(); + } + + public static String verifyOldUUID (String oldId, MsoLogger msoLogger) { + if (!UUIDChecker.isValidUUID(oldId)) { + String newId = UUIDChecker.getUUID(); + MsoLogger.setLogContext(newId, null); + msoLogger.info(MessageEnum.APIH_REPLACE_REQUEST_ID, oldId, "", ""); + return newId; + } + MsoLogger.setLogContext(oldId, null); + return oldId; + } + + public static String generateUUID (MsoLogger msoLogger) { + String newId = UUIDChecker.getUUID(); + MsoLogger.setLogContext(newId, null); + msoLogger.info(MessageEnum.APIH_GENERATED_REQUEST_ID, newId, "", ""); + return newId; + } + + public static String generateServiceInstanceID (MsoLogger msoLogger) { + String newId = UUIDChecker.getUUID(); + MsoLogger.setLogContext(null, newId); + msoLogger.info(MessageEnum.APIH_GENERATED_SERVICE_INSTANCE_ID, newId, "", ""); + return newId; + } +} diff --git a/common/src/main/java/org/onap/so/utils/XmlMarshaller.java b/common/src/main/java/org/onap/so/utils/XmlMarshaller.java new file mode 100644 index 0000000000..903d055548 --- /dev/null +++ b/common/src/main/java/org/onap/so/utils/XmlMarshaller.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.utils; + + +import java.io.StringReader; +import java.io.StringWriter; + +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.sax.SAXSource; + +import org.onap.so.exceptions.MarshallerException; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; + +public class XmlMarshaller { + + private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, XmlMarshaller.class); + + public static String marshal(Object object) throws MarshallerException { + + StringWriter stringWriter = new StringWriter(); + try { + JAXBContext jaxbContext = JAXBContext.newInstance(object.getClass()); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); + jaxbMarshaller.marshal(object, stringWriter); + } catch (JAXBException e) { + logger.error(MessageEnum.GENERAL_EXCEPTION, "", "", "", MsoLogger.ErrorCode.SchemaError, e.getMessage(), e); + throw new MarshallerException(e.getMessage(), MsoLogger.ErrorCode.SchemaError.getValue(), e); + } + + return stringWriter.toString(); + } + + public static Object unMarshal(String input, Object object) throws MarshallerException { + + try { + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + spf.setFeature("http://xml.org/sax/features/external-general-entities", false); + spf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); + spf.setNamespaceAware(true); + XMLReader xmlReader = spf.newSAXParser().getXMLReader(); + + JAXBContext jaxbContext = JAXBContext.newInstance(object.getClass()); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); + + InputSource inputSource = new InputSource(new StringReader(input)); + SAXSource source = new SAXSource(xmlReader, inputSource); + object = jaxbUnmarshaller.unmarshal(source, object.getClass()).getValue(); + } catch (Exception e) { + logger.error(MessageEnum.GENERAL_EXCEPTION, "", "", "", MsoLogger.ErrorCode.SchemaError, e.getMessage(), e); + throw new MarshallerException(e.getMessage(), MsoLogger.ErrorCode.SchemaError.getValue(), e); + } + + return object; + } + +} diff --git a/common/src/main/java/org/onap/so/web/exceptions/ExceptionResponse.java b/common/src/main/java/org/onap/so/web/exceptions/ExceptionResponse.java new file mode 100644 index 0000000000..048634190a --- /dev/null +++ b/common/src/main/java/org/onap/so/web/exceptions/ExceptionResponse.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.web.exceptions; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "message" +}) +public class ExceptionResponse { + @JsonProperty("message") + private String message; + + public ExceptionResponse(String message) { + this.message = message; + } + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java b/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java new file mode 100644 index 0000000000..72e609acbd --- /dev/null +++ b/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.web.exceptions; + +import javax.ws.rs.NotFoundException; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; + +import org.onap.so.logger.MsoAlarmLogger; +import org.onap.so.logger.MsoLogger; + +public class RuntimeExceptionMapper implements ExceptionMapper { + + private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, RuntimeExceptionMapper.class); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + @Override + public Response toResponse(RuntimeException exception) { + + if (exception instanceof NotFoundException) { + return Response.status(Status.NOT_FOUND).build(); + } else { + alarmLogger.sendAlarm("MsoApplicationError", MsoAlarmLogger.CRITICAL, exception.getMessage()); + logger.error(exception); + return Response.status(Status.INTERNAL_SERVER_ERROR).entity(new ExceptionResponse("Unexpected Internal Exception")).build(); + } + } +} diff --git a/common/src/main/java/org/openecomp/mso/client/PreconditionFailedException.java b/common/src/main/java/org/openecomp/mso/client/PreconditionFailedException.java deleted file mode 100644 index df28baac74..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/PreconditionFailedException.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; - -public class PreconditionFailedException extends WebApplicationException { - /** - * - */ - private static final long serialVersionUID = 1L; - - public PreconditionFailedException(String message) { - super(message, Response.Status.PRECONDITION_FAILED); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/ResponseExceptionMapper.java b/common/src/main/java/org/openecomp/mso/client/ResponseExceptionMapper.java deleted file mode 100644 index 19c178496c..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/ResponseExceptionMapper.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Optional; - -import javax.ws.rs.BadRequestException; -import javax.ws.rs.ForbiddenException; -import javax.ws.rs.InternalServerErrorException; -import javax.ws.rs.NotAcceptableException; -import javax.ws.rs.NotAllowedException; -import javax.ws.rs.NotAuthorizedException; -import javax.ws.rs.NotFoundException; -import javax.ws.rs.NotSupportedException; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.client.ClientRequestContext; -import javax.ws.rs.client.ClientResponseContext; -import javax.ws.rs.client.ClientResponseFilter; -import javax.ws.rs.core.Response; - -public abstract class ResponseExceptionMapper implements ClientResponseFilter { - - @Override - public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { - if (responseContext.getStatus() >= 300) { - String message = "empty message"; - if (responseContext.hasEntity()) { - Optional result = this.extractMessage(responseContext.getEntityStream()); - if (result.isPresent()) { - message = result.get(); - } - } - Response.Status status = Response.Status.fromStatusCode(responseContext.getStatus()); - WebApplicationException webAppException; - switch (status) { - case BAD_REQUEST: - webAppException = new BadRequestException(message); - break; - case UNAUTHORIZED: - webAppException = new NotAuthorizedException(message); - break; - case FORBIDDEN: - webAppException = new ForbiddenException(message); - break; - case NOT_FOUND: - webAppException = new NotFoundException(message); - break; - case METHOD_NOT_ALLOWED: - webAppException = new NotAllowedException(message); - break; - case NOT_ACCEPTABLE: - webAppException = new NotAcceptableException(message); - break; - case PRECONDITION_FAILED: - webAppException = new PreconditionFailedException(message); - break; - case UNSUPPORTED_MEDIA_TYPE: - webAppException = new NotSupportedException(message); - break; - case INTERNAL_SERVER_ERROR: - webAppException = new InternalServerErrorException(message); - break; - case SERVICE_UNAVAILABLE: - webAppException = new WebApplicationException(message); - break; - default: - webAppException = new WebApplicationException(message); - } - throw webAppException; - } - } - - public abstract Optional extractMessage(InputStream stream) throws IOException; -} diff --git a/common/src/main/java/org/openecomp/mso/client/ResponseExceptionMapperImpl.java b/common/src/main/java/org/openecomp/mso/client/ResponseExceptionMapperImpl.java deleted file mode 100644 index 7841d7accd..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/ResponseExceptionMapperImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Optional; - -import javax.annotation.Priority; -import javax.ws.rs.ext.Provider; - -import org.apache.commons.io.IOUtils; - -@Provider -@Priority(Integer.MIN_VALUE) -public class ResponseExceptionMapperImpl extends ResponseExceptionMapper { - - @Override - public Optional extractMessage(InputStream stream) throws IOException { - final String input = IOUtils.toString(stream, "UTF-8"); - IOUtils.closeQuietly(stream); - return Optional.of(input); - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/client/RestProperties.java b/common/src/main/java/org/openecomp/mso/client/RestProperties.java deleted file mode 100644 index ae8862de5e..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/RestProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client; - -import java.net.MalformedURLException; -import java.net.URL; - -public interface RestProperties { - - public URL getEndpoint() throws MalformedURLException; - public String getSystemName(); -} diff --git a/common/src/main/java/org/openecomp/mso/client/RestPropertiesLoader.java b/common/src/main/java/org/openecomp/mso/client/RestPropertiesLoader.java deleted file mode 100644 index 647acdfcf4..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/RestPropertiesLoader.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client; - -import java.util.Iterator; -import java.util.ServiceLoader; - -public class RestPropertiesLoader { - - private final ServiceLoader services; - private RestPropertiesLoader() { - services = ServiceLoader.load(RestProperties.class); - } - - private static class Helper { - private static final RestPropertiesLoader INSTANCE = new RestPropertiesLoader(); - } - - public static RestPropertiesLoader getInstance() { - return Helper.INSTANCE; - } - - public T getNewImpl(Class clazz) { - return this.getImpl(clazz, true); - } - public T getImpl(Class clazz) { - return this.getImpl(clazz, false); - } - - private T getImpl(Class clazz, boolean forceNewInstance) { - T result = null; - Iterator propertyImpls = services.iterator(); - RestProperties item; - while (propertyImpls.hasNext()) { - item = propertyImpls.next(); - if (clazz.isAssignableFrom(item.getClass())) { - try { - if (forceNewInstance) { - result = (T)item.getClass().newInstance(); - } else { - result = (T)item; - } - } catch (InstantiationException | IllegalAccessException e) { - /* all spi implementations must provide a public - * no argument constructor - */ - - } - //break; - } - } - - return result; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIClient.java deleted file mode 100644 index 9150dcab15..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIClient.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import java.net.URI; -import java.util.UUID; - -import javax.ws.rs.core.UriBuilder; - -import org.openecomp.mso.client.RestPropertiesLoader; -import org.openecomp.mso.client.aai.entities.uri.AAIUri; -import org.openecomp.mso.client.defaultproperties.DefaultAAIPropertiesImpl; -import org.openecomp.mso.client.policy.RestClient; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public abstract class AAIClient { - - protected final AAIVersion defaultVersion; - private static final String AAI_ROOT = "/aai"; - protected final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - private final AAIProperties properties; - protected final UUID requestId; - public AAIClient(UUID requestId) { - AAIProperties props = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class); - if (props == null) { - metricsLogger.error("No RestProperty.AAIProperties implementation found on classpath"); - props = new DefaultAAIPropertiesImpl(); - } - this.properties = props; - this.defaultVersion = props.getDefaultVersion(); - this.requestId = requestId; - } - protected URI constructPath(AAIUri uri) { - - return UriBuilder.fromUri(AAI_ROOT + "/" + this.getVersion().toString() + uri.build().toString()).build(); - } - - protected RestClient createClient(AAIUri uri) { - return new AAIRestClient(properties, this.getRequestId(), constructPath(uri)).addRequestId(this.getRequestId()); - - } - - protected UUID getRequestId() { - return this.requestId; - } - protected AAIVersion getVersion() { - return defaultVersion; - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java deleted file mode 100644 index 657b4c5a2c..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Optional; -import java.util.UUID; - -import javax.annotation.Priority; -import javax.ws.rs.ext.Provider; - -import org.openecomp.mso.client.ResponseExceptionMapper; -import org.openecomp.mso.client.aai.entities.AAIError; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Provider -@Priority(Integer.MIN_VALUE) -public class AAIClientResponseExceptionMapper extends ResponseExceptionMapper { - - private final UUID requestId; - public AAIClientResponseExceptionMapper(UUID requestId) { - this.requestId = requestId; - } - @Override - public Optional extractMessage(InputStream stream) throws IOException { - - String errorString = "Error calling A&AI. Request-Id=" + this.getRequestId() + " "; - try { - AAIError error = new ObjectMapper().readValue(stream, AAIError.class); - AAIErrorFormatter formatter = new AAIErrorFormatter(error); - return Optional.of(errorString + formatter.getMessage()); - } catch (JsonParseException e) { - return Optional.of(errorString); - } - } - - protected UUID getRequestId() { - return this.requestId; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java b/common/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java deleted file mode 100644 index cbee903835..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import javax.ws.rs.ext.ContextResolver; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.databind.AnnotationIntrospector; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; -import com.fasterxml.jackson.databind.type.TypeFactory; -import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; - -public class AAICommonObjectMapperProvider implements ContextResolver { - - final ObjectMapper mapper; - - public AAICommonObjectMapperProvider() { - mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); - mapper.enable(MapperFeature.USE_ANNOTATIONS); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - AnnotationIntrospector aiJaxb = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); - AnnotationIntrospector aiJackson = new JacksonAnnotationIntrospector(); - // first Jaxb, second Jackson annotations - mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(aiJaxb, aiJackson)); - } - - @Override - public ObjectMapper getContext(Class type) { - return mapper; - } - - public ObjectMapper getMapper() { - return mapper; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIConfigurationClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIConfigurationClient.java deleted file mode 100644 index fdeb975ad1..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIConfigurationClient.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import org.openecomp.mso.client.aai.entities.Configuration; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; -import org.openecomp.mso.serviceinstancebeans.RequestDetails; - -public class AAIConfigurationClient { - - private AAIResourcesClient aaiClient; - - private static final String ORCHESTRATION_STATUS = "PendingCreate"; - - public AAIConfigurationClient() { - aaiClient = new AAIResourcesClient(); - } - - public void createConfiguration(RequestDetails requestDetails, String configurationId, String configurationType, - String configurationSubType) { - Configuration payload = new Configuration(); - payload.setConfigurationId(configurationId); - payload.setConfigurationType(configurationType); - payload.setConfigurationSubType(configurationSubType); - payload.setModelInvariantId(requestDetails.getModelInfo().getModelInvariantId()); - payload.setModelVersionId(requestDetails.getModelInfo().getModelVersionId()); - payload.setOrchestrationStatus(ORCHESTRATION_STATUS); - payload.setOperationalStatus(""); - AAIResourceUri uri = getConfigurationURI(payload.getConfigurationId()); - payload.setConfigurationSelflink(uri.build().getPath()); - payload.setModelCustomizationId(requestDetails.getModelInfo().getModelCustomizationId()); - - aaiClient.create(uri, payload); - } - - public void deleteConfiguration(String uuid) { - aaiClient.delete(getConfigurationURI(uuid)); - } - - public void updateOrchestrationStatus(String uuid, String payload) { - aaiClient.update(getConfigurationURI(uuid), payload); - } - - public Configuration getConfiguration(String uuid) { - return aaiClient.get(Configuration.class, getConfigurationURI(uuid)); - } - - public boolean configurationExists(String uuid) { - return aaiClient.exists(getConfigurationURI(uuid)); - } - - public AAIResourceUri getConfigurationURI(String uuid) { - return AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, uuid); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIErrorFormatter.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIErrorFormatter.java deleted file mode 100644 index dd56e9712f..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIErrorFormatter.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import java.util.List; -import java.util.Optional; - -import org.openecomp.mso.client.aai.entities.AAIError; -import org.openecomp.mso.client.aai.entities.ServiceException; - -public class AAIErrorFormatter { - - private final AAIError error; - public AAIErrorFormatter(AAIError error) { - this.error = error; - } - - public String getMessage() { - if (error.getRequestError() != null && - error.getRequestError().getServiceException() != null) { - ServiceException serviceException = error.getRequestError().getServiceException(); - return this.fillInTemplate(serviceException.getText(), serviceException.getVariables()); - } - - return "no parsable error message found"; - } - - protected String fillInTemplate(String text, List variables) { - for (int i = 0; i < variables.size(); i++) { - variables.set(i, this.format(variables.get(i), variables)); - } - - return format(text, variables); - } - - protected String format(String s, List variables) { - return String.format(s.replaceAll("%(\\d+)", "%$1\\$s"), variables.toArray()); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAINamespaceConstants.java b/common/src/main/java/org/openecomp/mso/client/aai/AAINamespaceConstants.java deleted file mode 100644 index 4bdfc4d793..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAINamespaceConstants.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -public class AAINamespaceConstants { - - protected static final String CLOUD_INFRASTRUCTURE = "/cloud-infrastructure"; - protected static final String NETWORK = "/network"; - protected static final String BUSINESS = "/business"; - protected static final String SERVICE_DESIGN_AND_CREATION = "/service-design-and-creation"; - - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectName.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectName.java deleted file mode 100644 index c7459d31b5..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectName.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import com.google.common.base.CaseFormat; - -public interface AAIObjectName { - - public String typeName(); - public String typeName(CaseFormat format); -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectPlurals.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectPlurals.java deleted file mode 100644 index dc2831c1ed..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectPlurals.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import com.google.common.base.CaseFormat; - -public enum AAIObjectPlurals implements AAIObjectName, AAIObjectUriTemplate, AAIObjectUriPartial { - - GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs"), - PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers"); - - private final String uriTemplate; - private final String partialUri; - private AAIObjectPlurals(String parentUri, String partialUri) { - this.uriTemplate = parentUri + partialUri; - this.partialUri = partialUri; - } - - @Override - public String toString() { - return this.uriTemplate(); - } - - @Override - public String uriTemplate() { - return this.uriTemplate; - } - - @Override - public String partialUri() { - return this.partialUri; - } - - @Override - public String typeName() { - return this.typeName(CaseFormat.LOWER_HYPHEN); - } - @Override - public String typeName(CaseFormat format) { - String enumName = this.name(); - if (this.equals(AAIObjectType.DEFAULT_CLOUD_REGION) || this.equals(AAIObjectType.DEFAULT_TENANT)) { - enumName = enumName.replace("DEFAULT_", ""); - } - - return CaseFormat.UPPER_UNDERSCORE.to(format, enumName); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectType.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectType.java deleted file mode 100644 index 9026c29522..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectType.java +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import com.google.common.base.CaseFormat; - -public enum AAIObjectType implements AAIObjectName, AAIObjectUriTemplate, AAIObjectUriPartial { - - DEFAULT_CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/att-aic/{cloud-region-id}"), - CUSTOMER(AAINamespaceConstants.BUSINESS, "/customers/customer/{global-customer-id}"), - GENERIC_QUERY("/search", "/generic-query"), - BULK_PROCESS("/bulkprocess", ""), - GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs/generic-vnf/{vnf-id}"), - VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules/vf-module/{vf-module-id}"), - L3_NETWORK(AAINamespaceConstants.NETWORK, "/l3-networks/l3-network/{network-id}"), - NETWORK_POLICY(AAINamespaceConstants.NETWORK, "/network-policies/network-policy/{network-policy-id}"), - NODES_QUERY("/search", "/nodes-query"), - CUSTOM_QUERY("/query", ""), - ROUTE_TABLE_REFERENCE(AAINamespaceConstants.NETWORK, "/route-table-references/route-table-reference/{route-table-reference-id}"), - DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/att-aic/AAIAIC25", "/tenants/tenant/{tenant-id}"), - VCE(AAINamespaceConstants.NETWORK, "/vces/vce/{vnf-id}"), - VPN_BINDING(AAINamespaceConstants.NETWORK, "/vpn-bindings/vpn-binding/{vpn-id}"), - CONFIGURATION(AAINamespaceConstants.NETWORK, "/configurations/configuration/{configuration-id}"), - PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers/pserver/{hostname}"), - SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions/service-subscription/{service-type}"), - SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances/service-instance/{service-instance-id}"), - PROJECT(AAINamespaceConstants.BUSINESS, "/projects/project/{id}"), - LINE_OF_BUSINESS(AAINamespaceConstants.BUSINESS, "/lines-of-business/line-of-business/{id}"), - PLATFORM(AAINamespaceConstants.BUSINESS, "/platforms/platform/{id}"), - OWNING_ENTITY(AAINamespaceConstants.BUSINESS, "/owning-entities/owning-entity/{id}"), - ALLOTTED_RESOURCE(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/allotted-resources/allotted-resource/{id}"), - PNF(AAINamespaceConstants.NETWORK, "/pnfs/pnf/{pnf-name}"), - OPERATIONAL_ENVIRONMENT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/operational-environments/operational-environment/{operational-environment-id}"), - CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/{cloud-owner-id}/{cloud-region-id}"), - TENANT(AAIObjectType.CLOUD_REGION.uriTemplate(), "/tenants/tenant/{tenant-id}"), - VSERVER(AAIObjectType.TENANT.uriTemplate(), "/vservers/vserver/{vserver-id}"), - MODEL_VER(AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/models/model/{model-invariant-id}", "/model-vers/model-ver/{model-version-id}"), - TUNNEL_XCONNECT(AAIObjectType.ALLOTTED_RESOURCE.uriTemplate(), "/tunnel-xconnects/tunnel-xconnect/{id}"), - P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces/p-interface/{interface-name}"), - PHYSICAL_LINK(AAINamespaceConstants.NETWORK, "/physical-links/physical-link/{link-name}"), - UNKNOWN("", ""); - - private final String uriTemplate; - private final String parentUri; - private final String partialUri; - private AAIObjectType(String parentUri, String partialUri) { - this.parentUri = parentUri; - this.partialUri = partialUri; - this.uriTemplate = parentUri + partialUri; - } - - @Override - public String toString() { - return this.uriTemplate(); - } - - @Override - public String typeName() { - return this.typeName(CaseFormat.LOWER_HYPHEN); - } - @Override - public String typeName(CaseFormat format) { - String enumName = this.name(); - if (this.equals(AAIObjectType.DEFAULT_CLOUD_REGION) || this.equals(AAIObjectType.DEFAULT_TENANT)) { - enumName = enumName.replace("DEFAULT_", ""); - } - - return CaseFormat.UPPER_UNDERSCORE.to(format, enumName); - } - - @Override - public String uriTemplate() { - return this.uriTemplate; - } - - @Override - public String partialUri() { - return this.partialUri; - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriPartial.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriPartial.java deleted file mode 100644 index 3fb867d6fa..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriPartial.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -public interface AAIObjectUriPartial { - - public String partialUri(); -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriTemplate.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriTemplate.java deleted file mode 100644 index 397b66d547..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIObjectUriTemplate.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -public interface AAIObjectUriTemplate { - - public String uriTemplate(); -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIProperties.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIProperties.java deleted file mode 100644 index c208d6dd5f..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import org.openecomp.mso.client.RestProperties; - -public interface AAIProperties extends RestProperties { - - public AAIVersion getDefaultVersion(); - public String getAuth(); - public String getKey(); -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIQueryClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIQueryClient.java deleted file mode 100644 index f8707dec3e..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIQueryClient.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import java.util.Optional; -import java.util.UUID; - -import org.openecomp.mso.client.aai.entities.CustomQuery; -import org.openecomp.mso.client.aai.entities.uri.AAIUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; -import org.openecomp.mso.client.policy.RestClient; -import org.openecomp.mso.client.aai.AAIVersion; - -public class AAIQueryClient extends AAIClient { - - - private final AAIVersion version; - private Optional depth = Optional.empty(); - private boolean nodesOnly = false; - private Optional subgraph = Optional.empty(); - - public AAIQueryClient() { - super(UUID.randomUUID()); - this.version = super.getVersion(); - } - - public AAIQueryClient(AAIVersion version, UUID requestId) { - super(requestId); - this.version = version; - } - - public AAIQueryClient(AAIVersion version) { - this(version, UUID.randomUUID()); - } - - public String query(Format format, CustomQuery query) { - return this.createClient(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY).queryParam("format", format.toString())) - .addRequestId(requestId).put(query, String.class); - } - - @Override - protected AAIVersion getVersion() { - return this.version; - } - - public AAIQueryClient depth (String depth) { - this.depth = Optional.of(depth); - return this; - } - public AAIQueryClient nodesOnly() { - this.nodesOnly = true; - return this; - } - public AAIQueryClient subgraph(AAISubgraphType type){ - - subgraph = Optional.of(type); - - return this; - } - - @Override - public RestClient createClient(AAIUri uri) { - AAIUri clone = uri.clone(); - if (this.depth.isPresent()) { - clone.queryParam("depth", depth.get()); - } - if (this.nodesOnly) { - clone.queryParam("nodesOnly", ""); - } - if (this.subgraph.isPresent()) { - clone.queryParam("subgraph", this.subgraph.get().toString()); - } - return super.createClient(clone); - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java deleted file mode 100644 index 425d9ce60b..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import com.fasterxml.jackson.databind.AnnotationIntrospector; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; -import com.fasterxml.jackson.databind.type.TypeFactory; -import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; - -public class AAIQueryObjectMapperProvider extends AAICommonObjectMapperProvider { - - public AAIQueryObjectMapperProvider() { - super(); - AnnotationIntrospector aiJaxb = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); - AnnotationIntrospector aiJackson = new JacksonAnnotationIntrospector(); - // first Jaxb, second Jackson annotations - mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(aiJaxb, aiJackson)); - - } - - @Override - public ObjectMapper getContext(Class type) { - return mapper; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesClient.java deleted file mode 100644 index c55e5e9eee..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesClient.java +++ /dev/null @@ -1,254 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import java.util.Map; -import java.util.Optional; -import java.util.UUID; - -import javax.ws.rs.NotFoundException; -import javax.ws.rs.client.ResponseProcessingException; -import javax.ws.rs.core.GenericType; - -import javax.ws.rs.core.Response; -import org.onap.aai.domain.yang.Relationship; -import org.openecomp.mso.client.aai.entities.AAIResultWrapper; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUri; -import org.openecomp.mso.client.aai.entities.uri.Depth; -import org.openecomp.mso.client.policy.RestClient; - -public class AAIResourcesClient extends AAIClient { - - private final AAIVersion version; - - public AAIResourcesClient() { - super(UUID.randomUUID()); - this.version = super.getVersion(); - } - - public AAIResourcesClient(AAIVersion version) { - super(UUID.randomUUID()); - this.version = version; - } - - public AAIResourcesClient(AAIVersion version, UUID requestId) { - super(requestId); - this.version = version; - } - - /** - * creates a new object in A&AI - * - * @param obj - can be any object which will marshal into a valid A&AI payload - * @param uri - * @return - */ - public void create(AAIResourceUri uri, Object obj) { - RestClient aaiRC = this.createClient(uri); - aaiRC.put(obj); - return; - } - - /** - * creates a new object in A&AI with no payload body - * - * @param uri - * @return - */ - public void createEmpty(AAIResourceUri uri) { - RestClient aaiRC = this.createClient(uri); - aaiRC.put(""); - return; - } - - /** - * returns false if the object does not exist in A&AI - * - * @param uri - * @return - */ - public boolean exists(AAIResourceUri uri) { - AAIUri forceMinimal = this.addParams(Optional.of(Depth.ZERO), true, uri); - RestClient aaiRC = this.createClient(forceMinimal); - try{ - aaiRC.get(); - } catch(ResponseProcessingException e) { - if (e.getCause() instanceof NotFoundException) { - return false; - } else { - throw e; - } - } - return true; - } - - /** - * Adds a relationship between two objects in A&AI - * @param uriA - * @param uriB - * @return - */ - public void connect(AAIResourceUri uriA, AAIResourceUri uriB) { - AAIResourceUri uriAClone = uriA.clone(); - RestClient aaiRC = this.createClient(uriAClone.relationshipAPI()); - aaiRC.put(this.buildRelationship(uriB)); - return; - } - - /** - * Removes relationship from two objects in A&AI - * - * @param uriA - * @param uriB - * @return - */ - public void disconnect(AAIResourceUri uriA, AAIResourceUri uriB) { - AAIResourceUri uriAClone = uriA.clone(); - RestClient aaiRC = this.createClient(uriAClone.relationshipAPI()); - aaiRC.delete(this.buildRelationship(uriB)); - return; - } - - /** - * Deletes object from A&AI. Automatically handles resource-version. - * - * @param uri - * @return - */ - public void delete(AAIResourceUri uri) { - AAIResourceUri clone = uri.clone(); - RestClient aaiRC = this.createClient(clone); - Map result = aaiRC.get(new GenericType>(){}); - String resourceVersion = (String) result.get("resource-version"); - aaiRC = this.createClient(clone.resourceVersion(resourceVersion)); - aaiRC.delete(); - return; - } - - /** - * @param obj - can be any object which will marshal into a valid A&AI payload - * @param uri - * @return - */ - public void update(AAIResourceUri uri, Object obj) { - RestClient aaiRC = this.createClient(uri); - aaiRC.patch(obj); - return; - } - - /** - * Retrieves an object from A&AI and unmarshalls it into the Class specified - * @param clazz - * @param uri - * @return - */ - public T get(Class clazz, AAIResourceUri uri) { - return this.createClient(uri).get(clazz); - } - - /** - * Retrieves an object from A&AI and returns complete response - * @param uri - * @return - */ - public Response getFullResponse(AAIResourceUri uri) { - return this.createClient(uri).get(); - } - - /** - * Retrieves an object from A&AI and automatically unmarshalls it into a Map or List - * @param resultClass - * @param uri - * @return - */ - public T get(GenericType resultClass, AAIResourceUri uri) { - return this.createClient(uri).get(resultClass); - } - - /** - * Retrieves an object from A&AI wrapped in a helper class which offer additional features - * - * @param uri - * @return - */ - public AAIResultWrapper get(AAIResourceUri uri) { - String json = this.createClient(uri).get(String.class); - - return new AAIResultWrapper(json); - - } - private Relationship buildRelationship(AAIResourceUri uri) { - final Relationship result = new Relationship(); - result.setRelatedLink(uri.build().toString()); - return result; - } - - /** - * Will automatically create the object if it does not exist - * - * @param obj - Optional object which serializes to a valid A&AI payload - * @param uri - * @return - */ - public AAIResourcesClient createIfNotExists(AAIResourceUri uri, Optional obj) { - if(!this.exists(uri)){ - if (obj.isPresent()) { - this.create(uri, obj.get()); - } else { - this.createEmpty(uri); - } - - } - return this; - } - - /** - * Starts a transaction which encloses multiple A&AI mutations - * - * @return - */ - public AAITransactionalClient beginTransaction() { - return new AAITransactionalClient(this.version, this.requestId); - } - - @Override - protected AAIVersion getVersion() { - return this.version; - } - - @Override - protected RestClient createClient(AAIUri uri) { - return super.createClient(uri); - } - - private AAIUri addParams(Optional depth, boolean nodesOnly, AAIUri uri) { - AAIUri clone = uri.clone(); - if (depth.isPresent()) { - clone.depth(depth.get()); - } - if (nodesOnly) { - clone.nodesOnly(nodesOnly); - } - - return clone; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java deleted file mode 100644 index ada1939951..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public class AAIResourcesObjectMapperProvider extends AAICommonObjectMapperProvider { - - public AAIResourcesObjectMapperProvider() { - super(); - } - - @Override - public ObjectMapper getContext(Class type) { - return mapper; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java deleted file mode 100644 index e36033faa0..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import java.net.URI; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; - -import javax.ws.rs.client.ClientResponseFilter; -import javax.ws.rs.ext.ContextResolver; - -import org.openecomp.mso.client.policy.RestClient; -import org.openecomp.mso.client.policy.RestClientSSL; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public class AAIRestClient extends RestClientSSL { - - private final AAIProperties props; - - protected AAIRestClient(AAIProperties props, UUID requestId, URI uri) { - super(props, requestId, Optional.of(uri)); - this.props = props; - headerMap.put("X-TransactionId", requestId.toString()); - } - - @Override - protected void initializeHeaderMap(Map headerMap) { - headerMap.put("X-FromAppId", "MSO"); - - String auth = props.getAuth(); - String key = props.getKey(); - - if (auth != null && !auth.isEmpty() && key != null && !key.isEmpty()) { - addBasicAuthHeader(auth, key); - } - } - - @Override - protected Optional addResponseFilter() { - - return Optional.of(new AAIClientResponseExceptionMapper(this.getRequestId())); - } - - @Override - public RestClient addRequestId(UUID requestId) { - headerMap.put("X-TransactionId", requestId.toString()); - this.requestId = requestId; - return this; - } - - @Override - protected ContextResolver getMapper() { - return new AAICommonObjectMapperProvider(); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientI.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientI.java deleted file mode 100644 index 6819ba1edf..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientI.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.List; - -import java.util.Optional; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Pnf; -import org.onap.aai.domain.yang.Pserver; -import org.onap.aai.domain.yang.Pservers; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; - -public interface AAIRestClientI { - - Pservers getPhysicalServers(String hostName, String uuid); - - List getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) throws UnsupportedEncodingException, JsonParseException, JsonMappingException, IOException; - - void updateMaintenceFlag(String vnfId,boolean inMaint, String transactionLoggingUuid) throws Exception; - - void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) throws Exception; - - GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws Exception; - - Optional getPnfByName(String pnfId, String transactionLoggingUuid) throws Exception; - - void createPnf(String pnfId, String transactionLoggingUuid, Pnf pnf) throws IOException; -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java deleted file mode 100644 index a84aeaac8e..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java +++ /dev/null @@ -1,195 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; -import javax.ws.rs.core.Response; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.GenericVnfs; -import org.onap.aai.domain.yang.Pnf; -import org.onap.aai.domain.yang.Pserver; -import org.onap.aai.domain.yang.Pservers; -import org.openecomp.mso.client.aai.entities.CustomQuery; -import org.openecomp.mso.client.aai.entities.Results; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; -import org.springframework.stereotype.Service; - - -@Service -public class AAIRestClientImpl implements AAIRestClientI { - - private static final EELFLogger logger = EELFManager.getInstance().getMetricsLogger(); - private static final AAIVersion ENDPOINT_VERSION = AAIVersion.V10; - private static final String ENDPOINT_GET_ALL = ENDPOINT_VERSION + "/cloud-infrastructure/pservers"; - private static final String ENDPOINT_GET_ALL_VNFS = ENDPOINT_VERSION + "/network/generic-vnfs"; - private static final String ENDPOINT_CUSTOM_QUERY = ENDPOINT_VERSION + "/query"; - private static final String PSERVER_VNF_QUERY = "pservers-fromVnf"; - private static final String GENERIC_VNF_PATH = ENDPOINT_VERSION + "/network/generic-vnfs/generic-vnf"; - private static final String SERVICE_TOPOLOGY_BY_SERVICE_INSTANCE_ID = - "store(‘x’).union(__.in(‘subscribesTo’).has(‘aai-node-type’,’customer’).store(‘x’),__.out(‘uses’).has(‘aai-node-type’,’allotted-resource’).store(‘x’),__.in(‘hasInstance’).has(‘aai-node-type’,’generic-vnf’).store(‘x’).union(" - + ".out(‘has’).has(‘aai-node-type’,’vf-module’).store(‘x’),out(‘uses’).has(‘aai-node-type’,’volume-group’).store(‘x’)," - + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union(" - + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)," - + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)" - + ")," + ".out(‘runsOnVserver’).has(‘aai-node-type’,’vserver’).store(‘x’).union(" - + ".in(‘owns’).has(‘aai-node-type’,’tenant’).store(‘x’).in(‘has’).has(‘aai-node-type’,’cloud-region’).store(‘x’)," - + ".out(‘runsOnPserver’).has(‘aai-node-type’,’pserver’).store(‘x’)," - + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union(" - + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)," - + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)" - + ")" + ")" + ")" + ").cap(‘x’).unfold().dedup()"; - - public AAIRestClientImpl() { - } - - @Override - public Pservers getPhysicalServers(String hostName, String uuid) { - UUID requestId; - try { - requestId = UUID.fromString(uuid); - } catch (IllegalArgumentException e) { - logger.warn("could not parse uuid: " + uuid + " creating valid uuid automatically"); - requestId = UUID.randomUUID(); - } - return new AAIResourcesClient(ENDPOINT_VERSION, requestId) - .get(Pservers.class, AAIUriFactory.createResourceUri(AAIObjectPlurals.PSERVER)); - } - - @Override - public List getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) throws IOException { - UUID requestId; - try { - requestId = UUID.fromString(transactionLoggingUuid); - } catch (IllegalArgumentException e) { - logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); - requestId = UUID.randomUUID(); - } - List startNodes = new ArrayList<>(); - startNodes.add(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); - String jsonInput = new AAIQueryClient(ENDPOINT_VERSION, requestId) - .query(Format.RESOURCE, new CustomQuery(startNodes, PSERVER_VNF_QUERY)); - - return this.getListOfPservers(jsonInput); - - } - - protected List getListOfPservers(String jsonInput) throws IOException { - ObjectMapper mapper = new AAICommonObjectMapperProvider().getContext(Object.class); - Results> resultsFromJson = mapper.readValue(jsonInput, - new TypeReference>>() { - }); - List results = new ArrayList<>(); - for (Map m : resultsFromJson.getResult()) { - results.add(m.get("pserver")); - } - return results; - } - - @Override - public void updateMaintenceFlag(String vnfName, boolean inMaint, String transactionLoggingUuid) throws IOException { - UUID requestId; - try { - requestId = UUID.fromString(transactionLoggingUuid); - } catch (IllegalArgumentException e) { - logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); - requestId = UUID.randomUUID(); - } - GenericVnfs genericVnfs = new AAIResourcesClient(ENDPOINT_VERSION, requestId).get(GenericVnfs.class, - AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName)); - if (genericVnfs.getGenericVnf().size() > 1) { - throw new IndexOutOfBoundsException("Multiple Generic Vnfs Returned"); - } - - GenericVnf genericVnf = genericVnfs.getGenericVnf().get(0); - updateMaintenceFlagVnfId(genericVnf.getVnfId(), inMaint, transactionLoggingUuid); - } - - @Override - public void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) - throws IOException { - UUID requestId; - try { - requestId = UUID.fromString(transactionLoggingUuid); - } catch (IllegalArgumentException e) { - logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); - requestId = UUID.randomUUID(); - } - GenericVnf genericVnf = new GenericVnf(); - genericVnf.setInMaint(inMaint); - new AAIResourcesClient(ENDPOINT_VERSION, requestId) - .update(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId), genericVnf); - - } - - @Override - public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws IOException { - UUID requestId; - try { - requestId = UUID.fromString(transactionLoggingUuid); - } catch (IllegalArgumentException e) { - logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically"); - requestId = UUID.randomUUID(); - } - return new AAIResourcesClient(ENDPOINT_VERSION, requestId) - .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)); - } - - @Override - public Optional getPnfByName(String pnfId, String transactionLoggingUuid) throws IOException { - UUID requestId; - try { - requestId = UUID.fromString(transactionLoggingUuid); - } catch (IllegalArgumentException e) { - logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically", e); - requestId = UUID.randomUUID(); - } - Response response = new AAIResourcesClient(ENDPOINT_VERSION, requestId) - .getFullResponse(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId)); - if (response.getStatus() != 200) { - return Optional.empty(); - } else { - return Optional.of(response.readEntity(Pnf.class)); - } - } - - @Override - public void createPnf(String pnfId, String transactionLoggingUuid, Pnf pnf) throws IOException { - UUID requestId; - try { - requestId = UUID.fromString(transactionLoggingUuid); - } catch (IllegalArgumentException e) { - logger.warn("could not parse uuid: " + transactionLoggingUuid + " creating valid uuid automatically", e); - requestId = UUID.randomUUID(); - } - new AAIResourcesClient(ENDPOINT_VERSION, requestId) - .createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), Optional.of(pnf)); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAISubgraphType.java b/common/src/main/java/org/openecomp/mso/client/aai/AAISubgraphType.java deleted file mode 100644 index 917949967f..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAISubgraphType.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - - -public enum AAISubgraphType { - STAR("star"), - PRUNE("prune"); - - private final String name; - - private AAISubgraphType(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAITransactionalClient.java b/common/src/main/java/org/openecomp/mso/client/aai/AAITransactionalClient.java deleted file mode 100644 index 547862708a..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAITransactionalClient.java +++ /dev/null @@ -1,263 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; -import java.util.UUID; - -import javax.ws.rs.core.GenericType; -import javax.ws.rs.core.Response; - -import org.onap.aai.domain.yang.Relationship; -import org.openecomp.mso.client.aai.entities.AAIError; -import org.openecomp.mso.client.aai.entities.bulkprocess.OperationBody; -import org.openecomp.mso.client.aai.entities.bulkprocess.Transaction; -import org.openecomp.mso.client.aai.entities.bulkprocess.Transactions; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; -import org.openecomp.mso.client.aai.exceptions.BulkProcessFailed; -import org.openecomp.mso.client.policy.RestClient; -import org.openecomp.mso.jsonpath.JsonPathUtil; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Joiner; - -public class AAITransactionalClient extends AAIClient { - - private final Transactions transactions; - private Transaction currentTransaction; - private final AAIVersion version; - private int actionCount = 0; - protected AAITransactionalClient(AAIVersion version, UUID requestId) { - super(requestId); - this.version = version; - this.transactions = new Transactions(); - startTransaction(); - } - - private void startTransaction() { - Transaction transaction = new Transaction(); - transactions.getTransactions().add(transaction); - currentTransaction = transaction; - } - - /** - * adds an additional transaction and closes the previous transaction - * - * @return AAITransactionalClient - */ - public AAITransactionalClient beginNewTransaction() { - startTransaction(); - return this; - } - - /** - * creates a new object in A&AI - * - * @param obj - can be any object which will marshal into a valid A&AI payload - * @param uri - * @return - */ - public AAITransactionalClient create(AAIResourceUri uri, Object obj) { - currentTransaction.getPut().add(new OperationBody().withUri(uri.build().toString()).withBody(obj)); - incrementActionAmount(); - return this; - } - - /** - * creates a new object in A&AI with no payload body - * - * @param uri - * @return - */ - public AAITransactionalClient createEmpty(AAIResourceUri uri) { - currentTransaction.getPut().add(new OperationBody().withUri(uri.build().toString()).withBody(new HashMap())); - incrementActionAmount(); - return this; - } - - /** - * Adds a relationship between two objects in A&AI - * @param uriA - * @param uriB - * @return - */ - public AAITransactionalClient connect(AAIResourceUri uriA, AAIResourceUri uriB) { - AAIResourceUri uriAClone = uriA.clone(); - currentTransaction.getPut().add(new OperationBody().withUri(uriAClone.relationshipAPI().build().toString()).withBody(this.buildRelationship(uriB))); - incrementActionAmount(); - return this; - } - - /** - * relationship between multiple objects in A&AI - connects A to all objects specified in list - * - * @param uriA - * @param uris - * @return - */ - public AAITransactionalClient connect(AAIResourceUri uriA, List uris) { - for (AAIResourceUri uri : uris) { - this.connect(uriA, uri); - } - return this; - } - - /** - * Removes relationship from two objects in A&AI - * - * @param uriA - * @param uriB - * @return - */ - public AAITransactionalClient disconnect(AAIResourceUri uriA, AAIResourceUri uriB) { - AAIResourceUri uriAClone = uriA.clone(); - currentTransaction.getDelete().add(new OperationBody().withUri(uriAClone.relationshipAPI().build().toString()).withBody(this.buildRelationship(uriB))); - incrementActionAmount(); - return this; - } - - /** - * Removes relationship from multiple objects - disconnects A from all objects specified in list - * @param uriA - * @param uris - * @return - */ - public AAITransactionalClient disconnect(AAIResourceUri uriA, List uris) { - for (AAIResourceUri uri : uris) { - this.disconnect(uriA, uri); - } - return this; - } - /** - * Deletes object from A&AI. Automatically handles resource-version. - * - * @param uri - * @return - */ - public AAITransactionalClient delete(AAIResourceUri uri) { - AAIResourcesClient client = new AAIResourcesClient(); - AAIResourceUri clone = uri.clone(); - Map result = client.get(new GenericType>(){}, clone); - String resourceVersion = (String) result.get("resource-version"); - currentTransaction.getDelete().add(new OperationBody().withUri(clone.resourceVersion(resourceVersion).build().toString()).withBody("")); - incrementActionAmount(); - return this; - } - - /** - * @param obj - can be any object which will marshal into a valid A&AI payload - * @param uri - * @return - */ - public AAITransactionalClient update(AAIResourceUri uri, Object obj) { - currentTransaction.getPatch().add(new OperationBody().withUri(uri.build().toString()).withBody(obj)); - incrementActionAmount(); - return this; - } - - private void incrementActionAmount() { - actionCount++; - } - /** - * Executes all created transactions in A&AI - * @throws BulkProcessFailed - */ - public void execute() throws BulkProcessFailed { - RestClient client = this.createClient(AAIUriFactory.createResourceUri(AAIObjectType.BULK_PROCESS)); - try { - Response response = client.put(this.transactions); - if (response.hasEntity()) { - final Optional errorMessage = this.locateErrorMessages(response.readEntity(String.class)); - if (errorMessage.isPresent()) { - throw new BulkProcessFailed("One or more transactions failed in A&AI. Request-id=" + this.getRequestId() + ". Check logs for payloads.\nMessages:\n" + errorMessage.get()); - } - } else { - throw new BulkProcessFailed("Transactions acccepted by A&AI, but there was no response. Unsure of result."); - } - } finally { - this.transactions.getTransactions().clear(); - this.currentTransaction = null; - this.actionCount = 0; - } - } - - protected Optional locateErrorMessages(String response) { - final List errorMessages = new ArrayList<>(); - final List results = JsonPathUtil.getInstance().locateResultList(response, "$..body"); - final ObjectMapper mapper = new ObjectMapper(); - if (!results.isEmpty()) { - List> parsed = new ArrayList<>(); - try { - for (String result : results) { - parsed.add(mapper.readValue(result, new TypeReference>(){})); - } - } catch (IOException e) { - metricsLogger.error("could not map json", e); - } - for (Map map : parsed) { - for (Entry entry : map.entrySet()) { - if (!entry.getKey().matches("2\\d\\d")) { - AAIError error; - try { - error = mapper.readValue(entry.getValue().toString(), AAIError.class); - } catch (IOException e) { - metricsLogger.error("could not parse error object from A&AI", e); - error = new AAIError(); - } - AAIErrorFormatter formatter = new AAIErrorFormatter(error); - String outputMessage = formatter.getMessage(); - metricsLogger.error("part of a bulk action failed in A&AI: " + entry.getValue()); - errorMessages.add(outputMessage); - } - } - } - } - - if (!errorMessages.isEmpty()) { - return Optional.of(Joiner.on("\n").join(errorMessages)); - } else { - return Optional.empty(); - } - } - private Relationship buildRelationship(AAIUri uri) { - final Relationship result = new Relationship(); - result.setRelatedLink(uri.build().toString()); - return result; - } - - @Override - protected AAIVersion getVersion() { - return this.version; - } - - protected Transactions getTransactions() { - return this.transactions; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java deleted file mode 100644 index 3bdcdc56a3..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import java.io.IOException; - -public interface AAIUpdator { - - void updateVnfToLocked(String vnfName, String uuid) throws IOException, Exception; - - void updateVnfToUnLocked(String vnfName, String uuid) throws IOException, Exception; - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java deleted file mode 100644 index c808761040..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import org.springframework.beans.factory.annotation.Autowired; - -public class AAIUpdatorImpl implements AAIUpdator { - - @Autowired - protected AAIRestClientI client; - - public AAIRestClientI getClient() { - return client; - } - - - public void setClient(AAIRestClientI client) { - this.client = client; - } - - @Override - public void updateVnfToLocked(String vnfId, String uuid) throws Exception { - client.updateMaintenceFlagVnfId(vnfId, true, uuid); - } - - @Override - public void updateVnfToUnLocked(String vnfId, String uuid) throws Exception { - client.updateMaintenceFlagVnfId(vnfId, false, uuid); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java deleted file mode 100644 index 117ec42a36..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import java.io.IOException; - -public interface AAIValidator { - - boolean isPhysicalServerLocked(String hostName, String transactionLoggingUuid) throws IOException; - - boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws IOException, Exception; - - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java deleted file mode 100644 index c84d2f41bd..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import java.io.IOException; -import java.util.List; - -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Pserver; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - - - -@Service -public class AAIValidatorImpl implements AAIValidator { - - - @Autowired - protected AAIRestClientI client; - - public AAIRestClientI getClient() { - return client; - } - - - public void setClient(AAIRestClientI client) { - this.client = client; - } - - @Override - public boolean isPhysicalServerLocked(String vnfId, String transactionLoggingUuid) throws IOException { - List pservers; - boolean isLocked = false; - pservers = client.getPhysicalServerByVnfId(vnfId, transactionLoggingUuid); - for (Pserver pserver : pservers) - if (pserver.isInMaint()) - isLocked = true; - - return isLocked; - } - - @Override - public boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws Exception { - boolean isLocked = false; - GenericVnf genericVnf = client.getVnfByName(vnfId, transactionLoggingUuid); - if (genericVnf.isInMaint()) - isLocked = true; - - return isLocked; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/AAIVersion.java b/common/src/main/java/org/openecomp/mso/client/aai/AAIVersion.java deleted file mode 100644 index 20117fb98b..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/AAIVersion.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -public enum AAIVersion { - V8("v8"), - V9("v9"), - V10("v10"), - V11("v11"), - V12("v12"); - - public final static AAIVersion LATEST = AAIVersion.values()[AAIVersion.values().length - 1]; - private final String value; - private AAIVersion(String value){ - this.value = value; - } - @Override - public String toString(){ - return this.value; - } -} - - diff --git a/common/src/main/java/org/openecomp/mso/client/aai/Format.java b/common/src/main/java/org/openecomp/mso/client/aai/Format.java deleted file mode 100644 index e4008151ef..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/Format.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -public enum Format { - - RESOURCE("resource"), - SIMPLE("simple"), - RAW("raw"), - CONSOLE("console"), - PATHED("pathed"), - GRAPHSON("graphson"), - ID("id"); - - private final String name; - - private Format(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java deleted file mode 100644 index 3f0c4f3439..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java +++ /dev/null @@ -1,25 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities; - -public class AAIEntity{ - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntityObject.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntityObject.java deleted file mode 100644 index e4a64c4161..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntityObject.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities; - -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; - -public interface AAIEntityObject { - - public AAIResourceUri getUri(); - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java deleted file mode 100644 index 5f895ef862..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "requestError" -}) -public class AAIError { - - @JsonProperty("requestError") - private RequestError requestError; - - @JsonProperty("requestError") - public RequestError getRequestError() { - return requestError; - } - - @JsonProperty("requestError") - public void setRequestError(RequestError requestError) { - this.requestError = requestError; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIResultWrapper.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIResultWrapper.java deleted file mode 100644 index 9898f04844..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/AAIResultWrapper.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -import org.openecomp.mso.client.aai.AAICommonObjectMapperProvider; -import org.openecomp.mso.jsonpath.JsonPathUtil; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class AAIResultWrapper { - - private final String jsonBody; - private final ObjectMapper mapper; - public AAIResultWrapper(String json) { - this.jsonBody = json; - this.mapper = new AAICommonObjectMapperProvider().getMapper(); - } - - public Optional getRelationships() { - final String path = "$.relationship-list"; - Optional result = JsonPathUtil.getInstance().locateResult(jsonBody, path); - if (result.isPresent()) { - return Optional.of(new Relationships(result.get())); - } else { - return Optional.empty(); - } - } - - public String getJson() { - return jsonBody; - } - - public Map asMap() { - try { - return mapper.readValue(this.jsonBody, new TypeReference>(){}); - } catch (IOException e) { - return new HashMap<>(); - } - } - - public Optional asBean(Class clazz) { - try { - return Optional.of(mapper.readValue(this.jsonBody, clazz)); - } catch (IOException e) { - return Optional.empty(); - } - } - - @Override - public String toString() { - return this.getJson(); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/Configuration.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/Configuration.java deleted file mode 100644 index a2d0fb3604..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/Configuration.java +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.mso.client.aai.entities; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "configuration-id", - "configuration-type", - "configuration-sub-type", - "model-invariant-id", - "model-version-id", - "orchestration-status", - "operational-status", - "configuration-selflink", - "model-customization-id" -}) -public class Configuration { - - @JsonProperty("configuration-id") - private String configurationId; - @JsonProperty("configuration-name") - private String configurationName; - @JsonProperty("configuration-type") - private String configurationType; - @JsonProperty("configuration-sub-type") - private String configurationSubType; - @JsonProperty("model-invariant-id") - private String modelInvariantId; - @JsonProperty("model-version-id") - private String modelVersionId; - @JsonProperty("orchestration-status") - private String orchestrationStatus; - @JsonProperty("operational-status") - private String operationalStatus; - @JsonProperty("configuration-selflink") - private String configurationSelflink; - @JsonProperty("model-customization-id") - private String modelCustomizationId; - - @JsonProperty("configuration-id") - public String getConfigurationId() { - return configurationId; - } - - @JsonProperty("configuration-id") - public void setConfigurationId(String configurationId) { - this.configurationId = configurationId; - } - - @JsonProperty("configuration-name") - public String getConfigurationName() { - return configurationName; - } - - @JsonProperty("configuration-name") - public void setConfigurationName(String configurationName) { - this.configurationName = configurationName; - } - - @JsonProperty("configuration-type") - public String getConfigurationType() { - return configurationType; - } - - @JsonProperty("configuration-type") - public void setConfigurationType(String configurationType) { - this.configurationType = configurationType; - } - - @JsonProperty("configuration-sub-type") - public String getConfigurationSubType() { - return configurationSubType; - } - - @JsonProperty("configuration-sub-type") - public void setConfigurationSubType(String configurationSubType) { - this.configurationSubType = configurationSubType; - } - - @JsonProperty("model-invariant-id") - public String getModelInvariantId() { - return modelInvariantId; - } - - @JsonProperty("model-invariant-id") - public void setModelInvariantId(String modelInvariantId) { - this.modelInvariantId = modelInvariantId; - } - - @JsonProperty("model-version-id") - public String getModelVersionId() { - return modelVersionId; - } - - @JsonProperty("model-version-id") - public void setModelVersionId(String modelVersionId) { - this.modelVersionId = modelVersionId; - } - - @JsonProperty("orchestration-status") - public String getOrchestrationStatus() { - return orchestrationStatus; - } - - @JsonProperty("orchestration-status") - public void setOrchestrationStatus(String orchestrationStatus) { - this.orchestrationStatus = orchestrationStatus; - } - - @JsonProperty("operational-status") - public String getOperationalStatus() { - return operationalStatus; - } - - @JsonProperty("operational-status") - public void setOperationalStatus(String operationalStatus) { - this.operationalStatus = operationalStatus; - } - - @JsonProperty("model-customization-id") - public String getModelCustomizationId() { - return modelCustomizationId; - } - - @JsonProperty("model-customization-id") - public void setModelCustomizationId(String modelCustomizationId) { - this.modelCustomizationId = modelCustomizationId; - } - - @JsonProperty("configuration-selflink") - public String getConfigurationSelflink() { - return configurationSelflink; - } - - @JsonProperty("configuration-selflink") - public void setConfigurationSelflink(String configurationSelflink) { - this.configurationSelflink = configurationSelflink; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java deleted file mode 100644 index 3d014b8f67..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities; - -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.List; - -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; - -import com.fasterxml.jackson.annotation.JsonInclude; - - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class CustomQuery { - - private List start; - private String query; - private String gremlin; - - public String getGremlin() { - return gremlin; - } - - public void setGremlin(String gremlin) { - this.gremlin = gremlin; - } - - - public CustomQuery(List start){ - this.setStart(start); - } - - public CustomQuery(List start, String query){ - this.setStart(start); - this.query= "query/" + query; - } - - public CustomQuery(String gremlin) throws UnsupportedEncodingException{ - this.gremlin=gremlin; - } - - public List getStart() { - return start; - } - - public void setStart(List start) { - this.start = this.mapUris(start); - } - - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } - - private List mapUris(List uris) { - final List result = new ArrayList<>(); - uris.stream().map(item -> item.build().toString()).forEach(result::add); - return result; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/Relationships.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/Relationships.java deleted file mode 100644 index cca2fb3744..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/Relationships.java +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Predicate; - -import javax.ws.rs.core.UriBuilder; - -import org.openecomp.mso.client.aai.AAICommonObjectMapperProvider; -import org.openecomp.mso.client.aai.AAIObjectName; -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.AAIResourcesClient; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; -import org.openecomp.mso.jsonpath.JsonPathUtil; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.CaseFormat; - -public class Relationships { - - private final ObjectMapper mapper; - private Map map; - private final String jsonBody; - public Relationships(String json) { - this.jsonBody = json; - this.mapper = new AAICommonObjectMapperProvider().getMapper(); - try { - this.map = mapper.readValue(json, new TypeReference>() {}); - } catch (IOException e) { - this.map = new HashMap<>(); - } - } - - public List getByType(AAIObjectName type) { - - return this.getAll(Optional.of(type)); - } - - public List getAll() { - - return this.getAll(Optional.empty()); - } - - - public List getRelatedLinks() { - return this.getRelatedLinks(Optional.empty()); - } - - public List getRelatedLinks(AAIObjectName type) { - return this.getRelatedLinks(Optional.of(type)); - } - - public List getRelatedAAIUris() { - return this.getRelatedAAIUris(x -> true); - } - - public List getRelatedAAIUris(AAIObjectName type) { - return this.getRelatedAAIUris(x -> type.typeName().equals(x)); - } - protected List getRelatedAAIUris(Predicate p) { - List result = new ArrayList<>(); - if (map.containsKey("relationship")) { - List> relationships = (List>)map.get("relationship"); - for (Map relationship : relationships) { - final String relatedTo = (String)relationship.get("related-to"); - if (p.test(relatedTo)) { - AAIObjectType type; - try { - type = AAIObjectType.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, relatedTo)); - } catch (IllegalArgumentException e) { - type = AAIObjectType.UNKNOWN; - } - final String relatedLink = (String)relationship.get("related-link"); - - result.add(AAIUriFactory.createResourceFromExistingURI(type, UriBuilder.fromPath(relatedLink).build())); - } - } - } - return result; - } - - - - protected List getAll(final Optional type) { - List relatedLinks; - if (type.isPresent()) { - relatedLinks = this.getRelatedAAIUris(type.get()); - } else { - relatedLinks = this.getRelatedAAIUris(); - } - ArrayList result = new ArrayList<>(); - for (AAIResourceUri link : relatedLinks) { - result.add(this.get(link)); - } - return result; - } - - protected AAIResultWrapper get(AAIResourceUri uri) { - return new AAIResourcesClient().get(uri); - - } - - protected List getRelatedLinks(Optional type) { - String matcher = ""; - if (type.isPresent()) { - matcher = "[?(@.related-to=='" + type.get() + "')]"; - } - return JsonPathUtil.getInstance().locateResultList(this.jsonBody, String.format("$.relationship%s.related-link", matcher)); - } - - public String getJson() { - return this.jsonBody; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java deleted file mode 100644 index 2fd3572401..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "serviceException" -}) -public class RequestError { - - @JsonProperty("serviceException") - private ServiceException serviceException; - - @JsonProperty("serviceException") - public ServiceException getServiceException() { - return serviceException; - } - - @JsonProperty("serviceException") - public void setServiceException(ServiceException serviceException) { - this.serviceException = serviceException; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/Results.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/Results.java deleted file mode 100644 index e91823a348..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/Results.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities; - -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - - - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"results" -}) -public class Results { - @JsonProperty("results") - protected List results; - - @JsonProperty("results") - public List getResult() { - if (results == null) { - results = new ArrayList<>(); - } - return this.results; - } - @JsonProperty("results") - public void setResult(List results) { - this.results=results; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java deleted file mode 100644 index 66ca10d06b..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities; - -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "messageId", - "text", - "variables" -}) -public class ServiceException { - - @JsonProperty("messageId") - private String messageId; - @JsonProperty("text") - private String text; - @JsonProperty("variables") - private List variables = new ArrayList<>(); - - @JsonProperty("messageId") - public String getMessageId() { - return messageId; - } - - @JsonProperty("messageId") - public void setMessageId(String messageId) { - this.messageId = messageId; - } - - @JsonProperty("text") - public String getText() { - return text; - } - - @JsonProperty("text") - public void setText(String text) { - this.text = text; - } - - @JsonProperty("variables") - public List getVariables() { - return variables; - } - - @JsonProperty("variables") - public void setVariables(List variables) { - this.variables = variables; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/OperationBody.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/OperationBody.java deleted file mode 100644 index ddd9a454f8..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/OperationBody.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.bulkprocess; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"uri", -"body" -}) -public class OperationBody { - -@JsonProperty("uri") -private String uri; -@JsonProperty("body") -private Object body; - -@JsonProperty("uri") -public String getUri() { -return uri; -} - -@JsonProperty("uri") -public void setUri(String uri) { -this.uri = uri; -} - -public OperationBody withUri(String uri) { -this.uri = uri; -return this; -} - -@JsonProperty("body") -public Object getBody() { -return body; -} - -@JsonProperty("body") -public void setBody(Object body) { -this.body = body; -} - -public OperationBody withBody(Object body) { -this.body = body; -return this; -} - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transaction.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transaction.java deleted file mode 100644 index 8c4d54dc16..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transaction.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.bulkprocess; - -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"patch", -"patch", -"delete" -}) -public class Transaction { - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonProperty("put") -private List put = new ArrayList<>(); - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonProperty("patch") -private List patch = new ArrayList<>(); - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonProperty("delete") -private List delete = new ArrayList<>(); - -@JsonProperty("put") -public List getPut() { -return put; -} - -@JsonProperty("put") -public void setPut(List put) { -this.put = put; -} - -public Transaction withPut(List put) { -this.put = put; -return this; -} - -@JsonProperty("patch") -public List getPatch() { -return patch; -} - -@JsonProperty("patch") -public void setPatch(List patch) { -this.patch = patch; -} - -public Transaction withPatch(List patch) { -this.patch = patch; -return this; -} - -@JsonProperty("delete") -public List getDelete() { -return delete; -} - -@JsonProperty("delete") -public void setDelete(List delete) { -this.delete = delete; -} - -public Transaction withDelete(List delete) { -this.delete = delete; -return this; -} - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transactions.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transactions.java deleted file mode 100644 index f6ce3c5d2c..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/bulkprocess/Transactions.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.bulkprocess; - -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"transactions" -}) -public class Transactions { - -@JsonProperty("transactions") -private List transactions = new ArrayList<>(); - -@JsonProperty("transactions") -public List getTransactions() { -return transactions; -} - -@JsonProperty("transactions") -public void setTransactions(List transactions) { -this.transactions = transactions; -} - -public Transactions withTransactions(List transactions) { -this.transactions = transactions; -return this; -} - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIResourceUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIResourceUri.java deleted file mode 100644 index 36e3d008ae..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIResourceUri.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri; - -import org.openecomp.mso.client.aai.AAIObjectPlurals; -import org.openecomp.mso.client.aai.AAIObjectType; - -public interface AAIResourceUri extends AAIUri { - - public AAIResourceUri relationshipAPI(); - public AAIResourceUri relatedTo(AAIObjectPlurals plural); - public AAIResourceUri relatedTo(AAIObjectType type, String... values); - public AAIResourceUri resourceVersion(String version); - public AAIResourceUri depth(Depth depth); - public AAIResourceUri nodesOnly(boolean nodesOnly); - public AAIResourceUri queryParam(String name, String... values); - public AAIResourceUri clone(); -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUri.java deleted file mode 100644 index 1617bcddea..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUri.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri; - -import java.net.URI; -import java.util.Map; - -import org.openecomp.mso.client.aai.AAIObjectPlurals; -import org.openecomp.mso.client.aai.AAIObjectType; - -public interface AAIUri { - - public URI build(); - /** - * By default A&AI enforces a depth of 1. Some objects can be told to retrieve objects - * nested beneath them by increasing this number. - * - * You can use 0 to restrict the returned information to only the object you requested - * You can use all to retrieve all nested objects (this should only be used if you really need a massive amount of information and are caching the retrieval) - * @param depth - * @return - */ - public AAIUri depth(Depth depth); - /** - * Makes client only return object fields, no relationships - * - * @return - */ - public AAIUri nodesOnly(boolean nodesOnly); - public AAIUri queryParam(String name, String... values); - public AAIUri clone(); - - /** - * returns all key values of the URI as a map. Key names can be found in {@link AAIObjectType} - * @return - */ - public Map getURIKeys(); - public AAIObjectType getObjectType(); - public boolean equals(Object o); -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactory.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactory.java deleted file mode 100644 index cb33435c69..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactory.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri; - -import java.net.URI; - -import org.openecomp.mso.client.aai.AAIObjectPlurals; -import org.openecomp.mso.client.aai.AAIObjectType; - - -public class AAIUriFactory { - - /** - * values are filled into the URI template specified in {@link AAIObjectType} in order - * - * @param type - * @param values - * @return - */ - public static AAIResourceUri createResourceUri(AAIObjectType type, Object... values) { - if (AAIObjectType.SERVICE_INSTANCE.equals(type)) { - return new ServiceInstanceUri(values); - } else { - return new SimpleUri(type, values); - } - } - - public static AAIResourceUri createNodesUri(AAIObjectType type, Object... values) { - return new NodesUri(type, values); - - } - - /** - * This method should only be used to wrap a URI retrieved from A&AI contained within an object response - * - * @param type - * @param uri - * @return - */ - public static AAIResourceUri createResourceFromExistingURI(AAIObjectType type, URI uri) { - return new SimpleUri(type, uri); - } - - /** - * Creates a uri for a plural type e.g. /cloud-infrastructure/pservers - * - * @param type - * @return - */ - public static AAIResourceUri createResourceUri(AAIObjectPlurals type) { - - return new SimpleUri(type); - - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/Depth.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/Depth.java deleted file mode 100644 index 7522ea33d1..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/Depth.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri; - -public enum Depth { - ZERO("0"), - ONE("1"), - TWO("2"), - THREE("3"), - FOUR("4"), - FIVE("5"), - SIX("6"), - ALL("all"); - - private final String depth; - private Depth(String s) { - - this.depth = s; - } - - - @Override - public String toString() { - return this.depth; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/NodesUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/NodesUri.java deleted file mode 100644 index 407e0ecc9e..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/NodesUri.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri; - -import javax.ws.rs.core.UriBuilder; - -import org.openecomp.mso.client.aai.AAIObjectPlurals; -import org.openecomp.mso.client.aai.AAIObjectType; - -public class NodesUri extends SimpleUri { - - protected NodesUri(AAIObjectType type, Object... values) { - super(type, values); - } - - - @Override - protected String getTemplate(AAIObjectType type) { - return "/nodes" + type.partialUri(); - } - - @Override - protected String getTemplate(AAIObjectPlurals type) { - return "/nodes" + type.partialUri(); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUri.java deleted file mode 100644 index cdaecedfa9..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUri.java +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri; - -import java.io.IOException; -import java.net.URI; -import java.util.Collections; -import java.util.Map; -import java.util.Optional; - -import javax.ws.rs.BadRequestException; -import javax.ws.rs.client.ResponseProcessingException; -import javax.ws.rs.core.UriBuilder; - -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.AAIQueryClient; -import org.openecomp.mso.client.aai.Format; -import org.openecomp.mso.client.aai.entities.CustomQuery; -import org.openecomp.mso.client.aai.entities.Results; -import org.openecomp.mso.client.aai.exceptions.AAIPayloadException; -import org.openecomp.mso.client.aai.exceptions.AAIUriComputationException; -import org.openecomp.mso.client.aai.exceptions.AAIUriNotFoundException; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ServiceInstanceUri extends SimpleUri { - - private Optional cachedValue = Optional.empty(); - - protected ServiceInstanceUri(Object... values) { - super(AAIObjectType.SERVICE_INSTANCE, values); - } - protected ServiceInstanceUri(UriBuilder builder, Optional cachedValue, Object... values) { - super(AAIObjectType.SERVICE_INSTANCE, builder, values); - this.cachedValue = cachedValue; - } - protected String getSerivceInstance(Object id) throws AAIUriNotFoundException, AAIPayloadException { - if (!this.getCachedValue().isPresent()) { - AAIResourceUri serviceInstanceUri = AAIUriFactory.createNodesUri(AAIObjectType.SERVICE_INSTANCE, id); - CustomQuery query = new CustomQuery(Collections.singletonList(serviceInstanceUri)); - String resultJson; - try { - resultJson = this.getQueryClient().query(Format.PATHED, query); - } catch (ResponseProcessingException e) { - if (e.getCause() instanceof BadRequestException) { - throw new AAIUriNotFoundException("Service instance " + id + " not found at: " + serviceInstanceUri.build()); - } else { - throw e; - } - } - try { - cachedValue = extractRelatedLink(resultJson); - if (!cachedValue.isPresent()) { - throw new AAIUriNotFoundException("Service instance " + id + " not found at: " + serviceInstanceUri.build()); - } - } catch (IOException e) { - throw new AAIPayloadException("could not map payload: " + resultJson, e); - } - - } - - return this.getCachedValue().get(); - } - - protected Optional extractRelatedLink(String jsonString) throws IOException { - Optional result; - ObjectMapper mapper = new ObjectMapper(); - - Results> results = mapper.readValue(jsonString, new TypeReference>>(){}); - if (results.getResult().size() == 1) { - String uriString = results.getResult().get(0).get("resource-link"); - URI uri = UriBuilder.fromUri(uriString).build(); - String rawPath = uri.getRawPath(); - result = Optional.of(rawPath.replaceAll("/aai/v\\d+", "")); - } else if (results.getResult().isEmpty()) { - result = Optional.empty(); - } else { - throw new IllegalStateException("more than one result returned"); - } - - return result; - } - - protected Optional getCachedValue() { - return this.cachedValue; - } - - @Override - public URI build() { - try { - if (this.values.length == 1) { - String uri = getSerivceInstance(this.values[0]); - Map map = getURIKeys(uri); - return super.build(map.values().toArray(values)); - } - } catch (AAIUriNotFoundException | AAIPayloadException e) { - throw new AAIUriComputationException(e); - } - return super.build(); - } - - @Override - public ServiceInstanceUri clone() { - return new ServiceInstanceUri(this.internalURI.clone(), this.getCachedValue(), values); - } - - protected AAIQueryClient getQueryClient() { - return new AAIQueryClient(); - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/SimpleUri.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/SimpleUri.java deleted file mode 100644 index f3e6fad48b..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/SimpleUri.java +++ /dev/null @@ -1,187 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri; - -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; - -import javax.ws.rs.core.UriBuilder; - -import org.openecomp.mso.client.aai.AAIObjectPlurals; -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.entities.uri.parsers.UriParser; -import org.openecomp.mso.client.aai.entities.uri.parsers.UriParserSpringImpl; -import org.springframework.web.util.UriUtils; - -public class SimpleUri implements AAIResourceUri { - - protected UriBuilder internalURI; - protected final static String relationshipAPI = "/relationship-list/relationship"; - protected final static String relatedTo = "/related-to"; - protected final Object[] values; - protected final AAIObjectType type; - protected final AAIObjectPlurals pluralType; - protected SimpleUri(AAIObjectType type, Object... values) { - this.type = type; - this.pluralType = null; - this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); - this.values = values; - } - protected SimpleUri(AAIObjectType type, URI uri) { - this.type = type; - this.pluralType = null; - this.internalURI = UriBuilder.fromPath(uri.getRawPath().replaceAll("/aai/v\\d+", "")); - this.values = new Object[0]; - } - protected SimpleUri(AAIObjectType type, UriBuilder builder, Object... values) { - this.internalURI = builder; - this.values = values; - this.type = type; - this.pluralType = null; - } - protected SimpleUri(AAIObjectPlurals type, UriBuilder builder, Object... values) { - this.internalURI = builder; - this.values = values; - this.type = null; - this.pluralType = type; - } - protected SimpleUri(AAIObjectPlurals type) { - this.type = null; - this.pluralType = type; - this.internalURI = UriBuilder.fromPath(this.getTemplate(type)); - this.values = new Object[0]; - } - - @Override - public SimpleUri relationshipAPI() { - this.internalURI = internalURI.path(relationshipAPI); - return this; - } - - @Override - public SimpleUri relatedTo(AAIObjectPlurals plural) { - - this.internalURI = internalURI.path(relatedTo).path(plural.partialUri()); - return this; - } - @Override - public SimpleUri relatedTo(AAIObjectType type, String... values) { - this.internalURI = internalURI.path(relatedTo).path(UriBuilder.fromPath(type.partialUri()).build(values).toString()); - return this; - } - - @Override - public SimpleUri resourceVersion(String version) { - this.internalURI = internalURI.queryParam("resource-version", version); - return this; - } - - @Override - public SimpleUri queryParam(String name, String... values) { - this.internalURI = internalURI.queryParam(name, values); - return this; - } - - @Override - public URI build() { - return build(this.values); - } - - protected URI build(Object... values) { - //This is a workaround because resteasy does not encode URIs correctly - final String[] encoded = new String[values.length]; - for (int i = 0; i < values.length; i++) { - try { - encoded[i] = UriUtils.encode(values[i].toString(), StandardCharsets.UTF_8.toString()); - } catch (UnsupportedEncodingException e) { - encoded[i] = values[i].toString(); - } - } - return internalURI.buildFromEncoded(encoded); - } - - @Override - public Map getURIKeys() { - return this.getURIKeys(this.build().toString()); - } - - protected Map getURIKeys(String uri) { - UriParser parser; - if (this.type != null) { - if (!("".equals(this.getTemplate(type)))) { - parser = new UriParserSpringImpl(this.getTemplate(type)); - } else { - return new HashMap<>(); - } - } else { - parser = new UriParserSpringImpl(this.getTemplate(pluralType)); - } - - - return parser.parse(uri); - } - - @Override - public SimpleUri clone() { - if (this.type != null) { - return new SimpleUri(this.type, this.internalURI.clone(), values); - } else { - return new SimpleUri(this.pluralType, this.internalURI.clone(), values); - } - } - - @Override - public AAIObjectType getObjectType() { - return this.type; - } - - @Override - public boolean equals(Object o) { - if (o instanceof AAIUri) { - return this.build().equals(((AAIUri)o).build()); - } - return false; - } - @Override - public SimpleUri depth(Depth depth) { - this.internalURI.queryParam("depth", depth.toString()); - return this; - } - @Override - public SimpleUri nodesOnly(boolean nodesOnly) { - if (nodesOnly) { - this.internalURI.queryParam("nodes-only", ""); - } - return this; - } - - protected String getTemplate(AAIObjectType type) { - return type.uriTemplate(); - } - - protected String getTemplate(AAIObjectPlurals type) { - return type.uriTemplate(); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParser.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParser.java deleted file mode 100644 index 8e37d595b0..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParser.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri.parsers; - -import java.util.Map; -import java.util.Set; - -public interface UriParser { - public Set getVariables(); - public Map parse(final String uri); -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImpl.java b/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImpl.java deleted file mode 100644 index 75f9005125..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri.parsers; -import java.io.UnsupportedEncodingException; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.springframework.web.util.UriTemplate; -import org.springframework.web.util.UriUtils; - -public class UriParserSpringImpl implements UriParser { - - private final UriTemplate uriTemplate; - - public UriParserSpringImpl(final String template) { - this.uriTemplate = new UriTemplate(template); - } - - @Override - public Map parse(final String uri) { - final boolean match = this.uriTemplate.matches(uri); - if (!match) { - return new LinkedHashMap<>(); - } - return Collections.unmodifiableMap(decodeParams(this.uriTemplate.match(uri))); - } - - @Override - public Set getVariables() { - return Collections.unmodifiableSet(new LinkedHashSet(this.uriTemplate.getVariableNames())); - } - - protected Map decodeParams(Map map) { - final Map result = new LinkedHashMap<>(); - - for (Entry entry : map.entrySet()) { - try { - result.put(entry.getKey(), UriUtils.decode(entry.getValue(), "UTF-8")); - } catch (UnsupportedEncodingException e) { - result.put(entry.getKey(), ""); - } - } - - return result; - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIPayloadException.java b/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIPayloadException.java deleted file mode 100644 index 35842204ac..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIPayloadException.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.exceptions; - -public class AAIPayloadException extends Exception { - - private static final long serialVersionUID = -5712783905947711065L; - - public AAIPayloadException(Throwable t) { - super(t); - } - - public AAIPayloadException(String s, Throwable t) { - super(s, t); - } - - public AAIPayloadException(String s) { - super(s); - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriComputationException.java b/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriComputationException.java deleted file mode 100644 index 4d9f320cc8..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriComputationException.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.exceptions; - -public class AAIUriComputationException extends RuntimeException { - - private static final long serialVersionUID = 5187931752227522034L; - - public AAIUriComputationException(String s) { - super(s); - } - - public AAIUriComputationException(Throwable t) { - super(t); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriNotFoundException.java b/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriNotFoundException.java deleted file mode 100644 index 3e373946ce..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/exceptions/AAIUriNotFoundException.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.exceptions; - -public class AAIUriNotFoundException extends Exception { - private static final long serialVersionUID = 2789643165122257833L; - - public AAIUriNotFoundException(String message) { - super(message); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/exceptions/BulkProcessFailed.java b/common/src/main/java/org/openecomp/mso/client/aai/exceptions/BulkProcessFailed.java deleted file mode 100644 index ea64f54c33..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/exceptions/BulkProcessFailed.java +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.exceptions; - -public class BulkProcessFailed extends Exception { - - public BulkProcessFailed(String message) { - super(message); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOperationalEnvironment.java b/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOperationalEnvironment.java deleted file mode 100644 index f044e2a237..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOperationalEnvironment.java +++ /dev/null @@ -1,159 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.objects; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"operational-environment-id", -"operational-environment-name", -"operational-environment-type", -"operational-environment-status", -"tenant-context", -"workload-context", -"resource-version" -}) -public class AAIOperationalEnvironment { - -@JsonProperty("operational-environment-id") -private String operationalEnvironmentId; -@JsonProperty("operational-environment-name") -private String operationalEnvironmentName; -@JsonProperty("operational-environment-type") -private String operationalEnvironmentType; -@JsonProperty("operational-environment-status") -private String operationalEnvironmentStatus; -@JsonProperty("tenant-context") -private String tenantContext; -@JsonProperty("workload-context") -private String workloadContext; -@JsonProperty("resource-version") -private String resourceVersion; - -@JsonProperty("operational-environment-id") -public String getOperationalEnvironmentId() { -return operationalEnvironmentId; - } - -@JsonProperty("operational-environment-id") -public void setOperationalEnvironmentId(String operationalEnvironmentId) { -this.operationalEnvironmentId = operationalEnvironmentId; - } - -public AAIOperationalEnvironment withOperationalEnvironmentId(String operationalEnvironmentId) { -this.operationalEnvironmentId = operationalEnvironmentId; -return this; - } - -@JsonProperty("operational-environment-name") -public String getOperationalEnvironmentName() { -return operationalEnvironmentName; - } - -@JsonProperty("operational-environment-name") -public void setOperationalEnvironmentName(String operationalEnvironmentName) { -this.operationalEnvironmentName = operationalEnvironmentName; - } - -public AAIOperationalEnvironment withOperationalEnvironmentName(String operationalEnvironmentName) { -this.operationalEnvironmentName = operationalEnvironmentName; -return this; - } - -@JsonProperty("operational-environment-type") -public String getOperationalEnvironmentType() { -return operationalEnvironmentType; - } - -@JsonProperty("operational-environment-type") -public void setOperationalEnvironmentType(String operationalEnvironmentType) { -this.operationalEnvironmentType = operationalEnvironmentType; - } - -public AAIOperationalEnvironment withOperationalEnvironmentType(String operationalEnvironmentType) { -this.operationalEnvironmentType = operationalEnvironmentType; -return this; - } - -@JsonProperty("operational-environment-status") -public String getOperationalEnvironmentStatus() { -return operationalEnvironmentStatus; - } - -@JsonProperty("operational-environment-status") -public void setOperationalEnvironmentStatus(String operationalEnvironmentStatus) { -this.operationalEnvironmentStatus = operationalEnvironmentStatus; - } - -public AAIOperationalEnvironment withOperationalEnvironmentStatus(String operationalEnvironmentStatus) { -this.operationalEnvironmentStatus = operationalEnvironmentStatus; -return this; - } - -@JsonProperty("tenant-context") -public String getTenantContext() { -return tenantContext; - } - -@JsonProperty("tenant-context") -public void setTenantContext(String tenantContext) { -this.tenantContext = tenantContext; - } - -public AAIOperationalEnvironment withTenantContext(String tenantContext) { -this.tenantContext = tenantContext; -return this; - } - -@JsonProperty("workload-context") -public String getWorkloadContext() { -return workloadContext; - } - -@JsonProperty("workload-context") -public void setWorkloadContext(String workloadContext) { -this.workloadContext = workloadContext; - } - -public AAIOperationalEnvironment withWorkloadContext(String workloadContext) { -this.workloadContext = workloadContext; -return this; - } - -@JsonProperty("resource-version") -public String getResourceVersion() { -return resourceVersion; - } - -@JsonProperty("resource-version") -public void setResourceVersion(String resourceVersion) { -this.resourceVersion = resourceVersion; - } - -public AAIOperationalEnvironment withResourceVersion(String resourceVersion) { -this.resourceVersion = resourceVersion; -return this; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOwningEntity.java b/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOwningEntity.java deleted file mode 100644 index b0b3d06669..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIOwningEntity.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.objects; - -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.entities.AAIEntityObject; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class AAIOwningEntity implements AAIEntityObject { - - @JsonProperty("owning-entity-name") - private String owningEntityName; - - @JsonProperty("owning-entity-id") - private String owningEntityId; - - public String getOwningEntityName() { - return owningEntityName; - } - - public void setOwningEntityName(String owningEntityName) { - this.owningEntityName = owningEntityName; - } - - public String getOwningEntityId() { - return owningEntityId; - } - - public void setOwningEntityId(String owningEntityId) { - this.owningEntityId = owningEntityId; - } - - public AAIOwningEntity withOwningEntity(String owningEntityName, String owningEntityId) { - this.setOwningEntityName(owningEntityName); - this.setOwningEntityId(owningEntityId); - return this; - } - - @Override - public AAIResourceUri getUri() { - final AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, this.owningEntityId); - return uri; - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIProject.java b/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIProject.java deleted file mode 100644 index 34f715d98a..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIProject.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.objects; - -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.entities.AAIEntityObject; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class AAIProject implements AAIEntityObject { - - @JsonProperty("project-name") - private String projectName; - - public String getProjectName() { - return projectName; - } - - public void setProjectName(String projectName) { - this.projectName = projectName; - } - - public AAIProject withProjectName(String projectName) { - this.setProjectName(projectName); - return this; - } - - @Override - public AAIResourceUri getUri() { - final AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, this.projectName); - return uri; - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIServiceInstance.java b/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIServiceInstance.java deleted file mode 100644 index dbb34fcd44..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/aai/objects/AAIServiceInstance.java +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.objects; - -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.entities.AAIEntityObject; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class AAIServiceInstance implements AAIEntityObject { - - @JsonProperty("service-instance-id") - private String serviceInstanceId; - @JsonProperty("service-instance-name") - private String serviceInstanceName; - @JsonProperty("service-type") - private String serviceType; - @JsonProperty("service-role") - private String serviceRole; - @JsonProperty("orchestration-status") - private String oStatus; - @JsonProperty("model-invariant-id") - private String modelInvariantUuid; - @JsonProperty("model-version-id") - private String modelUuid; - @JsonProperty("environment-context") - private String environmentContext; - @JsonProperty("workload-context") - private String workloadContext; - - public String getServiceInstanceName() { - return serviceInstanceName; - } - - public void setServiceInstanceName(String serviceInstanceName) { - this.serviceInstanceName = serviceInstanceName; - } - - 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 String getoStatus() { - return oStatus; - } - - public void setoStatus(String oStatus) { - this.oStatus = oStatus; - } - - public String getModelInvariantUuid() { - return modelInvariantUuid; - } - - public void setModelInvariantUuid(String modelInvariantUuid) { - this.modelInvariantUuid = modelInvariantUuid; - } - - public String getModelUuid() { - return modelUuid; - } - - public void setModelUuid(String modelUuid) { - this.modelUuid = modelUuid; - } - - public String getEnvironmentContext() { - return environmentContext; - } - - public void setEnvironmentContext(String environmentContext) { - this.environmentContext = environmentContext; - } - - public String getWorkloadContext() { - return workloadContext; - } - - public void setWorkloadContext(String workloadContext) { - this.workloadContext = workloadContext; - } - - public String getServiceInstanceId() { - return serviceInstanceId; - } - - public void setServiceInstanceId(String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - } - - public AAIServiceInstance withServiceInstance(String serviceInstanceId) { - this.setServiceInstanceId(serviceInstanceId); - return this; - } - - @Override - public AAIResourceUri getUri() { - final AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, this.serviceInstanceId); - return uri; - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/client/defaultproperties/DefaultAAIPropertiesImpl.java b/common/src/main/java/org/openecomp/mso/client/defaultproperties/DefaultAAIPropertiesImpl.java deleted file mode 100644 index ce08759dd9..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/defaultproperties/DefaultAAIPropertiesImpl.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.defaultproperties; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.openecomp.mso.client.aai.AAIProperties; -import org.openecomp.mso.client.aai.AAIVersion; - -public class DefaultAAIPropertiesImpl implements AAIProperties { - - - final Map props; - public DefaultAAIPropertiesImpl() { - File initialFile = new File("src/test/resources/aai.properties"); - Map temp; - try(InputStream targetStream = new FileInputStream(initialFile)) { - Properties properties = new Properties(); - properties.load(targetStream); - temp = properties; - } catch (IOException e) { - temp = new HashMap<>(); - } - this.props = temp; - - } - @Override - public URL getEndpoint() throws MalformedURLException { - return new URL(props.get("aai.endpoint").toString()); - } - - @Override - public String getSystemName() { - return "MSO"; - } - @Override - public AAIVersion getDefaultVersion() { - return AAIVersion.LATEST; - } - - @Override - public String getAuth() { - Object value = props.get("aai.auth"); - return value == null ? null : value.toString(); - } - - @Override - public String getKey() { - Object value = props.get("mso.msoKey"); - return value == null ? null : value.toString(); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/defaultproperties/DefaultDmaapPropertiesImpl.java b/common/src/main/java/org/openecomp/mso/client/defaultproperties/DefaultDmaapPropertiesImpl.java deleted file mode 100644 index 1345286d9c..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/defaultproperties/DefaultDmaapPropertiesImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.defaultproperties; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.openecomp.mso.client.dmaap.DmaapProperties; - -public class DefaultDmaapPropertiesImpl implements DmaapProperties { - - private final Map properties; - public DefaultDmaapPropertiesImpl() throws IOException { - File initialFile = new File("src/test/resources/dmaap.properties"); - InputStream targetStream = new FileInputStream(initialFile); - Properties properties = new Properties(); - properties.load(targetStream); - this.properties = new HashMap<>(); - properties.forEach((key, value) -> this.properties.put((String)key, (String)value)); - } - @Override - public Map getProperties() { - return this.properties; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/defaultproperties/PolicyRestPropertiesImpl.java b/common/src/main/java/org/openecomp/mso/client/defaultproperties/PolicyRestPropertiesImpl.java deleted file mode 100644 index 655dc5a83d..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/defaultproperties/PolicyRestPropertiesImpl.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.defaultproperties; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.openecomp.mso.client.policy.PolicyRestProperties; - -public class PolicyRestPropertiesImpl implements PolicyRestProperties { - - - final Map props; - public PolicyRestPropertiesImpl() { - File initialFile = new File("src/test/resources/policy.properties"); - - Map temp; - try(InputStream targetStream = new FileInputStream(initialFile)) { - Properties properties = new Properties(); - properties.load(targetStream); - temp = properties; - } catch (IOException e) { - temp = new HashMap<>(); - } - this.props = temp; - - } - @Override - public URL getEndpoint() { - try { - return new URL((String)props.getOrDefault("policy.endpoint", "")); - } catch (MalformedURLException e) { - return null; - } - } - - @Override - public String getSystemName() { - return "MSO"; - } - - public String getClientAuth() { - return (String)props.get("policy.client.auth"); - } - - public String getAuth() { - return (String)props.get("policy.auth"); - } - - public String getEnvironment() { - return (String)props.get("policy.environment"); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java b/common/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java deleted file mode 100644 index 0e00ae5da8..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap; - -public interface Consumer { - - public Iterable fetch(); -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapClient.java b/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapClient.java deleted file mode 100644 index 5a2fa178de..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapClient.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap; - -import java.io.IOException; -import java.util.Base64; -import java.util.Map; -import java.util.Optional; -import java.util.Properties; - -import org.openecomp.mso.client.defaultproperties.DefaultDmaapPropertiesImpl; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public abstract class DmaapClient { - - protected final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - protected final Map msoProperties; - protected final Properties properties; - public DmaapClient(String filepath) throws IOException { - Resource resource = new ClassPathResource(filepath); - DmaapProperties dmaapProperties = DmaapPropertiesLoader.getInstance().getNewImpl(); - if (dmaapProperties == null) { - auditLogger.error("No RestProperty implementation found on classpath, loading default"); - dmaapProperties = new DefaultDmaapPropertiesImpl(); - } - this.msoProperties = dmaapProperties.getProperties(); - this.properties = new Properties(); - this.properties.load(resource.getInputStream()); - this.properties.put("password", this.deobfuscatePassword(this.getPassword())); - this.properties.put("username", this.getUserName()); - this.properties.put("topic", this.getTopic()); - if (this.getHost().isPresent()) { - this.properties.put("host", this.getHost().get()); - } - } - protected String deobfuscatePassword(String password) { - - try { - return new String(Base64.getDecoder().decode(password.getBytes())); - } catch(IllegalArgumentException iae) { - auditLogger.error("llegal Arguments",iae); - return password; - } - } - - - public abstract String getUserName(); - public abstract String getPassword(); - public abstract String getTopic(); - public abstract Optional getHost(); -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java b/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java deleted file mode 100644 index 6a01fb61ba..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap; - -import com.google.common.base.Stopwatch; -import java.io.IOException; -import java.util.concurrent.TimeUnit; -import org.openecomp.mso.client.dmaap.exceptions.DMaaPConsumerFailure; -import org.openecomp.mso.client.dmaap.exceptions.ExceededMaximumPollingTime; -import org.openecomp.mso.client.dmaap.rest.RestConsumer; - -public abstract class DmaapConsumer extends DmaapClient { - - public DmaapConsumer() throws IOException { - super("dmaap/default-consumer.properties"); - } - - public Consumer getConsumer() { - return new RestConsumer(this.properties); - } - - public boolean consume() throws Exception { - Consumer mrConsumer = this.getConsumer(); - boolean accepted = false; - Stopwatch stopwatch = Stopwatch.createUnstarted(); - try { - while (this.continuePolling()) { - if (stopwatch.elapsed(TimeUnit.MILLISECONDS) >= this.getMaximumElapsedTime()) { - final String message = "exceeded maximum retries on " + this.getRequestId() + " on " + this.getTopic(); - auditLogger.error(message); - throw new ExceededMaximumPollingTime(message); - } - stopwatch.start(); - Iterable itr = mrConsumer.fetch(); - stopwatch.stop(); - for (String message : itr) { - if (!accepted && this.isAccepted(message)) { - auditLogger.info("accepted message found for " + this.getRequestId() + " on " + this.getTopic()); - accepted = true; - } - if (accepted) { - auditLogger.info("received dmaap message: " + message); - if (this.isFailure(message)) { - this.stopProcessingMessages(); - final String errorMsg = "failure received from dmaap topic " + this.getTopic(); - auditLogger.error(errorMsg); - throw new DMaaPConsumerFailure(errorMsg); - } else { - this.processMessage(message); - } - } - } - } - return true; - } finally { - if (stopwatch.isRunning()) { - stopwatch.stop(); - } - } - } - - /** - * Should this consumer continue to consume messages from the topic? - * @return - */ - public abstract boolean continuePolling(); - /** - * Process a message from a DMaaP topic - * - * @param message - * @throws Exception - */ - public abstract void processMessage(String message) throws Exception; - /** - * Has the request been accepted by the receiving system? - * Should the consumer move to processing messages? - * - * @param message - * @return - */ - public abstract boolean isAccepted(String message); - /** - * has the request failed? - * - * @param message - * @return - */ - public abstract boolean isFailure(String message); - /** - * The request id to filter messages on - * @return - */ - public abstract String getRequestId(); - /** - * Logic that defines when the consumer should stop processing messages - */ - public abstract void stopProcessingMessages(); - - /** - * time in milliseconds - */ - public int getMaximumElapsedTime() { - return 180000; - } - - - -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapProperties.java b/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapProperties.java deleted file mode 100644 index 7bdd7dfe40..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapProperties.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap; - -import java.util.Map; - -public interface DmaapProperties { - - /** - * A map of strings which contains the properties for a dmaap client - * @return - */ - public Map getProperties(); -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java b/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java deleted file mode 100644 index 3c861991f6..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap; - -import java.util.ServiceLoader; - -public class DmaapPropertiesLoader { - - private final ServiceLoader services; - private DmaapPropertiesLoader() { - services = ServiceLoader.load(DmaapProperties.class); - } - - private static class Helper { - private static final DmaapPropertiesLoader INSTANCE = new DmaapPropertiesLoader(); - } - - public static DmaapPropertiesLoader getInstance() { - return Helper.INSTANCE; - } - public DmaapProperties getImpl() { - return this.getImpl(false); - } - public DmaapProperties getNewImpl() { - return this.getImpl(true); - } - private DmaapProperties getImpl(boolean forceNewInstance) { - for (DmaapProperties service : services) { - if (forceNewInstance) { - try { - return service.getClass().newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - /* all spi implementations must provide a public - * no argument constructor - */ - } - } else { - return service; - } - } - - return null; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java b/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java deleted file mode 100644 index d2752c531b..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap; - -import java.io.FileNotFoundException; -import java.io.IOException; - -import org.openecomp.mso.client.dmaap.rest.RestPublisher; - -public abstract class DmaapPublisher extends DmaapClient { - - private long seconds; - private final Publisher publisher; - public DmaapPublisher() throws FileNotFoundException, IOException { - super("dmaap/default-consumer.properties"); - this.publisher = new RestPublisher(properties); - this.seconds = 20; - - } - - public DmaapPublisher(long seconds) throws FileNotFoundException, IOException { - this(); - this.seconds = seconds; - } - - public void send(String json) throws IOException, InterruptedException { - auditLogger.info("publishing message to dmaap topic " + this.getTopic() + ": " + json); - publisher.send(json); - //publisher.close(seconds, TimeUnit.SECONDS); - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/Publisher.java b/common/src/main/java/org/openecomp/mso/client/dmaap/Publisher.java deleted file mode 100644 index ed1b3f3796..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/Publisher.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap; - -public interface Publisher { - - public void send(String json); -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/exceptions/DMaaPConsumerFailure.java b/common/src/main/java/org/openecomp/mso/client/dmaap/exceptions/DMaaPConsumerFailure.java deleted file mode 100644 index b1ae2b7e89..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/exceptions/DMaaPConsumerFailure.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap.exceptions; - -public class DMaaPConsumerFailure extends Exception { - - private static final long serialVersionUID = 2499229901897110362L; - - public DMaaPConsumerFailure() { - super(); - } - - public DMaaPConsumerFailure(String message) { - super(message); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/exceptions/ExceededMaximumPollingTime.java b/common/src/main/java/org/openecomp/mso/client/dmaap/exceptions/ExceededMaximumPollingTime.java deleted file mode 100644 index c0cda6b0ed..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/exceptions/ExceededMaximumPollingTime.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap.exceptions; - -public class ExceededMaximumPollingTime extends RuntimeException { - - private static final long serialVersionUID = 2331207691092906423L; - - public ExceededMaximumPollingTime() { - super(); - } - - public ExceededMaximumPollingTime(String message) { - super(message); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java b/common/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java deleted file mode 100644 index ad744ad31b..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap.rest; - -import java.net.URL; -import java.util.Base64; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; - -import javax.ws.rs.client.ClientResponseFilter; - -import org.openecomp.mso.client.ResponseExceptionMapperImpl; -import org.openecomp.mso.client.policy.RestClient; - -public class DMaaPRestClient extends RestClient { - - private final String username; - private final String password; - public DMaaPRestClient(URL url, String contentType, String username, String password) { - super(url, UUID.randomUUID(), contentType); - this.username = username; - this.password = password; - } - - @Override - protected void initializeHeaderMap(Map headerMap) { - headerMap.put("Authorization", "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes())); - } - - @Override - protected Optional addResponseFilter() { - return Optional.of(new ResponseExceptionMapperImpl()); - } - - @Override - public RestClient addRequestId(UUID requestId) { - return this; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/rest/PropertiesBean.java b/common/src/main/java/org/openecomp/mso/client/dmaap/rest/PropertiesBean.java deleted file mode 100644 index e661dd87bd..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/rest/PropertiesBean.java +++ /dev/null @@ -1,131 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap.rest; - -import java.util.Properties; - -public class PropertiesBean { - - private String username; - private String password; - private String environment; - private String partition; - private String contentType; - private String host; - private String topic; - private String timeout; - - - public PropertiesBean(Properties properties) { - this.withUsername(properties.getProperty("username")) - .withPassword(properties.getProperty("password")) - .withTopic(properties.getProperty("topic")) - .withEnvironment(properties.getProperty("environment")) - .withHost(properties.getProperty("host")) - .withTimeout(properties.getProperty("timeout", "20000")) - .withPartition(properties.getProperty("partition")) - .withContentType(properties.getProperty("contentType", "application/json")); - } - public String getUsername() { - return username; - } - public void setUsername(String username) { - this.username = username; - } - public PropertiesBean withUsername(String username) { - this.username = username; - return this; - } - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } - public PropertiesBean withPassword(String password) { - this.password = password; - return this; - } - public String getEnvironment() { - return environment; - } - public void setEnvironment(String environment) { - this.environment = environment; - } - public PropertiesBean withEnvironment(String environment) { - this.environment = environment; - return this; - } - public String getPartition() { - return partition; - } - public void setPartition(String partition) { - this.partition = partition; - } - public PropertiesBean withPartition(String partition) { - this.partition = partition; - return this; - } - public String getContentType() { - return contentType; - } - public void setContentType(String contentType) { - this.contentType = contentType; - } - public PropertiesBean withContentType(String contentType) { - this.contentType = contentType; - return this; - } - public String getHost() { - return host; - } - public void setHost(String host) { - this.host = host; - } - public PropertiesBean withHost(String host) { - this.host = host; - return this; - } - public String getTopic() { - return topic; - } - public void setTopic(String topic) { - this.topic = topic; - } - public PropertiesBean withTopic(String topic) { - this.topic = topic; - return this; - } - public String getTimeout() { - return timeout; - } - public void setTimeout(String timeout) { - this.timeout = timeout; - } - public PropertiesBean withTimeout(String timeout) { - this.timeout = timeout; - return this; - } - - - - -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/rest/RestConsumer.java b/common/src/main/java/org/openecomp/mso/client/dmaap/rest/RestConsumer.java deleted file mode 100644 index c2fb6f676f..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/rest/RestConsumer.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap.rest; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.List; -import java.util.Properties; - -import javax.ws.rs.core.GenericType; -import javax.ws.rs.core.UriBuilder; - -import org.openecomp.mso.client.dmaap.Consumer; -import org.openecomp.mso.client.policy.RestClient; - -public class RestConsumer implements Consumer { - - private final RestClient client; - public RestConsumer(Properties properties) { - PropertiesBean bean = new PropertiesBean(properties); - client = new DMaaPRestClient(this.createURL(bean), bean.getContentType(), bean.getUsername(), bean.getPassword()); - } - - private URL createURL(PropertiesBean properties) { - try { - return UriBuilder.fromUri(properties.getHost()) - .path("events").path(properties.getTopic()) - .path(properties.getPartition()) - .path("consumer1") - .queryParam("timeout", properties.getTimeout()).build().toURL(); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - - @Override - public Iterable fetch() { - - return client.get(new GenericType>() {}); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/dmaap/rest/RestPublisher.java b/common/src/main/java/org/openecomp/mso/client/dmaap/rest/RestPublisher.java deleted file mode 100644 index 3dab12f559..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/dmaap/rest/RestPublisher.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap.rest; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Properties; - -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.core.UriBuilderException; - -import org.openecomp.mso.client.dmaap.Publisher; -import org.openecomp.mso.client.policy.RestClient; - -public class RestPublisher implements Publisher { - - private final RestClient client; - - public RestPublisher(Properties properties) { - PropertiesBean bean = new PropertiesBean(properties); - client = new DMaaPRestClient(this.createURL(bean), bean.getContentType(), bean.getUsername(), bean.getPassword()); - } - - private URL createURL(PropertiesBean properties) { - try { - return UriBuilder.fromUri(properties.getHost()) - .path("events").path(properties.getTopic()) - .queryParam("timeout", properties.getTimeout()).build().toURL(); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - - @Override - public void send(String json) { - client.post(json); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/exceptions/SDNOException.java b/common/src/main/java/org/openecomp/mso/client/exceptions/SDNOException.java deleted file mode 100644 index d55f962662..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/exceptions/SDNOException.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.exceptions; - - -public class SDNOException extends Exception { - - private static final long serialVersionUID = 6189163383568887383L; - - public SDNOException() { - super(); - } - - public SDNOException(String string) { - super("SDN-O exception: " + string); - } - - public SDNOException(Exception e) { - super(e); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/grm/GRMAction.java b/common/src/main/java/org/openecomp/mso/client/grm/GRMAction.java deleted file mode 100644 index 50544bab70..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/GRMAction.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm; - -public enum GRMAction { - - FIND_RUNNING("findRunning"), - ADD("add"); - - private final String action; - - GRMAction(String action) { - this.action = action; - } - - public String getAction() { - return action; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/grm/GRMClient.java b/common/src/main/java/org/openecomp/mso/client/grm/GRMClient.java deleted file mode 100644 index 5b5f269731..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/GRMClient.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm; - -import org.openecomp.mso.client.grm.beans.ServiceEndPointList; -import org.openecomp.mso.client.grm.beans.ServiceEndPointLookup; -import org.openecomp.mso.client.grm.beans.ServiceEndPointLookupRequest; -import org.openecomp.mso.client.grm.beans.ServiceEndPointRequest; -import org.openecomp.mso.client.grm.beans.VersionLookup; -import org.openecomp.mso.client.grm.exceptions.GRMClientCallFailed; - -public class GRMClient { - - public String findRunningServicesAsString(String name, int majorVersion, String env) throws Exception { - - ServiceEndPointLookupRequest request = buildServiceEndPointlookupRequest(name, majorVersion, env); - try { - GRMRestInvoker invoker = this.getInvoker(GRMAction.FIND_RUNNING); - return invoker.post(request, String.class); - } - catch(Exception e) { - throw new GRMClientCallFailed("Call to GRM findRunning failed: " + e.getMessage(), e); - } - } - - public ServiceEndPointList findRunningServices(String name, int majorVersion, String env) throws Exception { - - ServiceEndPointLookupRequest request = buildServiceEndPointlookupRequest(name, majorVersion, env); - try { - GRMRestInvoker invoker = this.getInvoker(GRMAction.FIND_RUNNING); - return invoker.post(request, ServiceEndPointList.class); - } - catch(Exception e) { - throw new GRMClientCallFailed("Call to GRM findRunning failed: " + e.getMessage(), e); - } - } - - protected ServiceEndPointLookupRequest buildServiceEndPointlookupRequest(String name, int majorVersion, String env) { - VersionLookup version = new VersionLookup(); - version.setMajor(majorVersion); - - ServiceEndPointLookup endpoint = new ServiceEndPointLookup(); - endpoint.setName(name); - endpoint.setVersion(version); - - ServiceEndPointLookupRequest request = new ServiceEndPointLookupRequest(); - request.setServiceEndPoint(endpoint); - request.setEnv(env); - return request; - } - - public void addServiceEndPoint(ServiceEndPointRequest request) throws Exception { - try { - GRMRestInvoker invoker = this.getInvoker(GRMAction.ADD); - invoker.post(request); - } - catch(Exception e) { - throw new GRMClientCallFailed("Call to GRM addServiceEndPoint failed: " + e.getMessage(), e); - } - } - - protected GRMRestInvoker getInvoker(GRMAction action) { - return new GRMRestInvoker(action); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/grm/GRMDefaultPropertiesImpl.java b/common/src/main/java/org/openecomp/mso/client/grm/GRMDefaultPropertiesImpl.java deleted file mode 100644 index 3bdc769321..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/GRMDefaultPropertiesImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm; - -import java.net.MalformedURLException; -import java.net.URL; - -import javax.ws.rs.core.MediaType; - -public class GRMDefaultPropertiesImpl implements GRMProperties { - - public GRMDefaultPropertiesImpl() { - } - - @Override - public URL getEndpoint() throws MalformedURLException { - return new URL("http://localhost:28090"); - } - - @Override - public String getSystemName() { - return "MSO"; - } - - @Override - public String getDefaultVersion() { - return "v1"; - } - - @Override - public String getUsername() { - return "gmruser"; - } - - @Override - public String getPassword() { - return "cGFzc3dvcmQ="; - } - - @Override - public String getContentType() { - return MediaType.APPLICATION_JSON; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/grm/GRMProperties.java b/common/src/main/java/org/openecomp/mso/client/grm/GRMProperties.java deleted file mode 100644 index 6fbbb21a8a..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/GRMProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm; - -import org.openecomp.mso.client.RestProperties; - -public interface GRMProperties extends RestProperties { - public String getDefaultVersion(); - public String getUsername(); - public String getPassword(); - public String getContentType(); -} diff --git a/common/src/main/java/org/openecomp/mso/client/grm/GRMPropertiesLoader.java b/common/src/main/java/org/openecomp/mso/client/grm/GRMPropertiesLoader.java deleted file mode 100644 index 9323e22065..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/GRMPropertiesLoader.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm; - -import java.util.Iterator; -import java.util.ServiceLoader; - -public class GRMPropertiesLoader { - - private final ServiceLoader services; - private GRMPropertiesLoader() { - services = ServiceLoader.load(GRMProperties.class); - } - - private static class Helper { - private static final GRMPropertiesLoader INSTANCE = new GRMPropertiesLoader(); - } - - public static GRMPropertiesLoader getInstance() { - return Helper.INSTANCE; - } - - public GRMProperties getImpl() { - Iterator propertyImpls = services.iterator(); - while (propertyImpls.hasNext()) { - return propertyImpls.next(); - } - return null; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/grm/GRMRestClient.java b/common/src/main/java/org/openecomp/mso/client/grm/GRMRestClient.java deleted file mode 100644 index 7a81d7e7ec..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/GRMRestClient.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm; - - -import java.net.URI; -import java.util.Base64; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; - -import javax.ws.rs.client.ClientResponseFilter; - -import org.openecomp.mso.client.ResponseExceptionMapperImpl; -import org.openecomp.mso.client.RestProperties; -import org.openecomp.mso.client.policy.RestClient; - -public class GRMRestClient extends RestClient { - - private final String username; - private final String password; - - public GRMRestClient(RestProperties props, URI path, String username, String password) { - super(props, UUID.randomUUID(), Optional.of(path)); - this.username = username; - this.password = password; - } - - @Override - protected void initializeHeaderMap(Map headerMap) { - headerMap.put("Authorization", "Basic " + Base64.getEncoder().encodeToString(new String(username + ":" + password).getBytes())); - } - - @Override - protected Optional addResponseFilter() { - return Optional.of(new ResponseExceptionMapperImpl()); - } - - @Override - public RestClient addRequestId(UUID requestId) { - return this; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/grm/GRMRestInvoker.java b/common/src/main/java/org/openecomp/mso/client/grm/GRMRestInvoker.java deleted file mode 100644 index d706be3f16..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/GRMRestInvoker.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm; - -import java.net.URI; -import java.util.Base64; - -import javax.ws.rs.core.UriBuilder; -import org.openecomp.mso.client.RestPropertiesLoader; -import org.openecomp.mso.client.policy.RestClient; - -public class GRMRestInvoker { - - private final RestClient client; - private final GRMProperties properties; - - public GRMRestInvoker(GRMAction action) { - GRMProperties props = GRMPropertiesLoader.getInstance().getImpl(); - if (props == null) { - props = new GRMDefaultPropertiesImpl(); - } - this.properties = props; - this.client = new GRMRestClient(this.properties, this.createURI(action), this.properties.getUsername(), this.decode(this.properties.getPassword())); - } - - private URI createURI(GRMAction action) { - return UriBuilder.fromUri("/GRMLWPService") - .path(this.properties.getDefaultVersion()) - .path("serviceEndPoint") - .path(action.getAction()) - .build(); - } - - private String decode(String cred) { - try { - return new String(Base64.getDecoder().decode(cred.getBytes())); - } - catch(IllegalArgumentException iae) { - return cred; - } - } - - private RestClient getClient() { - return this.client; - } - - public void post(Object obj) { - getClient().post(obj); - } - - public T post(Object obj, Class resultClass) { - return getClient().post(obj, resultClass); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/grm/beans/OperationalInfo.java b/common/src/main/java/org/openecomp/mso/client/grm/beans/OperationalInfo.java deleted file mode 100644 index c5f5a7a7af..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/beans/OperationalInfo.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm.beans; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonPropertyOrder({ "createdBy", "updatedBy", "createdTimestamp", "updatedTimestamp" }) -public class OperationalInfo { - - @JsonProperty("createdBy") - private String createdBy; - @JsonProperty("updatedBy") - private String updatedBy; - @JsonProperty("createdTimestamp") - private String createdTimestamp; - @JsonProperty("updatedTimestamp") - private String updatedTimestamp; - - @JsonProperty("createdBy") - public String getCreatedBy() { - return createdBy; - } - - @JsonProperty("createdBy") - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - @JsonProperty("updatedBy") - public String getUpdatedBy() { - return updatedBy; - } - - @JsonProperty("updatedBy") - public void setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy; - } - - @JsonProperty("createdTimestamp") - public String getCreatedTimestamp() { - return createdTimestamp; - } - - @JsonProperty("createdTimestamp") - public void setCreatedTimestamp(String createdTimestamp) { - this.createdTimestamp = createdTimestamp; - } - - @JsonProperty("updatedTimestamp") - public String getUpdatedTimestamp() { - return updatedTimestamp; - } - - @JsonProperty("updatedTimestamp") - public void setUpdatedTimestamp(String updatedTimestamp) { - this.updatedTimestamp = updatedTimestamp; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/grm/beans/Property.java b/common/src/main/java/org/openecomp/mso/client/grm/beans/Property.java deleted file mode 100644 index eff1659102..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/beans/Property.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm.beans; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonPropertyOrder({ "name", "value" }) -public class Property { - - @JsonProperty("name") - private String name; - @JsonProperty("value") - private String value; - - @JsonProperty("name") - public String getName() { - return name; - } - - @JsonProperty("name") - public void setName(String name) { - this.name = name; - } - - @JsonProperty("value") - public String getValue() { - return value; - } - - @JsonProperty("value") - public void setValue(String value) { - this.value = value; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPoint.java b/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPoint.java deleted file mode 100644 index a753afbe90..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPoint.java +++ /dev/null @@ -1,247 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm.beans; - -import java.io.Serializable; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonRootName; - -@JsonRootName(value = "serviceEndPoint") -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonPropertyOrder({ "name", "version", "hostAddress", "listenPort", "latitude", "longitude", "registrationTime", - "expirationTime", "contextPath", "routeOffer", "statusInfo", "eventStatusInfo", "validatorStatusInfo", - "operationalInfo", "protocol", "properties", "disableType" }) -public class ServiceEndPoint implements Serializable { - - private static final long serialVersionUID = -1594441352549128491L; - - @JsonProperty("name") - private String name; - @JsonProperty("version") - private Version version; - @JsonProperty("hostAddress") - private String hostAddress; - @JsonProperty("listenPort") - private String listenPort; - @JsonProperty("latitude") - private String latitude; - @JsonProperty("longitude") - private String longitude; - @JsonProperty("registrationTime") - private String registrationTime; - @JsonProperty("expirationTime") - private String expirationTime; - @JsonProperty("contextPath") - private String contextPath; - @JsonProperty("routeOffer") - private String routeOffer; - @JsonProperty("statusInfo") - private Status statusInfo; - @JsonProperty("eventStatusInfo") - private Status eventStatusInfo; - @JsonProperty("validatorStatusInfo") - private Status validatorStatusInfo; - @JsonProperty("operationalInfo") - private OperationalInfo operationalInfo; - @JsonProperty("protocol") - private String protocol; - @JsonProperty("properties") - private List properties = null; - @JsonProperty("disableType") - private List disableType = null; - - @JsonProperty("name") - public String getName() { - return name; - } - - @JsonProperty("name") - public void setName(String name) { - this.name = name; - } - - @JsonProperty("version") - public Version getVersion() { - return version; - } - - @JsonProperty("version") - public void setVersion(Version version) { - this.version = version; - } - - @JsonProperty("hostAddress") - public String getHostAddress() { - return hostAddress; - } - - @JsonProperty("hostAddress") - public void setHostAddress(String hostAddress) { - this.hostAddress = hostAddress; - } - - @JsonProperty("listenPort") - public String getListenPort() { - return listenPort; - } - - @JsonProperty("listenPort") - public void setListenPort(String listenPort) { - this.listenPort = listenPort; - } - - @JsonProperty("latitude") - public String getLatitude() { - return latitude; - } - - @JsonProperty("latitude") - public void setLatitude(String latitude) { - this.latitude = latitude; - } - - @JsonProperty("longitude") - public String getLongitude() { - return longitude; - } - - @JsonProperty("longitude") - public void setLongitude(String longitude) { - this.longitude = longitude; - } - - @JsonProperty("registrationTime") - public String getRegistrationTime() { - return registrationTime; - } - - @JsonProperty("registrationTime") - public void setRegistrationTime(String registrationTime) { - this.registrationTime = registrationTime; - } - - @JsonProperty("expirationTime") - public String getExpirationTime() { - return expirationTime; - } - - @JsonProperty("expirationTime") - public void setExpirationTime(String expirationTime) { - this.expirationTime = expirationTime; - } - - @JsonProperty("contextPath") - public String getContextPath() { - return contextPath; - } - - @JsonProperty("contextPath") - public void setContextPath(String contextPath) { - this.contextPath = contextPath; - } - - @JsonProperty("routeOffer") - public String getRouteOffer() { - return routeOffer; - } - - @JsonProperty("routeOffer") - public void setRouteOffer(String routeOffer) { - this.routeOffer = routeOffer; - } - - @JsonProperty("statusInfo") - public Status getStatusInfo() { - return statusInfo; - } - - @JsonProperty("statusInfo") - public void setStatusInfo(Status statusInfo) { - this.statusInfo = statusInfo; - } - - @JsonProperty("eventStatusInfo") - public Status getEventStatusInfo() { - return eventStatusInfo; - } - - @JsonProperty("eventStatusInfo") - public void setEventStatusInfo(Status eventStatusInfo) { - this.eventStatusInfo = eventStatusInfo; - } - - @JsonProperty("validatorStatusInfo") - public Status getValidatorStatusInfo() { - return validatorStatusInfo; - } - - @JsonProperty("validatorStatusInfo") - public void setValidatorStatusInfo(Status validatorStatusInfo) { - this.validatorStatusInfo = validatorStatusInfo; - } - - @JsonProperty("operationalInfo") - public OperationalInfo getOperationalInfo() { - return operationalInfo; - } - - @JsonProperty("operationalInfo") - public void setOperationalInfo(OperationalInfo operationalInfo) { - this.operationalInfo = operationalInfo; - } - - @JsonProperty("protocol") - public String getProtocol() { - return protocol; - } - - @JsonProperty("protocol") - public void setProtocol(String protocol) { - this.protocol = protocol; - } - - @JsonProperty("properties") - public List getProperties() { - return properties; - } - - @JsonProperty("properties") - public void setProperties(List properties) { - this.properties = properties; - } - - @JsonProperty("disableType") - public List getDisableType() { - return disableType; - } - - @JsonProperty("disableType") - public void setDisableType(List disableType) { - this.disableType = disableType; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointList.java b/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointList.java deleted file mode 100644 index 0faf1fb826..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointList.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm.beans; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonPropertyOrder({ "serviceEndPointList" }) -public class ServiceEndPointList { - - @JsonProperty("serviceEndPointList") - private List serviceEndPointList = null; - - @JsonProperty("serviceEndPointList") - public List getServiceEndPointList() { - return serviceEndPointList; - } - - @JsonProperty("serviceEndPointList") - public void setServiceEndPointList(List serviceEndPointList) { - this.serviceEndPointList = serviceEndPointList; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointLookup.java b/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointLookup.java deleted file mode 100644 index 37e23795e9..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointLookup.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm.beans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonRootName; - -@JsonRootName(value = "serviceEndPoint") -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "name", "version"}) -public class ServiceEndPointLookup implements Serializable { - - private static final long serialVersionUID = 8867758152519088615L; - - @JsonProperty("name") - private String name; - @JsonProperty("version") - private VersionLookup version; - - @JsonProperty("name") - public String getName() { - return name; - } - - @JsonProperty("name") - public void setName(String name) { - this.name = name; - } - - @JsonProperty("version") - public VersionLookup getVersion() { - return version; - } - - @JsonProperty("version") - public void setVersion(VersionLookup version) { - this.version = version; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointLookupRequest.java b/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointLookupRequest.java deleted file mode 100644 index fc1992c763..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointLookupRequest.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm.beans; - -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.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonPropertyOrder({ "serviceEndPoint", "env" }) -public class ServiceEndPointLookupRequest { - - @JsonProperty("serviceEndPoint") - private ServiceEndPointLookup serviceEndPoint; - @JsonProperty("env") - private String env; - - @JsonProperty("serviceEndPoint") - public ServiceEndPointLookup getServiceEndPoint() { - return serviceEndPoint; - } - - @JsonProperty("serviceEndPoint") - public void setServiceEndPoint(ServiceEndPointLookup serviceEndPoint) { - this.serviceEndPoint = serviceEndPoint; - } - - @JsonProperty("env") - public String getEnv() { - return env; - } - - @JsonProperty("env") - public void setEnv(String env) { - this.env = env; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointRequest.java b/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointRequest.java deleted file mode 100644 index 324fe9f32a..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/beans/ServiceEndPointRequest.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm.beans; - -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.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonPropertyOrder({ "serviceEndPoint", "env" }) -public class ServiceEndPointRequest { - - @JsonProperty("serviceEndPoint") - private ServiceEndPoint serviceEndPoint; - @JsonProperty("env") - private String env; - - @JsonProperty("serviceEndPoint") - public ServiceEndPoint getServiceEndPoint() { - return serviceEndPoint; - } - - @JsonProperty("serviceEndPoint") - public void setServiceEndPoint(ServiceEndPoint serviceEndPoint) { - this.serviceEndPoint = serviceEndPoint; - } - - @JsonProperty("env") - public String getEnv() { - return env; - } - - @JsonProperty("env") - public void setEnv(String env) { - this.env = env; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/grm/beans/Status.java b/common/src/main/java/org/openecomp/mso/client/grm/beans/Status.java deleted file mode 100644 index 3c66c50a5c..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/beans/Status.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm.beans; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonPropertyOrder({ "status", "statusReasonCode", "statusReasonDescription", "statusCheckTime" }) -public class Status { - - @JsonProperty("status") - private String status; - @JsonProperty("statusReasonCode") - private String statusReasonCode; - @JsonProperty("statusReasonDescription") - private String statusReasonDescription; - @JsonProperty("statusCheckTime") - private String statusCheckTime; - - @JsonProperty("status") - public String getStatus() { - return status; - } - - @JsonProperty("status") - public void setStatus(String status) { - this.status = status; - } - - @JsonProperty("statusReasonCode") - public String getStatusReasonCode() { - return statusReasonCode; - } - - @JsonProperty("statusReasonCode") - public void setStatusReasonCode(String statusReasonCode) { - this.statusReasonCode = statusReasonCode; - } - - @JsonProperty("statusReasonDescription") - public String getStatusReasonDescription() { - return statusReasonDescription; - } - - @JsonProperty("statusReasonDescription") - public void setStatusReasonDescription(String statusReasonDescription) { - this.statusReasonDescription = statusReasonDescription; - } - - @JsonProperty("statusCheckTime") - public String getStatusCheckTime() { - return statusCheckTime; - } - - @JsonProperty("statusCheckTime") - public void setStatusCheckTime(String statusCheckTime) { - this.statusCheckTime = statusCheckTime; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/grm/beans/Version.java b/common/src/main/java/org/openecomp/mso/client/grm/beans/Version.java deleted file mode 100644 index 1d4d959f02..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/beans/Version.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm.beans; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonPropertyOrder({ "major", "minor", "patch" }) -public class Version { - - @JsonProperty("major") - private Integer major; - @JsonProperty("minor") - private Integer minor; - @JsonProperty("patch") - private String patch; - - @JsonProperty("major") - public Integer getMajor() { - return major; - } - - @JsonProperty("major") - public void setMajor(Integer major) { - this.major = major; - } - - @JsonProperty("minor") - public Integer getMinor() { - return minor; - } - - @JsonProperty("minor") - public void setMinor(Integer minor) { - this.minor = minor; - } - - @JsonProperty("patch") - public String getPatch() { - return patch; - } - - @JsonProperty("patch") - public void setPatch(String patch) { - this.patch = patch; - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/grm/beans/VersionLookup.java b/common/src/main/java/org/openecomp/mso/client/grm/beans/VersionLookup.java deleted file mode 100644 index b9d5a63450..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/beans/VersionLookup.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm.beans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonPropertyOrder({ "major" }) -public class VersionLookup implements Serializable { - - private static final long serialVersionUID = 3802602253627725770L; - - @JsonProperty("major") - private Integer major; - - @JsonProperty("major") - public Integer getMajor() { - return major; - } - - @JsonProperty("major") - public void setMajor(Integer major) { - this.major = major; - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/grm/exceptions/GRMClientCallFailed.java b/common/src/main/java/org/openecomp/mso/client/grm/exceptions/GRMClientCallFailed.java deleted file mode 100644 index 60de57286d..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/grm/exceptions/GRMClientCallFailed.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm.exceptions; - -public class GRMClientCallFailed extends Exception { - - private static final long serialVersionUID = -8714110346844078779L; - - public GRMClientCallFailed(String message, Throwable cause) { - super(message, cause); - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/CommonObjectMapperProvider.java b/common/src/main/java/org/openecomp/mso/client/policy/CommonObjectMapperProvider.java deleted file mode 100644 index 4f41b6441e..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/CommonObjectMapperProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - -import javax.ws.rs.ext.ContextResolver; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -public class CommonObjectMapperProvider implements ContextResolver { - - final ObjectMapper mapper; - - public CommonObjectMapperProvider() { - - mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - mapper.enable(MapperFeature.USE_ANNOTATIONS); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - } - - @Override - public ObjectMapper getContext(Class type) { - return mapper; - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/policy/DecisionAttributes.java b/common/src/main/java/org/openecomp/mso/client/policy/DecisionAttributes.java deleted file mode 100644 index 7b765ebb5f..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/DecisionAttributes.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "ServiceType", "VNFType", "BB_ID", "WorkStep", "ErrorCode" }) -public class DecisionAttributes { - - @JsonProperty("ServiceType") - private String serviceType; - @JsonProperty("VNFType") - private String vNFType; - @JsonProperty("BB_ID") - private String bbID; - @JsonProperty("WorkStep") - private String workStep; - @JsonProperty("ErrorCode") - private String errorCode; - - @JsonProperty("ServiceType") - public String getServiceType() { - return serviceType; - } - - @JsonProperty("ServiceType") - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - - @JsonProperty("VNFType") - public String getVNFType() { - return vNFType; - } - - @JsonProperty("VNFType") - public void setVNFType(String vNFType) { - this.vNFType = vNFType; - } - - @JsonProperty("BB_ID") - public String getBBID() { - return bbID; - } - - @JsonProperty("BB_ID") - public void setBBID(String bBID) { - this.bbID = bBID; - } - - @JsonProperty("WorkStep") - public String getWorkStep() { - return workStep; - } - - @JsonProperty("WorkStep") - public void setWorkStep(String workStep) { - this.workStep = workStep; - } - - @JsonProperty("ErrorCode") - public String getErrorCode() { - return errorCode; - } - - @JsonProperty("ErrorCode") - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/JettisonStyleMapperProvider.java b/common/src/main/java/org/openecomp/mso/client/policy/JettisonStyleMapperProvider.java deleted file mode 100644 index 19579e810b..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/JettisonStyleMapperProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - -import javax.ws.rs.ext.ContextResolver; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -public class JettisonStyleMapperProvider implements ContextResolver { - - final ObjectMapper mapper; - - public JettisonStyleMapperProvider() { - - mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - mapper.enable(MapperFeature.USE_ANNOTATIONS); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - } - - @Override - public ObjectMapper getContext(Class type) { - return mapper; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java b/common/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java deleted file mode 100644 index b04069697e..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java +++ /dev/null @@ -1,157 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - -import java.io.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; - -import javax.annotation.Priority; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.client.ClientRequestContext; -import javax.ws.rs.client.ClientRequestFilter; -import javax.ws.rs.client.ClientResponseContext; -import javax.ws.rs.client.ClientResponseFilter; -import javax.ws.rs.ext.Provider; -import javax.ws.rs.ext.WriterInterceptor; -import javax.ws.rs.ext.WriterInterceptorContext; - -import org.openecomp.mso.logger.MsoLogger; - - -@Provider -@Priority(0) -public class LoggingFilter implements ClientRequestFilter, ClientResponseFilter, WriterInterceptor { - - private static final MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - private static final String ENTITY_STREAM_PROPERTY = "LoggingFilter.entityStream"; - private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; - private final int maxEntitySize; - - public LoggingFilter() { - maxEntitySize = 1024 * 1024; - } - - public LoggingFilter(int maxPayloadSize) { - this.maxEntitySize = Integer.min(maxPayloadSize, 1024 * 1024); - } - - private void log(StringBuilder sb) { - logger.debug(sb.toString()); - } - - protected InputStream logInboundEntity(final StringBuilder b, InputStream stream, final Charset charset) - throws IOException { - if (!stream.markSupported()) { - stream = new BufferedInputStream(stream); - } - stream.mark(maxEntitySize + 1); - final byte[] entity = new byte[maxEntitySize + 1]; - final int entitySize = stream.read(entity); - if (entitySize != -1) { - b.append(new String(entity, 0, Math.min(entitySize, maxEntitySize), charset)); - } - if (entitySize > maxEntitySize) { - b.append("...more..."); - } - b.append('\n'); - stream.reset(); - return stream; - } - - @Override - public void filter(ClientRequestContext requestContext) throws IOException { - if (requestContext.hasEntity()) { - final OutputStream stream = new LoggingStream(requestContext.getEntityStream()); - requestContext.setEntityStream(stream); - requestContext.setProperty(ENTITY_STREAM_PROPERTY, stream); - } - String method = formatMethod(requestContext); - log(new StringBuilder("Making " + method + " request to: " + requestContext.getUri() + "\nRequest Headers: " + requestContext.getHeaders().toString())); - - } - - @Override - public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { - final StringBuilder sb = new StringBuilder(); - if (responseContext.hasEntity()) { - responseContext.setEntityStream(logInboundEntity(sb, responseContext.getEntityStream(), DEFAULT_CHARSET)); - String method = formatMethod(requestContext); - log(sb.insert(0, "Response from " + method + ": " + requestContext.getUri() + "\nResponse Headers: " + responseContext.getHeaders().toString())); - } - } - - @Override - public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException { - final LoggingStream stream = (LoggingStream) context.getProperty(ENTITY_STREAM_PROPERTY); - context.proceed(); - if (stream != null) { - log(stream.getStringBuilder(DEFAULT_CHARSET)); - } - } - - private class LoggingStream extends FilterOutputStream { - - private final StringBuilder sb = new StringBuilder(); - private final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - LoggingStream(OutputStream out) { - super(out); - } - - StringBuilder getStringBuilder(Charset charset) { - // write entity to the builder - final byte[] entity = baos.toByteArray(); - - sb.append(new String(entity, 0, entity.length, charset)); - if (entity.length > maxEntitySize) { - sb.append("...more..."); - } - sb.append('\n'); - - return sb; - } - - @Override - public void write(final int i) throws IOException { - if (baos.size() <= maxEntitySize) { - baos.write(i); - } - out.write(i); - } - } - - private String formatMethod(ClientRequestContext requestContext) { - String method = requestContext.getHeaderString("X-HTTP-Method-Override"); - if (method == null) { - method = requestContext.getMethod(); - } else { - method = requestContext.getMethod() + " (overridden to " + method + ")"; - } - - return method; - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/policy/PolicyClient.java b/common/src/main/java/org/openecomp/mso/client/policy/PolicyClient.java deleted file mode 100644 index defd11bc99..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/PolicyClient.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - -import org.openecomp.mso.client.policy.entities.AllowedTreatments; -import org.openecomp.mso.client.policy.entities.DictionaryData; -import org.openecomp.mso.client.policy.entities.PolicyDecision; - -public interface PolicyClient { - - public PolicyDecision getDecision(String serviceType, String vnfType, String bbID, String workStep, - String errorCode); - - public DictionaryData getAllowedTreatments(String bbID, String workStep); -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/PolicyClientImpl.java b/common/src/main/java/org/openecomp/mso/client/policy/PolicyClientImpl.java deleted file mode 100644 index 0ce1911c82..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/PolicyClientImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - -import org.openecomp.mso.client.RestPropertiesLoader; -import org.openecomp.mso.client.defaultproperties.PolicyRestPropertiesImpl; -import org.openecomp.mso.client.policy.entities.AllowedTreatments; -import org.openecomp.mso.client.policy.entities.Bbid; -import org.openecomp.mso.client.policy.entities.DecisionAttributes; -import org.openecomp.mso.client.policy.entities.DictionaryData; -import org.openecomp.mso.client.policy.entities.DictionaryItemsRequest; -import org.openecomp.mso.client.policy.entities.DictionaryJson; -import org.openecomp.mso.client.policy.entities.PolicyDecision; -import org.openecomp.mso.client.policy.entities.PolicyDecisionRequest; -import org.openecomp.mso.client.policy.entities.PolicyServiceType; -import org.openecomp.mso.client.policy.entities.Workstep; - -import java.util.List; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class PolicyClientImpl implements PolicyClient { - - protected final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - private PolicyRestProperties props; - public PolicyClientImpl() { - props = RestPropertiesLoader.getInstance().getNewImpl(PolicyRestProperties.class); - if (props == null) { - metricsLogger.error("No RestProperty.PolicyRestProperties implementation found on classpath"); - props = new PolicyRestPropertiesImpl(); - } - } - public PolicyDecision getDecision(String serviceType, String vnfType, String bbID, String workStep, - String errorCode) { - DecisionAttributes decisionAttributes = new DecisionAttributes(); - decisionAttributes.setServiceType(serviceType); - decisionAttributes.setVNFType(vnfType); - decisionAttributes.setBBID(bbID); - decisionAttributes.setWorkStep(workStep); - decisionAttributes.setErrorCode(errorCode); - - return this.getDecision(decisionAttributes); - } - - protected PolicyDecision getDecision(DecisionAttributes decisionAttributes) { - PolicyRestClient client = new PolicyRestClient(this.props, PolicyServiceType.GET_DECISION); - PolicyDecisionRequest decisionRequest = new PolicyDecisionRequest(); - decisionRequest.setDecisionAttributes(decisionAttributes); - decisionRequest.setEcompcomponentName(RestClient.ECOMP_COMPONENT_NAME); - - return client.post(decisionRequest, PolicyDecision.class); - } - - public DictionaryData getAllowedTreatments(String bbID, String workStep) - { - PolicyRestClient client = new PolicyRestClient(this.props, PolicyServiceType.GET_DICTIONARY_ITEMS); - DictionaryItemsRequest dictionaryItemsRequest = new DictionaryItemsRequest(); - dictionaryItemsRequest.setDictionaryType("Decision"); - dictionaryItemsRequest.setDictionary("RainyDayTreatments"); - final AllowedTreatments response = client.post(dictionaryItemsRequest, AllowedTreatments.class); - final DictionaryJson dictionaryJson = response.getDictionaryJson(); - final List dictionaryDataList = dictionaryJson.getDictionaryDatas(); - for(DictionaryData dictData : dictionaryDataList){ - Bbid bBid = dictData.getBbid(); - Workstep workstep = dictData.getWorkstep(); - String bBidString = bBid.getString(); - String workstepString = workstep.getString(); - if(bbID.equals(bBidString) && workStep.equals(workstepString)){ - return dictData; - } - } - metricsLogger.error("There is no AllowedTreatments with that specified parameter set"); - return null; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/PolicyDecision.java b/common/src/main/java/org/openecomp/mso/client/policy/PolicyDecision.java deleted file mode 100644 index 98c7e1558d..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/PolicyDecision.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "decision", "details" }) -public class PolicyDecision { - - @JsonProperty("decision") - private String decision; - @JsonProperty("details") - private String details; - - @JsonProperty("decision") - public String getDecision() { - return decision; - } - - @JsonProperty("decision") - public void setDecision(String decision) { - this.decision = decision; - } - - @JsonProperty("details") - public String getDetails() { - return details; - } - - @JsonProperty("details") - public void setDetails(String details) { - this.details = details; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/PolicyDecisionRequest.java b/common/src/main/java/org/openecomp/mso/client/policy/PolicyDecisionRequest.java deleted file mode 100644 index c83fb19e34..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/PolicyDecisionRequest.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "decisionAttributes", "ecompcomponentName" }) -public class PolicyDecisionRequest { - - @JsonProperty("decisionAttributes") - private DecisionAttributes decisionAttributes; - @JsonProperty("ecompcomponentName") - private String ecompcomponentName; - - @JsonProperty("decisionAttributes") - public DecisionAttributes getDecisionAttributes() { - return decisionAttributes; - } - - @JsonProperty("decisionAttributes") - public void setDecisionAttributes(DecisionAttributes decisionAttributes) { - this.decisionAttributes = decisionAttributes; - } - - @JsonProperty("ecompcomponentName") - public String getEcompcomponentName() { - return ecompcomponentName; - } - - @JsonProperty("ecompcomponentName") - public void setEcompcomponentName(String ecompcomponentName) { - this.ecompcomponentName = ecompcomponentName; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java b/common/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java deleted file mode 100644 index 77fec34de6..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - -import java.net.MalformedURLException; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; - -import javax.ws.rs.client.ClientResponseFilter; -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.core.UriBuilderException; - -import org.openecomp.mso.client.ResponseExceptionMapperImpl; -import org.openecomp.mso.client.RestProperties; -import org.openecomp.mso.client.policy.entities.PolicyServiceType; -import org.springframework.stereotype.Service; - -@Service -public class PolicyRestClient extends RestClient { - - private static final UUID X_ECOMP_REQUESTID = UUID.randomUUID(); - private final PolicyRestProperties properties; - public PolicyRestClient(PolicyRestProperties props, PolicyServiceType serviceType) { - super(props, UUID.randomUUID(), Optional.of(UriBuilder.fromPath(serviceType.toString()).build())); - this.properties = props; - this.getClient(); - } - - @Override - protected void initializeHeaderMap(Map headerMap) { - headerMap.put("ClientAuth", properties.getClientAuth()); - headerMap.put("Authorization", properties.getAuth()); - headerMap.put("Environment", properties.getEnvironment()); - this.addRequestId(X_ECOMP_REQUESTID); - } - - @Override - protected Optional addResponseFilter() { - return Optional.of(new ResponseExceptionMapperImpl()); - } - - @Override - public RestClient addRequestId(UUID requestId) { - this.headerMap.put("X-ECOMP-RequestID", requestId.toString()); - return this; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/PolicyRestProperties.java b/common/src/main/java/org/openecomp/mso/client/policy/PolicyRestProperties.java deleted file mode 100644 index d89bd54f66..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/PolicyRestProperties.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Map; - -import org.openecomp.mso.client.RestProperties; - -public interface PolicyRestProperties extends RestProperties { - - public String getClientAuth(); - public String getAuth(); - public String getEnvironment(); - -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/RestClient.java b/common/src/main/java/org/openecomp/mso/client/policy/RestClient.java deleted file mode 100644 index 77afe82758..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/RestClient.java +++ /dev/null @@ -1,243 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.security.GeneralSecurityException; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; -import java.util.UUID; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.ClientResponseFilter; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.Invocation.Builder; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.GenericType; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.ext.ContextResolver; - -import org.apache.commons.codec.binary.Base64; -import org.apache.log4j.Logger; -import org.openecomp.mso.client.RestProperties; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.utils.CryptoUtils; -import org.springframework.stereotype.Service; - -import com.fasterxml.jackson.databind.ObjectMapper; - -@Service -public abstract class RestClient { - protected static final String ECOMP_COMPONENT_NAME = "MSO"; - - private static final int MAX_PAYLOAD_SIZE = 1024 * 1024; - private WebTarget webTarget; - - protected final Map headerMap; - protected final MsoLogger msoLogger; - protected URL host; - protected Optional path; - protected Logger logger; - protected String accept; - protected String contentType; - protected UUID requestId; - - protected RestClient(RestProperties props, UUID requestId, Optional path) { - logger = Logger.getLogger(getClass().getName()); - msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - this.requestId = requestId; - headerMap = new HashMap<>(); - try { - host = props.getEndpoint(); - } catch (MalformedURLException e) { - logger.error("url not valid", e); - throw new RuntimeException(e); - } - - this.path = path; - initializeClient(getClient()); - } - - protected RestClient(RestProperties props, UUID requestId, Optional path, String accept, String contentType) { - this(props, requestId, path); - this.accept = accept; - this.contentType = contentType; - } - - protected RestClient(URL host, UUID requestId, String contentType) { - headerMap = new HashMap<>(); - logger = Logger.getLogger(getClass().getName()); - msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - this.path = Optional.empty(); - this.host = host; - this.contentType = contentType; - this.requestId = requestId; - initializeClient(getClient()); - } - - /** - * Override method to return false to disable logging. - * - * @return true - to enable logging, false otherwise - */ - protected boolean enableLogging() { - return true; - } - - /** - * Override method to return custom value for max payload size. - * - * @return Default value for MAX_PAYLOAD_SIZE = 1024 * 1024 - */ - protected int getMaxPayloadSize() - { - return MAX_PAYLOAD_SIZE; - } - - protected Builder getBuilder() { - - Builder builder = webTarget.request(); - initializeHeaderMap(headerMap); - - for (Entry entry : headerMap.entrySet()) { - builder.header(entry.getKey(), entry.getValue()); - } - return builder; - } - - protected abstract void initializeHeaderMap(Map headerMap); - - protected abstract Optional addResponseFilter(); - - public abstract RestClient addRequestId(UUID requestId); - - /** - * Adds a basic authentication header to the request. - * @param auth the encrypted credentials - * @param key the key for decrypting the credentials - */ - protected void addBasicAuthHeader(String auth, String key) { - try { - byte[] decryptedAuth = CryptoUtils.decrypt(auth, key).getBytes(); - String authHeaderValue = "Basic " + new String(Base64.encodeBase64(decryptedAuth)); - headerMap.put("Authorization", authHeaderValue); - } catch (GeneralSecurityException e) { - logger.warn(e.getMessage(), e); - } - } - - protected ContextResolver getMapper() { - return new CommonObjectMapperProvider(); - } - - protected String getAccept() { - return accept; - } - - protected String getContentType() { - return contentType; - } - - protected String getMergeContentType() { - return "application/merge-patch+json"; - } - - protected Client getClient() { - return ClientBuilder.newBuilder().build(); - } - - protected UUID getRequestId() { - return this.requestId; - } - protected void initializeClient(Client client) { - if (this.enableLogging()) { - client.register(logger).register(new LoggingFilter(this.getMaxPayloadSize())); - } - client.register(this.getMapper()); - Optional responseFilter = this.addResponseFilter(); - responseFilter.ifPresent(clientResponseFilter -> client.register(clientResponseFilter)); - webTarget = path.map(uri -> client.target(UriBuilder.fromUri(host + uri.toString()))) - .orElseGet(() -> client.target(host.toString())); - this.accept = MediaType.APPLICATION_JSON; - this.contentType = MediaType.APPLICATION_JSON; - } - - public Response get() { - return this.getBuilder().accept(this.getAccept()).get(); - } - - public Response post(Object obj) { - return this.getBuilder().accept(this.getAccept()).post(Entity.entity(obj, this.getContentType())); - } - - public Response patch(Object obj) { - return this.getBuilder().header("X-HTTP-Method-Override", "PATCH").accept(this.getAccept()) - .post(Entity.entity(obj, this.getMergeContentType())); - } - - public Response put(Object obj) { - return this.getBuilder().accept(this.getAccept()).put(Entity.entity(obj, this.getContentType())); - } - - public Response delete() { - return this.getBuilder().accept(this.getAccept()).delete(); - } - - public Response delete(Object obj) { - return this.getBuilder().header("X-HTTP-Method-Override", "DELETE").accept(this.getAccept()) - .put(Entity.entity(obj, this.getContentType())); - } - - public T get(Class resultClass) { - return this.get().readEntity(resultClass); - } - - public T get(GenericType resultClass) { - return this.get().readEntity(resultClass); - } - - public T post(Object obj, Class resultClass) { - return this.post(obj).readEntity(resultClass); - } - - public T patch(Object obj, Class resultClass) { - return this.patch(obj).readEntity(resultClass); - } - - public T put(Object obj, Class resultClass) { - return this.put(obj).readEntity(resultClass); - } - - public T delete(Class resultClass) { - return this.delete().readEntity(resultClass); - } - - public T delete(Object obj, Class resultClass) { - return this.delete(obj).readEntity(resultClass); - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/RestClientSSL.java b/common/src/main/java/org/openecomp/mso/client/policy/RestClientSSL.java deleted file mode 100644 index 6146fc373f..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/RestClientSSL.java +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - -import java.io.FileInputStream; -import java.io.IOException; -import java.net.URI; -import java.security.NoSuchAlgorithmException; -import java.security.KeyStore; -import java.util.Optional; -import java.util.Properties; -import java.util.UUID; - -import javax.net.ssl.SSLContext; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; - -import org.openecomp.mso.client.RestProperties; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -public abstract class RestClientSSL extends RestClient { - - public static final String SSL_KEY_STORE_KEY = "javax.net.ssl.keyStore"; - public static String SSL_KEY_STORE_PASSWORD_KEY; - public static final String MSO_LOAD_SSL_CLIENT_KEYSTORE_KEY = "mso.load.ssl.client.keystore"; - - - protected RestClientSSL(RestProperties props, UUID requestId, Optional path) { - super(props, requestId, path); - } - - protected RestClientSSL(RestProperties props, UUID requestId, Optional path, String accept, String contentType) { - super(props, requestId, path, accept, contentType); - } - - @Override - protected Client getClient() { - Client client = null; - Properties keyProp = new Properties (); - try { - keyProp.load (Thread.currentThread ().getContextClassLoader ().getResourceAsStream ("Policy.properties")); - SSL_KEY_STORE_PASSWORD_KEY=(String) keyProp.get ("ssl.key.store.password.key"); - String loadSSLKeyStore = System.getProperty(RestClientSSL.MSO_LOAD_SSL_CLIENT_KEYSTORE_KEY); - if(loadSSLKeyStore != null && loadSSLKeyStore.equalsIgnoreCase("true")) { - KeyStore ks = getKeyStore(); - if(ks != null) { - client = ClientBuilder.newBuilder().keyStore(ks, System.getProperty(RestClientSSL.SSL_KEY_STORE_PASSWORD_KEY)).build(); - this.msoLogger.debug("RestClientSSL not using default SSL context - setting keystore here."); - return client; - } - } - //Use default SSL context - client = ClientBuilder.newBuilder().sslContext(SSLContext.getDefault()).build(); - this.msoLogger.debug("RestClientSSL using default SSL context!"); - } catch (NoSuchAlgorithmException | IOException e) { - this.msoLogger.error(MessageEnum.APIH_GENERAL_EXCEPTION, "AAI", "Client init", MsoLogger.ErrorCode.UnknownError, "could not create SSL client", e); - throw new RuntimeException(e); - } - return client; - } - - private KeyStore getKeyStore() throws IOException { - KeyStore ks = null; - Properties keyProp = new Properties (); - - keyProp.load (Thread.currentThread ().getContextClassLoader ().getResourceAsStream ("Policy.properties")); - SSL_KEY_STORE_PASSWORD_KEY=(String) keyProp.get ("ssl.key.store.password.key"); - char[] password = System.getProperty(RestClientSSL.SSL_KEY_STORE_PASSWORD_KEY).toCharArray(); - FileInputStream fis = null; - - try { - ks = KeyStore.getInstance(KeyStore.getDefaultType()); - fis = new FileInputStream(System.getProperty(RestClientSSL.SSL_KEY_STORE_KEY)); - ks.load(fis, password); - } - catch(Exception e) { - return null; - } - - finally { - if (fis != null) { - try { - fis.close(); - } - catch(Exception e) {} - } - } - return ks; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/entities/AllowedTreatments.java b/common/src/main/java/org/openecomp/mso/client/policy/entities/AllowedTreatments.java deleted file mode 100644 index 50db843416..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/entities/AllowedTreatments.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy.entities; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"dictionaryJson", -"dictionaryData", -"responseCode", -"responseMessage" -}) -public class AllowedTreatments{ - -@JsonProperty("dictionaryJson") -private DictionaryJson dictionaryJson; -@JsonProperty("dictionaryData") -private Object dictionaryData; -@JsonProperty("responseCode") -private Integer responseCode; -@JsonProperty("responseMessage") -private String responseMessage; - -@JsonProperty("dictionaryJson") -public DictionaryJson getDictionaryJson() { -return dictionaryJson; - } - -@JsonProperty("dictionaryJson") -public void setDictionaryJson(DictionaryJson dictionaryJson) { -this.dictionaryJson = dictionaryJson; - } - -public AllowedTreatments withDictionaryJson(DictionaryJson dictionaryJson) { -this.dictionaryJson = dictionaryJson; -return this; - } - -@JsonProperty("dictionaryData") -public Object getDictionaryData() { -return dictionaryData; - } - -@JsonProperty("dictionaryData") -public void setDictionaryData(Object dictionaryData) { -this.dictionaryData = dictionaryData; - } - -public AllowedTreatments withDictionaryData(Object dictionaryData) { -this.dictionaryData = dictionaryData; -return this; - } - -@JsonProperty("responseCode") -public Integer getResponseCode() { -return responseCode; - } - -@JsonProperty("responseCode") -public void setResponseCode(Integer responseCode) { -this.responseCode = responseCode; - } - -public AllowedTreatments withResponseCode(Integer responseCode) { -this.responseCode = responseCode; -return this; - } - -@JsonProperty("responseMessage") -public String getResponseMessage() { -return responseMessage; - } - -@JsonProperty("responseMessage") -public void setResponseMessage(String responseMessage) { -this.responseMessage = responseMessage; - } - -public AllowedTreatments withResponseMessage(String responseMessage) { -this.responseMessage = responseMessage; -return this; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/policy/entities/Bbid.java b/common/src/main/java/org/openecomp/mso/client/policy/entities/Bbid.java deleted file mode 100644 index 382b27a04b..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/entities/Bbid.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy.entities; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"valueType", -"string", -"chars" -}) -public class Bbid { - -@JsonProperty("valueType") -private String valueType; -@JsonProperty("string") -private String string; -@JsonProperty("chars") -private String chars; - -@JsonProperty("valueType") -public String getValueType() { -return valueType; - } - -@JsonProperty("valueType") -public void setValueType(String valueType) { -this.valueType = valueType; - } - -public Bbid withValueType(String valueType) { -this.valueType = valueType; -return this; - } - -@JsonProperty("string") -public String getString() { -return string; - } - -@JsonProperty("string") -public void setString(String string) { -this.string = string; - } - -public Bbid withString(String string) { -this.string = string; -return this; - } - -@JsonProperty("chars") -public String getChars() { -return chars; - } - -@JsonProperty("chars") -public void setChars(String chars) { -this.chars = chars; - } - -public Bbid withChars(String chars) { -this.chars = chars; -return this; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/policy/entities/DecisionAttributes.java b/common/src/main/java/org/openecomp/mso/client/policy/entities/DecisionAttributes.java deleted file mode 100644 index 655f71f823..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/entities/DecisionAttributes.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.mso.client.policy.entities; - - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "ServiceType", "VNFType", "BB_ID", "WorkStep", "ErrorCode" }) -public class DecisionAttributes { - - @JsonProperty("ServiceType") - private String serviceType; - @JsonProperty("VNFType") - private String VNFType; - @JsonProperty("BB_ID") - private String BBID; - @JsonProperty("WorkStep") - private String workStep; - @JsonProperty("ErrorCode") - private String errorCode; - - @JsonProperty("ServiceType") - public String getServiceType() { - return serviceType; - } - - @JsonProperty("ServiceType") - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - - @JsonProperty("VNFType") - public String getVNFType() { - return VNFType; - } - - @JsonProperty("VNFType") - public void setVNFType(String vNFType) { - this.VNFType = vNFType; - } - - @JsonProperty("BB_ID") - public String getBBID() { - return BBID; - } - - @JsonProperty("BB_ID") - public void setBBID(String bBID) { - this.BBID = bBID; - } - - @JsonProperty("WorkStep") - public String getWorkStep() { - return workStep; - } - - @JsonProperty("WorkStep") - public void setWorkStep(String workStep) { - this.workStep = workStep; - } - - @JsonProperty("ErrorCode") - public String getErrorCode() { - return errorCode; - } - - @JsonProperty("ErrorCode") - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/entities/DictionaryData.java b/common/src/main/java/org/openecomp/mso/client/policy/entities/DictionaryData.java deleted file mode 100644 index 1ecf3366c7..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/entities/DictionaryData.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy.entities; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"id", -"bbid", -"workstep", -"treatments" -}) -public class DictionaryData { - -@JsonProperty("id") -private Id id; -@JsonProperty("bbid") -private Bbid bbid; -@JsonProperty("workstep") -private Workstep workstep; -@JsonProperty("treatments") -private Treatments treatments; - -@JsonProperty("id") -public Id getId() { -return id; - } - -@JsonProperty("id") -public void setId(Id id) { -this.id = id; - } - -public DictionaryData withId(Id id) { -this.id = id; -return this; - } - -@JsonProperty("bbid") -public Bbid getBbid() { -return bbid; - } - -@JsonProperty("bbid") -public void setBbid(Bbid bbid) { -this.bbid = bbid; - } - -public DictionaryData withBbid(Bbid bbid) { -this.bbid = bbid; -return this; - } - -@JsonProperty("workstep") -public Workstep getWorkstep() { -return workstep; - } - -@JsonProperty("workstep") -public void setWorkstep(Workstep workstep) { -this.workstep = workstep; - } - -public DictionaryData withWorkstep(Workstep workstep) { -this.workstep = workstep; -return this; - } - -@JsonProperty("treatments") -public Treatments getTreatments() { -return treatments; - } - -@JsonProperty("treatments") -public void setTreatments(Treatments treatments) { -this.treatments = treatments; - } - -public DictionaryData withTreatments(Treatments treatments) { -this.treatments = treatments; -return this; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/policy/entities/DictionaryItemsRequest.java b/common/src/main/java/org/openecomp/mso/client/policy/entities/DictionaryItemsRequest.java deleted file mode 100644 index d37d0c6f13..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/entities/DictionaryItemsRequest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.mso.client.policy.entities; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "dictionaryType", "dictionary" }) -public class DictionaryItemsRequest { - - @JsonProperty("dictionary") - private String dictionary; - @JsonProperty("dictionaryType") - private String dictionaryType; - - @JsonProperty("dictionary") - public String getDictionary() { - return dictionary; - } - - @JsonProperty("dictionary") - public void setDictionary(String dictionary) { - this.dictionary = dictionary; - } - - @JsonProperty("dictionaryType") - public String getDictionaryType() { - return dictionaryType; - } - - @JsonProperty("dictionaryType") - public void setDictionaryType(String dictionaryType) { - this.dictionaryType = dictionaryType; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/entities/DictionaryJson.java b/common/src/main/java/org/openecomp/mso/client/policy/entities/DictionaryJson.java deleted file mode 100644 index b6a95ae12a..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/entities/DictionaryJson.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy.entities; - -import java.util.ArrayList; -import java.util.List; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"DictionaryDatas" -}) -public class DictionaryJson { - -@JsonProperty("DictionaryDatas") -private List dictionaryDatas = new ArrayList(); - -@JsonProperty("DictionaryDatas") -public List getDictionaryDatas() { -return dictionaryDatas; - } - -@JsonProperty("DictionaryDatas") -public void setDictionaryDatas(List dictionaryDatas) { -this.dictionaryDatas = dictionaryDatas; - } - -public DictionaryJson withDictionaryDatas(List dictionaryDatas) { -this.dictionaryDatas = dictionaryDatas; -return this; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/policy/entities/Id.java b/common/src/main/java/org/openecomp/mso/client/policy/entities/Id.java deleted file mode 100644 index 728381a60b..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/entities/Id.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy.entities; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"integral", -"valueType" -}) -public class Id { - -@JsonProperty("integral") -private Boolean integral; -@JsonProperty("valueType") -private String valueType; - -@JsonProperty("integral") -public Boolean getIntegral() { -return integral; - } - -@JsonProperty("integral") -public void setIntegral(Boolean integral) { -this.integral = integral; - } - -public Id withIntegral(Boolean integral) { -this.integral = integral; -return this; - } - -@JsonProperty("valueType") -public String getValueType() { -return valueType; - } - -@JsonProperty("valueType") -public void setValueType(String valueType) { -this.valueType = valueType; - } - -public Id withValueType(String valueType) { -this.valueType = valueType; -return this; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/policy/entities/PolicyDecision.java b/common/src/main/java/org/openecomp/mso/client/policy/entities/PolicyDecision.java deleted file mode 100644 index fbc8e23151..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/entities/PolicyDecision.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.mso.client.policy.entities; - - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "decision", "details" }) -public class PolicyDecision { - - @JsonProperty("decision") - private String decision; - @JsonProperty("details") - private String details; - - @JsonProperty("decision") - public String getDecision() { - return decision; - } - - @JsonProperty("decision") - public void setDecision(String decision) { - this.decision = decision; - } - - @JsonProperty("details") - public String getDetails() { - return details; - } - - @JsonProperty("details") - public void setDetails(String details) { - this.details = details; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/entities/PolicyDecisionRequest.java b/common/src/main/java/org/openecomp/mso/client/policy/entities/PolicyDecisionRequest.java deleted file mode 100644 index bc20b9c143..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/entities/PolicyDecisionRequest.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.mso.client.policy.entities; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "decisionAttributes", "ecompcomponentName" }) -public class PolicyDecisionRequest { - - @JsonProperty("decisionAttributes") - private DecisionAttributes decisionAttributes; - @JsonProperty("ecompcomponentName") - private String ecompcomponentName; - - @JsonProperty("decisionAttributes") - public DecisionAttributes getDecisionAttributes() { - return decisionAttributes; - } - - @JsonProperty("decisionAttributes") - public void setDecisionAttributes(DecisionAttributes decisionAttributes) { - this.decisionAttributes = decisionAttributes; - } - - @JsonProperty("ecompcomponentName") - public String getEcompcomponentName() { - return ecompcomponentName; - } - - @JsonProperty("ecompcomponentName") - public void setEcompcomponentName(String ecompcomponentName) { - this.ecompcomponentName = ecompcomponentName; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/entities/PolicyServiceType.java b/common/src/main/java/org/openecomp/mso/client/policy/entities/PolicyServiceType.java deleted file mode 100644 index 01f6738947..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/entities/PolicyServiceType.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy.entities; - -public enum PolicyServiceType { - GET_CONFIG("getConfig"), - SEND_EVENT("sendEvent"), - PUSH_POLICY("pushPolicy"), - CREATE_POLICY("createPolicy"), - UPDATE_POLICY("updatePolicy"), - GET_DECISION("getDecision"), - GET_METRICS("getMetrics"), - DELETE_POLICY("deletePolicy"), - LIST_CONFIG("listConfig"), - CREATE_DICTIONARY_ITEM("createDictionaryItem"), - UPDATE_DICTIONARY_ITEM("updateDictionaryItem"), - GET_DICTIONARY_ITEMS("getDictionaryItems"); - - private final String name; - - PolicyServiceType(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/policy/entities/Treatments.java b/common/src/main/java/org/openecomp/mso/client/policy/entities/Treatments.java deleted file mode 100644 index 13af8932aa..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/entities/Treatments.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy.entities; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"valueType", -"string", -"chars" -}) -public class Treatments { - -@JsonProperty("valueType") -private String valueType; -@JsonProperty("string") -private String string; -@JsonProperty("chars") -private String chars; - -@JsonProperty("valueType") -public String getValueType() { -return valueType; - } - -@JsonProperty("valueType") -public void setValueType(String valueType) { -this.valueType = valueType; - } - -public Treatments withValueType(String valueType) { -this.valueType = valueType; -return this; - } - -@JsonProperty("string") -public String getString() { -return string; - } - -@JsonProperty("string") -public void setString(String string) { -this.string = string; - } - -public Treatments withString(String string) { -this.string = string; -return this; - } - -@JsonProperty("chars") -public String getChars() { -return chars; - } - -@JsonProperty("chars") -public void setChars(String chars) { -this.chars = chars; - } - -public Treatments withChars(String chars) { -this.chars = chars; -return this; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/policy/entities/Workstep.java b/common/src/main/java/org/openecomp/mso/client/policy/entities/Workstep.java deleted file mode 100644 index 9d2adfe2c0..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/policy/entities/Workstep.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.mso.client.policy.entities; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"valueType", -"string", -"chars" -}) -public class Workstep { - -@JsonProperty("valueType") -private String valueType; -@JsonProperty("string") -private String string; -@JsonProperty("chars") -private String chars; - -@JsonProperty("valueType") -public String getValueType() { -return valueType; - } - -@JsonProperty("valueType") -public void setValueType(String valueType) { -this.valueType = valueType; - } - -public Workstep withValueType(String valueType) { -this.valueType = valueType; -return this; - } - -@JsonProperty("string") -public String getString() { -return string; - } - -@JsonProperty("string") -public void setString(String string) { -this.string = string; - } - -public Workstep withString(String string) { -this.string = string; -return this; - } - -@JsonProperty("chars") -public String getChars() { -return chars; - } - -@JsonProperty("chars") -public void setChars(String chars) { -this.chars = chars; - } - -public Workstep withChars(String chars) { -this.chars = chars; -return this; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/ruby/RubyClient.java b/common/src/main/java/org/openecomp/mso/client/ruby/RubyClient.java deleted file mode 100644 index a4adcb23f7..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/ruby/RubyClient.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.ruby; - -import java.io.IOException; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; - -import org.openecomp.mso.client.dmaap.DmaapPublisher; -import org.openecomp.mso.client.ruby.beans.Event; -import org.openecomp.mso.client.ruby.beans.MsoRequest; -import org.openecomp.mso.client.ruby.beans.Ruby; -import org.openecomp.mso.client.ruby.dmaap.RubyCreateTicketRequestPublisher; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - - -public class RubyClient { - - private static final String REQUEST_CLIENT_NAME = "MSO"; - private static final String ACTION = "Create Ticket"; - - protected String buildRequest(String requestId, String sourceName, String reason, String workflowId, String notification) throws JsonProcessingException { - final MsoRequest request = new MsoRequest(); - request.withRequestClientName(REQUEST_CLIENT_NAME) - .withRequestId(requestId) - .withSourceName(sourceName) - .withWorkflowId(workflowId) - .withAction(ACTION); - - request.withRequestTime(this.getTime()); - - if(reason.length() <= 255){ - request.withReason(reason); - } else { - throw new IllegalArgumentException("reason exceeds 255 characters"); - } - if(notification.length() <= 1024){ - request.withNotification(notification); - } else { - throw new IllegalArgumentException("notification exceeds 1024 characters"); - } - final Event event = new Event(); - event.setMsoRequest(request); - final Ruby ruby = new Ruby(); - ruby.setEvent(event); - return this.getJson(ruby); - } - - protected String getJson(Ruby obj) throws JsonProcessingException { - final ObjectMapper mapper = new ObjectMapper(); - return mapper.writeValueAsString(obj); - } - - protected DmaapPublisher getPublisher() throws IOException { - return new RubyCreateTicketRequestPublisher(); - } - - protected String getTime() { - final ZonedDateTime currentDateTime = ZonedDateTime.now(ZoneOffset.UTC); - final DateTimeFormatter format = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss Z"); - return currentDateTime.format(format); - } - - public void rubyCreateTicketCheckRequest(String requestId, String sourceName, String reason, String workflowId, String notification) throws Exception { - String request = this.buildRequest(requestId, sourceName, reason, workflowId, notification); - final DmaapPublisher publisher = this.getPublisher(); - publisher.send(request); - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/ruby/beans/Event.java b/common/src/main/java/org/openecomp/mso/client/ruby/beans/Event.java deleted file mode 100644 index b9263596be..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/ruby/beans/Event.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.ruby.beans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"msoRequest" -}) -public class Event { - -@JsonProperty("msoRequest") -private MsoRequest msoRequest; - -/** -* No args constructor for use in serialization -* -*/ -public Event() { - } - -/** -* -* @param msoRequest -*/ -public Event(MsoRequest msoRequest) { -super(); -this.msoRequest = msoRequest; - } - -@JsonProperty("msoRequest") -public MsoRequest getMsoRequest() { -return msoRequest; - } - -@JsonProperty("msoRequest") -public void setMsoRequest(MsoRequest msoRequest) { -this.msoRequest = msoRequest; - } - -public Event withMsoRequest(MsoRequest msoRequest) { -this.msoRequest = msoRequest; -return this; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/ruby/beans/MsoRequest.java b/common/src/main/java/org/openecomp/mso/client/ruby/beans/MsoRequest.java deleted file mode 100644 index d00adae88a..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/ruby/beans/MsoRequest.java +++ /dev/null @@ -1,207 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.ruby.beans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"requestClientName", -"requestId", -"requestTime", -"sourceName", -"reason", -"action", -"workflowId", -"notification" -}) -public class MsoRequest { - -@JsonProperty("requestClientName") -private String requestClientName; -@JsonProperty("requestId") -private String requestId; -@JsonProperty("requestTime") -private String requestTime; -@JsonProperty("sourceName") -private String sourceName; -@JsonProperty("reason") -private String reason; -@JsonProperty("action") -private String action; -@JsonProperty("workflowId") -private String workflowId; -@JsonProperty("notification") -private String notification; - -/** -* No args constructor for use in serialization -* -*/ -public MsoRequest() { - } - -/** -* -* @param requestClientName -* @param requestTime -* @param reason -* @param requestId -* @param workflowId -* @param sourceName -* @param action -* @param notification -*/ -public MsoRequest(String requestClientName, String requestId, String requestTime, String sourceName, String reason, String action, String workflowId, String notification) { -super(); -this.requestClientName = requestClientName; -this.requestId = requestId; -this.requestTime = requestTime; -this.sourceName = sourceName; -this.reason = reason; -this.action = action; -this.workflowId = workflowId; -this.notification = notification; - } - -@JsonProperty("requestClientName") -public String getRequestClientName() { -return requestClientName; - } - -@JsonProperty("requestClientName") -public void setRequestClientName(String requestClientName) { -this.requestClientName = requestClientName; - } - -public MsoRequest withRequestClientName(String requestClientName) { -this.requestClientName = requestClientName; -return this; - } - -@JsonProperty("requestId") -public String getRequestId() { -return requestId; - } - -@JsonProperty("requestId") -public void setRequestId(String requestId) { -this.requestId = requestId; - } - -public MsoRequest withRequestId(String requestId) { -this.requestId = requestId; -return this; - } - -@JsonProperty("requestTime") -public String getRequestTime() { -return requestTime; - } - -@JsonProperty("requestTime") -public void setRequestTime(String requestTime) { -this.requestTime = requestTime; - } - -public MsoRequest withRequestTime(String requestTime) { -this.requestTime = requestTime; -return this; - } - -@JsonProperty("sourceName") -public String getSourceName() { -return sourceName; - } - -@JsonProperty("sourceName") -public void setSourceName(String sourceName) { -this.sourceName = sourceName; - } - -public MsoRequest withSourceName(String sourceName) { -this.sourceName = sourceName; -return this; - } - -@JsonProperty("reason") -public String getReason() { -return reason; - } - -@JsonProperty("reason") -public void setReason(String reason) { -this.reason = reason; - } - -public MsoRequest withReason(String reason) { -this.reason = reason; -return this; - } - -@JsonProperty("action") -public String getAction() { -return action; - } - -@JsonProperty("action") -public void setAction(String action) { -this.action = action; - } - -public MsoRequest withAction(String action) { -this.action = action; -return this; - } - -@JsonProperty("workflowId") -public String getWorkflowId() { -return workflowId; - } - -@JsonProperty("workflowId") -public void setWorkflowId(String workflowId) { -this.workflowId = workflowId; - } - -public MsoRequest withWorkflowId(String workflowId) { -this.workflowId = workflowId; -return this; - } - -@JsonProperty("notification") -public String getNotification() { -return notification; - } - -@JsonProperty("notification") -public void setNotification(String notification) { -this.notification = notification; - } - -public MsoRequest withNotification(String notification) { -this.notification = notification; -return this; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/ruby/beans/Ruby.java b/common/src/main/java/org/openecomp/mso/client/ruby/beans/Ruby.java deleted file mode 100644 index 1b81043faf..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/ruby/beans/Ruby.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.mso.client.ruby.beans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"event" -}) -public class Ruby { - -@JsonProperty("event") -private Event event; - -/** -* No args constructor for use in serialization -* -*/ -public Ruby() { - } - -/** -* -* @param event -*/ -public Ruby(Event event) { -super(); -this.event = event; - } - -@JsonProperty("event") -public Event getEvent() { -return event; - } - -@JsonProperty("event") -public void setEvent(Event event) { -this.event = event; - } - -public Ruby withEvent(Event event) { -this.event = event; -return this; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java b/common/src/main/java/org/openecomp/mso/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java deleted file mode 100644 index 521318f822..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.ruby.dmaap; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Optional; - -import org.openecomp.mso.client.dmaap.DmaapPublisher; - -public class RubyCreateTicketRequestPublisher extends DmaapPublisher{ - public RubyCreateTicketRequestPublisher() throws FileNotFoundException, IOException { - super(); - } - - @Override - public String getUserName() { - return msoProperties.get("ruby.create-ticket-request.dmaap.username"); - } - - @Override - public String getPassword() { - return msoProperties.get("ruby.create-ticket-request.dmaap.password"); - } - - @Override - public String getTopic() { - return msoProperties.get("ruby.create-ticket-request.publisher.topic"); - } - - @Override - public Optional getHost() { - return Optional.ofNullable(msoProperties.get("ruby.create-ticket-request.publisher.host")); - } - -} - - diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClient.java b/common/src/main/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClient.java deleted file mode 100644 index 3ba75bb2b4..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClient.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.openecomp.mso.client.dmaap.DmaapConsumer; -import org.openecomp.mso.client.dmaap.DmaapPublisher; -import org.openecomp.mso.client.sdno.beans.AAIParamList; -import org.openecomp.mso.client.sdno.beans.Body; -import org.openecomp.mso.client.sdno.beans.Input; -import org.openecomp.mso.client.sdno.beans.RequestHdCustom; -import org.openecomp.mso.client.sdno.beans.SDNO; -import org.openecomp.mso.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; -import org.openecomp.mso.client.sdno.dmaap.SDNOHealthCheckDmaapPublisher; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class SDNOHealthCheckClient { - - private static final String NODE_TYPE = "VROUTER"; - private static final String API_OPERATION_TYPE = "health-diagnostic-custom"; - private static final String MIRRORING_CHECK = "mirroring_check"; - private static final String CLIENT_NAME = "MSO"; - private static final String PRE_CHECK_CODE = "VROUTER000003"; - private static final String POST_CHECK_CODE = "VROUTER000004"; - private static final String LPORT_MIRRORING_CHECK = "lport_mirroring_check"; - private static final String CONFIGURATION_ID = "configuration-id"; - - - public boolean lPortMirrorHealthPreCheck(String userId, String requestId, OptionalclliCode, String configurationId, String interfaceId) throws Exception{ - String request = buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId); - return this.execute(requestId, request); - } - - public boolean lPortMirrorHealthPostCheck(String userId, String requestId, OptionalclliCode, String configurationId, String interfaceId) throws Exception{ - String request = buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId); - return this.execute(requestId, request); - } - - public boolean portMirrorHealthPreCheck(String userId, String requestId, Optional clliCode, String configurationId) throws Exception { - final String request = this.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId); - return this.execute(requestId, request); - } - - public boolean portMirrorHealthPostCheck(String userId, String requestId, Optional clliCode, String configurationId) throws Exception { - final String request = this.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId); - return this.execute(requestId, request); - } - - protected String buildLPortMirrorCheckPreRequest(String userId, String requestId, Optional clliCode, String configurationId, String interfaceId) throws JsonProcessingException{ - return this.buildLPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, interfaceId, PRE_CHECK_CODE); - } - - protected String buildLPortMirrorCheckPostRequest(String userId, String requestId, Optional clliCode, String configurationId, String interfaceId) throws JsonProcessingException{ - return this.buildLPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, interfaceId, POST_CHECK_CODE); - } - - protected String buildPortMirrorPreCheckRequest(String userId, String requestId, Optional clliCode, String configurationId) throws JsonProcessingException { - return this.buildPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, PRE_CHECK_CODE); - } - - protected String buildPortMirrorPostCheckRequest(String userId, String requestId, Optional clliCode, String configurationId) throws JsonProcessingException { - return this.buildPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, POST_CHECK_CODE); - } - - protected String buildPortMirrorCheckRequest(String userId, String requestId, Optional clliCode, String configurationId, String diagnosticCode) throws JsonProcessingException { - final AAIParamList list = new AAIParamList(); - list.setKey(CONFIGURATION_ID); - list.setValue(configurationId); - - return this.buildRequest(userId, requestId, clliCode, diagnosticCode, MIRRORING_CHECK, Collections.singletonList(list)); - } - - protected String buildLPortMirrorCheckRequest(String userId, String requestId, Optional clliCode, String configurationId, String interfaceId, String diagnosticCode) throws JsonProcessingException { - - final AAIParamList configurationIdParam = new AAIParamList(); - configurationIdParam.setKey(CONFIGURATION_ID); - configurationIdParam.setValue(configurationId); - final AAIParamList interfaceIdParam = new AAIParamList(); - interfaceIdParam.setKey("interface-id"); - interfaceIdParam.setValue(interfaceId); - final List list = new ArrayList<>(); - list.add(configurationIdParam); - list.add(interfaceIdParam); - return this.buildRequest(userId, requestId, clliCode, diagnosticCode, LPORT_MIRRORING_CHECK, list); - } - - - protected String buildRequest(String userId, String requestId, Optional clliCode, String diagnosticCode, String operationType, List paramList) throws JsonProcessingException { - - final RequestHdCustom hdCustom = new RequestHdCustom(); - hdCustom.withRequestUserId(userId) - .withRequestId(requestId) - .withRequestClientName(CLIENT_NAME) - .withHealthDiagnosticCode(diagnosticCode) - .withOperationType(operationType) - .withAaiParamList(paramList); - - final Input input = new Input(); - input.setRequestHdCustom(hdCustom); - final Body body = new Body(); - body.setInput(input); - final SDNO request = new SDNO(); - request.withBody(body).withOperation(API_OPERATION_TYPE).withNodeType(NODE_TYPE); - if (clliCode.isPresent()) { - request.setNodeLoc(clliCode.get()); - } - return this.getJson(request); - - } - protected String getJson(SDNO obj) throws JsonProcessingException { - final ObjectMapper mapper = new ObjectMapper(); - return mapper.writeValueAsString(obj); - } - - protected DmaapPublisher getPublisher() throws FileNotFoundException, IOException { - return new SDNOHealthCheckDmaapPublisher(); - } - - protected DmaapConsumer getConsumer(String requestId) throws FileNotFoundException, IOException { - return new SDNOHealthCheckDmaapConsumer(requestId); - } - - protected boolean execute(String requestId, String request) throws Exception { - final DmaapPublisher publisher = this.getPublisher(); - publisher.send(request); - - final DmaapConsumer consumer = this.getConsumer(requestId); - - return consumer.consume(); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java b/common/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java deleted file mode 100644 index 534186b7ef..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno; - -import java.io.IOException; -import java.util.UUID; - -public interface SDNOValidator { - - /** - * Issues a health diagnostic request for a given vnf to SDN-O - * - * @param vnfId - * @param requestingUserId - * @throws IOException - * @throws Exception - */ - public void healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception; - -} diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java b/common/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java deleted file mode 100644 index e6955f57fc..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Optional; -import java.util.UUID; - -import org.onap.aai.domain.yang.GenericVnf; -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.AAIResourcesClient; -import org.openecomp.mso.client.aai.AAIVersion; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; -import org.openecomp.mso.client.dmaap.DmaapConsumer; -import org.openecomp.mso.client.dmaap.DmaapPublisher; -import org.openecomp.mso.client.sdno.beans.Body; -import org.openecomp.mso.client.sdno.beans.Input; -import org.openecomp.mso.client.sdno.beans.RequestHealthDiagnostic; -import org.openecomp.mso.client.sdno.beans.SDNO; -import org.openecomp.mso.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; -import org.openecomp.mso.client.sdno.dmaap.SDNOHealthCheckDmaapPublisher; - -import com.fasterxml.jackson.databind.ObjectMapper; - - -public class SDNOValidatorImpl implements SDNOValidator { - - private final static String clientName = "MSO"; - - @Override - public void healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception { - - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); - AAIResourcesClient client = new AAIResourcesClient(AAIVersion.V10, uuid); - GenericVnf vnf = client.get(GenericVnf.class, uri); - - SDNO requestDiagnostic = buildRequestDiagnostic(vnf, uuid, requestingUserId); - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(requestDiagnostic); - this.submitRequest(json); - this.pollForResponse(uuid.toString()); - - } - - protected SDNO buildRequestDiagnostic(GenericVnf vnf, UUID uuid, String requestingUserId) { - - Optional vnfType; - if (vnf.getVnfType() == null) { - vnfType = Optional.empty(); - } else { - vnfType = Optional.of(vnf.getVnfType()); - } - Input input = new Input(); - SDNO parentRequest = new SDNO(); - Body body = new Body(); - parentRequest.setBody(body); - parentRequest.setNodeType(vnfType.orElse("NONE").toUpperCase()); - parentRequest.setOperation("health-diagnostic"); - - body.setInput(input); - - RequestHealthDiagnostic request = new RequestHealthDiagnostic(); - request.setRequestClientName(clientName); - request.setRequestNodeName(vnf.getVnfName()); - request.setRequestNodeIp(vnf.getIpv4OamAddress()); //generic-vnf oam ip - request.setRequestUserId(requestingUserId); //mech id? - request.setRequestId(uuid.toString()); //something to identify this request by for polling - - input.setRequestHealthDiagnostic(request); - - return parentRequest; - } - protected void submitRequest(String json) throws FileNotFoundException, IOException, InterruptedException { - - DmaapPublisher publisher = new SDNOHealthCheckDmaapPublisher(); - publisher.send(json); - } - protected boolean pollForResponse(String uuid) throws Exception { - DmaapConsumer consumer = this.getConsumer(uuid); - return consumer.consume(); - } - - - - protected DmaapConsumer getConsumer(String uuid) throws FileNotFoundException, IOException { - return new SDNOHealthCheckDmaapConsumer(uuid); - } - - - -} diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/beans/AAIParamList.java b/common/src/main/java/org/openecomp/mso/client/sdno/beans/AAIParamList.java deleted file mode 100644 index bab37c0685..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/sdno/beans/AAIParamList.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno.beans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"key", -"value" -}) -public class AAIParamList { - -@JsonProperty("key") -private String key; -@JsonProperty("value") -private String value; - -/** -* No args constructor for use in serialization -* -*/ -public AAIParamList() { - } - -/** -* -* @param value -* @param key -*/ -public AAIParamList(String key, String value) { -super(); -this.key = key; -this.value = value; - } - -@JsonProperty("key") -public String getKey() { -return key; - } - -@JsonProperty("key") -public void setKey(String key) { -this.key = key; - } - -public AAIParamList withKey(String key) { -this.key = key; -return this; - } - -@JsonProperty("value") -public String getValue() { -return value; - } - -@JsonProperty("value") -public void setValue(String value) { -this.value = value; - } - -public AAIParamList withValue(String value) { -this.value = value; -return this; - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java b/common/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java deleted file mode 100644 index 0898f3ca36..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno.beans; - -import java.io.Serializable; -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({ - "input" -}) -public class Body implements Serializable -{ - - @JsonProperty("input") - private Input input; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private final static long serialVersionUID = 9101706044452851559L; - - @JsonProperty("input") - public Input getInput() { - return input; - } - - @JsonProperty("input") - public void setInput(Input input) { - this.input = input; - } - - public Body withInput(Input input) { - this.input = input; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } - - public Body withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java b/common/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java deleted file mode 100644 index 9626ff06b4..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno.beans; - -import java.io.Serializable; -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({ - "request-healthdiagnostic", - "request-hd-custom" -}) -public class Input implements Serializable -{ - - @JsonProperty("request-healthdiagnostic") - private RequestHealthDiagnostic RequestHealthDiagnostic; - @JsonProperty("request-hd-custom") - private RequestHdCustom requestHdCustom; - - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private final static long serialVersionUID = 7155546785389227528L; - - @JsonProperty("request-healthdiagnostic") - public RequestHealthDiagnostic getRequestHealthDiagnostic() { - return RequestHealthDiagnostic; - } - - @JsonProperty("request-healthdiagnostic") - public void setRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { - this.RequestHealthDiagnostic = RequestHealthDiagnostic; - } - - @JsonProperty("request-hd-custom") - public RequestHdCustom getRequestHdCustom() { - return requestHdCustom; - } - - @JsonProperty("request-hd-custom") - public void setRequestHdCustom(RequestHdCustom requestHdCustom) { - this.requestHdCustom = requestHdCustom; - } - - public Input withRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { - this.RequestHealthDiagnostic = RequestHealthDiagnostic; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } - - public Input withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHdCustom.java b/common/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHdCustom.java deleted file mode 100644 index a0d00a7e6e..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHdCustom.java +++ /dev/null @@ -1,170 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - - -package org.openecomp.mso.client.sdno.beans; - -import java.util.ArrayList; -import java.util.List; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"request-client-name", -"request-user-id", -"request-id", -"health-diagnostic-code", -"operation-type", -"aai-param-list" -}) -public class RequestHdCustom { - -@JsonProperty("request-client-name") -private String requestClientName; -@JsonProperty("request-user-id") -private String requestUserId; -@JsonProperty("request-id") -private String requestId; -@JsonProperty("health-diagnostic-code") -private String healthDiagnosticCode; -@JsonProperty("operation-type") -private String operationType; -@JsonProperty("aai-param-list") -private List aaiParamList = new ArrayList(); - -/** -* No args constructor for use in serialization -* -*/ -public RequestHdCustom() { - } - -/** -* -* @param requestClientName -* @param operationType -* @param requestId -* @param healthDiagnosticCode -* @param aaiParamList -* @param requestUserId -*/ -public RequestHdCustom(String requestClientName, String requestUserId, String requestId, String healthDiagnosticCode, String operationType, List aaiParamList) { -super(); -this.requestClientName = requestClientName; -this.requestUserId = requestUserId; -this.requestId = requestId; -this.healthDiagnosticCode = healthDiagnosticCode; -this.operationType = operationType; -this.aaiParamList = aaiParamList; - } - -@JsonProperty("request-client-name") -public String getRequestClientName() { -return requestClientName; - } - -@JsonProperty("request-client-name") -public void setRequestClientName(String requestClientName) { -this.requestClientName = requestClientName; - } - -public RequestHdCustom withRequestClientName(String requestClientName) { -this.requestClientName = requestClientName; -return this; - } - -@JsonProperty("request-user-id") -public String getRequestUserId() { -return requestUserId; - } - -@JsonProperty("request-user-id") -public void setRequestUserId(String requestUserId) { -this.requestUserId = requestUserId; - } - -public RequestHdCustom withRequestUserId(String requestUserId) { -this.requestUserId = requestUserId; -return this; - } - -@JsonProperty("request-id") -public String getRequestId() { -return requestId; - } - -@JsonProperty("request-id") -public void setRequestId(String requestId) { -this.requestId = requestId; - } - -public RequestHdCustom withRequestId(String requestId) { -this.requestId = requestId; -return this; - } - -@JsonProperty("health-diagnostic-code") -public String getHealthDiagnosticCode() { -return healthDiagnosticCode; - } - -@JsonProperty("health-diagnostic-code") -public void setHealthDiagnosticCode(String healthDiagnosticCode) { -this.healthDiagnosticCode = healthDiagnosticCode; - } - -public RequestHdCustom withHealthDiagnosticCode(String healthDiagnosticCode) { -this.healthDiagnosticCode = healthDiagnosticCode; -return this; - } - -@JsonProperty("operation-type") -public String getOperationType() { -return operationType; - } - -@JsonProperty("operation-type") -public void setOperationType(String operationType) { -this.operationType = operationType; - } - -public RequestHdCustom withOperationType(String operationType) { -this.operationType = operationType; -return this; - } - -@JsonProperty("aai-param-list") -public List getAaiParamList() { -return aaiParamList; - } - -@JsonProperty("aai-param-list") -public void setAaiParamList(List aaiParamList) { -this.aaiParamList = aaiParamList; - } - -public RequestHdCustom withAaiParamList(List aaiParamList) { -this.aaiParamList = aaiParamList; -return this; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java b/common/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java deleted file mode 100644 index 5ff47fa4be..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java +++ /dev/null @@ -1,189 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno.beans; - -import java.io.Serializable; -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({ - "request-client-name", - "request-node-name", - "request-node-ip", - "request-id", - "request-user-id", - "request-node-type", - "health-diagnostic-code" -}) -public class RequestHealthDiagnostic implements Serializable -{ - - @JsonProperty("request-client-name") - private String requestClientName; - @JsonProperty("request-node-name") - private String requestNodeName; - @JsonProperty("request-node-ip") - private String requestNodeIp; - @JsonProperty("request-id") - private String requestId; - @JsonProperty("request-user-id") - private String requestUserId; - @JsonProperty("request-node-type") - private String requestNodeType; - @JsonProperty("health-diagnostic-code") - private String healthDiagnosticCode; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private final static long serialVersionUID = 1166788526178388021L; - - @JsonProperty("request-client-name") - public String getRequestClientName() { - return requestClientName; - } - - @JsonProperty("request-client-name") - public void setRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - } - - public RequestHealthDiagnostic withRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - return this; - } - - @JsonProperty("request-node-name") - public String getRequestNodeName() { - return requestNodeName; - } - - @JsonProperty("request-node-name") - public void setRequestNodeName(String requestNodeName) { - this.requestNodeName = requestNodeName; - } - - public RequestHealthDiagnostic withRequestNodeName(String requestNodeName) { - this.requestNodeName = requestNodeName; - return this; - } - - @JsonProperty("request-node-ip") - public String getRequestNodeIp() { - return requestNodeIp; - } - - @JsonProperty("request-node-ip") - public void setRequestNodeIp(String requestNodeIp) { - this.requestNodeIp = requestNodeIp; - } - - public RequestHealthDiagnostic withRequestNodeIp(String requestNodeIp) { - this.requestNodeIp = requestNodeIp; - return this; - } - - @JsonProperty("request-id") - public String getRequestId() { - return requestId; - } - - @JsonProperty("request-id") - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public RequestHealthDiagnostic withRequestId(String requestId) { - this.requestId = requestId; - return this; - } - - @JsonProperty("request-user-id") - public String getRequestUserId() { - return requestUserId; - } - - @JsonProperty("request-user-id") - public void setRequestUserId(String requestUserId) { - this.requestUserId = requestUserId; - } - - public RequestHealthDiagnostic withRequestUserId(String requestUserId) { - this.requestUserId = requestUserId; - return this; - } - - @JsonProperty("request-node-type") - public String getRequestNodeType() { - return requestNodeType; - } - - @JsonProperty("request-node-type") - public void setRequestNodeType(String requestNodeType) { - this.requestNodeType = requestNodeType; - } - - public RequestHealthDiagnostic withRequestNodeType(String requestNodeType) { - this.requestNodeType = requestNodeType; - return this; - } - - @JsonProperty("health-diagnostic-code") - public String getHealthDiagnosticCode() { - return healthDiagnosticCode; - } - - @JsonProperty("health-diagnostic-code") - public void setHealthDiagnosticCode(String healthDiagnosticCode) { - this.healthDiagnosticCode = healthDiagnosticCode; - } - - public RequestHealthDiagnostic withHealthDiagnosticCode(String healthDiagnosticCode) { - this.healthDiagnosticCode = healthDiagnosticCode; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } - - public RequestHealthDiagnostic withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java b/common/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java deleted file mode 100644 index 1fdc9b2484..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno.beans; - -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({ -"client-name", -"code", -"processing-host", -"request-id", -"status" -}) -public class ResultInfo { - -@JsonProperty("client-name") -private String clientName; -@JsonProperty("code") -private String code; -@JsonProperty("processing-host") -private String processingHost; -@JsonProperty("request-id") -private String requestId; -@JsonProperty("status") -private String status; -@JsonIgnore -private Map additionalProperties = new HashMap<>(); - -@JsonProperty("client-name") -public String getClientName() { -return clientName; -} - -@JsonProperty("client-name") -public void setClientName(String clientName) { -this.clientName = clientName; -} - -@JsonProperty("code") -public String getCode() { -return code; -} - -@JsonProperty("code") -public void setCode(String code) { -this.code = code; -} - -@JsonProperty("processing-host") -public String getProcessingHost() { -return processingHost; -} - -@JsonProperty("processing-host") -public void setProcessingHost(String processingHost) { -this.processingHost = processingHost; -} - -@JsonProperty("request-id") -public String getRequestId() { -return requestId; -} - -@JsonProperty("request-id") -public void setRequestId(String requestId) { -this.requestId = requestId; -} - -@JsonProperty("status") -public String getStatus() { -return status; -} - -@JsonProperty("status") -public void setStatus(String status) { -this.status = status; -} - -@JsonAnyGetter -public Map getAdditionalProperties() { -return this.additionalProperties; -} - -@JsonAnySetter -public void setAdditionalProperty(String name, Object value) { -this.additionalProperties.put(name, value); -} - -public void setAdditionalProperties(Map map) { -this.additionalProperties = map; -} -} diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java b/common/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java deleted file mode 100644 index fa3a26a9ef..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno.beans; - -import java.io.Serializable; -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({ - "operation", - "nodeLoc", - "nodeType", - "body" -}) -public class SDNO implements Serializable -{ - - @JsonProperty("operation") - private String operation; - @JsonProperty("nodeLoc") - private String nodeLoc; - @JsonProperty("nodeType") - private String nodeType; - @JsonProperty("body") - private Body body; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private final static long serialVersionUID = -5303297382564282650L; - - @JsonProperty("operation") - public String getOperation() { - return operation; - } - - @JsonProperty("operation") - public void setOperation(String operation) { - this.operation = operation; - } - - @JsonProperty("nodeLoc") - public String getNodeLoc() { - return nodeLoc; - } - - @JsonProperty("nodeLoc") - public void setNodeLoc(String nodeLoc) { - this.nodeLoc = nodeLoc; - } - - public SDNO withNodeLoc(String nodeLoc) { - this.nodeLoc = nodeLoc; - return this; - } - - public SDNO withOperation(String operation) { - this.operation = operation; - return this; - } - - @JsonProperty("nodeType") - public String getNodeType() { - return nodeType; - } - - @JsonProperty("nodeType") - public void setNodeType(String nodeType) { - this.nodeType = nodeType; - } - - public SDNO withNodeType(String nodeType) { - this.nodeType = nodeType; - return this; - } - - @JsonProperty("body") - public Body getBody() { - return body; - } - - @JsonProperty("body") - public void setBody(Body body) { - this.body = body; - } - - public SDNO withBody(Body body) { - this.body = body; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } - - public SDNO SDNO (String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java b/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java deleted file mode 100644 index ca5888caca..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java +++ /dev/null @@ -1,159 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno.dmaap; - -import java.io.IOException; -import java.util.Optional; -import org.openecomp.mso.client.dmaap.DmaapConsumer; -import org.openecomp.mso.client.exceptions.SDNOException; -import org.openecomp.mso.jsonpath.JsonPathUtil; - -public class SDNOHealthCheckDmaapConsumer extends DmaapConsumer { - - private final String uuid; - private boolean continuePolling = true; - private final static String healthDiagnosticPath = "body.output.*"; - - public SDNOHealthCheckDmaapConsumer() throws IOException { - this("none"); - } - - public SDNOHealthCheckDmaapConsumer(String uuid) throws IOException { - super(); - this.uuid = uuid; - } - - @Override - public String getUserName() { - return msoProperties.get("sdno.health-check.dmaap.username"); - } - - @Override - public String getPassword() { - return msoProperties.get("sdno.health-check.dmaap.password"); - } - - @Override - public String getTopic() { - return msoProperties.get("sdno.health-check.dmaap.subscriber.topic"); - } - - @Override - public Optional getHost() { - return Optional.ofNullable(msoProperties.get("sdno.health-check.dmaap.subscriber.host")); - } - - @Override - public boolean continuePolling() { - return continuePolling; - } - - @Override - public void stopProcessingMessages() { - continuePolling = false; - } - @Override - public void processMessage(String message) throws Exception { - if (isHealthDiagnostic(message, this.getRequestId())) { - if (!healthDiagnosticSuccessful(message)) { - Optional statusMessage = this.getStatusMessage(message); - if (statusMessage.isPresent()) { - throw new SDNOException("failed with message " + statusMessage.get()); - } else { - throw new SDNOException("failed with no status message"); - } - } else { - auditLogger.info("successful health diagnostic found for request: " + this.getRequestId()); - stopProcessingMessages(); - } - } - } - - @Override - public boolean isAccepted(String message) { - if (isResultInfo(message)) { - Optional code = isAccepted(message, this.getRequestId()); - if (code.isPresent()) { - if ("202".equals(code.get())) { - return true; - } else { - //TODO check other statuses 400 and 500 - } - } else { - //TODO throw error - } - } - - return false; - } - - @Override - public boolean isFailure(String message) { - if (isResultInfo(message)) { - Optional code = isFailure(message, this.getRequestId()); - if (code.isPresent()) { - if ("500".equals(code.get())) { - return true; - } else { - //TODO check other statuses 400 and 500 - } - } else { - //TODO throw error - } - } - - return false; - } - - @Override - public String getRequestId() { - return uuid; - } - - protected Optional isAccepted(String json, String uuid) { - return JsonPathUtil.getInstance().locateResult(json, String.format("$.result-info[?(@.status=='ACCEPTED' && @.request-id=='%s')].code", uuid)); - } - - protected Optional isFailure(String json, String uuid) { - return JsonPathUtil.getInstance().locateResult(json, String.format("$.result-info[?(@.status=='FAILURE' && @.request-id=='%s')].code", uuid)); - } - - protected boolean isResultInfo(String json) { - return JsonPathUtil.getInstance().pathExists(json, "$[?(@.result-info)]"); - } - - protected boolean isHealthDiagnostic(String json, String uuid) { - return JsonPathUtil.getInstance().pathExists(json, String.format("$[?(@.result-info.request-id=='%s')].%s", uuid, healthDiagnosticPath)); - } - - protected boolean healthDiagnosticSuccessful(String json) { - return JsonPathUtil.getInstance().pathExists(json, "$." + healthDiagnosticPath + "[?(@.response-status=='Success')]"); - } - - protected Optional getStatusMessage(String json) { - return JsonPathUtil.getInstance().locateResult(json, "$." + healthDiagnosticPath + ".error-message"); - } - - @Override - public int getMaximumElapsedTime() { - return 300000; - } -} diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java b/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java deleted file mode 100644 index ef19bb7921..0000000000 --- a/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno.dmaap; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Optional; - -import org.openecomp.mso.client.dmaap.DmaapPublisher; - -public class SDNOHealthCheckDmaapPublisher extends DmaapPublisher { - - public SDNOHealthCheckDmaapPublisher() throws FileNotFoundException, IOException { - super(); - } - - @Override - public String getUserName() { - return msoProperties.get("sdno.health-check.dmaap.username"); - } - - @Override - public String getPassword() { - return msoProperties.get("sdno.health-check.dmaap.password"); - } - - @Override - public String getTopic() { - return msoProperties.get("sdno.health-check.dmaap.publisher.topic"); - } - - @Override - public Optional getHost() { - return Optional.ofNullable(msoProperties.get("sdno.health-check.dmaap.publisher.host")); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/db/AbstractSessionFactoryManager.java b/common/src/main/java/org/openecomp/mso/db/AbstractSessionFactoryManager.java deleted file mode 100644 index 2988e30254..0000000000 --- a/common/src/main/java/org/openecomp/mso/db/AbstractSessionFactoryManager.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.db; - -import org.hibernate.cfg.Configuration; -import org.hibernate.SessionFactory; -import org.hibernate.service.ServiceRegistry; -import org.openecomp.mso.properties.MsoDatabaseException; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import java.net.URL; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -public abstract class AbstractSessionFactoryManager { - - protected static Map sessionFactories = new ConcurrentHashMap<>(); - - protected synchronized SessionFactory initializeSessionFactory(URL hibernateConfigFile) - throws MsoDatabaseException { - try { - if (hibernateConfigFile != null) { - SessionFactory tempFactory = sessionFactories.get(hibernateConfigFile.getPath()); - // Already initialized, skip - if (tempFactory != null) { - return tempFactory; - } - - Configuration conf = new Configuration().configure(hibernateConfigFile); - ServiceRegistry sr = new StandardServiceRegistryBuilder().applySettings(conf.getProperties()).build(); - tempFactory = conf.buildSessionFactory(sr); - if (tempFactory == null) { - throw new MsoDatabaseException( - "SessionFactory can't be initialized, method buildSessionFactory returned null !"); - } - sessionFactories.put(hibernateConfigFile.getPath(), tempFactory); - return tempFactory; - } else { - throw new MsoDatabaseException( - "HibernateConfigFile provided is null, therefore Hibernate can't be initialized !"); - } - } catch (Exception e) { - throw new MsoDatabaseException("Exception occurred during the SessionFactory Build", e); - } - } - - public SessionFactory getSessionFactory() throws MsoDatabaseException { - URL hibernateConfigFile = getHibernateConfigFile(); - SessionFactory factory = sessionFactories.get(hibernateConfigFile.getPath()); - if (factory == null) { - factory = initializeSessionFactory(hibernateConfigFile); - } - return factory; - } - - protected abstract URL getHibernateConfigFile(); -} diff --git a/common/src/main/java/org/openecomp/mso/entity/MsoRequest.java b/common/src/main/java/org/openecomp/mso/entity/MsoRequest.java deleted file mode 100644 index 39ba8dc175..0000000000 --- a/common/src/main/java/org/openecomp/mso/entity/MsoRequest.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.entity; - - - -/** - * This simple bean holds tracking information for MSO requests within - * the adapters. This tracking information should be added to logs, - * metrics, alarms as appropriate. - * - * - */ -public class MsoRequest -{ - private String requestId; - private String serviceInstanceId; - - public MsoRequest() { - this.requestId = null; - this.serviceInstanceId = null; - } - public MsoRequest(String r, String s) { - this.requestId = r; - this.serviceInstanceId = s; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getServiceInstanceId() { - return serviceInstanceId; - } - - public void setServiceInstanceId(String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - } -} diff --git a/common/src/main/java/org/openecomp/mso/entity/package-info.java b/common/src/main/java/org/openecomp/mso/entity/package-info.java deleted file mode 100644 index bf7201c15d..0000000000 --- a/common/src/main/java/org/openecomp/mso/entity/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -/** - * Entities used for logging. - */ - -package org.openecomp.mso.entity; - diff --git a/common/src/main/java/org/openecomp/mso/jsonpath/JsonPathUtil.java b/common/src/main/java/org/openecomp/mso/jsonpath/JsonPathUtil.java deleted file mode 100644 index 148eb74068..0000000000 --- a/common/src/main/java/org/openecomp/mso/jsonpath/JsonPathUtil.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.jsonpath; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.jayway.jsonpath.Configuration; -import com.jayway.jsonpath.JsonPath; -import com.jayway.jsonpath.Option; -import com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider; - -public class JsonPathUtil { - - - private final Configuration conf; - - private JsonPathUtil() { - conf = Configuration.defaultConfiguration().jsonProvider(new JacksonJsonNodeJsonProvider()).addOptions(Option.ALWAYS_RETURN_LIST, Option.SUPPRESS_EXCEPTIONS); - } - - private static class Helper { - private static final JsonPathUtil INSTANCE = new JsonPathUtil(); - } - - public static JsonPathUtil getInstance() { - return Helper.INSTANCE; - } - public boolean pathExists(String json, String jsonPath) { - return JsonPath.using(conf).parse(json).read(jsonPath).size() != 0; - } - - public Optional locateResult(String json, String jsonPath) { - final ArrayNode result = JsonPath.using(conf).parse(json).read(jsonPath); - if (result.size() == 0) { - return Optional.empty(); - } else { - if (result.get(0).isValueNode()) { - return Optional.of(result.get(0).asText()); - } else { - return Optional.of(result.get(0).toString()); - } - - } - } - - public List locateResultList(String json, String jsonPath) { - final ArrayNode resultNodes = JsonPath.using(conf).parse(json).read(jsonPath); - final ArrayList result = new ArrayList<>(); - - for (JsonNode node : resultNodes) { - if (node.isValueNode()) { - result.add(node.asText()); - } else { - result.add(node.toString()); - } - - } - return result; - } -} diff --git a/common/src/main/java/org/openecomp/mso/logger/LogFilter.java b/common/src/main/java/org/openecomp/mso/logger/LogFilter.java deleted file mode 100644 index d799b47e15..0000000000 --- a/common/src/main/java/org/openecomp/mso/logger/LogFilter.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.logger; - - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.slf4j.MDC; - -import java.io.IOException; -import java.security.Principal; - -public class LogFilter implements Filter { - @Override - public void destroy() { - // Nothing to do. - } - - @Override - public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { - final HttpServletRequest httpRequest = (HttpServletRequest) request; - final HttpServletResponse httpResponse = (HttpServletResponse) response; - - MDC.clear (); - MDC.put (MsoLogger.REMOTE_HOST, httpRequest.getRemoteAddr()); - - Principal userPrincipal = httpRequest.getUserPrincipal(); - if (null != userPrincipal) { - MDC.put (MsoLogger.PARTNERNAME, userPrincipal.getName ()); - } - //Set identity of calling application / component - String fromAppId = httpRequest.getHeader(MsoLogger.HEADER_FROM_APP_ID); - if(fromAppId != null && !fromAppId.isEmpty()) { - MDC.put (MsoLogger.FROM_APP_ID, fromAppId); - } - chain.doFilter(httpRequest, httpResponse); - } - - @Override - public void init(final FilterConfig config) throws ServletException { - // Nothing to do - } -} diff --git a/common/src/main/java/org/openecomp/mso/logger/MessageEnum.java b/common/src/main/java/org/openecomp/mso/logger/MessageEnum.java deleted file mode 100644 index 419bbf8ca6..0000000000 --- a/common/src/main/java/org/openecomp/mso/logger/MessageEnum.java +++ /dev/null @@ -1,233 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.logger; - - -import com.att.eelf.i18n.EELFResolvableErrorEnum; -import com.att.eelf.i18n.EELFResourceManager; - -public enum MessageEnum implements EELFResolvableErrorEnum{ - // Api Handler Messages - APIH_REQUEST_NULL, - APIH_QUERY_FOUND, - APIH_QUERY_NOT_FOUND, - APIH_QUERY_PARAM_WRONG, - APIH_DB_ACCESS_EXC, - APIH_DB_ACCESS_EXC_REASON, - APIH_VALIDATION_ERROR, - APIH_REQUEST_VALIDATION_ERROR, - APIH_SERVICE_VALIDATION_ERROR, - APIH_GENERAL_EXCEPTION_ARG, - APIH_GENERAL_EXCEPTION, - APIH_GENERAL_WARNING, - APIH_AUDIT_EXEC, - APIH_GENERAL_METRICS, - APIH_DUPLICATE_CHECK_EXC, - APIH_DUPLICATE_FOUND, - APIH_BAD_ORDER, - APIH_DB_ATTRIBUTE_NOT_FOUND, - APIH_BPEL_COMMUNICATE_ERROR, - APIH_BPEL_RESPONSE_ERROR, - APIH_WARP_REQUEST, - APIH_ERROR_FROM_BPEL_SERVER, - APIH_DB_INSERT_EXC, - APIH_DB_UPDATE_EXC, - APIH_NO_PROPERTIES, - APIH_PROPERTY_LOAD_SUC, - APIH_LOAD_PROPERTIES_FAIL, - APIH_SDNC_COMMUNICATE_ERROR, - APIH_SDNC_RESPONSE_ERROR, - APIH_CANNOT_READ_SCHEMA, - APIH_HEALTH_CHECK_EXCEPTION, - APIH_REQUEST_VALIDATION_ERROR_REASON, - APIH_JAXB_MARSH_ERROR, - APIH_JAXB_UNMARSH_ERROR, - APIH_VNFREQUEST_VALIDATION_ERROR, - APIH_DOM2STR_ERROR, - APIH_READ_VNFOUTPUT_CLOB_EXCEPTION, - APIH_DUPLICATE_CHECK_EXC_ATT, - APIH_GENERATED_REQUEST_ID, - APIH_GENERATED_SERVICE_INSTANCE_ID, - APIH_REPLACE_REQUEST_ID, - // Resource Adapter Messages - RA_GENERAL_EXCEPTION_ARG, - RA_GENERAL_EXCEPTION, - RA_GENERAL_WARNING, - RA_MISSING_PARAM, - RA_AUDIT_EXEC, - RA_GENERAL_METRICS, - RA_CREATE_STACK_TIMEOUT, - RA_DELETE_STACK_TIMEOUT, - RA_UPDATE_STACK_TIMEOUT, - RA_CONNECTION_EXCEPTION, - RA_PARSING_ERROR, - RA_PROPERTIES_NOT_FOUND, - RA_LOAD_PROPERTIES_SUC, - RA_NETWORK_ALREADY_EXIST, - RA_UPDATE_NETWORK_ERR, - RA_CREATE_STACK_ERR, - RA_UPDATE_STACK_ERR, - RA_CREATE_TENANT_ERR, - RA_NETWORK_NOT_FOUND, - RA_NETWORK_ORCHE_MODE_NOT_SUPPORT, - RA_CREATE_NETWORK_EXC, - RA_NS_EXC, - RA_PARAM_NOT_FOUND, - RA_CONFIG_EXC, - RA_UNKOWN_PARAM, - RA_VLAN_PARSE, - RA_DELETE_NETWORK_EXC, - RA_ROLLBACK_NULL, - RA_TENANT_NOT_FOUND, - RA_QUERY_NETWORK_EXC, - RA_CREATE_NETWORK_NOTIF_EXC, - RA_ASYNC_ROLLBACK, - RA_WSDL_NOT_FOUND, - RA_WSDL_URL_CONVENTION_EXC, - RA_INIT_NOTIF_EXC, - RA_SET_CALLBACK_AUTH_EXC, - RA_FAULT_INFO_EXC, - RA_MARSHING_ERROR, - RA_PARSING_REQUEST_ERROR, - RA_SEND_REQUEST_SDNC, - RA_RESPONSE_FROM_SDNC, - RA_EXCEPTION_COMMUNICATE_SDNC, - RA_EVALUATE_XPATH_ERROR, - RA_ANALYZE_ERROR_EXC, - RA_ERROR_GET_RESPONSE_SDNC, - RA_CALLBACK_BPEL, - RA_INIT_CALLBACK_WSDL_ERR, - RA_CALLBACK_BPEL_EXC, - RA_CALLBACK_BPEL_COMPLETE, - RA_SDNC_MISS_CONFIG_PARAM, - RA_SDNC_INVALID_CONFIG, - RA_PRINT_URL, - RA_ERROR_CREATE_SDNC_REQUEST, - RA_ERROR_CREATE_SDNC_RESPONSE, - RA_ERROR_CONVERT_XML2STR, - RA_RECEIVE_SDNC_NOTIF, - RA_INIT_SDNC_ADAPTER, - RA_SEND_REQUEST_APPC_ERR, - RA_SEND_REQUEST_SDNC_ERR, - RA_RECEIVE_BPEL_REQUEST, - RA_TENANT_ALREADY_EXIST, - RA_UPDATE_TENANT_ERR, - RA_DELETE_TEMAMT_ERR, - RA_ROLLBACK_TENANT_ERR, - RA_QUERY_VNF_ERR, - RA_VNF_ALREADY_EXIST, - RA_VNF_UNKNOWN_PARAM, - RA_VNF_EXTRA_PARAM, - RA_CREATE_VNF_ERR, - RA_VNF_NOT_EXIST, - RA_UPDATE_VNF_ERR, - RA_DELETE_VNF_ERR, - RA_ASYNC_CREATE_VNF, - RA_SEND_VNF_NOTIF_ERR, - RA_ASYNC_CREATE_VNF_COMPLETE, - RA_ASYNC_UPDATE_VNF, - RA_ASYNC_UPDATE_VNF_COMPLETE, - RA_ASYNC_QUERY_VNF, - RA_ASYNC_QUERY_VNF_COMPLETE, - RA_ASYNC_DELETE_VNF, - RA_ASYNC_DELETE_VNF_COMPLETE, - RA_ASYNC_ROLLBACK_VNF, - RA_ASYNC_ROLLBACK_VNF_COMPLETE, - RA_ROLLBACK_VNF_ERR, - RA_DB_INVALID_STATUS, - RA_CANT_UPDATE_REQUEST, - RA_DB_REQUEST_NOT_EXIST, - RA_CONFIG_NOT_FOUND, - RA_CONFIG_LOAD, - RA_RECEIVE_WORKFLOW_MESSAGE, - // BPEL engine Messages - BPMN_GENERAL_INFO, - BPMN_GENERAL_EXCEPTION_ARG, - BPMN_GENERAL_EXCEPTION, - BPMN_GENERAL_WARNING, - BPMN_AUDIT_EXEC, - BPMN_GENERAL_METRICS, - BPMN_URN_MAPPING_FAIL, - BPMN_VARIABLE_NULL, - BPMN_CALLBACK_EXCEPTION, - // ASDC Messages - ASDC_GENERAL_EXCEPTION_ARG, - ASDC_GENERAL_EXCEPTION, - ASDC_GENERAL_WARNING, - ASDC_GENERAL_INFO, - ASDC_AUDIT_EXEC, - ASDC_GENERAL_METRICS, - ASDC_CREATE_SERVICE, - ASDC_ARTIFACT_ALREADY_DEPLOYED, - ASDC_CREATE_ARTIFACT, - ASDC_ARTIFACT_INSTALL_EXC, - ASDC_ARTIFACT_ALREADY_DEPLOYED_DETAIL, - ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL, - ASDC_ARTIFACT_CHECK_EXC, - ASDC_INIT_ASDC_CLIENT_EXC, - ASDC_INIT_ASDC_CLIENT_SUC, - ASDC_LOAD_ASDC_CLIENT_EXC, - ASDC_SINGLETON_CHECKT_EXC, - ASDC_SHUTDOWN_ASDC_CLIENT_EXC, - ASDC_CHECK_HEAT_TEMPLATE, - ASDC_START_INSTALL_ARTIFACT, - ASDC_ARTIFACT_TYPE_NOT_SUPPORT, - ASDC_ARTIFACT_ALREADY_EXIST, - ASDC_ARTIFACT_DOWNLOAD_SUC, - ASDC_ARTIFACT_DOWNLOAD_FAIL, - ASDC_START_DEPLOY_ARTIFACT, - ASDC_SEND_NOTIF_ASDC, - ASDC_SEND_NOTIF_ASDC_EXEC, - ASDC_RECEIVE_CALLBACK_NOTIF, - ASDC_RECEIVE_SERVICE_NOTIF, - ASDC_ARTIFACT_NULL, - ASDC_SERVICE_NOT_SUPPORT, - ASDC_ARTIFACT_DEPLOY_SUC, - ASDC_PROPERTIES_NOT_FOUND, - ASDC_PROPERTIES_LOAD_SUCCESS, - // Default Messages, in case Log catalog is not defined - GENERAL_EXCEPTION_ARG, - GENERAL_EXCEPTION, - GENERAL_WARNING, - AUDIT_EXEC, - GENERAL_METRICS, - LOGGER_SETUP, - LOGGER_NOT_FOUND, - LOGGER_UPDATE_SUC, - LOGGER_UPDATE_DEBUG, - LOGGER_UPDATE_DEBUG_SUC, - LOAD_PROPERTIES_SUC, - NO_PROPERTIES, - MADATORY_PARAM_MISSING, - LOAD_PROPERTIES_FAIL, - INIT_LOGGER, - INIT_LOGGER_FAIL, - JAXB_EXCEPTION, - IDENTITY_SERVICE_NOT_FOUND; - - static { - EELFResourceManager.loadMessageBundle("GenericMessages"); - EELFResourceManager.loadMessageBundle("ApiHandler"); - EELFResourceManager.loadMessageBundle("BPMN"); - EELFResourceManager.loadMessageBundle("ResourceAdapter"); - EELFResourceManager.loadMessageBundle("ASDC"); - } -} diff --git a/common/src/main/java/org/openecomp/mso/logger/MsoAlarmLogger.java b/common/src/main/java/org/openecomp/mso/logger/MsoAlarmLogger.java deleted file mode 100644 index b2b8d0aa33..0000000000 --- a/common/src/main/java/org/openecomp/mso/logger/MsoAlarmLogger.java +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.logger; - - -import java.io.File; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; - -import org.slf4j.LoggerFactory; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.encoder.PatternLayoutEncoder; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.rolling.RollingFileAppender; -import ch.qos.logback.core.rolling.TimeBasedRollingPolicy; - -/** - * Wrapper around log4j and Nagios NRDP passive alarming for MSO. - * - * For local alarm logging, this class will look for an alarm log file name - * in the servlet context parameter "mso.alarms.file". If none is found, - * it will look for an MsoProperty of the same name. As a last resort, - * it will use the default path "/var/log/ecomp/MSO/alarms/alarm.log". - * It is expected that all alarms within an application will use the same - * alarm file, so there is no way to dynamically add other alarm files. - * - * Alarms are logged as a simple pipe-delimited string of the format: - * ||| - * - * This class also supports real-time Nagios NRDP alarming. If enabled via - * MsoProperties, all alarms generated and logged to the local alarm file will - * also be transmitted to a Nagios NRDP instance. NRDP requires 4 parameters - * in service alarm events (all Mso Alarms will be Service Alarms): - * hostname, servicename, state, detail - * - * The log file format is also intended to be compatible with Nagios NRDP for - * non-real-time reporting. The command-line tool for sending alarms is - * is "send_nrdp.php", which takes the same 4 parameters as input. - * It will be easy enough to translate entries from an alarm.log file to - * NRDP if real-time NRDP alarming is not enabled. - * - * For Nagios integration, the alarmTypes should all match "service names" - * configured in the receiving Nagios server. Also, the alarm state will - * be limited to the 4 values defined by Nagios: - * 0 = OK, 1 = Warning, 2 = Critical, 3 = Unknown - * - * - */ -public class MsoAlarmLogger implements ServletContextListener { - - private Logger alarmLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(MSO_ALARM_CONTEXT); - private static RollingFileAppender fileAppender = null; - public static final String DEFAULT_MSO_ALARM_FILE = "/var/log/ecomp/MSO/alarms/alarm.log"; - public static final String MSO_ALARM_CONTEXT = "mso.alarms"; - - public static final int OK = 0; - public static final int WARNING = 1; - public static final int CRITICAL = 2; - public static final int UNKNOWN = 3; - - /** - * Get the default MSO Alarm Logger - */ - public MsoAlarmLogger () { - - initializeAlarmLogger(null); - - } - - public MsoAlarmLogger (String alarmFile) { - initializeAlarmLogger(alarmFile); - - } - - /** - * Method to record an alarm. - * - * @param alarm - the alarm identifier (Nagios "service") - * @param state - the alarm state/severity, based on Nagios service - * state values: 0 = OK, 1 = Warning, 2 = Critical, 3 = Unknown - * @param detail - detail message (may contain additional internal - * structure per alarm type) - */ - public void sendAlarm (String alarm, int state, String detail) { - // Write the alarm to Log file - if (alarmLogger != null) { - String output = alarm + "|" + state + "|" + detail; - alarmLogger.info (output); - } - - } - - @Override - public void contextDestroyed (ServletContextEvent event) { - // Nothing to do... - } - - @Override - public void contextInitialized (ServletContextEvent event) { - String msoAlarmFile = event.getServletContext ().getInitParameter ("mso.alarm.file"); - if (msoAlarmFile == null) { - msoAlarmFile = DEFAULT_MSO_ALARM_FILE; - } - - initializeAlarmLogger (msoAlarmFile); - } - - private void initializeAlarmLogger (String alarmFile) { - synchronized (MsoAlarmLogger.class) { - if (fileAppender == null) { - if (alarmFile != null) { - fileAppender = MsoAlarmLogger.getAppender (alarmFile); - } else { - fileAppender = MsoAlarmLogger.getAppender (DEFAULT_MSO_ALARM_FILE); - } - } - } - // The alarmLogger was static originally. - // The initialization of the alarmLogger was fine, but not sure why, it lost its appender info later - // Due to that issue, the alarmLogger is not static any more. - // Instead static attribute fileAppender is added and will be assigned to the alarmLogger every time new MsoAlarmLogger is created. - alarmLogger.setLevel (Level.INFO); - alarmLogger.addAppender (fileAppender); - alarmLogger.setAdditive (false); - } - - - private static RollingFileAppender getAppender (String msoAlarmFile) { - // Create a Logger for alarms. Just use a default Pattern that outputs - // a message. MsoAlarmLogger will handle the formatting. - File alarmFile = new File (msoAlarmFile); - File alarmDir = alarmFile.getParentFile (); - if (!alarmDir.exists ()) { - alarmDir.mkdirs (); - } - - String logPattern = "%d{yyyy-MM-dd HH:mm:ss}|%m%n"; - - LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); - PatternLayoutEncoder encoder=new PatternLayoutEncoder(); - encoder.setPattern(logPattern); - encoder.setContext(context); - encoder.start(); - RollingFileAppender fileAppender= new RollingFileAppender<>(); - TimeBasedRollingPolicy rollingPolicy= new TimeBasedRollingPolicy<>(); - rollingPolicy.setContext(context); - rollingPolicy.setFileNamePattern(msoAlarmFile + ".%d"); - rollingPolicy.setParent(fileAppender); - rollingPolicy.start(); - fileAppender.setFile(msoAlarmFile); - fileAppender.setAppend(true); - fileAppender.setEncoder(encoder); - fileAppender.setRollingPolicy(rollingPolicy); - fileAppender.setContext(context); - fileAppender.start(); - - return fileAppender; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/logger/MsoLogInitializer.java b/common/src/main/java/org/openecomp/mso/logger/MsoLogInitializer.java deleted file mode 100644 index 6ed2786f35..0000000000 --- a/common/src/main/java/org/openecomp/mso/logger/MsoLogInitializer.java +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.logger; - - -import java.io.File; - -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; -import javax.servlet.annotation.WebListener; - -import org.slf4j.LoggerFactory; - -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.joran.JoranConfigurator; - - -/** - * This class will attempt to initialize MSO log4j when part of a web application. - * It will look for the logback configuration file logback.xml in the - * following order: - * 1. In an init-param "log.configuration" in web.xml - * 2. TODO: In a property "log.configuration" in an "application.properties" file - * 3. In the default location "/etc/ecomp/mso/config" - * 4. Using the log4j default (check system property log.configuration or - * just look on the classpath for logback.xml) - * - * - */ -@WebListener -public class MsoLogInitializer implements ServletContextListener -{ - private static String DEFAULT_LOG4J_PROPERTIES_FILE = "/etc/ecomp/mso/config/logback.xml"; - private static String prefixMsoPropertiesPath = System.getProperty("mso.config.path"); - static { - if (prefixMsoPropertiesPath == null) { - prefixMsoPropertiesPath = "/"; - } else if (!(prefixMsoPropertiesPath.charAt(prefixMsoPropertiesPath.length() - 1) == '/')) { - prefixMsoPropertiesPath = prefixMsoPropertiesPath + "/"; - } - } - - public MsoLogInitializer () { - } - - - @Override - public void contextDestroyed(ServletContextEvent event) { - // Nothing to do... - } - - @Override - public void contextInitialized(ServletContextEvent event) - { - String logPropertiesFile = null; - try { - // Look first in the init-parameters - String initParam = event.getServletContext().getInitParameter("log.configuration"); - if (initParam != null && fileIsReadable(prefixMsoPropertiesPath + initParam)) { - logPropertiesFile = prefixMsoPropertiesPath + initParam; - } - else if (fileIsReadable(DEFAULT_LOG4J_PROPERTIES_FILE)) { - logPropertiesFile = DEFAULT_LOG4J_PROPERTIES_FILE; - } - - if (logPropertiesFile != null) { - // Initialize loggers with the specified file. If no such file was - // specified, will use the default Log4j resolution. - LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); - JoranConfigurator jc = new JoranConfigurator(); - jc.setContext(context); - context.reset(); - jc.doConfigure(logPropertiesFile); - // Try it out - MsoLogger initLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - initLogger.info(MessageEnum.INIT_LOGGER, logPropertiesFile, "", ""); - } - } catch (Exception e) { - MsoLogger initLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - initLogger.error (MessageEnum.INIT_LOGGER_FAIL, "", "", MsoLogger.ErrorCode.UnknownError, "", e); - } - } - - private boolean fileIsReadable (String filePath) { - File f = new File(filePath); - if (f.exists() && f.canRead()) - return true; - return false; - } -} diff --git a/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java b/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java deleted file mode 100644 index 9f918805c0..0000000000 --- a/common/src/main/java/org/openecomp/mso/logger/MsoLogger.java +++ /dev/null @@ -1,1164 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.logger; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.UUID; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.slf4j.MDC; - -import org.openecomp.mso.entity.MsoRequest; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.att.eelf.i18n.EELFResolvableErrorEnum; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * Simple wrapper around the EELF Logger class for MSO usage. This class - * supports all of the normal logging functions (debug, info, etc.), prepending - * a string of format "[|) value to it - String serName = MDC.get(MsoLogger.SERVICE_NAME); - - // Check if service name was already set as the method name by a - // previous call to this method. - String isMethodNameStr = MDC.get(MsoLogger.SERVICE_NAME_IS_METHOD_NAME); - boolean isMethodName = isMethodNameStr != null && isMethodNameStr.equals(Boolean.TRUE.toString()); - if (serviceNamep != null) { - return serviceNamep; - } else if (serName != null && !isMethodName) { - return serName; - } - - MDC.put(MsoLogger.SERVICE_NAME_IS_METHOD_NAME, Boolean.TRUE.toString()); - int limit; - StackTraceElement[] classArr = new Exception().getStackTrace(); - if (classArr.length >= 6) { - limit = 7; - } else { - limit = classArr.length; - } - for (int i = 1; i < limit; i++) { - String className = classArr[i].getClassName(); - if (!className.equals(this.getClass().getName())) { - return classArr[i].getMethodName(); - } - } - return classArr[0].getMethodName(); - } - - // Based on the discussion with Adrian, instanceUUID is used to identifiy - // the mso instance, - // it is generated during mso instance initialization period - // The same mso instnace will use the same instanceUUID value, even after - // restart - private static String getInstanceUUID() { - // Avoid creation during build and tests - if (System.getProperty("jboss.server.name") == null) { - return "Test UUID as JBoss not found"; - } - File configFile = new File(CONFIG_FILE); - String uuid = ""; - BufferedReader in = null; - try{ - // Verify whether instanceUUID file exist, - // If yes, read the content; if not, generate the instanceUUID and - // write to the file - if (configFile.exists()) { - // read the content of the file - in = new BufferedReader(new FileReader(CONFIG_FILE)); - if ((uuid = in.readLine()) == null) { - // the file is empty, regenerate the file - uuid = UUID.randomUUID().toString(); - try(BufferedWriter bw = new BufferedWriter(new FileWriter(configFile.getAbsoluteFile()))) { - bw.write(uuid); - } catch (IOException e) { - LOGGER.log(Level.SEVERE, "Error trying to write UUID file", e); - } - } - in.close(); - } else { - // file doesn't exist yet -> create the file and generate the - // instanceUUID - uuid = UUID.randomUUID().toString(); - configFile.getParentFile().mkdirs(); - configFile.createNewFile(); - try(BufferedWriter bw1 = new BufferedWriter(new FileWriter(configFile.getAbsoluteFile()))){ - bw1.write(uuid); - } catch (IOException e) { - LOGGER.log(Level.SEVERE, "Error trying to write UUID file", e); - } - } - } catch (IOException e) { - LOGGER.log(Level.SEVERE, "Error trying to read UUID file", e); - } finally { - try { - if (in != null) { - in.close(); - } - } catch (IOException ex) { - LOGGER.log(Level.SEVERE, "Error trying to close UUID file", ex); - } - } - return uuid; - } - - /** - * Set the requestId and serviceInstanceId - * - * @param reqId - * The requestId - * @param svcId - * The serviceInstanceId - */ - public static void setLogContext(String reqId, String svcId) { - if (null != reqId) { - MDC.put(REQUEST_ID, reqId); - } - - if (null != svcId) { - MDC.put(SERVICE_INSTANCE_ID, svcId); - } - } - - /** - * Set the remoteIp and the basic HTTP Authentication user - * - * @param remoteIpp - * The remote ip address - * @param userp - * The basic http authencitation user - */ - public static void setLoggerParameters(String remoteIpp, String userp) { - if (null != remoteIpp) { - MDC.put(REMOTE_HOST, remoteIpp); - } - if (null != userp) { - MDC.put(USER, userp); - } - } - - /** - * Set the serviceName - * - * @param serviceNamep - * The service name - */ - public static void setServiceName(String serviceNamep) { - if (null != serviceNamep) { - MDC.put(SERVICE_NAME, serviceNamep); - MDC.remove(SERVICE_NAME_IS_METHOD_NAME); - } - } - - /** - * Get the serviceName - * - * @return The service name - */ - public static String getServiceName() { - return MDC.get(SERVICE_NAME); - } - - /** - * Reset the serviceName - */ - public static void resetServiceName() { - MDC.remove(SERVICE_NAME); - } - - /** - * Set the requestId and serviceInstanceId based on the mso request - * - * @param msoRequest - * The mso request - */ - public static void setLogContext(MsoRequest msoRequest) { - if (msoRequest != null) { - MDC.put(REQUEST_ID, msoRequest.getRequestId()); - MDC.put(SERVICE_INSTANCE_ID, msoRequest.getServiceInstanceId()); - } else { - MDC.put(REQUEST_ID, DUMMY_VALUE); - MDC.put(SERVICE_INSTANCE_ID, DUMMY_VALUE); - } - } - - private String normalize(String input) { - if (input == null) { - return null; - } - String result = input.replace('|', '!'); - result = result.replace("\n", " - "); - return result; - } - - private String getNormalizedStackTrace(Throwable t) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - t.printStackTrace(pw); - return sw.toString().replace('|', '!').replace("\n", " - "); - } - - private void setDefaultLogCatalog(MsoLogger.Catalog cat) { - if ("APIH".equals(cat.toString())) { - exceptionArg = MessageEnum.APIH_GENERAL_EXCEPTION_ARG; - defaultException = MessageEnum.APIH_GENERAL_EXCEPTION; - defaultWarning = MessageEnum.APIH_GENERAL_WARNING; - defaultAudit = MessageEnum.APIH_AUDIT_EXEC; - defaultMetrics = MessageEnum.APIH_GENERAL_METRICS; - } else if ("RA".equals(cat.toString())) { - exceptionArg = MessageEnum.RA_GENERAL_EXCEPTION_ARG; - defaultException = MessageEnum.RA_GENERAL_EXCEPTION; - defaultWarning = MessageEnum.RA_GENERAL_WARNING; - defaultAudit = MessageEnum.RA_AUDIT_EXEC; - defaultMetrics = MessageEnum.RA_GENERAL_METRICS; - } else if ("BPEL".equals(cat.toString())) { - exceptionArg = MessageEnum.BPMN_GENERAL_EXCEPTION_ARG; - defaultException = MessageEnum.BPMN_GENERAL_EXCEPTION; - defaultWarning = MessageEnum.BPMN_GENERAL_WARNING; - defaultAudit = MessageEnum.BPMN_AUDIT_EXEC; - defaultMetrics = MessageEnum.BPMN_GENERAL_METRICS; - } else if ("ASDC".equals(cat.toString())) { - exceptionArg = MessageEnum.ASDC_GENERAL_EXCEPTION_ARG; - defaultException = MessageEnum.ASDC_GENERAL_EXCEPTION; - defaultWarning = MessageEnum.ASDC_GENERAL_WARNING; - defaultAudit = MessageEnum.ASDC_AUDIT_EXEC; - defaultMetrics = MessageEnum.ASDC_GENERAL_METRICS; - } else { - exceptionArg = MessageEnum.GENERAL_EXCEPTION_ARG; - defaultException = MessageEnum.GENERAL_EXCEPTION; - defaultWarning = MessageEnum.GENERAL_WARNING; - defaultAudit = MessageEnum.AUDIT_EXEC; - defaultMetrics = MessageEnum.GENERAL_METRICS; - } - } -} diff --git a/common/src/main/java/org/openecomp/mso/logger/MsoLoggingServlet.java b/common/src/main/java/org/openecomp/mso/logger/MsoLoggingServlet.java deleted file mode 100644 index dd42efbfda..0000000000 --- a/common/src/main/java/org/openecomp/mso/logger/MsoLoggingServlet.java +++ /dev/null @@ -1,163 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.logger; - - -import java.util.List; - -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; - -import org.slf4j.LoggerFactory; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.joran.JoranConfigurator; -import ch.qos.logback.core.Appender; - -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; - -@Path("/logging") -@Api(value="/logging",description="logging") -public class MsoLoggingServlet { - - private static final String DEBUGLOG = "asyncEELFDebug"; - private MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); - private static final String GENERAL_LOGGER = "com.att.eelf.error"; - private static final String AUDIT_LOGGER = "com.att.eelf.audit"; - private static final String METRICS_LOGGER = "com.att.eelf.metrics"; - - @GET - @Path("/setLevel/{logContext}/{level}") - @Produces("text/plain") - @ApiOperation(value="message print",response=Response.class) - public Response setLogLevel (@PathParam("logContext") String logContext, @PathParam("level") String level) { - logger.info (MessageEnum.LOGGER_SETUP, "", ""); - - LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); - JoranConfigurator jc = new JoranConfigurator(); - jc.setContext(context); - Logger updateLogger = context.getLogger (logContext); - - if (updateLogger == null) { - logger.info (MessageEnum.LOGGER_NOT_FOUND, logContext, "", ""); - String response = "Unknown logger: " + logContext; - return Response.status (200).entity (response).build (); - } - - Level currentLevel = updateLogger.getLevel(); - if (!currentLevel.equals(Level.toLevel(level))) { - Level newLevel = Level.toLevel (level); - updateLogger.setLevel (newLevel); - logger.info (MessageEnum.LOGGER_UPDATE_SUC, updateLogger.getName (), currentLevel.toString(), newLevel.toString()); - } - - String response = "Log level set to: " + level + " for " + updateLogger.getName (); - return Response.status (200).entity (response).build (); - - } - - @GET - @Path("/loggers") - @Produces("text/plain") - @SuppressWarnings("rawtypes") - @ApiOperation(value="message print",response=Response.class) - public Response getLoggers () { - StringBuilder response = new StringBuilder (); - LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); - JoranConfigurator jc = new JoranConfigurator(); - jc.setContext(context); - List loggerList = context.getLoggerList(); - for (Logger logger:loggerList) { - //if (logger.getLevel() != null) { - response.append(logger.getName()).append(":").append(logger.getLevel()).append(" (") - .append(logger.getEffectiveLevel()).append(")\n"); - //} - } - return Response.status (200).entity (response).build (); - - } - - @GET - @Path("/debug") - @Produces("text/plain") - @ApiOperation(value="message print",response=Response.class) - @SuppressWarnings("rawtypes") - /* - * Debug log is used as a general log to store all the logs events, including events generated by MSO code or by - * components used by MSO. - * This method will only enable/disable the function to store MSO generated events into debug log, - * since those events will also be generated to error, audit, metrics log. - * The events generated by other components will not be affected by this interface. - */ - public Response updateDebugAppender (@DefaultValue("true") @QueryParam("enable") Boolean enable) { - String response; - - LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); - JoranConfigurator jc = new JoranConfigurator(); - jc.setContext(context); - List loggerList = context.getLoggerList(); - Logger rootLogger = context.getLogger("ROOT"); - Appender appender = rootLogger.getAppender(DEBUGLOG); - - if (null == appender) { - return Response.status (500).entity ("Not able to found Debug appender. Please verify to make sure the needed logback file is present in the config folder.").build (); - } - - if (enable) { - logger.info (MessageEnum.LOGGER_UPDATE_DEBUG, "", ""); - - for (Logger logger: loggerList) { - if (isMsoLogger (logger.getName ()) && logger.getAppender (DEBUGLOG) == null && logger.getLevel () != null) { - logger.addAppender (appender); - logger.setAdditive(false); - } - } - logger.info (MessageEnum.LOGGER_UPDATE_DEBUG_SUC, "enabled", "", ""); - response = "Debuglog successfully enabled."; - } else { - logger.info (MessageEnum.LOGGER_UPDATE_DEBUG, "", ""); - for (Logger logger: loggerList) { - if (isMsoLogger (logger.getName ())) { - logger.detachAppender (appender); - } - } - logger.info (MessageEnum.LOGGER_UPDATE_DEBUG_SUC, "disabled", "", ""); - response = "Debuglog successfully disabled."; - } - return Response.status (200).entity (response).build (); - - - } - - private boolean isMsoLogger (String loggerName) { - return loggerName.contains (GENERAL_LOGGER) || loggerName.equals (AUDIT_LOGGER) - || loggerName.equals (METRICS_LOGGER); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/CustomSetterMustExistRule.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/CustomSetterMustExistRule.java deleted file mode 100644 index fa24662d69..0000000000 --- a/common/src/main/java/org/openecomp/mso/openpojo/rules/CustomSetterMustExistRule.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.openpojo.rules; - -import static org.hamcrest.CoreMatchers.anyOf; -import static org.hamcrest.CoreMatchers.anything; -import static org.hamcrest.CoreMatchers.not; - -import org.hamcrest.Matcher; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoField; -import com.openpojo.validation.affirm.Affirm; -import com.openpojo.validation.rule.Rule; - -public class CustomSetterMustExistRule implements Rule { - - private Matcher[] excludeMatchers = new Matcher[]{not(anything())}; - private Matcher[] includeMatchers = new Matcher[]{anything()}; - public CustomSetterMustExistRule() { - } - @Override - public void evaluate(final PojoClass pojoClass) { - for (PojoField fieldEntry : pojoClass.getPojoFields()) { - if (!anyOf(excludeMatchers).matches(fieldEntry) && anyOf(includeMatchers).matches(fieldEntry) && !fieldEntry.isFinal() && !fieldEntry.hasSetter()) { - Affirm.fail(String.format("[%s] is missing a setter", fieldEntry)); - } - } - } - public CustomSetterMustExistRule exclude(Matcher... excludeMatchers) { - this.excludeMatchers = excludeMatchers; - return this; - } - - public CustomSetterMustExistRule include(Matcher... includeMatchers) { - this.includeMatchers = includeMatchers; - return this; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/EqualsAndHashCodeTester.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/EqualsAndHashCodeTester.java deleted file mode 100644 index 9540409e16..0000000000 --- a/common/src/main/java/org/openecomp/mso/openpojo/rules/EqualsAndHashCodeTester.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.openpojo.rules; - -import static org.hamcrest.CoreMatchers.anyOf; -import static org.hamcrest.CoreMatchers.anything; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.persistence.Id; - -import org.hamcrest.Matcher; - -import com.openpojo.business.annotation.BusinessKey; -import com.openpojo.random.RandomFactory; -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoField; -import com.openpojo.validation.affirm.Affirm; -import com.openpojo.validation.test.Tester; -import com.openpojo.validation.utils.ValidationHelper; - -public class EqualsAndHashCodeTester implements Tester { - - - private final Matcher m; - private boolean onlyDeclaredMethods = false; - public EqualsAndHashCodeTester() { - m = anything(); - } - - public EqualsAndHashCodeTester(Matcher m) { - this.m = m; - } - - public EqualsAndHashCodeTester onlyDeclaredMethods() { - this.onlyDeclaredMethods = true; - return this; - } - @Override - public void run(PojoClass pojoClass) { - Class clazz = pojoClass.getClazz(); - if (anyOf(m).matches(clazz)) { - final Object classInstanceOne = ValidationHelper.getBasicInstance(pojoClass); - final Object classInstanceTwo = ValidationHelper.getBasicInstance(pojoClass); - if (onlyDeclaredMethods) { - Method[] methods = classInstanceOne.getClass().getDeclaredMethods(); - boolean hasEquals = false; - boolean hasHashcode = false; - for (Method method : methods) { - if (method.getName().equals("equals")) { - hasEquals = true; - } else if (method.getName().equals("hashCode")) { - hasHashcode = true; - } - } - - if (!(hasEquals && hasHashcode)) { - return; - } - } - Set identityFields = hasIdOrBusinessKey(pojoClass); - List otherFields = new ArrayList<>(pojoClass.getPojoFields()); - otherFields.removeAll(identityFields); - - for (PojoField field : identityFields) { - final Object value = RandomFactory.getRandomValue(field); - - field.invokeSetter(classInstanceOne, value); - field.invokeSetter(classInstanceTwo, value); - } - - for (PojoField field : otherFields) { - if (field.hasSetter()) { - final Object valueOne = RandomFactory.getRandomValue(field); - final Object valueTwo = RandomFactory.getRandomValue(field); - - field.invokeSetter(classInstanceOne, valueOne); - field.invokeSetter(classInstanceTwo, valueTwo); - } - } - - Affirm.affirmTrue("Equals test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.equals(classInstanceTwo)); - - Affirm.affirmTrue("Equals test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.equals( - classInstanceOne)); - - Affirm.affirmTrue("HashCode test failed for [" + classInstanceOne.getClass().getName() + "]", classInstanceOne.hashCode() == classInstanceTwo.hashCode()); - - Affirm.affirmFalse("Expected false for comparison of two unlike objects", classInstanceOne.equals("test")); - } - } - - - private Set hasIdOrBusinessKey(PojoClass pojoClass) { - final Set fields = new HashSet<>(); - - fields.addAll(pojoClass.getPojoFieldsAnnotatedWith(BusinessKey.class)); - fields.addAll(pojoClass.getPojoFieldsAnnotatedWith(Id.class)); - - return fields; - - } - -} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationMatcher.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationMatcher.java deleted file mode 100644 index fdfb9695e7..0000000000 --- a/common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationMatcher.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.openpojo.rules; - -import static org.hamcrest.CoreMatchers.anything; - -import java.lang.annotation.Annotation; -import java.lang.reflect.AnnotatedElement; - -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeDiagnosingMatcher; - -public class HasAnnotationMatcher extends TypeSafeDiagnosingMatcher { - private final Class annotationType; - private final Matcher annotationMatcher; - - public HasAnnotationMatcher(final Class annotationType, final Matcher annotationMatcher) { - this.annotationType = annotationType; - this.annotationMatcher = annotationMatcher; - } - - @Override - protected boolean matchesSafely(final AnnotatedElement item, final Description mismatchDescription) { - final T annotation = item.getAnnotation(this.annotationType); - if (annotation == null) { - mismatchDescription.appendText("does not have annotation ").appendText(this.annotationType.getName()); - return false; - } - - if (!this.annotationMatcher.matches(annotation)) { - this.annotationMatcher.describeMismatch(annotation, mismatchDescription); - return false; - } - - return true; - } - - @Override - public void describeTo(final Description description) { - // Intentionally left blank. - } - - public static Matcher hasAnnotation(final Class annotationType) { - return hasAnnotation(annotationType, anything("")); - } - - public static Matcher hasAnnotation(final Class annotationType, final Matcher annotationMatcher) { - return new HasAnnotationMatcher(annotationType, annotationMatcher); - } -} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java deleted file mode 100644 index d1b2fb1d11..0000000000 --- a/common/src/main/java/org/openecomp/mso/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.openpojo.rules; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeDiagnosingMatcher; -import org.openecomp.mso.logger.MsoLogger; - -import com.openpojo.reflection.PojoField; - -public class HasAnnotationPropertyWithValueMatcher extends TypeSafeDiagnosingMatcher { - private MsoLogger logger=MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - private final String attribute; - private final Matcher annotationMatcher; - private final Class annotationClass; - public HasAnnotationPropertyWithValueMatcher(Class clazz, String attribute, final Matcher annotationMatcher) { - this.attribute = attribute; - this.annotationMatcher = annotationMatcher; - this.annotationClass = clazz; - } - - @Override - protected boolean matchesSafely(T obj, final Description mismatchDescription) { - final PojoField temp = (PojoField)obj; - final Method method; - try { - Annotation a = temp.getAnnotation(this.annotationClass); - if (a == null) { - mismatchDescription.appendText("does not have annotation ").appendText(this.annotationClass.getSimpleName()); - return false; - } - method = a.getClass().getMethod(attribute); - final Object result = method.invoke(a); - if (!this.annotationMatcher.matches(result)) { - this.annotationMatcher.describeMismatch(result, mismatchDescription); - return false; - } - } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - mismatchDescription.appendText("does not have property ").appendText(attribute); - logger.debug("Error occured", e); - return false; - } - return true; - } - - @Override - public void describeTo(final Description description) { - // Intentionally left blank. - } - - public static Matcher hasAnnotationPropertyWithValue(Class clazz, String attribute, final Matcher annotationMatcher) { - return new HasAnnotationPropertyWithValueMatcher(clazz, attribute, annotationMatcher); - } -} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/HasEqualsAndHashCodeRule.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/HasEqualsAndHashCodeRule.java deleted file mode 100644 index 4ef560721f..0000000000 --- a/common/src/main/java/org/openecomp/mso/openpojo/rules/HasEqualsAndHashCodeRule.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.openpojo.rules; - -import static org.hamcrest.CoreMatchers.anyOf; -import static org.hamcrest.CoreMatchers.anything; - -import java.lang.reflect.Method; -import java.lang.reflect.Parameter; - -import org.hamcrest.Matcher; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.validation.affirm.Affirm; -import com.openpojo.validation.rule.Rule; - -/** - * This rule ensures that classes have overriden the default equals and hashCode methods from Object - */ -public class HasEqualsAndHashCodeRule implements Rule { - - private final Matcher m; - public HasEqualsAndHashCodeRule() { - m = anything(); - } - - public HasEqualsAndHashCodeRule(Matcher m) { - this.m = m; - } - @Override - public void evaluate(PojoClass pojoClass) { - Class clazz = pojoClass.getClazz(); - if (anyOf(m).matches(clazz)) { - boolean hasEquals = false; - boolean hasHashCode = false; - final String name = clazz.getSimpleName(); - final Method[] methods; - if (clazz.getSuperclass().equals(Object.class)) { - methods = clazz.getDeclaredMethods(); - } else { - methods = clazz.getMethods(); - } - for (Method method : methods) { - Parameter[] parameters = method.getParameters(); - if ("equals".equals(method.getName()) && boolean.class.equals(method.getReturnType()) && parameters.length == 1 && Object.class.equals(parameters[0].getType())) { - hasEquals = true; - } else if ("hashCode".equals(method.getName()) && int.class.equals(method.getReturnType())) { - hasHashCode = true; - } - } - - if (!hasEquals) { - Affirm.fail(String.format( - "[%s] does not override equals", name)); - } - if (!hasHashCode) { - Affirm.fail(String.format( - "[%s] does not override hashCode", name)); - } - } - } - -} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/HasToStringRule.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/HasToStringRule.java deleted file mode 100644 index f866650d66..0000000000 --- a/common/src/main/java/org/openecomp/mso/openpojo/rules/HasToStringRule.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.openpojo.rules; - -import static org.hamcrest.CoreMatchers.anyOf; -import static org.hamcrest.CoreMatchers.anything; - -import java.lang.reflect.Method; -import java.lang.reflect.Parameter; - -import org.hamcrest.Matcher; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.validation.affirm.Affirm; -import com.openpojo.validation.rule.Rule; - -public class HasToStringRule implements Rule { - - private final Matcher m; - public HasToStringRule() { - m = anything(); - } - - public HasToStringRule(Matcher m) { - this.m = m; - } - @Override - public void evaluate(PojoClass pojoClass) { - Class clazz = pojoClass.getClazz(); - if (anyOf(m).matches(clazz)) { - boolean hasToString = false; - final String name = clazz.getSimpleName(); - final Method[] methods; - if (clazz.getSuperclass().equals(Object.class)) { - methods = clazz.getDeclaredMethods(); - } else { - methods = clazz.getMethods(); - } - for (Method method : methods) { - Parameter[] parameters = method.getParameters(); - if ("toString".equals(method.getName()) && String.class.equals(method.getReturnType()) && parameters.length == 0) { - hasToString = true; - break; - } - } - - if (!hasToString) { - Affirm.fail(String.format( - "[%s] does not override toString", name)); - } - } - } - -} diff --git a/common/src/main/java/org/openecomp/mso/openpojo/rules/ToStringTester.java b/common/src/main/java/org/openecomp/mso/openpojo/rules/ToStringTester.java deleted file mode 100644 index bd582d45dc..0000000000 --- a/common/src/main/java/org/openecomp/mso/openpojo/rules/ToStringTester.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.openpojo.rules; - -import static org.hamcrest.CoreMatchers.anyOf; -import static org.hamcrest.CoreMatchers.anything; - -import org.hamcrest.Matcher; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.validation.affirm.Affirm; -import com.openpojo.validation.test.Tester; -import com.openpojo.validation.utils.ValidationHelper; - -public class ToStringTester implements Tester { - - private final Matcher m; - public ToStringTester() { - m = anything(); - } - - public ToStringTester(Matcher m) { - this.m = m; - } - - @Override - public void run(PojoClass pojoClass) { - Class clazz = pojoClass.getClazz(); - if (anyOf(m).matches(clazz)) { - final Object classInstance = ValidationHelper.getBasicInstance(pojoClass); - - Affirm.affirmFalse("Found default toString output", classInstance.toString().matches(Object.class.getName() + "@" + "\\w+")); - } - - } - -} diff --git a/common/src/main/java/org/openecomp/mso/properties/AbstractMsoProperties.java b/common/src/main/java/org/openecomp/mso/properties/AbstractMsoProperties.java deleted file mode 100644 index 8ab275e734..0000000000 --- a/common/src/main/java/org/openecomp/mso/properties/AbstractMsoProperties.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.properties; - - -import java.io.IOException; -import java.util.Properties; - -import org.openecomp.mso.logger.MsoLogger; - -public abstract class AbstractMsoProperties { - - public static final int DEFAULT_RELOAD_TIME_MIN=1; - - public static final String RELOAD_TIME_PROPERTY="mso.properties.reload.time.minutes"; - - protected static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - - protected String propertiesFileName; - - protected int automaticRefreshInMinutes=0; - - public String getPropertiesFileName() { - return propertiesFileName; - } - - public int getAutomaticRefreshInMinutes() { - return automaticRefreshInMinutes; - } - - protected synchronized void reloadPropertiesFile() throws IOException { - this.loadPropertiesFile(this.propertiesFileName); - } - - /** - * This method load a properties file from a source path. - * - * @param propertiesPath The path to the file - * @throws IOException In case of issues during the opening - */ - - protected abstract void loadPropertiesFile(String propertiesPath) throws IOException; - - @Override - protected abstract AbstractMsoProperties clone(); - - @Override - public abstract int hashCode(); - - @Override - public abstract boolean equals(Object obj); - - @Override - public abstract String toString(); - - -} diff --git a/common/src/main/java/org/openecomp/mso/properties/MsoDatabaseException.java b/common/src/main/java/org/openecomp/mso/properties/MsoDatabaseException.java deleted file mode 100644 index 9583e519f5..0000000000 --- a/common/src/main/java/org/openecomp/mso/properties/MsoDatabaseException.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.properties; - - -/** - * Exception during artifact installation. - */ -public class MsoDatabaseException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = -7048331652191419371L; - - /** - * @param message The message to dump - * @param cause The Throwable cause object - */ - public MsoDatabaseException (final String message) { - super (message); - - } - - /** - * @param message The message to dump - * @param cause The Throwable cause object - */ - public MsoDatabaseException (final String message, final Throwable cause) { - super (message, cause); - - } -} diff --git a/common/src/main/java/org/openecomp/mso/properties/MsoJavaProperties.java b/common/src/main/java/org/openecomp/mso/properties/MsoJavaProperties.java deleted file mode 100644 index c13b9e0b53..0000000000 --- a/common/src/main/java/org/openecomp/mso/properties/MsoJavaProperties.java +++ /dev/null @@ -1,228 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.properties; - - -import java.io.FileReader; -import java.io.IOException; -import java.security.GeneralSecurityException; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.apache.commons.codec.binary.Base64; -import org.openecomp.mso.utils.CryptoUtils; - -public class MsoJavaProperties extends AbstractMsoProperties { - - - private Properties msoProperties = new Properties(); - - - public MsoJavaProperties() { - - } - - public synchronized void setProperty(String key,String value) { - msoProperties.setProperty(key, value); - } - - public synchronized String getProperty(String key, String defaultValue) { - if (msoProperties.containsKey(key)) { - return msoProperties.getProperty(key); - } else { - return defaultValue; - } - } - - public synchronized int getIntProperty(String key, int defaultValue) { - - int value = defaultValue; - if (msoProperties.containsKey(key)) { - try { - value = Integer.parseInt(msoProperties.getProperty(key)); - } catch (NumberFormatException e) { - LOGGER.debug("Exception while parsing integer: " + msoProperties.getProperty(key), e); - } - } - return value; - - } - - public synchronized boolean getBooleanProperty(String key, boolean defaultValue) { - - if (msoProperties.containsKey(key)) { - return Boolean.parseBoolean(msoProperties.getProperty(key)); - } else { - return defaultValue; - } - - } - - public synchronized String getEncryptedProperty(String key, String defaultValue, String encryptionKey) { - - if (msoProperties.containsKey(key)) { - try { - return CryptoUtils.decrypt(msoProperties.getProperty(key), encryptionKey); - } catch (GeneralSecurityException e) { - LOGGER.debug("Exception while decrypting property: " + msoProperties.getProperty(key), e); - } - } - return defaultValue; - - } - - /** - * @param encryptedAuth: encrypted credentials from properties - * @param msoKey: key to use to decrypt from properties - * @return base 64 encoded basic auth credentials - */ - public synchronized String getBasicAuth(String encryptedAuth, String msoKey){ - String encodedString = null; - if ((encryptedAuth == null || encryptedAuth.isEmpty()) || (msoKey == null || msoKey.isEmpty())) - return null; - try { - String auth = decrypt(encryptedAuth, msoKey); - byte[] encoded = Base64.encodeBase64(auth.getBytes()); - encodedString = new String(encoded); - encodedString = "Basic " + encodedString; - - } catch (Exception ex) { - LOGGER.debug("Exception while getBasicAuth " + encryptedAuth, ex); - } - return encodedString; - } - - public synchronized int size() { - return this.msoProperties.size(); - } - - public synchronized String decrypt(String toDecrypt, String msokey){ - String result = null; - try { - result = CryptoUtils.decrypt(toDecrypt, msokey); - - } - catch (Exception e) { - LOGGER.debug("Failed to decrypt credentials: " + toDecrypt, e); - } - return result; - } - - @Override - protected synchronized void reloadPropertiesFile() throws IOException { - this.loadPropertiesFile(this.propertiesFileName); - } - - /** - * This method load a properties file from a source path. - * - * @param propertiesPath The path to the file - * @throws IOException In case of issues during the opening - */ - @Override - protected synchronized void loadPropertiesFile(String propertiesPath) throws IOException { - - FileReader reader = null; - - propertiesFileName = propertiesPath; - try { - msoProperties.clear(); - reader = new FileReader(propertiesPath); - msoProperties.load(reader); - - } finally { - this.automaticRefreshInMinutes = this.getIntProperty(RELOAD_TIME_PROPERTY, DEFAULT_RELOAD_TIME_MIN); - try { - if (reader != null) { - reader.close(); - } - } catch (IOException e) { - LOGGER.debug("Exception while closing reader for file:" + propertiesPath, e); - } - } - } - - @Override - public synchronized MsoJavaProperties clone() { - MsoJavaProperties msoCopy = new MsoJavaProperties(); - msoCopy.msoProperties.putAll(msoProperties); - msoCopy.propertiesFileName = this.propertiesFileName; - msoCopy.automaticRefreshInMinutes = this.automaticRefreshInMinutes; - return msoCopy; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((msoProperties == null) ? 0 : msoProperties.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - MsoJavaProperties other = (MsoJavaProperties) obj; - - return msoProperties.equals(other.msoProperties); - } - - @Override - public String toString() { - - StringBuilder response = new StringBuilder(); - response.append("Config file ") - .append(propertiesFileName) - .append("(Timer:") - .append(automaticRefreshInMinutes) - .append("mins):") - .append(System.lineSeparator()); - - for (Object key : this.msoProperties.keySet()) { - String propertyName = (String) key; - response.append(propertyName); - response.append("="); - response.append(this.msoProperties.getProperty(propertyName)); - response.append(System.lineSeparator()); - } - response.append(System.lineSeparator()); - response.append(System.lineSeparator()); - - return response.toString(); - } - - public Map asMap() { - final Map result = new HashMap<>(); - msoProperties.forEach((key, value) -> result.put(key.toString(), value.toString())); - - return result; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/properties/MsoJsonProperties.java b/common/src/main/java/org/openecomp/mso/properties/MsoJsonProperties.java deleted file mode 100644 index ec0b54a14f..0000000000 --- a/common/src/main/java/org/openecomp/mso/properties/MsoJsonProperties.java +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.properties; - - -import java.io.FileReader; -import java.io.IOException; -import java.security.GeneralSecurityException; - -import org.openecomp.mso.utils.CryptoUtils; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - - -public class MsoJsonProperties extends AbstractMsoProperties { - - protected ObjectMapper mapper = new ObjectMapper(); - - protected JsonNode jsonRootNode = mapper.createObjectNode(); - - protected MsoJsonProperties() { - - } - - public synchronized JsonNode getJsonRootNode () { - return this.jsonRootNode; - } - - /** - * This method is used to get the text encrypted in the string value of the node. - * @param jsonNode The JsonNode containing the strig to decode - * @param defaultValue The default value in case of issue - * @param encryptionKey The encryption Key in AES 128 bits - * @return the String decrypted - */ - public synchronized String getEncryptedProperty(JsonNode jsonNode, String defaultValue, String encryptionKey) { - - if (jsonNode.isTextual()) { - try { - return CryptoUtils.decrypt(jsonNode.asText(), encryptionKey); - } catch (GeneralSecurityException e) { - LOGGER.debug("Exception while decrypting property: " + jsonNode.asText(), e); - } - } - - return defaultValue; - } - - /** - * This method load a properties file from a source path. - * - * @param propertiesPath The path to the file - * @throws IOException In case of issues during the opening - */ - @Override - protected synchronized void loadPropertiesFile(String propertiesPath) throws IOException { - - FileReader reader = null; - - this.propertiesFileName = propertiesPath; - - try { - // Clean - this.jsonRootNode = mapper.createObjectNode(); - - reader = new FileReader(propertiesPath); - - // Try a tree load - this.jsonRootNode = mapper.readValue(reader, JsonNode.class); - - - } finally { - JsonNode reloadJsonProp = this.jsonRootNode.get(RELOAD_TIME_PROPERTY); - if (reloadJsonProp != null) { - this.automaticRefreshInMinutes = reloadJsonProp.asInt(DEFAULT_RELOAD_TIME_MIN); - } else { - this.automaticRefreshInMinutes = DEFAULT_RELOAD_TIME_MIN; - } - - // Always close the file - try { - if (reader != null) { - reader.close(); - } - } catch (IOException e) { - LOGGER.debug("Exception while closing reader for file:" + propertiesFileName, e); - } - } - } - - @Override - public synchronized MsoJsonProperties clone() { - MsoJsonProperties msoCopy = new MsoJsonProperties(); - - ObjectMapper newMapper = new ObjectMapper(); - try { - msoCopy.jsonRootNode = newMapper.createObjectNode(); - msoCopy.jsonRootNode = newMapper.readValue(this.jsonRootNode.toString(), JsonNode.class); - } catch (JsonParseException e) { - LOGGER.debug("JsonParseException when cloning the object:" + this.propertiesFileName, e); - } catch (JsonMappingException e) { - LOGGER.debug("JsonMappingException when cloning the object:" + this.propertiesFileName, e); - } catch (IOException e) { - LOGGER.debug("IOException when cloning the object:" + this.propertiesFileName, e); - } - - msoCopy.propertiesFileName = this.propertiesFileName; - msoCopy.automaticRefreshInMinutes = this.automaticRefreshInMinutes; - return msoCopy; - } - - - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((jsonRootNode == null) ? 0 : jsonRootNode.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - MsoJsonProperties other = (MsoJsonProperties) obj; - if (jsonRootNode == null) { - if (other.jsonRootNode != null) - return false; - } else if (!jsonRootNode.equals(other.jsonRootNode)) - return false; - return true; - } - - @Override - public String toString() { - return "Config file " + propertiesFileName + "(Timer:" + automaticRefreshInMinutes + "mins):" + System - .getProperty("line.separator") + this.jsonRootNode.toString() + System.getProperty("line.separator") - + System.getProperty("line.separator"); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesException.java b/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesException.java deleted file mode 100644 index 1563ca556c..0000000000 --- a/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesException.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.properties; - - -/** - * Exception during artifact installation. - */ -public class MsoPropertiesException extends Exception { - - /** - * serialization id. - */ - private static final long serialVersionUID = 4095937499475915021L; - - /** - * @param message The message to dump - * @param cause The Throwable cause object - */ - public MsoPropertiesException (final String message) { - super (message); - - } - - /** - * @param message The message to dump - * @param cause The Throwable cause object - */ - public MsoPropertiesException (final String message, final Throwable cause) { - super (message, cause); - - } -} diff --git a/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesFactory.java b/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesFactory.java deleted file mode 100644 index 3f81734796..0000000000 --- a/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesFactory.java +++ /dev/null @@ -1,395 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.properties; - - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -import javax.ejb.ConcurrencyManagement; -import javax.ejb.ConcurrencyManagementType; -import javax.ejb.LocalBean; -import javax.ejb.Schedule; -import javax.ejb.Singleton; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Response; - -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.utils.CryptoUtils; - -/** - * This EJB Singleton class returns an instance of the mso properties for a specified file. - * This class can handle many config at the same time and is thread safe. - * This instance is a copy of the one cached so it can be modified or reloaded without impacting the others class using - * it. - * The mso properties files loaded and cached here will be reloaded every X second (it's configurable with the init - * method) - * This class can be used as an EJB or can be instantiated directly as long as the EJB has been initialized for the current - * module. Locks are made manually and not using EJB locks to allow this. - * - * - */ -@Singleton(name = "MsoPropertiesFactory") -@ConcurrencyManagement(ConcurrencyManagementType.BEAN) -@LocalBean -@Path("/properties") -public class MsoPropertiesFactory implements Serializable { - - private static final long serialVersionUID = 4365495305496742113L; - - protected static String prefixMsoPropertiesPath = System.getProperty ("mso.config.path"); - - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); - - // Keep a static copy of properties for global usage - private static final ConcurrentHashMap msoPropertiesCache; - - static { - if (prefixMsoPropertiesPath == null) { - // Hardcode if nothing is received - prefixMsoPropertiesPath = ""; - } - msoPropertiesCache = new ConcurrentHashMap<>(); - } - - private static final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock (); - - public MsoPropertiesFactory () { - - } - - private boolean isJsonFile(String propertiesFilePath) { - return propertiesFilePath.endsWith(".json"); - } - - - private boolean isJavaPropertiesFile (String propertiesFilePath) { - return propertiesFilePath.endsWith(".properties"); - } - - private MsoPropertiesParameters createObjectType (MsoPropertiesParameters msoPropParams, String propertiesFilePath) throws MsoPropertiesException, IOException { - - try { - if (this.isJavaPropertiesFile(propertiesFilePath)) { - - msoPropParams.msoProperties = new MsoJavaProperties(); - msoPropParams.msoPropertiesType = MsoPropertiesParameters.MsoPropertiesType.JAVA_PROP; - } else if (this.isJsonFile(propertiesFilePath)) { - - msoPropParams.msoProperties = new MsoJsonProperties(); - msoPropParams.msoPropertiesType = MsoPropertiesParameters.MsoPropertiesType.JSON_PROP; - } else { - throw new MsoPropertiesException("Unable to load the MSO properties file because format is not recognized (only .json or .properties): " + propertiesFilePath); - } - - msoPropParams.msoProperties.loadPropertiesFile (propertiesFilePath); - - return msoPropParams; - } finally { - if (msoPropParams.msoProperties!=null) { - msoPropParams.refreshCounter = msoPropParams.msoProperties.getAutomaticRefreshInMinutes(); - } - } - - } - - /** - * This method is used to create a MsoProperties file cache and factory. - * The ID is kept in cache even if the config fails to be loaded. - * This is used to maintain the config ID until someone fixes the config file. - * - * @param msoPropertiesID A string representing the key of the config - * @param propertiesFilePath The mso properties file to load - * - * @throws MsoPropertiesException In case of issues with the mso properties loading - * - * @see MsoPropertiesFactory#getMsoJavaProperties() - * @see MsoPropertiesFactory#getMsoJsonProperties() - */ - public void initializeMsoProperties (String msoPropertiesID, - String propertiesFilePath) throws MsoPropertiesException { - - rwl.writeLock ().lock (); - - String msoPropPath="none"; - MsoPropertiesParameters msoPropertiesParams=new MsoPropertiesParameters(); - try { - msoPropPath = prefixMsoPropertiesPath + propertiesFilePath; - if (msoPropertiesCache.get (msoPropertiesID) != null) { - throw new MsoPropertiesException ("The factory contains already an instance of this mso properties: " - + msoPropPath); - } - // Create the global MsoProperties object - msoPropertiesParams = createObjectType(msoPropertiesParams, msoPropPath); - - } catch (FileNotFoundException e) { - throw new MsoPropertiesException ("Unable to load the MSO properties file because it has not been found:" - + msoPropPath, e); - - } catch (IOException e) { - throw new MsoPropertiesException ("Unable to load the MSO properties file because IOException occurs: " - + msoPropPath, e); - } finally { - // put it in all cases, just to not forget about him and attempt a default reload - msoPropertiesCache.put (msoPropertiesID, msoPropertiesParams); - rwl.writeLock ().unlock (); - } - } - - public void removeMsoProperties (String msoPropertiesID) throws MsoPropertiesException { - - rwl.writeLock ().lock (); - try { - if (MsoPropertiesFactory.msoPropertiesCache.remove (msoPropertiesID) == null) { - throw new MsoPropertiesException ("Mso properties not found in cache:" + msoPropertiesID); - } - } finally { - rwl.writeLock ().unlock (); - } - } - - /** - * This method clears all the configs in cache, the factory will then be free of any config. - * - * @see MsoPropertiesFactory#initializeMsoProperties(String, String) - */ - public void removeAllMsoProperties () { - - rwl.writeLock ().lock (); - try { - MsoPropertiesFactory.msoPropertiesCache.clear (); - } finally { - rwl.writeLock ().unlock (); - } - } - - /** - * THis method can be used to change the file and timer fields of an existing MSO properties file. - * - * @param msoPropertiesID The MSO properties ID - * @param newMsoPropPath The new file Path - * @throws MsoPropertiesException In case of the MSO Properties is not found in cache - */ - public void changeMsoPropertiesFilePath (String msoPropertiesID, - String newMsoPropPath) throws MsoPropertiesException { - - rwl.writeLock ().lock (); - try { - MsoPropertiesParameters msoPropInCache = MsoPropertiesFactory.msoPropertiesCache.get (msoPropertiesID); - - if (msoPropInCache != null) { - msoPropInCache.msoProperties.propertiesFileName = prefixMsoPropertiesPath + newMsoPropPath; - - } else { - throw new MsoPropertiesException ("Mso properties not found in cache:" + msoPropertiesID); - } - } finally { - rwl.writeLock ().unlock (); - } - } - - private AbstractMsoProperties getAndCloneProperties(String msoPropertiesID, MsoPropertiesParameters.MsoPropertiesType type) throws MsoPropertiesException { - rwl.readLock ().lock (); - try { - MsoPropertiesParameters msoPropInCache = MsoPropertiesFactory.msoPropertiesCache.get (msoPropertiesID); - if (msoPropInCache == null) { - throw new MsoPropertiesException ("Mso properties not found in cache:" + msoPropertiesID); - } else { - if (type.equals(msoPropInCache.msoPropertiesType)) { - return msoPropInCache.msoProperties.clone (); - } else { - throw new MsoPropertiesException ("Mso properties is not "+type.name()+" properties type:" + msoPropertiesID); - } - - } - } finally { - rwl.readLock ().unlock (); - } - } - - /** - * Get the MSO Properties (As Java Properties) as a copy of the mso properties cache. - * The object returned can therefore be modified. - * - * @return A copy of the mso properties, properties class can be empty if the file has not been read properly - * @throws MsoPropertiesException If the mso properties does not exist in the cache - */ - public MsoJavaProperties getMsoJavaProperties (String msoPropertiesID) throws MsoPropertiesException { - - return (MsoJavaProperties)getAndCloneProperties(msoPropertiesID,MsoPropertiesParameters.MsoPropertiesType.JAVA_PROP); - } - - /** - * Get the MSO Properties (As JSON Properties) as a copy of the mso properties cache. - * The object returned can therefore be modified. - * - * @return A copy of the mso properties, properties class can be empty if the file has not been read properly - * @throws MsoPropertiesException If the mso properties does not exist in the cache - */ - public MsoJsonProperties getMsoJsonProperties (String msoPropertiesID) throws MsoPropertiesException { - - return (MsoJsonProperties)getAndCloneProperties(msoPropertiesID,MsoPropertiesParameters.MsoPropertiesType.JSON_PROP); - } - - /** - * Get all MSO Properties as a copy of the mso properties cache. - * The objects returned can therefore be modified. - * - * @return A List of copies of the mso properties, can be empty - */ - public List getAllMsoProperties () { - - List resultList = new LinkedList<>(); - rwl.readLock ().lock (); - try { - - for (MsoPropertiesParameters msoProp:MsoPropertiesFactory.msoPropertiesCache.values ()) { - resultList.add(msoProp.msoProperties.clone()); - } - return resultList; - - } finally { - rwl.readLock ().unlock (); - } - - } - - /** - * This method is not intended to be called, it's used to refresh the config automatically - * - * @return true if Properties have been reloaded, false otherwise - */ - @Schedule(minute = "*/1", hour = "*", persistent = false) - public boolean reloadMsoProperties () { - AbstractMsoProperties msoPropInCache = null; - try { - if (!rwl.writeLock ().tryLock () && !rwl.writeLock ().tryLock (30L, TimeUnit.SECONDS)) { - LOGGER.debug ("Busy write lock on mso properties factory, skipping the reloading"); - return false; - } - } catch (InterruptedException e1) { - LOGGER.debug ("Interrupted while trying to acquire write lock on mso properties factory, skipping the reloading"); - Thread.currentThread ().interrupt (); - return false; - } - try { - for (Entry entryMsoPropTimer : MsoPropertiesFactory.msoPropertiesCache.entrySet ()) { - - if (entryMsoPropTimer.getValue ().refreshCounter <= 1) { - // It's time to reload the config - msoPropInCache = MsoPropertiesFactory.msoPropertiesCache.get (entryMsoPropTimer.getKey ()).msoProperties; - try { - AbstractMsoProperties oldProps = msoPropInCache.clone (); - msoPropInCache.reloadPropertiesFile (); - entryMsoPropTimer.getValue().refreshCounter=entryMsoPropTimer.getValue().msoProperties.getAutomaticRefreshInMinutes(); - - if (!msoPropInCache.equals (oldProps)) { - LOGGER.info (MessageEnum.LOAD_PROPERTIES_SUC, msoPropInCache.getPropertiesFileName (), "", ""); - } - } catch (FileNotFoundException ef) { - LOGGER.error (MessageEnum.NO_PROPERTIES, msoPropInCache.propertiesFileName, "", "", MsoLogger.ErrorCode.PermissionError, "", ef); - } catch (Exception e) { - LOGGER.error (MessageEnum.LOAD_PROPERTIES_FAIL, msoPropInCache.propertiesFileName, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "", e); - } - - } else { - --entryMsoPropTimer.getValue().refreshCounter; - } - } - return true; - } catch (Exception e) { - LOGGER.error (MessageEnum.LOAD_PROPERTIES_FAIL, "Unknown. Global issue while reloading", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "", e); - return false; - } finally { - rwl.writeLock ().unlock (); - } - } - - /** - * This method can be used to known if the MSO properties instance hold is different from the one in cache - * - * @param msoPropertiesID The MSO properties ID - * @param oldMsoProperties The MSO Properties instance that must be compared to - * @return True if they are the same, false otherwise - * @throws MsoPropertiesException - */ - public boolean propertiesHaveChanged (String msoPropertiesID, AbstractMsoProperties oldMsoProperties) throws MsoPropertiesException { - rwl.readLock ().lock (); - try { - if (MsoPropertiesFactory.msoPropertiesCache.get (msoPropertiesID) == null) { - throw new MsoPropertiesException ("Mso properties not found in cache:" + msoPropertiesID); - } - - AbstractMsoProperties msoPropInCache = MsoPropertiesFactory.msoPropertiesCache.get (msoPropertiesID).msoProperties; - if (oldMsoProperties != null) { - return !oldMsoProperties.equals (msoPropInCache); - } else { - return msoPropInCache != null; - } - } finally { - rwl.readLock ().unlock (); - } - } - - @GET - @Path("/show") - @Produces("text/plain") - public Response showProperties () { - - List listMsoProp = this.getAllMsoProperties (); - StringBuffer response = new StringBuffer (); - - if (listMsoProp.isEmpty ()) { - response.append ("No file defined"); - } - - for (AbstractMsoProperties properties : listMsoProp) { - - response.append(properties.toString()); - } - - return Response.status (200).entity (response).build (); - } - - @GET - @Path("/encrypt/{value}/{cryptKey}") - @Produces("text/plain") - public Response encryptProperty (@PathParam("value") String value, @PathParam("cryptKey") String cryptKey) { - try { - String encryptedValue = CryptoUtils.encrypt (value, cryptKey); - return Response.status (200).entity (encryptedValue).build (); - } catch (Exception e) { - LOGGER.error (MessageEnum.GENERAL_EXCEPTION_ARG, "Encryption error", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Error in encrypting property", e); - return Response.status (500).entity (e.getMessage ()).build (); - } - } -} diff --git a/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesParameters.java b/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesParameters.java deleted file mode 100644 index b89a5d4791..0000000000 --- a/common/src/main/java/org/openecomp/mso/properties/MsoPropertiesParameters.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.properties; - - -public class MsoPropertiesParameters { - - protected enum MsoPropertiesType {JSON_PROP,JAVA_PROP} - - protected MsoPropertiesType msoPropertiesType; - - protected int refreshCounter; - - protected AbstractMsoProperties msoProperties; -} diff --git a/common/src/main/java/org/openecomp/mso/properties/MsoPropertyInitializer.java b/common/src/main/java/org/openecomp/mso/properties/MsoPropertyInitializer.java deleted file mode 100644 index 8490ff8afa..0000000000 --- a/common/src/main/java/org/openecomp/mso/properties/MsoPropertyInitializer.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.properties; - - -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; -import javax.servlet.annotation.WebListener; - -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -/** - * This class will attempt to initialize MSO Properties when part of a web application. - * It will look for the configuration file mso.properties in the - * following order: - * 1. In an init-param "mso.configuration" in web.xml - * 2. In a system property "mso.configuration" - * 3. In the default location "/etc/ecomp/mso/config/mso.properties" - * - * If all else fails, the MSO Properties will go uninitialized, and will - * attempt to use the default constructors within the MsoProperties class. - * - * - */ -@WebListener -public class MsoPropertyInitializer implements ServletContextListener -{ - - private MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory(); - - public MsoPropertyInitializer () { - } - - @Override - public void contextDestroyed(ServletContextEvent event) { - // Nothing to do... - } - - - @Override - public void contextInitialized(ServletContextEvent event) - { - - // Note - this logger may be before or after MSO Logging configuration applied - MsoLogger initLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - try { - // Look first in the init-parameters - String msoPropConfigParam = event.getServletContext().getInitParameter("mso.configuration"); - if (msoPropConfigParam != null && !msoPropConfigParam.isEmpty() ) { - String[] configFileSplit = msoPropConfigParam.split(","); - for (String msoPropConfig:configFileSplit) { - String[] msoPropDecoded = msoPropConfig.split("="); - - try { - msoPropertiesFactory.initializeMsoProperties(msoPropDecoded[0], msoPropDecoded[1]); - initLogger.info(MessageEnum.LOAD_PROPERTIES_SUC, msoPropDecoded[1], "", ""); - initLogger.debug("Mso properties successfully loaded:"+msoPropDecoded[1]+",ID:"+msoPropDecoded[0]+")"); - } catch (MsoPropertiesException e) { - initLogger.error(MessageEnum.LOAD_PROPERTIES_FAIL, msoPropDecoded[1] + ". MSO Properties failed due to an mso properties exception", "", "", MsoLogger.ErrorCode.DataError, "Error in contextInitialized", e); - } - } - } - } - catch (Exception e) { - initLogger.error(MessageEnum.LOAD_PROPERTIES_FAIL, "Unknown. MSO Properties failed to initialize completely", "", "", MsoLogger.ErrorCode.DataError, "", e); - } - } -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/CloudConfiguration.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/CloudConfiguration.java deleted file mode 100644 index cb5a1018ad..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/CloudConfiguration.java +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; - -@JsonRootName(value = "cloudConfiguration") -@JsonInclude(Include.NON_DEFAULT) -public class CloudConfiguration implements Serializable { - - private static final long serialVersionUID = 6260165690180745471L; - @JsonProperty("aicNodeClli") - protected String aicNodeClli; - @JsonProperty("tenantId") - protected String tenantId; - @JsonProperty("lcpCloudRegionId") - protected String lcpCloudRegionId; - - /** - * Gets the value of the aicNodeClli property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAicNodeClli() { - return aicNodeClli; - } - - /** - * Sets the value of the aicNodeClli property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAicNodeClli(String value) { - this.aicNodeClli = value; - } - - /** - * Gets the value of the tenantId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTenantId() { - return tenantId; - } - - /** - * Sets the value of the tenantId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTenantId(String value) { - this.tenantId = value; - } - - - public String getLcpCloudRegionId() { - return lcpCloudRegionId; - } - - public void setLcpCloudRegionId(String lcpCloudRegionId) { - this.lcpCloudRegionId = lcpCloudRegionId; - } - - @Override - public String toString() { - return "CloudConfiguration [aicNodeClli=" + aicNodeClli + ", tenantId=" - + tenantId + ", lcpCloudRegionId=" + lcpCloudRegionId + "]"; - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ExceptionType.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ExceptionType.java deleted file mode 100644 index 84518cf160..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ExceptionType.java +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2016.05.03 at 03:56:30 PM CDT -// - - -package org.openecomp.mso.serviceinstancebeans; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.bind.annotation.XmlType; -import org.apache.commons.lang3.builder.ToStringBuilder; - - -/** - *

Java class for exceptionType complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="exceptionType">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="text" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="variables" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="50" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "exceptionType", propOrder = { - "messageId", - "text", - "variables" -}) -@XmlSeeAlso({ - ServiceException.class, - PolicyException.class -}) -public class ExceptionType { - - @XmlElement(required = true) - protected String messageId; - @XmlElement(required = true) - protected String text; - protected List variables; - - /** - * Gets the value of the messageId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getMessageId() { - return messageId; - } - - /** - * Sets the value of the messageId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setMessageId(String value) { - this.messageId = value; - } - - /** - * Gets the value of the text property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getText() { - return text; - } - - /** - * Sets the value of the text property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setText(String value) { - this.text = value; - } - - /** - * Gets the value of the variables property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the variables property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getVariables().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link String } - * - * - */ - public List getVariables() { - if (variables == null) { - variables = new ArrayList<>(); - } - return this.variables; - } - - public void setVariables(List variables) { - this.variables = variables; - } - - @Override - public String toString() { - return new ToStringBuilder(this).append("messageId", messageId).append("text", text) - .append("variables", variables).toString(); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/GetOrchestrationListResponse.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/GetOrchestrationListResponse.java deleted file mode 100644 index adb1d38464..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/GetOrchestrationListResponse.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import org.apache.commons.lang3.builder.ToStringBuilder; - -@JsonInclude(Include.NON_DEFAULT) -public class GetOrchestrationListResponse { - - protected List requestList; - - public List getRequestList() { - return requestList; - } - - public void setRequestList(List requestList) { - this.requestList = requestList; - } - - @Override - public String toString() { - return new ToStringBuilder(this).append("requestList", requestList).toString(); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/GetOrchestrationResponse.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/GetOrchestrationResponse.java deleted file mode 100644 index 8d57d57513..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/GetOrchestrationResponse.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - -@JsonInclude(Include.NON_DEFAULT) -public class GetOrchestrationResponse { - - protected Request request; - - public Request getRequest() { - return request; - } - - public void setRequest(Request request) { - this.request = request; - } - - @Override - public String toString() { - return new ToStringBuilder(this).append("request", request).toString(); - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/InstanceDirection.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/InstanceDirection.java deleted file mode 100644 index b49825ee60..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/InstanceDirection.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -public enum InstanceDirection { - - source, - destination; - - public String value() { - return name(); - } - - public static InstanceDirection fromValue(String v) { - return valueOf(v); - } -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/InstanceReferences.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/InstanceReferences.java deleted file mode 100644 index 17f09556c3..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/InstanceReferences.java +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import org.apache.commons.lang3.builder.ToStringBuilder; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -@JsonInclude(Include.NON_DEFAULT) -public class InstanceReferences { - - protected String serviceInstanceId; - protected String serviceInstanceName; - protected String vnfInstanceId; - protected String vnfInstanceName; - protected String vfModuleInstanceId; - protected String vfModuleInstanceName; - protected String volumeGroupInstanceId; - protected String volumeGroupInstanceName; - protected String networkInstanceId; - protected String networkInstanceName; - protected String requestorId; - - - 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 getVnfInstanceId() { - return vnfInstanceId; - } - public void setVnfInstanceId(String vnfInstanceId) { - this.vnfInstanceId = vnfInstanceId; - } - public String getVnfInstanceName() { - return vnfInstanceName; - } - public void setVnfInstanceName(String vnfInstanceName) { - this.vnfInstanceName = vnfInstanceName; - } - public String getVfModuleInstanceId() { - return vfModuleInstanceId; - } - public void setVfModuleInstanceId(String vfModuleInstanceId) { - this.vfModuleInstanceId = vfModuleInstanceId; - } - public String getVfModuleInstanceName() { - return vfModuleInstanceName; - } - public void setVfModuleInstanceName(String vfModuleInstanceName) { - this.vfModuleInstanceName = vfModuleInstanceName; - } - public String getVolumeGroupInstanceId() { - return volumeGroupInstanceId; - } - public void setVolumeGroupInstanceId(String volumeGroupInstanceId) { - this.volumeGroupInstanceId = volumeGroupInstanceId; - } - public String getVolumeGroupInstanceName() { - return volumeGroupInstanceName; - } - public void setVolumeGroupInstanceName(String volumeGroupInstanceName) { - this.volumeGroupInstanceName = volumeGroupInstanceName; - } - public String getNetworkInstanceId() { - return networkInstanceId; - } - public void setNetworkInstanceId(String networkInstanceId) { - this.networkInstanceId = networkInstanceId; - } - public String getNetworkInstanceName() { - return networkInstanceName; - } - public void setNetworkInstanceName(String networkInstanceName) { - this.networkInstanceName = networkInstanceName; - } - - public String getRequestorId() { - return requestorId; - } - - public void setRequestorId(String requestorId) { - this.requestorId = requestorId; - } - @Override - public String toString() { - return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId) - .append("serviceInstanceName", serviceInstanceName).append("vnfInstanceId", vnfInstanceId) - .append("vnfInstanceName", vnfInstanceName).append("vfModuleInstanceId", vfModuleInstanceId) - .append("vfModuleInstanceName", vfModuleInstanceName) - .append("volumeGroupInstanceId", volumeGroupInstanceId) - .append("volumeGroupInstanceName", volumeGroupInstanceName) - .append("networkInstanceId", networkInstanceId).append("networkInstanceName", networkInstanceName) - .append("requestorId", requestorId).toString(); - } -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/LineOfBusiness.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/LineOfBusiness.java deleted file mode 100644 index ce46291da6..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/LineOfBusiness.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import org.apache.commons.lang3.builder.ToStringBuilder; - -@JsonRootName(value = "lineOfBusiness") -@JsonInclude(Include.NON_DEFAULT) -public class LineOfBusiness implements Serializable { - - private static final long serialVersionUID = -8574860788160041209L; - @JsonProperty("lineOfBusinessName") - private String lineOfBusinessName; - - public String getLineOfBusinessName(){ - return lineOfBusinessName; - } - public void setLineOfBusinessName(String value){ - this.lineOfBusinessName = value; - } - @Override - public String toString() { - return new ToStringBuilder(this).append("lineOfBusinessName", lineOfBusinessName).toString(); - } -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ModelInfo.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ModelInfo.java deleted file mode 100644 index f91dd10f38..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ModelInfo.java +++ /dev/null @@ -1,154 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2016.03.30 at 02:48:23 PM CDT -// - - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; - -@JsonRootName(value = "modelInfo") -@JsonInclude(Include.NON_DEFAULT) -public class ModelInfo implements Serializable { - - private static final long serialVersionUID = 5281763573935476852L; - @JsonProperty("modelCustomizationName") - protected String modelCustomizationName; - @JsonProperty("modelInvariantId") - protected String modelInvariantId; - @JsonProperty("modelType") - protected ModelType modelType; - //v2 - @JsonProperty("modelNameVersionId") - protected String modelNameVersionId; - @JsonProperty("modelName") - protected String modelName; - @JsonProperty("modelVersion") - protected String modelVersion; - @JsonProperty("modelCustomizationUuid") - protected String modelCustomizationUuid; - //v3 - @JsonProperty("modelVersionId") - protected String modelVersionId; - @JsonProperty("modelCustomizationId") - protected String modelCustomizationId; - //Decomposition fields - @JsonProperty("modelUuid") - protected String modelUuid; - @JsonProperty("modelInvariantUuid") - protected String modelInvariantUuid; - @JsonProperty("modelInstanceName") - protected String modelInstanceName; - - public String getModelCustomizationName() { - return modelCustomizationName; - } - public void setModelCustomizationName(String modelCustomizationName) { - this.modelCustomizationName = modelCustomizationName; - } - public String getModelNameVersionId() { - return modelNameVersionId; - } - public void setModelNameVersionId(String modelNameVersionId) { - this.modelNameVersionId = modelNameVersionId; - } - public String getModelName() { - return modelName; - } - public void setModelName(String modelName) { - this.modelName = modelName; - } - public String getModelVersion() { - return modelVersion; - } - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - public ModelType getModelType() { - return modelType; - } - public void setModelType(ModelType modelType) { - this.modelType = modelType; - } - public String getModelInvariantId() { - return modelInvariantId; - } - public void setModelInvariantId(String modelInvariantId) { - this.modelInvariantId = modelInvariantId; - } - public String getModelCustomizationUuid() { - return modelCustomizationUuid; - } - public void setModelCustomizationUuid(String modelCustomizationUuid) { - this.modelCustomizationUuid = modelCustomizationUuid; - } - public String getModelVersionId() { - return modelVersionId; - } - public void setModelVersionId(String modelVersionId) { - this.modelVersionId = modelVersionId; - } - public String getModelCustomizationId() { - return modelCustomizationId; - } - public void setModelCustomizationId(String modelCustomizationId) { - this.modelCustomizationId = modelCustomizationId; - } - public String getModelUuid() { - return modelUuid; - } - public void setModelUuid(String modelUuid) { - this.modelUuid = modelUuid; - } - public String getModelInvariantUuid() { - return modelInvariantUuid; - } - public void setModelInvariantUuid(String modelInvariantUuid) { - this.modelInvariantUuid = modelInvariantUuid; - } - public String getModelInstanceName() { - return modelInstanceName; - } - public void setModelInstanceName(String modelInstanceName) { - this.modelInstanceName = modelInstanceName; - } - @Override - public String toString() { - return "ModelInfo [modelCustomizationName=" + modelCustomizationName + ", modelInvariantId=" + modelInvariantId - + ", modelType=" + modelType + ", modelNameVersionId=" + modelNameVersionId + ", modelName=" + modelName - + ", modelVersion=" + modelVersion + ", modelCustomizationUuid=" + modelCustomizationUuid - + ", modelVersionId=" + modelVersionId + ", modelCustomizationId=" + modelCustomizationId - + ", modelUuid=" + modelUuid + ", modelInvariantUuid=" + modelInvariantUuid + ", modelInstanceName=" - + modelInstanceName + "]"; - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ModelType.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ModelType.java deleted file mode 100644 index 1080c57976..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ModelType.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -/* - * Enum for Model Type values returned by API Handler to BPMN -*/ -public enum ModelType { - service, - vnf, - vfModule, - volumeGroup, - network, - configuration, - connectionPoint, - pnf -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/OwningEntity.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/OwningEntity.java deleted file mode 100644 index 985de7d41a..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/OwningEntity.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; - -@JsonRootName(value = "owningEntity") -@JsonInclude(Include.NON_DEFAULT) -public class OwningEntity implements Serializable { - - private static final long serialVersionUID = -3907033130633428448L; - @JsonProperty("owningEntityId") - private String owningEntityId; - @JsonProperty("owningEntityName") - private String owningEntityName; - - public String getOwningEntityId(){ - return owningEntityId; - } - - public void setOwningEntityId(String value) { - this.owningEntityId = value; - } - - public String getOwningEntityName(){ - return owningEntityName; - } - - public void setOwningEntityName(String value){ - this.owningEntityName = value; - } - @Override - public String toString() { - return "OwningEntity [owningEntityId=" + owningEntityId - + ", owningEntityName=" + owningEntityName + "]"; - } -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/Platform.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/Platform.java deleted file mode 100644 index a7a34cc39b..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/Platform.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import org.apache.commons.lang3.builder.ToStringBuilder; - -@JsonInclude(Include.NON_DEFAULT) -@JsonRootName(value = "platform") -public class Platform implements Serializable { - - private static final long serialVersionUID = -7334479240678605536L; - @JsonProperty("platformName") - private String platformName; - - public String getPlatformName(){ - return platformName; - } - public void setPlatformName(String value){ - this.platformName = value; - } - @Override - public String toString() { - return new ToStringBuilder(this).append("platformName", platformName).toString(); - } -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/PolicyException.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/PolicyException.java deleted file mode 100644 index dfa23f6490..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/PolicyException.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2016.03.30 at 02:48:23 PM CDT -// - - -package org.openecomp.mso.serviceinstancebeans; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for policyException complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="policyException">
- *   <complexContent>
- *     <extension base="{http://org.openecomp/mso/request/types/v1}exceptionType">
- *     </extension>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "policyException") -public class PolicyException - extends ExceptionType -{ - - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/Project.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/Project.java deleted file mode 100644 index b7e80162ff..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/Project.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import org.apache.commons.lang3.builder.ToStringBuilder; - -@JsonRootName(value = "project") -@JsonInclude(Include.NON_DEFAULT) -public class Project implements Serializable { - - private static final long serialVersionUID = -3868114191925177035L; - @JsonProperty("projectName") - private String projectName; - - public String getProjectName(){ - return projectName; - } - - public void setProjectName(String value) { - this.projectName = value; - } - - @Override - public String toString() { - return new ToStringBuilder(this).append("projectName", projectName).toString(); - } -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RelatedInstance.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RelatedInstance.java deleted file mode 100644 index 60e7d9b69a..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RelatedInstance.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import org.apache.commons.lang3.builder.ToStringBuilder; - -@JsonRootName(value = "relatedInstance") -@JsonInclude(Include.NON_DEFAULT) -public class RelatedInstance implements Serializable { - - private static final long serialVersionUID = 137250604008221644L; - @JsonProperty("instanceName") - protected String instanceName; - @JsonProperty("instanceId") - protected String instanceId; - @JsonProperty("modelInfo") - protected ModelInfo modelInfo; - //Configuration field - @JsonProperty("instanceDirection") - protected InstanceDirection instanceDirection; - - - public String getInstanceName() { - return instanceName; - } - public void setInstanceName(String instanceName) { - this.instanceName = instanceName; - } - public String getInstanceId() { - return instanceId; - } - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - public ModelInfo getModelInfo() { - return modelInfo; - } - public void setModelInfo(ModelInfo modelInfo) { - this.modelInfo = modelInfo; - } - public InstanceDirection getInstanceDirection() { - return instanceDirection; - } - public void setInstanceDirection(InstanceDirection instanceDirection) { - this.instanceDirection = instanceDirection; - } - @Override - public String toString() { - return new ToStringBuilder(this).append("instanceName", instanceName).append("instanceId", instanceId) - .append("modelInfo", modelInfo).append("instanceDirection", instanceDirection).toString(); - } -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RelatedInstanceList.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RelatedInstanceList.java deleted file mode 100644 index b11acccf2a..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RelatedInstanceList.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; - -@JsonRootName(value = "relatedInstanceList") -@JsonInclude(Include.NON_DEFAULT) -public class RelatedInstanceList implements Serializable { - - private static final long serialVersionUID = 6333898302094446243L; - @JsonProperty("relatedInstance") - protected RelatedInstance relatedInstance; - - public RelatedInstance getRelatedInstance() { - return relatedInstance; - } - - public void setRelatedInstance(RelatedInstance relatedInstance) { - this.relatedInstance = relatedInstance; - } - - @Override - public String toString() { - return "RelatedInstanceList [relatedInstance=" + relatedInstance + "]"; - } - - - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/Request.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/Request.java deleted file mode 100644 index 0671089d99..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/Request.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import org.apache.commons.lang3.builder.ToStringBuilder; - -//@JsonRootName(value = "request") -@JsonInclude(Include.NON_DEFAULT) -public class Request { - - protected String requestId; - protected String startTime; - protected String requestScope; - protected String requestType; - //protected String requestDetails; - protected RequestDetails requestDetails; - protected InstanceReferences instanceReferences; - protected RequestStatus requestStatus; - - - public String getRequestId() { - return requestId; - } - public void setRequestId(String requestId) { - this.requestId = requestId; - } - public String getStartTime() { - return startTime; - } - public void setStartTime(String startTime) { - this.startTime = startTime; - } - public String getRequestScope() { - return requestScope; - } - public void setRequestScope(String requestScope) { - this.requestScope = requestScope; - } - public String getRequestType() { - return requestType; - } - public void setRequestType(String requestType) { - this.requestType = requestType; - } - public RequestStatus getRequestStatus() { - return requestStatus; - } - public void setRequestStatus(RequestStatus requestStatus) { - this.requestStatus = requestStatus; - } - public InstanceReferences getInstanceReferences() { - return instanceReferences; - } - public void setInstanceReferences(InstanceReferences instanceReferences) { - this.instanceReferences = instanceReferences; - } - public RequestDetails getRequestDetails() { - return requestDetails; - } - public void setRequestDetails(RequestDetails requestDetails) { - this.requestDetails = requestDetails; - } - @Override - public String toString() { - return new ToStringBuilder(this).append("requestId", requestId).append("startTime", startTime) - .append("requestScope", requestScope).append("requestType", requestType) - .append("requestDetails", requestDetails).append("instanceReferences", instanceReferences) - .append("requestStatus", requestStatus).toString(); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestDetails.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestDetails.java deleted file mode 100644 index 2bae526efa..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestDetails.java +++ /dev/null @@ -1,280 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; -import java.util.Arrays; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; - -@JsonRootName(value = "requestDetails") -@JsonInclude(Include.NON_DEFAULT) -public class RequestDetails implements Serializable { - - private static final long serialVersionUID = -73080684945860609L; - @JsonProperty("modelInfo") - protected ModelInfo modelInfo; - @JsonProperty("requestInfo") - protected RequestInfo requestInfo; - @JsonProperty("relatedInstanceList") - protected RelatedInstanceList[] relatedInstanceList; - @JsonProperty("subscriberInfo") - protected SubscriberInfo subscriberInfo; - @JsonProperty("cloudConfiguration") - protected CloudConfiguration cloudConfiguration; - @JsonProperty("requestParameters") - protected RequestParameters requestParameters; - @JsonProperty("project") - protected Project project; - @JsonProperty("owningEntity") - protected OwningEntity owningEntity; - @JsonProperty("platform") - protected Platform platform; - @JsonProperty("lineOfBusiness") - protected LineOfBusiness lineOfBusiness; - /** - * Gets the value of the serviceInfo property. - * - * @return - * possible object is - * {@link ModelInfo } - * - */ - public ModelInfo getModelInfo() { - return modelInfo; - } - - /** - * Sets the value of the serviceInfo property. - * - * @param value - * allowed object is - * {@link ModelInfo } - * - */ - public void setModelInfo(ModelInfo value) { - this.modelInfo = value; - } - - /** - * Gets the value of the requestInfo property. - * - * @return - * possible object is - * {@link RequestInfo } - * - */ - public RequestInfo getRequestInfo() { - return requestInfo; - } - - /** - * Sets the value of the requestInfo property. - * - * @param value - * allowed object is - * {@link RequestInfo } - * - */ - public void setRequestInfo(RequestInfo value) { - this.requestInfo = value; - } - - /** - * Gets the value of the subscriberInfo property. - * - * @return - * possible object is - * {@link SubscriberInfo } - * - */ - public SubscriberInfo getSubscriberInfo() { - return subscriberInfo; - } - - /** - * Sets the value of the subscriberInfo property. - * - * @param value - * allowed object is - * {@link SubscriberInfo } - * - */ - public void setSubscriberInfo(SubscriberInfo value) { - this.subscriberInfo = value; - } - - /** - * Gets the value of the cloudConfiguration property. - * - * @return - * possible object is - * {@link CloudConfiguration } - * - */ - public CloudConfiguration getCloudConfiguration() { - return cloudConfiguration; - } - - /** - * Sets the value of the cloudConfiguration property. - * - * @param value - * allowed object is - * {@link CloudConfiguration } - * - */ - public void setCloudConfiguration(CloudConfiguration value) { - this.cloudConfiguration = value; - } - - /** - * Gets the value of the requestParameters property. - * - * @return - * possible object is - * {@link RequestParameters } - * - */ - public RequestParameters getRequestParameters() { - return requestParameters; - } - - /** - * Sets the value of the requestParameters property. - * - * @param value - * allowed object is - * {@link RequestParameters } - * - */ - public void setRequestParameters(RequestParameters value) { - this.requestParameters = value; - } - - public RelatedInstanceList[] getRelatedInstanceList() { - return relatedInstanceList; - } - - public void setRelatedInstanceList(RelatedInstanceList[] relatedInstanceList) { - this.relatedInstanceList = relatedInstanceList; - } - /** - * Gets the value of the project property. - * - * @return - * possible object is - * {@link Project } - * - */ - public Project getProject(){ - return project; - } - /** - * Sets the value of the project property. - * - * @param value - * allowed object is - * {@link Project } - * - */ - public void setProject(Project value){ - this.project = value; - } - /** - * Gets the value of the owningEntity property. - * - * @return - * possible object is - * {@link OwningEntity } - * - */ - public OwningEntity getOwningEntity(){ - return owningEntity; - } - /** - * Sets the value of the owningEntity property. - * - * @param value - * allowed object is - * {@link OwningEntity } - * - */ - public void setOwningEntity(OwningEntity value){ - this.owningEntity = value; - } - /** - * Gets the value of the platform property. - * - * @return - * possible object is - * {@link Platform } - * - */ - public Platform getPlatform(){ - return platform; - } - /** - * Sets the value of the platform property. - * - * @param value - * allowed object is - * {@link Platform } - * - */ - public void setPlatform(Platform value){ - this.platform = value; - } - /** - * Gets the value of the lineOfBusiness property. - * - * @return - * possible object is - * {@link LineOfBusiness } - * - */ - public LineOfBusiness getLineOfBusiness(){ - return lineOfBusiness; - } - /** - * Sets the value of the lineOfBusiness property. - * - * @param value - * allowed object is - * {@link LineOfBusiness } - * - */ - public void setLineOfBusiness(LineOfBusiness value){ - this.lineOfBusiness = value; - } - @Override - public String toString() { - return "RequestDetails [modelInfo=" + modelInfo + ", requestInfo=" - + requestInfo + ", relatedInstanceList=" - + Arrays.toString(relatedInstanceList) + ", subscriberInfo=" - + subscriberInfo + ", cloudConfiguration=" + cloudConfiguration - + ", requestParameters=" + requestParameters + ", platform=" + platform - + ", lineOfBusiness=" + ", project=" + project + ", owningEntity=" + owningEntity + "]"; - } -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestError.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestError.java deleted file mode 100644 index efd5358073..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestError.java +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2016.04.07 at 08:25:52 AM CDT -// - - -package org.openecomp.mso.serviceinstancebeans; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import org.apache.commons.lang3.builder.ToStringBuilder; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <choice>
- *           <element name="policyException" type="{http://org.openecomp/mso/request/types/v1}policyException"/>
- *           <element name="serviceException" type="{http://org.openecomp/mso/request/types/v1}serviceException"/>
- *         </choice>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "policyException", - "serviceException" -}) -@XmlRootElement(name = "requestError") -public class RequestError { - - protected PolicyException policyException; - protected ServiceException serviceException; - - /** - * Gets the value of the policyException property. - * - * @return - * possible object is - * {@link PolicyException } - * - */ - public PolicyException getPolicyException() { - return policyException; - } - - /** - * Sets the value of the policyException property. - * - * @param value - * allowed object is - * {@link PolicyException } - * - */ - public void setPolicyException(PolicyException value) { - this.policyException = value; - } - - /** - * Gets the value of the serviceException property. - * - * @return - * possible object is - * {@link ServiceException } - * - */ - public ServiceException getServiceException() { - return serviceException; - } - - /** - * Sets the value of the serviceException property. - * - * @param value - * allowed object is - * {@link ServiceException } - * - */ - public void setServiceException(ServiceException value) { - this.serviceException = value; - } - - @Override - public String toString() { - return new ToStringBuilder(this).append("policyException", policyException) - .append("serviceException", serviceException).toString(); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestInfo.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestInfo.java deleted file mode 100644 index d1e489a174..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestInfo.java +++ /dev/null @@ -1,239 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; - -@JsonRootName(value = "requestInfo") -@JsonInclude(Include.NON_DEFAULT) -public class RequestInfo implements Serializable { - - private static final long serialVersionUID = -1370946827136030181L; - @JsonProperty("billingAccountNumber") - protected String billingAccountNumber; - @JsonProperty("callbackUrl") - protected String callbackUrl; - @JsonProperty("correlator") - protected String correlator; - @JsonProperty("orderNumber") - protected String orderNumber; - @JsonProperty("productFamilyId") - protected String productFamilyId; - @JsonProperty("orderVersion") - protected Integer orderVersion; - @JsonSerialize(include=Inclusion.ALWAYS) - @JsonProperty("source") - protected String source; - @JsonProperty("instanceName") - protected String instanceName; - @JsonProperty("suppressRollback") - @JsonSerialize(include=Inclusion.ALWAYS) - protected boolean suppressRollback; - @JsonProperty("requestorId") - protected String requestorId; - - /** - * Gets the value of the callbackUrl property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCallbackUrl() { - return callbackUrl; - } - - /** - * Sets the value of the callbackUrl property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCallbackUrl(String value) { - this.callbackUrl = value; - } - - /** - * Gets the value of the correlator property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCorrelator() { - return correlator; - } - - /** - * Sets the value of the correlator property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCorrelator(String value) { - this.correlator = value; - } - - /** - * Gets the value of the orderNumber property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getOrderNumber() { - return orderNumber; - } - - /** - * Sets the value of the orderNumber property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setOrderNumber(String value) { - this.orderNumber = value; - } - - /** - * Gets the value of the orderVersion property. - * - * @return - * possible object is - * {@link Integer } - * - */ - public Integer getOrderVersion() { - return orderVersion; - } - - /** - * Sets the value of the orderVersion property. - * - * @param value - * allowed object is - * {@link Integer } - * - */ - public void setOrderVersion(Integer value) { - this.orderVersion = value; - } - - /** - * Gets the value of the source property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSource() { - if(null == source || source.isEmpty()){ - source = "VID"; - } - return source; - } - - /** - * Sets the value of the source property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSource(String value) { - this.source = value; - } - - public String getInstanceName() { - return instanceName; - } - - public void setInstanceName(String instanceName) { - this.instanceName = instanceName; - } - - public String getBillingAccountNumber() { - return billingAccountNumber; - } - - public void setBillingAccountNumber(String billingAccountNumber) { - this.billingAccountNumber = billingAccountNumber; - } - - public String getProductFamilyId() { - return productFamilyId; - } - - public void setProductFamilyId(String productFamilyId) { - this.productFamilyId = productFamilyId; - } - - /** - * Required for Marshalers to send the fields. - * @return - */ - public boolean getSuppressRollback() { - return suppressRollback; - } - - public void setSuppressRollback(boolean suppressRollback) { - this.suppressRollback = suppressRollback; - } - - public String getRequestorId() { - return requestorId; - } - - public void setRequestorId(String requestorId) { - this.requestorId = requestorId; - } - - @Override - public String toString() { - return "RequestInfo [billingAccountNumber=" + billingAccountNumber - + ", callbackUrl=" + callbackUrl + ", correlator=" + correlator - + ", orderNumber=" + orderNumber + ", productFamilyId=" - + productFamilyId + ", orderVersion=" + orderVersion - + ", source=" + source + ", instanceName=" + instanceName - + ", suppressRollback=" + suppressRollback + ", requestorId=" - + requestorId + "]"; - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestList.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestList.java deleted file mode 100644 index 799e2f8c60..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestList.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.util.List; -import org.apache.commons.lang3.builder.ToStringBuilder; - - -public class RequestList { - - protected Request request; - - public Request getRequest() { - return request; - } - - public void setRequest(Request request) { - this.request = request; - } - - @Override - public String toString() { - return new ToStringBuilder(this).append("request", request).toString(); - } - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestParameters.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestParameters.java deleted file mode 100644 index 06d53285b0..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestParameters.java +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; - -@JsonRootName(value = "requestParameters") -@JsonInclude(Include.NON_DEFAULT) -public class RequestParameters implements Serializable { - - private static final long serialVersionUID = -5979049912538894930L; - @JsonProperty("subscriptionServiceType") - private String subscriptionServiceType; - @JsonProperty("userParams") - private List> userParams = new ArrayList<>(); - @JsonProperty("aLaCarte") - private Boolean aLaCarte; - @JsonProperty("autoBuildVfModules") - private Boolean autoBuildVfModules; - @JsonProperty("cascadeDelete") - private Boolean cascadeDelete; - @JsonProperty("usePreload") - private Boolean usePreload; // usePreload would always be true for Update - @JsonProperty("rebuildVolumeGroups") - private Boolean rebuildVolumeGroups; - @JsonProperty("payload") - private String payload; - @JsonProperty("controllerType") - private String controllerType; - - public String getSubscriptionServiceType() { - return subscriptionServiceType; - } - - public void setSubscriptionServiceType(String subscriptionServiceType) { - this.subscriptionServiceType = subscriptionServiceType; - } - - public Boolean getALaCarte() { - return aLaCarte; - } - - public void setaLaCarte(Boolean aLaCarte) { - this.aLaCarte = aLaCarte; - } - - public Boolean isaLaCarte() { - return aLaCarte; - } - - public List> getUserParams() { - return userParams; - } - - public void setUserParams(List> userParams) { - this.userParams = userParams; - } - - public String getUserParamValue(String name){ - if(userParams!=null){ - for(Map param:userParams){ - if(param.get("name").equals(name)){ - return param.get("value").toString(); - } - } - } - return null; - } - - public Boolean getAutoBuildVfModules() { - return autoBuildVfModules; - } - - public void setAutoBuildVfModules(Boolean autoBuildVfModules) { - this.autoBuildVfModules = autoBuildVfModules; - } - - public Boolean getCascadeDelete() { - return cascadeDelete; - } - - public void setCascadeDelete(Boolean cascadeDelete) { - this.cascadeDelete = cascadeDelete; - } - - public Boolean isUsePreload() { - return usePreload; - } - - public void setUsePreload(Boolean usePreload) { - this.usePreload = usePreload; - } - - public Boolean rebuildVolumeGroups() { - return rebuildVolumeGroups; - } - - public Boolean isRebuildVolumeGroups() { - return rebuildVolumeGroups; - } - public void setRebuildVolumeGroups(Boolean rebuildVolumeGroups) { - this.rebuildVolumeGroups = rebuildVolumeGroups; - } - public String getPayload(){ - return payload; - } - public void setPayload(String value){ - this.payload = value; - } - - public String getControllerType() { - return controllerType; - } - - public void setControllerType(String controllerType) { - this.controllerType = controllerType; - } - - @Override - public String toString() { - return "RequestParameters [subscriptionServiceType=" + subscriptionServiceType + ", userParams=" + userParams - + ", aLaCarte=" + aLaCarte + ", autoBuildVfModules=" + autoBuildVfModules + ", cascadeDelete=" - + cascadeDelete + ", usePreload=" + usePreload + ", rebuildVolumeGroups=" + rebuildVolumeGroups - + ", payload=" + payload + ", controllerType=" + controllerType + "]"; - } -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestReferences.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestReferences.java deleted file mode 100644 index d4d70190ff..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestReferences.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import org.apache.commons.lang3.builder.ToStringBuilder; - -public class RequestReferences { - - String requestId; - String instanceId; - - - public String getRequestId() { - return requestId; - } - public void setRequestId(String requestId) { - this.requestId = requestId; - } - public String getInstanceId() { - return instanceId; - } - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - @Override - public String toString() { - return new ToStringBuilder(this).append("requestId", requestId).append("instanceId", instanceId).toString(); - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestStatus.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestStatus.java deleted file mode 100644 index d6a8fc0084..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/RequestStatus.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import org.apache.commons.lang3.builder.ToStringBuilder; - -@JsonInclude(Include.NON_DEFAULT) -public class RequestStatus { - - protected String requestState; - protected String statusMessage; - protected Integer percentProgress; - protected String finishTime; - - - public String getRequestState() { - return requestState; - } - public void setRequestState(String requestState) { - this.requestState = requestState; - } - public String getStatusMessage() { - return statusMessage; - } - public void setStatusMessage(String statusMessage) { - this.statusMessage = statusMessage; - } - public Integer getPercentProgress() { - return percentProgress; - } - public void setPercentProgress(Integer percentProgress) { - this.percentProgress = percentProgress; - } - public String getFinishTime() { - return finishTime; - } - public void setFinishTime(String finishTime) { - this.finishTime = finishTime; - } - @Override - public String toString() { - return new ToStringBuilder(this).append("requestState", requestState).append("statusMessage", statusMessage) - .append("percentProgress", percentProgress).append("finishTime", finishTime).toString(); - } -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ServiceException.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ServiceException.java deleted file mode 100644 index 0fe8b5f0cf..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ServiceException.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2016.03.30 at 02:48:23 PM CDT -// - - -package org.openecomp.mso.serviceinstancebeans; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for serviceException complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="serviceException">
- *   <complexContent>
- *     <extension base="{http://org.openecomp/mso/request/types/v1}exceptionType">
- *     </extension>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "serviceException") -public class ServiceException - extends ExceptionType -{ - - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesRequest.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesRequest.java deleted file mode 100644 index d06c532f88..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesRequest.java +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class ServiceInstancesRequest implements Serializable { - - private static final long serialVersionUID = -4959169541182257787L; - @JsonProperty("requestDetails") - private RequestDetails requestDetails; - @JsonProperty("serviceInstanceId") - private String serviceInstanceId; - @JsonProperty("vnfInstanceId") - private String vnfInstanceId; - @JsonProperty("networkInstanceId") - private String networkInstanceId; - @JsonProperty("volumeGroupInstanceId") - private String volumeGroupInstanceId; - @JsonProperty("vfModuleInstanceId") - private String vfModuleInstanceId; - @JsonProperty("configurationId") - private String configurationId; - @JsonProperty("correlationId") - private String correlationId; - - public RequestDetails getRequestDetails() { - return requestDetails; - } - - public void setRequestDetails(RequestDetails requestDetails) { - this.requestDetails = requestDetails; - } - - public String getServiceInstanceId() { - return serviceInstanceId; - } - - public void setServiceInstanceId(String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - } - - public String getVnfInstanceId() { - return vnfInstanceId; - } - - public void setVnfInstanceId(String vnfInstanceId) { - this.vnfInstanceId = vnfInstanceId; - } - - public String getNetworkInstanceId() { - return networkInstanceId; - } - - public void setNetworkInstanceId(String networkInstanceId) { - this.networkInstanceId = networkInstanceId; - } - - public String getVolumeGroupInstanceId() { - return volumeGroupInstanceId; - } - - public void setVolumeGroupInstanceId(String volumeGroupInstanceId) { - this.volumeGroupInstanceId = volumeGroupInstanceId; - } - - public String getVfModuleInstanceId() { - return vfModuleInstanceId; - } - - public void setVfModuleInstanceId(String vfModuleInstanceId) { - this.vfModuleInstanceId = vfModuleInstanceId; - } - - public String getConfigurationId() { - return configurationId; - } - - public void setConfigurationId(String configurationId) { - this.configurationId = configurationId; - } - - public String getCorrelationId() { - return correlationId; - } - - public void setCorrelationId(String correlationId) { - this.correlationId = correlationId; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("ServiceInstancesRequest{"); - sb.append("requestDetails=").append(requestDetails); - sb.append(", serviceInstanceId='").append(serviceInstanceId).append('\''); - sb.append(", vnfInstanceId='").append(vnfInstanceId).append('\''); - sb.append(", networkInstanceId='").append(networkInstanceId).append('\''); - sb.append(", volumeGroupInstanceId='").append(volumeGroupInstanceId).append('\''); - sb.append(", vfModuleInstanceId='").append(vfModuleInstanceId).append('\''); - sb.append(", configurationId='").append(configurationId).append('\''); - sb.append(", correlationId='").append(correlationId).append('\''); - sb.append('}'); - return sb.toString(); - } -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesResponse.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesResponse.java deleted file mode 100644 index 614a87d009..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import org.apache.commons.lang3.builder.ToStringBuilder; - -public class ServiceInstancesResponse { - - RequestReferences requestReferences; - - public RequestReferences getRequestReferences() { - return requestReferences; - } - - public void setRequestReferences(RequestReferences requestReferences) { - this.requestReferences = requestReferences; - } - - @Override - public String toString() { - return new ToStringBuilder(this).append("requestReferences", requestReferences).toString(); - } - - -} diff --git a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/SubscriberInfo.java b/common/src/main/java/org/openecomp/mso/serviceinstancebeans/SubscriberInfo.java deleted file mode 100644 index 47cb1f2d26..0000000000 --- a/common/src/main/java/org/openecomp/mso/serviceinstancebeans/SubscriberInfo.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; - -@JsonRootName(value = "subscriberInfo") -@JsonInclude(Include.NON_DEFAULT) -public class SubscriberInfo implements Serializable { - - private static final long serialVersionUID = -1750701712128104652L; - @JsonProperty("globalSubscriberId") - protected String globalSubscriberId; - @JsonProperty("subscriberName") - protected String subscriberName; - - /** - * Gets the value of the globalSubscriberId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getGlobalSubscriberId() { - return globalSubscriberId; - } - - /** - * Sets the value of the globalSubscriberId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setGlobalSubscriberId(String value) { - this.globalSubscriberId = value; - } - - /** - * Gets the value of the subscriberName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSubscriberName() { - return subscriberName; - } - - /** - * Sets the value of the subscriberName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSubscriberName(String value) { - this.subscriberName = value; - } - - @Override - public String toString() { - return "SubscriberInfo [globalSubscriberId=" + globalSubscriberId - + ", subscriberName=" + subscriberName + "]"; - } - -} diff --git a/common/src/main/java/org/openecomp/mso/utils/CheckResults.java b/common/src/main/java/org/openecomp/mso/utils/CheckResults.java deleted file mode 100644 index ad0344d028..0000000000 --- a/common/src/main/java/org/openecomp/mso/utils/CheckResults.java +++ /dev/null @@ -1,118 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.utils; - - - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "checkresults") -public class CheckResults { - - @XmlElement(name = "checkresult") - private List results; - - public CheckResults () { - results = new ArrayList<>(); - } - - public List getResults () { - return results; - } - - public void addHostCheckResult (String hostname, int state, String output) { - CheckResult newResult = new CheckResult (); - newResult.setType ("host"); - newResult.setHostname (hostname); - newResult.setState (state); - newResult.setOutput (output); - results.add (newResult); - } - - public void addServiceCheckResult (String hostname, String servicename, int state, String output) { - CheckResult newResult = new CheckResult (); - newResult.setType ("service"); - newResult.setHostname (hostname); - newResult.setServicename (servicename); - newResult.setState (state); - newResult.setOutput (output); - results.add (newResult); - } - - public static class CheckResult { - - private String type; - private String hostname; - private String servicename; - private int state; - private String output; - - @XmlAttribute(required = true) - public String getType () { - return type; - } - - public void setType (String type) { - this.type = type; - } - - @XmlElement(required = true) - public String getHostname () { - return hostname; - } - - public void setHostname (String hostname) { - this.hostname = hostname; - } - - @XmlElement(required = false) - public String getServicename () { - return servicename; - } - - public void setServicename (String servicename) { - this.servicename = servicename; - } - - @XmlElement(required = true) - public int getState () { - return state; - } - - public void setState (int state) { - this.state = state; - } - - @XmlElement(required = true) - public String getOutput () { - return output; - } - - public void setOutput (String output) { - this.output = output; - } - } -} diff --git a/common/src/main/java/org/openecomp/mso/utils/CryptoUtils.java b/common/src/main/java/org/openecomp/mso/utils/CryptoUtils.java deleted file mode 100644 index 5d0ff5b79e..0000000000 --- a/common/src/main/java/org/openecomp/mso/utils/CryptoUtils.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.utils; - - - -import java.io.IOException; -import java.security.GeneralSecurityException; -import java.security.NoSuchAlgorithmException; - -import javax.crypto.Cipher; -import javax.crypto.spec.SecretKeySpec; - - -/** - * CryptoUtils adapted from RTTP client. - * - */ -public final class CryptoUtils { - - public static final String AES = "AES"; - - /** - * encrypt a value and generate a keyfile - * if the keyfile is not found then a new one is created - * - * @throws GeneralSecurityException - */ - public static String encrypt (String value, String keyString) throws GeneralSecurityException { - SecretKeySpec sks = getSecretKeySpec (keyString); - Cipher cipher = Cipher.getInstance (CryptoUtils.AES); - cipher.init (Cipher.ENCRYPT_MODE, sks, cipher.getParameters ()); - byte[] encrypted = cipher.doFinal (value.getBytes ()); - return byteArrayToHexString (encrypted); - } - - /** - * decrypt a value - * - * @throws GeneralSecurityException - */ - public static String decrypt (String message, String keyString) throws GeneralSecurityException { - SecretKeySpec sks = getSecretKeySpec (keyString); - Cipher cipher = Cipher.getInstance (CryptoUtils.AES); - cipher.init (Cipher.DECRYPT_MODE, sks); - byte[] decrypted = cipher.doFinal (hexStringToByteArray (message)); - return new String (decrypted); - } - - private static SecretKeySpec getSecretKeySpec (String keyString) throws NoSuchAlgorithmException { - byte[] key = hexStringToByteArray (keyString); - SecretKeySpec sks = new SecretKeySpec (key, CryptoUtils.AES); - return sks; - } - - public static String byteArrayToHexString (byte[] b) { - StringBuilder sb = new StringBuilder(b.length * 2); - for (byte aB : b) { - int v = aB & 0xff; - if (v < 16) { - sb.append('0'); - } - sb.append(Integer.toHexString(v)); - } - return sb.toString ().toUpperCase (); - } - - private static byte[] hexStringToByteArray (String s) { - byte[] b = new byte[s.length () / 2]; - for (int i = 0; i < b.length; i++) { - int index = i * 2; - int v = Integer.parseInt (s.substring (index, index + 2), 16); - b[i] = (byte) v; - } - return b; - } -} diff --git a/common/src/main/java/org/openecomp/mso/utils/RootIgnoringJsonDeserializer.java b/common/src/main/java/org/openecomp/mso/utils/RootIgnoringJsonDeserializer.java deleted file mode 100644 index 95f72c4dd4..0000000000 --- a/common/src/main/java/org/openecomp/mso/utils/RootIgnoringJsonDeserializer.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.utils; - -import java.io.IOException; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonRootName; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * A JSON deserializer that ignores the root element if it is present. - */ -public class RootIgnoringJsonDeserializer extends JsonDeserializer { - - private final ObjectMapper mapper = new ObjectMapper(); - private final Class clazz; - private final String jsonRootName; - - public RootIgnoringJsonDeserializer(Class clazz) { - this.clazz = clazz; - - JsonRootName annotation = clazz.getAnnotation(JsonRootName.class); - - if (annotation == null || annotation.value() == null || annotation.value().equals("")) { - jsonRootName = clazz.getSimpleName(); - } else { - jsonRootName = annotation.value(); - } - } - - @Override - public T deserialize(JsonParser jp, DeserializationContext dc) - throws IOException, JsonProcessingException { - JsonNode rootNode = jp.getCodec().readTree(jp); - Map.Entry field = rootNode.fields().next(); - - if (jsonRootName.equals(field.getKey())) { - rootNode = field.getValue(); - } - - return mapper.convertValue(rootNode, clazz); - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/utils/RootIgnoringObjectMapper.java b/common/src/main/java/org/openecomp/mso/utils/RootIgnoringObjectMapper.java deleted file mode 100644 index 6f3c5b7d99..0000000000 --- a/common/src/main/java/org/openecomp/mso/utils/RootIgnoringObjectMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.utils; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.module.SimpleModule; - -/** - * An ObjectMapper for a specific class that ignores the root element - * if it is present. - */ -public class RootIgnoringObjectMapper extends ObjectMapper { - - private static final long serialVersionUID = 6812584067195377395L; - - public RootIgnoringObjectMapper(Class clazz) { - SimpleModule module = new SimpleModule(); - module.addDeserializer(clazz, new RootIgnoringJsonDeserializer(clazz)); - registerModule(module); - } -} \ No newline at end of file diff --git a/common/src/main/java/org/openecomp/mso/utils/UUIDChecker.java b/common/src/main/java/org/openecomp/mso/utils/UUIDChecker.java deleted file mode 100644 index b715717924..0000000000 --- a/common/src/main/java/org/openecomp/mso/utils/UUIDChecker.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.utils; - -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -import java.util.UUID; - -/** - */ -public class UUIDChecker { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); - - private UUIDChecker() { - - } - - public static boolean isValidUUID (String id) { - try { - if (null == id) { - return false; - } - UUID uuid = UUID.fromString(id); - return uuid.toString().equalsIgnoreCase(id); - } catch (IllegalArgumentException iae) { - LOGGER.debug("IllegalArgumentException", iae); - return false; - } - } - - private static String getUUID () { - return UUID.randomUUID().toString(); - } - - public static String verifyOldUUID (String oldId, MsoLogger msoLogger) { - if (!UUIDChecker.isValidUUID(oldId)) { - String newId = UUIDChecker.getUUID(); - MsoLogger.setLogContext(newId, null); - msoLogger.info(MessageEnum.APIH_REPLACE_REQUEST_ID, oldId, "", ""); - return newId; - } - MsoLogger.setLogContext(oldId, null); - return oldId; - } - - public static String generateUUID (MsoLogger msoLogger) { - String newId = UUIDChecker.getUUID(); - MsoLogger.setLogContext(newId, null); - msoLogger.info(MessageEnum.APIH_GENERATED_REQUEST_ID, newId, "", ""); - return newId; - } - - public static String generateServiceInstanceID (MsoLogger msoLogger) { - String newId = UUIDChecker.getUUID(); - MsoLogger.setLogContext(null, newId); - msoLogger.info(MessageEnum.APIH_GENERATED_SERVICE_INSTANCE_ID, newId, "", ""); - return newId; - } -} diff --git a/common/src/main/resources/Policy.properties b/common/src/main/resources/Policy.properties index b5b38c465b..b82b7e4084 100644 --- a/common/src/main/resources/Policy.properties +++ b/common/src/main/resources/Policy.properties @@ -1,7 +1,7 @@ -HOST = https://mtanjvsgcvm02.nvp.cip.att.com:8081/pdp/api/getDecision -CLIENT_AUTH = Basic bTAzNzQzOnBvbGljeVIwY2sk -AUTHORIZATION = Basic dGVzdHBkcDphbHBoYTEyMw== -ENVIRONMENT = TEST -X_ECOMP_REQUESTID = 1234567h -ECOMP_COMPONENT_NAME = MSO +HOST = https://localhost:8081/pdp/api/getDecision +CLIENT_AUTH = Basic bTAzNzQzOnBvbGljeVIwY2sk +AUTHORIZATION = Basic dGVzdHBkcDphbHBoYTEyMw== +ENVIRONMENT = TEST +X_ECOMP_REQUESTID = 1234567h +ECOMP_COMPONENT_NAME = MSO ssl.key.store.password.key = javax.net.ssl.keyStorePassword \ No newline at end of file diff --git a/common/src/main/resources/dmaap/default-consumer.properties b/common/src/main/resources/dmaap/default-consumer.properties index 4d2ecce068..f19b64242d 100644 --- a/common/src/main/resources/dmaap/default-consumer.properties +++ b/common/src/main/resources/dmaap/default-consumer.properties @@ -10,7 +10,7 @@ SubContextPath=/events/ Protocol=http MethodType=GET contenttype=application/json -host=http://olsd005.wnsnet.attws.com:3904 +host=http://localhost:3904 partition=MSO maxBatchSize=100 maxAgeMs=250 diff --git a/common/src/main/resources/dmaap/default-publisher.properties b/common/src/main/resources/dmaap/default-publisher.properties index af1b481165..6d9be7528d 100644 --- a/common/src/main/resources/dmaap/default-publisher.properties +++ b/common/src/main/resources/dmaap/default-publisher.properties @@ -10,7 +10,7 @@ SubContextPath=/events/ Protocol=http MethodType=POST contenttype=application/json -host=http://olsd005.wnsnet.attws.com:3904 +host=http://localhost:3904 partition=MSO maxBatchSize=100 maxAgeMs=250 diff --git a/common/src/main/resources/test b/common/src/main/resources/test new file mode 100644 index 0000000000..7a8e433b1e --- /dev/null +++ b/common/src/main/resources/test @@ -0,0 +1,159 @@ + + 1 + 2 + 3 + 4 + 5 + 6 + 7 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 ${pattern} + 22 + 23 + 24 + 25 + 26 + 27 + 29 + 30 ${logDirectory}/${generalLogName}.log + 31 + 32 ${logDirectory}/${generalLogName}.%d{yyyy-MM-dd}.%i.log + 33 + 34 ${maxFileSize} + 35 + 36 ${maxHistory} + 37 ${totalSizeCap} + 38 + 39 + 40 ${pattern} + 41 + 42 + 43 + 44 + 45 + 46 INFO + 47 + 48 ${queueSize} + 49 + 50 + 51 + 52 ${logDirectory}/${auditLogName}.log + 53 + 54 ${logDirectory}/${auditLogName}.%d{yyyy-MM-dd}.%i.log + 55 + 56 ${maxFileSize} + 57 + 58 ${maxHistory} + 59 ${totalSizeCap} + 60 + 61 + 62 ${pattern} + 63 + 64 + 65 + 66 ${queueSize} + 67 + 68 + 69 + 70 ${logDirectory}/${metricsLogName}.log + 71 + 72 ${logDirectory}/${metricsLogName}.%d{yyyy-MM-dd}.%i.log + 73 + 74 ${maxFileSize} + 75 + 76 ${maxHistory} + 77 ${totalSizeCap} + 78 + 79 + 80 ${pattern} + 81 + 82 + 83 + 84 ${queueSize} + 85 + 86 + 87 + 88 ${logDirectory}/${debugLogName}.log + 89 + 90 ${logDirectory}/${debugLogName}.%d{yyyy-MM-dd}.%i.log + 91 + 92 ${maxFileSize} + 93 + 94 ${maxHistory} + 95 ${totalSizeCap} + 96 + 97 + 98 ${pattern} + 99 + 100 + 101 + 102 ${queueSize} + 103 + 104 true + 105 + 106 + 107 + 108 + 109 + 110 + 111 + 112 + 113 + 114 + 115 + 116 + 117 + 118 + 119 + 120 + 121 + 122 + 123 + 124 + 125 + 126 + 127 + 128 + 129 + 130 + 131 + 132 + 133 + 134 + 135 + 136 + 137 + 138 + 139 + 140 + 141 + 142 + 143 + 145 + 146 + 147 + 148 + 149 + 150 + 151 + 152 + 153 + 154 + 155 + 156 + 157 + 158 + 159 diff --git a/common/src/test/java/org/onap/so/BeansTest.java b/common/src/test/java/org/onap/so/BeansTest.java new file mode 100644 index 0000000000..2e825cf8c7 --- /dev/null +++ b/common/src/test/java/org/onap/so/BeansTest.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so; + +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.onap.so.openpojo.rules.HasAnnotationMatcher.hasAnnotation; +import static org.onap.so.openpojo.rules.HasAnnotationPropertyWithValueMatcher.hasAnnotationPropertyWithValue; + +import javax.persistence.Column; +import javax.persistence.Temporal; + +import org.junit.Test; +import org.onap.so.openpojo.rules.CustomSetterMustExistRule; +import org.onap.so.openpojo.rules.EqualsAndHashCodeTester; +import org.onap.so.openpojo.rules.HasEqualsAndHashCodeRule; +import org.onap.so.openpojo.rules.HasToStringRule; +import org.onap.so.openpojo.rules.ToStringTester; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoClassFilter; +import com.openpojo.reflection.filters.FilterEnum; +import com.openpojo.reflection.filters.FilterNonConcrete; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.BusinessKeyMustExistRule; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.NoNestedClassRule; +import com.openpojo.validation.rule.impl.NoPrimitivesRule; +import com.openpojo.validation.rule.impl.NoPublicFieldsExceptStaticFinalRule; +import com.openpojo.validation.rule.impl.NoStaticExceptFinalRule; +import com.openpojo.validation.rule.impl.SerializableMustHaveSerialVersionUIDRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + + +public class BeansTest { + + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + private PojoClassFilter enumFilter = new FilterEnum(); + + + + @Test + public void pojoStructure() { + test("org.onap.so.client.aai.objects"); + test("org.onap.so.client.policy.entities"); + test("org.onap.so.client.grm.beans"); + test("org.onap.so.client.ruby.beans"); + test("org.onap.so.client.sdno.beans"); + test("org.onap.so.entity"); + test("org.onap.so.serviceinstancebeans"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create() + .with(new GetterMustExistRule()) + .with(new NoNestedClassRule()) + .with(new NoStaticExceptFinalRule()) + .with(new SerializableMustHaveSerialVersionUIDRule()) + .with(new NoPublicFieldsExceptStaticFinalRule()) + .with(new SetterTester()) + .with(new GetterTester()) + + + + .build(); + + + validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses,enumFilter,new FilterNonConcrete()); + } + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } +} diff --git a/common/src/test/java/org/onap/so/adapter_utils/tests/CryptoTest.java b/common/src/test/java/org/onap/so/adapter_utils/tests/CryptoTest.java new file mode 100644 index 0000000000..15368f9966 --- /dev/null +++ b/common/src/test/java/org/onap/so/adapter_utils/tests/CryptoTest.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.adapter_utils.tests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.security.GeneralSecurityException; + +import org.junit.BeforeClass; +import org.junit.Test; + +import org.onap.so.utils.CryptoUtils; + +/** + * This class implements all test methods of the CryptoUtils features. + * + * + */ +public class CryptoTest { + + private static String testKey = "546573746F736973546573746F736973"; + + /** + * This method is called before any test occurs. + * It creates a fake tree from scratch + */ + @BeforeClass + public static final void prepare () { + + } + + /** + * This method implements a test of tree structure, mainly the storage of the leaves structure. + * @throws GeneralSecurityException + */ + @Test + public final void testEncryption () throws GeneralSecurityException { + String hexString = CryptoUtils.byteArrayToHexString("testosistestosi".getBytes()); + + final String testData = "This is a test string"; + final String nonTestData = "This is not the right String"; + + String encodeString = CryptoUtils.encrypt(testData, testKey); + + assertNotNull(encodeString); + + assertTrue(testData.equals(CryptoUtils.decrypt(encodeString, testKey))); + assertFalse(nonTestData.equals(CryptoUtils.decrypt(encodeString, testKey))); + + String encode2String = CryptoUtils.encrypt(testData, testKey); + assertNotNull(encode2String); + + assertEquals(encodeString,encode2String); + + assertEquals(CryptoUtils.decrypt(encodeString, testKey),CryptoUtils.decrypt(encode2String, testKey)); + + encodeString = CryptoUtils.encryptCloudConfigPassword(testData); + + assertEquals(testData, CryptoUtils.decryptCloudConfigPassword(encodeString)); + } + +} diff --git a/common/src/test/java/org/onap/so/adapter_utils/tests/MsoAlarmLoggerTest.java b/common/src/test/java/org/onap/so/adapter_utils/tests/MsoAlarmLoggerTest.java new file mode 100644 index 0000000000..6756bc98ad --- /dev/null +++ b/common/src/test/java/org/onap/so/adapter_utils/tests/MsoAlarmLoggerTest.java @@ -0,0 +1,134 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.adapter_utils.tests; + + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.so.logger.MsoAlarmLogger; + + +/** + * This junit test very roughly the alarm logger + * + */ +public class MsoAlarmLoggerTest { + + public static MsoAlarmLogger msoAlarmLogger; + + @BeforeClass + public static final void createObjects() throws IOException + { + + File outputFile = new File ("./target/alarm-test.log"); + if (outputFile.exists()) { + outputFile.delete(); + } else { + outputFile.createNewFile(); + } + msoAlarmLogger = new MsoAlarmLogger("./target/alarm-test.log"); + } + + @AfterClass + public static void tearDown() { + msoAlarmLogger.resetAppender(); + } + @Test + public void testAlarmConfig() throws IOException { + + msoAlarmLogger.sendAlarm("test", 0, "detail message"); + + FileInputStream inputStream = new FileInputStream("./target/alarm-test.log"); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + + String line = reader.readLine(); + String[] splitLine = line.split("\\|"); + assertTrue(splitLine.length==4); + assertTrue("test".equals(splitLine[1])); + assertTrue("0".equals(splitLine[2])); + assertTrue("detail message".equals(splitLine[3])); + + line = reader.readLine(); + assertNull(line); + reader.close(); + inputStream.close(); + + // Reset the file for others tests + PrintWriter writer = new PrintWriter(new File("./target/alarm-test.log")); + writer.print(""); + writer.close(); + + } + + @Test + public void testAlarm() throws IOException { + + msoAlarmLogger.sendAlarm("test", 0, "detail message"); + msoAlarmLogger.sendAlarm("test2", 1, "detail message2"); + msoAlarmLogger.sendAlarm("test3", 2, "detail message3"); + + FileInputStream inputStream = new FileInputStream("./target/alarm-test.log"); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + + String line = reader.readLine(); + String[] splitLine = line.split("\\|"); + assertTrue(splitLine.length==4); + assertTrue("test".equals(splitLine[1])); + assertTrue("0".equals(splitLine[2])); + assertTrue("detail message".equals(splitLine[3])); + + line = reader.readLine(); + splitLine = line.split("\\|"); + assertTrue(splitLine.length==4); + assertTrue("test2".equals(splitLine[1])); + assertTrue("1".equals(splitLine[2])); + assertTrue("detail message2".equals(splitLine[3])); + + line = reader.readLine(); + splitLine = line.split("\\|"); + assertTrue(splitLine.length==4); + assertTrue("test3".equals(splitLine[1])); + assertTrue("2".equals(splitLine[2])); + assertTrue("detail message3".equals(splitLine[3])); + + line = reader.readLine(); + assertNull(line); + reader.close(); + inputStream.close(); + + // Reset the file for others tests + PrintWriter writer = new PrintWriter(new File("./target/alarm-test.log")); + writer.print(""); + writer.close(); + + } +} diff --git a/common/src/test/java/org/onap/so/adapter_utils/tests/MsoLoggerTest.java b/common/src/test/java/org/onap/so/adapter_utils/tests/MsoLoggerTest.java new file mode 100644 index 0000000000..29ac91c864 --- /dev/null +++ b/common/src/test/java/org/onap/so/adapter_utils/tests/MsoLoggerTest.java @@ -0,0 +1,331 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.adapter_utils.tests; + +import org.onap.so.entity.MsoRequest; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; +import org.onap.so.logger.MsoLogger.ErrorCode; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.slf4j.MDC; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URL; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +/** + * This class implements all test methods of the MsoLogger features. + * + * + */ +public class MsoLoggerTest { + + static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, MsoLoggerTest.class); + + /** + * This method is called before any test occurs. It creates a fake tree from + * scratch + */ + @BeforeClass + public static final void prepare() { + + } + + @Before + public final void cleanErrorLogFile() throws FileNotFoundException { + URL url = this.getClass().getClassLoader().getResource("logback-test.xml"); + String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) + + "/MSO/Test/errorjboss.server.name_IS_UNDEFINED.log"; + PrintWriter asdcConfigFileWriter = new PrintWriter(logFile); + asdcConfigFileWriter.print(""); + asdcConfigFileWriter.flush(); + asdcConfigFileWriter.close(); + } + + @Before + public final void cleanMetricLogFile() throws FileNotFoundException { + URL url = this.getClass().getClassLoader().getResource("logback-test.xml"); + String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) + + "/MSO/Test/metricsjboss.server.name_IS_UNDEFINED.log"; + PrintWriter asdcConfigFileWriter = new PrintWriter(logFile); + asdcConfigFileWriter.print(""); + asdcConfigFileWriter.flush(); + asdcConfigFileWriter.close(); + } + + @Before + public final void cleanAuditLogFile() throws FileNotFoundException { + URL url = this.getClass().getClassLoader().getResource("logback-test.xml"); + String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) + + "/MSO/Test/auditjbo.server.name_IS_UNDEFINED.log"; + PrintWriter asdcConfigFileWriter = new PrintWriter(logFile); + asdcConfigFileWriter.print(""); + asdcConfigFileWriter.flush(); + asdcConfigFileWriter.close(); + } + + /** + * This method implements a test of getSeverifyLevel method. + */ + @Test + public final void testGetSeverityLevel() { + + try { + String levelInfo = (String) invokePriveMethod("getSeverityLevel", "INFO"); + Assert.assertEquals(levelInfo, "0"); + + String levelWarn = (String) invokePriveMethod("getSeverityLevel", "WARN"); + Assert.assertEquals(levelWarn, "1"); + + String levelERROR = (String) invokePriveMethod("getSeverityLevel", "ERROR"); + Assert.assertEquals(levelERROR, "2"); + + String levelDEBUG = (String) invokePriveMethod("getSeverityLevel", "DEBUG"); + Assert.assertEquals(levelDEBUG, "0"); + + String levelFATAL = (String) invokePriveMethod("getSeverityLevel", "FATAL"); + Assert.assertEquals(levelFATAL, "3"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * This method implements a test of getFinalServiceName method. + */ + @Test + public final void testGetFinalServiceName() { + try { + String serviceName1 = (String) invokePriveMethod("getFinalServiceName", "testServiceName1"); + Assert.assertEquals(serviceName1, "testServiceName1"); + + MsoLogger.setServiceName("testServiceName2"); + String serviceName2 = (String) invokePriveMethod("getFinalServiceName", "testServiceName1"); + Assert.assertEquals(serviceName2, "testServiceName1"); + + String msgNull = null; + String serviceName3 = (String) invokePriveMethod("getFinalServiceName", msgNull); + Assert.assertEquals(serviceName3, "testServiceName2"); + + MsoLogger.resetServiceName(); + String serviceName4 = (String) invokePriveMethod("getFinalServiceName", msgNull); + Assert.assertEquals(serviceName4, "invoke0"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public final void testPrepareMsg() { + try { + String msgNull = null; + MDC.clear(); + invokePrepareMsg("INFO", null, null); + + Assert.assertTrue(MDC.get(MsoLogger.REQUEST_ID).equals("trace-#") + && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("trace-#") + && MDC.get(MsoLogger.SERVICE_NAME).equals("invoke0") && MDC.get(MsoLogger.TIMER) == null + && MDC.get(MsoLogger.ALERT_SEVERITY).equals("0")); + + MsoLogger.setLoggerParameters("testRemoteIp", "testUser"); + MsoLogger.setLogContext("testReqId", "testSvcId"); + invokePrepareMsg("ERROR", "testServiceName3", null); + Assert.assertTrue(MDC.get(MsoLogger.REQUEST_ID).equals("testReqId") + && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("testSvcId") + && MDC.get(MsoLogger.SERVICE_NAME).equals("testServiceName3") && MDC.get(MsoLogger.TIMER) == null + && MDC.get(MsoLogger.ALERT_SEVERITY).equals("2")); + + MsoLogger.setServiceName("testServiceName2"); + invokePrepareMsg("WARN", msgNull, msgNull); + Assert.assertTrue(MDC.get(MsoLogger.REQUEST_ID).equals("testReqId") + && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("testSvcId") + && MDC.get(MsoLogger.SERVICE_NAME).equals("testServiceName2") && MDC.get(MsoLogger.TIMER) == null + && MDC.get(MsoLogger.ALERT_SEVERITY).equals("1")); + + MDC.clear(); + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId("reqId2"); + msoRequest.setServiceInstanceId("servId2"); + MsoLogger.setLogContext(msoRequest); + invokePrepareMsg("FATAL", null, "123"); + Assert.assertTrue(MDC.get(MsoLogger.REQUEST_ID).equals("reqId2") + && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("servId2") + && MDC.get(MsoLogger.TIMER).equals("123") && MDC.get(MsoLogger.ALERT_SEVERITY).equals("3")); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * This method implements a test of log methods + */ + @Test + @Ignore + public final void testLogMethods() { + try { + MDC.clear(); + MsoLogger.setLogContext("reqId2", "servId2"); + MsoLogger.setServiceName("MSO.testServiceName"); + msoLogger.info(MessageEnum.LOGGER_UPDATE_SUC, "testLogger", "INFO", "DEBUG", "target entity", + "target service"); + msoLogger.warn(MessageEnum.GENERAL_WARNING, "warning test", "", "", MsoLogger.ErrorCode.UnknownError, + "warning test"); + msoLogger.error(MessageEnum.GENERAL_EXCEPTION, "target entity", "target service", + MsoLogger.ErrorCode.UnknownError, "error test"); + + // Fetch from the error log + URL url = this.getClass().getClassLoader().getResource("logback-test.xml"); + String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) + + "/MSO/Test/errorjboss.server.name_IS_UNDEFINED.log"; + + Path filePath = new File(logFile).toPath(); + Charset charset = Charset.defaultCharset(); + List stringList = Files.readAllLines(filePath, charset); + String[] stringArray = stringList.toArray(new String[] {}); + int size = stringArray.length; + + Assert.assertTrue(stringArray[size - 3] + .contains("|reqId2|main|MSO.testServiceName||target entity|target service|INFO|null||") + && stringArray[size - 3].contains( + "||MSO-GENERAL-5408I Successfully update Logger: testLogger from level INFO to level DEBUG")); + Assert.assertTrue(stringArray[size - 2] + .contains("|reqId2|main|MSO.testServiceName||||WARN|UnknownError|warning test|") + && stringArray[size - 2].contains("|MSO-GENERAL-5401W WARNING: warning test")); + Assert.assertTrue(stringArray[size - 1].contains( + "|reqId2|main|MSO.testServiceName||target entity|target service|ERROR|UnknownError|error test|") + && stringArray[size - 1].contains("|MSO-GENERAL-9401E Exception encountered")); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * This method implements a test of recordMetricEvent method. + * + * @throws IOException + */ + @Test + @Ignore + public final void testRecordMetricEvent() throws IOException { + MDC.clear(); + MsoLogger.setLogContext("reqId", "servId"); + msoLogger.recordMetricEvent(123456789L, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful", + "VNF", "createVNF", null); + MDC.put(MsoLogger.REMOTE_HOST, "127.0.0.1"); + MDC.put(MsoLogger.PARTNERNAME, "testUser"); + msoLogger.recordMetricEvent(123456789L, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.ServiceNotAvailable, + "Exception", "SDNC", "removeSDNC", "testVNF"); + + // Fetch from the metric log + URL url = this.getClass().getClassLoader().getResource("logback-test.xml"); + String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) + + "/MSO/Test/metricsjboss.server.name_IS_UNDEFINED.log"; + + Path filePath = new File(logFile).toPath(); + Charset charset = Charset.defaultCharset(); + List stringList = Files.readAllLines(filePath, charset); + String[] stringArray = stringList.toArray(new String[] {}); + msoLogger.error(MessageEnum.GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.UnknownError, "test error msg"); + + Assert.assertTrue(stringArray[0] + .contains("|reqId|servId|main||testRecordMetricEvent||VNF|createVNF|COMPLETE|0|Successful|")); + // count the occurance of symbol "|" + Assert.assertTrue((stringArray[0].length() - stringArray[0].replace("|", "").length()) == 28); + Assert.assertTrue(stringArray[1] + .contains("|reqId|servId|main||testRecordMetricEvent|testUser|SDNC|removeSDNC|ERROR|501|Exception|") + && stringArray[1].contains("|127.0.0.1||||testVNF|||||")); + Assert.assertTrue((stringArray[1].length() - stringArray[1].replace("|", "").length()) == 28); + } + + /** + * This method implements a test of testRecordAuditEvent method. + */ + + // User reflection to invoke to avoid change the publicity of the method + private static String invokePrepareMsg(String arg1, String arg2, String arg3) { + Method method; + try { + method = MsoLogger.class.getDeclaredMethod("prepareMsg", String.class, String.class, String.class); + method.setAccessible(true); + return (String) method.invoke(msoLogger, arg1, arg2, arg3); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + // User reflection to invoke to avoid change the publicity of the method + private static Object invokePriveMethod(String methodName, String arg) { + Method method; + try { + method = MsoLogger.class.getDeclaredMethod(methodName, String.class); + method.setAccessible(true); + return method.invoke(msoLogger, arg); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } +} diff --git a/common/src/test/java/org/onap/so/client/RestClientTest.java b/common/src/test/java/org/onap/so/client/RestClientTest.java new file mode 100644 index 0000000000..1443f04f3a --- /dev/null +++ b/common/src/test/java/org/onap/so/client/RestClientTest.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.net.MalformedURLException; +import java.net.SocketTimeoutException; + +import javax.ws.rs.NotFoundException; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriBuilderException; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.so.utils.TargetEntity; + +@RunWith(MockitoJUnitRunner.class) +public class RestClientTest { + + + @Mock + private RestProperties props; + + + @Test + public void retries() throws Exception { + RestClient spy = buildSpy(); + RestRequest mockCallable = mock(RestRequest.class); + when(mockCallable.call()).thenThrow(new WebApplicationException(new SocketTimeoutException())); + doReturn(mockCallable).when(spy).buildRequest(any(String.class), any(Object.class)); + try { + spy.get(); + } catch (Exception e) { + //we expect an exception, ignore it + } + verify(mockCallable, times(3)).call(); + + } + + @Test + public void exceptionDoNotRetry() throws Exception { + RestClient spy = buildSpy(); + RestRequest mockCallable = mock(RestRequest.class); + when(mockCallable.call()).thenThrow(new WebApplicationException(new NotFoundException())); + doReturn(mockCallable).when(spy).buildRequest(any(String.class), any(Object.class)); + try { + spy.get(); + } catch (Exception e) { + //we expect an exception, ignore it + } + verify(mockCallable, times(1)).call(); + + } + private RestClient buildSpy() throws MalformedURLException, IllegalArgumentException, UriBuilderException { + RestClient client = new HttpClient(UriBuilder.fromUri("http://localhost/test").build().toURL(), "application/json", TargetEntity.BPMN); + + return spy(client); + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAIClientResponseExceptionMapperTest.java b/common/src/test/java/org/onap/so/client/aai/AAIClientResponseExceptionMapperTest.java new file mode 100644 index 0000000000..981a4ddacc --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAIClientResponseExceptionMapperTest.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.onap.so.client.aai.entities.AAIError; +import org.onap.so.client.aai.entities.RequestError; +import org.onap.so.client.aai.entities.ServiceException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class AAIClientResponseExceptionMapperTest { + + AAIClientResponseExceptionMapper mapper; + String errorMsg; + + @Before + public void before() { + mapper = new AAIClientResponseExceptionMapper(); + errorMsg = "Error calling A&AI. Request-Id=" + mapper.getRequestId() + " "; + } + + @Test + public void testExtractMessageWithEntity() throws JsonProcessingException { + ServiceException svcException = new ServiceException(); + svcException.setText("test %1 message - %2"); + svcException.setVariables(Arrays.asList("error", "service exception %1 test")); + + RequestError requestError = new RequestError(); + requestError.setServiceException(svcException); + + AAIError error = new AAIError(); + error.setRequestError(requestError); + + ObjectMapper objMapper = new ObjectMapper(); + String strRequestError = objMapper.writeValueAsString(error); + + assertEquals(errorMsg + "test error message - service exception error test", mapper.extractMessage(strRequestError).get()); + } + + @Test + public void testExtractMessageWithoutEntity() { + assertEquals(errorMsg, mapper.extractMessage("").get()); + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java new file mode 100644 index 0000000000..40410019f0 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAIConfigurationClientTest.java @@ -0,0 +1,181 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.isA; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.util.Optional; +import java.util.UUID; + +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.so.client.aai.entities.Configuration; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.RequestDetails; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; +@RunWith(MockitoJUnitRunner.class) +public class AAIConfigurationClientTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443)); + + @Mock + AAIResourcesClient aaiClient; + + @InjectMocks + AAIConfigurationClient aaiConfigurationClient = new AAIConfigurationClient(); + + @Test + public void verifyCreate() { + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelInvariantId("testInvariantID"); + modelInfo.setModelVersionId("testVersionID"); + modelInfo.setModelCustomizationId("testCustomizationID"); + + RequestDetails requestDetails = new RequestDetails(); + requestDetails.setModelInfo(modelInfo); + + String configurationId = UUID.randomUUID().toString(); + String configurationType = "test"; + String configurationSubType = "test"; + + // Test Create Configuration + doNothing().when(aaiClient).create(isA(AAIResourceUri.class), isA(Object.class)); + aaiConfigurationClient.createConfiguration(requestDetails, configurationId, configurationType, configurationSubType); + verify(aaiClient, times(1)).create(isA(AAIResourceUri.class), isA(Object.class)); + } + + @Test + public void verifyConfigurePayload() { + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelInvariantId("testInvariantID"); + modelInfo.setModelVersionId("testVersionID"); + modelInfo.setModelCustomizationId("testCustomizationID"); + + RequestDetails requestDetails = new RequestDetails(); + requestDetails.setModelInfo(modelInfo); + + String configurationId = UUID.randomUUID().toString(); + String configurationType = "test"; + String configurationSubType = "test"; + AAIResourceUri uri = aaiConfigurationClient.getConfigurationURI(configurationId); + + Configuration payload = aaiConfigurationClient.configurePayload(requestDetails, configurationId, configurationType, configurationSubType); + + assertEquals(configurationId, payload.getConfigurationId()); + assertEquals(configurationType, payload.getConfigurationType()); + assertEquals(configurationSubType, payload.getConfigurationSubType()); + assertEquals(uri.build().getPath(), payload.getConfigurationSelflink()); + assertEquals("PreCreated", payload.getOrchestrationStatus()); + assertEquals("", payload.getOperationalStatus()); + assertEquals(modelInfo.getModelVersionId(), payload.getModelVersionId()); + assertEquals(modelInfo.getModelInvariantId(), payload.getModelInvariantId()); + assertEquals(modelInfo.getModelCustomizationId(), payload.getModelCustomizationId()); + } + + @Test + public void testDeleteConfiguration() { + String uuid = UUID.randomUUID().toString(); + doNothing().when(aaiClient).delete(isA(AAIResourceUri.class)); + aaiConfigurationClient.deleteConfiguration(uuid); + verify(aaiClient, times(1)).delete(aaiConfigurationClient.getConfigurationURI(uuid)); + } + + @Test + public void testUpdateOrchestrationStatus() { + String uuid = UUID.randomUUID().toString(); + doNothing().when(aaiClient).update(isA(AAIResourceUri.class), isA(Object.class)); + aaiConfigurationClient.updateOrchestrationStatus(uuid, "testPayload"); + verify(aaiClient, times(1)).update(aaiConfigurationClient.getConfigurationURI(uuid), "testPayload"); + } + + @SuppressWarnings("unchecked") + @Test + public void testGetConfiguration() { + String uuid = UUID.randomUUID().toString(); + Optional expectedConfiguration = Optional.of(new Configuration()); + expectedConfiguration.get().setConfigurationId(uuid); + + doReturn(expectedConfiguration).when(aaiClient).get(isA(Class.class), isA(AAIResourceUri.class)); + Configuration actualConfiguration = aaiConfigurationClient.getConfiguration(uuid); + verify(aaiClient, times(1)).get(Configuration.class, aaiConfigurationClient.getConfigurationURI(uuid)); + assertEquals(expectedConfiguration.get(), actualConfiguration); + } + + @Test + public void testConfigurationExists() { + String uuid = UUID.randomUUID().toString(); + AAIResourceUri uri = aaiConfigurationClient.getConfigurationURI(uuid); + boolean expectedResult; + boolean actualResult; + + expectedResult = true; + doReturn(expectedResult).when(aaiClient).exists(isA(AAIResourceUri.class)); + actualResult = aaiConfigurationClient.configurationExists(uuid); + assertEquals(expectedResult, actualResult); + + expectedResult = false; + doReturn(expectedResult).when(aaiClient).exists(isA(AAIResourceUri.class)); + actualResult = aaiConfigurationClient.configurationExists(uuid); + assertEquals(expectedResult, actualResult); + + verify(aaiClient, times(2)).exists(uri); + } + + @Test + public void testGetConfigurationURI() { + String uuid = UUID.randomUUID().toString(); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, uuid); + assertEquals(uri, aaiConfigurationClient.getConfigurationURI(uuid)); + } + + @Test + public void verifyNotExists() { + AAIUri path = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "test2"); + wireMockRule.stubFor(get( + urlMatching("/aai/v[0-9]+" + path.build() + ".*")) + .willReturn( + aResponse() + .withHeader("Content-Type", "text/plain") + .withBody("hello") + .withStatus(404))); + boolean result = aaiConfigurationClient.configurationExists("test2"); + assertEquals("path not found", false, result); + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAIErrorFormatterTest.java b/common/src/test/java/org/onap/so/client/aai/AAIErrorFormatterTest.java new file mode 100644 index 0000000000..bea927afa5 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAIErrorFormatterTest.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.onap.so.client.aai.entities.AAIError; +import org.onap.so.client.aai.entities.RequestError; +import org.onap.so.client.aai.entities.ServiceException; + +public class AAIErrorFormatterTest { + + @Mock private AAIError errorObj; + + @Before + public void init() { + MockitoAnnotations.initMocks(this); + } + @Test + public void testFillInTemplateWithReplace() { + String error = "Error %1 on %2"; + List list = Arrays.asList("PUT", "hello %1"); + AAIErrorFormatter formatter = new AAIErrorFormatter(errorObj); + String result = formatter.fillInTemplate(error, list); + assertEquals("equal", "Error PUT on hello PUT", result); + + } + + @Test + public void testFillInTemplateWithoutReplace() { + String error = "Error"; + List list = new ArrayList<>(); + AAIErrorFormatter formatter = new AAIErrorFormatter(errorObj); + String result = formatter.fillInTemplate(error, list); + assertEquals("equal", "Error", result); + } + + @Test + public void testGetMessage() { + ServiceException svcException = new ServiceException(); + svcException.setText("test %1 message - %2"); + svcException.setVariables(Arrays.asList("error", "service exception %1 test")); + + RequestError requestError = new RequestError(); + requestError.setServiceException(svcException); + + doReturn(requestError).when(errorObj).getRequestError(); + + AAIErrorFormatter formatter = new AAIErrorFormatter(errorObj); + String result = formatter.getMessage(); + assertEquals("equal", "test error message - service exception error test", result); + } + + @Test + public void testGetMessageNoParsable() { + errorObj.setRequestError(null); + AAIErrorFormatter formatter = new AAIErrorFormatter(errorObj); + String result = formatter.getMessage(); + assertEquals("equal", "no parsable error message found", result); + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java b/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java new file mode 100644 index 0000000000..ce90ccdc0e --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.so.client.aai.entities.uri.AAIUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; + +public class AAIObjectTypeTest { + + @Test + public void verifyDefaultCase() { + assertEquals("default removed for tenant", "tenant", AAIObjectType.DEFAULT_TENANT.typeName()); + assertEquals("default removed for cloud-region", "cloud-region", AAIObjectType.DEFAULT_CLOUD_REGION.typeName()); + } + + @Test + public void verifyRegularCase() { + assertEquals("default removed for tenant", "allotted-resource", AAIObjectType.ALLOTTED_RESOURCE.typeName()); + } + + @Test + public void instanceGroupObjectTypeTest() { + final String id = "test1"; + AAIUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, id); + assertEquals("/network/instance-groups/instance-group/test1", aaiUri.build().toString()); + } + + @Test + public void collectionObjectTypeTest() { + final String id = "test1"; + AAIUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, id); + assertEquals("/network/collections/collection/test1", aaiUri.build().toString()); + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAIPServerTest.java b/common/src/test/java/org/onap/so/client/aai/AAIPServerTest.java new file mode 100644 index 0000000000..1e2e7471f1 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAIPServerTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.NoSuchAlgorithmException; +import java.util.List; +import java.util.UUID; + +import org.junit.Ignore; +import org.junit.Test; +import org.onap.aai.domain.yang.Pserver; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +public class AAIPServerTest { + + @Test + public void pserverTest() throws JsonParseException, JsonMappingException, IOException, NoSuchAlgorithmException { + AAIRestClientImpl client = new AAIRestClientImpl(); + String json = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/aai/pserver.json"))); + List list = client.getListOfPservers(json); + + assertEquals("", list.get(0).getHostname(), "test"); + } + + @Test + @Ignore // IGNORED FOR 1710 MERGE TO ONAP + public void pserverActualTest() throws JsonParseException, JsonMappingException, IOException, NoSuchAlgorithmException { + AAIRestClientImpl client = new AAIRestClientImpl(); + List list = client.getPhysicalServerByVnfId("d946afed-8ebe-4c5d-9665-54fcc043b8e7", UUID.randomUUID().toString()); + assertEquals("", list.size(), 0); + } + +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java new file mode 100644 index 0000000000..6e9c38517d --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.eq; +import static org.mockito.Matchers.isA; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.util.Arrays; +import java.util.List; + +import javax.ws.rs.core.Response; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.so.client.RestClient; +import org.onap.so.client.aai.entities.CustomQuery; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.graphinventory.Format; + + +@RunWith(MockitoJUnitRunner.class) +public class AAIQueryClientTest { + + @Mock + Response response; + + @Mock + RestClient restClient; + + @Spy + AAIQueryClient aaiQueryClient = new AAIQueryClient(); + + @Test + public void testQuery() { + List uris = Arrays.asList(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY)); + + Format format = Format.SIMPLE; + CustomQuery query = new CustomQuery(uris); + + doReturn(restClient).when(aaiQueryClient).createClient(isA(AAIUri.class)); + aaiQueryClient.query(format, query); + verify(aaiQueryClient, times(1)).createClient(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY).queryParam("format", format.toString())); + verify(restClient, times(1)).put(query, String.class); + } + + @Test + public void testCreateClient() { + String depth = "testDepth"; + AAISubgraphType subgraph = AAISubgraphType.STAR; + + aaiQueryClient.depth(depth); + aaiQueryClient.nodesOnly(); + aaiQueryClient.subgraph(subgraph); + + AAIUri aaiUri = spy(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY)); + doReturn(aaiUri).when(aaiUri).clone(); + aaiQueryClient.setupQueryParams(aaiUri); + + verify(aaiUri, times(1)).queryParam("depth", depth); + verify(aaiUri, times(1)).queryParam("nodesOnly", ""); + verify(aaiUri, times(1)).queryParam("subgraph", subgraph.toString()); + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java new file mode 100644 index 0000000000..63f8f652ce --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java @@ -0,0 +1,191 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.delete; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl; + +import com.github.tomakehurst.wiremock.admin.NotFoundException; +import com.github.tomakehurst.wiremock.junit.WireMockRule; +public class AAIResourcesClientTest { + + + @Rule + public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443)); + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void verifyNotExists() { + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test"); + wireMockRule.stubFor(get( + urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())) + .willReturn( + aResponse() + .withHeader("Content-Type", "text/plain") + .withBody("hello") + .withStatus(404))); + AAIResourcesClient client= createClient(); + boolean result = client.exists(path); + assertEquals("path not found", false, result); + } + + @Test + public void verifyDelete() { + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2"); + wireMockRule.stubFor(get( + urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())) + .willReturn( + aResponse() + .withHeader("Content-Type", "application/json") + .withBodyFile("aai/resources/mockObject.json") + .withStatus(200))); + wireMockRule.stubFor(delete( + urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())) + .withQueryParam("resource-version", equalTo("1234")) + .willReturn( + aResponse() + .withStatus(204))); + AAIResourcesClient client= createClient(); + client.delete(path); + } + + @Test + public void verifyBasicAuth() { + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); + wireMockRule.stubFor(get( + urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString())) + .withHeader("Authorization", equalTo("Basic TVNPOk1TTw==")) + .willReturn( + aResponse() + .withHeader("Content-Type", "application/json") + .withBodyFile("aai/resources/mockObject.json") + .withStatus(200))); + AAIResourcesClient client= createClient(); + client.get(path); + } + + @Test + public void verifyConnect() { + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2"); + AAIResourceUri path2 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); + wireMockRule.stubFor(put( + urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build() + "/relationship-list/relationship")) + .willReturn( + aResponse() + .withHeader("Content-Type", "application/json") + .withStatus(200))); + + AAIResourceUri pathClone = path.clone(); + AAIResourcesClient client= createClient(); + client.connect(path, path2); + assertEquals("uri not modified", pathClone.build().toString(), path.build().toString()); + } + + @Test + public void verifyDisconnect() { + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2"); + AAIResourceUri path2 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); + + wireMockRule.stubFor(post( + urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build() + "/relationship-list/relationship")) + .willReturn( + aResponse() + .withStatus(204))); + + AAIResourceUri pathClone = path.clone(); + AAIResourcesClient client= createClient(); + client.disconnect(path, path2); + assertEquals("uri not modified", pathClone.build().toString(), path.build().toString()); + } + + @Test + public void verifyPatch() { + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2"); + + wireMockRule.stubFor(post( + urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())) + .willReturn( + aResponse() + .withStatus(200))); + + AAIResourcesClient client= createClient(); + + client.update(path, "{}"); + } + + @Test + public void verifyNotExistsGet() { + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test"); + wireMockRule.stubFor(get( + urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())) + .willReturn( + aResponse() + .withHeader("Content-Type", "text/plain") + .withBody("hello") + .withStatus(404))); + AAIResourcesClient client= createClient(); + AAIResultWrapper result = client.get(path); + assertEquals("is empty", true, result.isEmpty()); + } + + @Test + public void verifyNotExistsGetException() { + AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test"); + wireMockRule.stubFor(get( + urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build())) + .willReturn( + aResponse() + .withHeader("Content-Type", "text/plain") + .withBody("hello") + .withStatus(404))); + AAIResourcesClient client= createClient(); + thrown.expect(NotFoundException.class); + thrown.expectMessage(containsString(path.build() + " not found in A&AI")); + AAIResultWrapper result = client.get(path, NotFoundException.class); + } + + private AAIResourcesClient createClient() { + AAIResourcesClient client = spy(new AAIResourcesClient()); + doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties(); + return client; + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java new file mode 100644 index 0000000000..f2e371c999 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java @@ -0,0 +1,124 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.client.aai; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; + +import javax.ws.rs.core.Response; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.client.graphinventory.exceptions.GraphInventoryPatchDepthExceededException; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(MockitoJUnitRunner.class) +public class AAIRestClientTest { + + @Mock + private AAIProperties props; + + private ObjectMapper mapper = new AAICommonObjectMapperProvider().getMapper(); + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void convertObjectToPatchFormatTest() throws URISyntaxException, JsonParseException, JsonMappingException, IOException { + AAIRestClient client = new AAIRestClient(props, new URI("")); + GenericVnf vnf = new GenericVnf(); + vnf.setIpv4Loopback0Address(""); + String result = client.convertObjectToPatchFormat(vnf); + GenericVnf resultObj = mapper.readValue(result.toString(), GenericVnf.class); + assertTrue("expect object to become a String to prevent double marshalling", result instanceof String); + assertNull("expect null because of custom mapper", resultObj.getIpv4Loopback0Address()); + + } + + @Test + public void convertStringToPatchFormatTest() throws URISyntaxException, JsonParseException, JsonMappingException, IOException { + AAIRestClient client = new AAIRestClient(props, new URI("")); + String payload = "{\"ipv4-loopback0-address\":\"\"}"; + String result = client.convertObjectToPatchFormat(payload); + + assertEquals("expect no change", payload, result); + } + + @Test + public void convertMapToPatchFormatTest() throws URISyntaxException, JsonParseException, JsonMappingException, IOException { + AAIRestClient client = new AAIRestClient(props, new URI("")); + HashMap map = new HashMap<>(); + map.put("ipv4-loopback0-address", ""); + String result = client.convertObjectToPatchFormat(map); + + assertEquals("expect string", "{\"ipv4-loopback0-address\":\"\"}", result); + } + + @Test + public void failPatchOnComplexObject() throws URISyntaxException { + AAIRestClient client = new AAIRestClient(props, new URI("")); + this.thrown.expect(GraphInventoryPatchDepthExceededException.class); + this.thrown.expectMessage(containsString("Object exceeds allowed depth for update action")); + client.patch("{ \"hello\" : \"world\", \"nestedSimple\" : [\"value1\" , \"value2\"], \"relationship-list\" : [{\"key\" : \"value\"}], \"nested\" : { \"key\" : \"value\" }}"); + + } + + @Test + public void hasComplexObjectTest() throws URISyntaxException { + AAIRestClient client = new AAIRestClient(props, new URI("")); + String hasNesting = "{ \"hello\" : \"world\", \"nested\" : { \"key\" : \"value\" } }"; + String noNesting = "{ \"hello\" : \"world\" }"; + String arrayCase = "{ \"hello\" : \"world\", \"nestedSimple\" : [\"value1\" , \"value2\"], \"nestedComplex\" : [{\"key\" : \"value\"}]}"; + String empty = "{}"; + String arrayCaseSimpleOnly = "{ \"hello\" : \"world\", \"nestedSimple\" : [\"value1\" , \"value2\"]}"; + String relationshipListCaseNesting = "{ \"hello\" : \"world\", \"nestedSimple\" : [\"value1\" , \"value2\"], \"relationship-list\" : [{\"key\" : \"value\"}], \"nested\" : { \"key\" : \"value\" }}"; + String relationshipListCase = "{ \"hello\" : \"world\", \"nestedSimple\" : [\"value1\" , \"value2\"], \"relationship-list\" : [{\"key\" : \"value\"}]}"; + String nothing = ""; + + assertTrue("expect has nesting", client.hasComplexObject(hasNesting)); + assertFalse("expect no nesting", client.hasComplexObject(noNesting)); + assertTrue("expect has nesting", client.hasComplexObject(arrayCase)); + assertFalse("expect no nesting", client.hasComplexObject(empty)); + assertFalse("expect no nesting", client.hasComplexObject(arrayCaseSimpleOnly)); + assertFalse("expect no nesting", client.hasComplexObject(relationshipListCase)); + assertTrue("expect has nesting", client.hasComplexObject(relationshipListCaseNesting)); + assertFalse("expect no nesting", client.hasComplexObject(nothing)); + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java new file mode 100644 index 0000000000..f6ee826a78 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java @@ -0,0 +1,148 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import org.junit.Before; +import org.junit.Test; + +import org.onap.aai.domain.yang.Relationship; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +public class AAITransactionalClientTest { + + private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/bulkprocess/"; + AAIResourceUri uriA = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); + AAIResourceUri uriB = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test2"); + AAIResourceUri uriC = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); + AAIResourceUri uriD = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test4"); + AAIResourceUri uriE = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test5"); + AAIResourceUri uriF = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test6"); + + ObjectMapper mapper; + + @Before + public void before() throws JsonParseException, JsonMappingException, IOException { + mapper = new AAICommonObjectMapperProvider().getMapper(); + mapper.enable(SerializationFeature.INDENT_OUTPUT); + } + + @Test + public void testCreate() throws IOException { + final Relationship body = new Relationship(); + body.setRelatedLink(uriB.build().toString()); + + AAITransactionalClient transactions = createClient().beginTransaction() + .create(uriA.clone().relationshipAPI(), body); + + String serializedTransactions = mapper.writeValueAsString(transactions.getTransactions()); + Map actual = mapper.readValue(serializedTransactions, new TypeReference>(){}); + Map expected = mapper.readValue(getJson("test-request-small.json"), new TypeReference>(){}); + + assertEquals(actual, expected); + } + + @Test + public void testConnect() throws IOException { + List uris = new ArrayList(); + uris.add(uriB); + + AAIResourceUri uriAClone = uriA.clone(); + AAITransactionalClient transactions = createClient() + .beginTransaction().connect(uriA, uris).connect(uriC, uriD) + .beginNewTransaction().connect(uriE, uriF); + + String serializedTransactions = mapper.writeValueAsString(transactions.getTransactions()); + Map actual = mapper.readValue(serializedTransactions, new TypeReference>(){}); + Map expected = mapper.readValue(getJson("test-request.json"), new TypeReference>(){}); + + assertEquals(actual, expected); + assertEquals("uri not manipulated", uriAClone.build().toString(), uriA.build().toString()); + } + + @Test + public void testDisconnect() throws IOException { + List uris = new ArrayList(); + uris.add(uriB); + + AAITransactionalClient transactions = createClient().beginTransaction() + .disconnect(uriA, uris); + + String serializedTransactions = mapper.writeValueAsString(transactions.getTransactions()); + Map actual = mapper.readValue(serializedTransactions, new TypeReference>(){}); + Map expected = mapper.readValue(getJson("test-request-small.json").replace("put", "delete"), new TypeReference>(){}); + + assertEquals(actual, expected); + } + + @Test + public void testUpdate() throws IOException { + final Relationship body = new Relationship(); + body.setRelatedLink(uriB.build().toString()); + + AAIResourceUri uriAClone = uriA.clone().relationshipAPI(); + AAITransactionalClient transactions = createClient().beginTransaction().update(uriAClone, body); + + String serializedTransactions = mapper.writeValueAsString(transactions.getTransactions()); + Map actual = mapper.readValue(serializedTransactions, new TypeReference>(){}); + Map expected = mapper.readValue(getJson("test-request-small.json").replace("put", "patch"), new TypeReference>(){}); + + assertEquals(actual, expected); + } + + @Test + public void verifyResponse() throws IOException { + AAITransactionalClient transactions = createClient() + .beginTransaction(); + + assertEquals("success status", Optional.empty(), transactions.locateErrorMessages(getJson("response-success.json"))); + assertEquals(transactions.locateErrorMessages(getJson("response-failure.json")).get(), "another error message\nmy great error"); + } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + filename))); + } + + private AAIResourcesClient createClient() { + AAIResourcesClient client = spy(new AAIResourcesClient()); + doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties(); + return client; + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAIURITest.java b/common/src/test/java/org/onap/so/client/aai/AAIURITest.java new file mode 100644 index 0000000000..cb426c5392 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAIURITest.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import static org.junit.Assert.assertEquals; + +import javax.ws.rs.core.UriBuilder; + +import org.junit.Test; +import org.onap.so.client.aai.entities.uri.AAIUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; + +public class AAIURITest { + + + + + @Test + public void verifyTemplateReplacement() { + final String id = "test1"; + AAIUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, id); + String manualReplace = AAIObjectType.CONFIGURATION.toString().replaceAll("\\{configuration-id\\}", id); + assertEquals("uri template replaced", aaiUri.build(), UriBuilder.fromPath(manualReplace).build()); + + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAIUpdatorImplTest.java b/common/src/test/java/org/onap/so/client/aai/AAIUpdatorImplTest.java new file mode 100644 index 0000000000..7ba92a1f06 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAIUpdatorImplTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei 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.so.client.aai; + +import org.junit.Test; + +public class AAIUpdatorImplTest { + + AAIUpdatorImpl test = new AAIUpdatorImpl(); + + protected AAIRestClientI client; + + @Test + public void getClientTest() throws Exception { + test.getClient(); + } + + @Test + public void setClientTest() throws Exception { + test.setClient(client); + } + + + @Test(expected = NullPointerException.class) + public void updateVnfToLockedTest() throws Exception { + test.updateVnfToLocked("vnfId","uuId"); + } + + + @Test(expected = NullPointerException.class) + public void updateVnfToUnLockedTest() throws Exception { + test.updateVnfToUnLocked("vnfId","uuId"); + } + +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAIUpdatorTest.java b/common/src/test/java/org/onap/so/client/aai/AAIUpdatorTest.java new file mode 100644 index 0000000000..fddd1e63ba --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAIUpdatorTest.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import static org.mockito.Matchers.isA; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class AAIUpdatorTest { + + @Mock + protected AAIRestClientI client; + String vnfName = "testVnf"; + String uuid = "UUID"; + AAIUpdatorImpl updator; + + @Before + public void init(){ + updator = new AAIUpdatorImpl(); + updator.setClient(client); + } + + @Test + public void testUpdateVnfToLocked() throws Exception{ + doNothing().when(client).updateMaintenceFlagVnfId(isA(String.class), isA(Boolean.class), isA(String.class)); + updator.updateVnfToLocked(vnfName, uuid); + verify(client, times(1)).updateMaintenceFlagVnfId(vnfName, true, uuid); + } + + @Test + public void testUpdateVnfToUnLocked() throws Exception { + doNothing().when(client).updateMaintenceFlagVnfId(isA(String.class), isA(Boolean.class), isA(String.class)); + updator.updateVnfToUnLocked(vnfName, uuid); + verify(client, times(1)).updateMaintenceFlagVnfId(vnfName, false, uuid); + } +} \ No newline at end of file diff --git a/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java b/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java new file mode 100644 index 0000000000..04c8b15b51 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java @@ -0,0 +1,98 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.Pserver; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; + +@RunWith(MockitoJUnitRunner.class) +public class AAIValidatorTest { + + @Mock + protected AAIRestClientI client; + String vnfName = "testVnf"; + String uuid = "UUID"; + AAIValidatorImpl validator; + + @Before + public void init(){ + validator = new AAIValidatorImpl(); + validator.setClient(client); + } + + public List getPservers(boolean locked){ + Pserver pserver = new Pserver(); + pserver.setInMaint(locked); + List pservers = new ArrayList(); + pservers.add(pserver); + return pservers; + } + + public GenericVnf createGenericVnfs(boolean locked){ + GenericVnf genericVnf = new GenericVnf(); + genericVnf.setInMaint(locked); + return genericVnf; + } + + @Test + public void test_IsPhysicalServerLocked_True() throws IOException{ + when(client.getPhysicalServerByVnfId(vnfName,uuid)).thenReturn(getPservers(true)); + boolean locked = validator.isPhysicalServerLocked(vnfName, uuid); + assertEquals(true, locked); + } + + @Test + public void test_IsPhysicalServerLocked_False() throws JsonParseException, JsonMappingException, UnsupportedEncodingException, IOException { + when(client.getPhysicalServerByVnfId(vnfName,uuid)).thenReturn(getPservers(false)); + boolean locked = validator.isPhysicalServerLocked(vnfName, uuid); + assertEquals(false, locked); + } + + @Test + public void test_IsVNFLocked_False() throws Exception{ + when(client.getVnfByName(vnfName,uuid)).thenReturn(createGenericVnfs(false)); + boolean locked = validator.isVNFLocked(vnfName, uuid); + assertEquals(false, locked); + } + + @Test + public void test_IsVNFLocked_True() throws Exception{ + when(client.getVnfByName(vnfName,uuid)).thenReturn(createGenericVnfs(true)); + boolean locked = validator.isVNFLocked(vnfName, uuid); + assertEquals(true,locked ); + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/entities/AAIResultWrapperTest.java b/common/src/test/java/org/onap/so/client/aai/entities/AAIResultWrapperTest.java new file mode 100644 index 0000000000..ff940a0dea --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/entities/AAIResultWrapperTest.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.client.aai.AAICommonObjectMapperProvider; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(MockitoJUnitRunner.class) +public class AAIResultWrapperTest { + String json; + + AAIResultWrapper aaiResultWrapper; + AAIResultWrapper aaiResultWrapperEmpty; + + @Before + public void init() throws IOException { + final String RESOURCE_PATH = "src/test/resources/__files/aai/resources/"; + json = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "e2e-complex.json"))); + + aaiResultWrapper = new AAIResultWrapper(json); + aaiResultWrapperEmpty = new AAIResultWrapper("{}"); + } + + @Test + public void testGetRelationshipsEmpty() { + Optional relationships = aaiResultWrapperEmpty.getRelationships(); + assertEquals("Compare relationships", Optional.empty(), relationships); + } + + @Test + public void testAsMap() throws JsonParseException, JsonMappingException, IOException { + ObjectMapper mapper = new AAICommonObjectMapperProvider().getMapper(); + Map expected = mapper.readValue(json, new TypeReference>(){}); + + Map actual = aaiResultWrapper.asMap(); + assertEquals(expected, actual); + } + + @Test + public void testAsMapEmpty() { + Map actual = aaiResultWrapperEmpty.asMap(); + assertEquals(new HashMap<>(), actual); + } + + @Test + public void nullCases() { + + AAIResultWrapper wrapper = new AAIResultWrapper(null); + + assertEquals(Optional.empty(), wrapper.getRelationships()); + assertEquals("{}", wrapper.getJson()); + assertEquals(Optional.empty(), wrapper.asBean(GenericVnf.class)); + assertEquals(true, wrapper.asMap().isEmpty()); + assertEquals("{}", wrapper.toString()); + + + + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/entities/RelationshipsTest.java b/common/src/test/java/org/onap/so/client/aai/entities/RelationshipsTest.java new file mode 100644 index 0000000000..1ce6e4377c --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/entities/RelationshipsTest.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; + +public class RelationshipsTest { + + private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/resources/"; + + @Test + public void run() throws IOException { + final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "e2e-complex.json"))); + + AAIResultWrapper wrapper = new AAIResultWrapper(content); + Relationships relationships = wrapper.getRelationships().get(); + + List test = relationships.getRelatedAAIUris(AAIObjectType.VCE); + + System.out.println(test.get(0).build()); + List uris = Arrays.asList( + AAIUriFactory.createResourceUri(AAIObjectType.VCE, "a9fec18e-1ea3-40e4-a6c0-a89b3de07053"), + AAIUriFactory.createResourceUri(AAIObjectType.VCE, "8ae1e5f8-61f1-4c71-913a-b40cc4593cb9"), + AAIUriFactory.createResourceUri(AAIObjectType.VCE, "a2935fa9-b743-49f4-9813-a127f13c4e93"), + AAIUriFactory.createResourceUri(AAIObjectType.VCE, "c7fe7698-8063-4e26-8bd3-ca3edde0b0d4")); + + + assertTrue(uris.containsAll(test) && test.containsAll(uris)); + + } + +} diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriFromUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriFromUriTest.java new file mode 100644 index 0000000000..5a69a42f35 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriFromUriTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities.uri; + +import static org.junit.Assert.assertEquals; + +import javax.ws.rs.core.UriBuilder; + +import org.junit.Test; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.graphinventory.entities.uri.SimpleUri; + +public class AAISimpleUriFromUriTest { + + + + @Test + public void removeHost() { + + AAIUri uri = new AAISimpleUri(AAIObjectType.UNKNOWN, UriBuilder.fromUri("https://localhost:8443/aai/v9/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053").build()); + + assertEquals("root and version removed", "/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053", uri.build().toString()); + + } + @Test + public void noChange() { + + AAIUri uri = new AAISimpleUri(AAIObjectType.UNKNOWN, UriBuilder.fromUri("/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053").build()); + + assertEquals("no change", "/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053", uri.build().toString()); + + } + + @Test + public void encodingPreserved() { + + AAIUri uri = new AAISimpleUri(AAIObjectType.UNKNOWN, UriBuilder.fromUri("/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053").build()); + + assertEquals("encoding preserved", "/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053", uri.build().toString()); + + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriTest.java new file mode 100644 index 0000000000..1b6cc7bf66 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAISimpleUriTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities.uri; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsIterableContainingInOrder.contains; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.junit.Assert.assertEquals; + +import java.util.Map; + +import org.junit.Test; +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.AAIObjectType; + +public class AAISimpleUriTest { + + + + @Test + public void relatedToTestPlural() { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); + uri.relatedTo(AAIObjectPlurals.PSERVER); + String uriOutput = uri.build().toString(); + assertEquals(true, uriOutput.contains("related-to")); + } + + @Test + public void relatedToTestSingular() { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); + uri.relatedTo(AAIObjectType.PSERVER, "test2"); + String uriOutput = uri.build().toString(); + assertEquals(true, uriOutput.contains("related-to")); + } + + @Test + public void cloneTestSingular() { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); + AAIResourceUri cloned = uri.clone(); + Map keys = cloned.getURIKeys(); + assertThat(keys.values(), contains("test1")); + } + + @Test + public void cloneTestPlural() { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF); + AAIResourceUri cloned = uri.clone(); + Map keys = cloned.getURIKeys(); + assertThat(keys.values(), empty()); + } + + @Test + public void getKeysTest() { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, "cloud1", "cloud2", "tenant1", "vserver1"); + Map keys = uri.getURIKeys(); + System.out.println(keys); + System.out.println(uri.build()); + assertEquals("vserver1", keys.get("vserver-id")); + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/AAIUriFactoryTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAIUriFactoryTest.java new file mode 100644 index 0000000000..0ddf5c707b --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/AAIUriFactoryTest.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities.uri; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.graphinventory.entities.uri.SimpleUri; + +public class AAIUriFactoryTest { + + @Test + public void testCreateResourceUri() { + + AAIUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); + + String expected = "/network/generic-vnfs/generic-vnf/VIP%28VelocitytoIP%29"; + assertEquals(expected, uri.build().toString()); + } + + @Test + public void testCreateNodesUri() { + + AAIUri uri = AAIUriFactory.createNodesUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); + + String expected = "/nodes/generic-vnfs/generic-vnf/VIP%28VelocitytoIP%29"; + assertEquals(expected, uri.build().toString()); + } + + @Test + public void testCreateResourceFromExistingURI() { + + AAIUri uri = new AAISimpleUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); + AAIUri uri2 = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.GENERIC_VNF, uri.build()); + + String expected = "/network/generic-vnfs/generic-vnf/VIP%28VelocitytoIP%29"; + assertEquals(expected, uri2.build().toString()); + } + + @Test + public void testCreateResourceURIForPluralsWithValues() { + + AAIUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, "customerId", "serviceType"); + + String expected = "/business/customers/customer/customerId/service-subscriptions/service-subscription/serviceType/service-instances"; + assertEquals(expected, uri.build().toString()); + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java new file mode 100644 index 0000000000..73720f55c2 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java @@ -0,0 +1,192 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.aai.entities.uri; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.collection.IsIterableContainingInOrder.contains; +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Optional; + +import javax.ws.rs.core.UriBuilder; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.so.client.aai.AAIQueryClient; +import org.onap.so.client.graphinventory.Format; +import org.onap.so.client.aai.entities.CustomQuery; +import org.onap.so.client.graphinventory.exceptions.GraphInventoryPayloadException; +import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException; +import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriNotFoundException; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; + +public class ServiceInstanceUriTest { + + private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/resources/"; + + @Rule + public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443)); + + @Rule + public final ExpectedException exception = ExpectedException.none(); + + @Test + public void found() throws IOException { + final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "service-instance-pathed-query.json"))); + + ServiceInstanceUri instance = new ServiceInstanceUri("key3"); + final Optional result = instance.extractRelatedLink(content); + final String expected = "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3"; + assertEquals("result is equal", expected, result.get()); + + } + + @Test + public void oneKey() throws IOException, URISyntaxException, GraphInventoryUriNotFoundException, GraphInventoryPayloadException { + + ServiceInstanceUri instance = new ServiceInstanceUri("key1"); + ServiceInstanceUri spy = spy(instance); + doReturn("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3").when(spy).getSerivceInstance(any(Object.class)); + + final URI result = spy.build(); + final URI expected = UriBuilder.fromPath("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3").build(); + assertEquals("result is equal", expected, result); + + } + + @Test + public void oneKeyQueryParams() throws IOException, URISyntaxException, GraphInventoryUriNotFoundException, GraphInventoryPayloadException { + + ServiceInstanceUri instance = new ServiceInstanceUri("key1"); + ServiceInstanceUri spy = spy(instance); + doReturn("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3").when(spy).getSerivceInstance(any(Object.class)); + + final URI result = spy.resourceVersion("1234").build(); + final URI expected = UriBuilder.fromUri("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3?resource-version=1234").build(); + assertEquals("result is equal", expected, result); + + } + + @Test + public void oneKeyEncoded() throws IOException, URISyntaxException, GraphInventoryUriNotFoundException, GraphInventoryPayloadException { + + ServiceInstanceUri instance = new ServiceInstanceUri("key1"); + ServiceInstanceUri spy = spy(instance); + doReturn("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%20space").when(spy).getSerivceInstance(any(Object.class)); + + final URI result = spy.build(); + final URI expected = UriBuilder.fromUri("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%20space").build(); + assertEquals("result is equal", expected, result); + + } + + @Test + public void oneKeyGetKeys() throws IOException, URISyntaxException, GraphInventoryUriNotFoundException, GraphInventoryPayloadException { + + ServiceInstanceUri instance = new ServiceInstanceUri("key1"); + ServiceInstanceUri spy = spy(instance); + doReturn("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%28space").when(spy).getSerivceInstance(any(Object.class)); + + assertThat(spy.getURIKeys().values(), contains("key1", "key2", "key3(space")); + + } + @Test + public void oneKeyClone() throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException { + ServiceInstanceUri instance = new ServiceInstanceUri("key1"); + ServiceInstanceUri spy = spy(instance); + String uri = "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3"; + doReturn(uri).when(spy).getSerivceInstance(any(Object.class)); + doReturn(Optional.of(uri)).when(spy).getCachedValue(); + final URI result = spy.resourceVersion("1234").clone().build(); + final URI expected = UriBuilder.fromUri("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3?resource-version=1234").build(); + assertEquals("result is equal", expected, result); + } + + @Test + public void threeKey() throws IOException { + + ServiceInstanceUri instance = new ServiceInstanceUri("key1", "key2", "key3"); + final URI result = instance.build(); + final URI expected = UriBuilder.fromPath("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3").build(); + assertEquals("result is equal", expected, result); + + } + + @Test + public void notfound() throws IOException, GraphInventoryUriNotFoundException, GraphInventoryPayloadException { + final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "empty-query-result.json"))); + + ServiceInstanceUri instance = new ServiceInstanceUri("key3"); + ServiceInstanceUri spy = spy(instance); + AAIQueryClient mockQueryClient = mock(AAIQueryClient.class); + when(mockQueryClient.query(any(Format.class), any(CustomQuery.class))).thenReturn(content); + when(spy.getQueryClient()).thenReturn(mockQueryClient); + exception.expect(GraphInventoryUriComputationException.class); + spy.build(); + + } + + @Test + public void cloneTest() { + ServiceInstanceUri instance = new ServiceInstanceUri("key1", "key2", "key3"); + final URI result = instance.build(); + final URI result2 = instance.clone().queryParam("something", "new").build(); + assertEquals("uris are not equal", false, result.toString().equals(result2.toString())); + + } + + @Test + public void noVertexFound() throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException { + ServiceInstanceUri instance = new ServiceInstanceUri("key3"); + ServiceInstanceUri spy = spy(instance); + AAIQueryClient client = mock(AAIQueryClient.class); + when(client.query(any(Format.class), any(CustomQuery.class))).thenReturn("{\"results\":[]}"); + doReturn(client).when(spy).getQueryClient(); + stubFor(put(urlMatching("/aai/v[0-9]+/query.*")) + .withRequestBody(containing("key3")) + .willReturn(aResponse() + .withStatus(400) + .withHeader("Content-Type", "application/json") + .withBodyFile(""))); + exception.expect(GraphInventoryUriComputationException.class); + exception.expectMessage(containsString("NotFoundException")); + spy.build(); + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java b/common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java new file mode 100644 index 0000000000..e2a3cbd6bd --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java @@ -0,0 +1,55 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * 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.so.client.aai.objects; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class AAIOperationalEnvironmentTest { + + AAIOperationalEnvironment aaiOE =new AAIOperationalEnvironment(); + + @Test + public void test() { + aaiOE.setOperationalEnvironmentId("operationalEnvironmentId"); + aaiOE.setOperationalEnvironmentName("operationalEnvironmentName"); + aaiOE.setOperationalEnvironmentStatus("operationalEnvironmentStatus"); + aaiOE.setOperationalEnvironmentType("operationalEnvironmentType"); + aaiOE.setResourceVersion("resourceVersion"); + aaiOE.setTenantContext("tenantContext"); + aaiOE.setWorkloadContext("workloadContext"); + assertEquals(aaiOE.getOperationalEnvironmentId(),"operationalEnvironmentId"); + assertEquals(aaiOE.getOperationalEnvironmentName(),"operationalEnvironmentName"); + assertEquals(aaiOE.getOperationalEnvironmentStatus(),"operationalEnvironmentStatus"); + assertEquals(aaiOE.getOperationalEnvironmentType(),"operationalEnvironmentType"); + assertEquals(aaiOE.getResourceVersion(),"resourceVersion"); + assertEquals(aaiOE.getTenantContext(),"tenantContext"); + assertEquals(aaiOE.getWorkloadContext(),"workloadContext"); + aaiOE.withOperationalEnvironmentId("operationalEnvironmentId"); + aaiOE.withOperationalEnvironmentName("operationalEnvironmentName"); + aaiOE.withOperationalEnvironmentStatus("operationalEnvironmentStatus"); + aaiOE.withOperationalEnvironmentType("operationalEnvironmentType"); + aaiOE.withResourceVersion("resourceVersion"); + aaiOE.withTenantContext("tenantContext"); + aaiOE.withWorkloadContext("workloadContext"); + } + +} diff --git a/common/src/test/java/org/onap/so/client/aai/objects/AAIServiceInstanceTest.java b/common/src/test/java/org/onap/so/client/aai/objects/AAIServiceInstanceTest.java new file mode 100644 index 0000000000..4b080252b2 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/objects/AAIServiceInstanceTest.java @@ -0,0 +1,53 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * 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.so.client.aai.objects; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class AAIServiceInstanceTest { + + @Test + public void test() { + AAIServiceInstance aaiSI= new AAIServiceInstance(); + aaiSI.setEnvironmentContext("environmentContext"); + aaiSI.setModelInvariantUuid("modelInvariantUuid"); + aaiSI.setModelUuid("modelUuid"); + aaiSI.setoStatus("oStatus"); + aaiSI.setServiceInstanceId("serviceInstanceId"); + aaiSI.setServiceInstanceName("serviceInstanceName"); + aaiSI.setServiceRole("serviceRole"); + aaiSI.setServiceType("serviceType"); + aaiSI.setWorkloadContext("workloadContext"); + assertEquals(aaiSI.getEnvironmentContext(), "environmentContext"); + assertEquals(aaiSI.getModelInvariantUuid(), "modelInvariantUuid"); + assertEquals(aaiSI.getModelUuid(), "modelUuid"); + assertEquals(aaiSI.getoStatus(), "oStatus"); + assertEquals(aaiSI.getServiceInstanceId(), "serviceInstanceId"); + assertEquals(aaiSI.getServiceInstanceName(), "serviceInstanceName"); + assertEquals(aaiSI.getServiceRole(), "serviceRole"); + assertEquals(aaiSI.getServiceType(), "serviceType"); + assertEquals(aaiSI.getWorkloadContext(), "workloadContext"); + aaiSI.withServiceInstance("serviceInstanceId"); + assert(aaiSI.getUri()!=null); + } + +} diff --git a/common/src/test/java/org/onap/so/client/defaultproperties/DefaultAAIPropertiesImpl.java b/common/src/test/java/org/onap/so/client/defaultproperties/DefaultAAIPropertiesImpl.java new file mode 100644 index 0000000000..77e1dfee7d --- /dev/null +++ b/common/src/test/java/org/onap/so/client/defaultproperties/DefaultAAIPropertiesImpl.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.defaultproperties; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.onap.so.client.aai.AAIProperties; +import org.onap.so.client.aai.AAIVersion; + +public class DefaultAAIPropertiesImpl implements AAIProperties { + + + final Map props; + public DefaultAAIPropertiesImpl() { + File initialFile = new File("src/test/resources/aai.properties"); + Map temp; + try (InputStream targetStream = new FileInputStream(initialFile)) { + Properties properties = new Properties(); + properties.load(targetStream); + temp = properties; + } catch (IOException e) { + temp = new HashMap<>(); + } + this.props = temp; + + } + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(props.get("aai.endpoint").toString()); + } + + @Override + public String getSystemName() { + return "MSO"; + } + @Override + public AAIVersion getDefaultVersion() { + return AAIVersion.LATEST; + } + + @Override + public String getAuth() { + Object value = props.get("aai.auth"); + return value == null ? null : value.toString(); + } + + @Override + public String getKey() { + Object value = props.get("mso.msoKey"); + return value == null ? null : value.toString(); + } +} diff --git a/common/src/test/java/org/onap/so/client/dmaap/DmaapClientTest.java b/common/src/test/java/org/onap/so/client/dmaap/DmaapClientTest.java new file mode 100644 index 0000000000..4b90cfe021 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/dmaap/DmaapClientTest.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.dmaap; + +import static org.junit.Assert.assertEquals; + +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.junit.Test; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; + +public class DmaapClientTest { + + @Test + public void deobfuscateTest() throws FileNotFoundException, IOException { + String encodedBase64 = "dGVzdHBhc3N3b3Jk"; + String notEncoded = "testpassword"; + DmaapConsumer consumer = new SDNOHealthCheckDmaapConsumer(); + assertEquals("decoded password", notEncoded, consumer.deobfuscatePassword(encodedBase64)); + + } +} diff --git a/common/src/test/java/org/onap/so/client/dmaap/DmaapPublisherTest.java b/common/src/test/java/org/onap/so/client/dmaap/DmaapPublisherTest.java new file mode 100644 index 0000000000..e1afa82e1e --- /dev/null +++ b/common/src/test/java/org/onap/so/client/dmaap/DmaapPublisherTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei 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.so.client.dmaap; + +import org.junit.Test; + +import javax.ws.rs.ProcessingException; +import java.io.IOException; +import java.util.Optional; + +public class DmaapPublisherTest { + + DmaapPublisher dmaapPublisher = new DmaapPublisher(120) { + @Override + public String getUserName() { + return "test"; + } + + @Override + public String getPassword() { + return "test"; + } + + @Override + public String getTopic() { + return "test"; + } + + @Override + public Optional getHost() { + return Optional.of("http://localhost:8080"); + } + }; + + public DmaapPublisherTest() throws IOException { + } + + @Test(expected = ProcessingException.class) + public void sendTest() throws Exception { + dmaapPublisher.send("{'key': 'value'}"); + } + +} \ No newline at end of file diff --git a/common/src/test/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImplTest.java b/common/src/test/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImplTest.java new file mode 100644 index 0000000000..be93f47585 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/graphinventory/entities/uri/parsers/UriParserSpringImplTest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.graphinventory.entities.uri.parsers; + +import static org.junit.Assert.assertEquals; + +import java.util.Map; + +import org.junit.Test; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.graphinventory.entities.uri.parsers.UriParser; +import org.onap.so.client.graphinventory.entities.uri.parsers.UriParserSpringImpl; + +public class UriParserSpringImplTest { + + + + + @Test + public void reverseTemplate() { + final UriParser parser = new UriParserSpringImpl(AAIObjectType.SERVICE_INSTANCE.toString()); + final String uri = "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3"; + + Map result = parser.parse(uri); + + assertEquals("found customer-id", "key1", result.get("global-customer-id")); + assertEquals("found service-type", "key2", result.get("service-type")); + assertEquals("found service-instance-id", "key3", result.get("service-instance-id")); + + } +} diff --git a/common/src/test/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPayloadExceptionTest.java b/common/src/test/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPayloadExceptionTest.java new file mode 100644 index 0000000000..6b23cbbe86 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/graphinventory/exceptions/GraphInventoryPayloadExceptionTest.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei 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.so.client.graphinventory.exceptions; + +import org.junit.Test; +import org.onap.so.client.graphinventory.exceptions.GraphInventoryPayloadException; + +public class GraphInventoryPayloadExceptionTest { + + Throwable t = new Throwable(); + + @Test + public void callConstructorTest() throws Exception { + + GraphInventoryPayloadException test1 = new GraphInventoryPayloadException("testing"); + + GraphInventoryPayloadException test2 = new GraphInventoryPayloadException("testing", t); + + GraphInventoryPayloadException test3 = new GraphInventoryPayloadException(t); + } + +} diff --git a/common/src/test/java/org/onap/so/client/grm/GRMBeansTest.java b/common/src/test/java/org/onap/so/client/grm/GRMBeansTest.java new file mode 100644 index 0000000000..76b7369399 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/grm/GRMBeansTest.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm; + +import java.util.List; + +import org.junit.Test; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoClassFilter; +import com.openpojo.reflection.filters.FilterEnum; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.reflection.impl.PojoClassFactory; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.affirm.Affirm; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +public class GRMBeansTest { + private static final String POJO_PACKAGE = "org.onap.so.client.grm.beans"; + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + @Test + public void testPojoStructureAndBehavior() { + Validator validator = ValidatorBuilder.create() + .with(new GetterMustExistRule()) + .with(new SetterMustExistRule()) + .with(new SetterTester()) + .with(new GetterTester()) + .build(); + + validator.validate(POJO_PACKAGE, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); + } + + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } + +} diff --git a/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java b/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java new file mode 100644 index 0000000000..3cce6a626b --- /dev/null +++ b/common/src/test/java/org/onap/so/client/grm/GRMClientTest.java @@ -0,0 +1,217 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.File; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.core.MediaType; + +import ch.qos.logback.classic.spi.ILoggingEvent; + +import org.apache.log4j.MDC; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.so.client.grm.beans.OperationalInfo; +import org.onap.so.client.grm.beans.Property; +import org.onap.so.client.grm.beans.ServiceEndPoint; +import org.onap.so.client.grm.beans.ServiceEndPointList; +import org.onap.so.client.grm.beans.ServiceEndPointLookupRequest; +import org.onap.so.client.grm.beans.ServiceEndPointRequest; +import org.onap.so.client.grm.beans.Version; +import org.onap.so.client.grm.exceptions.GRMClientCallFailed; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.tomakehurst.wiremock.junit.WireMockRule; +import org.onap.so.logger.MsoLogger; +import org.onap.so.logger.MsoLogger.Catalog; +import org.onap.so.utils.TestAppender; + +public class GRMClientTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(47389)); + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @BeforeClass + public static void setUp() throws Exception { + System.setProperty("mso.config.path", "src/test/resources"); + } + + private ObjectMapper mapper = new ObjectMapper(); + + @Test + public void testFind() throws Exception { + TestAppender.events.clear(); + String endpoints = getFileContentsAsString("__files/grm/endpoints.json"); + wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", MediaType.APPLICATION_JSON) + .withHeader("X-FromAppId", "GRM") + .withBody(endpoints))); + + MDC.put(MsoLogger.SERVICE_NAME, "my-value"); + GRMClient client = new GRMClient(); + ServiceEndPointList sel = client.findRunningServices("TEST.ECOMP_PSL.*", 1, "TEST"); + List list = sel.getServiceEndPointList(); + assertEquals(3, list.size()); + ILoggingEvent logEvent = TestAppender.events.get(0); + Map mdc = logEvent.getMDCPropertyMap(); + assertNotNull(mdc.get(MsoLogger.METRIC_BEGIN_TIME)); + assertNotNull(mdc.get(MsoLogger.METRIC_END_TIME)); + assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); + assertNotNull(mdc.get(MsoLogger.METRIC_TIMER)); + assertEquals("200",mdc.get(MsoLogger.RESPONSECODE)); + assertEquals("GRM",mdc.get(MsoLogger.PARTNERNAME)); + assertEquals("expect value to not be overwritten by jax rs client interceptor", "my-value",mdc.get(MsoLogger.SERVICE_NAME)); + assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE)); + assertNotNull(mdc.get(MsoLogger.RESPONSEDESC)); + } + + @Test + public void testFindFail() throws Exception { + + wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning")) + .willReturn(aResponse() + .withStatus(400) + .withHeader("Content-Type", MediaType.APPLICATION_JSON) + .withBody(""))); + + GRMClient client = new GRMClient(); + thrown.expect(GRMClientCallFailed.class); + client.findRunningServices("TEST.ECOMP_PSL.*", 1, "TEST"); + } + + @Ignore + @Test + public void testAdd() throws Exception { + + wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/add")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", MediaType.APPLICATION_JSON) + .withBody("test"))); + wireMockRule.addMockServiceRequestListener((request, response) -> { + System.out.println("URL Requested => " + request.getAbsoluteUrl()); + System.out.println("Request Body => " + request.getBodyAsString()); + System.out.println("Request Headers => " + request.getHeaders().toString()); + System.out.println("Response Status => " + response.getStatus()); + System.out.println("Response Body => " + response.getBodyAsString()); + }); + + Version ver = new Version(); + ver.setMajor(1); + ver.setMinor(0); + ver.setPatch("0"); + + ServiceEndPoint sep = new ServiceEndPoint(); + sep.setName("TEST.ECOMP_PSL.Inventory"); + sep.setVersion(ver); + sep.setHostAddress("127.0.0.1"); + sep.setListenPort("8080"); + sep.setLatitude("37.7022"); + sep.setLongitude("121.9358"); + sep.setContextPath("/"); + sep.setRouteOffer("TEST"); + + OperationalInfo operInfo = new OperationalInfo(); + operInfo.setCreatedBy("edge"); + operInfo.setUpdatedBy("edge"); + + sep.setOperationalInfo(operInfo); + + Property prop1 = new Property(); + prop1.setName("Environment"); + prop1.setValue("TEST"); + + Property prop2 = new Property(); + prop2.setName("cpfrun_cluster_name"); + prop2.setValue("testcase_cluster_no_cluster"); + + List props = new ArrayList(); + props.add(prop1); + props.add(prop2); + + sep.setProperties(props); + + ServiceEndPointRequest request = new ServiceEndPointRequest(); + request.setEnv("DEV"); + request.setServiceEndPoint(sep); + + System.out.println("Request in JSON: " + mapper.writeValueAsString(request)); + + GRMClient client = new GRMClient(); + client.addServiceEndPoint(request); + } + + @Test + public void testAddFail() throws Exception { + wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/add")) + .willReturn(aResponse() + .withStatus(404) + .withHeader("Content-Type", MediaType.APPLICATION_JSON) + .withBody("test"))); + ServiceEndPointRequest request = new ServiceEndPointRequest(); + GRMClient client = new GRMClient(); + thrown.expect(GRMClientCallFailed.class); + client.addServiceEndPoint(request); + } + + @Test + public void testBuildServiceEndPointLookupRequest() { + GRMClient client = new GRMClient(); + ServiceEndPointLookupRequest request = client.buildServiceEndPointlookupRequest("TEST.ECOMP_PSL.Inventory", 1, "DEV"); + assertEquals("TEST.ECOMP_PSL.Inventory", request.getServiceEndPoint().getName()); + assertEquals(Integer.valueOf(1), Integer.valueOf(request.getServiceEndPoint().getVersion().getMajor())); + assertEquals("DEV", request.getEnv()); + + } + + protected String getFileContentsAsString(String fileName) { + String content = ""; + try { + ClassLoader classLoader = this.getClass().getClassLoader(); + File file = new File(classLoader.getResource(fileName).getFile()); + content = new String(Files.readAllBytes(file.toPath())); + } + catch(Exception e) { + e.printStackTrace(); + System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage()); + } + return content; + } +} diff --git a/common/src/test/java/org/onap/so/client/grm/ServiceEndPointListTest.java b/common/src/test/java/org/onap/so/client/grm/ServiceEndPointListTest.java new file mode 100644 index 0000000000..a1fb43ea5e --- /dev/null +++ b/common/src/test/java/org/onap/so/client/grm/ServiceEndPointListTest.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm; + +import java.io.File; +import java.nio.file.Files; +import java.util.List; +import static org.junit.Assert.*; +import org.junit.Test; +import org.onap.so.client.grm.beans.ServiceEndPoint; +import org.onap.so.client.grm.beans.ServiceEndPointList; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class ServiceEndPointListTest { + + private ObjectMapper mapper = new ObjectMapper(); + + @Test + public void testUnmarshall() throws Exception { + String endpointsJson = getFileContentsAsString("__files/grm/endpoints.json"); + ServiceEndPointList sel = mapper.readValue(endpointsJson, ServiceEndPointList.class); + + List list = sel.getServiceEndPointList(); + ServiceEndPoint se = list.get(0); + + assertEquals(3, list.size()); + assertEquals("dummy.pod.ns.dummy-pod3", se.getName()); + assertEquals(Integer.valueOf(1), Integer.valueOf(se.getVersion().getMajor())); + assertEquals(Integer.valueOf(0), Integer.valueOf(se.getVersion().getMinor())); + assertEquals(Integer.valueOf(0), Integer.valueOf(se.getVersion().getPatch())); + assertEquals("192.168.120.218", se.getHostAddress()); + assertEquals("32004", se.getListenPort()); + assertEquals("37.7022", se.getLatitude()); + assertEquals("121.9358", se.getLongitude()); + assertEquals("/", se.getContextPath()); + assertEquals("edge", se.getOperationalInfo().getCreatedBy()); + assertEquals("edge", se.getOperationalInfo().getUpdatedBy()); + assertEquals("Environment", se.getProperties().get(0).getName()); + assertEquals("DEV", se.getProperties().get(0).getValue()); + } + + protected String getFileContentsAsString(String fileName) { + + String content = ""; + try { + ClassLoader classLoader = this.getClass().getClassLoader(); + File file = new File(classLoader.getResource(fileName).getFile()); + content = new String(Files.readAllBytes(file.toPath())); + } + catch(Exception e) { + e.printStackTrace(); + System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage()); + } + return content; + } +} diff --git a/common/src/test/java/org/onap/so/client/grm/ServiceEndPointRequestTest.java b/common/src/test/java/org/onap/so/client/grm/ServiceEndPointRequestTest.java new file mode 100644 index 0000000000..4fe6bca05e --- /dev/null +++ b/common/src/test/java/org/onap/so/client/grm/ServiceEndPointRequestTest.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.grm; + +import static org.junit.Assert.assertEquals; +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.so.client.grm.beans.OperationalInfo; +import org.onap.so.client.grm.beans.Property; +import org.onap.so.client.grm.beans.ServiceEndPoint; +import org.onap.so.client.grm.beans.ServiceEndPointRequest; +import org.onap.so.client.grm.beans.Version; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class ServiceEndPointRequestTest { + + private ObjectMapper mapper = new ObjectMapper(); + + @Test + public void testMarshall() throws Exception { + + String expected = + "{\"serviceEndPoint\":{\"name\":\"TEST.ECOMP_PSL.Inventory\",\"version\":{\"major\":1,\"minor\":0,\"patch\":\"0\"}," + + "\"hostAddress\":\"127.0.0.1\",\"listenPort\":\"8080\",\"latitude\":\"37.7022\",\"longitude\":\"121.9358\"," + + "\"contextPath\":\"/\",\"routeOffer\":\"TEST\",\"operationalInfo\":{\"createdBy\":\"edge\",\"updatedBy\":\"edge\"}," + + "\"properties\":[{\"name\":\"Environment\",\"value\":\"TEST\"},{\"name\":\"cpfrun_cluster_name\"," + + "\"value\":\"testcase_cluster_no_cluster\"}]},\"env\":\"DEV\"}"; + + Version ver = new Version(); + ver.setMajor(1); + ver.setMinor(0); + ver.setPatch("0"); + + ServiceEndPoint sep = new ServiceEndPoint(); + sep.setName("TEST.ECOMP_PSL.Inventory"); + sep.setVersion(ver); + sep.setHostAddress("127.0.0.1"); + sep.setListenPort("8080"); + sep.setLatitude("37.7022"); + sep.setLongitude("121.9358"); + sep.setContextPath("/"); + sep.setRouteOffer("TEST"); + + OperationalInfo operInfo = new OperationalInfo(); + operInfo.setCreatedBy("edge"); + operInfo.setUpdatedBy("edge"); + + sep.setOperationalInfo(operInfo); + + Property prop1 = new Property(); + prop1.setName("Environment"); + prop1.setValue("TEST"); + + Property prop2 = new Property(); + prop2.setName("cpfrun_cluster_name"); + prop2.setValue("testcase_cluster_no_cluster"); + + List props = new ArrayList(); + props.add(prop1); + props.add(prop2); + + sep.setProperties(props); + + ServiceEndPointRequest request = new ServiceEndPointRequest(); + request.setEnv("DEV"); + request.setServiceEndPoint(sep); + + assertEquals(expected, mapper.writeValueAsString(request)); + } +} diff --git a/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java b/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java new file mode 100644 index 0000000000..104d40f76e --- /dev/null +++ b/common/src/test/java/org/onap/so/client/policy/PolicyClientImplTest.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.policy; + +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.doReturn; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.so.client.defaultproperties.PolicyRestPropertiesImpl; +import org.onap.so.client.policy.entities.DictionaryData; +import org.onap.so.client.policy.entities.PolicyDecision; +import org.onap.so.client.policy.entities.PolicyServiceType; + +public class PolicyClientImplTest { + + @BeforeClass + public static void setUp() { + System.setProperty("mso.config.path", "src/test/resources"); + } + @Test + public void successReadProperties() { + PolicyRestClient client = new PolicyRestClient(new PolicyRestPropertiesImpl(), PolicyServiceType.GET_DECISION); + Map map = new HashMap<>(); + client.initializeHeaderMap(map); + assertEquals("Found expected Client Auth", "Basic bTAzNzQzOnBvbGljeVIwY2sk", map.get("ClientAuth")); + assertEquals("Found expected Authorization", "Basic dGVzdHBkcDphbHBoYTEyMw==", map.get("Authorization")); + assertEquals("Found expected Environment", "TEST", map.get("Environment")); + } + + @Test + @Ignore + public void getDecisionTest() { + PolicyClient client = new PolicyClientImpl(); + PolicyDecision decision = client.getDecision("S", "V", "BB1", "1", "123"); + assertEquals("Decision is correct", decision.getDecision(), "PERMIT"); + assertEquals("Decision details is correct", decision.getDetails(), "Retry"); + } + + @Test + @Ignore + public void getAllowedTreatmentsTest(){ + PolicyClient client = new PolicyClientImpl(); + DictionaryData dictClient = client.getAllowedTreatments("BB1", "1"); + final String dictBbidString = dictClient.getBbid().getString(); + final String dictWorkStepString = dictClient.getWorkstep().getString(); + assertEquals("DictionaryData matches a response Bbid", dictBbidString, "BB1"); + assertEquals("DicitonaryData matches a response WorkStep", dictWorkStepString, "1"); + } + + @Test + public void getDecisionMockTest() { + String serviceType = "S"; + String vnfType = "V"; + String bbID = "BB1"; + String workStep = "1"; + String errorCode = "123"; + + PolicyDecision expected = new PolicyDecision(); + expected.setDecision("PERMIT"); + expected.setDetails("Retry"); + + DecisionAttributes decisionAttributes = new DecisionAttributes(); + decisionAttributes.setServiceType(serviceType); + decisionAttributes.setVNFType(vnfType); + decisionAttributes.setBBID(bbID); + decisionAttributes.setWorkStep(workStep); + decisionAttributes.setErrorCode(errorCode); + PolicyClient client = Mockito.spy(PolicyClientImpl.class); + + doReturn(expected).when(client).getDecision(serviceType, vnfType, bbID, workStep, errorCode); + + PolicyDecision actual = client.getDecision(serviceType, vnfType, bbID, workStep, errorCode); + assertThat(actual, sameBeanAs(expected)); + } + + /* + @Test + public void getAllowedTreatmentsTest() { + PolicyClient client = new PolicyClientImpl(); + AllowedTreatments allowedTreatments = client.getAllowedTreatments("BB1", "1"); + int expectedSizeOfList = 4; + int sizeOfList = allowedTreatments.getAllowedTreatments().size(); + assertEquals("Decision is correct", sizeOfList, expectedSizeOfList); + }*/ +} diff --git a/common/src/test/java/org/onap/so/client/policy/entities/PolicyEntitiesTest.java b/common/src/test/java/org/onap/so/client/policy/entities/PolicyEntitiesTest.java new file mode 100644 index 0000000000..2796affa49 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/policy/entities/PolicyEntitiesTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.so.client.policy.entities; + +import org.junit.Test; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoClassFilter; +import com.openpojo.reflection.filters.FilterEnum; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +public class PolicyEntitiesTest { + + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + @Test + public void pojoStructure() { + test("org.onap.so.client.policy.entities"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create() + .with(new GetterMustExistRule()) + .with(new SetterMustExistRule()) + .with(new SetterTester()) + .with(new GetterTester()) + .build(); + validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); + } + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } +} diff --git a/common/src/test/java/org/onap/so/client/ruby/RubyCheckClientTest.java b/common/src/test/java/org/onap/so/client/ruby/RubyCheckClientTest.java new file mode 100644 index 0000000000..ba8772b05c --- /dev/null +++ b/common/src/test/java/org/onap/so/client/ruby/RubyCheckClientTest.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.ruby; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.text.ParseException; +import java.time.format.DateTimeFormatter; + +import org.junit.Test; +import org.onap.so.client.ruby.beans.Ruby; + +import static org.apache.commons.lang3.StringUtils.*; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class RubyCheckClientTest { + private final String fileLocation = "src/test/resources/org/onap/so/client/ruby/create-ticket/"; + private static final String REQUEST_ID = "abc123"; + private static final String SOURCE_NAME = "source-name"; + private static final String TIME = "test-time"; + private static final String REASON = "reason"; + private static final String WORK_FLOW_ID = "work-flow-Id"; + private static final String NOTIFICATION = "notification"; + + + + @Test + public void verifyRubyCreateTicketRequest() throws IOException, ParseException{ + String content = this.getJson("create-ticket-request.json"); + ObjectMapper mapper = new ObjectMapper(); + Ruby expected = mapper.readValue(content, Ruby.class); + RubyClient client = new RubyClient(); + RubyClient spy = spy(client); + when(spy.getTime()).thenReturn(TIME); + String actual = spy.buildRequest(REQUEST_ID, SOURCE_NAME, REASON, WORK_FLOW_ID, NOTIFICATION); + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + } + + + @Test + public void verifyTimeFormat() { + RubyClient client = new RubyClient(); + String time = client.getTime(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss Z"); + formatter.parse(time); + } + + + @Test + public void verifyReasonCharLimit() throws IOException{ + final String reasonLong = repeat("*", 256); + RubyClient client = new RubyClient(); + try{ + client.buildRequest(REQUEST_ID, SOURCE_NAME, reasonLong, WORK_FLOW_ID, NOTIFICATION); + fail("Should have thrown IllegalArgumentException but did not!"); + } + catch(final IllegalArgumentException e){ + final String msg = "reason exceeds 255 characters"; + assertEquals(msg, e.getMessage()); + } + } + + @Test + public void verifyNotificationCharLimit() throws IOException{ + final String notificationLong = repeat("*", 1025); + RubyClient client = new RubyClient(); + try{ + client.buildRequest(REQUEST_ID, SOURCE_NAME, REASON, WORK_FLOW_ID, notificationLong); + fail("Should have thrown IllegalArgumentException but did not!"); + } + catch(final IllegalArgumentException e){ + final String msg = "notification exceeds 1024 characters"; + assertEquals(msg, e.getMessage()); + } + } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); + } + +} + diff --git a/common/src/test/java/org/onap/so/client/ruby/beans/RubyBeansTest.java b/common/src/test/java/org/onap/so/client/ruby/beans/RubyBeansTest.java new file mode 100644 index 0000000000..eb142be4c6 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/ruby/beans/RubyBeansTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.so.client.ruby.beans; + +import org.junit.Test; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoClassFilter; +import com.openpojo.reflection.filters.FilterEnum; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +public class RubyBeansTest { + + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + @Test + public void pojoStructure() { + test("org.onap.so.client.ruby.beans"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create() + .with(new GetterMustExistRule()) + .with(new SetterMustExistRule()) + .with(new SetterTester()) + .with(new GetterTester()) + .build(); + validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); + } + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } +} diff --git a/common/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java b/common/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java new file mode 100644 index 0000000000..4887aed522 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Optional; + +import org.junit.Test; +import org.onap.so.client.sdno.beans.SDNO; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class SDNOHealthCheckClientTest { + + + + private final String fileLocation = "src/test/resources/org/onap/so/client/sdno/health-check/"; + private static final String userId = "test-user"; + private static final Optional clliCode = Optional.of("test-clli"); + private static final String requestId = "test-request-id"; + private static final String configurationId = "test-configuration-id"; + private static final String interfaceId = "test-interface-id"; + + @Test + public void verfyLPortMirrorPreCheckRequest() throws IOException{ + String content = this.getJson("custom-lport-mirror-pre-check-request.json"); + ObjectMapper mapper = new ObjectMapper(); + SDNO expected = mapper.readValue(content, SDNO.class); + SDNOHealthCheckClient client = new SDNOHealthCheckClient(); + String actual = client.buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId); + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + } + + @Test + public void verfyLPortMirrorPostCheckRequest() throws IOException{ + String content = this.getJson("custom-lport-mirror-post-check-request.json"); + ObjectMapper mapper = new ObjectMapper(); + SDNO expected = mapper.readValue(content, SDNO.class); + SDNOHealthCheckClient client = new SDNOHealthCheckClient(); + String actual = client.buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId); + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + } + + + @Test + public void verifyPortMirrorPostCheckRequest() throws IOException{ + String content = this.getJson("custom-port-mirror-post-check-request.json"); + ObjectMapper mapper = new ObjectMapper(); + SDNO expected = mapper.readValue(content, SDNO.class); + SDNOHealthCheckClient client = new SDNOHealthCheckClient(); + String actual = client.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId); + + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + + } + @Test + public void verifyPortMirrorPreCheckRequest() throws IOException { + String content = this.getJson("custom-port-mirror-pre-check-request.json"); + ObjectMapper mapper = new ObjectMapper(); + SDNO expected = mapper.readValue(content, SDNO.class); + SDNOHealthCheckClient client = new SDNOHealthCheckClient(); + String actual = client.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId); + + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + + } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); + } + +} diff --git a/common/src/test/java/org/onap/so/client/sdno/SDNOValidatorTest.java b/common/src/test/java/org/onap/so/client/sdno/SDNOValidatorTest.java new file mode 100644 index 0000000000..89dd2f554f --- /dev/null +++ b/common/src/test/java/org/onap/so/client/sdno/SDNOValidatorTest.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.client.sdno; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.UUID; + +import org.hamcrest.core.StringContains; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.Spy; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.client.dmaap.Consumer; +import org.onap.so.client.dmaap.exceptions.DMaaPConsumerFailure; +import org.onap.so.client.exceptions.SDNOException; +import org.onap.so.client.sdno.beans.SDNO; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; + +import com.fasterxml.jackson.databind.ObjectMapper; + + +public class SDNOValidatorTest { + + + @Mock private Consumer mrConsumer; + @Spy private SDNOHealthCheckDmaapConsumer dmaapConsumer; + private final String fileLocation = "src/test/resources/org/onap/so/client/sdno/"; + private final String uuid = "xyz123"; + @Rule public ExpectedException thrown = ExpectedException.none(); + + @Before + public void setUpTests() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void success() throws IOException, Exception { + when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer); + when(mrConsumer.fetch()).thenReturn(Arrays.asList(new String[]{getJson("response.json"), getJson("output-success.json")})); + + SDNOValidatorImpl validator = new SDNOValidatorImpl(); + SDNOValidatorImpl spy = spy(validator); + when(dmaapConsumer.getRequestId()).thenReturn("xyz123"); + doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class)); + boolean result = spy.pollForResponse("xyz123"); + assertEquals("result is true", result, true); + } + + @Test + public void failure() throws IOException, Exception { + when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer); + when(mrConsumer.fetch()).thenReturn(Arrays.asList(new String[]{getJson("response.json"), getJson("output-failure.json")})); + + SDNOValidatorImpl validator = new SDNOValidatorImpl(); + SDNOValidatorImpl spy = spy(validator); + when(dmaapConsumer.getRequestId()).thenReturn("xyz123"); + doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class)); + thrown.expect(SDNOException.class); + thrown.expectMessage(new StringContains("my error message")); + boolean result = spy.pollForResponse("xyz123"); + + } + @Ignore + @Test + public void run() throws Exception { + SDNOValidatorImpl validator = new SDNOValidatorImpl(); + UUID uuid = UUID.randomUUID(); + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("test"); + vnf.setIpv4OamAddress("1.2.3.4"); + vnf.setVnfType("VPE"); + SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid"); + ObjectMapper mapper = new ObjectMapper(); + String json = mapper.writeValueAsString(request); + validator.submitRequest(json); + thrown.expect(DMaaPConsumerFailure.class); + boolean result = validator.pollForResponse(uuid.toString()); + System.out.println(json); + + } + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); + } +} diff --git a/common/src/test/java/org/onap/so/client/sdno/beans/SdnoBeansTest.java b/common/src/test/java/org/onap/so/client/sdno/beans/SdnoBeansTest.java new file mode 100644 index 0000000000..bdfefd028c --- /dev/null +++ b/common/src/test/java/org/onap/so/client/sdno/beans/SdnoBeansTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.so.client.sdno.beans; + +import org.junit.Test; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoClassFilter; +import com.openpojo.reflection.filters.FilterEnum; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +public class SdnoBeansTest { + + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + @Test + public void pojoStructure() { + test("org.onap.so.client.sdno.beans"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create() + .with(new GetterMustExistRule()) + .with(new SetterMustExistRule()) + .with(new SetterTester()) + .with(new GetterTester()) + .build(); + validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); + } + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } +} diff --git a/common/src/test/java/org/onap/so/entity/MsoRequestTest.java b/common/src/test/java/org/onap/so/entity/MsoRequestTest.java new file mode 100644 index 0000000000..73b5c7ea2d --- /dev/null +++ b/common/src/test/java/org/onap/so/entity/MsoRequestTest.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei 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.so.entity; + +import org.junit.Test; +import org.onap.so.openpojo.rules.HasToStringRule; +import org.onap.so.openpojo.rules.ToStringTester; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoClassFilter; +import com.openpojo.reflection.filters.FilterEnum; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + + +public class MsoRequestTest { + + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + @Test + public void pojoStructure() { + test("org.onap.so.entity"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create() + .with(new GetterMustExistRule()) + .with(new SetterMustExistRule()) + .with(new SetterTester()) + .with(new GetterTester()) + .build(); + validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); + } + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } + +} + diff --git a/common/src/test/java/org/onap/so/exceptions/ValidationExceptionTest.java b/common/src/test/java/org/onap/so/exceptions/ValidationExceptionTest.java new file mode 100644 index 0000000000..b3ae7ba9f5 --- /dev/null +++ b/common/src/test/java/org/onap/so/exceptions/ValidationExceptionTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.exceptions; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by ANANDSAN on 4/12/2018. + */ +public class ValidationExceptionTest { + @Test + public void validationExceptionOverrideMessageFalse(){ + ValidationException e = new ValidationException("testMessage", false); + Assert.assertEquals("testMessage", e.getMessage()); + } + + @Test + public void validationExceptionOverrideMessageTrue(){ + ValidationException e = new ValidationException("testMessage", true); + Assert.assertEquals("No valid testMessage is specified", e.getMessage()); + } + + @Test + public void validationException(){ + ValidationException e = new ValidationException("testMessage"); + Assert.assertEquals("No valid testMessage is specified", e.getMessage()); + } + + @Test + public void validationExceptionVersion(){ + ValidationException e = new ValidationException("testMessage", "1.0"); + Assert.assertEquals("testMessage is not valid in the 1.0 version", e.getMessage()); + } +} diff --git a/common/src/test/java/org/onap/so/jsonpath/JsonPathUtilTest.java b/common/src/test/java/org/onap/so/jsonpath/JsonPathUtilTest.java new file mode 100644 index 0000000000..06e25daa98 --- /dev/null +++ b/common/src/test/java/org/onap/so/jsonpath/JsonPathUtilTest.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.jsonpath; + +import static org.junit.Assert.assertEquals; + +import java.util.Collections; +import java.util.Optional; + +import org.junit.Test; + +public class JsonPathUtilTest { + + private static final String json = "{\"test\" : \"hello\", \"test2\" : {\"nested\" : \"value\"}}"; + @Test + public void pathExistsTest() { + assertEquals("test is found", JsonPathUtil.getInstance().pathExists(json, "$.test"), true); + assertEquals("nothing is not found", JsonPathUtil.getInstance().pathExists(json, "$.nothing"), false); + } + + @Test + public void locateResultTest() { + assertEquals("value of hello is found", Optional.of("hello"), JsonPathUtil.getInstance().locateResult(json, "$.test")); + assertEquals("nothing returns empty", Optional.empty(), JsonPathUtil.getInstance().locateResult(json, "$.nothing")); + } + + @Test + public void simpleAndComplexValues() { + assertEquals("json doc found", Optional.of("{\"nested\":\"value\"}"), JsonPathUtil.getInstance().locateResult(json, "$.test2")); + assertEquals("value found", Optional.of("value"), JsonPathUtil.getInstance().locateResult(json, "$.test2.nested")); + } + + @Test + public void pathListTest() { + assertEquals(Collections.singletonList("$['test2']['nested']"), JsonPathUtil.getInstance().getPathList(json, "$.*.*")); + } +} diff --git a/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstanceBeansTest.java b/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstanceBeansTest.java new file mode 100644 index 0000000000..7a4af7808e --- /dev/null +++ b/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstanceBeansTest.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.so.serviceinstancebeans; + +import org.junit.Test; +import org.onap.so.openpojo.rules.HasToStringRule; +import org.onap.so.openpojo.rules.ToStringTester; + +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoClassFilter; +import com.openpojo.reflection.filters.FilterEnum; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +public class ServiceInstanceBeansTest { + + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + @Test + public void pojoStructure() { + test("org.onap.so.serviceinstancebeans"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create() + .with(new GetterMustExistRule()) + .with(new SetterMustExistRule()) + .with(new HasToStringRule()) + .with(new SetterTester()) + .with(new GetterTester()) + .with(new ToStringTester()) + .build(); + validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); + } + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } + +} diff --git a/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequestTest.java b/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequestTest.java new file mode 100644 index 0000000000..2e67ff4b2b --- /dev/null +++ b/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequestTest.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.serviceinstancebeans; + +import org.junit.Assert; +import org.junit.Test; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class ServiceInstancesRequestTest { + + @Test + public void serializeServiceInstance() { + String incomingRequest = "{\"requestDetails\":{\"modelInfo\":{\"modelInvariantUuid\":\"9647dfc4-2083-11e7-93ae-92361f002672\",\"modelType\":\"configuration\",\"modelName\":\"MSO-Configuration\",\"modelVersion\":\"1.0\",\"modelUuid\":\"36a3a8ea-49a6-4ac8-b06c-89a545444455\",\"modelCustomizationUuid\":\"68dc9a92-214c-11e7-93ae-92361f002671\"},\"requestInfo\":{\"source\":\"VID\",\"instanceName\":\"port_mirror_config_m830-01\",\"suppressRollback\":false,\"requestorId\":\"mdg1215\"},\"relatedInstanceList\":[{\"relatedInstance\":{\"instanceId\":\"956121e0-542d-4b30-b8c7-be611e3c8f13\",\"modelInfo\":{\"modelInvariantUuid\":\"9647dfc4-2083-11e7-93ae-92361f002671\",\"modelType\":\"service\",\"modelName\":\"MSOTADevInfra_vSAMP10a_Service\",\"modelVersion\":\"1.0\",\"modelUuid\":\"5df8b6de-2083-11e7-93ae-92361f002671\"}}},{\"relatedInstance\":{\"instanceId\":\"956121e0-542d-4b30-b8c7-be611e3c8f11\",\"modelInfo\":{\"modelInvariantUuid\":\"36a3a8ea-49a6-4ac8-b06c-89a545444456\",\"modelType\":\"vnf\",\"modelName\":\"testvnf\",\"modelVersion\":\"1.0\",\"modelUuid\":\"956121e0-542d-4b30-b8c7-be611e3c8f14\",\"modelCustomizationUuid\":\"68dc9a92-214c-11e7-93ae-92361f002676\"},\"instanceDirection\":\"source\"}},{\"relatedInstance\":{\"instanceId\":\"956121e0-542d-4b30-b8c7-be611e3c8f12\",\"modelInfo\":{\"modelInvariantUuid\":\"36a3a8ea-49a6-4ac8-b06c-89a545444477\",\"modelType\":\"vnf\",\"modelName\":\"svProbe vnf model name\",\"modelVersion\":\"1.0\",\"modelUuid\":\"36a3a8ea-49a6-4ac8-b06c-89a545444488\",\"modelCustomizationUuid\":\"68dc9a92-214c-11e7-93ae-92361f002672\"},\"instanceDirection\":\"destination\"}}],\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\"},\"requestParameters\":{\"subscriptionServiceType\":\"MSO-dev-service-type\",\"userParams\":[{\"name\":\"someUserParam\",\"value\":\"someValue\"}],\"aLaCarte\":false,\"autoBuildVfModules\":false,\"cascadeDelete\":false,\"usePreload\":true,\"rebuildVolumeGroups\":false}},\"serviceInstanceId\":\"956121e0-542d-4b30-b8c7-be611e3c8f13\"}"; + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + try { + ServiceInstancesRequest request = mapper.readValue(incomingRequest, ServiceInstancesRequest.class); + System.out.println("Java Object: " + request); + } catch (Exception e) { + System.out.println("Caught Exception " + e.getMessage()); + Assert.fail("Caught error on object serialization"); + } + } +} diff --git a/common/src/test/java/org/onap/so/utils/CheckResultsTest.java b/common/src/test/java/org/onap/so/utils/CheckResultsTest.java new file mode 100644 index 0000000000..0e1da16b9e --- /dev/null +++ b/common/src/test/java/org/onap/so/utils/CheckResultsTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.utils; + +import static org.junit.Assert.*; + +import java.util.List; + +import org.junit.Test; + +import org.onap.so.utils.CheckResults.CheckResult; + +public class CheckResultsTest { + + /** + * Test method for {@link org.onap.so.utils.CheckResults#getResults()}. + */ + @Test + public final void testGetResults () { + CheckResults cr = new CheckResults (); + cr.addHostCheckResult ("host1", 0, "output"); + cr.addHostCheckResult ("host2", 2, "output2"); + cr.addServiceCheckResult ("host1", "service1", 0, "outputServ"); + cr.addServiceCheckResult ("host1", "service2", 2, "outputServ2"); + cr.addServiceCheckResult ("host2", "service1", 0, "output2Serv"); + cr.addServiceCheckResult ("host2", "service2", 2, "output2Serv2"); + List res = cr.getResults (); + assertEquals(res.size (), 6); + assertEquals(res.get (0).getHostname (), "host1"); + assertEquals(res.get (1).getHostname (), "host2"); + assertEquals(res.get (2).getHostname (), "host1"); + assertEquals(res.get (3).getHostname (), "host1"); + assertEquals(res.get (4).getHostname (), "host2"); + assertEquals(res.get (5).getHostname (), "host2"); + assertEquals(res.get (0).getServicename (), null); + assertEquals(res.get (3).getServicename (), "service2"); + assertEquals(res.get (5).getState (), 2); + } + +} diff --git a/common/src/test/java/org/onap/so/utils/TestAppender.java b/common/src/test/java/org/onap/so/utils/TestAppender.java new file mode 100644 index 0000000000..fba9c71c68 --- /dev/null +++ b/common/src/test/java/org/onap/so/utils/TestAppender.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.utils; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.AppenderBase; + +import java.util.ArrayList; +import java.util.List; + + +public class TestAppender extends AppenderBase { + public static List events = new ArrayList<>(); + + @Override + protected void append(ILoggingEvent loggingEvent) { + if (loggingEvent.getLevel() == Level.INFO) { + events.add(loggingEvent); + } + } + +} diff --git a/common/src/test/java/org/onap/so/utils/UUIDCheckerTest.java b/common/src/test/java/org/onap/so/utils/UUIDCheckerTest.java new file mode 100644 index 0000000000..b4058a7ba8 --- /dev/null +++ b/common/src/test/java/org/onap/so/utils/UUIDCheckerTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.utils; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.onap.so.logger.MsoLogger; + +public class UUIDCheckerTest { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL, UUIDCheckerTest.class); + + @Test + public void isValidUUIDTest(){ + String nullID = null; + String badID = "This is not a UUID"; + String id = UUIDChecker.getUUID(); + assertFalse(UUIDChecker.isValidUUID(nullID)); + assertFalse(UUIDChecker.isValidUUID(badID)); + assertTrue(UUIDChecker.isValidUUID(id)); + } + + @Test + public void verifyOldUUIDTest(){ + String oldID = UUIDChecker.getUUID(); + String invalidID = "This is not a UUID"; + assertEquals(UUIDChecker.verifyOldUUID(oldID,LOGGER),oldID); + assertNotEquals(UUIDChecker.verifyOldUUID(invalidID,LOGGER),invalidID); + } + + @Test + public void generateTest(){ + String id = UUIDChecker.generateUUID(LOGGER); + assertNotNull(id); + assertTrue(UUIDChecker.isValidUUID(id)); + + id = UUIDChecker.generateServiceInstanceID(LOGGER); + assertNotNull(id); + assertTrue(UUIDChecker.isValidUUID(id)); + + } +} diff --git a/common/src/test/java/org/onap/so/utils/XMLMarshallerTest.java b/common/src/test/java/org/onap/so/utils/XMLMarshallerTest.java new file mode 100644 index 0000000000..148e1b452c --- /dev/null +++ b/common/src/test/java/org/onap/so/utils/XMLMarshallerTest.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * 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.so.utils; + +import org.junit.Assert; +import org.junit.Test; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Tests the XMLMarshaller to ensure that it's able to marshal and unmarshall a POJO + */ + +public class XMLMarshallerTest { + + @Test + public void testMarshal() throws Exception { + Assert.assertEquals(getXML(), XmlMarshaller.marshal(getPOJO())); + } + + @Test + public void testUnMarshal() throws Exception { + Assert.assertEquals(XmlMarshaller.unMarshal(getXML(), new TestPOJO()), getPOJO()); + } + + private TestPOJO getPOJO() { + TestPOJO testPOJO = new TestPOJO(); + testPOJO.setFirstName("FN"); + testPOJO.setLastName("LN"); + return testPOJO; + } + + private String getXML() { + return "FNLN"; + } + + @XmlRootElement + static class TestPOJO { + String firstName; + String lastName; + + public TestPOJO() { + } + + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof TestPOJO)) return false; + + TestPOJO testPOJO = (TestPOJO) o; + + if (getFirstName() != null ? !getFirstName().equals(testPOJO.getFirstName()) : testPOJO.getFirstName() != null) + return false; + return getLastName() != null ? getLastName().equals(testPOJO.getLastName()) : testPOJO.getLastName() == null; + } + + @Override + public int hashCode() { + int result = getFirstName() != null ? getFirstName().hashCode() : 0; + result = 31 * result + (getLastName() != null ? getLastName().hashCode() : 0); + return result; + } + } + + +} diff --git a/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java b/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java new file mode 100644 index 0000000000..8bcc73515b --- /dev/null +++ b/common/src/test/java/org/onap/so/web/exceptions/RuntimeExceptionMapperTest.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.so.web.exceptions; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import javax.ws.rs.NotFoundException; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; + +import org.junit.AfterClass; +import org.junit.Test; +import org.onap.so.logger.MsoAlarmLogger; + +public class RuntimeExceptionMapperTest { + + + @AfterClass + public static void tearDown() { + MsoAlarmLogger logger = new MsoAlarmLogger(); + logger.resetAppender(); + } + + @Test + public void testResponse() { + + RuntimeExceptionMapper mapper = new RuntimeExceptionMapper(); + + Response r = mapper.toResponse(new RuntimeException("This is the run time exception message")); + + assertEquals(Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus()); + assertThat(r.getEntity(), instanceOf(ExceptionResponse.class)); + assertThat(((ExceptionResponse)r.getEntity()).getMessage(), equalTo("Unexpected Internal Exception")); + + } + + @Test + public void preserve404ExceptionForForwarding() { + + RuntimeExceptionMapper mapper = new RuntimeExceptionMapper(); + + Response r = mapper.toResponse(new NotFoundException("not found")); + + assertEquals(Status.NOT_FOUND.getStatusCode(), r.getStatus()); + assertThat(r.getEntity(), is(nullValue())); + } + +} diff --git a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/CryptoTest.java b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/CryptoTest.java deleted file mode 100644 index 3415420c88..0000000000 --- a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/CryptoTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapter_utils.tests; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.security.GeneralSecurityException; - -import org.junit.BeforeClass; -import org.junit.Test; - -import org.openecomp.mso.utils.CryptoUtils; - -/** - * This class implements all test methods of the CryptoUtils features. - * - * - */ -public class CryptoTest { - - private static String testKey = "546573746F736973546573746F736973"; - - /** - * This method is called before any test occurs. - * It creates a fake tree from scratch - */ - @BeforeClass - public static final void prepare () { - - } - - /** - * This method implements a test of tree structure, mainly the storage of the leaves structure. - * @throws GeneralSecurityException - */ - @Test - public final void testEncryption () throws GeneralSecurityException { - String hexString = CryptoUtils.byteArrayToHexString("testosistestosi".getBytes()); - - final String testData = "This is a test string"; - final String nonTestData = "This is not the right String"; - - String encodeString = CryptoUtils.encrypt(testData, testKey); - - assertNotNull(encodeString); - - assertTrue(testData.equals(CryptoUtils.decrypt(encodeString, testKey))); - assertFalse(nonTestData.equals(CryptoUtils.decrypt(encodeString, testKey))); - - String encode2String = CryptoUtils.encrypt(testData, testKey); - assertNotNull(encode2String); - - assertEquals(encodeString,encode2String); - - assertEquals(CryptoUtils.decrypt(encodeString, testKey),CryptoUtils.decrypt(encode2String, testKey)); - } - -} diff --git a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoAlarmLoggerTest.java b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoAlarmLoggerTest.java deleted file mode 100644 index f7d27acaf3..0000000000 --- a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoAlarmLoggerTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapter_utils.tests; - - -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintWriter; - -import org.junit.BeforeClass; -import org.junit.Test; - -import org.openecomp.mso.logger.MsoAlarmLogger; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoPropertiesException; -import org.openecomp.mso.properties.MsoPropertiesFactory; - -/** - * This junit test very roughly the alarm logger - * - */ -public class MsoAlarmLoggerTest { - - public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - public static MsoAlarmLogger msoAlarmLogger; - - @BeforeClass - public static final void createObjects() throws MsoPropertiesException - { - - File outputFile = new File ("target/alarm-test.log"); - if (outputFile.exists()) { - outputFile.delete(); - } - msoAlarmLogger = new MsoAlarmLogger("target/alarm-test.log"); - } - - @Test - public void testAlarmConfig() throws MsoPropertiesException, IOException { - - msoAlarmLogger.sendAlarm("test", 0, "detail message"); - - FileInputStream inputStream = new FileInputStream("target/alarm-test.log"); - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); - - String line = reader.readLine(); - String[] splitLine = line.split("\\|"); - assertTrue(splitLine.length==4); - assertTrue("test".equals(splitLine[1])); - assertTrue("0".equals(splitLine[2])); - assertTrue("detail message".equals(splitLine[3])); - - line = reader.readLine(); - assertNull(line); - reader.close(); - inputStream.close(); - - // Reset the file for others tests - PrintWriter writer = new PrintWriter(new File("target/alarm-test.log")); - writer.print(""); - writer.close(); - - } - - @Test - public void testAlarm() throws IOException { - - msoAlarmLogger.sendAlarm("test", 0, "detail message"); - msoAlarmLogger.sendAlarm("test2", 1, "detail message2"); - msoAlarmLogger.sendAlarm("test3", 2, "detail message3"); - - FileInputStream inputStream = new FileInputStream("target/alarm-test.log"); - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); - - String line = reader.readLine(); - String[] splitLine = line.split("\\|"); - assertTrue(splitLine.length==4); - assertTrue("test".equals(splitLine[1])); - assertTrue("0".equals(splitLine[2])); - assertTrue("detail message".equals(splitLine[3])); - - line = reader.readLine(); - splitLine = line.split("\\|"); - assertTrue(splitLine.length==4); - assertTrue("test2".equals(splitLine[1])); - assertTrue("1".equals(splitLine[2])); - assertTrue("detail message2".equals(splitLine[3])); - - line = reader.readLine(); - splitLine = line.split("\\|"); - assertTrue(splitLine.length==4); - assertTrue("test3".equals(splitLine[1])); - assertTrue("2".equals(splitLine[2])); - assertTrue("detail message3".equals(splitLine[3])); - - line = reader.readLine(); - assertNull(line); - reader.close(); - inputStream.close(); - - // Reset the file for others tests - PrintWriter writer = new PrintWriter(new File("target/alarm-test.log")); - writer.print(""); - writer.close(); - - } -} diff --git a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoLoggerTest.java b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoLoggerTest.java deleted file mode 100644 index 6ac7002101..0000000000 --- a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoLoggerTest.java +++ /dev/null @@ -1,331 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapter_utils.tests; - -import org.openecomp.mso.entity.MsoRequest; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.logger.MsoLogger.ErrorCode; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.slf4j.MDC; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.PrintWriter; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URL; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; - -/** - * This class implements all test methods of the MsoLogger features. - * - * - */ -public class MsoLoggerTest { - - static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - - /** - * This method is called before any test occurs. It creates a fake tree from - * scratch - */ - @BeforeClass - public static final void prepare() { - - } - - @Before - public final void cleanErrorLogFile() throws FileNotFoundException { - URL url = this.getClass().getClassLoader().getResource("logback-test.xml"); - String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) - + "/MSO/Test/errorjboss.server.name_IS_UNDEFINED.log"; - PrintWriter asdcConfigFileWriter = new PrintWriter(logFile); - asdcConfigFileWriter.print(""); - asdcConfigFileWriter.flush(); - asdcConfigFileWriter.close(); - } - - @Before - public final void cleanMetricLogFile() throws FileNotFoundException { - URL url = this.getClass().getClassLoader().getResource("logback-test.xml"); - String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) - + "/MSO/Test/metricsjboss.server.name_IS_UNDEFINED.log"; - PrintWriter asdcConfigFileWriter = new PrintWriter(logFile); - asdcConfigFileWriter.print(""); - asdcConfigFileWriter.flush(); - asdcConfigFileWriter.close(); - } - - @Before - public final void cleanAuditLogFile() throws FileNotFoundException { - URL url = this.getClass().getClassLoader().getResource("logback-test.xml"); - String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) - + "/MSO/Test/auditjbo.server.name_IS_UNDEFINED.log"; - PrintWriter asdcConfigFileWriter = new PrintWriter(logFile); - asdcConfigFileWriter.print(""); - asdcConfigFileWriter.flush(); - asdcConfigFileWriter.close(); - } - - /** - * This method implements a test of getSeverifyLevel method. - */ - @Test - public final void testGetSeverityLevel() { - - try { - String levelInfo = (String) invokePriveMethod("getSeverityLevel", "INFO"); - Assert.assertEquals(levelInfo, "0"); - - String levelWarn = (String) invokePriveMethod("getSeverityLevel", "WARN"); - Assert.assertEquals(levelWarn, "1"); - - String levelERROR = (String) invokePriveMethod("getSeverityLevel", "ERROR"); - Assert.assertEquals(levelERROR, "2"); - - String levelDEBUG = (String) invokePriveMethod("getSeverityLevel", "DEBUG"); - Assert.assertEquals(levelDEBUG, "0"); - - String levelFATAL = (String) invokePriveMethod("getSeverityLevel", "FATAL"); - Assert.assertEquals(levelFATAL, "3"); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * This method implements a test of getFinalServiceName method. - */ - @Test - public final void testGetFinalServiceName() { - try { - String serviceName1 = (String) invokePriveMethod("getFinalServiceName", "testServiceName1"); - Assert.assertEquals(serviceName1, "testServiceName1"); - - MsoLogger.setServiceName("testServiceName2"); - String serviceName2 = (String) invokePriveMethod("getFinalServiceName", "testServiceName1"); - Assert.assertEquals(serviceName2, "testServiceName1"); - - String msgNull = null; - String serviceName3 = (String) invokePriveMethod("getFinalServiceName", msgNull); - Assert.assertEquals(serviceName3, "testServiceName2"); - - MsoLogger.resetServiceName(); - String serviceName4 = (String) invokePriveMethod("getFinalServiceName", msgNull); - Assert.assertEquals(serviceName4, "invoke0"); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public final void testPrepareMsg() { - try { - String msgNull = null; - MDC.clear(); - invokePrepareMsg("INFO", null, null); - - Assert.assertTrue(MDC.get(MsoLogger.REQUEST_ID).equals("trace-#") - && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("trace-#") - && MDC.get(MsoLogger.SERVICE_NAME).equals("invoke0") && MDC.get(MsoLogger.TIMER) == null - && MDC.get(MsoLogger.ALERT_SEVERITY).equals("0")); - - MsoLogger.setLoggerParameters("testRemoteIp", "testUser"); - MsoLogger.setLogContext("testReqId", "testSvcId"); - invokePrepareMsg("ERROR", "testServiceName3", null); - Assert.assertTrue(MDC.get(MsoLogger.REQUEST_ID).equals("testReqId") - && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("testSvcId") - && MDC.get(MsoLogger.SERVICE_NAME).equals("testServiceName3") && MDC.get(MsoLogger.TIMER) == null - && MDC.get(MsoLogger.ALERT_SEVERITY).equals("2")); - - MsoLogger.setServiceName("testServiceName2"); - invokePrepareMsg("WARN", msgNull, msgNull); - Assert.assertTrue(MDC.get(MsoLogger.REQUEST_ID).equals("testReqId") - && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("testSvcId") - && MDC.get(MsoLogger.SERVICE_NAME).equals("testServiceName2") && MDC.get(MsoLogger.TIMER) == null - && MDC.get(MsoLogger.ALERT_SEVERITY).equals("1")); - - MDC.clear(); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("reqId2"); - msoRequest.setServiceInstanceId("servId2"); - MsoLogger.setLogContext(msoRequest); - invokePrepareMsg("FATAL", null, "123"); - Assert.assertTrue(MDC.get(MsoLogger.REQUEST_ID).equals("reqId2") - && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("servId2") - && MDC.get(MsoLogger.TIMER).equals("123") && MDC.get(MsoLogger.ALERT_SEVERITY).equals("3")); - - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * This method implements a test of log methods - */ - @Test - @Ignore - public final void testLogMethods() { - try { - MDC.clear(); - MsoLogger.setLogContext("reqId2", "servId2"); - MsoLogger.setServiceName("MSO.testServiceName"); - msoLogger.info(MessageEnum.LOGGER_UPDATE_SUC, "testLogger", "INFO", "DEBUG", "target entity", - "target service"); - msoLogger.warn(MessageEnum.GENERAL_WARNING, "warning test", "", "", MsoLogger.ErrorCode.UnknownError, - "warning test"); - msoLogger.error(MessageEnum.GENERAL_EXCEPTION, "target entity", "target service", - MsoLogger.ErrorCode.UnknownError, "error test"); - - // Fetch from the error log - URL url = this.getClass().getClassLoader().getResource("logback-test.xml"); - String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) - + "/MSO/Test/errorjboss.server.name_IS_UNDEFINED.log"; - - Path filePath = new File(logFile).toPath(); - Charset charset = Charset.defaultCharset(); - List stringList = Files.readAllLines(filePath, charset); - String[] stringArray = stringList.toArray(new String[] {}); - int size = stringArray.length; - - Assert.assertTrue(stringArray[size - 3] - .contains("|reqId2|main|MSO.testServiceName||target entity|target service|INFO|null||") - && stringArray[size - 3].contains( - "||MSO-GENERAL-5408I Successfully update Logger: testLogger from level INFO to level DEBUG")); - Assert.assertTrue(stringArray[size - 2] - .contains("|reqId2|main|MSO.testServiceName||||WARN|UnknownError|warning test|") - && stringArray[size - 2].contains("|MSO-GENERAL-5401W WARNING: warning test")); - Assert.assertTrue(stringArray[size - 1].contains( - "|reqId2|main|MSO.testServiceName||target entity|target service|ERROR|UnknownError|error test|") - && stringArray[size - 1].contains("|MSO-GENERAL-9401E Exception encountered")); - - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * This method implements a test of recordMetricEvent method. - * - * @throws IOException - */ - @Test - @Ignore - public final void testRecordMetricEvent() throws IOException { - MDC.clear(); - MsoLogger.setLogContext("reqId", "servId"); - msoLogger.recordMetricEvent(123456789L, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful", - "VNF", "createVNF", null); - MDC.put(MsoLogger.REMOTE_HOST, "127.0.0.1"); - MDC.put(MsoLogger.PARTNERNAME, "testUser"); - msoLogger.recordMetricEvent(123456789L, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.ServiceNotAvailable, - "Exception", "SDNC", "removeSDNC", "testVNF"); - - // Fetch from the metric log - URL url = this.getClass().getClassLoader().getResource("logback-test.xml"); - String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) - + "/MSO/Test/metricsjboss.server.name_IS_UNDEFINED.log"; - - Path filePath = new File(logFile).toPath(); - Charset charset = Charset.defaultCharset(); - List stringList = Files.readAllLines(filePath, charset); - String[] stringArray = stringList.toArray(new String[] {}); - msoLogger.error(MessageEnum.GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.UnknownError, "test error msg"); - - Assert.assertTrue(stringArray[0] - .contains("|reqId|servId|main||testRecordMetricEvent||VNF|createVNF|COMPLETE|0|Successful|")); - // count the occurance of symbol "|" - Assert.assertTrue((stringArray[0].length() - stringArray[0].replace("|", "").length()) == 28); - Assert.assertTrue(stringArray[1] - .contains("|reqId|servId|main||testRecordMetricEvent|testUser|SDNC|removeSDNC|ERROR|501|Exception|") - && stringArray[1].contains("|127.0.0.1||||testVNF|||||")); - Assert.assertTrue((stringArray[1].length() - stringArray[1].replace("|", "").length()) == 28); - } - - /** - * This method implements a test of testRecordAuditEvent method. - */ - - // User reflection to invoke to avoid change the publicity of the method - private static String invokePrepareMsg(String arg1, String arg2, String arg3) { - Method method; - try { - method = MsoLogger.class.getDeclaredMethod("prepareMsg", String.class, String.class, String.class); - method.setAccessible(true); - return (String) method.invoke(msoLogger, arg1, arg2, arg3); - } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } - - // User reflection to invoke to avoid change the publicity of the method - private static Object invokePriveMethod(String methodName, String arg) { - Method method; - try { - method = MsoLogger.class.getDeclaredMethod(methodName, String.class); - method.setAccessible(true); - return method.invoke(msoLogger, arg); - } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } -} diff --git a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java deleted file mode 100644 index a814c4ea9c..0000000000 --- a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryConcurrencyTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapter_utils.tests; - - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -import org.junit.BeforeClass; -import org.junit.Test; - -import org.openecomp.mso.properties.AbstractMsoProperties; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoPropertiesException; -import org.openecomp.mso.properties.MsoPropertiesFactory; - -/** - * This class implements test methods of the MsoPropertiesFactory features. - * - * - */ -public class MsoPropertiesFactoryConcurrencyTest { - - public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - - public static final String MSO_PROP_ID = "TEST_PROP"; - public static final String PATH_MSO_PROP1 = MsoJavaProperties.class.getClassLoader().getResource("mso.properties") - .toString().substring(5); - public static final String PATH_MSO_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.properties") - .toString().substring(5); - - /** - * This method is called before any test occurs. It creates a fake tree from - * scratch - * - * @throws MsoPropertiesException - */ - @BeforeClass - public static final void prepare() throws MsoPropertiesException { - // it's possible to have it already initialized, as tests are executed in the same JVM - msoPropertiesFactory.removeAllMsoProperties (); - msoPropertiesFactory.initializeMsoProperties(MSO_PROP_ID, PATH_MSO_PROP1); - } - - private Callable taskReload = new Callable() { - @Override - public Integer call() { - try { - if (!msoPropertiesFactory.reloadMsoProperties()) { - return 1; - } - } catch (Exception e) { - e.printStackTrace (); - return 1; - } - return 0; - } - }; - - private Callable taskRead = new Callable() { - @Override - public Integer call() { - try { - MsoJavaProperties msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_ID); - String property1 = msoProperties.getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue"); - String property2 = msoProperties.getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue"); - String property3 = msoProperties.getProperty("ecomp.mso.cloud.1.msoId", "defaultValue"); - String property4 = msoProperties.getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue"); - String property5 = msoProperties.getProperty("does.not.exist", "defaultValue"); - String property6 = msoProperties.getProperty("ecomp.mso.cloud.1.test", "defaultValue"); - String property7 = msoProperties.getProperty("ecomp.mso.cloud.1.boolean", "defaultValue"); - - assertEquals(property1, "MT"); - assertEquals(property2, "http://localhost:5000/v2.0"); - assertEquals(property3, "John"); - assertEquals(property4, "FD205490A48D48475607C36B9AD902BF"); - assertEquals(property5, "defaultValue"); - assertEquals(property6, "1234"); - assertEquals(property7, "true"); - - } catch (MsoPropertiesException e) { - e.printStackTrace (); - return 1; - } - return 0; - } - }; - - private Callable taskReadAll = new Callable() { - @Override - public Integer call() { - try { - List msoPropertiesList = msoPropertiesFactory.getAllMsoProperties(); - String property1 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue"); - String property2 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue"); - String property3 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.msoId", "defaultValue"); - String property4 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue"); - String property5 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("does.not.exist", "defaultValue"); - String property6 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.test", "defaultValue"); - String property7 = ((MsoJavaProperties)msoPropertiesList.get(0)).getProperty("ecomp.mso.cloud.1.boolean", "defaultValue"); - - assertEquals(property1, "MT"); - assertEquals(property2, "http://localhost:5000/v2.0"); - assertEquals(property3, "John"); - assertEquals(property4, "FD205490A48D48475607C36B9AD902BF"); - assertEquals(property5, "defaultValue"); - assertEquals(property6, "1234"); - assertEquals(property7, "true"); - } catch (Exception e) { - e.printStackTrace (); - return 1; - } - return 0; - } - }; - - @Test - public final void testGetMsoProperties() - throws MsoPropertiesException, InterruptedException, ExecutionException, FileNotFoundException { - - List> list = new ArrayList<>(); - ExecutorService executor = Executors.newFixedThreadPool(20); - - for (int i = 0; i <= 100000; i++) { - - Future futureResult = executor.submit(taskRead); - list.add(futureResult); - - futureResult = executor.submit(taskReload); - list.add(futureResult); - - futureResult = executor.submit(taskReadAll); - list.add(futureResult); - } - executor.shutdown(); - while (!executor.awaitTermination(5, TimeUnit.SECONDS)) { - ; - } - - for (Future result : list) { - assertTrue(result.get().equals(0)); - } - - } - -} diff --git a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryTest.java b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryTest.java deleted file mode 100644 index db58c5a49e..0000000000 --- a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertiesFactoryTest.java +++ /dev/null @@ -1,611 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapter_utils.tests; - - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoJsonProperties; -import org.openecomp.mso.properties.MsoPropertiesException; -import org.openecomp.mso.properties.MsoPropertiesFactory; - -import com.fasterxml.jackson.databind.JsonNode; - -/** - * This class implements test methods of the MsoPropertiesFactory features. - * - * - */ -public class MsoPropertiesFactoryTest { - - public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - - public static final String MSO_JAVA_PROP_ID = "TEST_JAVA_PROP"; - public static final String MSO_JSON_PROP_ID = "TEST_JSON_PROP"; - public static final String PATH_MSO_JAVA_PROP1 = MsoJavaProperties.class.getClassLoader().getResource("mso.properties") - .toString().substring(5); - public static final String PATH_MSO_JAVA_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.properties") - .toString().substring(5); - public static final String PATH_MSO_JSON_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json") - .toString().substring(5); - public static final String PATH_MSO_JSON_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json") - .toString().substring(5); - public static final String PATH_MSO_JSON_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json") - .toString().substring(5); - - @BeforeClass - public static final void prepareBeforeAllTests() { - msoPropertiesFactory.removeAllMsoProperties(); - } - /** - * This method is called before any test occurs. It creates a fake tree from - * scratch - * - * @throws MsoPropertiesException - */ - @Before - public final void prepareBeforeEachTest() throws MsoPropertiesException { - - msoPropertiesFactory.initializeMsoProperties(MSO_JAVA_PROP_ID, PATH_MSO_JAVA_PROP1); - msoPropertiesFactory.initializeMsoProperties(MSO_JSON_PROP_ID, PATH_MSO_JSON_PROP); - } - - @After - public final void cleanAfterEachTest() throws MsoPropertiesException { - msoPropertiesFactory.removeAllMsoProperties (); - } - - @Test - public final void testNotRecognizedFile() { - try { - msoPropertiesFactory.initializeMsoProperties("BAD_FILE", "new_file.toto"); - - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("Unable to load the MSO properties file because format is not recognized (only .json or .properties): new_file.toto").equals(ep.getMessage())); - } - } - - @Test - public final void testDoubleInit() { - - try { - msoPropertiesFactory.initializeMsoProperties(MSO_JAVA_PROP_ID, PATH_MSO_JAVA_PROP1); - - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("The factory contains already an instance of this mso properties: "+PATH_MSO_JAVA_PROP1).equals(ep.getMessage())); - } - - - } - - /** - * This method implements a test for the getMsoJavaProperties method. - * - * @throws MsoPropertiesException - */ - @Test - public final void testGetMsoJavaProperties() throws MsoPropertiesException { - assertNotNull(msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID)); - assertTrue(msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID).size()==8); - - try { - msoPropertiesFactory.getMsoJavaProperties(MSO_JSON_PROP_ID); - - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("Mso properties is not JAVA_PROP properties type:" + MSO_JSON_PROP_ID).equals(ep.getMessage())); - } - - try { - msoPropertiesFactory.getMsoJavaProperties("DUMB_PROP"); - - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("Mso properties not found in cache:"+"DUMB_PROP").equals(ep.getMessage())); - } - - } - - /** - * This method test the MsoJavaProperties Set, equals and hascode - * @throws MsoPropertiesException - */ - @Test - public final void testSetMsoJavaProperties() throws MsoPropertiesException { - MsoJavaProperties msoPropChanged = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - msoPropChanged.setProperty("testos", "testos"); - assertNotNull(msoPropChanged.getProperty("testos", null)); - - // Check no modification occurred on cache one - MsoJavaProperties msoPropCache = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - assertNull(msoPropCache.getProperty("testos", null)); - assertFalse(msoPropChanged.hashCode() != msoPropCache.hashCode()); - - assertFalse(msoPropChanged.equals(null)); - assertFalse(msoPropChanged.equals(msoPropCache)); - assertFalse(msoPropChanged.equals(Boolean.TRUE)); - - assertTrue(msoPropChanged.equals(msoPropChanged)); - } - - - /** - * This method implements a test for the testGetMsoJsonProperties method. - * - * @throws MsoPropertiesException - */ - @Test - public final void testGetMsoJsonProperties() throws MsoPropertiesException { - assertNotNull(msoPropertiesFactory.getMsoJsonProperties(MSO_JSON_PROP_ID)); - - try { - msoPropertiesFactory.getMsoJsonProperties(MSO_JAVA_PROP_ID); - - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("Mso properties is not JSON_PROP properties type:" + MSO_JAVA_PROP_ID).equals(ep.getMessage())); - } - - try { - msoPropertiesFactory.getMsoJsonProperties("DUMB_PROP"); - - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("Mso properties not found in cache:"+"DUMB_PROP").equals(ep.getMessage())); - } - - } - - /** - * This method implements a test for the testGetAllMsoProperties method. - * - * @throws MsoPropertiesException - */ - @Test - public final void testGetAllMsoProperties() throws MsoPropertiesException { - assertNotNull(msoPropertiesFactory.getAllMsoProperties().size()==2); - - } - - /** - * This method implements a test for the testGetAllMsoProperties method. - * - * @throws MsoPropertiesException - */ - @Test - public final void testToString() throws MsoPropertiesException { - String dump = msoPropertiesFactory.getMsoJsonProperties(MSO_JSON_PROP_ID).toString(); - assertTrue(dump != null && !dump.isEmpty()); - - dump = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID).toString(); - assertTrue(dump != null && !dump.isEmpty()); - - } - - /** - * This method implements a test for the getProperty of JAVA_PROP type method. - * - * @throws MsoPropertiesException - */ - @Test - public final void testGetProperties() throws MsoPropertiesException { - MsoJavaProperties msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - - String property1 = msoProperties.getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue"); - String property2 = msoProperties.getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue"); - String property3 = msoProperties.getProperty("ecomp.mso.cloud.1.msoId", "defaultValue"); - String property4 = msoProperties.getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue"); - String property5 = msoProperties.getProperty("does.not.exist", "defaultValue"); - String property6 = msoProperties.getProperty("ecomp.mso.cloud.1.test", "defaultValue"); - String property7 = msoProperties.getProperty("ecomp.mso.cloud.1.boolean", "defaultValue"); - - assertEquals(property1, "MT"); - assertEquals(property2, "http://localhost:5000/v2.0"); - assertEquals(property3, "John"); - assertEquals(property4, "FD205490A48D48475607C36B9AD902BF"); - assertEquals(property5, "defaultValue"); - assertEquals(property6, "1234"); - assertEquals(property7, "true"); - } - - /** - * This method implements a test for the getIntProperty JAVA_RPOP type method. - * - * @throws MsoPropertiesException - */ - @Test - public final void testGetIntProperties() throws MsoPropertiesException { - MsoJavaProperties msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - int property1 = msoProperties.getIntProperty("ecomp.mso.cloud.1.test", 345); - int property2 = msoProperties.getIntProperty("ecomp.mso.cloud.1.publicNetId", 345); - int property3 = msoProperties.getIntProperty("does.not.exist", 345); - assertEquals(property1, 1234); - assertEquals(property2, 345); - assertEquals(property3, 345); - } - - /** - * This method implements a test for the getBooleanProperty JAVA_RPOP type method. - * - * @throws MsoPropertiesException - */ - @Test - public final void testGetBooleanProperty() throws MsoPropertiesException { - MsoJavaProperties msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - boolean property1 = msoProperties.getBooleanProperty("ecomp.mso.cloud.1.boolean", false); - boolean property2 = msoProperties.getBooleanProperty("ecomp.mso.cloud.1.publicNetId", false); - boolean property3NotThere = msoProperties.getBooleanProperty("ecomp.mso.cloud.1.publicNetIdBad", true); - - assertEquals(property1, true); - assertEquals(property2, false); - assertEquals(property3NotThere, true); - } - - /** - * This method implements a test for the getEncryptedProperty JAVA_RPOP type method. - * - * @throws MsoPropertiesException - */ - @Test - public final void testGetEncryptedProperty() throws MsoPropertiesException { - MsoJavaProperties msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - String property1 = msoProperties.getEncryptedProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue", - "aa3871669d893c7fb8abbcda31b88b4f"); - String property2 = msoProperties.getEncryptedProperty("test", "defaultValue", - "aa3871669d893c7fb8abbcda31b88b4f"); - - - String property3Wrong = msoProperties.getEncryptedProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue", - "aa3871669d893c7fb8abbcda31b88b4"); - - - assertEquals(property1, "changeme"); - assertEquals(property2, "defaultValue"); - assertEquals(property3Wrong, "defaultValue"); - } - - /** - * This method implements a test for the getEncryptedProperty JAVA_RPOP type method. - * - * @throws MsoPropertiesException - */ - @Test - public final void testencryptProperty() { - - assertTrue("FD205490A48D48475607C36B9AD902BF" - .contains(msoPropertiesFactory.encryptProperty("changeme", "aa3871669d893c7fb8abbcda31b88b4f").getEntity().toString())); - - - assertTrue("Invalid AES key length: 15 bytes".contains(msoPropertiesFactory.encryptProperty("changeme", "aa3871669d893c7fb8abbcda31b88b4").getEntity().toString())); - - } - - /** - * This method implements a test for the getJSON JSON_RPOP type method. - * - * @throws MsoPropertiesException - */ - @Test - public final void testGetJsonNode() throws MsoPropertiesException { - MsoJsonProperties msoProperties = msoPropertiesFactory.getMsoJsonProperties(MSO_JSON_PROP_ID); - - JsonNode propNode = msoProperties.getJsonRootNode(); - assertNotNull(propNode); - assertFalse(propNode.toString().isEmpty()); - assertTrue(propNode.isContainerNode()); - assertNotNull(propNode.path("asdc-connections").path("asdc-controller1")); - assertNotNull(propNode.path("asdc-connections").path("asdc-controller2")); - - } - - /** - * This method implements a test for the reloadMsoProperties method. - * - * @throws MsoPropertiesException - * - */ - @Test - public final void testReloadJavaMsoProperties() throws MsoPropertiesException { - MsoJavaProperties msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - - // Do some additional test on propertiesHaveChanged method - assertTrue(msoPropertiesFactory.propertiesHaveChanged(MSO_JAVA_PROP_ID, null)); - - // Change path with bad one - try { - msoPropertiesFactory.changeMsoPropertiesFilePath("DO_NOT_EXIST", PATH_MSO_JAVA_PROP2); - - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("Mso properties not found in cache:DO_NOT_EXIST").equals(ep.getMessage())); - } - - - // Change path with right one - msoPropertiesFactory.changeMsoPropertiesFilePath(MSO_JAVA_PROP_ID, PATH_MSO_JAVA_PROP2); - assertTrue(PATH_MSO_JAVA_PROP2.equals(msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID).getPropertiesFileName())); - - assertTrue(msoPropertiesFactory.reloadMsoProperties()); - assertFalse(msoPropertiesFactory.propertiesHaveChanged(MSO_JAVA_PROP_ID, msoProperties)); - // Do a second time as timer value is set to 2 - assertTrue(msoPropertiesFactory.reloadMsoProperties()); - assertTrue(msoPropertiesFactory.propertiesHaveChanged(MSO_JAVA_PROP_ID, msoProperties)); - - // Get the new one - msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - String property1 = msoProperties.getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue"); - String property2 = msoProperties.getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue"); - String property3 = msoProperties.getProperty("ecomp.mso.cloud.1.msoId", "defaultValue"); - String property4 = msoProperties.getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue"); - String property5 = msoProperties.getProperty("does.not.exist", "defaultValue"); - String property6 = msoProperties.getProperty("ecomp.mso.cloud.1.test", "defaultValue"); - String property7 = msoProperties.getProperty("ecomp.mso.cloud.1.boolean", "defaultValue"); - - assertEquals(property1, "MT2"); - assertEquals(property2, "defaultValue"); - assertEquals(property3, "defaultValue"); - assertEquals(property4, "defaultValue"); - assertEquals(property5, "defaultValue"); - assertEquals(property6, "defaultValue"); - assertEquals(property7, "defaultValue"); - - // Additional test on propertiesHaveChanged - msoPropertiesFactory.removeAllMsoProperties(); - - // Do some additional test on propertiesHaveChanged method - try { - msoPropertiesFactory.propertiesHaveChanged(MSO_JAVA_PROP_ID, null); - - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("Mso properties not found in cache:"+MSO_JAVA_PROP_ID).equals(ep.getMessage())); - } - - try { - msoPropertiesFactory.propertiesHaveChanged(MSO_JAVA_PROP_ID, msoProperties); - - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("Mso properties not found in cache:"+MSO_JAVA_PROP_ID).equals(ep.getMessage())); - } - - } - - /** - * This method implements a test for the reloadMsoProperties method. - * - * @throws MsoPropertiesException - * - */ - @Test - public final void testReloadMoreThanAMinuteMsoProperties() throws MsoPropertiesException { - MsoJavaProperties msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - - msoPropertiesFactory.changeMsoPropertiesFilePath(MSO_JAVA_PROP_ID, PATH_MSO_JAVA_PROP2); - - // Simulate 2 minutes - msoPropertiesFactory.reloadMsoProperties(); - assertFalse(msoPropertiesFactory.propertiesHaveChanged(MSO_JAVA_PROP_ID, msoProperties)); - msoPropertiesFactory.reloadMsoProperties(); - - assertTrue(msoPropertiesFactory.propertiesHaveChanged(MSO_JAVA_PROP_ID, msoProperties)); - - // Get the new one - msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - String property1 = msoProperties.getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue"); - String property2 = msoProperties.getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue"); - String property3 = msoProperties.getProperty("ecomp.mso.cloud.1.msoId", "defaultValue"); - String property4 = msoProperties.getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue"); - String property5 = msoProperties.getProperty("does.not.exist", "defaultValue"); - String property6 = msoProperties.getProperty("ecomp.mso.cloud.1.test", "defaultValue"); - String property7 = msoProperties.getProperty("ecomp.mso.cloud.1.boolean", "defaultValue"); - - assertEquals(property1, "MT2"); - assertEquals(property2, "defaultValue"); - assertEquals(property3, "defaultValue"); - assertEquals(property4, "defaultValue"); - assertEquals(property5, "defaultValue"); - assertEquals(property6, "defaultValue"); - assertEquals(property7, "defaultValue"); - - - } - - /** - * This method implements a test for the reloadMsoProperties method. - * - * @throws MsoPropertiesException - * - */ - @Test - public final void testReloadBadMsoProperties() throws MsoPropertiesException { - MsoJavaProperties msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - - msoPropertiesFactory.changeMsoPropertiesFilePath(MSO_JAVA_PROP_ID, "file-does-not-exist.properties"); - msoPropertiesFactory.reloadMsoProperties(); - assertFalse(msoPropertiesFactory.propertiesHaveChanged(MSO_JAVA_PROP_ID, msoProperties)); - // Reload it a second time as initial timer parameter was set to 2 - msoPropertiesFactory.reloadMsoProperties(); - - assertTrue(msoPropertiesFactory.propertiesHaveChanged(MSO_JAVA_PROP_ID, msoProperties)); - - // Get the new one - msoProperties = msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - String property1 = msoProperties.getProperty("ecomp.mso.cloud.1.cloudId", "defaultValue"); - String property2 = msoProperties.getProperty("ecomp.mso.cloud.1.keystoneUrl", "defaultValue"); - String property3 = msoProperties.getProperty("ecomp.mso.cloud.1.msoId", "defaultValue"); - String property4 = msoProperties.getProperty("ecomp.mso.cloud.1.publicNetId", "defaultValue"); - String property5 = msoProperties.getProperty("does.not.exist", "defaultValue"); - String property6 = msoProperties.getProperty("ecomp.mso.cloud.1.test", "defaultValue"); - String property7 = msoProperties.getProperty("ecomp.mso.cloud.1.boolean", "defaultValue"); - - assertEquals(property1, "defaultValue"); - assertEquals(property2, "defaultValue"); - assertEquals(property3, "defaultValue"); - assertEquals(property4, "defaultValue"); - assertEquals(property5, "defaultValue"); - assertEquals(property6, "defaultValue"); - assertEquals(property7, "defaultValue"); - - } - - /** - * This method implements a test for the reloadMsoProperties method. - * - * @throws MsoPropertiesException - * - */ - @Test - public final void testReloadBadMsoJsonProperties() throws MsoPropertiesException { - // Load a bad JSON file - MsoJsonProperties msoProperties = msoPropertiesFactory.getMsoJsonProperties(MSO_JSON_PROP_ID); - - msoPropertiesFactory.changeMsoPropertiesFilePath(MSO_JSON_PROP_ID, PATH_MSO_JSON_PROP_BAD); - - msoPropertiesFactory.reloadMsoProperties(); - assertFalse(msoPropertiesFactory.propertiesHaveChanged(MSO_JSON_PROP_ID, msoProperties)); - // Reload it a second time as initial timer parameter was set to 2 - msoPropertiesFactory.reloadMsoProperties(); - - assertTrue(msoPropertiesFactory.propertiesHaveChanged(MSO_JSON_PROP_ID, msoProperties)); - - // Get the new one - msoProperties = msoPropertiesFactory.getMsoJsonProperties(MSO_JSON_PROP_ID); - assertNotNull(msoProperties); - assertNotNull(msoProperties.getJsonRootNode()); - assertTrue(msoProperties.getJsonRootNode().size() == 0); - - } - - @Test - public final void testRemoveMsoProperties() throws MsoPropertiesException { - try { - msoPropertiesFactory.removeMsoProperties("DUMB_PROP"); - - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("Mso properties not found in cache:"+"DUMB_PROP").equals(ep.getMessage())); - } - - msoPropertiesFactory.removeMsoProperties(MSO_JAVA_PROP_ID); - - try { - msoPropertiesFactory.getMsoJavaProperties(MSO_JAVA_PROP_ID); - - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("Mso properties not found in cache:"+MSO_JAVA_PROP_ID).equals(ep.getMessage())); - } - - } - - @Test - public final void testInitializeWithNonExistingPropertiesFile () throws MsoPropertiesException { - try { - msoPropertiesFactory.initializeMsoProperties("NEW_BAD_FILE", "no_file.properties"); - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("Unable to load the MSO properties file because it has not been found:no_file.properties").equals(ep.getMessage())); - } - - // empty object should be returned as no config has been loaded, anyway no exception should be raised because the config ID must be loaded in cache - // This is there for automatic reload attempt - assertTrue(msoPropertiesFactory.getMsoJavaProperties("NEW_BAD_FILE").size()==0); - } - - - @Test - public final void testInitializeWithNonExistingJsonFile () throws MsoPropertiesException { - try { - msoPropertiesFactory.initializeMsoProperties("NEW_BAD_FILE", "no_file.json"); - fail ("MsoPropertiesException should have been raised"); - } catch (MsoPropertiesException ep) { - assertTrue(("Unable to load the MSO properties file because it has not been found:no_file.json").equals(ep.getMessage())); - } - - // empty object should be returned as no config has been loaded, anyway no exception should be raised because the config ID must be loaded in cache - // This is there for automatic reload attempt - assertTrue(msoPropertiesFactory.getMsoJsonProperties("NEW_BAD_FILE").getJsonRootNode()!=null); - assertTrue("{}".equals(msoPropertiesFactory.getMsoJsonProperties("NEW_BAD_FILE").getJsonRootNode().toString())); - } - - @Test - public final void testShowProperties() { - assertTrue(msoPropertiesFactory.showProperties().getEntity().toString().contains("/target/test-classes/mso.json(Timer:2mins)")); - assertTrue(msoPropertiesFactory.showProperties().getEntity().toString().contains("asdc-controller1")); - assertTrue(msoPropertiesFactory.showProperties().getEntity().toString().contains("/target/test-classes/mso.properties(Timer:2mins):")); - assertTrue(msoPropertiesFactory.showProperties().getEntity().toString().contains("ecomp.mso.cloud.1.keystoneUrl")); - - } - - @Test - public final void testGetEncryptedPropertyJson() throws MsoPropertiesException { - MsoJsonProperties msoProperties = msoPropertiesFactory.getMsoJsonProperties(MSO_JSON_PROP_ID); - assertTrue("ThePassword".equals(msoProperties.getEncryptedProperty(msoProperties.getJsonRootNode().get("asdc-connections").get("asdc-controller1").get("asdcPassword"),"defautlvalue","566B754875657232314F5548556D3665"))); - - assertTrue("defautlvalue".equals(msoProperties.getEncryptedProperty(msoProperties.getJsonRootNode().get("asdc-connections").get("asdc-controller1").get("asdcPassword"),"defautlvalue","566B754875657232314F5548556D366"))); - - - } - - @Test - public final void testHashcodeAndEqualsMsoJsonProperties() throws MsoPropertiesException { - - MsoJsonProperties msoProperties = msoPropertiesFactory.getMsoJsonProperties(MSO_JSON_PROP_ID); - - msoPropertiesFactory.changeMsoPropertiesFilePath(MSO_JSON_PROP_ID, PATH_MSO_JSON_PROP2); - - msoPropertiesFactory.reloadMsoProperties(); - assertFalse(msoPropertiesFactory.propertiesHaveChanged(MSO_JSON_PROP_ID, msoProperties)); - // Reload it a second time as initial timer parameter was set to 2 - msoPropertiesFactory.reloadMsoProperties(); - assertTrue(msoPropertiesFactory.propertiesHaveChanged(MSO_JSON_PROP_ID, msoProperties)); - - // Get the new one - MsoJsonProperties msoProperties2 = msoPropertiesFactory.getMsoJsonProperties(MSO_JSON_PROP_ID); - assertFalse(msoProperties.hashCode()==msoProperties2.hashCode()); - - assertFalse(msoProperties.equals(msoProperties2)); - assertTrue(msoProperties.equals(msoProperties)); - assertFalse(msoProperties.equals(null)); - assertFalse(msoProperties.toString().isEmpty()); - - // Test a reload with timer set to 1 in PATH_MSO_JSON_PROP2 - msoPropertiesFactory.changeMsoPropertiesFilePath(MSO_JSON_PROP_ID, PATH_MSO_JSON_PROP); - - msoPropertiesFactory.reloadMsoProperties(); - assertTrue(msoPropertiesFactory.propertiesHaveChanged(MSO_JSON_PROP_ID, msoProperties2)); - - } - -} diff --git a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertyInitializerTest.java b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertyInitializerTest.java deleted file mode 100644 index 419a82b8a4..0000000000 --- a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoPropertyInitializerTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapter_utils.tests; - - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; - -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoPropertiesException; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.openecomp.mso.properties.MsoPropertyInitializer; - -public class MsoPropertyInitializerTest { - - public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString().substring(5); - public static ServletContextEvent servletContextEvent = Mockito.mock(ServletContextEvent.class); - public static ServletContext servletContext = Mockito.mock(ServletContext.class); - public MsoPropertyInitializer msoPropInitializer = new MsoPropertyInitializer(); - - @BeforeClass - public static final void prepareBeforeClass() throws MsoPropertiesException { - - Mockito.when(servletContextEvent.getServletContext()).thenReturn(servletContext); - } - - @Before - public final void preparebeforeEachTest() throws MsoPropertiesException { - MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - msoPropertiesFactory.removeAllMsoProperties(); - - } - - @Test - public void testContextInitialized() throws MsoPropertiesException { - Mockito.when(servletContext.getInitParameter("mso.configuration")).thenReturn("MSO_PROP_ASDC="+ASDC_PROP); - msoPropInitializer.contextInitialized(servletContextEvent); - - MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - assertNotNull(msoPropertiesFactory.getMsoJsonProperties("MSO_PROP_ASDC")); - assertFalse("{}".equals(msoPropertiesFactory.getMsoJsonProperties("MSO_PROP_ASDC").getJsonRootNode().toString())); - assertTrue(msoPropertiesFactory.getMsoJsonProperties("MSO_PROP_ASDC").getJsonRootNode().get("asdc-connections")!= null); - } - - @Test - public void testContextInitializedFailure() throws MsoPropertiesException { - Mockito.when(servletContext.getInitParameter("mso.configuration")).thenReturn("MSO_PROP_ASDC="+"Does_not_exist.json"); - msoPropInitializer.contextInitialized(servletContextEvent); - - // No exception should be raised, log instead - MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - - assertTrue("{}".equals(msoPropertiesFactory.getMsoJsonProperties("MSO_PROP_ASDC").getJsonRootNode().toString())); - assertTrue(msoPropertiesFactory.getMsoJsonProperties("MSO_PROP_ASDC").getJsonRootNode().get("asdc-connections")== null); - - - - } - -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIConfigurationTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIConfigurationTest.java deleted file mode 100644 index da63b27efb..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/AAIConfigurationTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; - -import java.util.UUID; - -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.openecomp.mso.client.aai.entities.uri.AAIUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; -import org.openecomp.mso.serviceinstancebeans.ModelInfo; -import org.openecomp.mso.serviceinstancebeans.RequestDetails; - -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class AAIConfigurationTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443)); - - @Ignore - @Test - public void verifyCreate() { - AAIConfigurationClient aaiConfiguration = new AAIConfigurationClient(); - ModelInfo modelInfo = new ModelInfo(); - modelInfo.setModelInvariantId("testInvariantID"); - modelInfo.setModelVersionId("testVersionID"); - modelInfo.setModelCustomizationId("testCustomizationID"); - RequestDetails requestDetails = new RequestDetails(); - requestDetails.setModelInfo(modelInfo); - String configurationType = "test"; - String configurationSubType = "test"; - aaiConfiguration.createConfiguration(requestDetails, UUID.randomUUID().toString(), configurationType, configurationSubType); - } - - @Test - public void verifyNotExists() { - AAIUri path = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "test2"); - wireMockRule.stubFor(get( - urlPathEqualTo("/aai/v11" + path.build())) - .willReturn( - aResponse() - .withHeader("Content-Type", "text/plain") - .withBody("hello") - .withStatus(404))); - AAIConfigurationClient aaiConfiguration = new AAIConfigurationClient(); - boolean result = aaiConfiguration.configurationExists("test2"); - assertEquals("path not found", false, result); - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIExceptionMapperTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIExceptionMapperTest.java deleted file mode 100644 index 625e281792..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/AAIExceptionMapperTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.openecomp.mso.client.aai.entities.AAIError; - -public class AAIExceptionMapperTest { - - @Mock private AAIError errorObj; - - @Before - public void init() { - MockitoAnnotations.initMocks(this); - } - @Test - public void nestedReplace() { - String error = "Error %1 on %2"; - List list = Arrays.asList("PUT", "hello %1"); - AAIErrorFormatter formatter = new AAIErrorFormatter(errorObj); - String result = formatter.fillInTemplate(error, list); - assertEquals("equal", "Error PUT on hello PUT", result); - - } - - @Test - public void noReplace() { - String error = "Error"; - List list = new ArrayList<>(); - AAIErrorFormatter formatter = new AAIErrorFormatter(errorObj); - String result = formatter.fillInTemplate(error, list); - assertEquals("equal", "Error", result); - - } - -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIObjectTypeTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIObjectTypeTest.java deleted file mode 100644 index c8f6299d81..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/AAIObjectTypeTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class AAIObjectTypeTest { - - @Test - public void verifyDefaultCase() { - assertEquals("default removed for tenant", "tenant", AAIObjectType.DEFAULT_TENANT.typeName()); - assertEquals("default removed for cloud-region", "cloud-region", AAIObjectType.DEFAULT_CLOUD_REGION.typeName()); - } - - @Test - public void verifyRegularCase() { - assertEquals("default removed for tenant", "allotted-resource", AAIObjectType.ALLOTTED_RESOURCE.typeName()); - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIPServerTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIPServerTest.java deleted file mode 100644 index b6b01b384a..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/AAIPServerTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.security.NoSuchAlgorithmException; -import java.util.List; -import java.util.UUID; - -import org.junit.Ignore; -import org.junit.Test; -import org.onap.aai.domain.yang.Pserver; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -public class AAIPServerTest { - - @Test - public void pserverTest() throws JsonParseException, JsonMappingException, IOException, NoSuchAlgorithmException { - AAIRestClientImpl client = new AAIRestClientImpl(); - String json = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/aai/pserver.json"))); - List list = client.getListOfPservers(json); - - assertEquals("", list.get(0).getHostname(), "test"); - } - - @Test - @Ignore // IGNORED FOR 1710 MERGE TO ONAP - public void pserverActualTest() throws JsonParseException, JsonMappingException, IOException, NoSuchAlgorithmException { - AAIRestClientImpl client = new AAIRestClientImpl(); - List list = client.getPhysicalServerByVnfId("d946afed-8ebe-4c5d-9665-54fcc043b8e7", UUID.randomUUID().toString()); - assertEquals("", list.size(), 0); - } - -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIResourcesClientTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIResourcesClientTest.java deleted file mode 100644 index c7cc549130..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/AAIResourcesClientTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.assertEquals; - -import org.junit.Rule; -import org.junit.Test; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; - -import com.github.tomakehurst.wiremock.junit.WireMockRule; -public class AAIResourcesClientTest { - - - - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443)); - - @Test - public void verifyNotExists() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test"); - wireMockRule.stubFor(get( - urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString())) - .willReturn( - aResponse() - .withHeader("Content-Type", "text/plain") - .withBody("hello") - .withStatus(404))); - AAIResourcesClient client = new AAIResourcesClient(); - boolean result = client.exists(path); - assertEquals("path not found", false, result); - } - - @Test - public void verifyDelete() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2"); - wireMockRule.stubFor(get( - urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString())) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBodyFile("aai/resources/mockObject.json") - .withStatus(200))); - wireMockRule.stubFor(delete( - urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString())) - .withQueryParam("resource-version", equalTo("1234")) - .willReturn( - aResponse() - .withStatus(204))); - AAIResourcesClient client = new AAIResourcesClient(); - client.delete(path); - } - - @Test - public void verifyBasicAuth() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); - wireMockRule.stubFor(get( - urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString())) - .withHeader("Authorization", equalTo("Basic TVNPOk1TTw==")) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBodyFile("aai/resources/mockObject.json") - .withStatus(200))); - AAIResourcesClient client = new AAIResourcesClient(); - client.get(path); - } - - @Test - public void verifyConnect() { - AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2"); - AAIResourceUri path2 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); - wireMockRule.stubFor(put( - urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString() + "/relationship-list/relationship")) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withStatus(200))); - - AAIResourceUri pathClone = path.clone(); - AAIResourcesClient client = new AAIResourcesClient(); - client.connect(path, path2); - assertEquals("uri not modified", pathClone.build().toString(), path.build().toString()); - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAITransactionalClientTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAITransactionalClientTest.java deleted file mode 100644 index 1abb940f6e..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/AAITransactionalClientTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Map; -import java.util.Optional; - -import org.junit.Test; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -public class AAITransactionalClientTest { - - - private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/bulkprocess/"; - - @Test - public void run() throws IOException { - - - AAIResourcesClient client = new AAIResourcesClient(); - AAIResourceUri uriA = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); - AAIResourceUri uriB = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test2"); - AAIResourceUri uriC = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3"); - AAIResourceUri uriD = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test4"); - AAIResourceUri uriE = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test5"); - AAIResourceUri uriF = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test6"); - - AAIResourceUri uriAClone = uriA.clone(); - AAITransactionalClient transactions = client - .beginTransaction().connect(uriA, uriB).connect(uriC, uriD) - .beginNewTransaction().connect(uriE, uriF); - ObjectMapper mapper = new AAICommonObjectMapperProvider().getMapper(); - mapper.enable(SerializationFeature.INDENT_OUTPUT); - String serializedTransactions = mapper.writeValueAsString(transactions.getTransactions()); - Map map1 = mapper.readValue(serializedTransactions, new TypeReference>(){}); - Map map2 = mapper.readValue(getJson("test-request.json"), new TypeReference>(){}); - assertEquals("payloads are equal", map2, map1); - assertEquals("uri not manipulated", uriAClone.build().toString(), uriA.build().toString()); - } - - @Test - public void verifyResponse() throws IOException { - AAIResourcesClient client = new AAIResourcesClient(); - AAITransactionalClient transactions = client - .beginTransaction(); - assertEquals("success status", Optional.empty(), transactions.locateErrorMessages(getJson("response-success.json"))); - assertEquals(transactions.locateErrorMessages(getJson("response-failure.json")).get(), "another error message\nmy great error"); - - - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + filename))); - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIURITest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIURITest.java deleted file mode 100644 index 366c587b11..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/AAIURITest.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import static org.junit.Assert.assertEquals; - -import javax.ws.rs.core.UriBuilder; - -import org.junit.Test; -import org.openecomp.mso.client.aai.entities.uri.AAIUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; - -public class AAIURITest { - - - - - @Test - public void verifyTemplateReplacement() { - final String id = "test1"; - AAIUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, id); - String manualReplace = AAIObjectType.CONFIGURATION.toString().replaceAll("\\{configuration-id\\}", id); - assertEquals("uri template replaced", aaiUri.build(), UriBuilder.fromPath(manualReplace).build()); - - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIUpdatorImplTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIUpdatorImplTest.java deleted file mode 100644 index 86adb5f458..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/AAIUpdatorImplTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import org.junit.Test; - -public class AAIUpdatorImplTest { - - AAIUpdatorImpl test = new AAIUpdatorImpl(); - - protected AAIRestClientI client; - - @Test - public void getClientTest() throws Exception { - test.getClient(); - } - - @Test - public void setClientTest() throws Exception { - test.setClient(client); - } - - - @Test(expected = NullPointerException.class) - public void updateVnfToLockedTest() throws Exception { - test.updateVnfToLocked("vnfId","uuId"); - } - - - @Test(expected = NullPointerException.class) - public void updateVnfToUnLockedTest() throws Exception { - test.updateVnfToUnLocked("vnfId","uuId"); - } - -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java deleted file mode 100644 index 12034e0eea..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Pserver; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; - -@RunWith(MockitoJUnitRunner.class) -public class AAIValidatorTest { - - @Mock - protected AAIRestClientI client; - String vnfName = "testVnf"; - String uuid = "UUID"; - AAIValidatorImpl validator; - - @Before - public void init(){ - validator = new AAIValidatorImpl(); - validator.setClient(client); - } - - public List getPservers(boolean locked){ - Pserver pserver = new Pserver(); - pserver.setInMaint(locked); - List pservers = new ArrayList(); - pservers.add(pserver); - return pservers; - } - - public GenericVnf createGenericVnfs(boolean locked){ - GenericVnf genericVnf = new GenericVnf(); - genericVnf.setInMaint(locked); - return genericVnf; - } - - @Test - public void test_IsPhysicalServerLocked_True() throws IOException{ - when(client.getPhysicalServerByVnfId(vnfName,uuid)).thenReturn(getPservers(true)); - boolean locked = validator.isPhysicalServerLocked(vnfName, uuid); - assertEquals(true, locked); - } - - @Test - public void test_IsPhysicalServerLocked_False() throws JsonParseException, JsonMappingException, UnsupportedEncodingException, IOException { - when(client.getPhysicalServerByVnfId(vnfName,uuid)).thenReturn(getPservers(false)); - boolean locked = validator.isPhysicalServerLocked(vnfName, uuid); - assertEquals(false, locked); - } - - @Test - public void test_IsVNFLocked_False() throws Exception{ - when(client.getVnfByName(vnfName,uuid)).thenReturn(createGenericVnfs(false)); - boolean locked = validator.isVNFLocked(vnfName, uuid); - assertEquals(false, locked); - } - - @Test - public void test_IsVNFLocked_True() throws Exception{ - when(client.getVnfByName(vnfName,uuid)).thenReturn(createGenericVnfs(true)); - boolean locked = validator.isVNFLocked(vnfName, uuid); - assertEquals(true,locked ); - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/entities/RelationshipsTest.java b/common/src/test/java/org/openecomp/mso/client/aai/entities/RelationshipsTest.java deleted file mode 100644 index b2c1f9ed64..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/entities/RelationshipsTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities; - -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; - -public class RelationshipsTest { - - private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/resources/"; - - @Test - public void run() throws IOException { - final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "e2e-complex.json"))); - - AAIResultWrapper wrapper = new AAIResultWrapper(content); - Relationships relationships = wrapper.getRelationships().get(); - - List test = relationships.getRelatedAAIUris(AAIObjectType.VCE); - - System.out.println(test.get(0).build()); - List uris = Arrays.asList( - AAIUriFactory.createResourceUri(AAIObjectType.VCE, "a9fec18e-1ea3-40e4-a6c0-a89b3de07053"), - AAIUriFactory.createResourceUri(AAIObjectType.VCE, "8ae1e5f8-61f1-4c71-913a-b40cc4593cb9"), - AAIUriFactory.createResourceUri(AAIObjectType.VCE, "a2935fa9-b743-49f4-9813-a127f13c4e93"), - AAIUriFactory.createResourceUri(AAIObjectType.VCE, "c7fe7698-8063-4e26-8bd3-ca3edde0b0d4")); - - - assertTrue(uris.containsAll(test) && test.containsAll(uris)); - - } - -} \ No newline at end of file diff --git a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactoryTest.java b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactoryTest.java deleted file mode 100644 index a62d4b89c6..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactoryTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.openecomp.mso.client.aai.AAIObjectType; - -public class AAIUriFactoryTest { - - - - @Test - public void automaticallyEncodeUriTemplateValue() { - - AAIUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)"); - - String expected = "/network/generic-vnfs/generic-vnf/VIP%28VelocitytoIP%29"; - assertEquals(expected, uri.build().toString()); - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUriTest.java b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUriTest.java deleted file mode 100644 index 12ca0a2709..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUriTest.java +++ /dev/null @@ -1,194 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; - - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Optional; - -import javax.ws.rs.BadRequestException; -import javax.ws.rs.core.UriBuilder; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Matchers; -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.AAIQueryClient; -import org.openecomp.mso.client.aai.Format; -import org.openecomp.mso.client.aai.entities.CustomQuery; -import org.openecomp.mso.client.aai.exceptions.AAIPayloadException; -import org.openecomp.mso.client.aai.exceptions.AAIUriComputationException; -import org.openecomp.mso.client.aai.exceptions.AAIUriNotFoundException; - -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -public class ServiceInstanceUriTest { - - private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/resources/"; - - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443)); - - @Rule - public final ExpectedException exception = ExpectedException.none(); - - @Test - public void found() throws IOException { - final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "service-instance-pathed-query.json"))); - - ServiceInstanceUri instance = new ServiceInstanceUri("key3"); - final Optional result = instance.extractRelatedLink(content); - final String expected = "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3"; - assertEquals("result is equal", expected, result.get()); - - } - - @Test - public void oneKey() throws IOException, URISyntaxException, AAIUriNotFoundException, AAIPayloadException { - - ServiceInstanceUri instance = new ServiceInstanceUri("key1"); - ServiceInstanceUri spy = spy(instance); - doReturn("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3").when(spy).getSerivceInstance(any(Object.class)); - - final URI result = spy.build(); - final URI expected = UriBuilder.fromPath("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3").build(); - assertEquals("result is equal", expected, result); - - } - - @Test - public void oneKeyQueryParams() throws IOException, URISyntaxException, AAIUriNotFoundException, AAIPayloadException { - - ServiceInstanceUri instance = new ServiceInstanceUri("key1"); - ServiceInstanceUri spy = spy(instance); - doReturn("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3").when(spy).getSerivceInstance(any(Object.class)); - - final URI result = spy.resourceVersion("1234").build(); - final URI expected = UriBuilder.fromUri("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3?resource-version=1234").build(); - assertEquals("result is equal", expected, result); - - } - - @Test - public void oneKeyEncoded() throws IOException, URISyntaxException, AAIUriNotFoundException, AAIPayloadException { - - ServiceInstanceUri instance = new ServiceInstanceUri("key1"); - ServiceInstanceUri spy = spy(instance); - doReturn("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%20space").when(spy).getSerivceInstance(any(Object.class)); - - final URI result = spy.build(); - final URI expected = UriBuilder.fromUri("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%20space").build(); - assertEquals("result is equal", expected, result); - - } - - @Test - public void oneKeyGetKeys() throws IOException, URISyntaxException, AAIUriNotFoundException, AAIPayloadException { - - ServiceInstanceUri instance = new ServiceInstanceUri("key1"); - ServiceInstanceUri spy = spy(instance); - doReturn("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%28space").when(spy).getSerivceInstance(any(Object.class)); - - assertThat(spy.getURIKeys().values(), contains("key1", "key2", "key3(space")); - - } - @Test - public void oneKeyClone() throws AAIUriNotFoundException, AAIPayloadException { - ServiceInstanceUri instance = new ServiceInstanceUri("key1"); - ServiceInstanceUri spy = spy(instance); - String uri = "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3"; - doReturn(uri).when(spy).getSerivceInstance(any(Object.class)); - doReturn(Optional.of(uri)).when(spy).getCachedValue(); - final URI result = spy.resourceVersion("1234").clone().build(); - final URI expected = UriBuilder.fromUri("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3?resource-version=1234").build(); - assertEquals("result is equal", expected, result); - } - - @Test - public void threeKey() throws IOException { - - ServiceInstanceUri instance = new ServiceInstanceUri("key1", "key2", "key3"); - final URI result = instance.build(); - final URI expected = UriBuilder.fromPath("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3").build(); - assertEquals("result is equal", expected, result); - - } - - @Test - public void notfound() throws IOException, AAIUriNotFoundException, AAIPayloadException { - final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "empty-query-result.json"))); - - ServiceInstanceUri instance = new ServiceInstanceUri("key3"); - ServiceInstanceUri spy = spy(instance); - AAIQueryClient mockQueryClient = mock(AAIQueryClient.class); - when(mockQueryClient.query(any(Format.class), any(CustomQuery.class))).thenReturn(content); - when(spy.getQueryClient()).thenReturn(mockQueryClient); - exception.expect(AAIUriComputationException.class); - spy.build(); - - } - - @Test - public void cloneTest() { - ServiceInstanceUri instance = new ServiceInstanceUri("key1", "key2", "key3"); - final URI result = instance.build(); - final URI result2 = instance.clone().queryParam("something", "new").build(); - assertEquals("uris are not equal", false, result.toString().equals(result2.toString())); - - } - - @Test - public void noVertexFound() throws AAIUriNotFoundException, AAIPayloadException { - ServiceInstanceUri instance = new ServiceInstanceUri("key3"); - ServiceInstanceUri spy = spy(instance); - stubFor(put(urlMatching("/aai/v[0-9]+/query.*")) - .withRequestBody(containing("key3")) - .willReturn(aResponse() - .withStatus(400) - .withHeader("Content-Type", "application/json") - .withBodyFile(""))); - exception.expect(AAIUriComputationException.class); - exception.expectMessage(containsString("NotFoundException")); - spy.build(); - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriFromUriTest.java b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriFromUriTest.java deleted file mode 100644 index 6e3ab64108..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriFromUriTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri; - -import static org.junit.Assert.assertEquals; - -import javax.ws.rs.core.UriBuilder; - -import org.junit.Test; -import org.openecomp.mso.client.aai.AAIObjectType; - -public class SimpleUriFromUriTest { - - - - @Test - public void removeHost() { - - AAIUri uri = new SimpleUri(AAIObjectType.UNKNOWN, UriBuilder.fromUri("https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053").build()); - - assertEquals("root and version removed", "/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053", uri.build().toString()); - - } - @Test - public void noChange() { - - AAIUri uri = new SimpleUri(AAIObjectType.UNKNOWN, UriBuilder.fromUri("/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053").build()); - - assertEquals("no change", "/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053", uri.build().toString()); - - } - - @Test - public void encodingPreserved() { - - AAIUri uri = new SimpleUri(AAIObjectType.UNKNOWN, UriBuilder.fromUri("/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053").build()); - - assertEquals("encoding preserved", "/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053", uri.build().toString()); - - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriTest.java b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriTest.java deleted file mode 100644 index f4fe216cd2..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.junit.Assert.assertEquals; - -import java.util.Map; - -import org.junit.Test; -import org.openecomp.mso.client.aai.AAIObjectPlurals; -import org.openecomp.mso.client.aai.AAIObjectType; - -public class SimpleUriTest { - - - - @Test - public void relatedToTestPlural() { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); - uri.relatedTo(AAIObjectPlurals.PSERVER); - String uriOutput = uri.build().toString(); - assertEquals(true, uriOutput.contains("related-to")); - } - - @Test - public void relatedToTestSingular() { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); - uri.relatedTo(AAIObjectType.PSERVER, "test2"); - String uriOutput = uri.build().toString(); - assertEquals(true, uriOutput.contains("related-to")); - } - - @Test - public void cloneTest() { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1"); - AAIResourceUri cloned = uri.clone(); - Map keys = cloned.getURIKeys(); - assertThat(keys.values(), contains("test1")); - } - - @Test - public void getKeysTest() { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, "cloud1", "cloud2", "tenant1", "vserver1"); - Map keys = uri.getURIKeys(); - System.out.println(keys); - System.out.println(uri.build()); - assertEquals("vserver1", keys.get("vserver-id")); - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImplTest.java b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImplTest.java deleted file mode 100644 index e8d98718a4..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImplTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.entities.uri.parsers; - -import static org.junit.Assert.assertEquals; - -import java.util.Map; - -import org.junit.Test; -import org.openecomp.mso.client.aai.AAIObjectType; - -public class UriParserSpringImplTest { - - - - - @Test - public void reverseTemplate() { - final UriParser parser = new UriParserSpringImpl(AAIObjectType.SERVICE_INSTANCE.toString()); - final String uri = "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3"; - - Map result = parser.parse(uri); - - assertEquals("found customer-id", "key1", result.get("global-customer-id")); - assertEquals("found service-type", "key2", result.get("service-type")); - assertEquals("found service-instance-id", "key3", result.get("service-instance-id")); - - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/exceptions/AAIPayloadExceptionTest.java b/common/src/test/java/org/openecomp/mso/client/aai/exceptions/AAIPayloadExceptionTest.java deleted file mode 100644 index 3895230ed4..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/exceptions/AAIPayloadExceptionTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.aai.exceptions; - -import org.junit.Test; - -public class AAIPayloadExceptionTest { - - Throwable t = new Throwable(); - - @Test - public void callConstructorTest() throws Exception { - - AAIPayloadException test1 = new AAIPayloadException("testing"); - - AAIPayloadException test2 = new AAIPayloadException("testing", t); - - AAIPayloadException test3 = new AAIPayloadException(t); - } - -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/objects/AAIOperationalEnvironmentTest.java b/common/src/test/java/org/openecomp/mso/client/aai/objects/AAIOperationalEnvironmentTest.java deleted file mode 100644 index f512de848c..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/objects/AAIOperationalEnvironmentTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ -package org.openecomp.mso.client.aai.objects; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class AAIOperationalEnvironmentTest { - - AAIOperationalEnvironment aaiOE =new AAIOperationalEnvironment(); - - @Test - public void test() { - aaiOE.setOperationalEnvironmentId("operationalEnvironmentId"); - aaiOE.setOperationalEnvironmentName("operationalEnvironmentName"); - aaiOE.setOperationalEnvironmentStatus("operationalEnvironmentStatus"); - aaiOE.setOperationalEnvironmentType("operationalEnvironmentType"); - aaiOE.setResourceVersion("resourceVersion"); - aaiOE.setTenantContext("tenantContext"); - aaiOE.setWorkloadContext("workloadContext"); - assertEquals(aaiOE.getOperationalEnvironmentId(),"operationalEnvironmentId"); - assertEquals(aaiOE.getOperationalEnvironmentName(),"operationalEnvironmentName"); - assertEquals(aaiOE.getOperationalEnvironmentStatus(),"operationalEnvironmentStatus"); - assertEquals(aaiOE.getOperationalEnvironmentType(),"operationalEnvironmentType"); - assertEquals(aaiOE.getResourceVersion(),"resourceVersion"); - assertEquals(aaiOE.getTenantContext(),"tenantContext"); - assertEquals(aaiOE.getWorkloadContext(),"workloadContext"); - aaiOE.withOperationalEnvironmentId("operationalEnvironmentId"); - aaiOE.withOperationalEnvironmentName("operationalEnvironmentName"); - aaiOE.withOperationalEnvironmentStatus("operationalEnvironmentStatus"); - aaiOE.withOperationalEnvironmentType("operationalEnvironmentType"); - aaiOE.withResourceVersion("resourceVersion"); - aaiOE.withTenantContext("tenantContext"); - aaiOE.withWorkloadContext("workloadContext"); - } - -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/objects/AAIOwningEntityTest.java b/common/src/test/java/org/openecomp/mso/client/aai/objects/AAIOwningEntityTest.java deleted file mode 100644 index bc2ae41dd6..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/objects/AAIOwningEntityTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ -package org.openecomp.mso.client.aai.objects; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; - -public class AAIOwningEntityTest { - AAIOwningEntity aaiOE= new AAIOwningEntity(); - @Test - public void test() { - aaiOE.setOwningEntityId("OwningEntityId"); - aaiOE.setOwningEntityName("OwningEntityName"); - assertEquals(aaiOE.getOwningEntityId(), "OwningEntityId"); - assertEquals(aaiOE.getOwningEntityName(), "OwningEntityName"); - aaiOE.withOwningEntity("OwningEntityId1", "OwningEntityName1"); - assert(aaiOE.getUri()!=null); - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/objects/AAIProjectTest.java b/common/src/test/java/org/openecomp/mso/client/aai/objects/AAIProjectTest.java deleted file mode 100644 index 872b17a759..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/objects/AAIProjectTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ -package org.openecomp.mso.client.aai.objects; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; - -public class AAIProjectTest { - - - @Test - public void test() { - AAIProject aaiP =new AAIProject(); - aaiP.setProjectName("projectName"); - assertEquals(aaiP.getProjectName(),"projectName"); - aaiP.withProjectName("projectName"); - assert(aaiP.getUri()!=null); - - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/aai/objects/AAIServiceInstanceTest.java b/common/src/test/java/org/openecomp/mso/client/aai/objects/AAIServiceInstanceTest.java deleted file mode 100644 index 692e3bba0b..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/aai/objects/AAIServiceInstanceTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -*/ -package org.openecomp.mso.client.aai.objects; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class AAIServiceInstanceTest { - - @Test - public void test() { - AAIServiceInstance aaiSI= new AAIServiceInstance(); - aaiSI.setEnvironmentContext("environmentContext"); - aaiSI.setModelInvariantUuid("modelInvariantUuid"); - aaiSI.setModelUuid("modelUuid"); - aaiSI.setoStatus("oStatus"); - aaiSI.setServiceInstanceId("serviceInstanceId"); - aaiSI.setServiceInstanceName("serviceInstanceName"); - aaiSI.setServiceRole("serviceRole"); - aaiSI.setServiceType("serviceType"); - aaiSI.setWorkloadContext("workloadContext"); - assertEquals(aaiSI.getEnvironmentContext(), "environmentContext"); - assertEquals(aaiSI.getModelInvariantUuid(), "modelInvariantUuid"); - assertEquals(aaiSI.getModelUuid(), "modelUuid"); - assertEquals(aaiSI.getoStatus(), "oStatus"); - assertEquals(aaiSI.getServiceInstanceId(), "serviceInstanceId"); - assertEquals(aaiSI.getServiceInstanceName(), "serviceInstanceName"); - assertEquals(aaiSI.getServiceRole(), "serviceRole"); - assertEquals(aaiSI.getServiceType(), "serviceType"); - assertEquals(aaiSI.getWorkloadContext(), "workloadContext"); - aaiSI.withServiceInstance("serviceInstanceId"); - assert(aaiSI.getUri()!=null); - } - -} diff --git a/common/src/test/java/org/openecomp/mso/client/dmaap/DmaapClientTest.java b/common/src/test/java/org/openecomp/mso/client/dmaap/DmaapClientTest.java deleted file mode 100644 index dda7754712..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/dmaap/DmaapClientTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.dmaap; - -import static org.junit.Assert.assertEquals; - -import java.io.FileNotFoundException; -import java.io.IOException; - -import org.junit.Test; -import org.openecomp.mso.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; - -public class DmaapClientTest { - - @Test - public void deobfuscateTest() throws FileNotFoundException, IOException { - String encodedBase64 = "dGVzdHBhc3N3b3Jk"; - String notEncoded = "testpassword"; - DmaapConsumer consumer = new SDNOHealthCheckDmaapConsumer(); - assertEquals("decoded password", notEncoded, consumer.deobfuscatePassword(encodedBase64)); - - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/dmaap/DmaapPublisherTest.java b/common/src/test/java/org/openecomp/mso/client/dmaap/DmaapPublisherTest.java deleted file mode 100644 index a9bf81d2ad..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/dmaap/DmaapPublisherTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.client.dmaap; - -import org.junit.Test; - -import javax.ws.rs.ProcessingException; -import java.io.IOException; -import java.util.Optional; - -public class DmaapPublisherTest { - - DmaapPublisher dmaapPublisher = new DmaapPublisher(120) { - @Override - public String getUserName() { - return "test"; - } - - @Override - public String getPassword() { - return "test"; - } - - @Override - public String getTopic() { - return "test"; - } - - @Override - public Optional getHost() { - return Optional.of("http://localhost:8080"); - } - }; - - public DmaapPublisherTest() throws IOException { - } - - @Test(expected = ProcessingException.class) - public void sendTest() throws Exception { - dmaapPublisher.send("{'key': 'value'}"); - } - -} \ No newline at end of file diff --git a/common/src/test/java/org/openecomp/mso/client/grm/GRMBeansTest.java b/common/src/test/java/org/openecomp/mso/client/grm/GRMBeansTest.java deleted file mode 100644 index e22dc7b754..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/grm/GRMBeansTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm; - -import java.util.List; - -import org.junit.Test; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterEnum; -import com.openpojo.reflection.filters.FilterPackageInfo; -import com.openpojo.reflection.impl.PojoClassFactory; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.affirm.Affirm; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - -public class GRMBeansTest { - private static final String POJO_PACKAGE = "org.openecomp.mso.client.grm.beans"; - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - @Test - public void testPojoStructureAndBehavior() { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new SetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - - validator.validate(POJO_PACKAGE, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); - } - - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } - -} diff --git a/common/src/test/java/org/openecomp/mso/client/grm/GRMClientTest.java b/common/src/test/java/org/openecomp/mso/client/grm/GRMClientTest.java deleted file mode 100644 index 6865bbd773..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/grm/GRMClientTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm; - -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assert.*; - -import java.io.File; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.MediaType; - -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.openecomp.mso.client.grm.exceptions.GRMClientCallFailed; -import org.openecomp.mso.client.grm.GRMClient; -import org.openecomp.mso.client.grm.beans.ServiceEndPointRequest; -import org.openecomp.mso.client.grm.beans.OperationalInfo; -import org.openecomp.mso.client.grm.beans.Property; -import org.openecomp.mso.client.grm.beans.ServiceEndPoint; -import org.openecomp.mso.client.grm.beans.ServiceEndPointList; -import org.openecomp.mso.client.grm.beans.ServiceEndPointLookupRequest; -import org.openecomp.mso.client.grm.beans.Version; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; - -public class GRMClientTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(28090)); - - private ObjectMapper mapper = new ObjectMapper(); - - @Test - public void testFind() throws Exception { - String endpoints = getFileContentsAsString("__files/grm/endpoints.json"); - wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", MediaType.APPLICATION_JSON) - .withBody(endpoints))); - - - GRMClient client = new GRMClient(); - ServiceEndPointList sel = client.findRunningServices("TEST.ECOMP_PSL.*", 1, "TEST"); - List list = sel.getServiceEndPointList(); - assertEquals(3, list.size()); - } - - @Test(expected = GRMClientCallFailed.class) - public void testFindFail() throws Exception { - - wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning")) - .willReturn(aResponse() - .withStatus(400) - .withHeader("Content-Type", MediaType.APPLICATION_JSON) - .withBody(""))); - - GRMClient client = new GRMClient(); - client.findRunningServices("TEST.ECOMP_PSL.*", 1, "TEST"); - } - - @Ignore - @Test - public void testAdd() throws Exception { - - wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/add")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", MediaType.APPLICATION_JSON) - .withBody("test"))); - wireMockRule.addMockServiceRequestListener((request, response) -> { - System.out.println("URL Requested => " + request.getAbsoluteUrl()); - System.out.println("Request Body => " + request.getBodyAsString()); - System.out.println("Request Headers => " + request.getHeaders().toString()); - System.out.println("Response Status => " + response.getStatus()); - System.out.println("Response Body => " + response.getBodyAsString()); - }); - - Version ver = new Version(); - ver.setMajor(1); - ver.setMinor(0); - ver.setPatch("0"); - - ServiceEndPoint sep = new ServiceEndPoint(); - sep.setName("TEST.ECOMP_PSL.Inventory"); - sep.setVersion(ver); - sep.setHostAddress("127.0.0.1"); - sep.setListenPort("8080"); - sep.setLatitude("37.7022"); - sep.setLongitude("121.9358"); - sep.setContextPath("/"); - sep.setRouteOffer("TEST"); - - OperationalInfo operInfo = new OperationalInfo(); - operInfo.setCreatedBy("edge"); - operInfo.setUpdatedBy("edge"); - - sep.setOperationalInfo(operInfo); - - Property prop1 = new Property(); - prop1.setName("Environment"); - prop1.setValue("TEST"); - - Property prop2 = new Property(); - prop2.setName("cpfrun_cluster_name"); - prop2.setValue("testcase_cluster_no_cluster"); - - List props = new ArrayList(); - props.add(prop1); - props.add(prop2); - - sep.setProperties(props); - - ServiceEndPointRequest request = new ServiceEndPointRequest(); - request.setEnv("DEV"); - request.setServiceEndPoint(sep); - - System.out.println("Request in JSON: " + mapper.writeValueAsString(request)); - - GRMClient client = new GRMClient(); - client.addServiceEndPoint(request); - } - - @Test(expected = GRMClientCallFailed.class) - public void testAddFail() throws Exception { - wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/add")) - .willReturn(aResponse() - .withStatus(404) - .withHeader("Content-Type", MediaType.APPLICATION_JSON) - .withBody("test"))); - ServiceEndPointRequest request = new ServiceEndPointRequest(); - GRMClient client = new GRMClient(); - client.addServiceEndPoint(request); - } - - @Test - public void testBuildServiceEndPointLookupRequest() { - GRMClient client = new GRMClient(); - ServiceEndPointLookupRequest request = client.buildServiceEndPointlookupRequest("TEST.ECOMP_PSL.Inventory", 1, "DEV"); - assertEquals("TEST.ECOMP_PSL.Inventory", request.getServiceEndPoint().getName()); - assertEquals(Integer.valueOf(1), Integer.valueOf(request.getServiceEndPoint().getVersion().getMajor())); - assertEquals("DEV", request.getEnv()); - - } - - protected String getFileContentsAsString(String fileName) { - String content = ""; - try { - ClassLoader classLoader = this.getClass().getClassLoader(); - File file = new File(classLoader.getResource(fileName).getFile()); - content = new String(Files.readAllBytes(file.toPath())); - } - catch(Exception e) { - e.printStackTrace(); - System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage()); - } - return content; - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointListTest.java b/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointListTest.java deleted file mode 100644 index 111fec46eb..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointListTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm; - -import java.io.File; -import java.nio.file.Files; -import java.util.List; -import static org.junit.Assert.*; -import org.junit.Test; -import org.openecomp.mso.client.grm.beans.ServiceEndPoint; -import org.openecomp.mso.client.grm.beans.ServiceEndPointList; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ServiceEndPointListTest { - - private ObjectMapper mapper = new ObjectMapper(); - - @Test - public void testUnmarshall() throws Exception { - String endpointsJson = getFileContentsAsString("__files/grm/endpoints.json"); - ServiceEndPointList sel = mapper.readValue(endpointsJson, ServiceEndPointList.class); - - List list = sel.getServiceEndPointList(); - ServiceEndPoint se = list.get(0); - - assertEquals(3, list.size()); - assertEquals("dummy.pod.ns.dummy-pod3", se.getName()); - assertEquals(Integer.valueOf(1), Integer.valueOf(se.getVersion().getMajor())); - assertEquals(Integer.valueOf(0), Integer.valueOf(se.getVersion().getMinor())); - assertEquals(Integer.valueOf(0), Integer.valueOf(se.getVersion().getPatch())); - assertEquals("135.144.120.218", se.getHostAddress()); - assertEquals("32004", se.getListenPort()); - assertEquals("37.7022", se.getLatitude()); - assertEquals("121.9358", se.getLongitude()); - assertEquals("/", se.getContextPath()); - assertEquals("edge", se.getOperationalInfo().getCreatedBy()); - assertEquals("edge", se.getOperationalInfo().getUpdatedBy()); - assertEquals("Environment", se.getProperties().get(0).getName()); - assertEquals("DEV", se.getProperties().get(0).getValue()); - } - - protected String getFileContentsAsString(String fileName) { - - String content = ""; - try { - ClassLoader classLoader = this.getClass().getClassLoader(); - File file = new File(classLoader.getResource(fileName).getFile()); - content = new String(Files.readAllBytes(file.toPath())); - } - catch(Exception e) { - e.printStackTrace(); - System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage()); - } - return content; - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointRequestTest.java b/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointRequestTest.java deleted file mode 100644 index 230b58bd84..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointRequestTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.grm; - -import static org.junit.Assert.assertEquals; -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; -import org.openecomp.mso.client.grm.beans.OperationalInfo; -import org.openecomp.mso.client.grm.beans.Property; -import org.openecomp.mso.client.grm.beans.ServiceEndPoint; -import org.openecomp.mso.client.grm.beans.ServiceEndPointRequest; -import org.openecomp.mso.client.grm.beans.Version; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ServiceEndPointRequestTest { - - private ObjectMapper mapper = new ObjectMapper(); - - @Test - public void testMarshall() throws Exception { - - String expected = - "{\"serviceEndPoint\":{\"name\":\"TEST.ECOMP_PSL.Inventory\",\"version\":{\"major\":1,\"minor\":0,\"patch\":\"0\"}," + - "\"hostAddress\":\"127.0.0.1\",\"listenPort\":\"8080\",\"latitude\":\"37.7022\",\"longitude\":\"121.9358\"," + - "\"contextPath\":\"/\",\"routeOffer\":\"TEST\",\"operationalInfo\":{\"createdBy\":\"edge\",\"updatedBy\":\"edge\"}," + - "\"properties\":[{\"name\":\"Environment\",\"value\":\"TEST\"},{\"name\":\"cpfrun_cluster_name\"," + - "\"value\":\"testcase_cluster_no_cluster\"}]},\"env\":\"DEV\"}"; - - Version ver = new Version(); - ver.setMajor(1); - ver.setMinor(0); - ver.setPatch("0"); - - ServiceEndPoint sep = new ServiceEndPoint(); - sep.setName("TEST.ECOMP_PSL.Inventory"); - sep.setVersion(ver); - sep.setHostAddress("127.0.0.1"); - sep.setListenPort("8080"); - sep.setLatitude("37.7022"); - sep.setLongitude("121.9358"); - sep.setContextPath("/"); - sep.setRouteOffer("TEST"); - - OperationalInfo operInfo = new OperationalInfo(); - operInfo.setCreatedBy("edge"); - operInfo.setUpdatedBy("edge"); - - sep.setOperationalInfo(operInfo); - - Property prop1 = new Property(); - prop1.setName("Environment"); - prop1.setValue("TEST"); - - Property prop2 = new Property(); - prop2.setName("cpfrun_cluster_name"); - prop2.setValue("testcase_cluster_no_cluster"); - - List props = new ArrayList(); - props.add(prop1); - props.add(prop2); - - sep.setProperties(props); - - ServiceEndPointRequest request = new ServiceEndPointRequest(); - request.setEnv("DEV"); - request.setServiceEndPoint(sep); - - assertEquals(expected, mapper.writeValueAsString(request)); - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/policy/PolicyClientImplTest.java b/common/src/test/java/org/openecomp/mso/client/policy/PolicyClientImplTest.java deleted file mode 100644 index f406667870..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/policy/PolicyClientImplTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.doReturn; -import static com.shazam.shazamcrest.MatcherAssert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; - -import org.junit.Ignore; -import org.junit.Test; -import org.mockito.Mockito; -import org.openecomp.mso.client.defaultproperties.PolicyRestPropertiesImpl; -import org.openecomp.mso.client.policy.entities.DecisionAttributes; -import org.openecomp.mso.client.policy.entities.DictionaryData; -import org.openecomp.mso.client.policy.entities.PolicyDecision; -import org.openecomp.mso.client.policy.entities.PolicyServiceType; - -public class PolicyClientImplTest { - - @Test - public void successReadProperties() { - PolicyRestClient client = new PolicyRestClient(new PolicyRestPropertiesImpl(), PolicyServiceType.GET_DECISION); - client.initializeHeaderMap(client.headerMap); - - assertEquals("Found expected Client Auth", client.headerMap.get("ClientAuth"), - "Basic bTAzNzQzOnBvbGljeVIwY2sk"); - assertEquals("Found expected Authorization", client.headerMap.get("Authorization"), - "Basic dGVzdHBkcDphbHBoYTEyMw=="); - assertEquals("Found expected Environment", client.headerMap.get("Environment"), "TEST"); - assertEquals("Has X-ECOMP-RequestID", client.headerMap.containsKey("X-ECOMP-RequestID"), true); - } - - @Test - public void getDecisionMockTest() { - String serviceType = "S"; - String vnfType = "V"; - String bbID = "BB1"; - String workStep = "1"; - String errorCode = "123"; - - PolicyDecision expected = new PolicyDecision(); - expected.setDecision("PERMIT"); - expected.setDetails("Retry"); - - DecisionAttributes decisionAttributes = new DecisionAttributes(); - decisionAttributes.setServiceType(serviceType); - decisionAttributes.setVNFType(vnfType); - decisionAttributes.setBBID(bbID); - decisionAttributes.setWorkStep(workStep); - decisionAttributes.setErrorCode(errorCode); - PolicyClient client = Mockito.spy(PolicyClientImpl.class); - - doReturn(expected).when(client).getDecision(serviceType, vnfType, bbID, workStep, errorCode); - - PolicyDecision actual = client.getDecision(serviceType, vnfType, bbID, workStep, errorCode); - assertThat(actual, sameBeanAs(expected)); - } - - @Test - @Ignore - public void getDecisionTest() { - PolicyClient client = new PolicyClientImpl(); - PolicyDecision decision = client.getDecision("S", "V", "BB1", "1", "123"); - assertEquals("Decision is correct", decision.getDecision(), "PERMIT"); - assertEquals("Decision details is correct", decision.getDetails(), "Retry"); - } - - @Test - @Ignore - public void getAllowedTreatmentsTest() { - PolicyClient client = new PolicyClientImpl(); - DictionaryData dictClient = client.getAllowedTreatments("BB1", "1"); - final String dictBbidString = dictClient.getBbid().getString(); - final String dictWorkStepString = dictClient.getWorkstep().getString(); - assertEquals("DictionaryData matches a response Bbid", dictBbidString, "BB1"); - assertEquals("DicitonaryData matches a response WorkStep", dictWorkStepString, "1"); - } - /* - * @Test public void getAllowedTreatmentsTest() { PolicyClient client = new - * PolicyClientImpl(); AllowedTreatments allowedTreatments = - * client.getAllowedTreatments("BB1", "1"); int expectedSizeOfList = 4; int - * sizeOfList = allowedTreatments.getAllowedTreatments().size(); - * assertEquals("Decision is correct", sizeOfList, expectedSizeOfList); } - */ -} diff --git a/common/src/test/java/org/openecomp/mso/client/policy/entities/PolicyEntitiesTest.java b/common/src/test/java/org/openecomp/mso/client/policy/entities/PolicyEntitiesTest.java deleted file mode 100644 index f526e10249..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/policy/entities/PolicyEntitiesTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.policy.entities; - -import org.junit.Test; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterEnum; -import com.openpojo.reflection.filters.FilterPackageInfo; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - -public class PolicyEntitiesTest { - - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - @Test - public void pojoStructure() { - test("org.openecomp.mso.client.policy.entities"); - } - - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new SetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); - } - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/ruby/RubyCheckClientTest.java b/common/src/test/java/org/openecomp/mso/client/ruby/RubyCheckClientTest.java deleted file mode 100644 index 053f1f2533..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/ruby/RubyCheckClientTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.ruby; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.text.ParseException; -import java.time.format.DateTimeFormatter; - -import org.junit.Test; -import org.openecomp.mso.client.ruby.beans.Ruby; - -import static org.apache.commons.lang3.StringUtils.*; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class RubyCheckClientTest { - private final String fileLocation = "src/test/resources/org/openecomp/mso/client/ruby/create-ticket/"; - private static final String REQUEST_ID = "abc123"; - private static final String SOURCE_NAME = "source-name"; - private static final String TIME = "test-time"; - private static final String REASON = "reason"; - private static final String WORK_FLOW_ID = "work-flow-Id"; - private static final String NOTIFICATION = "notification"; - - - - @Test - public void verifyRubyCreateTicketRequest() throws IOException, ParseException{ - String content = this.getJson("create-ticket-request.json"); - ObjectMapper mapper = new ObjectMapper(); - Ruby expected = mapper.readValue(content, Ruby.class); - RubyClient client = new RubyClient(); - RubyClient spy = spy(client); - when(spy.getTime()).thenReturn(TIME); - String actual = spy.buildRequest(REQUEST_ID, SOURCE_NAME, REASON, WORK_FLOW_ID, NOTIFICATION); - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - } - - - @Test - public void verifyTimeFormat() { - RubyClient client = new RubyClient(); - String time = client.getTime(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss Z"); - formatter.parse(time); - } - - - @Test - public void verifyReasonCharLimit() throws IOException{ - final String reasonLong = repeat("*", 256); - RubyClient client = new RubyClient(); - try{ - client.buildRequest(REQUEST_ID, SOURCE_NAME, reasonLong, WORK_FLOW_ID, NOTIFICATION); - fail("Should have thrown IllegalArgumentException but did not!"); - } - catch(final IllegalArgumentException e){ - final String msg = "reason exceeds 255 characters"; - assertEquals(msg, e.getMessage()); - } - } - - @Test - public void verifyNotificationCharLimit() throws IOException{ - final String notificationLong = repeat("*", 1025); - RubyClient client = new RubyClient(); - try{ - client.buildRequest(REQUEST_ID, SOURCE_NAME, REASON, WORK_FLOW_ID, notificationLong); - fail("Should have thrown IllegalArgumentException but did not!"); - } - catch(final IllegalArgumentException e){ - final String msg = "notification exceeds 1024 characters"; - assertEquals(msg, e.getMessage()); - } - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); - } - -} - diff --git a/common/src/test/java/org/openecomp/mso/client/ruby/beans/RubyBeansTest.java b/common/src/test/java/org/openecomp/mso/client/ruby/beans/RubyBeansTest.java deleted file mode 100644 index 90e1861292..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/ruby/beans/RubyBeansTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.ruby.beans; - -import org.junit.Test; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterEnum; -import com.openpojo.reflection.filters.FilterPackageInfo; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - -public class RubyBeansTest { - - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - @Test - public void pojoStructure() { - test("org.openecomp.mso.client.ruby.beans"); - } - - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new SetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); - } - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClientTest.java b/common/src/test/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClientTest.java deleted file mode 100644 index 6c64d90ff4..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClientTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Optional; - -import org.junit.Test; -import org.openecomp.mso.client.sdno.beans.SDNO; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public class SDNOHealthCheckClientTest { - - - - private final String fileLocation = "src/test/resources/org/openecomp/mso/client/sdno/health-check/"; - private static final String userId = "test-user"; - private static final Optional clliCode = Optional.of("test-clli"); - private static final String requestId = "test-request-id"; - private static final String configurationId = "test-configuration-id"; - private static final String interfaceId = "test-interface-id"; - - @Test - public void verfyLPortMirrorPreCheckRequest() throws IOException{ - String content = this.getJson("custom-lport-mirror-pre-check-request.json"); - ObjectMapper mapper = new ObjectMapper(); - SDNO expected = mapper.readValue(content, SDNO.class); - SDNOHealthCheckClient client = new SDNOHealthCheckClient(); - String actual = client.buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId); - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - } - - @Test - public void verfyLPortMirrorPostCheckRequest() throws IOException{ - String content = this.getJson("custom-lport-mirror-post-check-request.json"); - ObjectMapper mapper = new ObjectMapper(); - SDNO expected = mapper.readValue(content, SDNO.class); - SDNOHealthCheckClient client = new SDNOHealthCheckClient(); - String actual = client.buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId); - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - } - - - @Test - public void verifyPortMirrorPostCheckRequest() throws IOException{ - String content = this.getJson("custom-port-mirror-post-check-request.json"); - ObjectMapper mapper = new ObjectMapper(); - SDNO expected = mapper.readValue(content, SDNO.class); - SDNOHealthCheckClient client = new SDNOHealthCheckClient(); - String actual = client.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId); - - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - - } - @Test - public void verifyPortMirrorPreCheckRequest() throws IOException { - String content = this.getJson("custom-port-mirror-pre-check-request.json"); - ObjectMapper mapper = new ObjectMapper(); - SDNO expected = mapper.readValue(content, SDNO.class); - SDNOHealthCheckClient client = new SDNOHealthCheckClient(); - String actual = client.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId); - - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); - } - -} diff --git a/common/src/test/java/org/openecomp/mso/client/sdno/SDNOValidatorTest.java b/common/src/test/java/org/openecomp/mso/client/sdno/SDNOValidatorTest.java deleted file mode 100644 index cd84e7854d..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/sdno/SDNOValidatorTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.UUID; - -import org.hamcrest.core.StringContains; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.Spy; -import org.onap.aai.domain.yang.GenericVnf; -import org.openecomp.mso.client.dmaap.Consumer; -import org.openecomp.mso.client.dmaap.exceptions.DMaaPConsumerFailure; -import org.openecomp.mso.client.exceptions.SDNOException; -import org.openecomp.mso.client.sdno.beans.SDNO; -import org.openecomp.mso.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; - -import com.fasterxml.jackson.databind.ObjectMapper; - - -public class SDNOValidatorTest { - - - @Mock private Consumer mrConsumer; - @Spy private SDNOHealthCheckDmaapConsumer dmaapConsumer; - private final String fileLocation = "src/test/resources/org/openecomp/mso/client/sdno/"; - private final String uuid = "xyz123"; - @Rule public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUpTests() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void success() throws IOException, Exception { - when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer); - when(mrConsumer.fetch()).thenReturn(Arrays.asList(new String[]{getJson("response.json"), getJson("output-success.json")})); - - SDNOValidatorImpl validator = new SDNOValidatorImpl(); - SDNOValidatorImpl spy = spy(validator); - when(dmaapConsumer.getRequestId()).thenReturn("xyz123"); - doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class)); - boolean result = spy.pollForResponse("xyz123"); - assertEquals("result is true", result, true); - } - - @Test - public void failure() throws IOException, Exception { - when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer); - when(mrConsumer.fetch()).thenReturn(Arrays.asList(new String[]{getJson("response.json"), getJson("output-failure.json")})); - - SDNOValidatorImpl validator = new SDNOValidatorImpl(); - SDNOValidatorImpl spy = spy(validator); - when(dmaapConsumer.getRequestId()).thenReturn("xyz123"); - doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class)); - thrown.expect(SDNOException.class); - thrown.expectMessage(new StringContains("my error message")); - boolean result = spy.pollForResponse("xyz123"); - - } - @Ignore - @Test - public void run() throws Exception { - SDNOValidatorImpl validator = new SDNOValidatorImpl(); - UUID uuid = UUID.randomUUID(); - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("test"); - vnf.setIpv4OamAddress("1.2.3.4"); - vnf.setVnfType("VPE"); - SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid"); - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(request); - validator.submitRequest(json); - thrown.expect(DMaaPConsumerFailure.class); - boolean result = validator.pollForResponse(uuid.toString()); - System.out.println(json); - - } - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); - } -} diff --git a/common/src/test/java/org/openecomp/mso/client/sdno/beans/SdnoBeansTest.java b/common/src/test/java/org/openecomp/mso/client/sdno/beans/SdnoBeansTest.java deleted file mode 100644 index 4a2580f3f1..0000000000 --- a/common/src/test/java/org/openecomp/mso/client/sdno/beans/SdnoBeansTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.client.sdno.beans; - -import org.junit.Test; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterEnum; -import com.openpojo.reflection.filters.FilterPackageInfo; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - -public class SdnoBeansTest { - - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - @Test - public void pojoStructure() { - test("org.openecomp.mso.client.sdno.beans"); - } - - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new SetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); - } - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } -} diff --git a/common/src/test/java/org/openecomp/mso/entity/MsoRequestTest.java b/common/src/test/java/org/openecomp/mso/entity/MsoRequestTest.java deleted file mode 100644 index a7fc7e223e..0000000000 --- a/common/src/test/java/org/openecomp/mso/entity/MsoRequestTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.entity; - -import org.junit.Test; -import org.openecomp.mso.openpojo.rules.HasToStringRule; -import org.openecomp.mso.openpojo.rules.ToStringTester; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterEnum; -import com.openpojo.reflection.filters.FilterPackageInfo; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - - -public class MsoRequestTest { - - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - @Test - public void pojoStructure() { - test("org.openecomp.mso.entity"); - } - - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new SetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); - } - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } - -} - diff --git a/common/src/test/java/org/openecomp/mso/jsonpath/JsonPathUtilTest.java b/common/src/test/java/org/openecomp/mso/jsonpath/JsonPathUtilTest.java deleted file mode 100644 index 85bb8b6804..0000000000 --- a/common/src/test/java/org/openecomp/mso/jsonpath/JsonPathUtilTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.jsonpath; - -import static org.junit.Assert.assertEquals; - -import java.util.Optional; - -import org.junit.Test; - -public class JsonPathUtilTest { - - private static final String json = "{\"test\" : \"hello\", \"test2\" : {\"nested\" : \"value\"}}"; - @Test - public void pathExistsTest() { - assertEquals("test is found", JsonPathUtil.getInstance().pathExists(json, "$.test"), true); - assertEquals("nothing is not found", JsonPathUtil.getInstance().pathExists(json, "$.nothing"), false); - } - - @Test - public void locateResultTest() { - assertEquals("value of hello is found", Optional.of("hello"), JsonPathUtil.getInstance().locateResult(json, "$.test")); - assertEquals("nothing returns empty", Optional.empty(), JsonPathUtil.getInstance().locateResult(json, "$.nothing")); - } - - @Test - public void simpleAndComplexValues() { - assertEquals("json doc found", Optional.of("{\"nested\":\"value\"}"), JsonPathUtil.getInstance().locateResult(json, "$.test2")); - assertEquals("value found", Optional.of("value"), JsonPathUtil.getInstance().locateResult(json, "$.test2.nested")); - } -} \ No newline at end of file diff --git a/common/src/test/java/org/openecomp/mso/serviceinstancebeans/ServiceInstanceBeansTest.java b/common/src/test/java/org/openecomp/mso/serviceinstancebeans/ServiceInstanceBeansTest.java deleted file mode 100644 index f0853305ee..0000000000 --- a/common/src/test/java/org/openecomp/mso/serviceinstancebeans/ServiceInstanceBeansTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import org.junit.Test; -import org.openecomp.mso.openpojo.rules.HasToStringRule; -import org.openecomp.mso.openpojo.rules.ToStringTester; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterEnum; -import com.openpojo.reflection.filters.FilterPackageInfo; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - -public class ServiceInstanceBeansTest { - - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - @Test - public void pojoStructure() { - test("org.openecomp.mso.serviceinstancebeans"); - } - - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new SetterMustExistRule()) - .with(new HasToStringRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .with(new ToStringTester()) - .build(); - validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); - } - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } - -} diff --git a/common/src/test/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesRequestTest.java b/common/src/test/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesRequestTest.java deleted file mode 100644 index 28cbe799cd..0000000000 --- a/common/src/test/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesRequestTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.serviceinstancebeans; - -import org.junit.Assert; -import org.junit.Test; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ServiceInstancesRequestTest { - - @Test - public void serializeServiceInstance() { - String incomingRequest = "{\"requestDetails\":{\"modelInfo\":{\"modelInvariantUuid\":\"9647dfc4-2083-11e7-93ae-92361f002672\",\"modelType\":\"configuration\",\"modelName\":\"MSO-Configuration\",\"modelVersion\":\"1.0\",\"modelUuid\":\"36a3a8ea-49a6-4ac8-b06c-89a545444455\",\"modelCustomizationUuid\":\"68dc9a92-214c-11e7-93ae-92361f002671\"},\"requestInfo\":{\"source\":\"VID\",\"instanceName\":\"port_mirror_config_m830-01\",\"suppressRollback\":false,\"requestorId\":\"mdg1215\"},\"relatedInstanceList\":[{\"relatedInstance\":{\"instanceId\":\"956121e0-542d-4b30-b8c7-be611e3c8f13\",\"modelInfo\":{\"modelInvariantUuid\":\"9647dfc4-2083-11e7-93ae-92361f002671\",\"modelType\":\"service\",\"modelName\":\"MSOTADevInfra_vSAMP10a_Service\",\"modelVersion\":\"1.0\",\"modelUuid\":\"5df8b6de-2083-11e7-93ae-92361f002671\"}}},{\"relatedInstance\":{\"instanceId\":\"956121e0-542d-4b30-b8c7-be611e3c8f11\",\"modelInfo\":{\"modelInvariantUuid\":\"36a3a8ea-49a6-4ac8-b06c-89a545444456\",\"modelType\":\"vnf\",\"modelName\":\"testvnf\",\"modelVersion\":\"1.0\",\"modelUuid\":\"956121e0-542d-4b30-b8c7-be611e3c8f14\",\"modelCustomizationUuid\":\"68dc9a92-214c-11e7-93ae-92361f002676\"},\"instanceDirection\":\"source\"}},{\"relatedInstance\":{\"instanceId\":\"956121e0-542d-4b30-b8c7-be611e3c8f12\",\"modelInfo\":{\"modelInvariantUuid\":\"36a3a8ea-49a6-4ac8-b06c-89a545444477\",\"modelType\":\"vnf\",\"modelName\":\"svProbe vnf model name\",\"modelVersion\":\"1.0\",\"modelUuid\":\"36a3a8ea-49a6-4ac8-b06c-89a545444488\",\"modelCustomizationUuid\":\"68dc9a92-214c-11e7-93ae-92361f002672\"},\"instanceDirection\":\"destination\"}}],\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\"},\"requestParameters\":{\"subscriptionServiceType\":\"MSO-dev-service-type\",\"userParams\":[{\"name\":\"someUserParam\",\"value\":\"someValue\"}],\"aLaCarte\":false,\"autoBuildVfModules\":false,\"cascadeDelete\":false,\"usePreload\":true,\"rebuildVolumeGroups\":false}},\"serviceInstanceId\":\"956121e0-542d-4b30-b8c7-be611e3c8f13\"}"; - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - try { - ServiceInstancesRequest request = mapper.readValue(incomingRequest, ServiceInstancesRequest.class); - System.out.println("Java Object: " + request); - } catch (Exception e) { - System.out.println("Caught Exception " + e.getMessage()); - Assert.fail("Caught error on object serialization"); - } - } -} diff --git a/common/src/test/java/org/openecomp/mso/utils/CheckResultsTest.java b/common/src/test/java/org/openecomp/mso/utils/CheckResultsTest.java deleted file mode 100644 index eeb7342d50..0000000000 --- a/common/src/test/java/org/openecomp/mso/utils/CheckResultsTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.utils; - -import java.util.List; - -import org.junit.Test; - -import org.openecomp.mso.utils.CheckResults.CheckResult; - -public class CheckResultsTest { - - /** - * Test method for {@link org.openecomp.mso.utils.CheckResults#getResults()}. - */ - @Test - public final void testGetResults () { - CheckResults cr = new CheckResults (); - cr.addHostCheckResult ("host1", 0, "output"); - cr.addHostCheckResult ("host2", 2, "output2"); - cr.addServiceCheckResult ("host1", "service1", 0, "outputServ"); - cr.addServiceCheckResult ("host1", "service2", 2, "outputServ2"); - cr.addServiceCheckResult ("host2", "service1", 0, "output2Serv"); - cr.addServiceCheckResult ("host2", "service2", 2, "output2Serv2"); - List res = cr.getResults (); - assert(res.size () == 6); - assert(res.get (0).getHostname ().equals ("host1")); - assert(res.get (1).getHostname ().equals ("host2")); - assert(res.get (2).getHostname ().equals ("host1")); - assert(res.get (3).getHostname ().equals ("host1")); - assert(res.get (4).getHostname ().equals ("host2")); - assert(res.get (5).getHostname ().equals ("host2")); - assert(res.get (0).getServicename () == null); - assert(res.get (3).getServicename ().equals ("service2")); - assert(res.get (5).getState () == 2); - } - -} diff --git a/common/src/test/java/org/openecomp/mso/utils/RootIgnoringObjectMapperTest.java b/common/src/test/java/org/openecomp/mso/utils/RootIgnoringObjectMapperTest.java deleted file mode 100644 index 1c7e845f16..0000000000 --- a/common/src/test/java/org/openecomp/mso/utils/RootIgnoringObjectMapperTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.utils; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class RootIgnoringObjectMapperTest { - - @Test - public void someObjectWithoutRootTest() throws Exception { - ObjectMapper mapper = new RootIgnoringObjectMapper(SomeObject.class); - - String content = "{" - + "\"attribute\":\"charm\"" - + "}"; - - SomeObject response = mapper.readValue(content, SomeObject.class); - assertEquals("SomeObject[attribute=charm]", response.toString()); - } - - @Test - public void someObjectWithRootTest() throws Exception { - ObjectMapper mapper = new RootIgnoringObjectMapper(SomeObject.class); - - String content = "{\"SomeObject\":{" - + "\"attribute\":\"charm\"" - + "}}"; - - SomeObject response = mapper.readValue(content, SomeObject.class); - assertEquals("SomeObject[attribute=charm]", response.toString()); - } - - @Test - public void annotatedObjectWithoutRootTest() throws Exception { - ObjectMapper mapper = new RootIgnoringObjectMapper(AnnotatedObject.class); - - String content = "{" - + "\"attribute\":\"charm\"" - + "}"; - - AnnotatedObject response = mapper.readValue(content, AnnotatedObject.class); - assertEquals("AnnotatedObject[attribute=charm]", response.toString()); - } - - @Test - public void annotatedObjectWithRootTest() throws Exception { - ObjectMapper mapper = new RootIgnoringObjectMapper(AnnotatedObject.class); - - String content = "{\"annotated-object\":{" - + "\"attribute\":\"charm\"" - + "}}"; - - AnnotatedObject response = mapper.readValue(content, AnnotatedObject.class); - assertEquals("AnnotatedObject[attribute=charm]", response.toString()); - } - - public static class SomeObject { - - @JsonProperty("attribute") - private String attribute; - - public String toString() { - return getClass().getSimpleName() + "[attribute=" + attribute + "]"; - } - } - - @JsonRootName(value = "annotated-object") - public static class AnnotatedObject extends SomeObject { - } -} \ No newline at end of file diff --git a/common/src/test/java/org/openecomp/mso/utils/UUIDCheckerTest.java b/common/src/test/java/org/openecomp/mso/utils/UUIDCheckerTest.java deleted file mode 100644 index fa00246e8b..0000000000 --- a/common/src/test/java/org/openecomp/mso/utils/UUIDCheckerTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.utils; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.openecomp.mso.logger.MsoLogger; - -public class UUIDCheckerTest { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); - - @Test - public void testUUIDChecker() throws Exception { - boolean isValidUUID = UUIDChecker.isValidUUID("invalid-uuid"); - assertEquals(false, isValidUUID); - String validUUID = UUIDChecker.verifyOldUUID("invalid-uuid", LOGGER); - assertEquals(true, UUIDChecker.isValidUUID(validUUID)); - String generatedUUID = UUIDChecker.generateUUID(LOGGER); - assertEquals(true, UUIDChecker.isValidUUID(generatedUUID)); - String generatedServiceInstanceId = UUIDChecker.generateServiceInstanceID(LOGGER); - assertEquals(true, UUIDChecker.isValidUUID(generatedServiceInstanceId)); - } - -} diff --git a/common/src/test/resources/__files/aai/bulkprocess/test-request-small.json b/common/src/test/resources/__files/aai/bulkprocess/test-request-small.json new file mode 100644 index 0000000000..973928108f --- /dev/null +++ b/common/src/test/resources/__files/aai/bulkprocess/test-request-small.json @@ -0,0 +1,10 @@ +{ + "transactions" : [ { + "put" : [ { + "uri" : "/network/generic-vnfs/generic-vnf/test1/relationship-list/relationship", + "body" : { + "related-link" : "/cloud-infrastructure/pservers/pserver/test2" + } + } ] + } ] +} \ No newline at end of file diff --git a/common/src/test/resources/__files/aai/resources/e2e-complex.json b/common/src/test/resources/__files/aai/resources/e2e-complex.json index 6fc9cb36e6..21bacbd5ce 100644 --- a/common/src/test/resources/__files/aai/resources/e2e-complex.json +++ b/common/src/test/resources/__files/aai/resources/e2e-complex.json @@ -24,7 +24,7 @@ "relationship": [ { "related-to": "vpls-pe", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vpls-pes/vpls-pe/sfcca301vr1", + "related-link": "https://localhost:8443/aai/v9/network/vpls-pes/vpls-pe/sfcca301vr1", "relationship-data": [ { "relationship-key": "vpls-pe.equipment-name", @@ -48,7 +48,7 @@ "relationship": [ { "related-to": "vce", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053", + "related-link": "https://localhost:8443/aai/v9/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053", "relationship-data": [ { "relationship-key": "vce.vnf-id", @@ -64,7 +64,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj104snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj104snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -79,7 +79,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj105snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj105snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -94,7 +94,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/compute_host", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/compute_host", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -109,7 +109,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj106snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj106snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -124,7 +124,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj126sd9", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj126sd9", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -139,7 +139,7 @@ }, { "related-to": "vce", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/8ae1e5f8-61f1-4c71-913a-b40cc4593cb9", + "related-link": "https://localhost:8443/aai/v9/network/vces/vce/8ae1e5f8-61f1-4c71-913a-b40cc4593cb9", "relationship-data": [ { "relationship-key": "vce.vnf-id", @@ -155,7 +155,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj102sta", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj102sta", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -170,7 +170,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnjtax102", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnjtax102", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -185,7 +185,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj107snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj107snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -200,7 +200,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj118snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj118snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -215,7 +215,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj110snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj110snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -230,7 +230,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj109snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj109snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -245,7 +245,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj114snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj114snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -260,7 +260,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj119snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj119snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -275,7 +275,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj116snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj116snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -290,7 +290,7 @@ }, { "related-to": "vce", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/a2935fa9-b743-49f4-9813-a127f13c4e93", + "related-link": "https://localhost:8443/aai/v9/network/vces/vce/a2935fa9-b743-49f4-9813-a127f13c4e93", "relationship-data": [ { "relationship-key": "vce.vnf-id", @@ -306,7 +306,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj108snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj108snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -321,7 +321,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj123sd9", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj123sd9", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -336,7 +336,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj101snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj101snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -351,7 +351,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj102snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj102snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -366,7 +366,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnjtax101", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnjtax101", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -381,7 +381,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj113snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj113snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -396,7 +396,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj111snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj111snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -411,7 +411,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj103snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj103snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -426,7 +426,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj117snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj117snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -441,7 +441,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj101sta", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj101sta", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -456,7 +456,7 @@ }, { "related-to": "vce", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/c7fe7698-8063-4e26-8bd3-ca3edde0b0d4", + "related-link": "https://localhost:8443/aai/v9/network/vces/vce/c7fe7698-8063-4e26-8bd3-ca3edde0b0d4", "relationship-data": [ { "relationship-key": "vce.vnf-id", @@ -472,7 +472,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj120snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj120snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -487,7 +487,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj124sd9", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj124sd9", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -502,7 +502,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj125sd9", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj125sd9", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -517,7 +517,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj112snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj112snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -532,7 +532,7 @@ }, { "related-to": "pserver", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj115snd", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj115snd", "relationship-data": [ { "relationship-key": "pserver.hostname", @@ -547,7 +547,7 @@ }, { "related-to": "cloud-region", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtcnj2", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtcnj2", "relationship-data": [ { "relationship-key": "cloud-region.cloud-owner", @@ -567,7 +567,7 @@ }, { "related-to": "oam-network", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/oam-networks/oam-network/f9263cat-4eaa-43a0-bea4-adcf6e123456", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/oam-networks/oam-network/f9263cat-4eaa-43a0-bea4-adcf6e123456", "relationship-data": [ { "relationship-key": "cloud-region.cloud-owner", @@ -591,7 +591,7 @@ }, { "related-to": "oam-network", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/oam-networks/oam-network/b9263fab-4eaa-43a0-bea4-adcf6e999999", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/oam-networks/oam-network/b9263fab-4eaa-43a0-bea4-adcf6e999999", "relationship-data": [ { "relationship-key": "cloud-region.cloud-owner", @@ -615,7 +615,7 @@ }, { "related-to": "oam-network", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/oam-networks/oam-network/cf33dc95-c5d2-48fd-8078-fd949363f63b", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/oam-networks/oam-network/cf33dc95-c5d2-48fd-8078-fd949363f63b", "relationship-data": [ { "relationship-key": "cloud-region.cloud-owner", @@ -639,7 +639,7 @@ }, { "related-to": "availability-zone", - "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/availability-zones/availability-zone/mtcnj-esx-az01", + "related-link": "https://localhost:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/availability-zones/availability-zone/mtcnj-esx-az01", "relationship-data": [ { "relationship-key": "cloud-region.cloud-owner", diff --git a/common/src/test/resources/__files/aai/resources/service-instance-pathed-query.json b/common/src/test/resources/__files/aai/resources/service-instance-pathed-query.json index 6ec513e4bb..0fa9515820 100644 --- a/common/src/test/resources/__files/aai/resources/service-instance-pathed-query.json +++ b/common/src/test/resources/__files/aai/resources/service-instance-pathed-query.json @@ -2,7 +2,7 @@ "results": [ { "resource-type": "service-instance", - "resource-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3" + "resource-link": "https://localhost:8443/aai/v9/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3" } ] } \ No newline at end of file diff --git a/common/src/test/resources/__files/grm/endpoints.json b/common/src/test/resources/__files/grm/endpoints.json index 20947540b4..7e92c21c9e 100644 --- a/common/src/test/resources/__files/grm/endpoints.json +++ b/common/src/test/resources/__files/grm/endpoints.json @@ -7,7 +7,7 @@ "minor": 0, "patch": "0" }, - "hostAddress": "135.144.120.218", + "hostAddress": "192.168.120.218", "listenPort": "32004", "latitude": "37.7022", "longitude": "121.9358", @@ -54,7 +54,7 @@ "minor": 0, "patch": "0" }, - "hostAddress": "135.144.120.22", + "hostAddress": "192.168.120.22", "listenPort": "32004", "latitude": "1.0", "longitude": "1.0", @@ -101,7 +101,7 @@ "minor": 0, "patch": "0" }, - "hostAddress": "135.144.120.218", + "hostAddress": "192.168.120.218", "listenPort": "32002", "latitude": "1.0", "longitude": "1.0", diff --git a/common/src/test/resources/dmaap.properties b/common/src/test/resources/dmaap.properties index 8adb8e4976..7ce101996c 100644 --- a/common/src/test/resources/dmaap.properties +++ b/common/src/test/resources/dmaap.properties @@ -1,7 +1,7 @@ -sdno.health-check.dmaap.username=m04768@mso.ecomp.att.com +sdno.health-check.dmaap.username=testuser sdno.health-check.dmaap.password=eHQ1cUJrOUc sdno.health-check.dmaap.subscriber.topic=com.att.sdno.test-health-diagnostic-v02 sdno.health-check.dmaap.publisher.topic=com.att.sdno.test-health-diagnostic-v02 -ruby.create-ticket-request.dmaap.username=m04768@mso.ecomp.att.com +ruby.create-ticket-request.dmaap.username=testuser ruby.create-ticket-request.dmaap.password=eHQ1cUJrOUc ruby.create-ticket-request.publisher.topic=com.att.pdas.st1.msoCMFallout-v1 \ No newline at end of file diff --git a/common/src/test/resources/logback-test.xml b/common/src/test/resources/logback-test.xml index b1888ac986..c4248bf985 100644 --- a/common/src/test/resources/logback-test.xml +++ b/common/src/test/resources/logback-test.xml @@ -21,6 +21,7 @@ + @@ -44,15 +45,8 @@ - - - - - - ${defaultPattern} - - + @@ -148,24 +142,35 @@ true - + + + %d{HH:mm:ss.SSS} [%thread] |%X{RequestId}| %-5level + %logger{1024} - %msg%n + + + + - - + + - - + + + - + - - + + + + - + + \ No newline at end of file diff --git a/common/src/test/resources/mso-bad.json b/common/src/test/resources/mso-bad.json index 57b271459e..1aaea50042 100644 --- a/common/src/test/resources/mso-bad.json +++ b/common/src/test/resources/mso-bad.json @@ -1,20 +1,20 @@ { - "asdc-connections":{, - "asdc-controller1":{ - "asdcUser": "user1", - "asdcConsumerGroup": "consumer1", - "asdcConsumerId": "consumer1", - "asdcEnvironmentName": "PROD", - "asdcAddress": "localhost:8443", - "asdcPassword": "1c551b8b5ab91fcd5a0907b11c304199" - }, - "asdc-controller2":{ - "asdcUser": "user2", - "asdcConsumerGroup": "consumer2", - "asdcConsumerId": "consumer2", - "asdcEnvironmentName": "E2E", - "asdcAddress": "localhost:8443", - "asdcPassword": "1c551b8b5ab91fcd5a0907b11c304199" - } - } -} + "asdc-connections": { + "asdc-controller1": { + "asdcUser": "user1", + "asdcConsumerGroup": "consumer1", + "asdcConsumerId": "consumer1", + "asdcEnvironmentName": "PROD", + "asdcAddress": "localhost:8443", + "asdcPassword": "1c551b8b5ab91fcd5a0907b11c304199" + }, + "asdc-controller2": { + "asdcUser": "user2", + "asdcConsumerGroup": "consumer2", + "asdcConsumerId": "consumer2", + "asdcEnvironmentName": "E2E", + "asdcAddress": "localhost:8443", + "asdcPassword": "1c551b8b5ab91fcd5a0907b11c304199" + } + } +} \ No newline at end of file diff --git a/common/src/test/resources/org/onap/so/client/ruby/create-ticket/create-ticket-request.json b/common/src/test/resources/org/onap/so/client/ruby/create-ticket/create-ticket-request.json new file mode 100644 index 0000000000..e388d3e9ad --- /dev/null +++ b/common/src/test/resources/org/onap/so/client/ruby/create-ticket/create-ticket-request.json @@ -0,0 +1,15 @@ +{ + "event": { + "msoRequest": { + "requestClientName": "MSO", + "requestId": "abc123", + "requestTime": "test-time", + "sourceName": "source-name", + "reason": "reason", + "action": "Create Ticket", + "workflowId": "work-flow-Id", + "notification": "notification" + } +} +} + diff --git a/common/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json b/common/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json new file mode 100644 index 0000000000..2c46b5a8cb --- /dev/null +++ b/common/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json @@ -0,0 +1,27 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000004", + "operation-type": "lport_mirroring_check", + "send-detailed-cmd-response": "false", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + }, + { + "key": "interface-id", + "value": "test-interface-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} \ No newline at end of file diff --git a/common/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json b/common/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json new file mode 100644 index 0000000000..bf168b0028 --- /dev/null +++ b/common/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json @@ -0,0 +1,27 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000003", + "operation-type": "lport_mirroring_check", + "send-detailed-cmd-response": "false", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + }, + { + "key": "interface-id", + "value": "test-interface-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} \ No newline at end of file diff --git a/common/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json b/common/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json new file mode 100644 index 0000000000..89e505e7d0 --- /dev/null +++ b/common/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json @@ -0,0 +1,23 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000004", + "operation-type": "mirroring_check", + "send-detailed-cmd-response": "false", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} \ No newline at end of file diff --git a/common/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json b/common/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json new file mode 100644 index 0000000000..86897c8a1f --- /dev/null +++ b/common/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json @@ -0,0 +1,23 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000003", + "operation-type": "mirroring_check", + "send-detailed-cmd-response": "false", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} diff --git a/common/src/test/resources/org/onap/so/client/sdno/output-failure.json b/common/src/test/resources/org/onap/so/client/sdno/output-failure.json new file mode 100644 index 0000000000..8cf0a820cd --- /dev/null +++ b/common/src/test/resources/org/onap/so/client/sdno/output-failure.json @@ -0,0 +1,25 @@ +{ + "body": { + "output": { + "response-hd-custom": { + "response-status": "Failure", + "cached-data": "false", + "response-interface-type": "ansible", + "response-id": "191bf423-8473-4f7c-9fbb-e5dcbb40a12b", + "remote_end_time": "2017-10-13T14:51:53.490+0000", + "response-client-name": "MSO", + "user_id": "xxxxxx", + "remote_start_time": "2017-10-13T14:51:53.173+0000", + "error-message": "my error message", + "connection-failure-msg": "SDNO was unable to connect to an Ansible REST API server; Please ensure Ansible REST server is running" + } + } + }, + "result-info": { + "code": "200", + "status": "SUCCESS", + "request-id": "xyz123", + "client-name": "MSO", + "processing-host": "sdno-sdno-mtsnjv9sdno01" + } +} \ No newline at end of file diff --git a/common/src/test/resources/org/onap/so/client/sdno/output-success.json b/common/src/test/resources/org/onap/so/client/sdno/output-success.json new file mode 100644 index 0000000000..a6794327d8 --- /dev/null +++ b/common/src/test/resources/org/onap/so/client/sdno/output-success.json @@ -0,0 +1,22 @@ +{ + "body": { + "output": { + "response-healthdiagnostic": { + "response-node-ip": "192.20.127.76", + "response-id": "xyz123", + "response-node-name": "mtvnjv9aads11", + "response-status": "Success", + "response-interface-type": "ssh", + "response-details-json": "result", + "cached-data": "false" + } + } + }, + "result-info": { + "client-name": "MSO", + "code": "200", + "processing-host": "sdno1-host01", + "request-id": "xyz123", + "status": "SUCCESS" + } +} \ No newline at end of file diff --git a/common/src/test/resources/org/onap/so/client/sdno/response.json b/common/src/test/resources/org/onap/so/client/sdno/response.json new file mode 100644 index 0000000000..2355e86938 --- /dev/null +++ b/common/src/test/resources/org/onap/so/client/sdno/response.json @@ -0,0 +1,17 @@ +{ + + "result-info": { + + "client-name": "MSO", + + "code": "202", + + "processing-host": "sdno1-host01", + + "request-id": "xyz123", + + "status": "ACCEPTED" + + } + +} \ No newline at end of file diff --git a/common/src/test/resources/org/openecomp/mso/client/ruby/create-ticket/create-ticket-request.json b/common/src/test/resources/org/openecomp/mso/client/ruby/create-ticket/create-ticket-request.json deleted file mode 100644 index e388d3e9ad..0000000000 --- a/common/src/test/resources/org/openecomp/mso/client/ruby/create-ticket/create-ticket-request.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "event": { - "msoRequest": { - "requestClientName": "MSO", - "requestId": "abc123", - "requestTime": "test-time", - "sourceName": "source-name", - "reason": "reason", - "action": "Create Ticket", - "workflowId": "work-flow-Id", - "notification": "notification" - } -} -} - diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-post-check-request.json b/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-post-check-request.json deleted file mode 100644 index 8c3ca1938d..0000000000 --- a/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-post-check-request.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "body": { - "input": { - "request-hd-custom": { - "request-client-name": "MSO", - "request-user-id": "test-user", - "request-id": "test-request-id", - "health-diagnostic-code": "VROUTER000004", - "operation-type": "lport_mirroring_check", - "aai-param-list": [ - { - "key": "configuration-id", - "value": "test-configuration-id" - }, - { - "key": "interface-id", - "value": "test-interface-id" - } - ] - } - } - }, - "operation": "health-diagnostic-custom", - "nodeLoc": "test-clli", - "nodeType": "VROUTER" -} \ No newline at end of file diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-pre-check-request.json b/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-pre-check-request.json deleted file mode 100644 index 08220abe2d..0000000000 --- a/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-pre-check-request.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "body": { - "input": { - "request-hd-custom": { - "request-client-name": "MSO", - "request-user-id": "test-user", - "request-id": "test-request-id", - "health-diagnostic-code": "VROUTER000003", - "operation-type": "lport_mirroring_check", - "aai-param-list": [ - { - "key": "configuration-id", - "value": "test-configuration-id" - }, - { - "key": "interface-id", - "value": "test-interface-id" - } - ] - } - } - }, - "operation": "health-diagnostic-custom", - "nodeLoc": "test-clli", - "nodeType": "VROUTER" -} \ No newline at end of file diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-post-check-request.json b/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-post-check-request.json deleted file mode 100644 index 834fcc8e72..0000000000 --- a/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-post-check-request.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "body": { - "input": { - "request-hd-custom": { - "request-client-name": "MSO", - "request-user-id": "test-user", - "request-id": "test-request-id", - "health-diagnostic-code": "VROUTER000004", - "operation-type": "mirroring_check", - "aai-param-list": [ - { - "key": "configuration-id", - "value": "test-configuration-id" - } - ] - } - } - }, - "operation": "health-diagnostic-custom", - "nodeLoc": "test-clli", - "nodeType": "VROUTER" -} \ No newline at end of file diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-pre-check-request.json b/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-pre-check-request.json deleted file mode 100644 index 19d934d291..0000000000 --- a/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-pre-check-request.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "body": { - "input": { - "request-hd-custom": { - "request-client-name": "MSO", - "request-user-id": "test-user", - "request-id": "test-request-id", - "health-diagnostic-code": "VROUTER000003", - "operation-type": "mirroring_check", - "aai-param-list": [ - { - "key": "configuration-id", - "value": "test-configuration-id" - } - ] - } - } - }, - "operation": "health-diagnostic-custom", - "nodeLoc": "test-clli", - "nodeType": "VROUTER" -} diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/output-failure.json b/common/src/test/resources/org/openecomp/mso/client/sdno/output-failure.json deleted file mode 100644 index 15160b9dd9..0000000000 --- a/common/src/test/resources/org/openecomp/mso/client/sdno/output-failure.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "body": { - "output": { - "response-hd-custom": { - "response-status": "Failure", - "cached-data": "false", - "response-interface-type": "ansible", - "response-id": "191bf423-8473-4f7c-9fbb-e5dcbb40a12b", - "remote_end_time": "2017-10-13T14:51:53.490+0000", - "response-client-name": "MSO", - "user_id": "md5621", - "remote_start_time": "2017-10-13T14:51:53.173+0000", - "error-message": "my error message", - "connection-failure-msg": "SDNO was unable to connect to an Ansible REST API server; Please ensure Ansible REST server is running" - } - } - }, - "result-info": { - "code": "200", - "status": "SUCCESS", - "request-id": "xyz123", - "client-name": "MSO", - "processing-host": "sdno-sdno-mtsnjv9sdno01" - } -} \ No newline at end of file diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/output-success.json b/common/src/test/resources/org/openecomp/mso/client/sdno/output-success.json deleted file mode 100644 index a6794327d8..0000000000 --- a/common/src/test/resources/org/openecomp/mso/client/sdno/output-success.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "body": { - "output": { - "response-healthdiagnostic": { - "response-node-ip": "192.20.127.76", - "response-id": "xyz123", - "response-node-name": "mtvnjv9aads11", - "response-status": "Success", - "response-interface-type": "ssh", - "response-details-json": "result", - "cached-data": "false" - } - } - }, - "result-info": { - "client-name": "MSO", - "code": "200", - "processing-host": "sdno1-host01", - "request-id": "xyz123", - "status": "SUCCESS" - } -} \ No newline at end of file diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/response.json b/common/src/test/resources/org/openecomp/mso/client/sdno/response.json deleted file mode 100644 index 2355e86938..0000000000 --- a/common/src/test/resources/org/openecomp/mso/client/sdno/response.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - - "result-info": { - - "client-name": "MSO", - - "code": "202", - - "processing-host": "sdno1-host01", - - "request-id": "xyz123", - - "status": "ACCEPTED" - - } - -} \ No newline at end of file -- cgit 1.2.3-korg